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