| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 (function() { 2 "use strict"; 3 var wp; 4 (wp ||= {}).blocks = (() => { 5 var __create = Object.create; 6 var __defProp = Object.defineProperty; 7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 8 var __getOwnPropNames = Object.getOwnPropertyNames; 9 var __getProtoOf = Object.getPrototypeOf; 10 var __hasOwnProp = Object.prototype.hasOwnProperty; 11 var __commonJS = (cb, mod) => function __require() { 12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 13 }; 14 var __export = (target, all) => { 15 for (var name in all) 16 __defProp(target, name, { get: all[name], enumerable: true }); 17 }; 18 var __copyProps = (to, from, except, desc) => { 19 if (from && typeof from === "object" || typeof from === "function") { 20 for (let key of __getOwnPropNames(from)) 21 if (!__hasOwnProp.call(to, key) && key !== except) 22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 23 } 24 return to; 25 }; 26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 27 // If the importer is in node compatibility mode or this is not an ESM 28 // file that has been converted to a CommonJS file using a Babel- 29 // compatible transform (i.e. "__esModule" has not been set), then set 30 // "default" to the CommonJS "module.exports" for node compatibility. 31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 32 mod 33 )); 34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 35 36 // package-external:@wordpress/data 37 var require_data = __commonJS({ 38 "package-external:@wordpress/data"(exports, module) { 39 module.exports = window.wp.data; 40 } 41 }); 42 43 // package-external:@wordpress/i18n 44 var require_i18n = __commonJS({ 45 "package-external:@wordpress/i18n"(exports, module) { 46 module.exports = window.wp.i18n; 47 } 48 }); 49 50 // package-external:@wordpress/element 51 var require_element = __commonJS({ 52 "package-external:@wordpress/element"(exports, module) { 53 module.exports = window.wp.element; 54 } 55 }); 56 57 // package-external:@wordpress/dom 58 var require_dom = __commonJS({ 59 "package-external:@wordpress/dom"(exports, module) { 60 module.exports = window.wp.dom; 61 } 62 }); 63 64 // package-external:@wordpress/rich-text 65 var require_rich_text = __commonJS({ 66 "package-external:@wordpress/rich-text"(exports, module) { 67 module.exports = window.wp.richText; 68 } 69 }); 70 71 // package-external:@wordpress/deprecated 72 var require_deprecated = __commonJS({ 73 "package-external:@wordpress/deprecated"(exports, module) { 74 module.exports = window.wp.deprecated; 75 } 76 }); 77 78 // package-external:@wordpress/warning 79 var require_warning = __commonJS({ 80 "package-external:@wordpress/warning"(exports, module) { 81 module.exports = window.wp.warning; 82 } 83 }); 84 85 // package-external:@wordpress/private-apis 86 var require_private_apis = __commonJS({ 87 "package-external:@wordpress/private-apis"(exports, module) { 88 module.exports = window.wp.privateApis; 89 } 90 }); 91 92 // node_modules/.store/remove-accents@0.5.0-S_lnImruWgc6kBSjIJlPgw/node_modules/remove-accents/index.js 93 var require_remove_accents = __commonJS({ 94 "node_modules/.store/remove-accents@0.5.0-S_lnImruWgc6kBSjIJlPgw/node_modules/remove-accents/index.js"(exports, module) { 95 var characterMap = { 96 "\xC0": "A", 97 "\xC1": "A", 98 "\xC2": "A", 99 "\xC3": "A", 100 "\xC4": "A", 101 "\xC5": "A", 102 "\u1EA4": "A", 103 "\u1EAE": "A", 104 "\u1EB2": "A", 105 "\u1EB4": "A", 106 "\u1EB6": "A", 107 "\xC6": "AE", 108 "\u1EA6": "A", 109 "\u1EB0": "A", 110 "\u0202": "A", 111 "\u1EA2": "A", 112 "\u1EA0": "A", 113 "\u1EA8": "A", 114 "\u1EAA": "A", 115 "\u1EAC": "A", 116 "\xC7": "C", 117 "\u1E08": "C", 118 "\xC8": "E", 119 "\xC9": "E", 120 "\xCA": "E", 121 "\xCB": "E", 122 "\u1EBE": "E", 123 "\u1E16": "E", 124 "\u1EC0": "E", 125 "\u1E14": "E", 126 "\u1E1C": "E", 127 "\u0206": "E", 128 "\u1EBA": "E", 129 "\u1EBC": "E", 130 "\u1EB8": "E", 131 "\u1EC2": "E", 132 "\u1EC4": "E", 133 "\u1EC6": "E", 134 "\xCC": "I", 135 "\xCD": "I", 136 "\xCE": "I", 137 "\xCF": "I", 138 "\u1E2E": "I", 139 "\u020A": "I", 140 "\u1EC8": "I", 141 "\u1ECA": "I", 142 "\xD0": "D", 143 "\xD1": "N", 144 "\xD2": "O", 145 "\xD3": "O", 146 "\xD4": "O", 147 "\xD5": "O", 148 "\xD6": "O", 149 "\xD8": "O", 150 "\u1ED0": "O", 151 "\u1E4C": "O", 152 "\u1E52": "O", 153 "\u020E": "O", 154 "\u1ECE": "O", 155 "\u1ECC": "O", 156 "\u1ED4": "O", 157 "\u1ED6": "O", 158 "\u1ED8": "O", 159 "\u1EDC": "O", 160 "\u1EDE": "O", 161 "\u1EE0": "O", 162 "\u1EDA": "O", 163 "\u1EE2": "O", 164 "\xD9": "U", 165 "\xDA": "U", 166 "\xDB": "U", 167 "\xDC": "U", 168 "\u1EE6": "U", 169 "\u1EE4": "U", 170 "\u1EEC": "U", 171 "\u1EEE": "U", 172 "\u1EF0": "U", 173 "\xDD": "Y", 174 "\xE0": "a", 175 "\xE1": "a", 176 "\xE2": "a", 177 "\xE3": "a", 178 "\xE4": "a", 179 "\xE5": "a", 180 "\u1EA5": "a", 181 "\u1EAF": "a", 182 "\u1EB3": "a", 183 "\u1EB5": "a", 184 "\u1EB7": "a", 185 "\xE6": "ae", 186 "\u1EA7": "a", 187 "\u1EB1": "a", 188 "\u0203": "a", 189 "\u1EA3": "a", 190 "\u1EA1": "a", 191 "\u1EA9": "a", 192 "\u1EAB": "a", 193 "\u1EAD": "a", 194 "\xE7": "c", 195 "\u1E09": "c", 196 "\xE8": "e", 197 "\xE9": "e", 198 "\xEA": "e", 199 "\xEB": "e", 200 "\u1EBF": "e", 201 "\u1E17": "e", 202 "\u1EC1": "e", 203 "\u1E15": "e", 204 "\u1E1D": "e", 205 "\u0207": "e", 206 "\u1EBB": "e", 207 "\u1EBD": "e", 208 "\u1EB9": "e", 209 "\u1EC3": "e", 210 "\u1EC5": "e", 211 "\u1EC7": "e", 212 "\xEC": "i", 213 "\xED": "i", 214 "\xEE": "i", 215 "\xEF": "i", 216 "\u1E2F": "i", 217 "\u020B": "i", 218 "\u1EC9": "i", 219 "\u1ECB": "i", 220 "\xF0": "d", 221 "\xF1": "n", 222 "\xF2": "o", 223 "\xF3": "o", 224 "\xF4": "o", 225 "\xF5": "o", 226 "\xF6": "o", 227 "\xF8": "o", 228 "\u1ED1": "o", 229 "\u1E4D": "o", 230 "\u1E53": "o", 231 "\u020F": "o", 232 "\u1ECF": "o", 233 "\u1ECD": "o", 234 "\u1ED5": "o", 235 "\u1ED7": "o", 236 "\u1ED9": "o", 237 "\u1EDD": "o", 238 "\u1EDF": "o", 239 "\u1EE1": "o", 240 "\u1EDB": "o", 241 "\u1EE3": "o", 242 "\xF9": "u", 243 "\xFA": "u", 244 "\xFB": "u", 245 "\xFC": "u", 246 "\u1EE7": "u", 247 "\u1EE5": "u", 248 "\u1EED": "u", 249 "\u1EEF": "u", 250 "\u1EF1": "u", 251 "\xFD": "y", 252 "\xFF": "y", 253 "\u0100": "A", 254 "\u0101": "a", 255 "\u0102": "A", 256 "\u0103": "a", 257 "\u0104": "A", 258 "\u0105": "a", 259 "\u0106": "C", 260 "\u0107": "c", 261 "\u0108": "C", 262 "\u0109": "c", 263 "\u010A": "C", 264 "\u010B": "c", 265 "\u010C": "C", 266 "\u010D": "c", 267 "C\u0306": "C", 268 "c\u0306": "c", 269 "\u010E": "D", 270 "\u010F": "d", 271 "\u0110": "D", 272 "\u0111": "d", 273 "\u0112": "E", 274 "\u0113": "e", 275 "\u0114": "E", 276 "\u0115": "e", 277 "\u0116": "E", 278 "\u0117": "e", 279 "\u0118": "E", 280 "\u0119": "e", 281 "\u011A": "E", 282 "\u011B": "e", 283 "\u011C": "G", 284 "\u01F4": "G", 285 "\u011D": "g", 286 "\u01F5": "g", 287 "\u011E": "G", 288 "\u011F": "g", 289 "\u0120": "G", 290 "\u0121": "g", 291 "\u0122": "G", 292 "\u0123": "g", 293 "\u0124": "H", 294 "\u0125": "h", 295 "\u0126": "H", 296 "\u0127": "h", 297 "\u1E2A": "H", 298 "\u1E2B": "h", 299 "\u0128": "I", 300 "\u0129": "i", 301 "\u012A": "I", 302 "\u012B": "i", 303 "\u012C": "I", 304 "\u012D": "i", 305 "\u012E": "I", 306 "\u012F": "i", 307 "\u0130": "I", 308 "\u0131": "i", 309 "\u0132": "IJ", 310 "\u0133": "ij", 311 "\u0134": "J", 312 "\u0135": "j", 313 "\u0136": "K", 314 "\u0137": "k", 315 "\u1E30": "K", 316 "\u1E31": "k", 317 "K\u0306": "K", 318 "k\u0306": "k", 319 "\u0139": "L", 320 "\u013A": "l", 321 "\u013B": "L", 322 "\u013C": "l", 323 "\u013D": "L", 324 "\u013E": "l", 325 "\u013F": "L", 326 "\u0140": "l", 327 "\u0141": "l", 328 "\u0142": "l", 329 "\u1E3E": "M", 330 "\u1E3F": "m", 331 "M\u0306": "M", 332 "m\u0306": "m", 333 "\u0143": "N", 334 "\u0144": "n", 335 "\u0145": "N", 336 "\u0146": "n", 337 "\u0147": "N", 338 "\u0148": "n", 339 "\u0149": "n", 340 "N\u0306": "N", 341 "n\u0306": "n", 342 "\u014C": "O", 343 "\u014D": "o", 344 "\u014E": "O", 345 "\u014F": "o", 346 "\u0150": "O", 347 "\u0151": "o", 348 "\u0152": "OE", 349 "\u0153": "oe", 350 "P\u0306": "P", 351 "p\u0306": "p", 352 "\u0154": "R", 353 "\u0155": "r", 354 "\u0156": "R", 355 "\u0157": "r", 356 "\u0158": "R", 357 "\u0159": "r", 358 "R\u0306": "R", 359 "r\u0306": "r", 360 "\u0212": "R", 361 "\u0213": "r", 362 "\u015A": "S", 363 "\u015B": "s", 364 "\u015C": "S", 365 "\u015D": "s", 366 "\u015E": "S", 367 "\u0218": "S", 368 "\u0219": "s", 369 "\u015F": "s", 370 "\u0160": "S", 371 "\u0161": "s", 372 "\u0162": "T", 373 "\u0163": "t", 374 "\u021B": "t", 375 "\u021A": "T", 376 "\u0164": "T", 377 "\u0165": "t", 378 "\u0166": "T", 379 "\u0167": "t", 380 "T\u0306": "T", 381 "t\u0306": "t", 382 "\u0168": "U", 383 "\u0169": "u", 384 "\u016A": "U", 385 "\u016B": "u", 386 "\u016C": "U", 387 "\u016D": "u", 388 "\u016E": "U", 389 "\u016F": "u", 390 "\u0170": "U", 391 "\u0171": "u", 392 "\u0172": "U", 393 "\u0173": "u", 394 "\u0216": "U", 395 "\u0217": "u", 396 "V\u0306": "V", 397 "v\u0306": "v", 398 "\u0174": "W", 399 "\u0175": "w", 400 "\u1E82": "W", 401 "\u1E83": "w", 402 "X\u0306": "X", 403 "x\u0306": "x", 404 "\u0176": "Y", 405 "\u0177": "y", 406 "\u0178": "Y", 407 "Y\u0306": "Y", 408 "y\u0306": "y", 409 "\u0179": "Z", 410 "\u017A": "z", 411 "\u017B": "Z", 412 "\u017C": "z", 413 "\u017D": "Z", 414 "\u017E": "z", 415 "\u017F": "s", 416 "\u0192": "f", 417 "\u01A0": "O", 418 "\u01A1": "o", 419 "\u01AF": "U", 420 "\u01B0": "u", 421 "\u01CD": "A", 422 "\u01CE": "a", 423 "\u01CF": "I", 424 "\u01D0": "i", 425 "\u01D1": "O", 426 "\u01D2": "o", 427 "\u01D3": "U", 428 "\u01D4": "u", 429 "\u01D5": "U", 430 "\u01D6": "u", 431 "\u01D7": "U", 432 "\u01D8": "u", 433 "\u01D9": "U", 434 "\u01DA": "u", 435 "\u01DB": "U", 436 "\u01DC": "u", 437 "\u1EE8": "U", 438 "\u1EE9": "u", 439 "\u1E78": "U", 440 "\u1E79": "u", 441 "\u01FA": "A", 442 "\u01FB": "a", 443 "\u01FC": "AE", 444 "\u01FD": "ae", 445 "\u01FE": "O", 446 "\u01FF": "o", 447 "\xDE": "TH", 448 "\xFE": "th", 449 "\u1E54": "P", 450 "\u1E55": "p", 451 "\u1E64": "S", 452 "\u1E65": "s", 453 "X\u0301": "X", 454 "x\u0301": "x", 455 "\u0403": "\u0413", 456 "\u0453": "\u0433", 457 "\u040C": "\u041A", 458 "\u045C": "\u043A", 459 "A\u030B": "A", 460 "a\u030B": "a", 461 "E\u030B": "E", 462 "e\u030B": "e", 463 "I\u030B": "I", 464 "i\u030B": "i", 465 "\u01F8": "N", 466 "\u01F9": "n", 467 "\u1ED2": "O", 468 "\u1ED3": "o", 469 "\u1E50": "O", 470 "\u1E51": "o", 471 "\u1EEA": "U", 472 "\u1EEB": "u", 473 "\u1E80": "W", 474 "\u1E81": "w", 475 "\u1EF2": "Y", 476 "\u1EF3": "y", 477 "\u0200": "A", 478 "\u0201": "a", 479 "\u0204": "E", 480 "\u0205": "e", 481 "\u0208": "I", 482 "\u0209": "i", 483 "\u020C": "O", 484 "\u020D": "o", 485 "\u0210": "R", 486 "\u0211": "r", 487 "\u0214": "U", 488 "\u0215": "u", 489 "B\u030C": "B", 490 "b\u030C": "b", 491 "\u010C\u0323": "C", 492 "\u010D\u0323": "c", 493 "\xCA\u030C": "E", 494 "\xEA\u030C": "e", 495 "F\u030C": "F", 496 "f\u030C": "f", 497 "\u01E6": "G", 498 "\u01E7": "g", 499 "\u021E": "H", 500 "\u021F": "h", 501 "J\u030C": "J", 502 "\u01F0": "j", 503 "\u01E8": "K", 504 "\u01E9": "k", 505 "M\u030C": "M", 506 "m\u030C": "m", 507 "P\u030C": "P", 508 "p\u030C": "p", 509 "Q\u030C": "Q", 510 "q\u030C": "q", 511 "\u0158\u0329": "R", 512 "\u0159\u0329": "r", 513 "\u1E66": "S", 514 "\u1E67": "s", 515 "V\u030C": "V", 516 "v\u030C": "v", 517 "W\u030C": "W", 518 "w\u030C": "w", 519 "X\u030C": "X", 520 "x\u030C": "x", 521 "Y\u030C": "Y", 522 "y\u030C": "y", 523 "A\u0327": "A", 524 "a\u0327": "a", 525 "B\u0327": "B", 526 "b\u0327": "b", 527 "\u1E10": "D", 528 "\u1E11": "d", 529 "\u0228": "E", 530 "\u0229": "e", 531 "\u0190\u0327": "E", 532 "\u025B\u0327": "e", 533 "\u1E28": "H", 534 "\u1E29": "h", 535 "I\u0327": "I", 536 "i\u0327": "i", 537 "\u0197\u0327": "I", 538 "\u0268\u0327": "i", 539 "M\u0327": "M", 540 "m\u0327": "m", 541 "O\u0327": "O", 542 "o\u0327": "o", 543 "Q\u0327": "Q", 544 "q\u0327": "q", 545 "U\u0327": "U", 546 "u\u0327": "u", 547 "X\u0327": "X", 548 "x\u0327": "x", 549 "Z\u0327": "Z", 550 "z\u0327": "z", 551 "\u0439": "\u0438", 552 "\u0419": "\u0418", 553 "\u0451": "\u0435", 554 "\u0401": "\u0415" 555 }; 556 var chars = Object.keys(characterMap).join("|"); 557 var allAccents = new RegExp(chars, "g"); 558 var firstAccent = new RegExp(chars, ""); 559 function matcher3(match) { 560 return characterMap[match]; 561 } 562 var removeAccents2 = function(string) { 563 return string.replace(allAccents, matcher3); 564 }; 565 var hasAccents = function(string) { 566 return !!string.match(firstAccent); 567 }; 568 module.exports = removeAccents2; 569 module.exports.has = hasAccents; 570 module.exports.remove = removeAccents2; 571 } 572 }); 573 574 // node_modules/.store/fast-deep-equal@3.1.3-Dk0kpzcWCOUHE1bkOO2LLA/node_modules/fast-deep-equal/es6/index.js 575 var require_es6 = __commonJS({ 576 "node_modules/.store/fast-deep-equal@3.1.3-Dk0kpzcWCOUHE1bkOO2LLA/node_modules/fast-deep-equal/es6/index.js"(exports, module) { 577 "use strict"; 578 module.exports = function equal(a, b2) { 579 if (a === b2) return true; 580 if (a && b2 && typeof a == "object" && typeof b2 == "object") { 581 if (a.constructor !== b2.constructor) return false; 582 var length, i, keys; 583 if (Array.isArray(a)) { 584 length = a.length; 585 if (length != b2.length) return false; 586 for (i = length; i-- !== 0; ) 587 if (!equal(a[i], b2[i])) return false; 588 return true; 589 } 590 if (a instanceof Map && b2 instanceof Map) { 591 if (a.size !== b2.size) return false; 592 for (i of a.entries()) 593 if (!b2.has(i[0])) return false; 594 for (i of a.entries()) 595 if (!equal(i[1], b2.get(i[0]))) return false; 596 return true; 597 } 598 if (a instanceof Set && b2 instanceof Set) { 599 if (a.size !== b2.size) return false; 600 for (i of a.entries()) 601 if (!b2.has(i[0])) return false; 602 return true; 603 } 604 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b2)) { 605 length = a.length; 606 if (length != b2.length) return false; 607 for (i = length; i-- !== 0; ) 608 if (a[i] !== b2[i]) return false; 609 return true; 610 } 611 if (a.constructor === RegExp) return a.source === b2.source && a.flags === b2.flags; 612 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b2.valueOf(); 613 if (a.toString !== Object.prototype.toString) return a.toString() === b2.toString(); 614 keys = Object.keys(a); 615 length = keys.length; 616 if (length !== Object.keys(b2).length) return false; 617 for (i = length; i-- !== 0; ) 618 if (!Object.prototype.hasOwnProperty.call(b2, keys[i])) return false; 619 for (i = length; i-- !== 0; ) { 620 var key = keys[i]; 621 if (!equal(a[key], b2[key])) return false; 622 } 623 return true; 624 } 625 return a !== a && b2 !== b2; 626 }; 627 } 628 }); 629 630 // node_modules/.store/react-is@19.3.0-h9DBeE4BCfrMSfxZZXEDFw/node_modules/react-is/cjs/react-is.development.js 631 var require_react_is_development = __commonJS({ 632 "node_modules/.store/react-is@19.3.0-h9DBeE4BCfrMSfxZZXEDFw/node_modules/react-is/cjs/react-is.development.js"(exports) { 633 "use strict"; 634 (function() { 635 function typeOf(object) { 636 if ("object" === typeof object && null !== object) { 637 var $$typeof = object.$$typeof; 638 switch ($$typeof) { 639 case REACT_ELEMENT_TYPE: 640 switch (object = object.type, object) { 641 case REACT_FRAGMENT_TYPE: 642 case REACT_PROFILER_TYPE: 643 case REACT_STRICT_MODE_TYPE: 644 case REACT_SUSPENSE_TYPE: 645 case REACT_SUSPENSE_LIST_TYPE: 646 case REACT_VIEW_TRANSITION_TYPE: 647 return object; 648 default: 649 switch (object = object && object.$$typeof, object) { 650 case REACT_CONTEXT_TYPE: 651 case REACT_FORWARD_REF_TYPE: 652 case REACT_LAZY_TYPE: 653 case REACT_MEMO_TYPE: 654 return object; 655 case REACT_CONSUMER_TYPE: 656 return object; 657 default: 658 return $$typeof; 659 } 660 } 661 case REACT_PORTAL_TYPE: 662 return $$typeof; 663 } 664 } 665 } 666 var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"); 667 exports.ContextConsumer = REACT_CONSUMER_TYPE; 668 exports.ContextProvider = REACT_CONTEXT_TYPE; 669 exports.Element = REACT_ELEMENT_TYPE; 670 exports.ForwardRef = REACT_FORWARD_REF_TYPE; 671 exports.Fragment = REACT_FRAGMENT_TYPE; 672 exports.Lazy = REACT_LAZY_TYPE; 673 exports.Memo = REACT_MEMO_TYPE; 674 exports.Portal = REACT_PORTAL_TYPE; 675 exports.Profiler = REACT_PROFILER_TYPE; 676 exports.StrictMode = REACT_STRICT_MODE_TYPE; 677 exports.Suspense = REACT_SUSPENSE_TYPE; 678 exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE; 679 exports.isContextConsumer = function(object) { 680 return typeOf(object) === REACT_CONSUMER_TYPE; 681 }; 682 exports.isContextProvider = function(object) { 683 return typeOf(object) === REACT_CONTEXT_TYPE; 684 }; 685 exports.isElement = function(object) { 686 return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE; 687 }; 688 exports.isForwardRef = function(object) { 689 return typeOf(object) === REACT_FORWARD_REF_TYPE; 690 }; 691 exports.isFragment = function(object) { 692 return typeOf(object) === REACT_FRAGMENT_TYPE; 693 }; 694 exports.isLazy = function(object) { 695 return typeOf(object) === REACT_LAZY_TYPE; 696 }; 697 exports.isMemo = function(object) { 698 return typeOf(object) === REACT_MEMO_TYPE; 699 }; 700 exports.isPortal = function(object) { 701 return typeOf(object) === REACT_PORTAL_TYPE; 702 }; 703 exports.isProfiler = function(object) { 704 return typeOf(object) === REACT_PROFILER_TYPE; 705 }; 706 exports.isStrictMode = function(object) { 707 return typeOf(object) === REACT_STRICT_MODE_TYPE; 708 }; 709 exports.isSuspense = function(object) { 710 return typeOf(object) === REACT_SUSPENSE_TYPE; 711 }; 712 exports.isSuspenseList = function(object) { 713 return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; 714 }; 715 exports.isValidElementType = function(type) { 716 return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_VIEW_TRANSITION_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false; 717 }; 718 exports.typeOf = typeOf; 719 })(); 720 } 721 }); 722 723 // node_modules/.store/react-is@19.3.0-h9DBeE4BCfrMSfxZZXEDFw/node_modules/react-is/index.js 724 var require_react_is = __commonJS({ 725 "node_modules/.store/react-is@19.3.0-h9DBeE4BCfrMSfxZZXEDFw/node_modules/react-is/index.js"(exports, module) { 726 "use strict"; 727 if (false) { 728 module.exports = null; 729 } else { 730 module.exports = require_react_is_development(); 731 } 732 } 733 }); 734 735 // package-external:@wordpress/hooks 736 var require_hooks = __commonJS({ 737 "package-external:@wordpress/hooks"(exports, module) { 738 module.exports = window.wp.hooks; 739 } 740 }); 741 742 // package-external:@wordpress/block-serialization-default-parser 743 var require_block_serialization_default_parser = __commonJS({ 744 "package-external:@wordpress/block-serialization-default-parser"(exports, module) { 745 module.exports = window.wp.blockSerializationDefaultParser; 746 } 747 }); 748 749 // package-external:@wordpress/autop 750 var require_autop = __commonJS({ 751 "package-external:@wordpress/autop"(exports, module) { 752 module.exports = window.wp.autop; 753 } 754 }); 755 756 // package-external:@wordpress/is-shallow-equal 757 var require_is_shallow_equal = __commonJS({ 758 "package-external:@wordpress/is-shallow-equal"(exports, module) { 759 module.exports = window.wp.isShallowEqual; 760 } 761 }); 762 763 // vendor-external:react/jsx-runtime 764 var require_jsx_runtime = __commonJS({ 765 "vendor-external:react/jsx-runtime"(exports, module) { 766 module.exports = window.ReactJSXRuntime; 767 } 768 }); 769 770 // package-external:@wordpress/html-entities 771 var require_html_entities = __commonJS({ 772 "package-external:@wordpress/html-entities"(exports, module) { 773 module.exports = window.wp.htmlEntities; 774 } 775 }); 776 777 // package-external:@wordpress/shortcode 778 var require_shortcode = __commonJS({ 779 "package-external:@wordpress/shortcode"(exports, module) { 780 module.exports = window.wp.shortcode; 781 } 782 }); 783 784 // package-external:@wordpress/blob 785 var require_blob = __commonJS({ 786 "package-external:@wordpress/blob"(exports, module) { 787 module.exports = window.wp.blob; 788 } 789 }); 790 791 // packages/blocks/build-module/index.mjs 792 var index_exports = {}; 793 __export(index_exports, { 794 __EXPERIMENTAL_ELEMENTS: () => __EXPERIMENTAL_ELEMENTS, 795 __EXPERIMENTAL_PATHS_WITH_OVERRIDE: () => __EXPERIMENTAL_PATHS_WITH_OVERRIDE, 796 __EXPERIMENTAL_STYLE_PROPERTY: () => __EXPERIMENTAL_STYLE_PROPERTY, 797 __experimentalCloneSanitizedBlock: () => __experimentalCloneSanitizedBlock, 798 __experimentalGetAccessibleBlockLabel: () => getAccessibleBlockLabel, 799 __experimentalGetBlockAttributesNamesByRole: () => __experimentalGetBlockAttributesNamesByRole, 800 __experimentalGetBlockLabel: () => getBlockLabel, 801 __experimentalSanitizeBlockAttributes: () => __experimentalSanitizeBlockAttributes, 802 __unstableGetBlockProps: () => getBlockProps, 803 __unstableGetInnerBlocksProps: () => getInnerBlocksProps, 804 __unstableSerializeAndClean: () => __unstableSerializeAndClean, 805 children: () => children_default, 806 cloneBlock: () => cloneBlock, 807 cloneSanitizedBlock: () => cloneSanitizedBlock, 808 createBlock: () => createBlock, 809 createBlocksFromInnerBlocksTemplate: () => createBlocksFromInnerBlocksTemplate, 810 doBlocksMatchTemplate: () => doBlocksMatchTemplate, 811 findTransform: () => findTransform, 812 getBlockAttributes: () => getBlockAttributes, 813 getBlockAttributesNamesByRole: () => getBlockAttributesNamesByRole, 814 getBlockBindingsSource: () => getBlockBindingsSource, 815 getBlockBindingsSources: () => getBlockBindingsSources, 816 getBlockContent: () => getBlockInnerHTML, 817 getBlockDefaultClassName: () => getBlockDefaultClassName, 818 getBlockFromExample: () => getBlockFromExample, 819 getBlockMenuDefaultClassName: () => getBlockMenuDefaultClassName, 820 getBlockSupport: () => getBlockSupport, 821 getBlockTransforms: () => getBlockTransforms, 822 getBlockType: () => getBlockType, 823 getBlockTypes: () => getBlockTypes, 824 getBlockVariations: () => getBlockVariations, 825 getCategories: () => getCategories2, 826 getChildBlockNames: () => getChildBlockNames, 827 getDefaultBlockName: () => getDefaultBlockName, 828 getFreeformContentHandlerName: () => getFreeformContentHandlerName, 829 getGroupingBlockName: () => getGroupingBlockName, 830 getPhrasingContentSchema: () => deprecatedGetPhrasingContentSchema, 831 getPossibleBlockTransformations: () => getPossibleBlockTransformations, 832 getSaveContent: () => getSaveContent, 833 getSaveElement: () => getSaveElement, 834 getUnregisteredTypeHandlerName: () => getUnregisteredTypeHandlerName, 835 hasBlockSupport: () => hasBlockSupport, 836 hasChildBlocks: () => hasChildBlocks, 837 hasChildBlocksWithInserterSupport: () => hasChildBlocksWithInserterSupport, 838 isReusableBlock: () => isReusableBlock, 839 isTemplatePart: () => isTemplatePart, 840 isUnmodifiedBlock: () => isUnmodifiedBlock, 841 isUnmodifiedDefaultBlock: () => isUnmodifiedDefaultBlock, 842 isValidBlockContent: () => isValidBlockContent, 843 isValidIcon: () => isValidIcon, 844 node: () => node_default, 845 normalizeIconObject: () => normalizeIconObject, 846 parse: () => parse2, 847 parseWithAttributeSchema: () => parseWithAttributeSchema, 848 pasteHandler: () => pasteHandler, 849 privateApis: () => privateApis, 850 rawHandler: () => rawHandler, 851 registerBlockBindingsSource: () => registerBlockBindingsSource, 852 registerBlockCollection: () => registerBlockCollection, 853 registerBlockStyle: () => registerBlockStyle, 854 registerBlockType: () => registerBlockType, 855 registerBlockVariation: () => registerBlockVariation, 856 sanitizeBlockAttributes: () => sanitizeBlockAttributes, 857 serialize: () => serialize, 858 serializeRawBlock: () => serializeRawBlock, 859 setCategories: () => setCategories2, 860 setDefaultBlockName: () => setDefaultBlockName, 861 setFreeformContentHandlerName: () => setFreeformContentHandlerName, 862 setGroupingBlockName: () => setGroupingBlockName, 863 setUnregisteredTypeHandlerName: () => setUnregisteredTypeHandlerName, 864 store: () => store, 865 switchToBlockType: () => switchToBlockType, 866 synchronizeBlocksWithTemplate: () => synchronizeBlocksWithTemplate, 867 unregisterBlockBindingsSource: () => unregisterBlockBindingsSource, 868 unregisterBlockStyle: () => unregisterBlockStyle, 869 unregisterBlockType: () => unregisterBlockType, 870 unregisterBlockVariation: () => unregisterBlockVariation, 871 unstable__bootstrapServerSideBlockDefinitions: () => unstable__bootstrapServerSideBlockDefinitions, 872 updateCategory: () => updateCategory2, 873 validateBlock: () => validateBlock, 874 withBlockContentContext: () => withBlockContentContext 875 }); 876 877 // packages/blocks/build-module/store/index.mjs 878 var import_data5 = __toESM(require_data(), 1); 879 880 // node_modules/.store/tslib@2.8.1-LT-dxu1EkVy7OUDyVf5glQ/node_modules/tslib/tslib.es6.mjs 881 var __assign = function() { 882 __assign = Object.assign || function __assign2(t2) { 883 for (var s, i = 1, n = arguments.length; i < n; i++) { 884 s = arguments[i]; 885 for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2)) t2[p2] = s[p2]; 886 } 887 return t2; 888 }; 889 return __assign.apply(this, arguments); 890 }; 891 892 // node_modules/.store/lower-case@2.0.2-5YZP5nczP5_f_8Vt5KBPjA/node_modules/lower-case/dist.es2015/index.js 893 function lowerCase(str) { 894 return str.toLowerCase(); 895 } 896 897 // node_modules/.store/no-case@3.0.4-R4Hzt6qn-erEsTak7ojDpg/node_modules/no-case/dist.es2015/index.js 898 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 899 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 900 function noCase(input, options) { 901 if (options === void 0) { 902 options = {}; 903 } 904 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; 905 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 906 var start = 0; 907 var end = result.length; 908 while (result.charAt(start) === "\0") 909 start++; 910 while (result.charAt(end - 1) === "\0") 911 end--; 912 return result.slice(start, end).split("\0").map(transform).join(delimiter); 913 } 914 function replace(input, re, value) { 915 if (re instanceof RegExp) 916 return input.replace(re, value); 917 return re.reduce(function(input2, re2) { 918 return input2.replace(re2, value); 919 }, input); 920 } 921 922 // node_modules/.store/pascal-case@3.1.2-khtSA9hpCTEVLYfMgyRdoA/node_modules/pascal-case/dist.es2015/index.js 923 function pascalCaseTransform(input, index) { 924 var firstChar = input.charAt(0); 925 var lowerChars = input.substr(1).toLowerCase(); 926 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 927 return "_" + firstChar + lowerChars; 928 } 929 return "" + firstChar.toUpperCase() + lowerChars; 930 } 931 function pascalCase(input, options) { 932 if (options === void 0) { 933 options = {}; 934 } 935 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 936 } 937 938 // node_modules/.store/camel-case@4.1.2-5Gz5buNb7xjdcDcS4uJ7xw/node_modules/camel-case/dist.es2015/index.js 939 function camelCaseTransform(input, index) { 940 if (index === 0) 941 return input.toLowerCase(); 942 return pascalCaseTransform(input, index); 943 } 944 function camelCase(input, options) { 945 if (options === void 0) { 946 options = {}; 947 } 948 return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); 949 } 950 951 // packages/blocks/build-module/store/reducer.mjs 952 var import_data2 = __toESM(require_data(), 1); 953 var import_i18n3 = __toESM(require_i18n(), 1); 954 955 // node_modules/.store/colord@2.10.0-Qx66Amv6c9C3nDPQDizV6Q/node_modules/colord/index.mjs 956 for (r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t2 = function(r3) { 957 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 958 }, n = function(r3, t3, n2) { 959 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0; 960 }, u = function(r3, t3, n2) { 961 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3; 962 }, e2 = function(r3) { 963 return (r3 = isFinite(r3) ? r3 % 360 : 0) < 0 ? r3 + 360 : r3; 964 }, o2 = function(r3, t3) { 965 return void 0 === t3 && (t3 = 0), n(r3, t3) % 360; 966 }, a = function(r3) { 967 return { r: u(r3.r, 0, 255), g: u(r3.g, 0, 255), b: u(r3.b, 0, 255), a: u(r3.a) }; 968 }, i = function(r3) { 969 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 970 }, s = /^#([0-9a-f]{3,8})$/i, d2 = function(r3, t3) { 971 var n2 = r3.charCodeAt(t3); 972 return (15 & n2) + 9 * (n2 >> 6); 973 }, h = function(r3, t3) { 974 return d2(r3, t3) << 4 | d2(r3, t3 + 1); 975 }, b2 = [], f2 = 0; f2 < 256; f2++) b2.push((f2 < 16 ? "0" : "") + f2.toString(16)); 976 var r2; 977 var t2; 978 var n; 979 var u; 980 var e2; 981 var o2; 982 var a; 983 var i; 984 var s; 985 var d2; 986 var h; 987 var b2; 988 var f2; 989 var g = function(r2) { 990 return b2[u(r2, 0, 255)]; 991 }; 992 var c = function(r2) { 993 var t2 = r2.r, n = r2.g, u = r2.b, e2 = r2.a, o2 = Math.max(t2, n, u), a = o2 - Math.min(t2, n, u), i = a ? o2 === t2 ? (n - u) / a : o2 === n ? 2 + (u - t2) / a : 4 + (t2 - n) / a : 0; 994 return { h: 60 * (i < 0 ? i + 6 : i), s: o2 ? a / o2 * 100 : 0, v: o2 / 255 * 100, a: e2 }; 995 }; 996 var v = function(r2) { 997 var t2 = r2.h, n = r2.s, u = r2.v, e2 = r2.a; 998 t2 = t2 / 360 * 6, n /= 100, u /= 100; 999 var o2 = Math.floor(t2), a = u * (1 - n), i = u * (1 - (t2 - o2) * n), s = u * (1 - (1 - t2 + o2) * n), d2 = o2 % 6; 1000 return { r: 255 * [u, i, a, a, s, u][d2], g: 255 * [s, u, u, i, a, a][d2], b: 255 * [a, a, s, u, u, i][d2], a: e2 }; 1001 }; 1002 var l = function(r2) { 1003 return { h: e2(r2.h), s: u(r2.s, 0, 100), l: u(r2.l, 0, 100), a: u(r2.a) }; 1004 }; 1005 var p = function(r2) { 1006 return { h: o2(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) }; 1007 }; 1008 var m = function(r2) { 1009 return v((n = (t2 = r2).s, { h: t2.h, s: (n *= ((u = t2.l) < 50 ? u : 100 - u) / 100) > 0 ? 2 * n / (u + n) * 100 : 0, v: u + n, a: t2.a })); 1010 var t2, n, u; 1011 }; 1012 var y = function(r2) { 1013 return { h: (t2 = c(r2)).h, s: (e2 = (200 - (n = t2.s)) * (u = t2.v) / 100) > 0 && e2 < 200 ? n * u / 100 / (e2 <= 100 ? e2 : 200 - e2) * 100 : 0, l: e2 / 2, a: t2.a }; 1014 var t2, n, u, e2; 1015 }; 1016 var N = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1017 var x = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s+([+-]?(?:\d*\.\d+|\d+))%\s+([+-]?(?:\d*\.\d+|\d+))%\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1018 var M = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1019 var H = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1020 var $ = { string: [[function(r2) { 1021 if (!s.test(r2)) return null; 1022 var t2 = r2.length; 1023 return t2 <= 5 ? { r: 17 * d2(r2, 1), g: 17 * d2(r2, 2), b: 17 * d2(r2, 3), a: 5 === t2 ? n(17 * d2(r2, 4) / 255, 2) : 1 } : 7 === t2 || 9 === t2 ? { r: h(r2, 1), g: h(r2, 3), b: h(r2, 5), a: 9 === t2 ? n(h(r2, 7) / 255, 2) : 1 } : null; 1024 }, "hex"], [function(r2) { 1025 var t2 = M.exec(r2) || H.exec(r2); 1026 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null; 1027 }, "rgb"], [function(t2) { 1028 var n = N.exec(t2) || x.exec(t2); 1029 if (!n) return null; 1030 var u, e2, o2 = l({ h: (u = n[1], e2 = n[2], void 0 === e2 && (e2 = "deg"), Number(u) * (r2[e2] || 1)), s: Number(n[3]), l: Number(n[4]), a: void 0 === n[5] ? 1 : Number(n[5]) / (n[6] ? 100 : 1) }); 1031 return m(o2); 1032 }, "hsl"]], object: [[function(r2) { 1033 var n = r2.r, u = r2.g, e2 = r2.b, o2 = r2.a, i = void 0 === o2 ? 1 : o2; 1034 return t2(n) && t2(u) && t2(e2) ? a({ r: Number(n), g: Number(u), b: Number(e2), a: Number(i) }) : null; 1035 }, "rgb"], [function(r2) { 1036 var n = r2.h, u = r2.s, e2 = r2.l, o2 = r2.a, a = void 0 === o2 ? 1 : o2; 1037 if (!t2(n) || !t2(u) || !t2(e2)) return null; 1038 var i = l({ h: Number(n), s: Number(u), l: Number(e2), a: Number(a) }); 1039 return m(i); 1040 }, "hsl"], [function(r2) { 1041 var n = r2.h, o2 = r2.s, a = r2.v, i = r2.a, s = void 0 === i ? 1 : i; 1042 if (!t2(n) || !t2(o2) || !t2(a)) return null; 1043 var d2 = (function(r3) { 1044 return { h: e2(r3.h), s: u(r3.s, 0, 100), v: u(r3.v, 0, 100), a: u(r3.a) }; 1045 })({ h: Number(n), s: Number(o2), v: Number(a), a: Number(s) }); 1046 return v(d2); 1047 }, "hsv"]] }; 1048 var j = function(r2, t2) { 1049 for (var n = 0; n < t2.length; n++) { 1050 var u = t2[n][0](r2); 1051 if (u) return [u, t2[n][1]]; 1052 } 1053 return [null, void 0]; 1054 }; 1055 var w = function(r2) { 1056 return "string" == typeof r2 ? j(r2.trim(), $.string) : "object" == typeof r2 && null !== r2 ? j(r2, $.object) : [null, void 0]; 1057 }; 1058 var k = function(r2, t2) { 1059 var n = y(r2); 1060 return { h: n.h, s: u(n.s + 100 * t2, 0, 100), l: n.l, a: n.a }; 1061 }; 1062 var E = function(r2) { 1063 return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255; 1064 }; 1065 var R = function(r2, t2) { 1066 var n = y(r2); 1067 return { h: n.h, s: n.s, l: u(n.l + 100 * t2, 0, 100), a: n.a }; 1068 }; 1069 var q = (function() { 1070 function r2(r3) { 1071 this.parsed = w(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 1072 } 1073 return r2.prototype.isValid = function() { 1074 return null !== this.parsed; 1075 }, r2.prototype.brightness = function() { 1076 return n(E(this.rgba), 2); 1077 }, r2.prototype.isDark = function() { 1078 return E(this.rgba) < 0.5; 1079 }, r2.prototype.isLight = function() { 1080 return E(this.rgba) >= 0.5; 1081 }, r2.prototype.toHex = function() { 1082 return r3 = i(this.rgba), t2 = r3.r, u = r3.g, e2 = r3.b, a = (o2 = r3.a) < 1 ? g(n(255 * o2)) : "", "#" + g(t2) + g(u) + g(e2) + a; 1083 var r3, t2, u, e2, o2, a; 1084 }, r2.prototype.toRgb = function() { 1085 return i(this.rgba); 1086 }, r2.prototype.toRgbString = function() { 1087 return r3 = i(this.rgba), t2 = r3.r, n = r3.g, u = r3.b, (e2 = r3.a) < 1 ? "rgba(" + t2 + ", " + n + ", " + u + ", " + e2 + ")" : "rgb(" + t2 + ", " + n + ", " + u + ")"; 1088 var r3, t2, n, u, e2; 1089 }, r2.prototype.toHsl = function() { 1090 return p(y(this.rgba)); 1091 }, r2.prototype.toHslString = function() { 1092 return r3 = p(y(this.rgba)), t2 = r3.h, n = r3.s, u = r3.l, (e2 = r3.a) < 1 ? "hsla(" + t2 + ", " + n + "%, " + u + "%, " + e2 + ")" : "hsl(" + t2 + ", " + n + "%, " + u + "%)"; 1093 var r3, t2, n, u, e2; 1094 }, r2.prototype.toHsv = function() { 1095 return r3 = c(this.rgba), { h: o2(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) }; 1096 var r3; 1097 }, r2.prototype.invert = function() { 1098 return A({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a }); 1099 var r3; 1100 }, r2.prototype.saturate = function(r3) { 1101 return void 0 === r3 && (r3 = 0.1), A(k(this.rgba, r3)); 1102 }, r2.prototype.desaturate = function(r3) { 1103 return void 0 === r3 && (r3 = 0.1), A(k(this.rgba, -r3)); 1104 }, r2.prototype.grayscale = function() { 1105 return A(k(this.rgba, -1)); 1106 }, r2.prototype.lighten = function(r3) { 1107 return void 0 === r3 && (r3 = 0.1), A(R(this.rgba, r3)); 1108 }, r2.prototype.darken = function(r3) { 1109 return void 0 === r3 && (r3 = 0.1), A(R(this.rgba, -r3)); 1110 }, r2.prototype.rotate = function(r3) { 1111 return void 0 === r3 && (r3 = 15), this.hue(y(this.rgba).h + r3); 1112 }, r2.prototype.alpha = function(r3) { 1113 return "number" == typeof r3 ? A({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r3 }) : n(this.rgba.a, 3); 1114 var t2; 1115 }, r2.prototype.hue = function(r3) { 1116 var t2 = y(this.rgba); 1117 return "number" == typeof r3 ? A({ h: r3, s: t2.s, l: t2.l, a: t2.a }) : o2(t2.h); 1118 }, r2.prototype.isEqual = function(r3) { 1119 return this.toHex() === A(r3).toHex(); 1120 }, r2; 1121 })(); 1122 var A = function(r2) { 1123 return r2 instanceof q ? r2 : new q(r2); 1124 }; 1125 var C = []; 1126 var D = function(r2) { 1127 r2.forEach(function(r3) { 1128 C.indexOf(r3) < 0 && (r3(q, $), C.push(r3)); 1129 }); 1130 }; 1131 1132 // node_modules/.store/colord@2.10.0-Qx66Amv6c9C3nDPQDizV6Q/node_modules/colord/plugins/names.mjs 1133 var e = function(e2, f2) { 1134 var a = { white: "#ffffff", bisque: "#ffe4c4", blue: "#0000ff", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", antiquewhite: "#faebd7", aqua: "#00ffff", azure: "#f0ffff", whitesmoke: "#f5f5f5", papayawhip: "#ffefd5", plum: "#dda0dd", blanchedalmond: "#ffebcd", black: "#000000", gold: "#ffd700", goldenrod: "#daa520", gainsboro: "#dcdcdc", cornsilk: "#fff8dc", cornflowerblue: "#6495ed", burlywood: "#deb887", aquamarine: "#7fffd4", beige: "#f5f5dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkkhaki: "#bdb76b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", peachpuff: "#ffdab9", darkmagenta: "#8b008b", darkred: "#8b0000", darkorchid: "#9932cc", darkorange: "#ff8c00", darkslateblue: "#483d8b", gray: "#808080", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", deeppink: "#ff1493", deepskyblue: "#00bfff", wheat: "#f5deb3", firebrick: "#b22222", floralwhite: "#fffaf0", ghostwhite: "#f8f8ff", darkviolet: "#9400d3", magenta: "#ff00ff", green: "#008000", dodgerblue: "#1e90ff", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", blueviolet: "#8a2be2", forestgreen: "#228b22", lawngreen: "#7cfc00", indianred: "#cd5c5c", indigo: "#4b0082", fuchsia: "#ff00ff", brown: "#a52a2a", maroon: "#800000", mediumblue: "#0000cd", lightcoral: "#f08080", darkturquoise: "#00ced1", lightcyan: "#e0ffff", ivory: "#fffff0", lightyellow: "#ffffe0", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", linen: "#faf0e6", mediumaquamarine: "#66cdaa", lemonchiffon: "#fffacd", lime: "#00ff00", khaki: "#f0e68c", mediumseagreen: "#3cb371", limegreen: "#32cd32", mediumspringgreen: "#00fa9a", lightskyblue: "#87cefa", lightblue: "#add8e6", midnightblue: "#191970", lightpink: "#ffb6c1", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", mintcream: "#f5fffa", lightslategray: "#778899", lightslategrey: "#778899", navajowhite: "#ffdead", navy: "#000080", mediumvioletred: "#c71585", powderblue: "#b0e0e6", palegoldenrod: "#eee8aa", oldlace: "#fdf5e6", paleturquoise: "#afeeee", mediumturquoise: "#48d1cc", mediumorchid: "#ba55d3", rebeccapurple: "#663399", lightsteelblue: "#b0c4de", mediumslateblue: "#7b68ee", thistle: "#d8bfd8", tan: "#d2b48c", orchid: "#da70d6", mediumpurple: "#9370db", purple: "#800080", pink: "#ffc0cb", skyblue: "#87ceeb", springgreen: "#00ff7f", palegreen: "#98fb98", red: "#ff0000", yellow: "#ffff00", slateblue: "#6a5acd", lavenderblush: "#fff0f5", peru: "#cd853f", palevioletred: "#db7093", violet: "#ee82ee", teal: "#008080", slategray: "#708090", slategrey: "#708090", aliceblue: "#f0f8ff", darkseagreen: "#8fbc8f", darkolivegreen: "#556b2f", greenyellow: "#adff2f", seagreen: "#2e8b57", seashell: "#fff5ee", tomato: "#ff6347", silver: "#c0c0c0", sienna: "#a0522d", lavender: "#e6e6fa", lightgreen: "#90ee90", orange: "#ffa500", orangered: "#ff4500", steelblue: "#4682b4", royalblue: "#4169e1", turquoise: "#40e0d0", yellowgreen: "#9acd32", salmon: "#fa8072", saddlebrown: "#8b4513", sandybrown: "#f4a460", rosybrown: "#bc8f8f", darksalmon: "#e9967a", lightgoldenrodyellow: "#fafad2", snow: "#fffafa", lightgrey: "#d3d3d3", lightgray: "#d3d3d3", dimgray: "#696969", dimgrey: "#696969", olivedrab: "#6b8e23", olive: "#808000" }, r2 = {}; 1135 for (var d2 in a) r2[a[d2]] = d2; 1136 var l4 = {}; 1137 e2.prototype.toName = function(f3) { 1138 if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent"; 1139 var d3, i, n = r2[this.toHex()]; 1140 if (n) return n; 1141 if (null == f3 ? void 0 : f3.closest) { 1142 var o2 = this.toRgb(), t2 = 1 / 0, b2 = "black"; 1143 if (!l4.length) for (var c2 in a) l4[c2] = new e2(a[c2]).toRgb(); 1144 for (var g2 in a) { 1145 var u = (d3 = o2, i = l4[g2], Math.pow(d3.r - i.r, 2) + Math.pow(d3.g - i.g, 2) + Math.pow(d3.b - i.b, 2)); 1146 u < t2 && (t2 = u, b2 = g2); 1147 } 1148 return b2; 1149 } 1150 }; 1151 f2.string.push([function(f3) { 1152 var r3 = f3.toLowerCase(), d3 = "transparent" === r3 ? "#0000" : a[r3]; 1153 return d3 ? new e2(d3).toRgb() : null; 1154 }, "name"]); 1155 }; 1156 1157 // node_modules/.store/colord@2.10.0-Qx66Amv6c9C3nDPQDizV6Q/node_modules/colord/plugins/a11y.mjs 1158 var o = function(o2) { 1159 var t2 = o2 / 255; 1160 return t2 < 0.04045 ? t2 / 12.92 : Math.pow((t2 + 0.055) / 1.055, 2.4); 1161 }; 1162 var t = function(t2) { 1163 return 0.2126 * o(t2.r) + 0.7152 * o(t2.g) + 0.0722 * o(t2.b); 1164 }; 1165 var r = function(o2) { 1166 o2.prototype.luminance = function() { 1167 return o3 = t(this.rgba), void 0 === (r2 = 2) && (r2 = 0), void 0 === n && (n = Math.pow(10, r2)), Math.round(n * o3) / n + 0; 1168 var o3, r2, n; 1169 }, o2.prototype.contrast = function(r2) { 1170 void 0 === r2 && (r2 = "#FFF"); 1171 var n, a, i, e2, v3, u, d2, c2 = r2 instanceof o2 ? r2 : new o2(r2); 1172 return e2 = this.rgba, v3 = c2.toRgb(), u = t(e2), d2 = t(v3), n = u > d2 ? (u + 0.05) / (d2 + 0.05) : (d2 + 0.05) / (u + 0.05), void 0 === (a = 2) && (a = 0), void 0 === i && (i = Math.pow(10, a)), Math.floor(i * n) / i + 0; 1173 }, o2.prototype.isReadable = function(o3, t2) { 1174 return void 0 === o3 && (o3 = "#FFF"), void 0 === t2 && (t2 = {}), this.contrast(o3) >= (e2 = void 0 === (i = (r2 = t2).size) ? "normal" : i, "AAA" === (a = void 0 === (n = r2.level) ? "AA" : n) && "normal" === e2 ? 7 : "AA" === a && "large" === e2 ? 3 : 4.5); 1175 var r2, n, a, i, e2; 1176 }; 1177 }; 1178 1179 // packages/blocks/build-module/api/utils.mjs 1180 var import_element = __toESM(require_element(), 1); 1181 var import_i18n2 = __toESM(require_i18n(), 1); 1182 var import_dom = __toESM(require_dom(), 1); 1183 var import_rich_text = __toESM(require_rich_text(), 1); 1184 var import_deprecated = __toESM(require_deprecated(), 1); 1185 1186 // packages/blocks/build-module/api/constants.mjs 1187 var BLOCK_ICON_DEFAULT = "block-default"; 1188 var DEPRECATED_ENTRY_KEYS = [ 1189 "attributes", 1190 "supports", 1191 "save", 1192 "migrate", 1193 "isEligible", 1194 "apiVersion" 1195 ]; 1196 var __EXPERIMENTAL_STYLE_PROPERTY = { 1197 // Kept for back-compatibility purposes. 1198 "--wp--style--color--link": { 1199 value: ["color", "link"], 1200 support: ["color", "link"] 1201 }, 1202 aspectRatio: { 1203 value: ["dimensions", "aspectRatio"], 1204 support: ["dimensions", "aspectRatio"], 1205 useEngine: true 1206 }, 1207 background: { 1208 value: ["color", "gradient"], 1209 support: ["color", "gradients"], 1210 useEngine: true 1211 }, 1212 backgroundColor: { 1213 value: ["color", "background"], 1214 support: ["color", "background"], 1215 requiresOptOut: true, 1216 useEngine: true 1217 }, 1218 backgroundImage: { 1219 value: ["background", "backgroundImage"], 1220 support: ["background", "backgroundImage"], 1221 useEngine: true 1222 }, 1223 backgroundRepeat: { 1224 value: ["background", "backgroundRepeat"], 1225 support: ["background", "backgroundRepeat"], 1226 useEngine: true 1227 }, 1228 backgroundSize: { 1229 value: ["background", "backgroundSize"], 1230 support: ["background", "backgroundSize"], 1231 useEngine: true 1232 }, 1233 backgroundPosition: { 1234 value: ["background", "backgroundPosition"], 1235 support: ["background", "backgroundPosition"], 1236 useEngine: true 1237 }, 1238 backgroundGradient: { 1239 value: ["background", "gradient"], 1240 support: ["background", "gradient"], 1241 useEngine: true 1242 }, 1243 backgroundClip: { 1244 value: ["background", "backgroundClip"], 1245 support: ["background", "backgroundClip"], 1246 useEngine: true 1247 }, 1248 borderColor: { 1249 value: ["border", "color"], 1250 support: ["__experimentalBorder", "color"], 1251 useEngine: true 1252 }, 1253 borderRadius: { 1254 value: ["border", "radius"], 1255 support: ["__experimentalBorder", "radius"], 1256 properties: { 1257 borderTopLeftRadius: "topLeft", 1258 borderTopRightRadius: "topRight", 1259 borderBottomLeftRadius: "bottomLeft", 1260 borderBottomRightRadius: "bottomRight" 1261 }, 1262 useEngine: true 1263 }, 1264 borderStyle: { 1265 value: ["border", "style"], 1266 support: ["__experimentalBorder", "style"], 1267 useEngine: true 1268 }, 1269 borderWidth: { 1270 value: ["border", "width"], 1271 support: ["__experimentalBorder", "width"], 1272 useEngine: true 1273 }, 1274 borderTopColor: { 1275 value: ["border", "top", "color"], 1276 support: ["__experimentalBorder", "color"], 1277 useEngine: true 1278 }, 1279 borderTopStyle: { 1280 value: ["border", "top", "style"], 1281 support: ["__experimentalBorder", "style"], 1282 useEngine: true 1283 }, 1284 borderTopWidth: { 1285 value: ["border", "top", "width"], 1286 support: ["__experimentalBorder", "width"], 1287 useEngine: true 1288 }, 1289 borderRightColor: { 1290 value: ["border", "right", "color"], 1291 support: ["__experimentalBorder", "color"], 1292 useEngine: true 1293 }, 1294 borderRightStyle: { 1295 value: ["border", "right", "style"], 1296 support: ["__experimentalBorder", "style"], 1297 useEngine: true 1298 }, 1299 borderRightWidth: { 1300 value: ["border", "right", "width"], 1301 support: ["__experimentalBorder", "width"], 1302 useEngine: true 1303 }, 1304 borderBottomColor: { 1305 value: ["border", "bottom", "color"], 1306 support: ["__experimentalBorder", "color"], 1307 useEngine: true 1308 }, 1309 borderBottomStyle: { 1310 value: ["border", "bottom", "style"], 1311 support: ["__experimentalBorder", "style"], 1312 useEngine: true 1313 }, 1314 borderBottomWidth: { 1315 value: ["border", "bottom", "width"], 1316 support: ["__experimentalBorder", "width"], 1317 useEngine: true 1318 }, 1319 borderLeftColor: { 1320 value: ["border", "left", "color"], 1321 support: ["__experimentalBorder", "color"], 1322 useEngine: true 1323 }, 1324 borderLeftStyle: { 1325 value: ["border", "left", "style"], 1326 support: ["__experimentalBorder", "style"], 1327 useEngine: true 1328 }, 1329 borderLeftWidth: { 1330 value: ["border", "left", "width"], 1331 support: ["__experimentalBorder", "width"], 1332 useEngine: true 1333 }, 1334 color: { 1335 value: ["color", "text"], 1336 support: ["color", "text"], 1337 requiresOptOut: true, 1338 useEngine: true 1339 }, 1340 columnCount: { 1341 value: ["typography", "textColumns"], 1342 support: ["typography", "textColumns"], 1343 useEngine: true 1344 }, 1345 filter: { 1346 value: ["filter", "duotone"], 1347 support: ["filter", "duotone"] 1348 }, 1349 linkColor: { 1350 value: ["elements", "link", "color", "text"], 1351 support: ["color", "link"] 1352 }, 1353 captionColor: { 1354 value: ["elements", "caption", "color", "text"], 1355 support: ["color", "caption"] 1356 }, 1357 buttonColor: { 1358 value: ["elements", "button", "color", "text"], 1359 support: ["color", "button"] 1360 }, 1361 buttonBackgroundColor: { 1362 value: ["elements", "button", "color", "background"], 1363 support: ["color", "button"] 1364 }, 1365 headingColor: { 1366 value: ["elements", "heading", "color", "text"], 1367 support: ["color", "heading"] 1368 }, 1369 headingBackgroundColor: { 1370 value: ["elements", "heading", "color", "background"], 1371 support: ["color", "heading"] 1372 }, 1373 fontFamily: { 1374 value: ["typography", "fontFamily"], 1375 support: ["typography", "__experimentalFontFamily"], 1376 useEngine: true 1377 }, 1378 fontSize: { 1379 value: ["typography", "fontSize"], 1380 support: ["typography", "fontSize"], 1381 useEngine: true 1382 }, 1383 fontStyle: { 1384 value: ["typography", "fontStyle"], 1385 support: ["typography", "__experimentalFontStyle"], 1386 useEngine: true 1387 }, 1388 fontWeight: { 1389 value: ["typography", "fontWeight"], 1390 support: ["typography", "__experimentalFontWeight"], 1391 useEngine: true 1392 }, 1393 lineHeight: { 1394 value: ["typography", "lineHeight"], 1395 support: ["typography", "lineHeight"], 1396 useEngine: true 1397 }, 1398 margin: { 1399 value: ["spacing", "margin"], 1400 support: ["spacing", "margin"], 1401 properties: { 1402 marginTop: "top", 1403 marginRight: "right", 1404 marginBottom: "bottom", 1405 marginLeft: "left" 1406 }, 1407 useEngine: true 1408 }, 1409 minHeight: { 1410 value: ["dimensions", "minHeight"], 1411 support: ["dimensions", "minHeight"], 1412 useEngine: true 1413 }, 1414 minWidth: { 1415 value: ["dimensions", "minWidth"], 1416 support: ["dimensions", "minWidth"], 1417 useEngine: true 1418 }, 1419 height: { 1420 value: ["dimensions", "height"], 1421 support: ["dimensions", "height"], 1422 useEngine: true 1423 }, 1424 width: { 1425 value: ["dimensions", "width"], 1426 support: ["dimensions", "width"], 1427 useEngine: true 1428 }, 1429 padding: { 1430 value: ["spacing", "padding"], 1431 support: ["spacing", "padding"], 1432 properties: { 1433 paddingTop: "top", 1434 paddingRight: "right", 1435 paddingBottom: "bottom", 1436 paddingLeft: "left" 1437 }, 1438 useEngine: true 1439 }, 1440 textAlign: { 1441 value: ["typography", "textAlign"], 1442 support: ["typography", "textAlign"], 1443 useEngine: false 1444 }, 1445 textDecoration: { 1446 value: ["typography", "textDecoration"], 1447 support: ["typography", "__experimentalTextDecoration"], 1448 useEngine: true 1449 }, 1450 textTransform: { 1451 value: ["typography", "textTransform"], 1452 support: ["typography", "__experimentalTextTransform"], 1453 useEngine: true 1454 }, 1455 letterSpacing: { 1456 value: ["typography", "letterSpacing"], 1457 support: ["typography", "__experimentalLetterSpacing"], 1458 useEngine: true 1459 }, 1460 textIndent: { 1461 value: ["typography", "textIndent"], 1462 support: ["typography", "textIndent"], 1463 useEngine: true 1464 }, 1465 textShadow: { 1466 value: ["typography", "textShadow"], 1467 support: ["typography", "textShadow"], 1468 useEngine: true 1469 }, 1470 writingMode: { 1471 value: ["typography", "writingMode"], 1472 support: ["typography", "__experimentalWritingMode"], 1473 useEngine: true 1474 }, 1475 "--wp--style--root--padding": { 1476 value: ["spacing", "padding"], 1477 support: ["spacing", "padding"], 1478 properties: { 1479 "--wp--style--root--padding-top": "top", 1480 "--wp--style--root--padding-right": "right", 1481 "--wp--style--root--padding-bottom": "bottom", 1482 "--wp--style--root--padding-left": "left" 1483 }, 1484 rootOnly: true 1485 } 1486 }; 1487 var __EXPERIMENTAL_ELEMENTS = { 1488 link: "a:where(:not(.wp-element-button))", 1489 heading: "h1, h2, h3, h4, h5, h6", 1490 h1: "h1", 1491 h2: "h2", 1492 h3: "h3", 1493 h4: "h4", 1494 h5: "h5", 1495 h6: "h6", 1496 button: ".wp-element-button, .wp-block-button__link", 1497 caption: ".wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption", 1498 cite: "cite", 1499 label: "label", 1500 select: "select", 1501 textInput: "textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url])" 1502 }; 1503 var __EXPERIMENTAL_PATHS_WITH_OVERRIDE = { 1504 "color.duotone": true, 1505 "color.gradients": true, 1506 "color.palette": true, 1507 "dimensions.aspectRatios": true, 1508 "typography.fontSizes": true, 1509 "spacing.spacingSizes": true 1510 }; 1511 1512 // packages/blocks/build-module/api/registration.mjs 1513 var import_data = __toESM(require_data(), 1); 1514 var import_i18n = __toESM(require_i18n(), 1); 1515 var import_warning = __toESM(require_warning(), 1); 1516 1517 // packages/blocks/build-module/api/i18n-block.json 1518 var i18n_block_default = { 1519 title: "block title", 1520 description: "block description", 1521 keywords: ["block keyword"], 1522 styles: [ 1523 { 1524 label: "block style label" 1525 } 1526 ], 1527 variations: [ 1528 { 1529 title: "block variation title", 1530 description: "block variation description", 1531 keywords: ["block variation keyword"] 1532 } 1533 ] 1534 }; 1535 1536 // packages/blocks/build-module/lock-unlock.mjs 1537 var import_private_apis = __toESM(require_private_apis(), 1); 1538 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1539 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1540 "@wordpress/blocks" 1541 ); 1542 1543 // packages/blocks/build-module/api/registration.mjs 1544 function isObject(object) { 1545 return object !== null && typeof object === "object"; 1546 } 1547 function unstable__bootstrapServerSideBlockDefinitions(definitions) { 1548 const { addBootstrappedBlockType: addBootstrappedBlockType2 } = unlock((0, import_data.dispatch)(store)); 1549 for (const [name, blockType] of Object.entries(definitions)) { 1550 addBootstrappedBlockType2(name, blockType); 1551 } 1552 } 1553 function getBlockSettingsFromMetadata({ 1554 textdomain, 1555 ...metadata 1556 }) { 1557 const allowedFields = [ 1558 "apiVersion", 1559 "title", 1560 "category", 1561 "parent", 1562 "ancestor", 1563 "icon", 1564 "description", 1565 "keywords", 1566 "attributes", 1567 "providesContext", 1568 "usesContext", 1569 "selectors", 1570 "supports", 1571 "styles", 1572 "example", 1573 "variations", 1574 "blockHooks", 1575 "allowedBlocks" 1576 ]; 1577 const settings = Object.fromEntries( 1578 Object.entries(metadata).filter( 1579 ([key]) => allowedFields.includes(key) 1580 ) 1581 ); 1582 if (textdomain) { 1583 Object.keys(i18n_block_default).forEach((key) => { 1584 if (!settings[key]) { 1585 return; 1586 } 1587 settings[key] = translateBlockSettingUsingI18nSchema( 1588 i18n_block_default[key], 1589 settings[key], 1590 textdomain 1591 ); 1592 }); 1593 } 1594 return settings; 1595 } 1596 function registerBlockType(blockNameOrMetadata, settings) { 1597 const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; 1598 if (typeof name !== "string") { 1599 (0, import_warning.default)("Block names must be strings."); 1600 return; 1601 } 1602 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { 1603 (0, import_warning.default)( 1604 "Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block" 1605 ); 1606 return; 1607 } 1608 if ((0, import_data.select)(store).getBlockType(name)) { 1609 (0, import_warning.default)('Block "' + name + '" is already registered.'); 1610 return; 1611 } 1612 const { addBootstrappedBlockType: addBootstrappedBlockType2, addUnprocessedBlockType: addUnprocessedBlockType2 } = unlock( 1613 (0, import_data.dispatch)(store) 1614 ); 1615 if (isObject(blockNameOrMetadata)) { 1616 const metadata = getBlockSettingsFromMetadata(blockNameOrMetadata); 1617 addBootstrappedBlockType2(name, metadata); 1618 } 1619 addUnprocessedBlockType2(name, settings); 1620 return (0, import_data.select)(store).getBlockType(name); 1621 } 1622 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { 1623 if (typeof i18nSchema === "string" && typeof settingValue === "string") { 1624 return (0, import_i18n._x)(settingValue, i18nSchema, textdomain); 1625 } 1626 if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) { 1627 return settingValue.map( 1628 (value) => translateBlockSettingUsingI18nSchema( 1629 i18nSchema[0], 1630 value, 1631 textdomain 1632 ) 1633 ); 1634 } 1635 if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) { 1636 return Object.keys(settingValue).reduce( 1637 (accumulator, key) => { 1638 if (!i18nSchema[key]) { 1639 accumulator[key] = settingValue[key]; 1640 return accumulator; 1641 } 1642 accumulator[key] = translateBlockSettingUsingI18nSchema( 1643 i18nSchema[key], 1644 settingValue[key], 1645 textdomain 1646 ); 1647 return accumulator; 1648 }, 1649 {} 1650 ); 1651 } 1652 return settingValue; 1653 } 1654 function registerBlockCollection(namespace, { title, icon }) { 1655 (0, import_data.dispatch)(store).addBlockCollection(namespace, title, icon); 1656 } 1657 function unregisterBlockType(name) { 1658 const oldBlock = (0, import_data.select)(store).getBlockType(name); 1659 if (!oldBlock) { 1660 (0, import_warning.default)('Block "' + name + '" is not registered.'); 1661 return; 1662 } 1663 (0, import_data.dispatch)(store).removeBlockTypes(name); 1664 return oldBlock; 1665 } 1666 function setFreeformContentHandlerName(blockName) { 1667 (0, import_data.dispatch)(store).setFreeformFallbackBlockName(blockName); 1668 } 1669 function getFreeformContentHandlerName() { 1670 return (0, import_data.select)(store).getFreeformFallbackBlockName(); 1671 } 1672 function getGroupingBlockName() { 1673 return (0, import_data.select)(store).getGroupingBlockName(); 1674 } 1675 function setUnregisteredTypeHandlerName(blockName) { 1676 (0, import_data.dispatch)(store).setUnregisteredFallbackBlockName(blockName); 1677 } 1678 function getUnregisteredTypeHandlerName() { 1679 return (0, import_data.select)(store).getUnregisteredFallbackBlockName(); 1680 } 1681 function setDefaultBlockName(name) { 1682 (0, import_data.dispatch)(store).setDefaultBlockName(name); 1683 } 1684 function setGroupingBlockName(name) { 1685 (0, import_data.dispatch)(store).setGroupingBlockName(name); 1686 } 1687 function getDefaultBlockName() { 1688 return (0, import_data.select)(store).getDefaultBlockName(); 1689 } 1690 function getBlockType(name) { 1691 return (0, import_data.select)(store)?.getBlockType(name); 1692 } 1693 function getBlockTypes() { 1694 return (0, import_data.select)(store).getBlockTypes(); 1695 } 1696 function getBlockSupport(nameOrType, feature, defaultSupports) { 1697 return (0, import_data.select)(store).getBlockSupport( 1698 nameOrType, 1699 feature, 1700 defaultSupports 1701 ); 1702 } 1703 function hasBlockSupport(nameOrType, feature, defaultSupports) { 1704 return (0, import_data.select)(store).hasBlockSupport( 1705 nameOrType, 1706 feature, 1707 defaultSupports 1708 ); 1709 } 1710 function isReusableBlock(blockOrType) { 1711 return blockOrType?.name === "core/block"; 1712 } 1713 function isTemplatePart(blockOrType) { 1714 return blockOrType?.name === "core/template-part"; 1715 } 1716 var getChildBlockNames = (blockName) => { 1717 return (0, import_data.select)(store).getChildBlockNames(blockName); 1718 }; 1719 var hasChildBlocks = (blockName) => { 1720 return (0, import_data.select)(store).hasChildBlocks(blockName); 1721 }; 1722 var hasChildBlocksWithInserterSupport = (blockName) => { 1723 return (0, import_data.select)(store).hasChildBlocksWithInserterSupport(blockName); 1724 }; 1725 var registerBlockStyle = (blockNames, styleVariation) => { 1726 (0, import_data.dispatch)(store).addBlockStyles(blockNames, styleVariation); 1727 }; 1728 var unregisterBlockStyle = (blockName, styleVariationName) => { 1729 (0, import_data.dispatch)(store).removeBlockStyles(blockName, styleVariationName); 1730 }; 1731 var getBlockVariations = (blockName, scope) => { 1732 return (0, import_data.select)(store).getBlockVariations(blockName, scope); 1733 }; 1734 var registerBlockVariation = (blockName, variation) => { 1735 if (Array.isArray(variation)) { 1736 for (const v3 of variation) { 1737 if (typeof v3.name !== "string") { 1738 (0, import_warning.default)("Variation names must be unique strings."); 1739 } 1740 } 1741 } else if (typeof variation.name !== "string") { 1742 (0, import_warning.default)("Variation names must be unique strings."); 1743 } 1744 (0, import_data.dispatch)(store).addBlockVariations(blockName, variation); 1745 }; 1746 var unregisterBlockVariation = (blockName, variationName) => { 1747 (0, import_data.dispatch)(store).removeBlockVariations(blockName, variationName); 1748 }; 1749 var registerBlockBindingsSource = (source) => { 1750 const { 1751 name, 1752 label, 1753 usesContext, 1754 getValues, 1755 setValues, 1756 canUserEditValue, 1757 getFieldsList 1758 } = source; 1759 const existingSource = unlock( 1760 (0, import_data.select)(store) 1761 ).getBlockBindingsSource(name); 1762 const serverProps = ["label", "usesContext"]; 1763 for (const prop2 in existingSource) { 1764 if (!serverProps.includes(prop2) && existingSource[prop2]) { 1765 (0, import_warning.default)( 1766 'Block bindings source "' + name + '" is already registered.' 1767 ); 1768 return; 1769 } 1770 } 1771 if (!name) { 1772 (0, import_warning.default)("Block bindings source must contain a name."); 1773 return; 1774 } 1775 if (typeof name !== "string") { 1776 (0, import_warning.default)("Block bindings source name must be a string."); 1777 return; 1778 } 1779 if (/[A-Z]+/.test(name)) { 1780 (0, import_warning.default)( 1781 "Block bindings source name must not contain uppercase characters." 1782 ); 1783 return; 1784 } 1785 if (!/^[a-z0-9/-]+$/.test(name)) { 1786 (0, import_warning.default)( 1787 "Block bindings source name must contain only valid characters: lowercase characters, hyphens, or digits. Example: my-plugin/my-custom-source." 1788 ); 1789 return; 1790 } 1791 if (!/^[a-z0-9-]+\/[a-z0-9-]+$/.test(name)) { 1792 (0, import_warning.default)( 1793 "Block bindings source name must contain a namespace and valid characters. Example: my-plugin/my-custom-source." 1794 ); 1795 return; 1796 } 1797 if (!label && !existingSource?.label) { 1798 (0, import_warning.default)("Block bindings source must contain a label."); 1799 return; 1800 } 1801 if (label && typeof label !== "string") { 1802 (0, import_warning.default)("Block bindings source label must be a string."); 1803 return; 1804 } 1805 if (label && existingSource?.label && label !== existingSource?.label) { 1806 (0, import_warning.default)('Block bindings "' + name + '" source label was overridden.'); 1807 } 1808 if (usesContext && !Array.isArray(usesContext)) { 1809 (0, import_warning.default)("Block bindings source usesContext must be an array."); 1810 return; 1811 } 1812 if (getValues && typeof getValues !== "function") { 1813 (0, import_warning.default)("Block bindings source getValues must be a function."); 1814 return; 1815 } 1816 if (setValues && typeof setValues !== "function") { 1817 (0, import_warning.default)("Block bindings source setValues must be a function."); 1818 return; 1819 } 1820 if (canUserEditValue && typeof canUserEditValue !== "function") { 1821 (0, import_warning.default)("Block bindings source canUserEditValue must be a function."); 1822 return; 1823 } 1824 if (getFieldsList && typeof getFieldsList !== "function") { 1825 (0, import_warning.default)("Block bindings source getFieldsList must be a function."); 1826 return; 1827 } 1828 return unlock((0, import_data.dispatch)(store)).addBlockBindingsSource(source); 1829 }; 1830 function unregisterBlockBindingsSource(name) { 1831 const oldSource = getBlockBindingsSource(name); 1832 if (!oldSource) { 1833 (0, import_warning.default)('Block bindings source "' + name + '" is not registered.'); 1834 return; 1835 } 1836 unlock((0, import_data.dispatch)(store)).removeBlockBindingsSource(name); 1837 } 1838 function getBlockBindingsSource(name) { 1839 return unlock((0, import_data.select)(store)).getBlockBindingsSource(name); 1840 } 1841 function getBlockBindingsSources() { 1842 return unlock((0, import_data.select)(store)).getAllBlockBindingsSources(); 1843 } 1844 1845 // packages/blocks/build-module/api/utils.mjs 1846 D([e, r]); 1847 var ICON_COLORS = ["#191e23", "#f8f9f9"]; 1848 function isUnmodifiedBlock(block, role) { 1849 const blockAttributes = getBlockType(block.name)?.attributes ?? {}; 1850 const attributesByRole = role ? Object.entries(blockAttributes).filter(([key, definition]) => { 1851 if (role === "content" && key === "metadata") { 1852 return Object.keys( 1853 block.attributes[key]?.bindings ?? {} 1854 ).length > 0; 1855 } 1856 return definition.role === role || definition.__experimentalRole === role; 1857 }) : []; 1858 const attributesToCheck = !!attributesByRole.length ? attributesByRole : Object.entries(blockAttributes); 1859 return attributesToCheck.every(([key, definition]) => { 1860 const value = block.attributes[key]; 1861 if (definition.hasOwnProperty("default")) { 1862 return value === definition.default; 1863 } 1864 if (definition.type === "rich-text") { 1865 return !value?.length; 1866 } 1867 return value === void 0; 1868 }); 1869 } 1870 function isUnmodifiedDefaultBlock(block, role) { 1871 return block.name === getDefaultBlockName() && isUnmodifiedBlock(block, role); 1872 } 1873 function isValidIcon(icon) { 1874 return !!icon && (typeof icon === "string" || (0, import_element.isValidElement)(icon) || typeof icon === "function" || icon instanceof import_element.Component); 1875 } 1876 function normalizeIconObject(icon) { 1877 const resolvedIcon = icon || BLOCK_ICON_DEFAULT; 1878 if (isValidIcon(resolvedIcon)) { 1879 return { src: resolvedIcon }; 1880 } 1881 const iconDescriptor = resolvedIcon; 1882 if ("background" in iconDescriptor) { 1883 const colordBgColor = A(iconDescriptor.background); 1884 const getColorContrast = (iconColor) => colordBgColor.contrast(iconColor); 1885 const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast)); 1886 return { 1887 ...iconDescriptor, 1888 foreground: iconDescriptor.foreground ? iconDescriptor.foreground : ICON_COLORS.find( 1889 (iconColor) => getColorContrast(iconColor) === maxContrast 1890 ), 1891 shadowColor: colordBgColor.alpha(0.3).toRgbString() 1892 }; 1893 } 1894 return iconDescriptor; 1895 } 1896 function normalizeBlockType(blockTypeOrName) { 1897 if (typeof blockTypeOrName === "string") { 1898 return getBlockType(blockTypeOrName); 1899 } 1900 return blockTypeOrName; 1901 } 1902 function getBlockLabel(blockType, attributes, context = "visual") { 1903 const { __experimentalLabel: getLabel, title } = blockType; 1904 const label = getLabel && getLabel(attributes, { context }); 1905 if (!label) { 1906 return title; 1907 } 1908 if (label.toPlainText) { 1909 return label.toPlainText(); 1910 } 1911 return (0, import_dom.__unstableStripHTML)(label); 1912 } 1913 function getAccessibleBlockLabel(blockType, attributes, position, direction = "vertical") { 1914 const title = blockType?.title ?? ""; 1915 const label = blockType ? getBlockLabel(blockType, attributes, "accessibility") : ""; 1916 const hasPosition = position !== void 0; 1917 const hasLabel = label && label !== title; 1918 if (hasPosition && direction === "vertical") { 1919 if (hasLabel) { 1920 return (0, import_i18n2.sprintf)( 1921 /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ 1922 (0, import_i18n2.__)("%1$s Block. Row %2$d. %3$s"), 1923 title, 1924 position, 1925 label 1926 ); 1927 } 1928 return (0, import_i18n2.sprintf)( 1929 /* translators: accessibility text. 1: The block title. 2: The block row number. */ 1930 (0, import_i18n2.__)("%1$s Block. Row %2$d"), 1931 title, 1932 position 1933 ); 1934 } else if (hasPosition && direction === "horizontal") { 1935 if (hasLabel) { 1936 return (0, import_i18n2.sprintf)( 1937 /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ 1938 (0, import_i18n2.__)("%1$s Block. Column %2$d. %3$s"), 1939 title, 1940 position, 1941 label 1942 ); 1943 } 1944 return (0, import_i18n2.sprintf)( 1945 /* translators: accessibility text. 1: The block title. 2: The block column number. */ 1946 (0, import_i18n2.__)("%1$s Block. Column %2$d"), 1947 title, 1948 position 1949 ); 1950 } 1951 if (hasLabel) { 1952 return (0, import_i18n2.sprintf)( 1953 /* translators: accessibility text. 1: The block title. 2: The block label. */ 1954 (0, import_i18n2.__)("%1$s Block. %2$s"), 1955 title, 1956 label 1957 ); 1958 } 1959 return (0, import_i18n2.sprintf)( 1960 /* translators: accessibility text. %s: The block title. */ 1961 (0, import_i18n2.__)("%s Block"), 1962 title 1963 ); 1964 } 1965 function getDefault(attributeSchema) { 1966 if (attributeSchema.default !== void 0) { 1967 return attributeSchema.default; 1968 } 1969 if (attributeSchema.type === "rich-text") { 1970 return new import_rich_text.RichTextData(); 1971 } 1972 return void 0; 1973 } 1974 function isBlockRegistered(name) { 1975 return getBlockType(name) !== void 0; 1976 } 1977 function sanitizeBlockAttributes(name, attributes) { 1978 const blockType = getBlockType(name); 1979 if (void 0 === blockType) { 1980 throw new Error(`Block type '$name}' is not registered.`); 1981 } 1982 return Object.entries(blockType.attributes).reduce( 1983 (accumulator, [key, schema]) => { 1984 const value = attributes[key]; 1985 if (void 0 !== value) { 1986 if (schema.type === "rich-text") { 1987 if (value instanceof import_rich_text.RichTextData) { 1988 accumulator[key] = value; 1989 } else if (typeof value === "string") { 1990 accumulator[key] = import_rich_text.RichTextData.fromHTMLString(value); 1991 } 1992 } else if (schema.type === "string" && value instanceof import_rich_text.RichTextData) { 1993 accumulator[key] = value.toHTMLString(); 1994 } else { 1995 accumulator[key] = value; 1996 } 1997 } else { 1998 const _default = getDefault(schema); 1999 if (void 0 !== _default) { 2000 accumulator[key] = _default; 2001 } 2002 } 2003 if (["node", "children"].indexOf(schema.source ?? "") !== -1) { 2004 if (typeof accumulator[key] === "string") { 2005 accumulator[key] = [accumulator[key]]; 2006 } else if (!Array.isArray(accumulator[key])) { 2007 accumulator[key] = []; 2008 } 2009 } 2010 return accumulator; 2011 }, 2012 {} 2013 ); 2014 } 2015 function __experimentalSanitizeBlockAttributes(name, attributes) { 2016 (0, import_deprecated.default)("__experimentalSanitizeBlockAttributes", { 2017 since: "7.1", 2018 alternative: "sanitizeBlockAttributes" 2019 }); 2020 return sanitizeBlockAttributes(name, attributes); 2021 } 2022 function getBlockAttributesNamesByRole(name, role) { 2023 const attributes = getBlockType(name)?.attributes; 2024 if (!attributes) { 2025 return []; 2026 } 2027 const attributesNames = Object.keys(attributes); 2028 if (!role) { 2029 return attributesNames; 2030 } 2031 return attributesNames.filter((attributeName) => { 2032 const attribute = attributes[attributeName]; 2033 if (attribute?.role === role) { 2034 return true; 2035 } 2036 if (attribute?.__experimentalRole === role) { 2037 (0, import_deprecated.default)("__experimentalRole attribute", { 2038 since: "6.7", 2039 version: "6.8", 2040 alternative: "role attribute", 2041 hint: `Check the block.json of the $name} block.` 2042 }); 2043 return true; 2044 } 2045 return false; 2046 }); 2047 } 2048 var __experimentalGetBlockAttributesNamesByRole = (...args) => { 2049 (0, import_deprecated.default)("__experimentalGetBlockAttributesNamesByRole", { 2050 since: "6.7", 2051 version: "6.8", 2052 alternative: "getBlockAttributesNamesByRole" 2053 }); 2054 return getBlockAttributesNamesByRole(...args); 2055 }; 2056 function isContentBlock(name) { 2057 const blockType = getBlockType(name); 2058 const attributes = blockType?.attributes; 2059 const supportsContentRole = blockType?.supports?.contentRole; 2060 if (supportsContentRole) { 2061 return true; 2062 } 2063 if (!attributes) { 2064 return false; 2065 } 2066 return !!Object.keys(attributes)?.some((attributeKey) => { 2067 const attribute = attributes[attributeKey]; 2068 return attribute?.role === "content" || attribute?.__experimentalRole === "content"; 2069 }); 2070 } 2071 function omit(object, keys) { 2072 const keysArray = Array.isArray(keys) ? keys : [keys]; 2073 return Object.fromEntries( 2074 Object.entries(object).filter( 2075 ([key]) => !keysArray.includes(key) 2076 ) 2077 ); 2078 } 2079 2080 // packages/blocks/build-module/store/reducer.mjs 2081 var DEFAULT_CATEGORIES = [ 2082 { slug: "text", title: (0, import_i18n3.__)("Text") }, 2083 { slug: "media", title: (0, import_i18n3.__)("Media") }, 2084 { slug: "design", title: (0, import_i18n3.__)("Design") }, 2085 { slug: "widgets", title: (0, import_i18n3.__)("Widgets") }, 2086 { slug: "theme", title: (0, import_i18n3.__)("Theme") }, 2087 { slug: "embed", title: (0, import_i18n3.__)("Embeds") }, 2088 { slug: "reusable", title: (0, import_i18n3.__)("Reusable blocks") } 2089 ]; 2090 function keyBlockTypesByName(types) { 2091 return types.reduce( 2092 (newBlockTypes, block) => ({ 2093 ...newBlockTypes, 2094 [block.name]: block 2095 }), 2096 {} 2097 ); 2098 } 2099 function getUniqueItemsByName(items) { 2100 return items.reduce((acc, currentItem) => { 2101 if (!acc.some((item) => item.name === currentItem.name)) { 2102 acc.push(currentItem); 2103 } 2104 return acc; 2105 }, []); 2106 } 2107 function bootstrappedBlockTypes(state = {}, action) { 2108 switch (action.type) { 2109 case "ADD_BOOTSTRAPPED_BLOCK_TYPE": 2110 const { name, blockType } = action; 2111 const serverDefinition = state[name]; 2112 if (serverDefinition) { 2113 return state; 2114 } 2115 const newDefinition = Object.fromEntries( 2116 Object.entries(blockType).filter( 2117 ([, value]) => value !== null && value !== void 0 2118 ).map(([key, value]) => [camelCase(key), value]) 2119 ); 2120 newDefinition.name = name; 2121 return { 2122 ...state, 2123 [name]: newDefinition 2124 }; 2125 case "REMOVE_BLOCK_TYPES": 2126 return omit(state, action.names); 2127 } 2128 return state; 2129 } 2130 function unprocessedBlockTypes(state = {}, action) { 2131 switch (action.type) { 2132 case "ADD_UNPROCESSED_BLOCK_TYPE": 2133 return { 2134 ...state, 2135 [action.name]: action.blockType 2136 }; 2137 case "REMOVE_BLOCK_TYPES": 2138 return omit(state, action.names); 2139 } 2140 return state; 2141 } 2142 function blockTypes(state = {}, action) { 2143 switch (action.type) { 2144 case "ADD_BLOCK_TYPES": 2145 return { 2146 ...state, 2147 ...keyBlockTypesByName(action.blockTypes) 2148 }; 2149 case "REMOVE_BLOCK_TYPES": 2150 return omit(state, action.names); 2151 } 2152 return state; 2153 } 2154 function blockStyles(state = {}, action) { 2155 switch (action.type) { 2156 case "ADD_BLOCK_TYPES": 2157 return { 2158 ...state, 2159 ...Object.fromEntries( 2160 Object.entries( 2161 keyBlockTypesByName(action.blockTypes) 2162 ).map(([name, blockType]) => [ 2163 name, 2164 getUniqueItemsByName([ 2165 ...(blockType.styles ?? []).map((style) => ({ 2166 ...style, 2167 source: "block" 2168 })), 2169 ...(state[blockType.name] ?? []).filter( 2170 ({ source }) => "block" !== source 2171 ) 2172 ]) 2173 ]) 2174 ) 2175 }; 2176 case "ADD_BLOCK_STYLES": 2177 const updatedStyles = {}; 2178 action.blockNames.forEach((blockName) => { 2179 updatedStyles[blockName] = getUniqueItemsByName([ 2180 ...state[blockName] ?? [], 2181 ...action.styles 2182 ]); 2183 }); 2184 return { ...state, ...updatedStyles }; 2185 case "REMOVE_BLOCK_STYLES": 2186 return { 2187 ...state, 2188 [action.blockName]: (state[action.blockName] ?? []).filter( 2189 (style) => action.styleNames.indexOf(style.name) === -1 2190 ) 2191 }; 2192 } 2193 return state; 2194 } 2195 function blockVariations(state = {}, action) { 2196 switch (action.type) { 2197 case "ADD_BLOCK_TYPES": 2198 return { 2199 ...state, 2200 ...Object.fromEntries( 2201 Object.entries( 2202 keyBlockTypesByName(action.blockTypes) 2203 ).map(([name, blockType]) => { 2204 return [ 2205 name, 2206 getUniqueItemsByName([ 2207 ...(blockType.variations ?? []).map( 2208 (variation) => ({ 2209 ...variation, 2210 source: "block" 2211 }) 2212 ), 2213 ...(state[blockType.name] ?? []).filter( 2214 ({ source }) => "block" !== source 2215 ) 2216 ]) 2217 ]; 2218 }) 2219 ) 2220 }; 2221 case "ADD_BLOCK_VARIATIONS": 2222 return { 2223 ...state, 2224 [action.blockName]: getUniqueItemsByName([ 2225 ...state[action.blockName] ?? [], 2226 ...action.variations 2227 ]) 2228 }; 2229 case "REMOVE_BLOCK_VARIATIONS": 2230 return { 2231 ...state, 2232 [action.blockName]: (state[action.blockName] ?? []).filter( 2233 (variation) => action.variationNames.indexOf(variation.name) === -1 2234 ) 2235 }; 2236 } 2237 return state; 2238 } 2239 function createBlockNameSetterReducer(setActionType) { 2240 return (state = null, action) => { 2241 switch (action.type) { 2242 case "REMOVE_BLOCK_TYPES": 2243 if (action.names.indexOf(state) !== -1) { 2244 return null; 2245 } 2246 return state; 2247 case setActionType: 2248 return action.name || null; 2249 } 2250 return state; 2251 }; 2252 } 2253 var defaultBlockName = createBlockNameSetterReducer( 2254 "SET_DEFAULT_BLOCK_NAME" 2255 ); 2256 var freeformFallbackBlockName = createBlockNameSetterReducer( 2257 "SET_FREEFORM_FALLBACK_BLOCK_NAME" 2258 ); 2259 var unregisteredFallbackBlockName = createBlockNameSetterReducer( 2260 "SET_UNREGISTERED_FALLBACK_BLOCK_NAME" 2261 ); 2262 var groupingBlockName = createBlockNameSetterReducer( 2263 "SET_GROUPING_BLOCK_NAME" 2264 ); 2265 function categories(state = DEFAULT_CATEGORIES, action) { 2266 switch (action.type) { 2267 case "SET_CATEGORIES": 2268 const uniqueCategories = /* @__PURE__ */ new Map(); 2269 (action.categories || []).forEach((category) => { 2270 uniqueCategories.set(category.slug, category); 2271 }); 2272 return [...uniqueCategories.values()]; 2273 case "UPDATE_CATEGORY": { 2274 if (!action.category || !Object.keys(action.category).length) { 2275 return state; 2276 } 2277 const categoryToChange = state.find( 2278 ({ slug }) => slug === action.slug 2279 ); 2280 if (categoryToChange) { 2281 return state.map((category) => { 2282 if (category.slug === action.slug) { 2283 return { 2284 ...category, 2285 ...action.category 2286 }; 2287 } 2288 return category; 2289 }); 2290 } 2291 } 2292 } 2293 return state; 2294 } 2295 function collections(state = {}, action) { 2296 switch (action.type) { 2297 case "ADD_BLOCK_COLLECTION": 2298 return { 2299 ...state, 2300 [action.namespace]: { 2301 title: action.title, 2302 icon: action.icon 2303 } 2304 }; 2305 case "REMOVE_BLOCK_COLLECTION": 2306 return omit(state, action.namespace); 2307 } 2308 return state; 2309 } 2310 function getMergedUsesContext(existingUsesContext = [], newUsesContext = []) { 2311 const mergedArrays = Array.from( 2312 new Set(existingUsesContext.concat(newUsesContext)) 2313 ); 2314 return mergedArrays.length > 0 ? mergedArrays : void 0; 2315 } 2316 function blockBindingsSources(state = {}, action) { 2317 switch (action.type) { 2318 case "ADD_BLOCK_BINDINGS_SOURCE": 2319 return { 2320 ...state, 2321 [action.name]: { 2322 label: action.label || state[action.name]?.label, 2323 usesContext: getMergedUsesContext( 2324 state[action.name]?.usesContext, 2325 action.usesContext 2326 ), 2327 getValues: action.getValues, 2328 setValues: action.setValues, 2329 // Only set `canUserEditValue` if `setValues` is also defined. 2330 canUserEditValue: action.setValues && action.canUserEditValue, 2331 getFieldsList: action.getFieldsList 2332 } 2333 }; 2334 case "REMOVE_BLOCK_BINDINGS_SOURCE": 2335 return omit(state, action.name); 2336 } 2337 return state; 2338 } 2339 var reducer_default = (0, import_data2.combineReducers)({ 2340 bootstrappedBlockTypes, 2341 unprocessedBlockTypes, 2342 blockTypes, 2343 blockStyles, 2344 blockVariations, 2345 defaultBlockName, 2346 freeformFallbackBlockName, 2347 unregisteredFallbackBlockName, 2348 groupingBlockName, 2349 categories, 2350 collections, 2351 blockBindingsSources 2352 }); 2353 2354 // packages/blocks/build-module/store/selectors.mjs 2355 var selectors_exports = {}; 2356 __export(selectors_exports, { 2357 __experimentalHasContentRoleAttribute: () => __experimentalHasContentRoleAttribute, 2358 getActiveBlockVariation: () => getActiveBlockVariation, 2359 getBlockStyles: () => getBlockStyles, 2360 getBlockSupport: () => getBlockSupport2, 2361 getBlockType: () => getBlockType2, 2362 getBlockTypes: () => getBlockTypes2, 2363 getBlockVariations: () => getBlockVariations2, 2364 getCategories: () => getCategories, 2365 getChildBlockNames: () => getChildBlockNames2, 2366 getCollections: () => getCollections, 2367 getDefaultBlockName: () => getDefaultBlockName2, 2368 getDefaultBlockVariation: () => getDefaultBlockVariation, 2369 getFreeformFallbackBlockName: () => getFreeformFallbackBlockName, 2370 getGroupingBlockName: () => getGroupingBlockName2, 2371 getUnregisteredFallbackBlockName: () => getUnregisteredFallbackBlockName, 2372 hasBlockSupport: () => hasBlockSupport2, 2373 hasChildBlocks: () => hasChildBlocks2, 2374 hasChildBlocksWithInserterSupport: () => hasChildBlocksWithInserterSupport2, 2375 isMatchingSearchTerm: () => isMatchingSearchTerm 2376 }); 2377 var import_remove_accents = __toESM(require_remove_accents(), 1); 2378 var import_es6 = __toESM(require_es6(), 1); 2379 var import_data4 = __toESM(require_data(), 1); 2380 var import_rich_text2 = __toESM(require_rich_text(), 1); 2381 var import_deprecated3 = __toESM(require_deprecated(), 1); 2382 2383 // packages/blocks/build-module/store/utils.mjs 2384 var getValueFromObjectPath = (object, path, defaultValue) => { 2385 const normalizedPath = Array.isArray(path) ? path : path.split("."); 2386 let value = object; 2387 normalizedPath.forEach((fieldName) => { 2388 value = value?.[fieldName]; 2389 }); 2390 return value ?? defaultValue; 2391 }; 2392 function isObject2(candidate) { 2393 return typeof candidate === "object" && candidate !== null && candidate.constructor === Object; 2394 } 2395 function matchesAttributes(blockAttributes, variationAttributes) { 2396 if (isObject2(blockAttributes) && isObject2(variationAttributes)) { 2397 return Object.entries(variationAttributes).every( 2398 ([key, value]) => matchesAttributes(blockAttributes?.[key], value) 2399 ); 2400 } 2401 return blockAttributes === variationAttributes; 2402 } 2403 2404 // packages/blocks/build-module/store/private-selectors.mjs 2405 var private_selectors_exports = {}; 2406 __export(private_selectors_exports, { 2407 getAllBlockBindingsSources: () => getAllBlockBindingsSources, 2408 getBlockBindingsSource: () => getBlockBindingsSource2, 2409 getBlockBindingsSourceFieldsList: () => getBlockBindingsSourceFieldsList, 2410 getBlockKeyboardShortcuts: () => getBlockKeyboardShortcuts, 2411 getBlockVariationsRaw: () => getBlockVariationsRaw, 2412 getBootstrappedBlockType: () => getBootstrappedBlockType, 2413 getSupportedStyles: () => getSupportedStyles, 2414 getUnprocessedBlockTypes: () => getUnprocessedBlockTypes, 2415 hasContentRoleAttribute: () => hasContentRoleAttribute 2416 }); 2417 var import_data3 = __toESM(require_data(), 1); 2418 var import_deprecated2 = __toESM(require_deprecated(), 1); 2419 var ROOT_BLOCK_SUPPORTS = [ 2420 "background", 2421 "backgroundColor", 2422 "color", 2423 "linkColor", 2424 "captionColor", 2425 "buttonColor", 2426 "headingColor", 2427 "fontFamily", 2428 "fontSize", 2429 "fontStyle", 2430 "fontWeight", 2431 "lineHeight", 2432 "padding", 2433 "contentSize", 2434 "wideSize", 2435 "blockGap", 2436 "textAlign", 2437 "textDecoration", 2438 "textIndent", 2439 "textTransform", 2440 "textShadow", 2441 "letterSpacing" 2442 ]; 2443 var ELEMENT_BLOCK_SUPPORTS = [ 2444 ...ROOT_BLOCK_SUPPORTS, 2445 "backgroundGradient", 2446 "backgroundImage", 2447 "backgroundSize", 2448 "borderColor", 2449 "borderRadius", 2450 "borderStyle", 2451 "borderWidth", 2452 "margin", 2453 "shadow", 2454 "writingMode" 2455 ]; 2456 function filterElementBlockSupports(blockSupports, name, element) { 2457 return blockSupports.filter((support) => { 2458 if (support === "fontSize" && element === "heading") { 2459 return false; 2460 } 2461 if (support === "textDecoration" && !name && element !== "link") { 2462 return false; 2463 } 2464 if (support === "textTransform" && !name && !(["heading", "h1", "h2", "h3", "h4", "h5", "h6"].includes( 2465 element 2466 ) || element === "button" || element === "caption" || element === "text")) { 2467 return false; 2468 } 2469 if (support === "letterSpacing" && !name && !(["heading", "h1", "h2", "h3", "h4", "h5", "h6"].includes( 2470 element 2471 ) || element === "button" || element === "caption" || element === "text")) { 2472 return false; 2473 } 2474 if (support === "textIndent" && !name) { 2475 return false; 2476 } 2477 if (support === "textColumns" && !name) { 2478 return false; 2479 } 2480 const isElement = !name && !!element && element in __EXPERIMENTAL_ELEMENTS; 2481 if (["blockGap", "contentSize", "wideSize"].includes(support) && isElement) { 2482 return false; 2483 } 2484 return true; 2485 }); 2486 } 2487 var getSupportedStyles = (0, import_data3.createSelector)( 2488 (state, name, element) => { 2489 if (!name) { 2490 const isElement = !!element && element in __EXPERIMENTAL_ELEMENTS; 2491 return filterElementBlockSupports( 2492 isElement ? ELEMENT_BLOCK_SUPPORTS : ROOT_BLOCK_SUPPORTS, 2493 name, 2494 element 2495 ); 2496 } 2497 const blockType = getBlockType2(state, name); 2498 if (!blockType) { 2499 return []; 2500 } 2501 const supportKeys = []; 2502 const supports = blockType?.supports; 2503 if (supports?.spacing?.blockGap) { 2504 supportKeys.push("blockGap"); 2505 } 2506 if (supports?.shadow) { 2507 supportKeys.push("shadow"); 2508 } 2509 const stylePropertyMap = __EXPERIMENTAL_STYLE_PROPERTY; 2510 Object.keys(stylePropertyMap).forEach((styleName) => { 2511 if (!stylePropertyMap[styleName].support) { 2512 return; 2513 } 2514 if (stylePropertyMap[styleName].requiresOptOut) { 2515 if (supports && stylePropertyMap[styleName].support[0] in supports && getValueFromObjectPath( 2516 supports, 2517 stylePropertyMap[styleName].support 2518 ) !== false) { 2519 supportKeys.push(styleName); 2520 return; 2521 } 2522 } 2523 if (supports && getValueFromObjectPath( 2524 supports, 2525 stylePropertyMap[styleName].support, 2526 false 2527 )) { 2528 supportKeys.push(styleName); 2529 } 2530 }); 2531 return filterElementBlockSupports(supportKeys, name, element); 2532 }, 2533 (state, name) => [ 2534 state.blockTypes[name] 2535 ] 2536 ); 2537 function getBootstrappedBlockType(state, name) { 2538 return state.bootstrappedBlockTypes[name]; 2539 } 2540 function getUnprocessedBlockTypes(state) { 2541 return state.unprocessedBlockTypes; 2542 } 2543 function getBlockVariationsRaw(state) { 2544 return state.blockVariations; 2545 } 2546 function getAllBlockBindingsSources(state) { 2547 return state.blockBindingsSources; 2548 } 2549 function getBlockBindingsSource2(state, sourceName) { 2550 return state.blockBindingsSources[sourceName]; 2551 } 2552 var getBlockBindingsSourceFieldsList = (0, import_data3.createRegistrySelector)( 2553 (select3) => (0, import_data3.createSelector)( 2554 (state, source, blockContext) => { 2555 if (!source.getFieldsList) { 2556 return []; 2557 } 2558 const context = {}; 2559 if (source?.usesContext?.length) { 2560 for (const key of source.usesContext) { 2561 context[key] = blockContext[key]; 2562 } 2563 } 2564 return source.getFieldsList({ select: select3, context }); 2565 }, 2566 (state, source, blockContext) => [source.getFieldsList, source.usesContext, blockContext] 2567 ) 2568 ); 2569 var getBlockKeyboardShortcuts = (0, import_data3.createSelector)( 2570 (state) => { 2571 const shortcuts = []; 2572 for (const blockName of Object.keys(state.blockTypes)) { 2573 for (const variation of state.blockVariations[blockName] ?? []) { 2574 if (!variation.shortcut) { 2575 continue; 2576 } 2577 shortcuts.push({ 2578 ...variation.shortcut, 2579 targetBlockName: blockName, 2580 blockNames: [blockName], 2581 variationName: variation.name 2582 }); 2583 } 2584 const transforms = state.blockTypes[blockName]?.transforms; 2585 for (const transform of transforms?.to ?? []) { 2586 if (transform.type !== "block") { 2587 continue; 2588 } 2589 const targetBlockName = transform.blocks?.[0]; 2590 if (!targetBlockName) { 2591 continue; 2592 } 2593 for (const shortcut of transform.shortcuts ?? []) { 2594 shortcuts.push({ 2595 ...shortcut, 2596 targetBlockName, 2597 blockNames: [blockName], 2598 variationName: shortcut.variationName ?? transform.variationName 2599 }); 2600 } 2601 } 2602 for (const transform of transforms?.from ?? []) { 2603 if (transform.type !== "block" || !transform.blocks?.length) { 2604 continue; 2605 } 2606 for (const shortcut of transform.shortcuts ?? []) { 2607 shortcuts.push({ 2608 ...shortcut, 2609 targetBlockName: blockName, 2610 blockNames: transform.blocks, 2611 variationName: shortcut.variationName ?? transform.variationName 2612 }); 2613 } 2614 } 2615 } 2616 return shortcuts; 2617 }, 2618 (state) => [state.blockTypes, state.blockVariations] 2619 ); 2620 var hasContentRoleAttribute = (state, blockTypeName) => { 2621 const blockType = getBlockType2(state, blockTypeName); 2622 if (!blockType) { 2623 return false; 2624 } 2625 return Object.values(blockType.attributes).some( 2626 ({ role, __experimentalRole }) => { 2627 if (role === "content") { 2628 return true; 2629 } 2630 if (__experimentalRole === "content") { 2631 (0, import_deprecated2.default)("__experimentalRole attribute", { 2632 since: "6.7", 2633 version: "6.8", 2634 alternative: "role attribute", 2635 hint: `Check the block.json of the $blockTypeName} block.` 2636 }); 2637 return true; 2638 } 2639 return false; 2640 } 2641 ); 2642 }; 2643 2644 // packages/blocks/build-module/store/selectors.mjs 2645 var getNormalizedBlockType = (state, nameOrType) => "string" === typeof nameOrType ? getBlockType2(state, nameOrType) : nameOrType; 2646 var getBlockTypes2 = (0, import_data4.createSelector)( 2647 (state) => Object.values(state.blockTypes), 2648 (state) => [state.blockTypes] 2649 ); 2650 function getBlockType2(state, name) { 2651 return state.blockTypes[name]; 2652 } 2653 function getBlockStyles(state, name) { 2654 return state.blockStyles[name]; 2655 } 2656 var getBlockVariations2 = (0, import_data4.createSelector)( 2657 (state, blockName, scope) => { 2658 const variations = state.blockVariations[blockName]; 2659 if (!variations || !scope) { 2660 return variations; 2661 } 2662 return variations.filter((variation) => { 2663 return (variation.scope || ["block", "inserter"]).includes( 2664 scope 2665 ); 2666 }); 2667 }, 2668 (state, blockName) => [ 2669 state.blockVariations[blockName] 2670 ] 2671 ); 2672 function getActiveBlockVariation(state, blockName, attributes, scope, innerContent) { 2673 const variations = getBlockVariations2(state, blockName, scope); 2674 if (!variations) { 2675 return variations; 2676 } 2677 if (innerContent) { 2678 const innerContentMatch = variations.find( 2679 (variation) => variation.innerContent && (0, import_es6.default)(variation.innerContent, innerContent) 2680 ); 2681 if (innerContentMatch) { 2682 return innerContentMatch; 2683 } 2684 } 2685 const blockType = getBlockType2(state, blockName); 2686 const attributeKeys = Object.keys(blockType?.attributes || {}); 2687 let match; 2688 let maxMatchedAttributes = 0; 2689 for (const variation of variations) { 2690 if (variation.innerContent) { 2691 continue; 2692 } 2693 if (Array.isArray(variation.isActive)) { 2694 const definedAttributes = variation.isActive.filter( 2695 (attribute) => { 2696 const topLevelAttribute = attribute.split(".")[0]; 2697 return attributeKeys.includes(topLevelAttribute); 2698 } 2699 ); 2700 const definedAttributesLength = definedAttributes.length; 2701 if (definedAttributesLength === 0) { 2702 continue; 2703 } 2704 const isMatch = definedAttributes.every((attribute) => { 2705 const variationAttributeValue = getValueFromObjectPath( 2706 variation.attributes, 2707 attribute 2708 ); 2709 if (variationAttributeValue === void 0) { 2710 return false; 2711 } 2712 let blockAttributeValue = getValueFromObjectPath( 2713 attributes, 2714 attribute 2715 ); 2716 if (blockAttributeValue instanceof import_rich_text2.RichTextData) { 2717 blockAttributeValue = blockAttributeValue.toHTMLString(); 2718 } 2719 return matchesAttributes( 2720 blockAttributeValue, 2721 variationAttributeValue 2722 ); 2723 }); 2724 if (isMatch && definedAttributesLength > maxMatchedAttributes) { 2725 match = variation; 2726 maxMatchedAttributes = definedAttributesLength; 2727 } 2728 } else if (variation.isActive?.( 2729 attributes, 2730 variation.attributes 2731 )) { 2732 return match || variation; 2733 } 2734 } 2735 if (!match && ["block", "transform"].includes(scope)) { 2736 match = variations.find( 2737 (variation) => variation?.isDefault && !Object.hasOwn(variation, "isActive") 2738 ); 2739 } 2740 return match; 2741 } 2742 function getDefaultBlockVariation(state, blockName, scope) { 2743 const variations = getBlockVariations2(state, blockName, scope); 2744 const defaultVariation = [...variations || []].reverse().find(({ isDefault }) => !!isDefault); 2745 return defaultVariation || variations?.[0]; 2746 } 2747 function getCategories(state) { 2748 return state.categories; 2749 } 2750 function getCollections(state) { 2751 return state.collections; 2752 } 2753 function getDefaultBlockName2(state) { 2754 return state.defaultBlockName; 2755 } 2756 function getFreeformFallbackBlockName(state) { 2757 return state.freeformFallbackBlockName; 2758 } 2759 function getUnregisteredFallbackBlockName(state) { 2760 return state.unregisteredFallbackBlockName; 2761 } 2762 function getGroupingBlockName2(state) { 2763 return state.groupingBlockName; 2764 } 2765 var getChildBlockNames2 = (0, import_data4.createSelector)( 2766 (state, blockName) => { 2767 return getBlockTypes2(state).filter((blockType) => { 2768 return blockType.parent?.includes(blockName); 2769 }).map(({ name }) => name); 2770 }, 2771 (state) => [state.blockTypes] 2772 ); 2773 var getBlockSupport2 = (state, nameOrType, feature, defaultSupports) => { 2774 const blockType = getNormalizedBlockType(state, nameOrType); 2775 if (!blockType?.supports) { 2776 return defaultSupports; 2777 } 2778 return getValueFromObjectPath( 2779 blockType.supports, 2780 feature, 2781 defaultSupports 2782 ); 2783 }; 2784 function hasBlockSupport2(state, nameOrType, feature, defaultSupports) { 2785 return !!getBlockSupport2(state, nameOrType, feature, defaultSupports); 2786 } 2787 function getNormalizedSearchTerm(term) { 2788 return (0, import_remove_accents.default)(term ?? "").toLowerCase().trim(); 2789 } 2790 function isMatchingSearchTerm(state, nameOrType, searchTerm = "") { 2791 const blockType = getNormalizedBlockType(state, nameOrType); 2792 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); 2793 const isSearchMatch = (candidate) => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm); 2794 return isSearchMatch(blockType?.title) || blockType?.keywords?.some(isSearchMatch) || isSearchMatch(blockType?.category) || typeof blockType?.description === "string" && isSearchMatch(blockType.description); 2795 } 2796 var hasChildBlocks2 = (state, blockName) => { 2797 return getChildBlockNames2(state, blockName).length > 0; 2798 }; 2799 var hasChildBlocksWithInserterSupport2 = (state, blockName) => { 2800 return getChildBlockNames2(state, blockName).some((childBlockName) => { 2801 return hasBlockSupport2(state, childBlockName, "inserter", true); 2802 }); 2803 }; 2804 var __experimentalHasContentRoleAttribute = (...args) => { 2805 (0, import_deprecated3.default)("__experimentalHasContentRoleAttribute", { 2806 since: "6.7", 2807 version: "6.8", 2808 hint: "This is a private selector." 2809 }); 2810 return hasContentRoleAttribute(...args); 2811 }; 2812 2813 // packages/blocks/build-module/store/actions.mjs 2814 var actions_exports = {}; 2815 __export(actions_exports, { 2816 __experimentalReapplyBlockFilters: () => __experimentalReapplyBlockFilters, 2817 addBlockCollection: () => addBlockCollection, 2818 addBlockStyles: () => addBlockStyles, 2819 addBlockTypes: () => addBlockTypes, 2820 addBlockVariations: () => addBlockVariations, 2821 reapplyBlockTypeFilters: () => reapplyBlockTypeFilters, 2822 removeBlockCollection: () => removeBlockCollection, 2823 removeBlockStyles: () => removeBlockStyles, 2824 removeBlockTypes: () => removeBlockTypes, 2825 removeBlockVariations: () => removeBlockVariations, 2826 setCategories: () => setCategories, 2827 setDefaultBlockName: () => setDefaultBlockName2, 2828 setFreeformFallbackBlockName: () => setFreeformFallbackBlockName, 2829 setGroupingBlockName: () => setGroupingBlockName2, 2830 setUnregisteredFallbackBlockName: () => setUnregisteredFallbackBlockName, 2831 updateCategory: () => updateCategory 2832 }); 2833 var import_deprecated5 = __toESM(require_deprecated(), 1); 2834 2835 // node_modules/.store/is-plain-object@5.1.0-5G_-lUnpSwJHYfRbkIxLrw/node_modules/is-plain-object/dist/is-plain-object.mjs 2836 function isObject3(o2) { 2837 return Object.prototype.toString.call(o2) === "[object Object]"; 2838 } 2839 function isPlainObject(o2) { 2840 var ctor, prot; 2841 if (isObject3(o2) === false) return false; 2842 ctor = o2.constructor; 2843 if (ctor === void 0) return true; 2844 prot = ctor.prototype; 2845 if (isObject3(prot) === false) return false; 2846 if (prot.hasOwnProperty("isPrototypeOf") === false) { 2847 return false; 2848 } 2849 return true; 2850 } 2851 2852 // packages/blocks/build-module/store/process-block-type.mjs 2853 var import_react_is = __toESM(require_react_is(), 1); 2854 var import_deprecated4 = __toESM(require_deprecated(), 1); 2855 var import_hooks = __toESM(require_hooks(), 1); 2856 var import_warning2 = __toESM(require_warning(), 1); 2857 var LEGACY_CATEGORY_MAPPING = { 2858 common: "text", 2859 formatting: "text", 2860 layout: "design" 2861 }; 2862 function mergeBlockVariations(bootstrappedVariations = [], clientVariations = []) { 2863 const result = [...bootstrappedVariations]; 2864 clientVariations.forEach((clientVariation) => { 2865 const index = result.findIndex( 2866 (bootstrappedVariation) => bootstrappedVariation.name === clientVariation.name 2867 ); 2868 if (index !== -1) { 2869 result[index] = { ...result[index], ...clientVariation }; 2870 } else { 2871 result.push(clientVariation); 2872 } 2873 }); 2874 return result; 2875 } 2876 var processBlockType = (name, blockSettings) => ({ 2877 select: select3 2878 }) => { 2879 const bootstrappedBlockType = select3.getBootstrappedBlockType(name); 2880 const blockType = { 2881 apiVersion: 1, 2882 name, 2883 icon: BLOCK_ICON_DEFAULT, 2884 keywords: [], 2885 attributes: {}, 2886 providesContext: {}, 2887 usesContext: [], 2888 selectors: {}, 2889 supports: {}, 2890 styles: [], 2891 blockHooks: {}, 2892 save: () => null, 2893 ...bootstrappedBlockType, 2894 ...blockSettings, 2895 // blockType.variations can be defined as a filePath. 2896 variations: mergeBlockVariations( 2897 Array.isArray(bootstrappedBlockType?.variations) ? bootstrappedBlockType.variations : [], 2898 Array.isArray(blockSettings?.variations) ? blockSettings.variations : [] 2899 ) 2900 }; 2901 if (!blockType.attributes || typeof blockType.attributes !== "object") { 2902 (0, import_warning2.default)( 2903 'The block "' + name + '" is registering attributes as `null` or `undefined`. Use an empty object (`attributes: {}`) or exclude the `attributes` key.' 2904 ); 2905 blockType.attributes = {}; 2906 } 2907 const settings = (0, import_hooks.applyFilters)( 2908 "blocks.registerBlockType", 2909 blockType, 2910 name, 2911 null 2912 ); 2913 if (settings.apiVersion <= 2) { 2914 (0, import_deprecated4.default)("Block with API version 2 or lower", { 2915 since: "6.9", 2916 hint: `The block "$name}" is registered with API version $settings.apiVersion}. This means that the post editor may work as a non-iframe editor. Since all editors are planned to work as iframes in the future, set the \`apiVersion\` field to 3 and test the block inside the iframe editor.`, 2917 link: "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/" 2918 }); 2919 } 2920 if (settings.description && typeof settings.description !== "string") { 2921 (0, import_deprecated4.default)("Declaring non-string block descriptions", { 2922 since: "6.2" 2923 }); 2924 } 2925 if (settings.deprecated) { 2926 settings.deprecated = settings.deprecated.map( 2927 (deprecation) => Object.fromEntries( 2928 Object.entries( 2929 // Only keep valid deprecation keys. 2930 (0, import_hooks.applyFilters)( 2931 "blocks.registerBlockType", 2932 // Merge deprecation keys with pre-filter settings 2933 // so that filters that depend on specific keys being 2934 // present don't fail. 2935 { 2936 // Omit deprecation keys here so that deprecations 2937 // can opt out of specific keys like "supports". 2938 ...omit(blockType, DEPRECATED_ENTRY_KEYS), 2939 ...deprecation 2940 }, 2941 blockType.name, 2942 deprecation 2943 ) 2944 ).filter( 2945 ([key]) => DEPRECATED_ENTRY_KEYS.includes(key) 2946 ) 2947 ) 2948 ); 2949 } 2950 if (!isPlainObject(settings)) { 2951 (0, import_warning2.default)("Block settings must be a valid object."); 2952 return; 2953 } 2954 if (typeof settings.save !== "function") { 2955 (0, import_warning2.default)('The "save" property must be a valid function.'); 2956 return; 2957 } 2958 if ("edit" in settings && !(0, import_react_is.isValidElementType)(settings.edit)) { 2959 (0, import_warning2.default)('The "edit" property must be a valid component.'); 2960 return; 2961 } 2962 if (typeof settings.category === "string" && LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { 2963 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; 2964 } 2965 if ("category" in settings && !select3.getCategories().some( 2966 ({ slug }) => slug === settings.category 2967 )) { 2968 (0, import_warning2.default)( 2969 'The block "' + name + '" is registered with an invalid category "' + settings.category + '".' 2970 ); 2971 delete settings.category; 2972 } 2973 if (!("title" in settings) || settings.title === "") { 2974 (0, import_warning2.default)('The block "' + name + '" must have a title.'); 2975 return; 2976 } 2977 if (typeof settings.title !== "string") { 2978 (0, import_warning2.default)("Block titles must be strings."); 2979 return; 2980 } 2981 const icon = normalizeIconObject(settings.icon); 2982 settings.icon = icon; 2983 if (!isValidIcon(icon.src)) { 2984 (0, import_warning2.default)( 2985 "The icon passed is invalid. The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional" 2986 ); 2987 return; 2988 } 2989 if (typeof settings?.parent === "string" || settings?.parent instanceof String) { 2990 settings.parent = [settings.parent]; 2991 (0, import_warning2.default)( 2992 "Parent must be undefined or an array of strings (block types), but it is a string." 2993 ); 2994 } 2995 if (!Array.isArray(settings?.parent) && settings?.parent !== void 0) { 2996 (0, import_warning2.default)( 2997 "Parent must be undefined or an array of block types, but it is " + settings.parent 2998 ); 2999 return; 3000 } 3001 if (1 === settings?.parent?.length && name === settings.parent[0]) { 3002 (0, import_warning2.default)( 3003 'Block "' + name + '" cannot be a parent of itself. Please remove the block name from the parent list.' 3004 ); 3005 return; 3006 } 3007 return settings; 3008 }; 3009 3010 // packages/blocks/build-module/store/actions.mjs 3011 function addBlockTypes(blockTypes2) { 3012 return { 3013 type: "ADD_BLOCK_TYPES", 3014 blockTypes: Array.isArray(blockTypes2) ? blockTypes2 : [blockTypes2] 3015 }; 3016 } 3017 function reapplyBlockTypeFilters() { 3018 return ({ dispatch: dispatch3, select: select3 }) => { 3019 const processedBlockTypes = []; 3020 for (const [name, settings] of Object.entries( 3021 select3.getUnprocessedBlockTypes() 3022 )) { 3023 const result = dispatch3(processBlockType(name, settings)); 3024 if (result) { 3025 processedBlockTypes.push(result); 3026 } 3027 } 3028 if (!processedBlockTypes.length) { 3029 return; 3030 } 3031 dispatch3.addBlockTypes(processedBlockTypes); 3032 }; 3033 } 3034 function __experimentalReapplyBlockFilters() { 3035 (0, import_deprecated5.default)( 3036 'wp.data.dispatch( "core/blocks" ).__experimentalReapplyBlockFilters', 3037 { 3038 since: "6.4", 3039 alternative: "reapplyBlockFilters" 3040 } 3041 ); 3042 return reapplyBlockTypeFilters(); 3043 } 3044 function removeBlockTypes(names) { 3045 return { 3046 type: "REMOVE_BLOCK_TYPES", 3047 names: Array.isArray(names) ? names : [names] 3048 }; 3049 } 3050 function addBlockStyles(blockNames, styles) { 3051 return { 3052 type: "ADD_BLOCK_STYLES", 3053 styles: Array.isArray(styles) ? styles : [styles], 3054 blockNames: Array.isArray(blockNames) ? blockNames : [blockNames] 3055 }; 3056 } 3057 function removeBlockStyles(blockName, styleNames) { 3058 return { 3059 type: "REMOVE_BLOCK_STYLES", 3060 styleNames: Array.isArray(styleNames) ? styleNames : [styleNames], 3061 blockName 3062 }; 3063 } 3064 function addBlockVariations(blockName, variations) { 3065 return { 3066 type: "ADD_BLOCK_VARIATIONS", 3067 variations: Array.isArray(variations) ? variations : [variations], 3068 blockName 3069 }; 3070 } 3071 function removeBlockVariations(blockName, variationNames) { 3072 return { 3073 type: "REMOVE_BLOCK_VARIATIONS", 3074 variationNames: Array.isArray(variationNames) ? variationNames : [variationNames], 3075 blockName 3076 }; 3077 } 3078 function setDefaultBlockName2(name) { 3079 return { 3080 type: "SET_DEFAULT_BLOCK_NAME", 3081 name 3082 }; 3083 } 3084 function setFreeformFallbackBlockName(name) { 3085 return { 3086 type: "SET_FREEFORM_FALLBACK_BLOCK_NAME", 3087 name 3088 }; 3089 } 3090 function setUnregisteredFallbackBlockName(name) { 3091 return { 3092 type: "SET_UNREGISTERED_FALLBACK_BLOCK_NAME", 3093 name 3094 }; 3095 } 3096 function setGroupingBlockName2(name) { 3097 return { 3098 type: "SET_GROUPING_BLOCK_NAME", 3099 name 3100 }; 3101 } 3102 function setCategories(categories2) { 3103 return { 3104 type: "SET_CATEGORIES", 3105 categories: categories2 3106 }; 3107 } 3108 function updateCategory(slug, category) { 3109 return { 3110 type: "UPDATE_CATEGORY", 3111 slug, 3112 category 3113 }; 3114 } 3115 function addBlockCollection(namespace, title, icon) { 3116 return { 3117 type: "ADD_BLOCK_COLLECTION", 3118 namespace, 3119 title, 3120 icon 3121 }; 3122 } 3123 function removeBlockCollection(namespace) { 3124 return { 3125 type: "REMOVE_BLOCK_COLLECTION", 3126 namespace 3127 }; 3128 } 3129 3130 // packages/blocks/build-module/store/private-actions.mjs 3131 var private_actions_exports = {}; 3132 __export(private_actions_exports, { 3133 addBlockBindingsSource: () => addBlockBindingsSource, 3134 addBootstrappedBlockType: () => addBootstrappedBlockType, 3135 addUnprocessedBlockType: () => addUnprocessedBlockType, 3136 removeBlockBindingsSource: () => removeBlockBindingsSource 3137 }); 3138 function addBootstrappedBlockType(name, blockType) { 3139 return { 3140 type: "ADD_BOOTSTRAPPED_BLOCK_TYPE", 3141 name, 3142 blockType 3143 }; 3144 } 3145 function addUnprocessedBlockType(name, blockType) { 3146 return ({ dispatch: dispatch3 }) => { 3147 dispatch3({ type: "ADD_UNPROCESSED_BLOCK_TYPE", name, blockType }); 3148 const processedBlockType = dispatch3( 3149 processBlockType(name, blockType) 3150 ); 3151 if (!processedBlockType) { 3152 return; 3153 } 3154 dispatch3.addBlockTypes(processedBlockType); 3155 }; 3156 } 3157 function addBlockBindingsSource(source) { 3158 return { 3159 type: "ADD_BLOCK_BINDINGS_SOURCE", 3160 name: source.name, 3161 label: source.label, 3162 usesContext: source.usesContext, 3163 getValues: source.getValues, 3164 setValues: source.setValues, 3165 canUserEditValue: source.canUserEditValue, 3166 getFieldsList: source.getFieldsList 3167 }; 3168 } 3169 function removeBlockBindingsSource(name) { 3170 return { 3171 type: "REMOVE_BLOCK_BINDINGS_SOURCE", 3172 name 3173 }; 3174 } 3175 3176 // packages/blocks/build-module/store/constants.mjs 3177 var STORE_NAME = "core/blocks"; 3178 3179 // packages/blocks/build-module/store/index.mjs 3180 var store = (0, import_data5.createReduxStore)(STORE_NAME, { 3181 reducer: reducer_default, 3182 selectors: selectors_exports, 3183 actions: actions_exports 3184 }); 3185 (0, import_data5.register)(store); 3186 unlock(store).registerPrivateSelectors(private_selectors_exports); 3187 unlock(store).registerPrivateActions(private_actions_exports); 3188 3189 // node_modules/.store/uuid@14.0.2-ALlTd6-Rf9bZs703d7TIjQ/node_modules/uuid/dist/stringify.js 3190 var byteToHex = []; 3191 for (let i = 0; i < 256; ++i) { 3192 byteToHex.push((i + 256).toString(16).slice(1)); 3193 } 3194 function unsafeStringify(arr, offset = 0) { 3195 return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); 3196 } 3197 3198 // node_modules/.store/uuid@14.0.2-ALlTd6-Rf9bZs703d7TIjQ/node_modules/uuid/dist/rng.js 3199 var rnds8 = new Uint8Array(16); 3200 function rng() { 3201 return crypto.getRandomValues(rnds8); 3202 } 3203 3204 // node_modules/.store/uuid@14.0.2-ALlTd6-Rf9bZs703d7TIjQ/node_modules/uuid/dist/v4.js 3205 function v4(options, buf, offset) { 3206 if (!buf && !options && crypto.randomUUID) { 3207 return crypto.randomUUID(); 3208 } 3209 return _v4(options, buf, offset); 3210 } 3211 function _v4(options, buf, offset) { 3212 options = options || {}; 3213 const rnds = options.random ?? options.rng?.() ?? rng(); 3214 if (rnds.length < 16) { 3215 throw new Error("Random bytes length must be >= 16"); 3216 } 3217 rnds[6] = rnds[6] & 15 | 64; 3218 rnds[8] = rnds[8] & 63 | 128; 3219 if (buf) { 3220 offset = offset || 0; 3221 if (offset < 0 || offset + 16 > buf.length) { 3222 throw new RangeError(`UUID byte range $offset}:$offset + 15} is out of buffer bounds`); 3223 } 3224 for (let i = 0; i < 16; ++i) { 3225 buf[offset + i] = rnds[i]; 3226 } 3227 return buf; 3228 } 3229 return unsafeStringify(rnds); 3230 } 3231 var v4_default = v4; 3232 3233 // packages/blocks/build-module/api/factory.mjs 3234 var import_hooks2 = __toESM(require_hooks(), 1); 3235 var import_deprecated6 = __toESM(require_deprecated(), 1); 3236 var import_warning3 = __toESM(require_warning(), 1); 3237 var isBlockTypeTransform = (transform) => transform?.type === "block"; 3238 var getBlockTypeWithTransformMetadata = (blockType, transform) => transform.variationName ? { ...blockType, variationName: transform.variationName } : blockType; 3239 function createBlock(name, attributes = {}, innerBlocks = [], innerContent) { 3240 if (!isBlockRegistered(name)) { 3241 return createBlock("core/missing", { 3242 originalName: name, 3243 originalContent: "", 3244 originalUndelimitedContent: "" 3245 }); 3246 } 3247 const sanitizedAttributes = sanitizeBlockAttributes(name, attributes); 3248 const clientId = v4_default(); 3249 const block = { 3250 clientId, 3251 name, 3252 isValid: true, 3253 attributes: sanitizedAttributes, 3254 innerBlocks 3255 }; 3256 if (innerContent) { 3257 if (name === "core/html") { 3258 block.innerContent = innerContent; 3259 } else { 3260 (0, import_warning3.default)( 3261 `The innerContent argument passed to createBlock for the "$name}" block was ignored. Only the Custom HTML block stores static inner content.` 3262 ); 3263 } 3264 } 3265 return block; 3266 } 3267 function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) { 3268 return innerBlocksOrTemplate.map((innerBlock) => { 3269 const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [ 3270 innerBlock.name, 3271 innerBlock.attributes, 3272 innerBlock.innerBlocks, 3273 innerBlock.innerContent 3274 ]; 3275 const [name, attributes, innerBlocks = [], innerContent] = innerBlockTemplate; 3276 return createBlock( 3277 name, 3278 attributes, 3279 createBlocksFromInnerBlocksTemplate( 3280 innerBlocks 3281 ), 3282 innerContent 3283 ); 3284 }); 3285 } 3286 function cloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { 3287 const { name } = block; 3288 if (!isBlockRegistered(name)) { 3289 return createBlock("core/missing", { 3290 originalName: name, 3291 originalContent: "", 3292 originalUndelimitedContent: "" 3293 }); 3294 } 3295 const clientId = v4_default(); 3296 const sanitizedAttributes = sanitizeBlockAttributes(name, { 3297 ...block.attributes, 3298 ...mergeAttributes 3299 }); 3300 return { 3301 ...block, 3302 clientId, 3303 attributes: sanitizedAttributes, 3304 innerBlocks: newInnerBlocks || block.innerBlocks.map( 3305 (innerBlock) => cloneSanitizedBlock(innerBlock) 3306 ) 3307 }; 3308 } 3309 function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { 3310 (0, import_deprecated6.default)("__experimentalCloneSanitizedBlock", { 3311 since: "7.1", 3312 alternative: "cloneSanitizedBlock" 3313 }); 3314 return cloneSanitizedBlock(block, mergeAttributes, newInnerBlocks); 3315 } 3316 function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) { 3317 const clientId = v4_default(); 3318 return { 3319 ...block, 3320 clientId, 3321 attributes: { 3322 ...block.attributes, 3323 ...mergeAttributes 3324 }, 3325 innerBlocks: newInnerBlocks || block.innerBlocks.map((innerBlock) => cloneBlock(innerBlock)) 3326 }; 3327 } 3328 var isPossibleTransformForSource = (transform, direction, blocks) => { 3329 if (!blocks.length) { 3330 return false; 3331 } 3332 const isMultiBlock = blocks.length > 1; 3333 const firstBlockName = blocks[0].name; 3334 const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; 3335 if (!isValidForMultiBlocks) { 3336 return false; 3337 } 3338 if (!isWildcardBlockTransform(transform) && !blocks.every((block) => block.name === firstBlockName)) { 3339 return false; 3340 } 3341 const sourceBlock = blocks[0]; 3342 const hasMatchingName = direction !== "from" || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); 3343 if (!hasMatchingName) { 3344 return false; 3345 } 3346 if (!isMultiBlock && direction === "from" && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { 3347 return false; 3348 } 3349 if (!maybeCheckTransformIsMatch(transform, blocks)) { 3350 return false; 3351 } 3352 return true; 3353 }; 3354 var getBlockTypesForPossibleFromTransforms = (blocks) => { 3355 if (!blocks.length) { 3356 return []; 3357 } 3358 const allBlockTypes = getBlockTypes(); 3359 const blockTypesWithPossibleFromTransforms = allBlockTypes.flatMap( 3360 (blockType) => { 3361 const fromTransforms = getBlockTransforms("from", blockType.name); 3362 return fromTransforms.filter(isBlockTypeTransform).filter( 3363 (transform) => isPossibleTransformForSource(transform, "from", blocks) 3364 ).map( 3365 (transform) => getBlockTypeWithTransformMetadata(blockType, transform) 3366 ); 3367 } 3368 ); 3369 return blockTypesWithPossibleFromTransforms; 3370 }; 3371 var getBlockTypesForPossibleToTransforms = (blocks) => { 3372 if (!blocks.length) { 3373 return []; 3374 } 3375 const sourceBlock = blocks[0]; 3376 const blockType = getBlockType(sourceBlock.name); 3377 const transformsTo = blockType ? getBlockTransforms("to", blockType.name) : []; 3378 const possibleTransforms = transformsTo.filter(isBlockTypeTransform).filter( 3379 (transform) => isPossibleTransformForSource(transform, "to", blocks) 3380 ); 3381 return possibleTransforms.flatMap((transformation) => { 3382 return (transformation.blocks ?? []).map((name) => { 3383 const transformedBlockType = getBlockType(name); 3384 return transformedBlockType ? getBlockTypeWithTransformMetadata( 3385 transformedBlockType, 3386 transformation 3387 ) : void 0; 3388 }); 3389 }).filter((bt2) => !!bt2); 3390 }; 3391 var isWildcardBlockTransform = (t2) => isBlockTypeTransform(t2) && Array.isArray(t2.blocks) && t2.blocks.includes("*"); 3392 var isContainerGroupBlock = (name) => name === getGroupingBlockName(); 3393 function getPossibleBlockTransformations(blocks) { 3394 if (!blocks.length) { 3395 return []; 3396 } 3397 const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); 3398 const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); 3399 const blockTypesByNameAndVariation = /* @__PURE__ */ new Map(); 3400 for (const blockType of [ 3401 ...blockTypesForFromTransforms, 3402 ...blockTypesForToTransforms 3403 ]) { 3404 const key = blockType.variationName ? `$blockType.name}/$blockType.variationName}` : blockType.name; 3405 if (!blockTypesByNameAndVariation.has(key)) { 3406 blockTypesByNameAndVariation.set(key, blockType); 3407 } 3408 } 3409 return [...blockTypesByNameAndVariation.values()]; 3410 } 3411 function findTransform(transforms, predicate) { 3412 const priority = (t2) => t2.priority ?? 10; 3413 const candidates = transforms.filter((t2) => predicate(t2)).toSorted((t1, t2) => priority(t1) - priority(t2)); 3414 return candidates.length > 0 ? candidates[0] : null; 3415 } 3416 function getBlockTransforms(direction, blockTypeOrName) { 3417 if (blockTypeOrName === void 0) { 3418 return getBlockTypes().map(({ name }) => getBlockTransforms(direction, name)).flat(); 3419 } 3420 const blockType = normalizeBlockType(blockTypeOrName); 3421 const directionTransforms = blockType?.transforms?.[direction]; 3422 if (!blockType || !Array.isArray(directionTransforms)) { 3423 return []; 3424 } 3425 return directionTransforms.map((transform) => ({ 3426 ...transform, 3427 blockName: blockType.name 3428 })); 3429 } 3430 function maybeCheckTransformIsMatch(transform, blocks) { 3431 if (typeof transform.isMatch !== "function") { 3432 return true; 3433 } 3434 const sourceBlock = blocks[0]; 3435 const attributes = transform.isMultiBlock ? blocks.map((block2) => block2.attributes) : sourceBlock.attributes; 3436 const block = transform.isMultiBlock ? blocks : sourceBlock; 3437 return transform.isMatch(attributes, block); 3438 } 3439 function switchToBlockType(blocks, name, variationName) { 3440 const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; 3441 const isMultiBlock = blocksArray.length > 1; 3442 const firstBlock = blocksArray[0]; 3443 const sourceName = firstBlock.name; 3444 const transformationsFrom = getBlockTransforms("from", name).filter( 3445 isBlockTypeTransform 3446 ); 3447 const transformationsTo = getBlockTransforms("to", sourceName).filter( 3448 isBlockTypeTransform 3449 ); 3450 const isMatchingVariation = (t2) => variationName ? t2.variationName === variationName : !t2.variationName; 3451 const transformation = findTransform( 3452 transformationsTo, 3453 (t2) => isMatchingVariation(t2) && (isWildcardBlockTransform(t2) || t2.blocks.indexOf(name) !== -1) && (!isMultiBlock || !!t2.isMultiBlock) && maybeCheckTransformIsMatch(t2, blocksArray) 3454 ) || findTransform( 3455 transformationsFrom, 3456 (t2) => isMatchingVariation(t2) && (isWildcardBlockTransform(t2) || t2.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || !!t2.isMultiBlock) && maybeCheckTransformIsMatch(t2, blocksArray) 3457 ); 3458 if (!transformation) { 3459 return null; 3460 } 3461 let transformationResults; 3462 if (transformation.isMultiBlock) { 3463 if ("__experimentalConvert" in transformation) { 3464 transformationResults = transformation.__experimentalConvert(blocksArray); 3465 } else { 3466 transformationResults = transformation.transform( 3467 blocksArray.map((currentBlock) => currentBlock.attributes), 3468 blocksArray.map((currentBlock) => currentBlock.innerBlocks) 3469 ); 3470 } 3471 } else if ("__experimentalConvert" in transformation) { 3472 transformationResults = transformation.__experimentalConvert(firstBlock); 3473 } else { 3474 transformationResults = transformation.transform( 3475 firstBlock.attributes, 3476 firstBlock.innerBlocks 3477 ); 3478 } 3479 if (transformationResults === null || typeof transformationResults !== "object") { 3480 return null; 3481 } 3482 transformationResults = Array.isArray(transformationResults) ? transformationResults : [transformationResults]; 3483 if (transformationResults.some( 3484 (result) => !getBlockType(result.name) 3485 )) { 3486 return null; 3487 } 3488 const hasSwitchedBlock = transformationResults.some( 3489 (result) => result.name === name 3490 ); 3491 if (!hasSwitchedBlock) { 3492 return null; 3493 } 3494 const ret = transformationResults.map((result, index, results) => { 3495 return (0, import_hooks2.applyFilters)( 3496 "blocks.switchToBlockType.transformedBlock", 3497 result, 3498 blocks, 3499 index, 3500 results 3501 ); 3502 }); 3503 return ret; 3504 } 3505 var getBlockFromExample = (name, example) => createBlock( 3506 name, 3507 example.attributes, 3508 (example.innerBlocks ?? []).map( 3509 (innerBlock) => getBlockFromExample(innerBlock.name, innerBlock) 3510 ), 3511 example.innerContent 3512 ); 3513 3514 // packages/blocks/build-module/api/parser/index.mjs 3515 var import_block_serialization_default_parser = __toESM(require_block_serialization_default_parser(), 1); 3516 var import_autop2 = __toESM(require_autop(), 1); 3517 3518 // packages/blocks/build-module/api/serializer.mjs 3519 var import_element2 = __toESM(require_element(), 1); 3520 var import_hooks3 = __toESM(require_hooks(), 1); 3521 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1); 3522 var import_autop = __toESM(require_autop(), 1); 3523 var import_deprecated7 = __toESM(require_deprecated(), 1); 3524 3525 // packages/blocks/build-module/api/parser/serialize-raw-block.mjs 3526 function serializeRawBlock(rawBlock, options = {}) { 3527 const { isCommentDelimited = true } = options; 3528 const { 3529 blockName, 3530 attrs = {}, 3531 innerBlocks = [], 3532 innerContent = [] 3533 } = rawBlock; 3534 let childIndex = 0; 3535 const content = innerContent.map( 3536 (item) => ( 3537 // `null` denotes a nested block, otherwise we have an HTML fragment. 3538 item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options) 3539 ) 3540 ).join("\n").replace(/\n+/g, "\n").trim(); 3541 return isCommentDelimited ? getCommentDelimitedContent(blockName ?? void 0, attrs, content) : content; 3542 } 3543 3544 // packages/blocks/build-module/api/serializer.mjs 3545 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 3546 function getBlockDefaultClassName(blockName) { 3547 const className = "wp-block-" + blockName.replace(/\//, "-").replace(/^core-/, ""); 3548 return (0, import_hooks3.applyFilters)( 3549 "blocks.getBlockDefaultClassName", 3550 className, 3551 blockName 3552 ); 3553 } 3554 function getBlockMenuDefaultClassName(blockName) { 3555 const className = "editor-block-list-item-" + blockName.replace(/\//, "-").replace(/^core-/, ""); 3556 return (0, import_hooks3.applyFilters)( 3557 "blocks.getBlockMenuDefaultClassName", 3558 className, 3559 blockName 3560 ); 3561 } 3562 var blockPropsProvider = {}; 3563 var innerBlocksPropsProvider = {}; 3564 function getBlockProps(props = {}) { 3565 const { blockType, attributes } = blockPropsProvider; 3566 return getBlockProps.skipFilters ? props : (0, import_hooks3.applyFilters)( 3567 "blocks.getSaveContent.extraProps", 3568 { ...props }, 3569 blockType, 3570 attributes 3571 ); 3572 } 3573 function getInnerBlocksProps(props = {}) { 3574 const { innerBlocks } = innerBlocksPropsProvider; 3575 if (!Array.isArray(innerBlocks)) { 3576 return { ...props, children: innerBlocks }; 3577 } 3578 const html2 = serialize(innerBlocks, { isInnerBlocks: true }); 3579 const children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element2.RawHTML, { children: html2 }); 3580 return { ...props, children }; 3581 } 3582 function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) { 3583 const blockType = normalizeBlockType(blockTypeOrName); 3584 if (!blockType?.save) { 3585 return null; 3586 } 3587 let save = blockType.save; 3588 if (save.prototype instanceof import_element2.Component) { 3589 const SaveClass = save; 3590 const instance = new SaveClass({ attributes }); 3591 save = instance.render.bind(instance); 3592 } 3593 blockPropsProvider.blockType = blockType; 3594 blockPropsProvider.attributes = attributes; 3595 innerBlocksPropsProvider.innerBlocks = innerBlocks; 3596 let element = save({ 3597 attributes, 3598 innerBlocks 3599 }); 3600 if (element !== null && typeof element === "object" && (0, import_hooks3.hasFilter)("blocks.getSaveContent.extraProps") && !((blockType.apiVersion ?? 0) > 1)) { 3601 const props = (0, import_hooks3.applyFilters)( 3602 "blocks.getSaveContent.extraProps", 3603 { ...element.props }, 3604 blockType, 3605 attributes 3606 ); 3607 if (!(0, import_is_shallow_equal.isShallowEqual)(props, element.props)) { 3608 element = (0, import_element2.cloneElement)( 3609 element, 3610 props 3611 ); 3612 } 3613 } 3614 return (0, import_hooks3.applyFilters)( 3615 "blocks.getSaveElement", 3616 element, 3617 blockType, 3618 attributes 3619 ); 3620 } 3621 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { 3622 const blockType = normalizeBlockType( 3623 blockTypeOrName 3624 ); 3625 if (!blockType) { 3626 return ""; 3627 } 3628 return (0, import_element2.renderToString)( 3629 getSaveElement(blockType, attributes, innerBlocks) 3630 ); 3631 } 3632 function getCommentAttributes(blockType, attributes) { 3633 return Object.entries(blockType.attributes ?? {}).reduce( 3634 (accumulator, [key, attributeSchema]) => { 3635 const value = attributes[key]; 3636 if (void 0 === value) { 3637 return accumulator; 3638 } 3639 if (attributeSchema.source !== void 0) { 3640 return accumulator; 3641 } 3642 if (attributeSchema.role === "local") { 3643 return accumulator; 3644 } 3645 if (attributeSchema.__experimentalRole === "local") { 3646 (0, import_deprecated7.default)("__experimentalRole attribute", { 3647 since: "6.7", 3648 version: "6.8", 3649 alternative: "role attribute", 3650 hint: `Check the block.json of the $blockType?.name} block.` 3651 }); 3652 return accumulator; 3653 } 3654 if ("default" in attributeSchema && JSON.stringify(attributeSchema.default) === JSON.stringify(value)) { 3655 return accumulator; 3656 } 3657 accumulator[key] = value; 3658 return accumulator; 3659 }, 3660 {} 3661 ); 3662 } 3663 function serializeAttributes(attributes) { 3664 return JSON.stringify(attributes).replaceAll("\\\\", "\\u005c").replaceAll("--", "\\u002d\\u002d").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("&", "\\u0026").replaceAll('\\"', "\\u0022"); 3665 } 3666 function serializeInnerContent(innerContent, innerBlocks) { 3667 let childIndex = 0; 3668 const parts = innerContent.map((item) => { 3669 if (item !== null) { 3670 return item; 3671 } 3672 const innerBlock = innerBlocks[childIndex++]; 3673 return innerBlock ? serializeBlock(innerBlock, { isInnerBlocks: true }) : ""; 3674 }); 3675 for (; childIndex < innerBlocks.length; childIndex++) { 3676 parts.push( 3677 serializeBlock(innerBlocks[childIndex], { isInnerBlocks: true }) 3678 ); 3679 } 3680 return parts.join("").trim(); 3681 } 3682 function getBlockInnerHTML(block) { 3683 if (block.innerContent && block.name === "core/html") { 3684 return serializeInnerContent(block.innerContent, block.innerBlocks); 3685 } 3686 let saveContent = block.originalContent ?? ""; 3687 if (block.isValid || block.innerBlocks.length) { 3688 try { 3689 saveContent = getSaveContent( 3690 block.name, 3691 block.attributes, 3692 block.innerBlocks 3693 ); 3694 } catch { 3695 } 3696 } 3697 return saveContent; 3698 } 3699 function getCommentDelimitedContent(rawBlockName, attributes, content) { 3700 const serializedAttributes = attributes && Object.entries(attributes).length ? serializeAttributes(attributes) + " " : ""; 3701 const blockName = rawBlockName?.startsWith("core/") ? rawBlockName.slice(5) : rawBlockName; 3702 if (!content) { 3703 return `<!-- wp:$blockName} $serializedAttributes}/-->`; 3704 } 3705 return `<!-- wp:$blockName} $serializedAttributes}--> 3706 ` + content + ` 3707 <!-- /wp:$blockName} -->`; 3708 } 3709 function serializeBlock(block, { isInnerBlocks = false } = {}) { 3710 if (!block.isValid && block.__unstableBlockSource) { 3711 return serializeRawBlock(block.__unstableBlockSource); 3712 } 3713 const blockName = block.name; 3714 const saveContent = getBlockInnerHTML(block); 3715 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { 3716 return saveContent; 3717 } 3718 const blockType = getBlockType(blockName); 3719 if (!blockType) { 3720 return saveContent; 3721 } 3722 const saveAttributes = getCommentAttributes(blockType, block.attributes); 3723 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); 3724 } 3725 var __unstableSerializeAndClean = /* @__PURE__ */ (() => { 3726 const cache = /* @__PURE__ */ new WeakMap(); 3727 return (blocks) => { 3728 const cached = cache.get(blocks); 3729 if (cached !== void 0) { 3730 return cached; 3731 } 3732 let effectiveBlocks = blocks; 3733 if (effectiveBlocks.length === 1 && isUnmodifiedDefaultBlock(effectiveBlocks[0])) { 3734 effectiveBlocks = []; 3735 } 3736 let content = serialize(effectiveBlocks); 3737 if (effectiveBlocks.length === 1 && effectiveBlocks[0].name === getFreeformContentHandlerName() && effectiveBlocks[0].name === "core/freeform") { 3738 content = (0, import_autop.removep)(content); 3739 } 3740 cache.set(blocks, content); 3741 return content; 3742 }; 3743 })(); 3744 function serialize(blocks, options) { 3745 const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; 3746 return blocksArray.map((block) => serializeBlock(block, options)).join("\n\n"); 3747 } 3748 3749 // node_modules/.store/simple-html-tokenizer@0.5.7-XqyG3gha3SmBXttNwRHo8w/node_modules/simple-html-tokenizer/dist/es6/index.js 3750 var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/; 3751 var CHARCODE = /^#([0-9]+)$/; 3752 var NAMED = /^([A-Za-z0-9]+)$/; 3753 var EntityParser = ( 3754 /** @class */ 3755 (function() { 3756 function EntityParser2(named) { 3757 this.named = named; 3758 } 3759 EntityParser2.prototype.parse = function(entity) { 3760 if (!entity) { 3761 return; 3762 } 3763 var matches = entity.match(HEXCHARCODE); 3764 if (matches) { 3765 return String.fromCharCode(parseInt(matches[1], 16)); 3766 } 3767 matches = entity.match(CHARCODE); 3768 if (matches) { 3769 return String.fromCharCode(parseInt(matches[1], 10)); 3770 } 3771 matches = entity.match(NAMED); 3772 if (matches) { 3773 return this.named[matches[1]]; 3774 } 3775 }; 3776 return EntityParser2; 3777 })() 3778 ); 3779 var WSP = /[\t\n\f ]/; 3780 var ALPHA = /[A-Za-z]/; 3781 var CRLF = /\r\n?/g; 3782 function isSpace(char) { 3783 return WSP.test(char); 3784 } 3785 function isAlpha(char) { 3786 return ALPHA.test(char); 3787 } 3788 function preprocessInput(input) { 3789 return input.replace(CRLF, "\n"); 3790 } 3791 var EventedTokenizer = ( 3792 /** @class */ 3793 (function() { 3794 function EventedTokenizer2(delegate, entityParser) { 3795 this.delegate = delegate; 3796 this.entityParser = entityParser; 3797 this.state = "beforeData"; 3798 this.line = -1; 3799 this.column = -1; 3800 this.input = ""; 3801 this.index = -1; 3802 this.tagNameBuffer = ""; 3803 this.states = { 3804 beforeData: function() { 3805 var char = this.peek(); 3806 if (char === "<") { 3807 this.transitionTo( 3808 "tagOpen" 3809 /* tagOpen */ 3810 ); 3811 this.markTagStart(); 3812 this.consume(); 3813 } else { 3814 if (char === "\n") { 3815 var tag = this.tagNameBuffer.toLowerCase(); 3816 if (tag === "pre" || tag === "textarea") { 3817 this.consume(); 3818 } 3819 } 3820 this.transitionTo( 3821 "data" 3822 /* data */ 3823 ); 3824 this.delegate.beginData(); 3825 } 3826 }, 3827 data: function() { 3828 var char = this.peek(); 3829 if (char === "<") { 3830 this.delegate.finishData(); 3831 this.transitionTo( 3832 "tagOpen" 3833 /* tagOpen */ 3834 ); 3835 this.markTagStart(); 3836 this.consume(); 3837 } else if (char === "&") { 3838 this.consume(); 3839 this.delegate.appendToData(this.consumeCharRef() || "&"); 3840 } else { 3841 this.consume(); 3842 this.delegate.appendToData(char); 3843 } 3844 }, 3845 tagOpen: function() { 3846 var char = this.consume(); 3847 if (char === "!") { 3848 this.transitionTo( 3849 "markupDeclarationOpen" 3850 /* markupDeclarationOpen */ 3851 ); 3852 } else if (char === "/") { 3853 this.transitionTo( 3854 "endTagOpen" 3855 /* endTagOpen */ 3856 ); 3857 } else if (char === "@" || char === ":" || isAlpha(char)) { 3858 this.transitionTo( 3859 "tagName" 3860 /* tagName */ 3861 ); 3862 this.tagNameBuffer = ""; 3863 this.delegate.beginStartTag(); 3864 this.appendToTagName(char); 3865 } 3866 }, 3867 markupDeclarationOpen: function() { 3868 var char = this.consume(); 3869 if (char === "-" && this.input.charAt(this.index) === "-") { 3870 this.consume(); 3871 this.transitionTo( 3872 "commentStart" 3873 /* commentStart */ 3874 ); 3875 this.delegate.beginComment(); 3876 } 3877 }, 3878 commentStart: function() { 3879 var char = this.consume(); 3880 if (char === "-") { 3881 this.transitionTo( 3882 "commentStartDash" 3883 /* commentStartDash */ 3884 ); 3885 } else if (char === ">") { 3886 this.delegate.finishComment(); 3887 this.transitionTo( 3888 "beforeData" 3889 /* beforeData */ 3890 ); 3891 } else { 3892 this.delegate.appendToCommentData(char); 3893 this.transitionTo( 3894 "comment" 3895 /* comment */ 3896 ); 3897 } 3898 }, 3899 commentStartDash: function() { 3900 var char = this.consume(); 3901 if (char === "-") { 3902 this.transitionTo( 3903 "commentEnd" 3904 /* commentEnd */ 3905 ); 3906 } else if (char === ">") { 3907 this.delegate.finishComment(); 3908 this.transitionTo( 3909 "beforeData" 3910 /* beforeData */ 3911 ); 3912 } else { 3913 this.delegate.appendToCommentData("-"); 3914 this.transitionTo( 3915 "comment" 3916 /* comment */ 3917 ); 3918 } 3919 }, 3920 comment: function() { 3921 var char = this.consume(); 3922 if (char === "-") { 3923 this.transitionTo( 3924 "commentEndDash" 3925 /* commentEndDash */ 3926 ); 3927 } else { 3928 this.delegate.appendToCommentData(char); 3929 } 3930 }, 3931 commentEndDash: function() { 3932 var char = this.consume(); 3933 if (char === "-") { 3934 this.transitionTo( 3935 "commentEnd" 3936 /* commentEnd */ 3937 ); 3938 } else { 3939 this.delegate.appendToCommentData("-" + char); 3940 this.transitionTo( 3941 "comment" 3942 /* comment */ 3943 ); 3944 } 3945 }, 3946 commentEnd: function() { 3947 var char = this.consume(); 3948 if (char === ">") { 3949 this.delegate.finishComment(); 3950 this.transitionTo( 3951 "beforeData" 3952 /* beforeData */ 3953 ); 3954 } else { 3955 this.delegate.appendToCommentData("--" + char); 3956 this.transitionTo( 3957 "comment" 3958 /* comment */ 3959 ); 3960 } 3961 }, 3962 tagName: function() { 3963 var char = this.consume(); 3964 if (isSpace(char)) { 3965 this.transitionTo( 3966 "beforeAttributeName" 3967 /* beforeAttributeName */ 3968 ); 3969 } else if (char === "/") { 3970 this.transitionTo( 3971 "selfClosingStartTag" 3972 /* selfClosingStartTag */ 3973 ); 3974 } else if (char === ">") { 3975 this.delegate.finishTag(); 3976 this.transitionTo( 3977 "beforeData" 3978 /* beforeData */ 3979 ); 3980 } else { 3981 this.appendToTagName(char); 3982 } 3983 }, 3984 beforeAttributeName: function() { 3985 var char = this.peek(); 3986 if (isSpace(char)) { 3987 this.consume(); 3988 return; 3989 } else if (char === "/") { 3990 this.transitionTo( 3991 "selfClosingStartTag" 3992 /* selfClosingStartTag */ 3993 ); 3994 this.consume(); 3995 } else if (char === ">") { 3996 this.consume(); 3997 this.delegate.finishTag(); 3998 this.transitionTo( 3999 "beforeData" 4000 /* beforeData */ 4001 ); 4002 } else if (char === "=") { 4003 this.delegate.reportSyntaxError("attribute name cannot start with equals sign"); 4004 this.transitionTo( 4005 "attributeName" 4006 /* attributeName */ 4007 ); 4008 this.delegate.beginAttribute(); 4009 this.consume(); 4010 this.delegate.appendToAttributeName(char); 4011 } else { 4012 this.transitionTo( 4013 "attributeName" 4014 /* attributeName */ 4015 ); 4016 this.delegate.beginAttribute(); 4017 } 4018 }, 4019 attributeName: function() { 4020 var char = this.peek(); 4021 if (isSpace(char)) { 4022 this.transitionTo( 4023 "afterAttributeName" 4024 /* afterAttributeName */ 4025 ); 4026 this.consume(); 4027 } else if (char === "/") { 4028 this.delegate.beginAttributeValue(false); 4029 this.delegate.finishAttributeValue(); 4030 this.consume(); 4031 this.transitionTo( 4032 "selfClosingStartTag" 4033 /* selfClosingStartTag */ 4034 ); 4035 } else if (char === "=") { 4036 this.transitionTo( 4037 "beforeAttributeValue" 4038 /* beforeAttributeValue */ 4039 ); 4040 this.consume(); 4041 } else if (char === ">") { 4042 this.delegate.beginAttributeValue(false); 4043 this.delegate.finishAttributeValue(); 4044 this.consume(); 4045 this.delegate.finishTag(); 4046 this.transitionTo( 4047 "beforeData" 4048 /* beforeData */ 4049 ); 4050 } else if (char === '"' || char === "'" || char === "<") { 4051 this.delegate.reportSyntaxError(char + " is not a valid character within attribute names"); 4052 this.consume(); 4053 this.delegate.appendToAttributeName(char); 4054 } else { 4055 this.consume(); 4056 this.delegate.appendToAttributeName(char); 4057 } 4058 }, 4059 afterAttributeName: function() { 4060 var char = this.peek(); 4061 if (isSpace(char)) { 4062 this.consume(); 4063 return; 4064 } else if (char === "/") { 4065 this.delegate.beginAttributeValue(false); 4066 this.delegate.finishAttributeValue(); 4067 this.consume(); 4068 this.transitionTo( 4069 "selfClosingStartTag" 4070 /* selfClosingStartTag */ 4071 ); 4072 } else if (char === "=") { 4073 this.consume(); 4074 this.transitionTo( 4075 "beforeAttributeValue" 4076 /* beforeAttributeValue */ 4077 ); 4078 } else if (char === ">") { 4079 this.delegate.beginAttributeValue(false); 4080 this.delegate.finishAttributeValue(); 4081 this.consume(); 4082 this.delegate.finishTag(); 4083 this.transitionTo( 4084 "beforeData" 4085 /* beforeData */ 4086 ); 4087 } else { 4088 this.delegate.beginAttributeValue(false); 4089 this.delegate.finishAttributeValue(); 4090 this.transitionTo( 4091 "attributeName" 4092 /* attributeName */ 4093 ); 4094 this.delegate.beginAttribute(); 4095 this.consume(); 4096 this.delegate.appendToAttributeName(char); 4097 } 4098 }, 4099 beforeAttributeValue: function() { 4100 var char = this.peek(); 4101 if (isSpace(char)) { 4102 this.consume(); 4103 } else if (char === '"') { 4104 this.transitionTo( 4105 "attributeValueDoubleQuoted" 4106 /* attributeValueDoubleQuoted */ 4107 ); 4108 this.delegate.beginAttributeValue(true); 4109 this.consume(); 4110 } else if (char === "'") { 4111 this.transitionTo( 4112 "attributeValueSingleQuoted" 4113 /* attributeValueSingleQuoted */ 4114 ); 4115 this.delegate.beginAttributeValue(true); 4116 this.consume(); 4117 } else if (char === ">") { 4118 this.delegate.beginAttributeValue(false); 4119 this.delegate.finishAttributeValue(); 4120 this.consume(); 4121 this.delegate.finishTag(); 4122 this.transitionTo( 4123 "beforeData" 4124 /* beforeData */ 4125 ); 4126 } else { 4127 this.transitionTo( 4128 "attributeValueUnquoted" 4129 /* attributeValueUnquoted */ 4130 ); 4131 this.delegate.beginAttributeValue(false); 4132 this.consume(); 4133 this.delegate.appendToAttributeValue(char); 4134 } 4135 }, 4136 attributeValueDoubleQuoted: function() { 4137 var char = this.consume(); 4138 if (char === '"') { 4139 this.delegate.finishAttributeValue(); 4140 this.transitionTo( 4141 "afterAttributeValueQuoted" 4142 /* afterAttributeValueQuoted */ 4143 ); 4144 } else if (char === "&") { 4145 this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); 4146 } else { 4147 this.delegate.appendToAttributeValue(char); 4148 } 4149 }, 4150 attributeValueSingleQuoted: function() { 4151 var char = this.consume(); 4152 if (char === "'") { 4153 this.delegate.finishAttributeValue(); 4154 this.transitionTo( 4155 "afterAttributeValueQuoted" 4156 /* afterAttributeValueQuoted */ 4157 ); 4158 } else if (char === "&") { 4159 this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); 4160 } else { 4161 this.delegate.appendToAttributeValue(char); 4162 } 4163 }, 4164 attributeValueUnquoted: function() { 4165 var char = this.peek(); 4166 if (isSpace(char)) { 4167 this.delegate.finishAttributeValue(); 4168 this.consume(); 4169 this.transitionTo( 4170 "beforeAttributeName" 4171 /* beforeAttributeName */ 4172 ); 4173 } else if (char === "/") { 4174 this.delegate.finishAttributeValue(); 4175 this.consume(); 4176 this.transitionTo( 4177 "selfClosingStartTag" 4178 /* selfClosingStartTag */ 4179 ); 4180 } else if (char === "&") { 4181 this.consume(); 4182 this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); 4183 } else if (char === ">") { 4184 this.delegate.finishAttributeValue(); 4185 this.consume(); 4186 this.delegate.finishTag(); 4187 this.transitionTo( 4188 "beforeData" 4189 /* beforeData */ 4190 ); 4191 } else { 4192 this.consume(); 4193 this.delegate.appendToAttributeValue(char); 4194 } 4195 }, 4196 afterAttributeValueQuoted: function() { 4197 var char = this.peek(); 4198 if (isSpace(char)) { 4199 this.consume(); 4200 this.transitionTo( 4201 "beforeAttributeName" 4202 /* beforeAttributeName */ 4203 ); 4204 } else if (char === "/") { 4205 this.consume(); 4206 this.transitionTo( 4207 "selfClosingStartTag" 4208 /* selfClosingStartTag */ 4209 ); 4210 } else if (char === ">") { 4211 this.consume(); 4212 this.delegate.finishTag(); 4213 this.transitionTo( 4214 "beforeData" 4215 /* beforeData */ 4216 ); 4217 } else { 4218 this.transitionTo( 4219 "beforeAttributeName" 4220 /* beforeAttributeName */ 4221 ); 4222 } 4223 }, 4224 selfClosingStartTag: function() { 4225 var char = this.peek(); 4226 if (char === ">") { 4227 this.consume(); 4228 this.delegate.markTagAsSelfClosing(); 4229 this.delegate.finishTag(); 4230 this.transitionTo( 4231 "beforeData" 4232 /* beforeData */ 4233 ); 4234 } else { 4235 this.transitionTo( 4236 "beforeAttributeName" 4237 /* beforeAttributeName */ 4238 ); 4239 } 4240 }, 4241 endTagOpen: function() { 4242 var char = this.consume(); 4243 if (char === "@" || char === ":" || isAlpha(char)) { 4244 this.transitionTo( 4245 "tagName" 4246 /* tagName */ 4247 ); 4248 this.tagNameBuffer = ""; 4249 this.delegate.beginEndTag(); 4250 this.appendToTagName(char); 4251 } 4252 } 4253 }; 4254 this.reset(); 4255 } 4256 EventedTokenizer2.prototype.reset = function() { 4257 this.transitionTo( 4258 "beforeData" 4259 /* beforeData */ 4260 ); 4261 this.input = ""; 4262 this.index = 0; 4263 this.line = 1; 4264 this.column = 0; 4265 this.delegate.reset(); 4266 }; 4267 EventedTokenizer2.prototype.transitionTo = function(state) { 4268 this.state = state; 4269 }; 4270 EventedTokenizer2.prototype.tokenize = function(input) { 4271 this.reset(); 4272 this.tokenizePart(input); 4273 this.tokenizeEOF(); 4274 }; 4275 EventedTokenizer2.prototype.tokenizePart = function(input) { 4276 this.input += preprocessInput(input); 4277 while (this.index < this.input.length) { 4278 var handler = this.states[this.state]; 4279 if (handler !== void 0) { 4280 handler.call(this); 4281 } else { 4282 throw new Error("unhandled state " + this.state); 4283 } 4284 } 4285 }; 4286 EventedTokenizer2.prototype.tokenizeEOF = function() { 4287 this.flushData(); 4288 }; 4289 EventedTokenizer2.prototype.flushData = function() { 4290 if (this.state === "data") { 4291 this.delegate.finishData(); 4292 this.transitionTo( 4293 "beforeData" 4294 /* beforeData */ 4295 ); 4296 } 4297 }; 4298 EventedTokenizer2.prototype.peek = function() { 4299 return this.input.charAt(this.index); 4300 }; 4301 EventedTokenizer2.prototype.consume = function() { 4302 var char = this.peek(); 4303 this.index++; 4304 if (char === "\n") { 4305 this.line++; 4306 this.column = 0; 4307 } else { 4308 this.column++; 4309 } 4310 return char; 4311 }; 4312 EventedTokenizer2.prototype.consumeCharRef = function() { 4313 var endIndex = this.input.indexOf(";", this.index); 4314 if (endIndex === -1) { 4315 return; 4316 } 4317 var entity = this.input.slice(this.index, endIndex); 4318 var chars = this.entityParser.parse(entity); 4319 if (chars) { 4320 var count = entity.length; 4321 while (count) { 4322 this.consume(); 4323 count--; 4324 } 4325 this.consume(); 4326 return chars; 4327 } 4328 }; 4329 EventedTokenizer2.prototype.markTagStart = function() { 4330 this.delegate.tagOpen(); 4331 }; 4332 EventedTokenizer2.prototype.appendToTagName = function(char) { 4333 this.tagNameBuffer += char; 4334 this.delegate.appendToTagName(char); 4335 }; 4336 return EventedTokenizer2; 4337 })() 4338 ); 4339 var Tokenizer = ( 4340 /** @class */ 4341 (function() { 4342 function Tokenizer2(entityParser, options) { 4343 if (options === void 0) { 4344 options = {}; 4345 } 4346 this.options = options; 4347 this.token = null; 4348 this.startLine = 1; 4349 this.startColumn = 0; 4350 this.tokens = []; 4351 this.tokenizer = new EventedTokenizer(this, entityParser); 4352 this._currentAttribute = void 0; 4353 } 4354 Tokenizer2.prototype.tokenize = function(input) { 4355 this.tokens = []; 4356 this.tokenizer.tokenize(input); 4357 return this.tokens; 4358 }; 4359 Tokenizer2.prototype.tokenizePart = function(input) { 4360 this.tokens = []; 4361 this.tokenizer.tokenizePart(input); 4362 return this.tokens; 4363 }; 4364 Tokenizer2.prototype.tokenizeEOF = function() { 4365 this.tokens = []; 4366 this.tokenizer.tokenizeEOF(); 4367 return this.tokens[0]; 4368 }; 4369 Tokenizer2.prototype.reset = function() { 4370 this.token = null; 4371 this.startLine = 1; 4372 this.startColumn = 0; 4373 }; 4374 Tokenizer2.prototype.current = function() { 4375 var token = this.token; 4376 if (token === null) { 4377 throw new Error("token was unexpectedly null"); 4378 } 4379 if (arguments.length === 0) { 4380 return token; 4381 } 4382 for (var i = 0; i < arguments.length; i++) { 4383 if (token.type === arguments[i]) { 4384 return token; 4385 } 4386 } 4387 throw new Error("token type was unexpectedly " + token.type); 4388 }; 4389 Tokenizer2.prototype.push = function(token) { 4390 this.token = token; 4391 this.tokens.push(token); 4392 }; 4393 Tokenizer2.prototype.currentAttribute = function() { 4394 return this._currentAttribute; 4395 }; 4396 Tokenizer2.prototype.addLocInfo = function() { 4397 if (this.options.loc) { 4398 this.current().loc = { 4399 start: { 4400 line: this.startLine, 4401 column: this.startColumn 4402 }, 4403 end: { 4404 line: this.tokenizer.line, 4405 column: this.tokenizer.column 4406 } 4407 }; 4408 } 4409 this.startLine = this.tokenizer.line; 4410 this.startColumn = this.tokenizer.column; 4411 }; 4412 Tokenizer2.prototype.beginData = function() { 4413 this.push({ 4414 type: "Chars", 4415 chars: "" 4416 }); 4417 }; 4418 Tokenizer2.prototype.appendToData = function(char) { 4419 this.current( 4420 "Chars" 4421 /* Chars */ 4422 ).chars += char; 4423 }; 4424 Tokenizer2.prototype.finishData = function() { 4425 this.addLocInfo(); 4426 }; 4427 Tokenizer2.prototype.beginComment = function() { 4428 this.push({ 4429 type: "Comment", 4430 chars: "" 4431 }); 4432 }; 4433 Tokenizer2.prototype.appendToCommentData = function(char) { 4434 this.current( 4435 "Comment" 4436 /* Comment */ 4437 ).chars += char; 4438 }; 4439 Tokenizer2.prototype.finishComment = function() { 4440 this.addLocInfo(); 4441 }; 4442 Tokenizer2.prototype.tagOpen = function() { 4443 }; 4444 Tokenizer2.prototype.beginStartTag = function() { 4445 this.push({ 4446 type: "StartTag", 4447 tagName: "", 4448 attributes: [], 4449 selfClosing: false 4450 }); 4451 }; 4452 Tokenizer2.prototype.beginEndTag = function() { 4453 this.push({ 4454 type: "EndTag", 4455 tagName: "" 4456 }); 4457 }; 4458 Tokenizer2.prototype.finishTag = function() { 4459 this.addLocInfo(); 4460 }; 4461 Tokenizer2.prototype.markTagAsSelfClosing = function() { 4462 this.current( 4463 "StartTag" 4464 /* StartTag */ 4465 ).selfClosing = true; 4466 }; 4467 Tokenizer2.prototype.appendToTagName = function(char) { 4468 this.current( 4469 "StartTag", 4470 "EndTag" 4471 /* EndTag */ 4472 ).tagName += char; 4473 }; 4474 Tokenizer2.prototype.beginAttribute = function() { 4475 this._currentAttribute = ["", "", false]; 4476 }; 4477 Tokenizer2.prototype.appendToAttributeName = function(char) { 4478 this.currentAttribute()[0] += char; 4479 }; 4480 Tokenizer2.prototype.beginAttributeValue = function(isQuoted) { 4481 this.currentAttribute()[2] = isQuoted; 4482 }; 4483 Tokenizer2.prototype.appendToAttributeValue = function(char) { 4484 this.currentAttribute()[1] += char; 4485 }; 4486 Tokenizer2.prototype.finishAttributeValue = function() { 4487 this.current( 4488 "StartTag" 4489 /* StartTag */ 4490 ).attributes.push(this._currentAttribute); 4491 }; 4492 Tokenizer2.prototype.reportSyntaxError = function(message) { 4493 this.current().syntaxError = message; 4494 }; 4495 return Tokenizer2; 4496 })() 4497 ); 4498 4499 // packages/blocks/build-module/api/validation/index.mjs 4500 var import_es62 = __toESM(require_es6(), 1); 4501 var import_deprecated8 = __toESM(require_deprecated(), 1); 4502 var import_html_entities = __toESM(require_html_entities(), 1); 4503 4504 // packages/blocks/build-module/api/validation/logger.mjs 4505 function createLogger() { 4506 function createLogHandler(logger) { 4507 return (message, ...args) => logger("Block validation: " + message, ...args); 4508 } 4509 return { 4510 // eslint-disable-next-line no-console 4511 error: createLogHandler(console.error), 4512 // eslint-disable-next-line no-console 4513 warning: createLogHandler(console.warn), 4514 getItems() { 4515 return []; 4516 } 4517 }; 4518 } 4519 function createQueuedLogger() { 4520 const queue = []; 4521 const logger = createLogger(); 4522 return { 4523 error(...args) { 4524 queue.push({ log: logger.error, args }); 4525 }, 4526 warning(...args) { 4527 queue.push({ log: logger.warning, args }); 4528 }, 4529 getItems() { 4530 return queue; 4531 } 4532 }; 4533 } 4534 4535 // packages/blocks/build-module/api/validation/index.mjs 4536 var identity = (x3) => x3; 4537 var REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; 4538 var REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; 4539 var REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; 4540 var BOOLEAN_ATTRIBUTES = [ 4541 "allowfullscreen", 4542 "allowpaymentrequest", 4543 "allowusermedia", 4544 "async", 4545 "autofocus", 4546 "autoplay", 4547 "checked", 4548 "controls", 4549 "default", 4550 "defer", 4551 "disabled", 4552 "download", 4553 "formnovalidate", 4554 "hidden", 4555 "ismap", 4556 "itemscope", 4557 "loop", 4558 "multiple", 4559 "muted", 4560 "nomodule", 4561 "novalidate", 4562 "open", 4563 "playsinline", 4564 "readonly", 4565 "required", 4566 "reversed", 4567 "selected", 4568 "typemustmatch" 4569 ]; 4570 var ENUMERATED_ATTRIBUTES = [ 4571 "autocapitalize", 4572 "autocomplete", 4573 "charset", 4574 "contenteditable", 4575 "crossorigin", 4576 "decoding", 4577 "dir", 4578 "draggable", 4579 "enctype", 4580 "formenctype", 4581 "formmethod", 4582 "http-equiv", 4583 "inputmode", 4584 "kind", 4585 "method", 4586 "preload", 4587 "scope", 4588 "shape", 4589 "spellcheck", 4590 "translate", 4591 "type", 4592 "wrap" 4593 ]; 4594 var MEANINGFUL_ATTRIBUTES = [ 4595 ...BOOLEAN_ATTRIBUTES, 4596 ...ENUMERATED_ATTRIBUTES 4597 ]; 4598 var TEXT_NORMALIZATIONS = [ 4599 identity, 4600 getTextWithCollapsedWhitespace 4601 ]; 4602 var REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; 4603 var REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; 4604 var REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; 4605 function isValidCharacterReference(text2) { 4606 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text2) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text2) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text2); 4607 } 4608 var DecodeEntityParser = class { 4609 /** 4610 * Returns a substitute string for an entity string sequence between `&` 4611 * and `;`, or undefined if no substitution should occur. 4612 * 4613 * @param entity Entity fragment discovered in HTML. 4614 * 4615 * @return Entity substitute value. 4616 */ 4617 parse(entity) { 4618 if (isValidCharacterReference(entity)) { 4619 return (0, import_html_entities.decodeEntities)("&" + entity + ";"); 4620 } 4621 return void 0; 4622 } 4623 }; 4624 function getTextPiecesSplitOnWhitespace(text2) { 4625 return text2.trim().split(REGEXP_WHITESPACE); 4626 } 4627 function getTextWithCollapsedWhitespace(text2) { 4628 return getTextPiecesSplitOnWhitespace(text2).join(" "); 4629 } 4630 function getMeaningfulAttributePairs(token) { 4631 return (token.attributes ?? []).filter((pair) => { 4632 const [key, value] = pair; 4633 return value || key.indexOf("data-") === 0 || MEANINGFUL_ATTRIBUTES.includes(key); 4634 }); 4635 } 4636 function isEquivalentTextTokens(actual, expected, logger = createLogger()) { 4637 let actualChars = actual.chars; 4638 let expectedChars = expected.chars; 4639 for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) { 4640 const normalize = TEXT_NORMALIZATIONS[i]; 4641 actualChars = normalize(actualChars); 4642 expectedChars = normalize(expectedChars); 4643 if (actualChars === expectedChars) { 4644 return true; 4645 } 4646 } 4647 logger.warning( 4648 "Expected text `%s`, saw `%s`.", 4649 expected.chars, 4650 actual.chars 4651 ); 4652 return false; 4653 } 4654 function getNormalizedLength(value) { 4655 if (0 === parseFloat(value)) { 4656 return "0"; 4657 } 4658 if (value.indexOf(".") === 0) { 4659 return "0" + value; 4660 } 4661 return value; 4662 } 4663 function getNormalizedStyleValue(value) { 4664 const textPieces = getTextPiecesSplitOnWhitespace(value); 4665 const normalizedPieces = textPieces.map(getNormalizedLength); 4666 const result = normalizedPieces.join(" "); 4667 return result.replace(REGEXP_STYLE_URL_TYPE, "url($1)"); 4668 } 4669 function getStyleProperties(text2) { 4670 const pairs = text2.replace(/;?\s*$/, "").split(";").map((style) => { 4671 const [key, ...valueParts] = style.split(":"); 4672 const value = valueParts.join(":"); 4673 return [key.trim(), getNormalizedStyleValue(value.trim())]; 4674 }); 4675 return Object.fromEntries(pairs); 4676 } 4677 var isEqualAttributesOfName = { 4678 class: (actual, expected) => { 4679 const [actualPieces, expectedPieces] = [actual, expected].map( 4680 getTextPiecesSplitOnWhitespace 4681 ); 4682 const actualDiff = actualPieces.filter( 4683 (c2) => !expectedPieces.includes(c2) 4684 ); 4685 const expectedDiff = expectedPieces.filter( 4686 (c2) => !actualPieces.includes(c2) 4687 ); 4688 return actualDiff.length === 0 && expectedDiff.length === 0; 4689 }, 4690 style: (actual, expected) => { 4691 return (0, import_es62.default)( 4692 ...[actual, expected].map(getStyleProperties) 4693 ); 4694 }, 4695 // For each boolean attribute, mere presence of attribute in both is enough 4696 // to assume equivalence. 4697 ...Object.fromEntries( 4698 BOOLEAN_ATTRIBUTES.map((attribute) => [attribute, () => true]) 4699 ) 4700 }; 4701 function isEqualTagAttributePairs(actual, expected, logger = createLogger()) { 4702 if (actual.length !== expected.length) { 4703 logger.warning( 4704 "Expected attributes %o, instead saw %o.", 4705 expected, 4706 actual 4707 ); 4708 return false; 4709 } 4710 const expectedAttributes = {}; 4711 for (let i = 0; i < expected.length; i++) { 4712 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; 4713 } 4714 for (let i = 0; i < actual.length; i++) { 4715 const [name, actualValue] = actual[i]; 4716 const nameLower = name.toLowerCase(); 4717 if (!expectedAttributes.hasOwnProperty(nameLower)) { 4718 logger.warning("Encountered unexpected attribute `%s`.", name); 4719 return false; 4720 } 4721 const expectedValue = expectedAttributes[nameLower]; 4722 const isEqualAttributes = isEqualAttributesOfName[nameLower]; 4723 if (isEqualAttributes) { 4724 if (!isEqualAttributes(actualValue, expectedValue)) { 4725 logger.warning( 4726 "Expected attribute `%s` of value `%s`, saw `%s`.", 4727 name, 4728 expectedValue, 4729 actualValue 4730 ); 4731 return false; 4732 } 4733 } else if (actualValue !== expectedValue) { 4734 logger.warning( 4735 "Expected attribute `%s` of value `%s`, saw `%s`.", 4736 name, 4737 expectedValue, 4738 actualValue 4739 ); 4740 return false; 4741 } 4742 } 4743 return true; 4744 } 4745 var isEqualTokensOfType = { 4746 StartTag: (actual, expected, logger = createLogger()) => { 4747 if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- 4748 // insensitive check on the assumption that the majority case will 4749 // have exactly equal tag names. 4750 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { 4751 logger.warning( 4752 "Expected tag name `%s`, instead saw `%s`.", 4753 expected.tagName, 4754 actual.tagName 4755 ); 4756 return false; 4757 } 4758 return isEqualTagAttributePairs( 4759 ...[actual, expected].map(getMeaningfulAttributePairs), 4760 logger 4761 ); 4762 }, 4763 Chars: isEquivalentTextTokens, 4764 Comment: isEquivalentTextTokens 4765 }; 4766 function getNextNonWhitespaceToken(tokens) { 4767 let token; 4768 while (token = tokens.shift()) { 4769 if (token.type !== "Chars") { 4770 return token; 4771 } 4772 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { 4773 return token; 4774 } 4775 } 4776 return void 0; 4777 } 4778 function getHTMLTokens(html2, logger = createLogger()) { 4779 try { 4780 return new Tokenizer(new DecodeEntityParser()).tokenize( 4781 html2 4782 ); 4783 } catch { 4784 logger.warning("Malformed HTML detected: %s", html2); 4785 } 4786 return null; 4787 } 4788 function isClosedByToken(currentToken, nextToken) { 4789 if (!currentToken.selfClosing) { 4790 return false; 4791 } 4792 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === "EndTag") { 4793 return true; 4794 } 4795 return false; 4796 } 4797 function isEquivalentHTML(actual, expected, logger = createLogger()) { 4798 if (actual === expected) { 4799 return true; 4800 } 4801 const [actualTokens, expectedTokens] = [actual, expected].map( 4802 (html2) => getHTMLTokens(html2, logger) 4803 ); 4804 if (!actualTokens || !expectedTokens) { 4805 return false; 4806 } 4807 let actualToken, expectedToken; 4808 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { 4809 expectedToken = getNextNonWhitespaceToken(expectedTokens); 4810 if (!expectedToken) { 4811 logger.warning( 4812 "Expected end of content, instead saw %o.", 4813 actualToken 4814 ); 4815 return false; 4816 } 4817 if (actualToken.type !== expectedToken.type) { 4818 logger.warning( 4819 "Expected token of type `%s` (%o), instead saw `%s` (%o).", 4820 expectedToken.type, 4821 expectedToken, 4822 actualToken.type, 4823 actualToken 4824 ); 4825 return false; 4826 } 4827 const isEqualTokens = isEqualTokensOfType[actualToken.type]; 4828 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { 4829 return false; 4830 } 4831 if (isClosedByToken(actualToken, expectedTokens[0])) { 4832 getNextNonWhitespaceToken(expectedTokens); 4833 } else if (isClosedByToken(expectedToken, actualTokens[0])) { 4834 getNextNonWhitespaceToken(actualTokens); 4835 } 4836 } 4837 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { 4838 logger.warning( 4839 "Expected %o, instead saw end of content.", 4840 expectedToken 4841 ); 4842 return false; 4843 } 4844 return true; 4845 } 4846 function validateBlock(block, blockTypeOrName = block.name) { 4847 const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); 4848 if (isFallbackBlock) { 4849 return [true, []]; 4850 } 4851 const logger = createQueuedLogger(); 4852 const blockType = normalizeBlockType(blockTypeOrName); 4853 let generatedBlockContent; 4854 try { 4855 generatedBlockContent = getSaveContent(blockType, block.attributes); 4856 } catch (error) { 4857 logger.error( 4858 "Block validation failed because an error occurred while generating block content:\n\n%s", 4859 error.toString() 4860 ); 4861 return [false, logger.getItems()]; 4862 } 4863 const isValid = isEquivalentHTML( 4864 block.originalContent, 4865 generatedBlockContent, 4866 logger 4867 ); 4868 if (!isValid) { 4869 logger.error( 4870 "Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s", 4871 blockType.name, 4872 blockType, 4873 generatedBlockContent, 4874 block.originalContent 4875 ); 4876 } 4877 return [isValid, logger.getItems()]; 4878 } 4879 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { 4880 (0, import_deprecated8.default)("isValidBlockContent introduces opportunity for data loss", { 4881 since: "12.6", 4882 plugin: "Gutenberg", 4883 alternative: "validateBlock" 4884 }); 4885 const blockType = normalizeBlockType(blockTypeOrName); 4886 const block = { 4887 clientId: "", 4888 name: blockType.name, 4889 isValid: true, 4890 attributes, 4891 innerBlocks: [], 4892 originalContent: originalBlockContent 4893 }; 4894 const [isValid] = validateBlock(block, blockType); 4895 return isValid; 4896 } 4897 4898 // packages/blocks/build-module/api/parser/convert-legacy-block.mjs 4899 function convertLegacyBlockNameAndAttributes(name, attributes) { 4900 const newAttributes = { ...attributes }; 4901 if ("core/cover-image" === name) { 4902 name = "core/cover"; 4903 } 4904 if ("core/text" === name || "core/cover-text" === name) { 4905 name = "core/paragraph"; 4906 } 4907 if (name && name.indexOf("core/social-link-") === 0) { 4908 newAttributes.service = name.substring(17); 4909 name = "core/social-link"; 4910 } 4911 if (name && name.indexOf("core-embed/") === 0) { 4912 const providerSlug = name.substring(11); 4913 const deprecated13 = { 4914 speaker: "speaker-deck", 4915 polldaddy: "crowdsignal" 4916 }; 4917 newAttributes.providerNameSlug = providerSlug in deprecated13 ? deprecated13[providerSlug] : providerSlug; 4918 if (!["amazon-kindle", "wordpress"].includes(providerSlug)) { 4919 newAttributes.responsive = true; 4920 } 4921 name = "core/embed"; 4922 } 4923 if (name === "core/post-comment-author") { 4924 name = "core/comment-author-name"; 4925 } 4926 if (name === "core/post-comment-content") { 4927 name = "core/comment-content"; 4928 } 4929 if (name === "core/post-comment-date") { 4930 name = "core/comment-date"; 4931 } 4932 if (name === "core/comments-query-loop") { 4933 name = "core/comments"; 4934 const className = newAttributes.className ?? ""; 4935 if (!className.includes("wp-block-comments-query-loop")) { 4936 newAttributes.className = [ 4937 "wp-block-comments-query-loop", 4938 className 4939 ].join(" "); 4940 } 4941 } 4942 if (name === "core/post-comments") { 4943 name = "core/comments"; 4944 newAttributes.legacy = true; 4945 } 4946 const layout = attributes.layout; 4947 if (layout?.type === "grid" && typeof layout?.columnCount === "string") { 4948 newAttributes.layout = { 4949 ...newAttributes.layout, 4950 columnCount: parseInt(layout.columnCount, 10) 4951 }; 4952 } 4953 const style = attributes.style; 4954 const styleLayout = style?.layout; 4955 if (typeof styleLayout?.columnSpan === "string") { 4956 const columnSpanNumber = parseInt(styleLayout.columnSpan, 10); 4957 newAttributes.style = { 4958 ...newAttributes.style, 4959 layout: { 4960 ...newAttributes.style?.layout, 4961 columnSpan: isNaN(columnSpanNumber) ? void 0 : columnSpanNumber 4962 } 4963 }; 4964 } 4965 if (typeof styleLayout?.rowSpan === "string") { 4966 const rowSpanNumber = parseInt(styleLayout.rowSpan, 10); 4967 newAttributes.style = { 4968 ...newAttributes.style, 4969 layout: { 4970 ...newAttributes.style?.layout, 4971 rowSpan: isNaN(rowSpanNumber) ? void 0 : rowSpanNumber 4972 } 4973 }; 4974 } 4975 return [name, newAttributes]; 4976 } 4977 4978 // node_modules/.store/hpq@1.4.0-W9NdSIZtdLeCHL5yGEJLvQ/node_modules/hpq/es/get-path.js 4979 function getPath(object, path) { 4980 var segments = path.split("."); 4981 var segment; 4982 while (segment = segments.shift()) { 4983 if (!(segment in object)) { 4984 return; 4985 } 4986 object = object[segment]; 4987 } 4988 return object; 4989 } 4990 4991 // node_modules/.store/hpq@1.4.0-W9NdSIZtdLeCHL5yGEJLvQ/node_modules/hpq/es/index.js 4992 var getDocument = /* @__PURE__ */ (function() { 4993 var doc; 4994 return function() { 4995 if (!doc) { 4996 doc = document.implementation.createHTMLDocument(""); 4997 } 4998 return doc; 4999 }; 5000 })(); 5001 function parse(source, matchers) { 5002 if (!matchers) { 5003 return; 5004 } 5005 if ("string" === typeof source) { 5006 var doc = getDocument(); 5007 doc.body.innerHTML = source; 5008 source = doc.body; 5009 } 5010 if (typeof matchers === "function") { 5011 return matchers(source); 5012 } 5013 if (Object !== matchers.constructor) { 5014 return; 5015 } 5016 return Object.keys(matchers).reduce(function(memo, key) { 5017 var inner = matchers[key]; 5018 memo[key] = parse(source, inner); 5019 return memo; 5020 }, {}); 5021 } 5022 function prop(arg1, arg2) { 5023 var name; 5024 var selector; 5025 if (1 === arguments.length) { 5026 name = arg1; 5027 selector = void 0; 5028 } else { 5029 name = arg2; 5030 selector = arg1; 5031 } 5032 return function(node) { 5033 var match = node; 5034 if (selector) { 5035 match = node.querySelector(selector); 5036 } 5037 if (match) { 5038 return getPath(match, name); 5039 } 5040 }; 5041 } 5042 function attr(arg1, arg2) { 5043 var name; 5044 var selector; 5045 if (1 === arguments.length) { 5046 name = arg1; 5047 selector = void 0; 5048 } else { 5049 name = arg2; 5050 selector = arg1; 5051 } 5052 return function(node) { 5053 var attributes = prop(selector, "attributes")(node); 5054 if (attributes && Object.prototype.hasOwnProperty.call(attributes, name)) { 5055 return attributes[name].value; 5056 } 5057 }; 5058 } 5059 function text(selector) { 5060 return prop(selector, "textContent"); 5061 } 5062 function query(selector, matchers) { 5063 return function(node) { 5064 var matches = node.querySelectorAll(selector); 5065 return [].map.call(matches, function(match) { 5066 return parse(match, matchers); 5067 }); 5068 }; 5069 } 5070 5071 // node_modules/.store/memize@2.1.1-roXbtpG2bis3Lggp7SQpAA/node_modules/memize/dist/index.js 5072 function memize(fn, options) { 5073 var size = 0; 5074 var head; 5075 var tail; 5076 options = options || {}; 5077 function memoized() { 5078 var node = head, len = arguments.length, args, i; 5079 searchCache: while (node) { 5080 if (node.args.length !== arguments.length) { 5081 node = node.next; 5082 continue; 5083 } 5084 for (i = 0; i < len; i++) { 5085 if (node.args[i] !== arguments[i]) { 5086 node = node.next; 5087 continue searchCache; 5088 } 5089 } 5090 if (node !== head) { 5091 if (node === tail) { 5092 tail = node.prev; 5093 } 5094 node.prev.next = node.next; 5095 if (node.next) { 5096 node.next.prev = node.prev; 5097 } 5098 node.next = head; 5099 node.prev = null; 5100 head.prev = node; 5101 head = node; 5102 } 5103 return node.val; 5104 } 5105 args = new Array(len); 5106 for (i = 0; i < len; i++) { 5107 args[i] = arguments[i]; 5108 } 5109 node = { 5110 args, 5111 // Generate the result from original function 5112 val: fn.apply(null, args) 5113 }; 5114 if (head) { 5115 head.prev = node; 5116 node.next = head; 5117 } else { 5118 tail = node; 5119 } 5120 if (size === /** @type {MemizeOptions} */ 5121 options.maxSize) { 5122 tail = /** @type {MemizeCacheNode} */ 5123 tail.prev; 5124 tail.next = null; 5125 } else { 5126 size++; 5127 } 5128 head = node; 5129 return node.val; 5130 } 5131 memoized.clear = function() { 5132 head = null; 5133 tail = null; 5134 size = 0; 5135 }; 5136 return memoized; 5137 } 5138 5139 // packages/blocks/build-module/api/parser/get-block-attributes.mjs 5140 var import_hooks4 = __toESM(require_hooks(), 1); 5141 var import_rich_text4 = __toESM(require_rich_text(), 1); 5142 5143 // packages/blocks/build-module/api/matchers.mjs 5144 var import_rich_text3 = __toESM(require_rich_text(), 1); 5145 5146 // packages/blocks/build-module/api/node.mjs 5147 var import_deprecated10 = __toESM(require_deprecated(), 1); 5148 5149 // packages/blocks/build-module/api/children.mjs 5150 var import_element3 = __toESM(require_element(), 1); 5151 var import_deprecated9 = __toESM(require_deprecated(), 1); 5152 function getSerializeCapableElement(children) { 5153 return children; 5154 } 5155 function getChildrenArray(children) { 5156 (0, import_deprecated9.default)("wp.blocks.children.getChildrenArray", { 5157 since: "6.1", 5158 version: "6.3", 5159 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5160 }); 5161 return children; 5162 } 5163 function concat(...blockNodes) { 5164 (0, import_deprecated9.default)("wp.blocks.children.concat", { 5165 since: "6.1", 5166 version: "6.3", 5167 alternative: "wp.richText.concat", 5168 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5169 }); 5170 const result = []; 5171 for (let i = 0; i < blockNodes.length; i++) { 5172 const blockNode = Array.isArray(blockNodes[i]) ? blockNodes[i] : [blockNodes[i]]; 5173 for (let j2 = 0; j2 < blockNode.length; j2++) { 5174 const child = blockNode[j2]; 5175 const canConcatToPreviousString = typeof child === "string" && typeof result[result.length - 1] === "string"; 5176 if (canConcatToPreviousString) { 5177 result[result.length - 1] += child; 5178 } else { 5179 result.push(child); 5180 } 5181 } 5182 } 5183 return result; 5184 } 5185 function fromDOM22(domNodes) { 5186 (0, import_deprecated9.default)("wp.blocks.children.fromDOM", { 5187 since: "6.1", 5188 version: "6.3", 5189 alternative: "wp.richText.create", 5190 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5191 }); 5192 const result = []; 5193 for (let i = 0; i < domNodes.length; i++) { 5194 try { 5195 result.push(fromDOM2(domNodes[i])); 5196 } catch { 5197 } 5198 } 5199 return result; 5200 } 5201 function toHTML(children) { 5202 (0, import_deprecated9.default)("wp.blocks.children.toHTML", { 5203 since: "6.1", 5204 version: "6.3", 5205 alternative: "wp.richText.toHTMLString", 5206 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5207 }); 5208 const element = getSerializeCapableElement(children); 5209 return (0, import_element3.renderToString)(element); 5210 } 5211 function matcher(selector) { 5212 (0, import_deprecated9.default)("wp.blocks.children.matcher", { 5213 since: "6.1", 5214 version: "6.3", 5215 alternative: "html source", 5216 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5217 }); 5218 return (domNode) => { 5219 let match = domNode; 5220 if (selector) { 5221 match = domNode.querySelector(selector); 5222 } 5223 if (match) { 5224 return fromDOM22(match.childNodes); 5225 } 5226 return []; 5227 }; 5228 } 5229 var children_default = { 5230 concat, 5231 getChildrenArray, 5232 fromDOM: fromDOM22, 5233 toHTML, 5234 matcher 5235 }; 5236 5237 // packages/blocks/build-module/api/node.mjs 5238 function isNodeOfType(node, type) { 5239 (0, import_deprecated10.default)("wp.blocks.node.isNodeOfType", { 5240 since: "6.1", 5241 version: "6.3", 5242 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5243 }); 5244 return typeof node !== "string" && node?.type === type; 5245 } 5246 function getNamedNodeMapAsObject(nodeMap) { 5247 const result = {}; 5248 for (let i = 0; i < nodeMap.length; i++) { 5249 const { name, value } = nodeMap[i]; 5250 result[name] = value; 5251 } 5252 return result; 5253 } 5254 function fromDOM2(domNode) { 5255 (0, import_deprecated10.default)("wp.blocks.node.fromDOM", { 5256 since: "6.1", 5257 version: "6.3", 5258 alternative: "wp.richText.create", 5259 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5260 }); 5261 if (domNode.nodeType === domNode.TEXT_NODE) { 5262 return domNode.nodeValue; 5263 } 5264 if (domNode.nodeType !== domNode.ELEMENT_NODE) { 5265 throw new TypeError( 5266 "A block node can only be created from a node of type text or element." 5267 ); 5268 } 5269 return { 5270 type: domNode.nodeName.toLowerCase(), 5271 props: { 5272 ...getNamedNodeMapAsObject(domNode.attributes), 5273 children: fromDOM22(domNode.childNodes) 5274 } 5275 }; 5276 } 5277 function toHTML2(node) { 5278 (0, import_deprecated10.default)("wp.blocks.node.toHTML", { 5279 since: "6.1", 5280 version: "6.3", 5281 alternative: "wp.richText.toHTMLString", 5282 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5283 }); 5284 return toHTML([node]); 5285 } 5286 function matcher2(selector) { 5287 (0, import_deprecated10.default)("wp.blocks.node.matcher", { 5288 since: "6.1", 5289 version: "6.3", 5290 alternative: "html source", 5291 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5292 }); 5293 return (domNode) => { 5294 let match = domNode; 5295 if (selector) { 5296 match = domNode.querySelector(selector); 5297 } 5298 try { 5299 return fromDOM2(match); 5300 } catch { 5301 return null; 5302 } 5303 }; 5304 } 5305 var node_default = { 5306 isNodeOfType, 5307 fromDOM: fromDOM2, 5308 toHTML: toHTML2, 5309 matcher: matcher2 5310 }; 5311 5312 // packages/blocks/build-module/api/matchers.mjs 5313 function html(selector, multilineTag) { 5314 return (domNode) => { 5315 let match = domNode; 5316 if (selector) { 5317 match = domNode.querySelector(selector); 5318 } 5319 if (!match) { 5320 return ""; 5321 } 5322 if (multilineTag) { 5323 let value = ""; 5324 const length = match.children.length; 5325 for (let index = 0; index < length; index++) { 5326 const child = match.children[index]; 5327 if (child.nodeName.toLowerCase() !== multilineTag) { 5328 continue; 5329 } 5330 value += child.outerHTML; 5331 } 5332 return value; 5333 } 5334 return match.innerHTML; 5335 }; 5336 } 5337 var richText = (selector, preserveWhiteSpace) => (el) => { 5338 const target = selector ? el.querySelector(selector) : el; 5339 return target ? import_rich_text3.RichTextData.fromHTMLElement(target, { 5340 preserveWhiteSpace 5341 }) : import_rich_text3.RichTextData.empty(); 5342 }; 5343 5344 // packages/blocks/build-module/api/parser/get-block-attributes.mjs 5345 var toBooleanAttributeMatcher = (matcher3) => (domNode) => matcher3(domNode) !== void 0; 5346 function isOfType(value, type) { 5347 switch (type) { 5348 case "rich-text": 5349 return value instanceof import_rich_text4.RichTextData; 5350 case "string": 5351 return typeof value === "string"; 5352 case "boolean": 5353 return typeof value === "boolean"; 5354 case "object": 5355 return !!value && value.constructor === Object; 5356 case "null": 5357 return value === null; 5358 case "array": 5359 return Array.isArray(value); 5360 case "integer": 5361 case "number": 5362 return typeof value === "number"; 5363 } 5364 return true; 5365 } 5366 function isOfTypes(value, types) { 5367 return types.some((type) => isOfType(value, type)); 5368 } 5369 function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) { 5370 let value; 5371 switch (attributeSchema.source) { 5372 // An undefined source means that it's an attribute serialized to the 5373 // block's "comment". 5374 case void 0: 5375 value = commentAttributes ? commentAttributes[attributeKey] : void 0; 5376 break; 5377 // raw source means that it's the original raw block content. 5378 case "raw": 5379 value = innerHTML; 5380 break; 5381 case "attribute": 5382 case "property": 5383 case "html": 5384 case "text": 5385 case "rich-text": 5386 case "children": 5387 case "node": 5388 case "query": 5389 case "tag": 5390 value = parseWithAttributeSchema(innerDOM, attributeSchema); 5391 break; 5392 } 5393 if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) { 5394 value = void 0; 5395 } 5396 if (value === void 0) { 5397 value = getDefault(attributeSchema); 5398 } 5399 return value; 5400 } 5401 function isValidByType(value, type) { 5402 return type === void 0 || isOfTypes(value, Array.isArray(type) ? type : [type]); 5403 } 5404 function isValidByEnum(value, enumSet) { 5405 return !Array.isArray(enumSet) || enumSet.includes(value); 5406 } 5407 var matcherFromSource = memize( 5408 (sourceConfig) => { 5409 switch (sourceConfig.source) { 5410 case "attribute": { 5411 const matcher3 = attr( 5412 sourceConfig.selector, 5413 sourceConfig.attribute 5414 ); 5415 if (sourceConfig.type === "boolean") { 5416 return toBooleanAttributeMatcher(matcher3); 5417 } 5418 return matcher3; 5419 } 5420 case "html": 5421 return html(sourceConfig.selector, sourceConfig.multiline); 5422 case "text": 5423 return text(sourceConfig.selector); 5424 case "rich-text": 5425 return richText( 5426 sourceConfig.selector, 5427 sourceConfig.__unstablePreserveWhiteSpace 5428 ); 5429 case "children": 5430 return matcher(sourceConfig.selector); 5431 case "node": 5432 return matcher2(sourceConfig.selector); 5433 case "query": 5434 const subMatchers = Object.fromEntries( 5435 Object.entries(sourceConfig.query).map( 5436 ([key, subSourceConfig]) => [ 5437 key, 5438 matcherFromSource(subSourceConfig) 5439 ] 5440 ) 5441 ); 5442 return query(sourceConfig.selector, subMatchers); 5443 case "tag": { 5444 const matcher3 = prop(sourceConfig.selector, "nodeName"); 5445 return (domNode) => matcher3(domNode)?.toLowerCase(); 5446 } 5447 default: 5448 console.error( 5449 `Unknown source type "${sourceConfig.source}"` 5450 ); 5451 return void 0; 5452 } 5453 } 5454 ); 5455 function parseHtml(innerHTML) { 5456 return parse( 5457 innerHTML ?? "", 5458 (h) => h 5459 ); 5460 } 5461 function parseWithAttributeSchema(innerHTML, attributeSchema) { 5462 return matcherFromSource(attributeSchema)( 5463 parseHtml(innerHTML) 5464 ); 5465 } 5466 function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) { 5467 const doc = parseHtml(innerHTML); 5468 const blockType = normalizeBlockType(blockTypeOrName); 5469 const blockAttributes = Object.fromEntries( 5470 Object.entries(blockType?.attributes ?? {}).map( 5471 ([key, schema]) => [ 5472 key, 5473 getBlockAttribute(key, schema, doc, attributes, innerHTML) 5474 ] 5475 ) 5476 ); 5477 return (0, import_hooks4.applyFilters)( 5478 "blocks.getBlockAttributes", 5479 blockAttributes, 5480 blockType, 5481 innerHTML, 5482 attributes 5483 ); 5484 } 5485 5486 // packages/blocks/build-module/api/parser/fix-custom-classname.mjs 5487 var CLASS_ATTR_SCHEMA = { 5488 type: "string", 5489 source: "attribute", 5490 selector: "[data-custom-class-name] > *", 5491 attribute: "class" 5492 }; 5493 function getHTMLRootElementClasses(innerHTML) { 5494 const parsed = parseWithAttributeSchema( 5495 `<div data-custom-class-name>$innerHTML}</div>`, 5496 CLASS_ATTR_SCHEMA 5497 ); 5498 return parsed ? parsed.trim().split(/\s+/) : []; 5499 } 5500 function fixCustomClassname(blockAttributes, blockType, innerHTML) { 5501 if (!hasBlockSupport(blockType, "customClassName", true)) { 5502 return blockAttributes; 5503 } 5504 const modifiedBlockAttributes = { ...blockAttributes }; 5505 const { className: omittedClassName, ...attributesSansClassName } = modifiedBlockAttributes; 5506 const serialized = getSaveContent(blockType, attributesSansClassName); 5507 const defaultClasses = getHTMLRootElementClasses(serialized); 5508 const actualClasses = getHTMLRootElementClasses(innerHTML); 5509 const customClasses = actualClasses.filter( 5510 (className) => !defaultClasses.includes(className) 5511 ); 5512 if (customClasses.length) { 5513 modifiedBlockAttributes.className = customClasses.join(" "); 5514 } else if (serialized) { 5515 delete modifiedBlockAttributes.className; 5516 } 5517 return modifiedBlockAttributes; 5518 } 5519 5520 // packages/blocks/build-module/api/parser/fix-global-attribute.mjs 5521 function getHTMLRootElement(innerHTML, dataAttribute, attributeSchema) { 5522 const parsed = parseWithAttributeSchema( 5523 `<div $dataAttribute}>$innerHTML}</div>`, 5524 attributeSchema 5525 ); 5526 return parsed; 5527 } 5528 function fixGlobalAttribute(blockAttributes, blockType, innerHTML, supportKey, dataAttribute, attributeSchema) { 5529 if (!hasBlockSupport(blockType, supportKey, false)) { 5530 return blockAttributes; 5531 } 5532 const modifiedBlockAttributes = { ...blockAttributes }; 5533 const attributeValue = getHTMLRootElement( 5534 innerHTML, 5535 dataAttribute, 5536 attributeSchema 5537 ); 5538 if (attributeValue) { 5539 modifiedBlockAttributes[supportKey] = attributeValue; 5540 } 5541 return modifiedBlockAttributes; 5542 } 5543 5544 // packages/blocks/build-module/api/parser/apply-built-in-validation-fixes.mjs 5545 var ARIA_LABEL_ATTR_SCHEMA = { 5546 type: "string", 5547 source: "attribute", 5548 selector: "[data-aria-label] > *", 5549 attribute: "aria-label" 5550 }; 5551 var ANCHOR_ATTR_SCHEMA = { 5552 type: "string", 5553 source: "attribute", 5554 selector: "[data-anchor] > *", 5555 attribute: "id" 5556 }; 5557 function applyBuiltInValidationFixes(block, blockType) { 5558 const { attributes, originalContent } = block; 5559 let updatedBlockAttributes = attributes; 5560 updatedBlockAttributes = fixCustomClassname( 5561 attributes, 5562 blockType, 5563 originalContent ?? "" 5564 ); 5565 updatedBlockAttributes = fixGlobalAttribute( 5566 updatedBlockAttributes, 5567 blockType, 5568 originalContent ?? "", 5569 "ariaLabel", 5570 "data-aria-label", 5571 ARIA_LABEL_ATTR_SCHEMA 5572 ); 5573 updatedBlockAttributes = fixGlobalAttribute( 5574 updatedBlockAttributes, 5575 blockType, 5576 originalContent ?? "", 5577 "anchor", 5578 "data-anchor", 5579 ANCHOR_ATTR_SCHEMA 5580 ); 5581 return { 5582 ...block, 5583 attributes: updatedBlockAttributes 5584 }; 5585 } 5586 5587 // packages/blocks/build-module/api/parser/apply-block-deprecated-versions.mjs 5588 function stubFalse() { 5589 return false; 5590 } 5591 function applyBlockDeprecatedVersions(block, rawBlock, blockType) { 5592 const parsedAttributes = rawBlock.attrs ?? {}; 5593 const { deprecated: deprecatedDefinitions } = blockType; 5594 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { 5595 return block; 5596 } 5597 for (let i = 0; i < deprecatedDefinitions.length; i++) { 5598 const { isEligible = stubFalse } = deprecatedDefinitions[i]; 5599 if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, { 5600 blockNode: rawBlock, 5601 block 5602 })) { 5603 continue; 5604 } 5605 const deprecatedBlockType = Object.assign( 5606 omit( 5607 blockType, 5608 DEPRECATED_ENTRY_KEYS 5609 ), 5610 deprecatedDefinitions[i] 5611 ); 5612 let migratedBlock = { 5613 ...block, 5614 attributes: getBlockAttributes( 5615 deprecatedBlockType, 5616 block.originalContent ?? "", 5617 parsedAttributes 5618 ) 5619 }; 5620 let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); 5621 if (!isValid) { 5622 migratedBlock = applyBuiltInValidationFixes( 5623 migratedBlock, 5624 deprecatedBlockType 5625 ); 5626 [isValid] = validateBlock(migratedBlock, deprecatedBlockType); 5627 } 5628 if (!isValid) { 5629 continue; 5630 } 5631 let migratedInnerBlocks = migratedBlock.innerBlocks; 5632 let migratedAttributes = migratedBlock.attributes; 5633 const { migrate } = deprecatedBlockType; 5634 if (migrate) { 5635 let migrated = migrate(migratedAttributes, block.innerBlocks); 5636 if (!Array.isArray(migrated)) { 5637 migrated = [migrated]; 5638 } 5639 [ 5640 migratedAttributes = parsedAttributes, 5641 migratedInnerBlocks = block.innerBlocks 5642 ] = migrated; 5643 } 5644 block = { 5645 ...block, 5646 attributes: migratedAttributes, 5647 innerBlocks: migratedInnerBlocks, 5648 isValid: true, 5649 validationIssues: [] 5650 }; 5651 } 5652 return block; 5653 } 5654 5655 // packages/blocks/build-module/api/parser/index.mjs 5656 function convertLegacyBlocks(rawBlock) { 5657 const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes( 5658 rawBlock.blockName, 5659 rawBlock.attrs ?? {} 5660 ); 5661 return { 5662 ...rawBlock, 5663 blockName: correctName, 5664 attrs: correctedAttributes 5665 }; 5666 } 5667 function normalizeRawBlock(rawBlock, options) { 5668 const fallbackBlockName = getFreeformContentHandlerName(); 5669 const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName(); 5670 const rawAttributes = rawBlock.attrs || {}; 5671 const rawInnerBlocks = rawBlock.innerBlocks || []; 5672 let rawInnerHTML = rawBlock.innerHTML.trim(); 5673 if (rawBlockName === fallbackBlockName && rawBlockName === "core/freeform" && !options?.__unstableSkipAutop) { 5674 rawInnerHTML = (0, import_autop2.autop)(rawInnerHTML).trim(); 5675 } 5676 return { 5677 ...rawBlock, 5678 blockName: rawBlockName, 5679 attrs: rawAttributes, 5680 innerHTML: rawInnerHTML, 5681 innerBlocks: rawInnerBlocks 5682 }; 5683 } 5684 function createMissingBlockType(rawBlock) { 5685 const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); 5686 const originalUndelimitedContent = serializeRawBlock(rawBlock, { 5687 isCommentDelimited: false 5688 }); 5689 const originalContent = serializeRawBlock(rawBlock, { 5690 isCommentDelimited: true 5691 }); 5692 return { 5693 blockName: unregisteredFallbackBlock, 5694 attrs: { 5695 originalName: rawBlock.blockName, 5696 originalContent, 5697 originalUndelimitedContent 5698 }, 5699 innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML, 5700 innerBlocks: rawBlock.innerBlocks, 5701 innerContent: rawBlock.innerContent 5702 }; 5703 } 5704 function applyBlockValidation(unvalidatedBlock, blockType) { 5705 const [isValid] = validateBlock(unvalidatedBlock, blockType); 5706 if (isValid) { 5707 return { ...unvalidatedBlock, isValid, validationIssues: [] }; 5708 } 5709 const fixedBlock = applyBuiltInValidationFixes( 5710 unvalidatedBlock, 5711 blockType 5712 ); 5713 const [isFixedValid, validationIssues] = validateBlock( 5714 fixedBlock, 5715 blockType 5716 ); 5717 return { ...fixedBlock, isValid: isFixedValid, validationIssues }; 5718 } 5719 function parseRawBlock(rawBlock, options) { 5720 let normalizedBlock = normalizeRawBlock(rawBlock, options); 5721 normalizedBlock = convertLegacyBlocks(normalizedBlock); 5722 let blockType = getBlockType(normalizedBlock.blockName); 5723 if (!blockType) { 5724 normalizedBlock = createMissingBlockType(normalizedBlock); 5725 blockType = getBlockType(normalizedBlock.blockName); 5726 } 5727 const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName(); 5728 if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) { 5729 return; 5730 } 5731 const parsedInnerBlocks = normalizedBlock.innerBlocks.map((innerBlock) => parseRawBlock(innerBlock, options)).filter((innerBlock) => !!innerBlock); 5732 const parsedBlock = createBlock( 5733 normalizedBlock.blockName, 5734 getBlockAttributes( 5735 blockType, 5736 normalizedBlock.innerHTML, 5737 normalizedBlock.attrs 5738 ), 5739 parsedInnerBlocks 5740 ); 5741 parsedBlock.originalContent = normalizedBlock.innerHTML; 5742 if (blockType.name === "core/html") { 5743 parsedBlock.innerContent = normalizedBlock.innerContent ?? [ 5744 normalizedBlock.innerHTML 5745 ]; 5746 parsedBlock.isValid = true; 5747 parsedBlock.validationIssues = []; 5748 return parsedBlock; 5749 } 5750 const validatedBlock = applyBlockValidation(parsedBlock, blockType); 5751 const { validationIssues } = validatedBlock; 5752 const updatedBlock = applyBlockDeprecatedVersions( 5753 validatedBlock, 5754 normalizedBlock, 5755 blockType 5756 ); 5757 if (!updatedBlock.isValid) { 5758 updatedBlock.__unstableBlockSource = rawBlock; 5759 } 5760 if (!validatedBlock.isValid && updatedBlock.isValid && !options?.__unstableSkipMigrationLogs) { 5761 console.groupCollapsed("Updated Block: %s", blockType.name); 5762 console.info( 5763 "Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s", 5764 blockType.name, 5765 blockType, 5766 getSaveContent(blockType, updatedBlock.attributes), 5767 updatedBlock.originalContent 5768 ); 5769 console.groupEnd(); 5770 } else if (!validatedBlock.isValid && !updatedBlock.isValid) { 5771 validationIssues.forEach(({ log: log2, args }) => log2(...args)); 5772 } 5773 return updatedBlock; 5774 } 5775 function parse2(content, options) { 5776 return (0, import_block_serialization_default_parser.parse)(content).reduce( 5777 (accumulator, rawBlock) => { 5778 const block = parseRawBlock( 5779 rawBlock, 5780 options 5781 ); 5782 if (block) { 5783 accumulator.push(block); 5784 } 5785 return accumulator; 5786 }, 5787 [] 5788 ); 5789 } 5790 5791 // packages/blocks/build-module/api/raw-handling/index.mjs 5792 var import_deprecated11 = __toESM(require_deprecated(), 1); 5793 var import_dom13 = __toESM(require_dom(), 1); 5794 5795 // packages/blocks/build-module/api/raw-handling/get-raw-transforms.mjs 5796 function getRawTransforms() { 5797 return getBlockTransforms("from").filter( 5798 (transform) => transform.type === "raw" 5799 ).map((transform) => ({ 5800 ...transform, 5801 isMatch: transform.isMatch ?? ((node) => !!transform.selector && node.matches(transform.selector)) 5802 })); 5803 } 5804 5805 // packages/blocks/build-module/api/raw-handling/html-to-blocks.mjs 5806 function htmlToBlocks(html2, handler) { 5807 const doc = document.implementation.createHTMLDocument(""); 5808 doc.body.innerHTML = html2; 5809 return Array.from(doc.body.children).flatMap((node) => { 5810 const transforms = getRawTransforms(); 5811 const rawTransform = findTransform( 5812 transforms, 5813 (transform2) => transform2.isMatch(node) 5814 ); 5815 if (!rawTransform) { 5816 return createBlock( 5817 // Should not be hardcoded. 5818 "core/html", 5819 {}, 5820 [], 5821 [node.outerHTML] 5822 ); 5823 } 5824 const { transform, blockName } = rawTransform; 5825 if (transform) { 5826 const block = transform(node, handler); 5827 if (node.hasAttribute("class")) { 5828 block.attributes.className = node.getAttribute("class"); 5829 } 5830 return block; 5831 } 5832 return createBlock( 5833 blockName, 5834 getBlockAttributes(blockName, node.outerHTML) 5835 ); 5836 }); 5837 } 5838 5839 // packages/blocks/build-module/api/raw-handling/normalise-blocks.mjs 5840 var import_dom2 = __toESM(require_dom(), 1); 5841 function normaliseBlocks(HTML, options = {}) { 5842 const decuDoc = document.implementation.createHTMLDocument(""); 5843 const accuDoc = document.implementation.createHTMLDocument(""); 5844 const decu = decuDoc.body; 5845 const accu = accuDoc.body; 5846 decu.innerHTML = HTML; 5847 while (decu.firstChild) { 5848 const node = decu.firstChild; 5849 if (node.nodeType === node.TEXT_NODE) { 5850 if ((0, import_dom2.isEmpty)(node)) { 5851 decu.removeChild(node); 5852 } else { 5853 if (!accu.lastChild || accu.lastChild.nodeName !== "P") { 5854 accu.appendChild(accuDoc.createElement("P")); 5855 } 5856 accu.lastChild.appendChild(node); 5857 } 5858 } else if (node.nodeType === node.ELEMENT_NODE) { 5859 if (node.nodeName === "BR") { 5860 if (node.nextSibling && node.nextSibling.nodeName === "BR") { 5861 accu.appendChild(accuDoc.createElement("P")); 5862 decu.removeChild(node.nextSibling); 5863 } 5864 if (accu.lastChild && accu.lastChild.nodeName === "P" && accu.lastChild.hasChildNodes()) { 5865 accu.lastChild.appendChild(node); 5866 } else { 5867 decu.removeChild(node); 5868 } 5869 } else if (node.nodeName === "P") { 5870 if ((0, import_dom2.isEmpty)(node) && !options.raw) { 5871 decu.removeChild(node); 5872 } else { 5873 accu.appendChild(node); 5874 } 5875 } else if ((0, import_dom2.isPhrasingContent)(node)) { 5876 if (!accu.lastChild || accu.lastChild.nodeName !== "P") { 5877 accu.appendChild(accuDoc.createElement("P")); 5878 } 5879 accu.lastChild.appendChild(node); 5880 } else { 5881 accu.appendChild(node); 5882 } 5883 } else { 5884 decu.removeChild(node); 5885 } 5886 } 5887 return accu.innerHTML; 5888 } 5889 5890 // packages/blocks/build-module/api/raw-handling/special-comment-converter.mjs 5891 var import_dom3 = __toESM(require_dom(), 1); 5892 function specialCommentConverter(node, doc) { 5893 if (node.nodeType !== node.COMMENT_NODE) { 5894 return; 5895 } 5896 if (node.nodeValue !== "nextpage" && node.nodeValue.indexOf("more") !== 0) { 5897 return; 5898 } 5899 const block = createBlock2(node, doc); 5900 if (!node.parentNode || node.parentNode.nodeName !== "P") { 5901 (0, import_dom3.replace)(node, block); 5902 } else { 5903 const childNodes = Array.from(node.parentNode.childNodes); 5904 const nodeIndex = childNodes.indexOf(node); 5905 const wrapperNode = node.parentNode.parentNode || doc.body; 5906 const paragraphBuilder = (acc, child) => { 5907 if (!acc) { 5908 acc = doc.createElement("p"); 5909 } 5910 acc.appendChild(child); 5911 return acc; 5912 }; 5913 [ 5914 childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), 5915 block, 5916 childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null) 5917 ].forEach( 5918 (element) => element && wrapperNode.insertBefore(element, node.parentNode) 5919 ); 5920 (0, import_dom3.remove)(node.parentNode); 5921 } 5922 } 5923 function createBlock2(commentNode, doc) { 5924 if (commentNode.nodeValue === "nextpage") { 5925 return createNextpage(doc); 5926 } 5927 const customText = commentNode.nodeValue.slice(4).trim(); 5928 let sibling = commentNode; 5929 let noTeaser = false; 5930 while (sibling = sibling.nextSibling) { 5931 if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === "noteaser") { 5932 noTeaser = true; 5933 (0, import_dom3.remove)(sibling); 5934 break; 5935 } 5936 } 5937 return createMore(customText, noTeaser, doc); 5938 } 5939 function createMore(customText, noTeaser, doc) { 5940 const node = doc.createElement("wp-block"); 5941 node.dataset.block = "core/more"; 5942 if (customText) { 5943 node.dataset.customText = customText; 5944 } 5945 if (noTeaser) { 5946 node.dataset.noTeaser = ""; 5947 } 5948 return node; 5949 } 5950 function createNextpage(doc) { 5951 const node = doc.createElement("wp-block"); 5952 node.dataset.block = "core/nextpage"; 5953 return node; 5954 } 5955 5956 // packages/blocks/build-module/api/raw-handling/list-reducer.mjs 5957 var import_dom4 = __toESM(require_dom(), 1); 5958 function isList(node) { 5959 return node.nodeName === "OL" || node.nodeName === "UL"; 5960 } 5961 function shallowTextContent(element) { 5962 return Array.from(element.childNodes).map(({ nodeValue = "" }) => nodeValue).join(""); 5963 } 5964 function listReducer(node) { 5965 if (!isList(node)) { 5966 return; 5967 } 5968 const list = node; 5969 const prevElement = list.previousElementSibling; 5970 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { 5971 while (list.firstChild) { 5972 prevElement.appendChild(list.firstChild); 5973 } 5974 list.parentNode.removeChild(list); 5975 } 5976 const parentElement = node.parentNode; 5977 if (parentElement && parentElement.nodeName === "LI" && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { 5978 const parentListItem = parentElement; 5979 const prevListItem = parentListItem.previousElementSibling; 5980 const parentList = parentListItem.parentNode; 5981 if (prevListItem) { 5982 prevListItem.appendChild(list); 5983 parentList.removeChild(parentListItem); 5984 } 5985 } 5986 if (parentElement && isList(parentElement)) { 5987 const prevListItem = list.previousElementSibling; 5988 if (prevListItem) { 5989 prevListItem.appendChild(node); 5990 } else { 5991 (0, import_dom4.unwrap)(node); 5992 } 5993 } 5994 } 5995 5996 // packages/blocks/build-module/api/raw-handling/blockquote-normaliser.mjs 5997 function blockquoteNormaliser(options = {}) { 5998 return (bq) => { 5999 if (bq.nodeName !== "BLOCKQUOTE") { 6000 return; 6001 } 6002 const node = bq; 6003 node.innerHTML = normaliseBlocks(node.innerHTML, options); 6004 }; 6005 } 6006 6007 // packages/blocks/build-module/api/raw-handling/figure-content-reducer.mjs 6008 var import_dom5 = __toESM(require_dom(), 1); 6009 function isFigureContent(node, schema) { 6010 const tag = node.nodeName.toLowerCase(); 6011 if (tag === "figcaption" || (0, import_dom5.isTextContent)(node)) { 6012 return false; 6013 } 6014 return tag in (schema?.figure?.children ?? {}); 6015 } 6016 function canHaveAnchor(node, schema) { 6017 const tag = node.nodeName.toLowerCase(); 6018 return tag in (schema?.figure?.children?.a?.children ?? {}); 6019 } 6020 function wrapFigureContent(element, beforeElement = element) { 6021 const figure = element.ownerDocument.createElement("figure"); 6022 beforeElement.parentNode.insertBefore(figure, beforeElement); 6023 figure.appendChild(element); 6024 } 6025 function figureContentReducer(node, doc, schema) { 6026 if (!schema || !isFigureContent(node, schema)) { 6027 return; 6028 } 6029 let nodeToInsert = node; 6030 const parentNode = node.parentNode; 6031 if (canHaveAnchor(node, schema) && parentNode.nodeName === "A" && parentNode.childNodes.length === 1) { 6032 nodeToInsert = node.parentNode; 6033 } 6034 const wrapper = nodeToInsert.closest("p,div"); 6035 if (wrapper) { 6036 const element = node; 6037 if (!element.classList) { 6038 wrapFigureContent(nodeToInsert, wrapper); 6039 } else if (element.classList.contains("alignright") || element.classList.contains("alignleft") || element.classList.contains("aligncenter") || !wrapper.textContent.trim()) { 6040 wrapFigureContent(nodeToInsert, wrapper); 6041 } 6042 } else { 6043 wrapFigureContent(nodeToInsert); 6044 } 6045 } 6046 6047 // packages/blocks/build-module/api/raw-handling/shortcode-converter.mjs 6048 var import_shortcode = __toESM(require_shortcode(), 1); 6049 var castArray = (maybeArray) => Array.isArray(maybeArray) ? maybeArray : [maybeArray]; 6050 var beforeLineRegexp = /(\n|<p>|<br\s*\/?>)\s*$/; 6051 var afterLineRegexp = /^\s*(\n|<\/p>|<br\s*\/?>)/; 6052 function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) { 6053 const transformsFrom = getBlockTransforms("from").filter( 6054 (transform) => transform.type === "shortcode" 6055 ); 6056 const transformation = findTransform( 6057 transformsFrom, 6058 (transform) => excludedBlockNames.indexOf(transform.blockName) === -1 && castArray(transform.tag).some( 6059 (tag) => (0, import_shortcode.regexp)(tag).test(HTML) 6060 ) 6061 ); 6062 if (!transformation) { 6063 return [HTML]; 6064 } 6065 const transformTags = castArray(transformation.tag); 6066 const transformTag = transformTags.find( 6067 (tag) => (0, import_shortcode.regexp)(tag).test(HTML) 6068 ); 6069 const previousIndex = lastIndex; 6070 const match = (0, import_shortcode.next)(transformTag, HTML, lastIndex); 6071 if (!match) { 6072 return [HTML]; 6073 } 6074 lastIndex = match.index + match.content.length; 6075 const beforeHTML = HTML.substr(0, match.index); 6076 const afterHTML = HTML.substr(lastIndex); 6077 if (!match.shortcode.content?.includes("<") && !(beforeLineRegexp.test(beforeHTML) && afterLineRegexp.test(afterHTML))) { 6078 return segmentHTMLToShortcodeBlock(HTML, lastIndex); 6079 } 6080 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { 6081 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [ 6082 ...excludedBlockNames, 6083 transformation.blockName 6084 ]); 6085 } 6086 let blocks = []; 6087 if (typeof transformation.transform === "function") { 6088 blocks = [].concat( 6089 transformation.transform(match.shortcode.attrs, match) 6090 ); 6091 blocks = blocks.map((block) => { 6092 block.originalContent = match.shortcode.content; 6093 return applyBuiltInValidationFixes( 6094 block, 6095 getBlockType(block.name) 6096 ); 6097 }); 6098 } else { 6099 const blockType = getBlockType(transformation.blockName); 6100 if (!blockType) { 6101 return [HTML]; 6102 } 6103 const transformAttributes = transformation.attributes ?? blockType.attributes; 6104 const attributes = Object.fromEntries( 6105 Object.entries(transformAttributes).filter(([, schema]) => schema.shortcode).map(([key, schema]) => [ 6106 key, 6107 schema.shortcode(match.shortcode.attrs, match) 6108 ]) 6109 ); 6110 const transformationBlockType = { 6111 ...blockType, 6112 attributes: transformAttributes 6113 }; 6114 let block = createBlock( 6115 transformation.blockName, 6116 getBlockAttributes( 6117 transformationBlockType, 6118 match.shortcode.content, 6119 attributes 6120 ) 6121 ); 6122 block.originalContent = match.shortcode.content; 6123 block = applyBuiltInValidationFixes(block, transformationBlockType); 6124 blocks = [block]; 6125 } 6126 return [ 6127 ...segmentHTMLToShortcodeBlock( 6128 beforeHTML.replace(beforeLineRegexp, "") 6129 ), 6130 ...blocks, 6131 ...segmentHTMLToShortcodeBlock( 6132 afterHTML.replace(afterLineRegexp, "") 6133 ) 6134 ]; 6135 } 6136 var shortcode_converter_default = segmentHTMLToShortcodeBlock; 6137 6138 // packages/blocks/build-module/api/raw-handling/utils.mjs 6139 var import_dom6 = __toESM(require_dom(), 1); 6140 function getBlockContentSchemaFromTransforms(transforms, context) { 6141 const phrasingContentSchema = (0, import_dom6.getPhrasingContentSchema)(context); 6142 const schemaArgs = { phrasingContentSchema, isPaste: context === "paste" }; 6143 const schemas = transforms.map(({ isMatch, blockName, schema }) => { 6144 const hasAnchorSupport = hasBlockSupport(blockName, "anchor"); 6145 schema = typeof schema === "function" ? schema(schemaArgs) : schema; 6146 if (!hasAnchorSupport && !isMatch) { 6147 return schema; 6148 } 6149 if (!schema) { 6150 return {}; 6151 } 6152 return Object.fromEntries( 6153 Object.entries(schema).map(([key, value]) => { 6154 let attributes = value.attributes || []; 6155 if (hasAnchorSupport) { 6156 attributes = [...attributes, "id"]; 6157 } 6158 return [ 6159 key, 6160 { 6161 ...value, 6162 attributes, 6163 isMatch: isMatch ? isMatch : void 0 6164 } 6165 ]; 6166 }) 6167 ); 6168 }); 6169 function mergeTagNameSchemaProperties(objValue, srcValue, key) { 6170 switch (key) { 6171 case "children": { 6172 if (objValue === "*" || srcValue === "*") { 6173 return "*"; 6174 } 6175 return mergeSchemas( 6176 { ...objValue || {} }, 6177 srcValue || {} 6178 ); 6179 } 6180 case "attributes": 6181 case "require": { 6182 return Array.from( 6183 /* @__PURE__ */ new Set([...objValue || [], ...srcValue || []]) 6184 ); 6185 } 6186 case "isMatch": { 6187 if (!objValue || !srcValue) { 6188 return void 0; 6189 } 6190 return (...args) => { 6191 return objValue(...args) || srcValue(...args); 6192 }; 6193 } 6194 case "classes": { 6195 if ((objValue || []).includes("*") || (srcValue || []).includes("*")) { 6196 return ["*"]; 6197 } 6198 return [...objValue || [], ...srcValue || []]; 6199 } 6200 } 6201 } 6202 function mergeTagNameSchemas(a, b2) { 6203 if (a === b2) { 6204 return a; 6205 } 6206 for (const key in b2) { 6207 if (a[key]) { 6208 a[key] = mergeTagNameSchemaProperties( 6209 a[key], 6210 b2[key], 6211 key 6212 ); 6213 } else if (Array.isArray(b2[key])) { 6214 a[key] = b2[key].slice(); 6215 } else { 6216 a[key] = { ...b2[key] }; 6217 } 6218 } 6219 return a; 6220 } 6221 function mergeSchemas(a, b2) { 6222 if (a === b2) { 6223 return a; 6224 } 6225 for (const key in b2) { 6226 if (a[key]) { 6227 a[key] = mergeTagNameSchemas(a[key], b2[key]); 6228 } else if (Array.isArray(b2[key])) { 6229 a[key] = b2[key].slice(); 6230 } else { 6231 a[key] = { ...b2[key] }; 6232 } 6233 } 6234 return a; 6235 } 6236 return schemas.reduce(mergeSchemas, {}); 6237 } 6238 function getBlockContentSchema(context) { 6239 return getBlockContentSchemaFromTransforms(getRawTransforms(), context); 6240 } 6241 function isPlain(HTML) { 6242 if (!/<(?!br[ />])/i.test(HTML)) { 6243 return true; 6244 } 6245 const doc = document.implementation.createHTMLDocument(""); 6246 doc.body.innerHTML = HTML; 6247 if (doc.body.children.length !== 1) { 6248 return false; 6249 } 6250 const wrapper = doc.body.children.item(0); 6251 const descendants = wrapper.getElementsByTagName("*"); 6252 for (let i = 0; i < descendants.length; i++) { 6253 if (descendants.item(i).tagName !== "BR") { 6254 return false; 6255 } 6256 } 6257 if (wrapper.tagName !== "SPAN") { 6258 return false; 6259 } 6260 return true; 6261 } 6262 function deepFilterNodeList(nodeList, filters, doc, schema) { 6263 Array.from(nodeList).forEach((node) => { 6264 deepFilterNodeList(node.childNodes, filters, doc, schema); 6265 filters.forEach((item) => { 6266 if (!doc.contains(node)) { 6267 return; 6268 } 6269 item(node, doc, schema); 6270 }); 6271 }); 6272 } 6273 function deepFilterHTML(HTML, filters = [], schema) { 6274 const doc = document.implementation.createHTMLDocument(""); 6275 doc.body.innerHTML = HTML; 6276 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); 6277 return doc.body.innerHTML; 6278 } 6279 function getSibling(node, which) { 6280 const sibling = node[`$which}Sibling`]; 6281 if (sibling && (0, import_dom6.isPhrasingContent)(sibling)) { 6282 return sibling; 6283 } 6284 const { parentNode } = node; 6285 if (!parentNode || !(0, import_dom6.isPhrasingContent)(parentNode)) { 6286 return; 6287 } 6288 return getSibling(parentNode, which); 6289 } 6290 6291 // packages/blocks/build-module/api/raw-handling/paste-handler.mjs 6292 var import_dom12 = __toESM(require_dom(), 1); 6293 6294 // packages/blocks/build-module/api/raw-handling/comment-remover.mjs 6295 var import_dom7 = __toESM(require_dom(), 1); 6296 function commentRemover(node) { 6297 if (node.nodeType === node.COMMENT_NODE) { 6298 (0, import_dom7.remove)(node); 6299 } 6300 } 6301 6302 // packages/blocks/build-module/api/raw-handling/is-inline-content.mjs 6303 var import_dom8 = __toESM(require_dom(), 1); 6304 function isInline(node, contextTag) { 6305 if ((0, import_dom8.isTextContent)(node)) { 6306 return true; 6307 } 6308 if (!contextTag) { 6309 return false; 6310 } 6311 const tag = node.nodeName.toLowerCase(); 6312 const inlineAllowedTagGroups = [ 6313 ["ul", "li", "ol"], 6314 ["h1", "h2", "h3", "h4", "h5", "h6"] 6315 ]; 6316 return inlineAllowedTagGroups.some( 6317 (tagGroup) => [tag, contextTag].filter((t2) => !tagGroup.includes(t2)).length === 0 6318 ); 6319 } 6320 function deepCheck(nodes, contextTag) { 6321 return nodes.every( 6322 (node) => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag) 6323 ); 6324 } 6325 function isDoubleBR(node) { 6326 return node.nodeName === "BR" && !!node.previousSibling && node.previousSibling.nodeName === "BR"; 6327 } 6328 function isInlineContent(HTML, contextTag) { 6329 const doc = document.implementation.createHTMLDocument(""); 6330 doc.body.innerHTML = HTML; 6331 const nodes = Array.from(doc.body.children); 6332 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); 6333 } 6334 6335 // packages/blocks/build-module/api/raw-handling/phrasing-content-reducer.mjs 6336 var import_dom9 = __toESM(require_dom(), 1); 6337 function phrasingContentReducer(node, doc) { 6338 if (node.nodeName === "SPAN" && node.style) { 6339 const { 6340 fontWeight, 6341 fontStyle, 6342 textDecorationLine, 6343 textDecoration, 6344 verticalAlign 6345 } = node.style; 6346 const element = node; 6347 if (fontWeight === "bold" || fontWeight === "700") { 6348 (0, import_dom9.wrap)(doc.createElement("strong"), element); 6349 } 6350 if (fontStyle === "italic") { 6351 (0, import_dom9.wrap)(doc.createElement("em"), element); 6352 } 6353 if (textDecorationLine === "line-through" || textDecoration.includes("line-through")) { 6354 (0, import_dom9.wrap)(doc.createElement("s"), element); 6355 } 6356 if (verticalAlign === "super") { 6357 (0, import_dom9.wrap)(doc.createElement("sup"), element); 6358 } else if (verticalAlign === "sub") { 6359 (0, import_dom9.wrap)(doc.createElement("sub"), element); 6360 } 6361 } else if (node.nodeName === "B") { 6362 (0, import_dom9.replaceTag)(node, "strong"); 6363 } else if (node.nodeName === "I") { 6364 (0, import_dom9.replaceTag)(node, "em"); 6365 } else if (node.nodeName === "A") { 6366 const anchor = node; 6367 if (anchor.target && anchor.target.toLowerCase() === "_blank") { 6368 anchor.rel = "noopener"; 6369 } else { 6370 anchor.removeAttribute("target"); 6371 anchor.removeAttribute("rel"); 6372 } 6373 if (anchor.name && !anchor.id) { 6374 anchor.id = anchor.name; 6375 } 6376 if (anchor.id && !anchor.ownerDocument.querySelector(`[href="#$anchor.id}"]`)) { 6377 anchor.removeAttribute("id"); 6378 } 6379 } 6380 } 6381 6382 // packages/blocks/build-module/api/raw-handling/head-remover.mjs 6383 function headRemover(node) { 6384 if (node.nodeName !== "SCRIPT" && node.nodeName !== "NOSCRIPT" && node.nodeName !== "TEMPLATE" && node.nodeName !== "STYLE") { 6385 return; 6386 } 6387 node.parentNode.removeChild(node); 6388 } 6389 6390 // packages/blocks/build-module/api/raw-handling/ms-list-ignore.mjs 6391 function msListIgnore(node) { 6392 if (node.nodeType !== node.ELEMENT_NODE) { 6393 return; 6394 } 6395 const el = node; 6396 const style = el.getAttribute("style"); 6397 if (!style || !style.includes("mso-list")) { 6398 return; 6399 } 6400 const rules = style.split(";").reduce( 6401 (acc, rule) => { 6402 const [key, value] = rule.split(":"); 6403 if (key && value) { 6404 acc[key.trim().toLowerCase()] = value.trim().toLowerCase(); 6405 } 6406 return acc; 6407 }, 6408 {} 6409 ); 6410 if (rules["mso-list"] === "ignore") { 6411 el.remove(); 6412 } 6413 } 6414 6415 // packages/blocks/build-module/api/raw-handling/ms-list-converter.mjs 6416 function isList2(node) { 6417 return node.nodeName === "OL" || node.nodeName === "UL"; 6418 } 6419 function msListConverter(node, doc) { 6420 if (node.nodeName !== "P") { 6421 return; 6422 } 6423 const element = node; 6424 const style = element.getAttribute("style"); 6425 if (!style || !style.includes("mso-list")) { 6426 return; 6427 } 6428 const prevNode = element.previousElementSibling; 6429 if (!prevNode || !isList2(prevNode)) { 6430 const type = element.textContent.trim().slice(0, 1); 6431 const isNumeric = /[1iIaA]/.test(type); 6432 const newListNode = doc.createElement(isNumeric ? "ol" : "ul"); 6433 if (isNumeric) { 6434 newListNode.setAttribute("type", type); 6435 } 6436 element.parentNode.insertBefore(newListNode, element); 6437 } 6438 const listNode = element.previousElementSibling; 6439 const listType = listNode.nodeName; 6440 const listItem = doc.createElement("li"); 6441 let receivingNode = listNode; 6442 listItem.innerHTML = deepFilterHTML(element.innerHTML, [msListIgnore]); 6443 const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); 6444 let level = matches ? parseInt(matches[1], 10) - 1 || 0 : 0; 6445 while (level--) { 6446 receivingNode = receivingNode.lastChild || receivingNode; 6447 if (isList2(receivingNode)) { 6448 receivingNode = receivingNode.lastChild || receivingNode; 6449 } 6450 } 6451 if (!isList2(receivingNode)) { 6452 receivingNode = receivingNode.appendChild( 6453 doc.createElement(listType) 6454 ); 6455 } 6456 receivingNode.appendChild(listItem); 6457 element.parentNode.removeChild(element); 6458 } 6459 6460 // packages/blocks/build-module/api/raw-handling/image-corrector.mjs 6461 var import_blob = __toESM(require_blob(), 1); 6462 function imageCorrector(img) { 6463 if (img.nodeName !== "IMG") { 6464 return; 6465 } 6466 const node = img; 6467 if (node.src.indexOf("file:") === 0) { 6468 node.src = ""; 6469 } 6470 if (node.src.indexOf("data:") === 0) { 6471 const [properties, data] = node.src.split(","); 6472 const [type] = properties.slice(5).split(";"); 6473 if (!data || !type) { 6474 node.src = ""; 6475 return; 6476 } 6477 let decoded; 6478 try { 6479 decoded = atob(data); 6480 } catch { 6481 node.src = ""; 6482 return; 6483 } 6484 const uint8Array = new Uint8Array(decoded.length); 6485 for (let i = 0; i < uint8Array.length; i++) { 6486 uint8Array[i] = decoded.charCodeAt(i); 6487 } 6488 const subtype = type.slice(type.indexOf("/") + 1); 6489 const name = `image-$v4_default().slice(0, 8)}.$subtype}`; 6490 const file = new window.File([uint8Array], name, { type }); 6491 node.src = (0, import_blob.createBlobURL)(file); 6492 } 6493 if (node.height === 1 || node.width === 1) { 6494 node.parentNode.removeChild(node); 6495 } 6496 } 6497 6498 // packages/blocks/build-module/api/raw-handling/div-normaliser.mjs 6499 function divNormaliser(div) { 6500 if (div.nodeName !== "DIV") { 6501 return; 6502 } 6503 const node = div; 6504 node.innerHTML = normaliseBlocks(node.innerHTML); 6505 } 6506 6507 // node_modules/.store/marked@18.0.13-B-tDZfJAz9zUYDQYWjYtzA/node_modules/marked/lib/marked.esm.js 6508 function A2() { 6509 return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null }; 6510 } 6511 var T = A2(); 6512 function U(l4) { 6513 T = l4; 6514 } 6515 var E2 = { exec: () => null }; 6516 function I(l4) { 6517 let e2 = []; 6518 return (t2) => { 6519 let n = Math.max(0, Math.min(3, t2 - 1)), i = e2[n]; 6520 return i || (i = l4(n), e2[n] = i), i; 6521 }; 6522 } 6523 function d(l4, e2 = "") { 6524 let t2 = typeof l4 == "string" ? l4 : l4.source, n = { replace: (i, r2) => { 6525 let o2 = typeof r2 == "string" ? r2 : r2.source; 6526 return o2 = o2.replace(m2.caret, "$1"), t2 = t2.replace(i, o2), n; 6527 }, getRegex: () => new RegExp(t2, e2) }; 6528 return n; 6529 } 6530 var we = ((l4 = "") => { 6531 try { 6532 return !!new RegExp("(?<=1)(?<!1)" + l4); 6533 } catch { 6534 return false; 6535 } 6536 })(); 6537 var m2 = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l4) => new RegExp(`^( {0,3}${l4})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((l4) => new RegExp(`^ {0,${l4}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((l4) => new RegExp(`^ {0,${l4}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}#`)), htmlBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}(?:</?(?:${H2})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`, "i")), blockquoteBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}>`)) }; 6538 var ye = /^(?:[ \t]*(?:\n|$))+/; 6539 var Pe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/; 6540 var Se = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; 6541 var v2 = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; 6542 var _e = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; 6543 var K = / {0,3}(?:[*+-]|\d{1,9}[.)])/; 6544 var le = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/; 6545 var ue = d(le).replace(/bull/g, K).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(); 6546 var $e = d(le).replace(/bull/g, K).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(); 6547 var W = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/; 6548 var Le = /^[^\n]+/; 6549 var X = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/; 6550 var ze = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", X).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(); 6551 var Ee = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, K).getRegex(); 6552 var H2 = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul"; 6553 var J = /<!--(?:-?>|[\s\S]*?(?:-->|$))/; 6554 var Me = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", J).replace("tag", H2).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(); 6555 var pe = (l4) => d(W).replace("hr", v2).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l4).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H2).getRegex(); 6556 var Ae = pe(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/); 6557 var Ie = pe(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/); 6558 var Ce = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ie).getRegex(); 6559 var V = { blockquote: Ce, code: Pe, def: ze, fences: Se, heading: _e, hr: v2, html: Me, lheading: ue, list: Ee, newline: ye, paragraph: Ae, table: E2, text: Le }; 6560 var ie = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", v2).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H2).getRegex(); 6561 var Be = { ...V, lheading: $e, table: ie, paragraph: d(W).replace("hr", v2).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ie).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H2).getRegex() }; 6562 var De = { ...V, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", J).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: E2, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(W).replace("hr", v2).replace("heading", ` *#{1,6} *[^ 6563 ]`).replace("lheading", ue).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }; 6564 var qe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/; 6565 var ve = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/; 6566 var ce = /^( {2,}|\\)\n(?!\s*$)[ \t]*/; 6567 var He = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/; 6568 var _ = /[\p{P}\p{S}]/u; 6569 var C2 = /[\s\p{P}\p{S}]/u; 6570 var Z = /[^\s\p{P}\p{S}]/u; 6571 var Ze = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, C2).getRegex(); 6572 var Ge = /[\p{Pi}\p{Ps}"']/u; 6573 var he = /(?!~)[\p{P}\p{S}]/u; 6574 var Qe = /(?!~)[\s\p{P}\p{S}]/u; 6575 var Ne = /(?:[^\s\p{P}\p{S}]|~)/u; 6576 var je = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", we ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(); 6577 var de = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/; 6578 var Ue = d(de, "u").replace(/punct/g, _).getRegex(); 6579 var Fe = d(de, "u").replace(/punct/g, he).getRegex(); 6580 var Ke = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/; 6581 var We = d(Ke, "u").replace(/openQuote/g, Ge).replace(/punct/g, _).getRegex(); 6582 var ke = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)"; 6583 var Xe = d(ke, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6584 var Je = d(ke, "gu").replace(/notPunctSpace/g, Ne).replace(/punctSpace/g, Qe).replace(/punct/g, he).getRegex(); 6585 var Ve = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)"; 6586 var Ye = d(Ve, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6587 var et = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6588 var tt = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)"; 6589 var nt = d(tt, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6590 var rt = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex(); 6591 var st = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)"; 6592 var it = d(st, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6593 var ot = d(/\\(punct)/, "gu").replace(/punct/g, _).getRegex(); 6594 var at = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(); 6595 var lt = d(J).replace("(?:-->|$)", "-->").getRegex(); 6596 var ut = d("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", lt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(); 6597 var ge = /\[(?:\\[\s\S]|[^\[\]\\])*\]/; 6598 var N2 = d(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", ge).getRegex(); 6599 var pt = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", N2).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(); 6600 var ct = d(/^!?\[(label)\]\[(ref)\]/).replace("label", N2).replace("ref", X).getRegex(); 6601 var ht = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", X).getRegex(); 6602 var oe = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/; 6603 var dt = d(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", ge).getRegex(); 6604 var kt = d("reflink|nolink(?!\\()", "g").replace("reflink", d(/^!?\[(label)\]\[(ref)\]/).replace("label", dt).replace("ref", oe).getRegex()).replace("nolink", d(/^!?\[(ref)\](?:\[\])?/).replace("ref", oe).getRegex()).getRegex(); 6605 var ae = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/; 6606 var Y = { _backpedal: E2, anyPunctuation: ot, autolink: at, blockSkip: je, br: ce, code: ve, del: E2, delLDelim: E2, delRDelim: E2, emStrongLDelim: Ue, emStrongRDelimAst: Xe, emStrongRDelimUnd: et, escape: qe, link: pt, nolink: ht, punctuation: Ze, reflink: ct, reflinkSearch: kt, tag: ut, text: He, url: E2 }; 6607 var gt = { ...Y, emStrongLDelim: We, emStrongRDelimAst: Ye, emStrongRDelimUnd: nt, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", N2).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", N2).getRegex() }; 6608 var F = { ...Y, emStrongRDelimAst: Je, emStrongLDelim: Fe, delLDelim: rt, delRDelim: it, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ae).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ae).getRegex() }; 6609 var ft = { ...F, br: d(ce).replace("{2,}", "*").getRegex(), text: d(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }; 6610 var G = { normal: V, gfm: Be, pedantic: De }; 6611 var B = { normal: Y, gfm: F, breaks: ft, pedantic: gt }; 6612 var mt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }; 6613 var fe = (l4) => mt[l4]; 6614 function R2(l4, e2) { 6615 if (e2) { 6616 if (m2.escapeTest.test(l4)) return l4.replace(m2.escapeReplace, fe); 6617 } else if (m2.escapeTestNoEncode.test(l4)) return l4.replace(m2.escapeReplaceNoEncode, fe); 6618 return l4; 6619 } 6620 function ee(l4) { 6621 try { 6622 l4 = encodeURI(l4).replace(m2.percentDecode, "%"); 6623 } catch { 6624 return null; 6625 } 6626 return l4; 6627 } 6628 function te(l4, e2) { 6629 let t2 = l4.replace(m2.findPipe, (r2, o2, s) => { 6630 let u = false, a = o2; 6631 for (; --a >= 0 && s[a] === "\\"; ) u = !u; 6632 return u ? "|" : " |"; 6633 }), n = t2.split(m2.splitPipe), i = 0; 6634 if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e2) if (n.length > e2) n.splice(e2); 6635 else for (; n.length < e2; ) n.push(""); 6636 for (; i < n.length; i++) n[i] = n[i].trim().replace(m2.slashPipe, "|"); 6637 return n; 6638 } 6639 function $2(l4, e2, t2) { 6640 let n = l4.length; 6641 if (n === 0) return ""; 6642 let i = 0; 6643 for (; i < n; ) { 6644 let r2 = l4.charAt(n - i - 1); 6645 if (r2 === e2 && !t2) i++; 6646 else if (r2 !== e2 && t2) i++; 6647 else break; 6648 } 6649 return l4.slice(0, n - i); 6650 } 6651 function ne(l4) { 6652 let e2 = l4.split(` 6653 `), t2 = e2.length - 1; 6654 for (; t2 >= 0 && m2.blankLine.test(e2[t2]); ) t2--; 6655 return e2.length - t2 <= 2 ? l4 : e2.slice(0, t2 + 1).join(` 6656 `); 6657 } 6658 function D2(l4) { 6659 return l4.toLowerCase().toUpperCase().toLowerCase(); 6660 } 6661 function me(l4, e2) { 6662 if (l4.indexOf(e2[1]) === -1) return -1; 6663 let t2 = 0; 6664 for (let n = 0; n < l4.length; n++) if (l4[n] === "\\") n++; 6665 else if (l4[n] === e2[0]) t2++; 6666 else if (l4[n] === e2[1] && (t2--, t2 < 0)) return n; 6667 return t2 > 0 ? -2 : -1; 6668 } 6669 function xe(l4, e2 = 0) { 6670 let t2 = e2, n = ""; 6671 for (let i of l4) if (i === " ") { 6672 let r2 = 4 - t2 % 4; 6673 n += " ".repeat(r2), t2 += r2; 6674 } else n += i, t2++; 6675 return n; 6676 } 6677 function be(l4, e2, t2, n, i) { 6678 let r2 = e2.href, o2 = e2.title || null, s = l4[1].replace(i.other.outputLinkReplace, "$1"), u = l4[0].charAt(0) === "!"; 6679 n.state.inLink = true; 6680 let a = n.state.linkEmitted, p2 = n.state.inRawBlock; 6681 n.state.linkEmitted = false; 6682 let c2 = n.inlineTokens(s), h = n.state.linkEmitted; 6683 if (n.state.linkEmitted = a, n.state.inLink = false, !u) { 6684 if (h) { 6685 n.state.inRawBlock = p2; 6686 return; 6687 } 6688 n.state.linkEmitted = true; 6689 } 6690 return { type: u ? "image" : "link", raw: t2, href: r2, title: o2, text: s, tokens: c2 }; 6691 } 6692 function xt(l4, e2, t2) { 6693 let n = l4.match(t2.other.indentCodeCompensation); 6694 if (n === null) return e2; 6695 let i = n[1]; 6696 return e2.split(` 6697 `).map((r2) => { 6698 let o2 = r2.match(t2.other.beginningSpace); 6699 if (o2 === null) return r2; 6700 let [s] = o2; 6701 return r2.slice(Math.min(s.length, i.length)); 6702 }).join(` 6703 `); 6704 } 6705 function Re(l4, e2, t2, n) { 6706 if (!e2.includes("<")) return false; 6707 for (let i = 0; i < e2.length; i++) { 6708 if (e2[i] === "\\") { 6709 i++; 6710 continue; 6711 } 6712 if (e2[i] === "`") { 6713 let s = n.inline.code.exec(e2.slice(i)); 6714 if (s) { 6715 i += s[0].length - 1; 6716 continue; 6717 } 6718 } 6719 if (e2[i] !== "<") continue; 6720 let r2 = l4.slice(t2 + i), o2 = n.inline.tag.exec(r2) || n.inline.autolink.exec(r2); 6721 if (o2) { 6722 if (o2[0].length > e2.length - i) return true; 6723 i += o2[0].length - 1; 6724 } 6725 } 6726 return false; 6727 } 6728 var y2 = class { 6729 options; 6730 rules; 6731 lexer; 6732 constructor(e2) { 6733 this.options = e2 || T; 6734 } 6735 space(e2) { 6736 let t2 = this.rules.block.newline.exec(e2); 6737 if (t2 && t2[0].length > 0) return { type: "space", raw: t2[0] }; 6738 } 6739 code(e2) { 6740 let t2 = this.rules.block.code.exec(e2); 6741 if (t2) { 6742 let n = this.options.pedantic ? t2[0] : ne(t2[0]), i = n.replace(this.rules.other.codeRemoveIndent, ""); 6743 return { type: "code", raw: n, codeBlockStyle: "indented", text: i }; 6744 } 6745 } 6746 fences(e2) { 6747 let t2 = this.rules.block.fences.exec(e2); 6748 if (t2) { 6749 let n = t2[0], i = xt(n, t2[3] || "", this.rules); 6750 return { type: "code", raw: n, lang: t2[2] ? t2[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t2[2], text: i }; 6751 } 6752 } 6753 heading(e2) { 6754 let t2 = this.rules.block.heading.exec(e2); 6755 if (t2) { 6756 let n = t2[2].trim(); 6757 if (this.rules.other.endingHash.test(n)) { 6758 let i = $2(n, "#"); 6759 (this.options.pedantic || !i || this.rules.other.endingSpaceTabChar.test(i)) && (n = i.trim()); 6760 } 6761 return { type: "heading", raw: $2(t2[0], ` 6762 `), depth: t2[1].length, text: n, tokens: this.lexer.inline(n) }; 6763 } 6764 } 6765 hr(e2) { 6766 let t2 = this.rules.block.hr.exec(e2); 6767 if (t2) return { type: "hr", raw: $2(t2[0], ` 6768 `) }; 6769 } 6770 blockquote(e2) { 6771 let t2 = this.rules.block.blockquote.exec(e2); 6772 if (t2) { 6773 let n = $2(t2[0], ` 6774 `).split(` 6775 `), i = "", r2 = "", o2 = []; 6776 for (; n.length > 0; ) { 6777 let s = false, u = [], a; 6778 for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), s = true; 6779 else if (!s) u.push(n[a]); 6780 else break; 6781 n = n.slice(a); 6782 let p2 = u.join(` 6783 `), c2 = p2.replace(this.rules.other.blockquoteSetextReplace, ` 6784 $1`).replace(this.rules.other.blockquoteSetextReplace2, ""); 6785 i = i ? `$i} 6786 $p2}` : p2, r2 = r2 ? `$r2} 6787 $c2}` : c2; 6788 let h = this.lexer.state.top; 6789 if (this.lexer.state.top = true, this.lexer.blockTokens(c2, o2, true), this.lexer.state.top = h, n.length === 0) break; 6790 let k2 = o2.at(-1); 6791 if (k2?.type === "code") break; 6792 if (k2?.type === "blockquote") { 6793 let O = k2, g2 = n.join(` 6794 `), w2 = O.raw + ` 6795 ` + g2.replace(this.rules.other.blockquoteSetextReplace2, ""), z = this.blockquote(w2); 6796 o2[o2.length - 1] = z, i = `$i} 6797 $g2}`, r2 = r2.substring(0, r2.length - O.text.length) + z.text; 6798 break; 6799 } else if (k2?.type === "list") { 6800 let O = k2, g2 = O.raw + ` 6801 ` + n.join(` 6802 `), w2 = this.list(g2); 6803 o2[o2.length - 1] = w2, i = i.substring(0, i.length - k2.raw.length) + w2.raw, r2 = r2.substring(0, r2.length - O.raw.length) + w2.raw, n = g2.substring(o2.at(-1).raw.length).split(` 6804 `); 6805 continue; 6806 } 6807 } 6808 return { type: "blockquote", raw: i, tokens: o2, text: r2 }; 6809 } 6810 } 6811 list(e2) { 6812 let t2 = this.rules.block.list.exec(e2); 6813 if (t2) { 6814 let n = t2[1].trim(), i = n.length > 1, r2 = { type: "list", raw: "", ordered: i, start: i ? +n.slice(0, -1) : "", loose: false, items: [] }; 6815 n = i ? `\\d{1,9}\\$n.slice(-1)}` : `\\$n}`, this.options.pedantic && (n = i ? n : "[*+-]"); 6816 let o2 = this.rules.other.listItemRegex(n), s = false; 6817 for (; e2; ) { 6818 let a = false, p2 = "", c2 = ""; 6819 if (!(t2 = o2.exec(e2)) || this.rules.block.hr.test(e2)) break; 6820 p2 = t2[0], e2 = e2.substring(p2.length); 6821 let h = xe(t2[2].split(` 6822 `, 1)[0], t2[1].length), k2 = e2.split(` 6823 `, 1)[0], O = !h.trim(), g2 = 0; 6824 if (this.options.pedantic ? (g2 = 2, c2 = h.trimStart()) : O ? g2 = t2[1].length + 1 : (g2 = h.search(this.rules.other.nonSpaceChar), g2 = g2 > 4 ? 1 : g2, c2 = h.slice(g2), g2 += t2[1].length), O && this.rules.other.blankLine.test(k2) && (p2 += k2 + ` 6825 `, e2 = e2.substring(k2.length + 1), a = true), !a) { 6826 let w2 = this.rules.other.nextBulletRegex(g2), z = this.rules.other.hrRegex(g2), re = this.rules.other.fencesBeginRegex(g2), se = this.rules.other.headingBeginRegex(g2), Te = this.rules.other.htmlBeginRegex(g2), Oe = this.rules.other.blockquoteBeginRegex(g2); 6827 for (; e2; ) { 6828 let j2 = e2.split(` 6829 `, 1)[0], q2; 6830 if (k2 = j2, this.options.pedantic ? (k2 = k2.replace(this.rules.other.listReplaceNesting, " "), q2 = k2) : q2 = k2.replace(this.rules.other.tabCharGlobal, " "), re.test(k2) || se.test(k2) || Te.test(k2) || Oe.test(k2) || w2.test(k2) || z.test(k2)) break; 6831 if (q2.search(this.rules.other.nonSpaceChar) >= g2 || !k2.trim()) c2 += ` 6832 ` + q2.slice(g2); 6833 else { 6834 if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || re.test(h) || se.test(h) || z.test(h)) break; 6835 c2 += ` 6836 ` + k2; 6837 } 6838 O = !k2.trim(), p2 += j2 + ` 6839 `, e2 = e2.substring(j2.length + 1), h = q2.slice(g2); 6840 } 6841 } 6842 r2.loose || (s ? r2.loose = true : this.rules.other.doubleBlankLine.test(p2) && (s = true)), r2.items.push({ type: "list_item", raw: p2, task: !!this.options.gfm && this.rules.other.listIsTask.test(c2), loose: false, text: c2, tokens: [] }), r2.raw += p2; 6843 } 6844 let u = r2.items.at(-1); 6845 if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd(); 6846 else return; 6847 r2.raw = r2.raw.trimEnd(); 6848 for (let a of r2.items) if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r2.loose) { 6849 let p2 = a.tokens.filter((h) => h.type === "space"), c2 = p2.length > 0 && p2.some((h) => this.rules.other.anyLine.test(h.raw)); 6850 r2.loose = c2; 6851 } 6852 for (let a of r2.items) { 6853 let p2 = a.tokens[0]; 6854 if (a.task && (p2?.type === "text" || p2?.type === "paragraph")) { 6855 a.text = a.text.replace(this.rules.other.listReplaceTask, ""), p2.raw = p2.raw.replace(this.rules.other.listReplaceTask, ""), p2.text = p2.text.replace(this.rules.other.listReplaceTask, ""); 6856 for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) { 6857 this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, ""); 6858 break; 6859 } 6860 let c2 = this.rules.other.listTaskCheckbox.exec(a.raw); 6861 if (c2) { 6862 let h = { type: "checkbox", raw: c2[0] + " ", checked: c2[0] !== "[ ]" }; 6863 a.checked = h.checked, r2.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h); 6864 } 6865 } else a.task && (a.task = false); 6866 } 6867 if (r2.loose) for (let a of r2.items) { 6868 a.loose = true; 6869 for (let p2 of a.tokens) p2.type === "text" && (p2.type = "paragraph"); 6870 } 6871 return r2; 6872 } 6873 } 6874 html(e2) { 6875 let t2 = this.rules.block.html.exec(e2); 6876 if (t2) { 6877 let n = ne(t2[0]); 6878 return { type: "html", block: true, raw: n, pre: t2[1] === "pre" || t2[1] === "script" || t2[1] === "style", text: n }; 6879 } 6880 } 6881 def(e2) { 6882 let t2 = this.rules.block.def.exec(e2); 6883 if (t2) { 6884 let n = D2(t2[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t2[2] ? t2[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r2 = t2[3] ? t2[3].substring(1, t2[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t2[3]; 6885 return { type: "def", tag: n, raw: $2(t2[0], ` 6886 `), href: i, title: r2 }; 6887 } 6888 } 6889 table(e2) { 6890 let t2 = this.rules.block.table.exec(e2); 6891 if (!t2 || !this.rules.other.tableDelimiter.test(t2[2])) return; 6892 let n = te(t2[1]), i = t2[2].replace(this.rules.other.tableAlignChars, "").split("|"), r2 = t2[3]?.trim() ? t2[3].replace(this.rules.other.tableRowBlankLine, "").split(` 6893 `) : [], o2 = { type: "table", raw: $2(t2[0], ` 6894 `), header: [], align: [], rows: [] }; 6895 if (n.length === i.length) { 6896 for (let s of i) this.rules.other.tableAlignRight.test(s) ? o2.align.push("right") : this.rules.other.tableAlignCenter.test(s) ? o2.align.push("center") : this.rules.other.tableAlignLeft.test(s) ? o2.align.push("left") : o2.align.push(null); 6897 for (let s = 0; s < n.length; s++) o2.header.push({ text: n[s], tokens: this.lexer.inline(n[s]), header: true, align: o2.align[s] }); 6898 for (let s of r2) o2.rows.push(te(s, o2.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: o2.align[a] }))); 6899 return o2; 6900 } 6901 } 6902 lheading(e2) { 6903 let t2 = this.rules.block.lheading.exec(e2); 6904 if (t2) { 6905 let n = t2[1].trim(); 6906 return { type: "heading", raw: $2(t2[0], ` 6907 `), depth: t2[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) }; 6908 } 6909 } 6910 paragraph(e2) { 6911 let t2 = this.rules.block.paragraph.exec(e2); 6912 if (t2) { 6913 let n = t2[1].charAt(t2[1].length - 1) === ` 6914 ` ? t2[1].slice(0, -1) : t2[1]; 6915 return { type: "paragraph", raw: t2[0], text: n, tokens: this.lexer.inline(n) }; 6916 } 6917 } 6918 text(e2) { 6919 let t2 = this.rules.block.text.exec(e2); 6920 if (t2) return { type: "text", raw: t2[0], text: t2[0], tokens: this.lexer.inline(t2[0]) }; 6921 } 6922 escape(e2) { 6923 let t2 = this.rules.inline.escape.exec(e2); 6924 if (t2) return { type: "escape", raw: t2[0], text: t2[1] }; 6925 } 6926 tag(e2) { 6927 let t2 = this.rules.inline.tag.exec(e2); 6928 if (t2) return !this.lexer.state.inLink && this.rules.other.startATag.test(t2[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t2[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t2[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t2[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t2[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t2[0] }; 6929 } 6930 link(e2) { 6931 let t2 = this.rules.inline.link.exec(e2); 6932 if (t2) { 6933 let n = t2[0].charAt(0) === "!" ? 2 : 1; 6934 if (!this.options.pedantic && Re(e2, t2[1], n, this.rules)) return; 6935 let i = t2[2].trim(); 6936 if (!this.options.pedantic && this.rules.other.startAngleBracket.test(i)) { 6937 if (!this.rules.other.endAngleBracket.test(i)) return; 6938 let s = $2(i.slice(0, -1), "\\"); 6939 if ((i.length - s.length) % 2 === 0) return; 6940 } else { 6941 let s = me(t2[2], "()"); 6942 if (s === -2) return; 6943 if (s > -1) { 6944 let a = (t2[0].indexOf("!") === 0 ? 5 : 4) + t2[1].length + s; 6945 t2[2] = t2[2].substring(0, s), t2[0] = t2[0].substring(0, a).trim(), t2[3] = ""; 6946 } 6947 } 6948 let r2 = t2[2], o2 = ""; 6949 if (this.options.pedantic) { 6950 let s = this.rules.other.pedanticHrefTitle.exec(r2); 6951 s && (r2 = s[1], o2 = s[3]); 6952 } else o2 = t2[3] ? t2[3].slice(1, -1) : ""; 6953 return r2 = r2.trim(), this.rules.other.startAngleBracket.test(r2) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(i) ? r2 = r2.slice(1) : r2 = r2.slice(1, -1)), be(t2, { href: r2 && r2.replace(this.rules.inline.anyPunctuation, "$1"), title: o2 && o2.replace(this.rules.inline.anyPunctuation, "$1") }, t2[0], this.lexer, this.rules); 6954 } 6955 } 6956 reflink(e2, t2) { 6957 let n; 6958 if ((n = this.rules.inline.reflink.exec(e2)) || (n = this.rules.inline.nolink.exec(e2))) { 6959 let i = n[0].charAt(0) === "!" ? 2 : 1; 6960 if (!this.options.pedantic && Re(e2, n[1], i, this.rules)) return; 6961 let r2 = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), o2 = t2[D2(r2)]; 6962 if (!o2) { 6963 let s = n[0].charAt(0); 6964 return { type: "text", raw: s, text: s }; 6965 } 6966 return be(n, o2, n[0], this.lexer, this.rules); 6967 } 6968 } 6969 emStrong(e2, t2, n = "") { 6970 let i = this.rules.inline.emStrongLDelim.exec(e2); 6971 if (!i || !i[1] && !i[2] && !i[3] && !i[4] || i[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return; 6972 if (!(i[1] || i[3] || "") || !n || this.rules.inline.punctuation.exec(n)) { 6973 let o2 = [...i[0]].length - 1, s, u, a = o2, p2 = 0, c2 = i[0][0], h = n === c2, k2 = c2 === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; 6974 for (k2.lastIndex = 0, t2 = t2.slice(-1 * e2.length + o2); (i = k2.exec(t2)) !== null; ) { 6975 if (s = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !s) continue; 6976 if (u = [...s].length, i[3] || i[4]) { 6977 a += u; 6978 continue; 6979 } else if (i[5] || i[6]) { 6980 if (o2 % 3 && !((o2 + u) % 3)) { 6981 p2 += u; 6982 continue; 6983 } 6984 if (h) break; 6985 } 6986 if (a -= u, a > 0) continue; 6987 u = Math.min(u, u + a + p2); 6988 let O = [...i[0]][0].length, g2 = e2.slice(0, o2 + i.index + O + u); 6989 if (Math.min(o2, u) % 2) { 6990 let z = g2.slice(1, -1); 6991 return { type: "em", raw: g2, text: z, tokens: this.lexer.inlineTokens(z) }; 6992 } 6993 let w2 = g2.slice(2, -2); 6994 return { type: "strong", raw: g2, text: w2, tokens: this.lexer.inlineTokens(w2) }; 6995 } 6996 } 6997 } 6998 codespan(e2) { 6999 let t2 = this.rules.inline.code.exec(e2); 7000 if (t2) { 7001 let n = t2[2].replace(this.rules.other.newLineCharGlobal, " "), i = this.rules.other.nonSpaceChar.test(n), r2 = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n); 7002 return i && r2 && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t2[0], text: n }; 7003 } 7004 } 7005 br(e2) { 7006 let t2 = this.rules.inline.br.exec(e2); 7007 if (t2) return { type: "br", raw: t2[0] }; 7008 } 7009 del(e2, t2, n = "") { 7010 let i = this.rules.inline.delLDelim.exec(e2); 7011 if (!i) return; 7012 if (!(i[1] || "") || !n || this.rules.inline.punctuation.exec(n)) { 7013 let o2 = [...i[0]].length - 1, s, u, a = o2, p2 = this.rules.inline.delRDelim; 7014 for (p2.lastIndex = 0, t2 = t2.slice(-1 * e2.length + o2); (i = p2.exec(t2)) !== null; ) { 7015 if (s = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !s || (u = [...s].length, u !== o2)) continue; 7016 if (i[3] || i[4]) { 7017 a += u; 7018 continue; 7019 } 7020 if (a -= u, a > 0) continue; 7021 u = Math.min(u, u + a); 7022 let c2 = [...i[0]][0].length, h = e2.slice(0, o2 + i.index + c2 + u), k2 = h.slice(o2, -o2); 7023 return { type: "del", raw: h, text: k2, tokens: this.lexer.inlineTokens(k2) }; 7024 } 7025 } 7026 } 7027 autolink(e2) { 7028 let t2 = this.rules.inline.autolink.exec(e2); 7029 if (t2) { 7030 let n, i; 7031 return t2[2] === "@" ? (n = t2[1], i = "mailto:" + n) : (n = t2[1], i = n), { type: "link", raw: t2[0], text: n, href: i, autolink: true, tokens: [{ type: "text", raw: n, text: n }] }; 7032 } 7033 } 7034 url(e2) { 7035 let t2; 7036 if (t2 = this.rules.inline.url.exec(e2)) { 7037 let n, i; 7038 if (t2[2] === "@") n = t2[0], i = "mailto:" + n; 7039 else { 7040 let r2; 7041 do 7042 r2 = t2[0], t2[0] = this.rules.inline._backpedal.exec(t2[0])?.[0] ?? ""; 7043 while (r2 !== t2[0]); 7044 n = t2[0], t2[1] === "www." ? i = "http://" + t2[0] : i = t2[0]; 7045 } 7046 return { type: "link", raw: t2[0], text: n, href: i, autolink: true, tokens: [{ type: "text", raw: n, text: n }] }; 7047 } 7048 } 7049 inlineText(e2) { 7050 let t2 = this.rules.inline.text.exec(e2); 7051 if (t2) { 7052 let n = this.lexer.state.inRawBlock; 7053 return { type: "text", raw: t2[0], text: t2[0], escaped: n }; 7054 } 7055 } 7056 }; 7057 var x2 = class l2 { 7058 tokens; 7059 options; 7060 state; 7061 inlineQueue; 7062 tokenizer; 7063 constructor(e2) { 7064 this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e2 || T, this.options.tokenizer = this.options.tokenizer || new y2(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, top: true }; 7065 let t2 = { other: m2, block: G.normal, inline: B.normal }; 7066 this.options.pedantic ? (t2.block = G.pedantic, t2.inline = B.pedantic) : this.options.gfm && (t2.block = G.gfm, this.options.breaks ? t2.inline = B.breaks : t2.inline = B.gfm), this.tokenizer.rules = t2; 7067 } 7068 static get rules() { 7069 return { block: G, inline: B }; 7070 } 7071 static lex(e2, t2) { 7072 return new l2(t2).lex(e2); 7073 } 7074 static lexInline(e2, t2) { 7075 return new l2(t2).inlineTokens(e2); 7076 } 7077 lex(e2) { 7078 e2 = e2.replace(m2.carriageReturn, ` 7079 `), this.blockTokens(e2, this.tokens); 7080 for (let t2 = 0; t2 < this.inlineQueue.length; t2++) { 7081 let n = this.inlineQueue[t2]; 7082 this.inlineTokens(n.src, n.tokens); 7083 } 7084 return this.inlineQueue = [], this.tokens; 7085 } 7086 blockTokens(e2, t2 = [], n = false) { 7087 this.tokenizer.lexer = this, this.options.pedantic && (e2 = e2.replace(m2.tabCharGlobal, " ").replace(m2.spaceLine, "")); 7088 let i = 1 / 0; 7089 for (; e2; ) { 7090 if (e2.length < i) i = e2.length; 7091 else { 7092 this.infiniteLoopError(e2.charCodeAt(0)); 7093 break; 7094 } 7095 let r2; 7096 if (this.options.extensions?.block?.some((s) => (r2 = s.call({ lexer: this }, e2, t2)) ? (e2 = e2.substring(r2.raw.length), t2.push(r2), true) : false)) continue; 7097 if (r2 = this.tokenizer.space(e2)) { 7098 e2 = e2.substring(r2.raw.length); 7099 let s = t2.at(-1); 7100 r2.raw.length === 1 && s !== void 0 ? s.raw += ` 7101 ` : t2.push(r2); 7102 continue; 7103 } 7104 if (r2 = this.tokenizer.code(e2)) { 7105 e2 = e2.substring(r2.raw.length); 7106 let s = t2.at(-1); 7107 s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(` 7108 `) ? "" : ` 7109 `) + r2.raw, s.text += ` 7110 ` + r2.text, this.inlineQueue.at(-1).src = s.text) : t2.push(r2); 7111 continue; 7112 } 7113 if (r2 = this.tokenizer.fences(e2)) { 7114 e2 = e2.substring(r2.raw.length), t2.push(r2); 7115 continue; 7116 } 7117 if (r2 = this.tokenizer.heading(e2)) { 7118 e2 = e2.substring(r2.raw.length), t2.push(r2); 7119 continue; 7120 } 7121 if (r2 = this.tokenizer.hr(e2)) { 7122 e2 = e2.substring(r2.raw.length), t2.push(r2); 7123 continue; 7124 } 7125 if (r2 = this.tokenizer.blockquote(e2)) { 7126 e2 = e2.substring(r2.raw.length), t2.push(r2); 7127 continue; 7128 } 7129 if (r2 = this.tokenizer.list(e2)) { 7130 e2 = e2.substring(r2.raw.length), t2.push(r2); 7131 continue; 7132 } 7133 if (r2 = this.tokenizer.html(e2)) { 7134 e2 = e2.substring(r2.raw.length), t2.push(r2); 7135 continue; 7136 } 7137 if (r2 = this.tokenizer.def(e2)) { 7138 e2 = e2.substring(r2.raw.length); 7139 let s = t2.at(-1); 7140 s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(` 7141 `) ? "" : ` 7142 `) + r2.raw, s.text += ` 7143 ` + r2.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r2.tag] || (this.tokens.links[r2.tag] = { href: r2.href, title: r2.title }, t2.push(r2)); 7144 continue; 7145 } 7146 if (r2 = this.tokenizer.table(e2)) { 7147 e2 = e2.substring(r2.raw.length), t2.push(r2); 7148 continue; 7149 } 7150 if (r2 = this.tokenizer.lheading(e2)) { 7151 e2 = e2.substring(r2.raw.length), t2.push(r2); 7152 continue; 7153 } 7154 let o2 = e2; 7155 if (this.options.extensions?.startBlock) { 7156 let s = 1 / 0, u = e2.slice(1), a; 7157 this.options.extensions.startBlock.forEach((p2) => { 7158 a = p2.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (s = Math.min(s, a)); 7159 }), s < 1 / 0 && s >= 0 && (o2 = e2.substring(0, s + 1)); 7160 } 7161 if (this.state.top && (r2 = this.tokenizer.paragraph(o2))) { 7162 let s = t2.at(-1); 7163 n && s?.type === "paragraph" ? (s.raw += (s.raw.endsWith(` 7164 `) ? "" : ` 7165 `) + r2.raw, s.text += ` 7166 ` + r2.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t2.push(r2), n = o2.length !== e2.length, e2 = e2.substring(r2.raw.length); 7167 continue; 7168 } 7169 if (r2 = this.tokenizer.text(e2)) { 7170 e2 = e2.substring(r2.raw.length); 7171 let s = t2.at(-1); 7172 s?.type === "text" ? (s.raw += (s.raw.endsWith(` 7173 `) ? "" : ` 7174 `) + r2.raw, s.text += ` 7175 ` + r2.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t2.push(r2); 7176 continue; 7177 } 7178 if (e2) { 7179 this.infiniteLoopError(e2.charCodeAt(0)); 7180 break; 7181 } 7182 } 7183 return this.state.top = true, t2; 7184 } 7185 inline(e2, t2 = []) { 7186 return this.inlineQueue.push({ src: e2, tokens: t2 }), t2; 7187 } 7188 linkInText(e2) { 7189 if (!e2.includes("[")) return false; 7190 let t2 = this.tokenizer.rules.inline.link; 7191 for (let n of e2.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t2.test(n[0]) && e2.charAt(n.index - 1) !== "!") return true; 7192 for (let n of e2.matchAll(this.tokenizer.rules.inline.reflinkSearch)) { 7193 let i = n[0], r2 = i.lastIndexOf("["); 7194 if (!(i.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, D2(i.slice(r2 + 1, -1)))) && !(r2 > 1 && this.linkInText(i.slice(1, r2 - 1)))) return true; 7195 } 7196 return false; 7197 } 7198 inlineTokens(e2, t2 = []) { 7199 this.tokenizer.lexer = this; 7200 let n = e2; 7201 if (this.tokens.links && e2.includes("[")) { 7202 let s = this.tokenizer.rules.inline.reflinkSearch, u = (a) => { 7203 let p2 = a.lastIndexOf("["); 7204 if (!Object.hasOwn(this.tokens.links, D2(a.slice(p2 + 1, -1)))) return a; 7205 if (p2 > 1 && a.charAt(0) !== "!") { 7206 let c2 = a.slice(1, p2 - 1); 7207 if (this.linkInText(c2)) return "[" + c2.replace(s, u) + "][" + "a".repeat(a.length - p2 - 2) + "]"; 7208 } 7209 return "[" + "a".repeat(a.length - 2) + "]"; 7210 }; 7211 n = n.replace(s, u); 7212 } 7213 n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (s) => "+".repeat(s.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (s, u, a) => { 7214 let p2 = a ? a.length : 0; 7215 return s.slice(0, p2) + "[" + "a".repeat(s.length - p2 - 2) + "]"; 7216 }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n; 7217 let i = false, r2 = "", o2 = 1 / 0; 7218 for (; e2; ) { 7219 if (e2.length < o2) o2 = e2.length; 7220 else { 7221 this.infiniteLoopError(e2.charCodeAt(0)); 7222 break; 7223 } 7224 i || (r2 = ""), i = false; 7225 let s; 7226 if (this.options.extensions?.inline?.some((a) => (s = a.call({ lexer: this }, e2, t2)) ? (e2 = e2.substring(s.raw.length), t2.push(s), true) : false)) continue; 7227 if (s = this.tokenizer.escape(e2)) { 7228 e2 = e2.substring(s.raw.length), t2.push(s); 7229 continue; 7230 } 7231 if (s = this.tokenizer.tag(e2)) { 7232 e2 = e2.substring(s.raw.length), t2.push(s); 7233 continue; 7234 } 7235 if (s = this.tokenizer.link(e2)) { 7236 e2 = e2.substring(s.raw.length), t2.push(s); 7237 continue; 7238 } 7239 if (s = this.tokenizer.reflink(e2, this.tokens.links)) { 7240 e2 = e2.substring(s.raw.length); 7241 let a = t2.at(-1); 7242 s.type === "text" && a?.type === "text" ? (a.raw += s.raw, a.text += s.text) : t2.push(s); 7243 continue; 7244 } 7245 if (s = this.tokenizer.emStrong(e2, n, r2)) { 7246 e2 = e2.substring(s.raw.length), t2.push(s); 7247 continue; 7248 } 7249 if (s = this.tokenizer.codespan(e2)) { 7250 e2 = e2.substring(s.raw.length), t2.push(s); 7251 continue; 7252 } 7253 if (s = this.tokenizer.br(e2)) { 7254 e2 = e2.substring(s.raw.length), t2.push(s); 7255 continue; 7256 } 7257 if (s = this.tokenizer.del(e2, n, r2)) { 7258 e2 = e2.substring(s.raw.length), t2.push(s); 7259 continue; 7260 } 7261 if (s = this.tokenizer.autolink(e2)) { 7262 e2 = e2.substring(s.raw.length), t2.push(s); 7263 continue; 7264 } 7265 if (!this.state.inLink && (s = this.tokenizer.url(e2))) { 7266 e2 = e2.substring(s.raw.length), t2.push(s); 7267 continue; 7268 } 7269 let u = e2; 7270 if (this.options.extensions?.startInline) { 7271 let a = 1 / 0, p2 = e2.slice(1), c2; 7272 this.options.extensions.startInline.forEach((h) => { 7273 c2 = h.call({ lexer: this }, p2), typeof c2 == "number" && c2 >= 0 && (a = Math.min(a, c2)); 7274 }), a < 1 / 0 && a >= 0 && (u = e2.substring(0, a + 1)); 7275 } 7276 if (s = this.tokenizer.inlineText(u)) { 7277 e2 = e2.substring(s.raw.length), s.raw.slice(-1) !== "_" && (r2 = s.raw.slice(-1)), i = true; 7278 let a = t2.at(-1); 7279 a?.type === "text" ? (a.raw += s.raw, a.text += s.text) : t2.push(s); 7280 continue; 7281 } 7282 if (e2) { 7283 this.infiniteLoopError(e2.charCodeAt(0)); 7284 break; 7285 } 7286 } 7287 return t2; 7288 } 7289 infiniteLoopError(e2) { 7290 let t2 = "Infinite loop on byte: " + e2; 7291 if (this.options.silent) console.error(t2); 7292 else throw new Error(t2); 7293 } 7294 }; 7295 var P = class { 7296 options; 7297 parser; 7298 constructor(e2) { 7299 this.options = e2 || T; 7300 } 7301 space(e2) { 7302 return ""; 7303 } 7304 code({ text: e2, lang: t2, escaped: n }) { 7305 let i = (t2 || "").match(m2.notSpaceStart)?.[0], r2 = e2 ? e2.replace(m2.endingNewline, "") + ` 7306 ` : ""; 7307 return i ? '<pre><code class="language-' + R2(i) + '">' + (n ? r2 : R2(r2, true)) + `</code></pre> 7308 ` : "<pre><code>" + (n ? r2 : R2(r2, true)) + `</code></pre> 7309 `; 7310 } 7311 blockquote({ tokens: e2 }) { 7312 return `<blockquote> 7313 $this.parser.parse(e2)}</blockquote> 7314 `; 7315 } 7316 html({ text: e2 }) { 7317 return e2; 7318 } 7319 def(e2) { 7320 return ""; 7321 } 7322 heading({ tokens: e2, depth: t2 }) { 7323 return `<h$t2}>$this.parser.parseInline(e2)}</h$t2}> 7324 `; 7325 } 7326 hr(e2) { 7327 return `<hr> 7328 `; 7329 } 7330 list(e2) { 7331 let t2 = e2.ordered, n = e2.start, i = ""; 7332 for (let s = 0; s < e2.items.length; s++) { 7333 let u = e2.items[s]; 7334 i += this.listitem(u); 7335 } 7336 let r2 = t2 ? "ol" : "ul", o2 = t2 && n !== 1 ? ' start="' + n + '"' : ""; 7337 return "<" + r2 + o2 + `> 7338 ` + i + "</" + r2 + `> 7339 `; 7340 } 7341 listitem(e2) { 7342 return `<li>$this.parser.parse(e2.tokens)}</li> 7343 `; 7344 } 7345 checkbox({ checked: e2 }) { 7346 return "<input " + (e2 ? 'checked="" ' : "") + 'disabled="" type="checkbox"> '; 7347 } 7348 paragraph({ tokens: e2 }) { 7349 return `<p>$this.parser.parseInline(e2)}</p> 7350 `; 7351 } 7352 table(e2) { 7353 let t2 = "", n = ""; 7354 for (let r2 = 0; r2 < e2.header.length; r2++) n += this.tablecell(e2.header[r2]); 7355 t2 += this.tablerow({ text: n }); 7356 let i = ""; 7357 for (let r2 = 0; r2 < e2.rows.length; r2++) { 7358 let o2 = e2.rows[r2]; 7359 n = ""; 7360 for (let s = 0; s < o2.length; s++) n += this.tablecell(o2[s]); 7361 i += this.tablerow({ text: n }); 7362 } 7363 return i && (i = `<tbody>$i}</tbody>`), `<table> 7364 <thead> 7365 ` + t2 + `</thead> 7366 ` + i + `</table> 7367 `; 7368 } 7369 tablerow({ text: e2 }) { 7370 return `<tr> 7371 $e2}</tr> 7372 `; 7373 } 7374 tablecell(e2) { 7375 let t2 = this.parser.parseInline(e2.tokens), n = e2.header ? "th" : "td"; 7376 return (e2.align ? `<$n} align="$e2.align}">` : `<$n}>`) + t2 + `</$n}> 7377 `; 7378 } 7379 strong({ tokens: e2 }) { 7380 return `<strong>$this.parser.parseInline(e2)}</strong>`; 7381 } 7382 em({ tokens: e2 }) { 7383 return `<em>$this.parser.parseInline(e2)}</em>`; 7384 } 7385 codespan({ text: e2 }) { 7386 return `<code>$R2(e2, true)}</code>`; 7387 } 7388 br(e2) { 7389 return "<br>"; 7390 } 7391 del({ tokens: e2 }) { 7392 return `<del>$this.parser.parseInline(e2)}</del>`; 7393 } 7394 link({ href: e2, title: t2, text: n, tokens: i, autolink: r2 }) { 7395 let o2 = r2 ? R2(n, true) : this.parser.parseInline(i), s = ee(e2); 7396 if (s === null) return o2; 7397 e2 = R2(s, r2); 7398 let u = '<a href="' + e2 + '"'; 7399 return t2 && (u += ' title="' + R2(t2) + '"'), u += ">" + o2 + "</a>", u; 7400 } 7401 image({ href: e2, title: t2, text: n, tokens: i }) { 7402 i && (n = this.parser.parseInline(i, this.parser.textRenderer)); 7403 let r2 = ee(e2); 7404 if (r2 === null) return R2(n); 7405 e2 = r2; 7406 let o2 = `<img src="$R2(e2)}" alt="$R2(n)}"`; 7407 return t2 && (o2 += ` title="$R2(t2)}"`), o2 += ">", o2; 7408 } 7409 text(e2) { 7410 return "tokens" in e2 && e2.tokens ? this.parser.parseInline(e2.tokens) : "escaped" in e2 && e2.escaped ? e2.text : R2(e2.text); 7411 } 7412 }; 7413 var L = class { 7414 strong({ text: e2 }) { 7415 return e2; 7416 } 7417 em({ text: e2 }) { 7418 return e2; 7419 } 7420 codespan({ text: e2 }) { 7421 return e2; 7422 } 7423 del({ text: e2 }) { 7424 return e2; 7425 } 7426 html({ text: e2 }) { 7427 return e2; 7428 } 7429 text({ text: e2 }) { 7430 return e2; 7431 } 7432 link({ text: e2 }) { 7433 return "" + e2; 7434 } 7435 image({ text: e2 }) { 7436 return "" + e2; 7437 } 7438 br() { 7439 return ""; 7440 } 7441 checkbox({ raw: e2 }) { 7442 return e2; 7443 } 7444 }; 7445 var b = class l3 { 7446 options; 7447 renderer; 7448 textRenderer; 7449 constructor(e2) { 7450 this.options = e2 || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L(); 7451 } 7452 static parse(e2, t2) { 7453 return new l3(t2).parse(e2); 7454 } 7455 static parseInline(e2, t2) { 7456 return new l3(t2).parseInline(e2); 7457 } 7458 parse(e2) { 7459 this.renderer.parser = this; 7460 let t2 = ""; 7461 for (let n = 0; n < e2.length; n++) { 7462 let i = e2[n]; 7463 if (this.options.extensions?.renderers?.[i.type]) { 7464 let o2 = i, s = this.options.extensions.renderers[o2.type].call({ parser: this }, o2); 7465 if (s !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o2.type)) { 7466 t2 += s || ""; 7467 continue; 7468 } 7469 } 7470 let r2 = i; 7471 switch (r2.type) { 7472 case "space": { 7473 t2 += this.renderer.space(r2); 7474 break; 7475 } 7476 case "hr": { 7477 t2 += this.renderer.hr(r2); 7478 break; 7479 } 7480 case "heading": { 7481 t2 += this.renderer.heading(r2); 7482 break; 7483 } 7484 case "code": { 7485 t2 += this.renderer.code(r2); 7486 break; 7487 } 7488 case "table": { 7489 t2 += this.renderer.table(r2); 7490 break; 7491 } 7492 case "blockquote": { 7493 t2 += this.renderer.blockquote(r2); 7494 break; 7495 } 7496 case "list": { 7497 t2 += this.renderer.list(r2); 7498 break; 7499 } 7500 case "checkbox": { 7501 t2 += this.renderer.checkbox(r2); 7502 break; 7503 } 7504 case "html": { 7505 t2 += this.renderer.html(r2); 7506 break; 7507 } 7508 case "def": { 7509 t2 += this.renderer.def(r2); 7510 break; 7511 } 7512 case "paragraph": { 7513 t2 += this.renderer.paragraph(r2); 7514 break; 7515 } 7516 case "text": { 7517 t2 += this.renderer.text(r2); 7518 break; 7519 } 7520 default: { 7521 let o2 = 'Token with "' + r2.type + '" type was not found.'; 7522 if (this.options.silent) return console.error(o2), ""; 7523 throw new Error(o2); 7524 } 7525 } 7526 } 7527 return t2; 7528 } 7529 parseInline(e2, t2 = this.renderer) { 7530 this.renderer.parser = this; 7531 let n = ""; 7532 for (let i = 0; i < e2.length; i++) { 7533 let r2 = e2[i]; 7534 if (this.options.extensions?.renderers?.[r2.type]) { 7535 let s = this.options.extensions.renderers[r2.type].call({ parser: this }, r2); 7536 if (s !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r2.type)) { 7537 n += s || ""; 7538 continue; 7539 } 7540 } 7541 let o2 = r2; 7542 switch (o2.type) { 7543 case "escape": { 7544 n += t2.text(o2); 7545 break; 7546 } 7547 case "html": { 7548 n += t2.html(o2); 7549 break; 7550 } 7551 case "link": { 7552 n += t2.link(o2); 7553 break; 7554 } 7555 case "image": { 7556 n += t2.image(o2); 7557 break; 7558 } 7559 case "checkbox": { 7560 n += t2.checkbox(o2); 7561 break; 7562 } 7563 case "strong": { 7564 n += t2.strong(o2); 7565 break; 7566 } 7567 case "em": { 7568 n += t2.em(o2); 7569 break; 7570 } 7571 case "codespan": { 7572 n += t2.codespan(o2); 7573 break; 7574 } 7575 case "br": { 7576 n += t2.br(o2); 7577 break; 7578 } 7579 case "del": { 7580 n += t2.del(o2); 7581 break; 7582 } 7583 case "text": { 7584 n += t2.text(o2); 7585 break; 7586 } 7587 default: { 7588 let s = 'Token with "' + o2.type + '" type was not found.'; 7589 if (this.options.silent) return console.error(s), ""; 7590 throw new Error(s); 7591 } 7592 } 7593 } 7594 return n; 7595 } 7596 }; 7597 var S = class { 7598 options; 7599 block; 7600 constructor(e2) { 7601 this.options = e2 || T; 7602 } 7603 static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]); 7604 static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]); 7605 preprocess(e2) { 7606 return e2; 7607 } 7608 postprocess(e2) { 7609 return e2; 7610 } 7611 processAllTokens(e2) { 7612 return e2; 7613 } 7614 emStrongMask(e2) { 7615 return e2; 7616 } 7617 provideLexer(e2 = this.block) { 7618 return e2 ? x2.lex : x2.lexInline; 7619 } 7620 provideParser(e2 = this.block) { 7621 return e2 ? b.parse : b.parseInline; 7622 } 7623 }; 7624 var Q = class { 7625 defaults = A2(); 7626 options = this.setOptions; 7627 parse = this.parseMarkdown(true); 7628 parseInline = this.parseMarkdown(false); 7629 Parser = b; 7630 Renderer = P; 7631 TextRenderer = L; 7632 Lexer = x2; 7633 Tokenizer = y2; 7634 Hooks = S; 7635 constructor(...e2) { 7636 this.use(...e2); 7637 } 7638 walkTokens(e2, t2) { 7639 let n = []; 7640 for (let i of e2) switch (n = n.concat(t2.call(this, i)), i.type) { 7641 case "table": { 7642 let r2 = i; 7643 for (let o2 of r2.header) n = n.concat(this.walkTokens(o2.tokens, t2)); 7644 for (let o2 of r2.rows) for (let s of o2) n = n.concat(this.walkTokens(s.tokens, t2)); 7645 break; 7646 } 7647 case "list": { 7648 let r2 = i; 7649 n = n.concat(this.walkTokens(r2.items, t2)); 7650 break; 7651 } 7652 default: { 7653 let r2 = i; 7654 this.defaults.extensions?.childTokens?.[r2.type] ? this.defaults.extensions.childTokens[r2.type].forEach((o2) => { 7655 let s = r2[o2].flat(1 / 0); 7656 n = n.concat(this.walkTokens(s, t2)); 7657 }) : r2.tokens && (n = n.concat(this.walkTokens(r2.tokens, t2))); 7658 } 7659 } 7660 return n; 7661 } 7662 use(...e2) { 7663 let t2 = this.defaults.extensions || { renderers: {}, childTokens: {} }; 7664 return e2.forEach((n) => { 7665 let i = { ...n }; 7666 if (i.async = this.defaults.async || i.async || false, n.extensions && (n.extensions.forEach((r2) => { 7667 if (!r2.name) throw new Error("extension name required"); 7668 if ("renderer" in r2) { 7669 let o2 = t2.renderers[r2.name]; 7670 o2 ? t2.renderers[r2.name] = function(...s) { 7671 let u = r2.renderer.apply(this, s); 7672 return u === false && (u = o2.apply(this, s)), u; 7673 } : t2.renderers[r2.name] = r2.renderer; 7674 } 7675 if ("tokenizer" in r2) { 7676 if (!r2.level || r2.level !== "block" && r2.level !== "inline") throw new Error("extension level must be 'block' or 'inline'"); 7677 let o2 = t2[r2.level]; 7678 o2 ? o2.unshift(r2.tokenizer) : t2[r2.level] = [r2.tokenizer], r2.start && (r2.level === "block" ? t2.startBlock ? t2.startBlock.push(r2.start) : t2.startBlock = [r2.start] : r2.level === "inline" && (t2.startInline ? t2.startInline.push(r2.start) : t2.startInline = [r2.start])); 7679 } 7680 "childTokens" in r2 && r2.childTokens && (t2.childTokens[r2.name] = r2.childTokens); 7681 }), i.extensions = t2), n.renderer) { 7682 let r2 = this.defaults.renderer || new P(this.defaults); 7683 for (let o2 in n.renderer) { 7684 if (!(o2 in r2)) throw new Error(`renderer '$o2}' does not exist`); 7685 if (["options", "parser"].includes(o2)) continue; 7686 let s = o2, u = n.renderer[s], a = r2[s]; 7687 r2[s] = (...p2) => { 7688 let c2 = u.apply(r2, p2); 7689 return c2 === false && (c2 = a.apply(r2, p2)), c2 || ""; 7690 }; 7691 } 7692 i.renderer = r2; 7693 } 7694 if (n.tokenizer) { 7695 let r2 = this.defaults.tokenizer || new y2(this.defaults); 7696 for (let o2 in n.tokenizer) { 7697 if (!(o2 in r2)) throw new Error(`tokenizer '$o2}' does not exist`); 7698 if (["options", "rules", "lexer"].includes(o2)) continue; 7699 let s = o2, u = n.tokenizer[s], a = r2[s]; 7700 r2[s] = (...p2) => { 7701 let c2 = u.apply(r2, p2); 7702 return c2 === false && (c2 = a.apply(r2, p2)), c2; 7703 }; 7704 } 7705 i.tokenizer = r2; 7706 } 7707 if (n.hooks) { 7708 let r2 = this.defaults.hooks || new S(); 7709 for (let o2 in n.hooks) { 7710 if (!(o2 in r2)) throw new Error(`hook '$o2}' does not exist`); 7711 if (["options", "block"].includes(o2)) continue; 7712 let s = o2, u = n.hooks[s], a = r2[s]; 7713 S.passThroughHooks.has(o2) ? r2[s] = (p2) => { 7714 if (this.defaults.async && S.passThroughHooksRespectAsync.has(o2)) return (async () => { 7715 let h = await u.call(r2, p2); 7716 return a.call(r2, h); 7717 })(); 7718 let c2 = u.call(r2, p2); 7719 return a.call(r2, c2); 7720 } : r2[s] = (...p2) => { 7721 if (this.defaults.async) return (async () => { 7722 let h = await u.apply(r2, p2); 7723 return h === false && (h = await a.apply(r2, p2)), h; 7724 })(); 7725 let c2 = u.apply(r2, p2); 7726 return c2 === false && (c2 = a.apply(r2, p2)), c2; 7727 }; 7728 } 7729 i.hooks = r2; 7730 } 7731 if (n.walkTokens) { 7732 let r2 = this.defaults.walkTokens, o2 = n.walkTokens; 7733 i.walkTokens = function(s) { 7734 let u = []; 7735 return u.push(o2.call(this, s)), r2 && (u = u.concat(r2.call(this, s))), u; 7736 }; 7737 } 7738 this.defaults = { ...this.defaults, ...i }; 7739 }), this; 7740 } 7741 setOptions(e2) { 7742 return this.defaults = { ...this.defaults, ...e2 }, this; 7743 } 7744 lexer(e2, t2) { 7745 return x2.lex(e2, t2 ?? this.defaults); 7746 } 7747 parser(e2, t2) { 7748 return b.parse(e2, t2 ?? this.defaults); 7749 } 7750 parseMarkdown(e2) { 7751 return (n, i) => { 7752 let r2 = { ...i }, o2 = { ...this.defaults, ...r2 }, s = this.onError(!!o2.silent, !!o2.async); 7753 if (this.defaults.async === true && r2.async === false) return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); 7754 if (typeof n > "u" || n === null) return s(new Error("marked(): input parameter is undefined or null")); 7755 if (typeof n != "string") return s(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected")); 7756 if (o2.hooks && (o2.hooks.options = o2, o2.hooks.block = e2), o2.async) return (async () => { 7757 let u = o2.hooks ? await o2.hooks.preprocess(n) : n, p2 = await (o2.hooks ? await o2.hooks.provideLexer(e2) : e2 ? x2.lex : x2.lexInline)(u, o2), c2 = o2.hooks ? await o2.hooks.processAllTokens(p2) : p2; 7758 o2.walkTokens && await Promise.all(this.walkTokens(c2, o2.walkTokens)); 7759 let k2 = await (o2.hooks ? await o2.hooks.provideParser(e2) : e2 ? b.parse : b.parseInline)(c2, o2); 7760 return o2.hooks ? await o2.hooks.postprocess(k2) : k2; 7761 })().catch(s); 7762 try { 7763 o2.hooks && (n = o2.hooks.preprocess(n)); 7764 let a = (o2.hooks ? o2.hooks.provideLexer(e2) : e2 ? x2.lex : x2.lexInline)(n, o2); 7765 o2.hooks && (a = o2.hooks.processAllTokens(a)), o2.walkTokens && this.walkTokens(a, o2.walkTokens); 7766 let c2 = (o2.hooks ? o2.hooks.provideParser(e2) : e2 ? b.parse : b.parseInline)(a, o2); 7767 return o2.hooks && (c2 = o2.hooks.postprocess(c2)), c2; 7768 } catch (u) { 7769 return s(u); 7770 } 7771 }; 7772 } 7773 onError(e2, t2) { 7774 return (n) => { 7775 if (n.message += ` 7776 Please report this to https://github.com/markedjs/marked.`, e2) { 7777 let i = "<p>An error occurred:</p><pre>" + R2(n.message + "", true) + "</pre>"; 7778 return t2 ? Promise.resolve(i) : i; 7779 } 7780 if (t2) return Promise.reject(n); 7781 throw n; 7782 }; 7783 } 7784 }; 7785 var M2 = new Q(); 7786 function f(l4, e2) { 7787 return M2.parse(l4, e2); 7788 } 7789 f.options = f.setOptions = function(l4) { 7790 return M2.setOptions(l4), f.defaults = M2.defaults, U(f.defaults), f; 7791 }; 7792 f.getDefaults = A2; 7793 f.defaults = T; 7794 function bt(...l4) { 7795 return M2.use(...l4), f.defaults = M2.defaults, U(f.defaults), f; 7796 } 7797 f.use = bt; 7798 f.walkTokens = function(l4, e2) { 7799 return M2.walkTokens(l4, e2); 7800 }; 7801 f.parseInline = M2.parseInline; 7802 f.Parser = b; 7803 f.parser = b.parse; 7804 f.Renderer = P; 7805 f.TextRenderer = L; 7806 f.Lexer = x2; 7807 f.lexer = x2.lex; 7808 f.Tokenizer = y2; 7809 f.Hooks = S; 7810 f.parse = f; 7811 var un = f.options; 7812 var pn = f.setOptions; 7813 var cn = f.walkTokens; 7814 var hn = f.parseInline; 7815 var kn = b.parse; 7816 var gn = x2.lex; 7817 7818 // packages/blocks/build-module/api/raw-handling/markdown-converter.mjs 7819 function escapeBodyText(value) { 7820 return value.replace(/&(?!#?\w+;)/g, "&").replace(/</g, "<").replace(/>/g, ">"); 7821 } 7822 var converter = new Q({ 7823 gfm: true, 7824 breaks: true, 7825 renderer: { 7826 // Match showdown's `omitExtraWLInCodeBlocks`: marked appends `\n` 7827 // before `</code>`, which leaks into the Code block's content as a 7828 // trailing blank line. 7829 code({ text: text2, lang }) { 7830 const language = (lang || "").match(/^\S*/)?.[0]; 7831 const cls = language ? ` class="$language} language-$language}"` : ""; 7832 return `<pre><code$cls}>$escapeBodyText( 7833 text2 7834 )}</code></pre>`; 7835 }, 7836 text(token) { 7837 if ("tokens" in token && token.tokens || "escaped" in token && token.escaped) { 7838 return false; 7839 } 7840 return escapeBodyText(token.text); 7841 } 7842 } 7843 }); 7844 function slackMarkdownVariantCorrector(text2) { 7845 return text2.replace( 7846 /((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, 7847 (match, p1, p2, p3) => `$p1} 7848 $p2} 7849 $p3}` 7850 ); 7851 } 7852 function bulletsToAsterisks(text2) { 7853 return text2.replace(/(^|\n)•( +)/g, "$1*$2"); 7854 } 7855 function escapeSingleLineOrderedListMarker(text2) { 7856 if (text2.includes("\n")) { 7857 return text2; 7858 } 7859 return text2.replace(/^(\d+)\.(\s)/, "$1\\.$2"); 7860 } 7861 var correctors = [ 7862 escapeSingleLineOrderedListMarker, 7863 bulletsToAsterisks, 7864 slackMarkdownVariantCorrector 7865 ]; 7866 function markdownConverter(text2) { 7867 return converter.parse( 7868 correctors.reduce( 7869 (current, corrector) => corrector(current), 7870 text2 7871 ), 7872 { async: false } 7873 ); 7874 } 7875 7876 // packages/blocks/build-module/api/raw-handling/iframe-remover.mjs 7877 function iframeRemover(iframe) { 7878 if (iframe.nodeName === "IFRAME") { 7879 const node = iframe; 7880 const text2 = node.ownerDocument.createTextNode(node.src); 7881 node.parentNode.replaceChild(text2, node); 7882 } 7883 } 7884 7885 // packages/blocks/build-module/api/raw-handling/google-docs-uid-remover.mjs 7886 var import_dom10 = __toESM(require_dom(), 1); 7887 function googleDocsUIdRemover(node) { 7888 const el = node; 7889 if (!el.id || el.id.indexOf("docs-internal-guid-") !== 0) { 7890 return; 7891 } 7892 if (el.tagName === "B") { 7893 (0, import_dom10.unwrap)(node); 7894 } else { 7895 el.removeAttribute("id"); 7896 } 7897 } 7898 7899 // packages/blocks/build-module/api/raw-handling/non-breaking-space-corrector.mjs 7900 function nonBreakingSpaceCorrector(node) { 7901 if (node.nodeType !== node.TEXT_NODE) { 7902 return; 7903 } 7904 if (node.parentElement?.closest("pre")) { 7905 return; 7906 } 7907 const text2 = node; 7908 if (/^\u00a0+$/.test(text2.data) && !getSibling(node, "previous") && !getSibling(node, "next")) { 7909 return; 7910 } 7911 text2.data = text2.data.replace(/^\u00a0+|\u00a0+$/g, " "); 7912 } 7913 7914 // packages/blocks/build-module/api/raw-handling/html-formatting-remover.mjs 7915 function isFormattingSpace(character) { 7916 return character === " " || character === "\r" || character === "\n" || character === " "; 7917 } 7918 function htmlFormattingRemover(node) { 7919 if (node.nodeType !== node.TEXT_NODE) { 7920 return; 7921 } 7922 let parent = node; 7923 while (parent = parent.parentNode) { 7924 if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === "PRE") { 7925 return; 7926 } 7927 } 7928 const textNode = node; 7929 let newData = textNode.data.replace(/[ \r\n\t]+/g, " "); 7930 if (newData[0] === " ") { 7931 const previousSibling = getSibling(node, "previous"); 7932 if (!previousSibling || previousSibling.nodeName === "BR" || previousSibling.textContent.slice(-1) === " ") { 7933 newData = newData.slice(1); 7934 } 7935 } 7936 if (newData[newData.length - 1] === " ") { 7937 const nextSibling = getSibling(node, "next"); 7938 if (!nextSibling || nextSibling.nodeName === "BR" || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { 7939 newData = newData.slice(0, -1); 7940 } 7941 } 7942 if (!newData) { 7943 node.parentNode.removeChild(node); 7944 } else { 7945 textNode.data = newData; 7946 } 7947 } 7948 7949 // packages/blocks/build-module/api/raw-handling/format-space-corrector.mjs 7950 var import_dom11 = __toESM(require_dom(), 1); 7951 function moveEdgeSpace(node, doc, isLeading) { 7952 const child = isLeading ? node.firstChild : node.lastChild; 7953 if (!child || child.nodeType !== node.TEXT_NODE) { 7954 return; 7955 } 7956 const text2 = child; 7957 const edgeIndex = isLeading ? 0 : text2.data.length - 1; 7958 if (text2.data[edgeIndex] !== " ") { 7959 return; 7960 } 7961 text2.data = isLeading ? text2.data.slice(1) : text2.data.slice(0, -1); 7962 if (!text2.data) { 7963 node.removeChild(text2); 7964 } 7965 node.parentNode.insertBefore( 7966 doc.createTextNode(" "), 7967 isLeading ? node : node.nextSibling 7968 ); 7969 } 7970 function formatSpaceCorrector(node, doc) { 7971 if (node.nodeType !== node.ELEMENT_NODE || !(0, import_dom11.isPhrasingContent)(node)) { 7972 return; 7973 } 7974 moveEdgeSpace(node, doc, true); 7975 moveEdgeSpace(node, doc, false); 7976 } 7977 7978 // packages/blocks/build-module/api/raw-handling/br-remover.mjs 7979 function brRemover(node) { 7980 if (node.nodeName !== "BR") { 7981 return; 7982 } 7983 if (getSibling(node, "next")) { 7984 return; 7985 } 7986 node.parentNode.removeChild(node); 7987 } 7988 7989 // packages/blocks/build-module/api/raw-handling/empty-paragraph-remover.mjs 7990 function emptyParagraphRemover(node) { 7991 if (node.nodeName !== "P") { 7992 return; 7993 } 7994 if (node.hasChildNodes()) { 7995 return; 7996 } 7997 node.parentNode.removeChild(node); 7998 } 7999 8000 // packages/blocks/build-module/api/raw-handling/slack-paragraph-corrector.mjs 8001 function slackParagraphCorrector(node) { 8002 if (node.nodeName !== "SPAN") { 8003 return; 8004 } 8005 if (node.getAttribute("data-stringify-type") !== "paragraph-break") { 8006 return; 8007 } 8008 const parentNode = node.parentNode; 8009 parentNode.insertBefore(node.ownerDocument.createElement("br"), node); 8010 parentNode.insertBefore(node.ownerDocument.createElement("br"), node); 8011 parentNode.removeChild(node); 8012 } 8013 8014 // packages/blocks/build-module/api/raw-handling/latex-to-math.mjs 8015 function isLatexMathMode(text2) { 8016 const lettersRegex = /[\p{L}\s]+/gu; 8017 let match; 8018 while (match = lettersRegex.exec(text2)) { 8019 if (text2[match.index - 1] === "{") { 8020 continue; 8021 } 8022 let sequence = match[0]; 8023 if (text2[match.index - 1] === "\\") { 8024 sequence = sequence.replace(/^[a-zA-Z]+/, ""); 8025 } 8026 if (sequence.length < 6) { 8027 continue; 8028 } 8029 return false; 8030 } 8031 if (/\\[a-zA-Z]+\s*\{/g.test(text2)) { 8032 return true; 8033 } 8034 const softClues = [ 8035 (t2) => t2.includes("^") && !t2.startsWith("^"), 8036 (t2) => ["=", "+", "-", "/", "*"].some( 8037 (operator) => t2.includes(operator) 8038 ), 8039 (t2) => /\\[a-zA-Z]+/g.test(t2) 8040 ]; 8041 if (softClues.filter((clue) => clue(text2)).length >= 2) { 8042 return true; 8043 } 8044 return false; 8045 } 8046 8047 // packages/blocks/build-module/api/raw-handling/heading-transformer.mjs 8048 function headingTransformer(node) { 8049 if (node.nodeType !== node.ELEMENT_NODE) { 8050 return; 8051 } 8052 const element = node; 8053 if (element.tagName === "P" && element.getAttribute("role") === "heading" && element.hasAttribute("aria-level")) { 8054 const level = parseInt(element.getAttribute("aria-level"), 10); 8055 if (level >= 1 && level <= 6) { 8056 const headingTag = `H$level}`; 8057 const newHeading = element.ownerDocument.createElement(headingTag); 8058 Array.from(element.attributes).forEach((attr2) => { 8059 if (attr2.name !== "role" && attr2.name !== "aria-level") { 8060 newHeading.setAttribute(attr2.name, attr2.value); 8061 } 8062 }); 8063 while (element.firstChild) { 8064 newHeading.appendChild(element.firstChild); 8065 } 8066 element.parentNode.replaceChild(newHeading, element); 8067 } 8068 } 8069 } 8070 8071 // packages/blocks/build-module/api/raw-handling/paste-handler.mjs 8072 var log = (...args) => window?.console?.log?.(...args); 8073 function filterInlineHTML(HTML) { 8074 HTML = deepFilterHTML(HTML, [ 8075 headRemover, 8076 googleDocsUIdRemover, 8077 msListIgnore, 8078 phrasingContentReducer, 8079 commentRemover 8080 ]); 8081 HTML = (0, import_dom12.removeInvalidHTML)( 8082 HTML, 8083 (0, import_dom12.getPhrasingContentSchema)("paste"), 8084 true 8085 ); 8086 HTML = deepFilterHTML(HTML, [ 8087 nonBreakingSpaceCorrector, 8088 htmlFormattingRemover, 8089 formatSpaceCorrector, 8090 brRemover 8091 ]); 8092 log("Processed inline HTML:\n\n", HTML); 8093 return HTML; 8094 } 8095 function pasteHandler({ 8096 HTML = "", 8097 plainText = "", 8098 mode = "AUTO", 8099 tagName 8100 }) { 8101 log("Received HTML (pasteHandler):\n\n", HTML); 8102 log("Received plain text (pasteHandler):\n\n", plainText); 8103 HTML = HTML.replace(/<meta[^>]+>/g, ""); 8104 HTML = HTML.replace( 8105 /^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, 8106 "" 8107 ); 8108 HTML = HTML.replace( 8109 /(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, 8110 "" 8111 ); 8112 if (mode !== "INLINE") { 8113 const content = HTML ? HTML : plainText; 8114 if (content.indexOf("<!-- wp:") !== -1) { 8115 const parseResult = parse2(content); 8116 const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === "core/freeform"; 8117 if (!isSingleFreeFormBlock) { 8118 return parseResult; 8119 } 8120 } 8121 } 8122 HTML = HTML.normalize(); 8123 HTML = deepFilterHTML(HTML, [slackParagraphCorrector]); 8124 const isPlainText = plainText && (!HTML || isPlain(HTML)); 8125 if (isPlainText && isLatexMathMode(plainText)) { 8126 return [createBlock("core/math", { latex: plainText })]; 8127 } 8128 if (isPlainText) { 8129 HTML = plainText; 8130 if (!/^\s+$/.test(plainText)) { 8131 HTML = markdownConverter(HTML); 8132 } 8133 } 8134 const pieces = shortcode_converter_default(HTML); 8135 const hasShortcodes = pieces.length > 1; 8136 if (isPlainText && !hasShortcodes) { 8137 if (mode === "AUTO" && plainText.indexOf("\n") === -1 && plainText.indexOf("<p>") !== 0 && HTML.indexOf("<p>") === 0) { 8138 mode = "INLINE"; 8139 } 8140 } 8141 if (mode === "INLINE") { 8142 return filterInlineHTML(HTML); 8143 } 8144 if (mode === "AUTO" && !hasShortcodes && isInlineContent(HTML, tagName)) { 8145 return filterInlineHTML(HTML); 8146 } 8147 const phrasingContentSchema = (0, import_dom12.getPhrasingContentSchema)("paste"); 8148 const blockContentSchema = getBlockContentSchema("paste"); 8149 const blocks = pieces.map((piece) => { 8150 if (typeof piece !== "string") { 8151 return piece; 8152 } 8153 const filters = [ 8154 googleDocsUIdRemover, 8155 msListConverter, 8156 headRemover, 8157 listReducer, 8158 imageCorrector, 8159 phrasingContentReducer, 8160 specialCommentConverter, 8161 commentRemover, 8162 iframeRemover, 8163 figureContentReducer, 8164 blockquoteNormaliser(), 8165 divNormaliser, 8166 headingTransformer 8167 ]; 8168 const schema = { 8169 ...blockContentSchema, 8170 // Keep top-level phrasing content, normalised by `normaliseBlocks`. 8171 ...phrasingContentSchema 8172 }; 8173 piece = deepFilterHTML(piece, filters, blockContentSchema); 8174 piece = (0, import_dom12.removeInvalidHTML)(piece, schema, false); 8175 piece = normaliseBlocks(piece); 8176 piece = deepFilterHTML( 8177 piece, 8178 [ 8179 nonBreakingSpaceCorrector, 8180 htmlFormattingRemover, 8181 formatSpaceCorrector, 8182 brRemover, 8183 emptyParagraphRemover 8184 ], 8185 blockContentSchema 8186 ); 8187 log("Processed HTML piece:\n\n", piece); 8188 return htmlToBlocks(piece, pasteHandler); 8189 }).flat().filter(Boolean); 8190 if (mode === "AUTO" && blocks.length === 1 && hasBlockSupport(blocks[0].name, "__unstablePasteTextInline", false)) { 8191 const trimRegex = /^[\n]+|[\n]+$/g; 8192 const trimmedPlainText = plainText.replace(trimRegex, ""); 8193 if (trimmedPlainText !== "" && trimmedPlainText.indexOf("\n") === -1) { 8194 return (0, import_dom12.removeInvalidHTML)( 8195 getBlockInnerHTML(blocks[0]), 8196 phrasingContentSchema, 8197 false 8198 ).replace(trimRegex, ""); 8199 } 8200 } 8201 return blocks; 8202 } 8203 8204 // packages/blocks/build-module/api/raw-handling/index.mjs 8205 function deprecatedGetPhrasingContentSchema(context) { 8206 (0, import_deprecated11.default)("wp.blocks.getPhrasingContentSchema", { 8207 since: "5.6", 8208 alternative: "wp.dom.getPhrasingContentSchema" 8209 }); 8210 return (0, import_dom13.getPhrasingContentSchema)(context); 8211 } 8212 function rawHandler({ HTML = "" }) { 8213 if (HTML.indexOf("<!-- wp:") !== -1) { 8214 const parseResult = parse2(HTML); 8215 const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === "core/freeform"; 8216 if (!isSingleFreeFormBlock) { 8217 return parseResult; 8218 } 8219 } 8220 const pieces = shortcode_converter_default(HTML); 8221 const blockContentSchema = getBlockContentSchema(); 8222 return pieces.map((piece) => { 8223 if (typeof piece !== "string") { 8224 return piece; 8225 } 8226 const filters = [ 8227 // Needed to adjust invalid lists. 8228 listReducer, 8229 // Needed to create more and nextpage blocks. 8230 specialCommentConverter, 8231 // Needed to create media blocks. 8232 figureContentReducer, 8233 // Needed to create the quote block, which cannot handle text 8234 // without wrapper paragraphs. 8235 blockquoteNormaliser({ raw: true }) 8236 ]; 8237 piece = deepFilterHTML(piece, filters, blockContentSchema); 8238 piece = normaliseBlocks(piece, { raw: true }); 8239 return htmlToBlocks(piece, rawHandler); 8240 }).flat().filter(Boolean); 8241 } 8242 8243 // packages/blocks/build-module/api/categories.mjs 8244 var import_data6 = __toESM(require_data(), 1); 8245 function getCategories2() { 8246 return (0, import_data6.select)(store).getCategories(); 8247 } 8248 function setCategories2(categories2) { 8249 (0, import_data6.dispatch)(store).setCategories(categories2); 8250 } 8251 function updateCategory2(slug, category) { 8252 (0, import_data6.dispatch)(store).updateCategory(slug, category); 8253 } 8254 8255 // packages/blocks/build-module/api/templates.mjs 8256 var import_element4 = __toESM(require_element(), 1); 8257 function doBlocksMatchTemplate(blocks = [], template = []) { 8258 return blocks.length === template.length && template.every(([name, , innerBlocksTemplate], index) => { 8259 const block = blocks[index]; 8260 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); 8261 }); 8262 } 8263 var isHTMLAttribute = (attributeDefinition) => attributeDefinition?.source === "html"; 8264 var isQueryAttribute = (attributeDefinition) => attributeDefinition?.source === "query"; 8265 function normalizeAttributes(schema, values) { 8266 if (!values) { 8267 return {}; 8268 } 8269 return Object.fromEntries( 8270 Object.entries(values).map(([key, value]) => [ 8271 key, 8272 normalizeAttribute(schema[key], value) 8273 ]) 8274 ); 8275 } 8276 function normalizeAttribute(definition, value) { 8277 if (isHTMLAttribute(definition) && Array.isArray(value)) { 8278 return (0, import_element4.renderToString)(value); 8279 } 8280 if (isQueryAttribute(definition) && value) { 8281 return value.map( 8282 (subValues) => { 8283 return normalizeAttributes(definition.query, subValues); 8284 } 8285 ); 8286 } 8287 return value; 8288 } 8289 function synchronizeBlocksWithTemplate(blocks = [], template) { 8290 if (!template) { 8291 return blocks; 8292 } 8293 return template.map( 8294 ([name, attributes, innerBlocksTemplate], index) => { 8295 const block = blocks[index]; 8296 if (block && block.name === name) { 8297 const innerBlocks = synchronizeBlocksWithTemplate( 8298 block.innerBlocks, 8299 innerBlocksTemplate 8300 ); 8301 return { ...block, innerBlocks }; 8302 } 8303 const blockType = getBlockType(name); 8304 const normalizedAttributes = normalizeAttributes( 8305 blockType?.attributes ?? {}, 8306 attributes 8307 ); 8308 const [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes( 8309 name, 8310 normalizedAttributes 8311 ); 8312 return createBlock( 8313 blockName, 8314 blockAttributes, 8315 synchronizeBlocksWithTemplate([], innerBlocksTemplate) 8316 ); 8317 } 8318 ); 8319 } 8320 8321 // packages/blocks/build-module/api/index.mjs 8322 var editableRootKey = /* @__PURE__ */ Symbol("editableRoot"); 8323 var privateApis = {}; 8324 lock(privateApis, { 8325 isContentBlock, 8326 editableRootKey, 8327 parseRawBlock 8328 }); 8329 8330 // packages/blocks/build-module/deprecated.mjs 8331 var import_deprecated12 = __toESM(require_deprecated(), 1); 8332 function withBlockContentContext(OriginalComponent) { 8333 (0, import_deprecated12.default)("wp.blocks.withBlockContentContext", { 8334 since: "6.1" 8335 }); 8336 return OriginalComponent; 8337 } 8338 return __toCommonJS(index_exports); 8339 })(); 8340 /*! Bundled license information: 8341 8342 react-is/cjs/react-is.development.js: 8343 (** 8344 * @license React 8345 * react-is.development.js 8346 * 8347 * Copyright (c) Meta Platforms, Inc. and affiliates. 8348 * 8349 * This source code is licensed under the MIT license found in the 8350 * LICENSE file in the root directory of this source tree. 8351 *) 8352 8353 is-plain-object/dist/is-plain-object.mjs: 8354 (*! 8355 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 8356 * 8357 * Copyright (c) 2014-2017, Jon Schlinkert. 8358 * Released under the MIT License. 8359 *) 8360 */ 8361 (window.wp ||= {}).blocks = wp.blocks; 8362 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Thu Oct 29 08:20:35 2026 | Cross-referenced by PHPXref |