PluginProbe
Gutenberg / 23.3.1
Gutenberg v23.3.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / element / index.js

index.js in Gutenberg 23.3.1, at build/scripts/element/index.js

1,100 lines 32.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).element = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // vendor-external:react
36 var require_react = __commonJS({
37 "vendor-external:react"(exports, module) {
38 module.exports = window.React;
39 }
40 });
41
42 // vendor-external:react-dom
43 var require_react_dom = __commonJS({
44 "vendor-external:react-dom"(exports, module) {
45 module.exports = window.ReactDOM;
46 }
47 });
48
49 // vendor-external:react-dom/client
50 var require_client = __commonJS({
51 "vendor-external:react-dom/client"(exports, module) {
52 module.exports = window.ReactDOM;
53 }
54 });
55
56 // package-external:@wordpress/escape-html
57 var require_escape_html = __commonJS({
58 "package-external:@wordpress/escape-html"(exports, module) {
59 module.exports = window.wp.escapeHtml;
60 }
61 });
62
63 // package-external:@wordpress/deprecated
64 var require_deprecated = __commonJS({
65 "package-external:@wordpress/deprecated"(exports, module) {
66 module.exports = window.wp.deprecated;
67 }
68 });
69
70 // packages/element/build-module/index.mjs
71 var index_exports = {};
72 __export(index_exports, {
73 Activity: () => import_react.Activity,
74 Children: () => import_react.Children,
75 Component: () => import_react.Component,
76 Fragment: () => import_react.Fragment,
77 Platform: () => platform_default,
78 PureComponent: () => import_react.PureComponent,
79 RawHTML: () => RawHTML,
80 StrictMode: () => import_react.StrictMode,
81 Suspense: () => import_react.Suspense,
82 cloneElement: () => import_react.cloneElement,
83 concatChildren: () => concatChildren,
84 createContext: () => import_react.createContext,
85 createElement: () => import_react.createElement,
86 createInterpolateElement: () => create_interpolate_element_default,
87 createPortal: () => import_react_dom.createPortal,
88 createRef: () => import_react.createRef,
89 createRoot: () => import_client.createRoot,
90 findDOMNode: () => findDOMNode2,
91 flushSync: () => import_react_dom.flushSync,
92 forwardRef: () => import_react.forwardRef,
93 hydrate: () => hydrate2,
94 hydrateRoot: () => import_client.hydrateRoot,
95 isEmptyElement: () => isEmptyElement,
96 isValidElement: () => import_react.isValidElement,
97 lazy: () => import_react.lazy,
98 memo: () => import_react.memo,
99 preconnect: () => import_react_dom.preconnect,
100 prefetchDNS: () => import_react_dom.prefetchDNS,
101 preinit: () => import_react_dom.preinit,
102 preinitModule: () => import_react_dom.preinitModule,
103 preload: () => import_react_dom.preload,
104 preloadModule: () => import_react_dom.preloadModule,
105 render: () => render2,
106 renderToString: () => serialize_default,
107 startTransition: () => import_react.startTransition,
108 switchChildrenNodeName: () => switchChildrenNodeName,
109 unmountComponentAtNode: () => unmountComponentAtNode2,
110 use: () => import_react.use,
111 useActionState: () => import_react.useActionState,
112 useCallback: () => import_react.useCallback,
113 useContext: () => import_react.useContext,
114 useDebugValue: () => import_react.useDebugValue,
115 useDeferredValue: () => import_react.useDeferredValue,
116 useEffect: () => import_react.useEffect,
117 useEffectEvent: () => import_react.useEffectEvent,
118 useFormStatus: () => import_react_dom.useFormStatus,
119 useId: () => import_react.useId,
120 useImperativeHandle: () => import_react.useImperativeHandle,
121 useInsertionEffect: () => import_react.useInsertionEffect,
122 useLayoutEffect: () => import_react.useLayoutEffect,
123 useMemo: () => import_react.useMemo,
124 useOptimistic: () => import_react.useOptimistic,
125 useReducer: () => import_react.useReducer,
126 useRef: () => import_react.useRef,
127 useState: () => import_react.useState,
128 useSyncExternalStore: () => import_react.useSyncExternalStore,
129 useTransition: () => import_react.useTransition
130 });
131
132 // packages/element/build-module/react.mjs
133 var import_react = __toESM(require_react(), 1);
134 function concatChildren(...childrenArguments) {
135 return childrenArguments.reduce(
136 (accumulator, children, i) => {
137 import_react.Children.forEach(children, (child, j) => {
138 if ((0, import_react.isValidElement)(child) && typeof child !== "string") {
139 child = (0, import_react.cloneElement)(child, {
140 key: [i, j].join()
141 });
142 }
143 accumulator.push(child);
144 });
145 return accumulator;
146 },
147 []
148 );
149 }
150 function switchChildrenNodeName(children, nodeName) {
151 return children && import_react.Children.map(children, (elt, index) => {
152 if (typeof elt?.valueOf() === "string") {
153 return (0, import_react.createElement)(nodeName, { key: index }, elt);
154 }
155 if (!(0, import_react.isValidElement)(elt)) {
156 return elt;
157 }
158 const { children: childrenProp, ...props } = elt.props;
159 return (0, import_react.createElement)(
160 nodeName,
161 { key: index, ...props },
162 childrenProp
163 );
164 });
165 }
166
167 // packages/element/build-module/create-interpolate-element.mjs
168 var indoc;
169 var offset;
170 var output;
171 var stack;
172 var tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
173 function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
174 return {
175 element,
176 tokenStart,
177 tokenLength,
178 prevOffset,
179 leadingTextStart,
180 children: []
181 };
182 }
183 function createInterpolateElement(interpolatedString, conversionMap) {
184 indoc = interpolatedString;
185 offset = 0;
186 output = [];
187 stack = [];
188 tokenizer.lastIndex = 0;
189 if (!isValidConversionMap(conversionMap)) {
190 throw new TypeError(
191 "The conversionMap provided is not valid. It must be an object with values that are React Elements"
192 );
193 }
194 do {
195 } while (proceed(conversionMap));
196 return (0, import_react.createElement)(import_react.Fragment, null, ...output);
197 }
198 var isValidConversionMap = (conversionMap) => {
199 const isObject2 = typeof conversionMap === "object" && conversionMap !== null;
200 const values = isObject2 && Object.values(conversionMap);
201 return isObject2 && values.length > 0 && values.every((element) => (0, import_react.isValidElement)(element));
202 };
203 function proceed(conversionMap) {
204 const next = nextToken();
205 const [tokenType, name, startOffset, tokenLength] = next;
206 const stackDepth = stack.length;
207 const leadingTextStart = startOffset > offset ? offset : null;
208 if (name && !conversionMap[name]) {
209 addText();
210 return false;
211 }
212 switch (tokenType) {
213 case "no-more-tokens":
214 if (stackDepth !== 0) {
215 const { leadingTextStart: stackLeadingText, tokenStart } = stack.pop();
216 output.push(indoc.substr(stackLeadingText, tokenStart));
217 }
218 addText();
219 return false;
220 case "self-closed":
221 if (0 === stackDepth) {
222 if (null !== leadingTextStart) {
223 output.push(
224 indoc.substr(
225 leadingTextStart,
226 startOffset - leadingTextStart
227 )
228 );
229 }
230 output.push(conversionMap[name]);
231 offset = startOffset + tokenLength;
232 return true;
233 }
234 addChild(
235 createFrame(conversionMap[name], startOffset, tokenLength)
236 );
237 offset = startOffset + tokenLength;
238 return true;
239 case "opener":
240 stack.push(
241 createFrame(
242 conversionMap[name],
243 startOffset,
244 tokenLength,
245 startOffset + tokenLength,
246 leadingTextStart
247 )
248 );
249 offset = startOffset + tokenLength;
250 return true;
251 case "closer":
252 if (1 === stackDepth) {
253 closeOuterElement(startOffset);
254 offset = startOffset + tokenLength;
255 return true;
256 }
257 const stackTop = stack.pop();
258 const text = indoc.substr(
259 stackTop.prevOffset,
260 startOffset - stackTop.prevOffset
261 );
262 stackTop.children.push(text);
263 stackTop.prevOffset = startOffset + tokenLength;
264 const frame = createFrame(
265 stackTop.element,
266 stackTop.tokenStart,
267 stackTop.tokenLength,
268 startOffset + tokenLength
269 );
270 frame.children = stackTop.children;
271 addChild(frame);
272 offset = startOffset + tokenLength;
273 return true;
274 default:
275 addText();
276 return false;
277 }
278 }
279 function nextToken() {
280 const matches = tokenizer.exec(indoc);
281 if (null === matches) {
282 return ["no-more-tokens"];
283 }
284 const startedAt = matches.index;
285 const [match, isClosing, name, isSelfClosed] = matches;
286 const length = match.length;
287 if (isSelfClosed) {
288 return ["self-closed", name, startedAt, length];
289 }
290 if (isClosing) {
291 return ["closer", name, startedAt, length];
292 }
293 return ["opener", name, startedAt, length];
294 }
295 function addText() {
296 const length = indoc.length - offset;
297 if (0 === length) {
298 return;
299 }
300 output.push(indoc.substr(offset, length));
301 }
302 function addChild(frame) {
303 const { element, tokenStart, tokenLength, prevOffset, children } = frame;
304 const parent = stack[stack.length - 1];
305 const text = indoc.substr(
306 parent.prevOffset,
307 tokenStart - parent.prevOffset
308 );
309 if (text) {
310 parent.children.push(text);
311 }
312 parent.children.push((0, import_react.cloneElement)(element, null, ...children));
313 parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
314 }
315 function closeOuterElement(endOffset) {
316 const { element, leadingTextStart, prevOffset, tokenStart, children } = stack.pop();
317 const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
318 if (text) {
319 children.push(text);
320 }
321 if (null !== leadingTextStart) {
322 output.push(
323 indoc.substr(leadingTextStart, tokenStart - leadingTextStart)
324 );
325 }
326 output.push((0, import_react.cloneElement)(element, null, ...children));
327 }
328 var create_interpolate_element_default = createInterpolateElement;
329
330 // packages/element/build-module/react-platform.mjs
331 var import_react_dom = __toESM(require_react_dom(), 1);
332 var import_client = __toESM(require_client(), 1);
333
334 // packages/element/build-module/utils.mjs
335 var isEmptyElement = (element) => {
336 if (typeof element === "number") {
337 return false;
338 }
339 if (typeof element?.valueOf() === "string" || Array.isArray(element)) {
340 return !element.length;
341 }
342 return !element;
343 };
344
345 // packages/element/build-module/platform.mjs
346 var Platform = {
347 /** Platform identifier. Will always be `'web'` in this module. */
348 OS: "web",
349 /**
350 * Select a value based on the platform.
351 *
352 * @template T
353 * @param spec - Object with optional platform-specific values.
354 * @return The selected value.
355 */
356 select(spec) {
357 return "web" in spec ? spec.web : spec.default;
358 },
359 /** Whether the platform is web */
360 isWeb: true
361 };
362 var platform_default = Platform;
363
364 // node_modules/is-plain-object/dist/is-plain-object.mjs
365 function isObject(o) {
366 return Object.prototype.toString.call(o) === "[object Object]";
367 }
368 function isPlainObject(o) {
369 var ctor, prot;
370 if (isObject(o) === false) return false;
371 ctor = o.constructor;
372 if (ctor === void 0) return true;
373 prot = ctor.prototype;
374 if (isObject(prot) === false) return false;
375 if (prot.hasOwnProperty("isPrototypeOf") === false) {
376 return false;
377 }
378 return true;
379 }
380
381 // node_modules/tslib/tslib.es6.mjs
382 var __assign = function() {
383 __assign = Object.assign || function __assign2(t) {
384 for (var s, i = 1, n = arguments.length; i < n; i++) {
385 s = arguments[i];
386 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
387 }
388 return t;
389 };
390 return __assign.apply(this, arguments);
391 };
392
393 // node_modules/lower-case/dist.es2015/index.js
394 function lowerCase(str) {
395 return str.toLowerCase();
396 }
397
398 // node_modules/no-case/dist.es2015/index.js
399 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
400 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
401 function noCase(input, options) {
402 if (options === void 0) {
403 options = {};
404 }
405 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;
406 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
407 var start = 0;
408 var end = result.length;
409 while (result.charAt(start) === "\0")
410 start++;
411 while (result.charAt(end - 1) === "\0")
412 end--;
413 return result.slice(start, end).split("\0").map(transform).join(delimiter);
414 }
415 function replace(input, re, value) {
416 if (re instanceof RegExp)
417 return input.replace(re, value);
418 return re.reduce(function(input2, re2) {
419 return input2.replace(re2, value);
420 }, input);
421 }
422
423 // node_modules/dot-case/dist.es2015/index.js
424 function dotCase(input, options) {
425 if (options === void 0) {
426 options = {};
427 }
428 return noCase(input, __assign({ delimiter: "." }, options));
429 }
430
431 // node_modules/param-case/dist.es2015/index.js
432 function paramCase(input, options) {
433 if (options === void 0) {
434 options = {};
435 }
436 return dotCase(input, __assign({ delimiter: "-" }, options));
437 }
438
439 // packages/element/build-module/serialize.mjs
440 var import_escape_html = __toESM(require_escape_html(), 1);
441
442 // packages/element/build-module/raw-html.mjs
443 function RawHTML({ children, ...props }) {
444 let rawHtml = "";
445 import_react.Children.toArray(children).forEach((child) => {
446 if (typeof child === "string" && child.trim() !== "") {
447 rawHtml += child;
448 }
449 });
450 return (0, import_react.createElement)("div", {
451 dangerouslySetInnerHTML: { __html: rawHtml },
452 ...props
453 });
454 }
455
456 // packages/element/build-module/serialize.mjs
457 var Context = (0, import_react.createContext)(void 0);
458 Context.displayName = "ElementContext";
459 var { Provider, Consumer } = Context;
460 var ForwardRef = (0, import_react.forwardRef)(() => {
461 return null;
462 });
463 var ATTRIBUTES_TYPES = /* @__PURE__ */ new Set(["string", "boolean", "number"]);
464 var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
465 "area",
466 "base",
467 "br",
468 "col",
469 "command",
470 "embed",
471 "hr",
472 "img",
473 "input",
474 "keygen",
475 "link",
476 "meta",
477 "param",
478 "source",
479 "track",
480 "wbr"
481 ]);
482 var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
483 "allowfullscreen",
484 "allowpaymentrequest",
485 "allowusermedia",
486 "async",
487 "autofocus",
488 "autoplay",
489 "checked",
490 "controls",
491 "default",
492 "defer",
493 "disabled",
494 "download",
495 "formnovalidate",
496 "hidden",
497 "ismap",
498 "itemscope",
499 "loop",
500 "multiple",
501 "muted",
502 "nomodule",
503 "novalidate",
504 "open",
505 "playsinline",
506 "readonly",
507 "required",
508 "reversed",
509 "selected",
510 "typemustmatch"
511 ]);
512 var ENUMERATED_ATTRIBUTES = /* @__PURE__ */ new Set([
513 "autocapitalize",
514 "autocomplete",
515 "charset",
516 "contenteditable",
517 "crossorigin",
518 "decoding",
519 "dir",
520 "draggable",
521 "enctype",
522 "formenctype",
523 "formmethod",
524 "http-equiv",
525 "inputmode",
526 "kind",
527 "method",
528 "preload",
529 "scope",
530 "shape",
531 "spellcheck",
532 "translate",
533 "type",
534 "wrap"
535 ]);
536 var CSS_PROPERTIES_SUPPORTS_UNITLESS = /* @__PURE__ */ new Set([
537 "animation",
538 "animationIterationCount",
539 "baselineShift",
540 "borderImageOutset",
541 "borderImageSlice",
542 "borderImageWidth",
543 "columnCount",
544 "cx",
545 "cy",
546 "fillOpacity",
547 "flexGrow",
548 "flexShrink",
549 "floodOpacity",
550 "fontWeight",
551 "gridColumnEnd",
552 "gridColumnStart",
553 "gridRowEnd",
554 "gridRowStart",
555 "lineHeight",
556 "opacity",
557 "order",
558 "orphans",
559 "r",
560 "rx",
561 "ry",
562 "shapeImageThreshold",
563 "stopOpacity",
564 "strokeDasharray",
565 "strokeDashoffset",
566 "strokeMiterlimit",
567 "strokeOpacity",
568 "strokeWidth",
569 "tabSize",
570 "widows",
571 "x",
572 "y",
573 "zIndex",
574 "zoom"
575 ]);
576 function hasPrefix(string, prefixes) {
577 return prefixes.some((prefix) => string.indexOf(prefix) === 0);
578 }
579 function isInternalAttribute(attribute) {
580 return "key" === attribute || "children" === attribute;
581 }
582 function getNormalAttributeValue(attribute, value) {
583 switch (attribute) {
584 case "style":
585 return renderStyle(value);
586 }
587 return value;
588 }
589 var SVG_ATTRIBUTE_WITH_DASHES_LIST = [
590 "accentHeight",
591 "alignmentBaseline",
592 "arabicForm",
593 "baselineShift",
594 "capHeight",
595 "clipPath",
596 "clipRule",
597 "colorInterpolation",
598 "colorInterpolationFilters",
599 "colorProfile",
600 "colorRendering",
601 "dominantBaseline",
602 "enableBackground",
603 "fillOpacity",
604 "fillRule",
605 "floodColor",
606 "floodOpacity",
607 "fontFamily",
608 "fontSize",
609 "fontSizeAdjust",
610 "fontStretch",
611 "fontStyle",
612 "fontVariant",
613 "fontWeight",
614 "glyphName",
615 "glyphOrientationHorizontal",
616 "glyphOrientationVertical",
617 "horizAdvX",
618 "horizOriginX",
619 "imageRendering",
620 "letterSpacing",
621 "lightingColor",
622 "markerEnd",
623 "markerMid",
624 "markerStart",
625 "overlinePosition",
626 "overlineThickness",
627 "paintOrder",
628 "panose1",
629 "pointerEvents",
630 "renderingIntent",
631 "shapeRendering",
632 "stopColor",
633 "stopOpacity",
634 "strikethroughPosition",
635 "strikethroughThickness",
636 "strokeDasharray",
637 "strokeDashoffset",
638 "strokeLinecap",
639 "strokeLinejoin",
640 "strokeMiterlimit",
641 "strokeOpacity",
642 "strokeWidth",
643 "textAnchor",
644 "textDecoration",
645 "textRendering",
646 "underlinePosition",
647 "underlineThickness",
648 "unicodeBidi",
649 "unicodeRange",
650 "unitsPerEm",
651 "vAlphabetic",
652 "vHanging",
653 "vIdeographic",
654 "vMathematical",
655 "vectorEffect",
656 "vertAdvY",
657 "vertOriginX",
658 "vertOriginY",
659 "wordSpacing",
660 "writingMode",
661 "xmlnsXlink",
662 "xHeight"
663 ].reduce(
664 (map, attribute) => {
665 map[attribute.toLowerCase()] = attribute;
666 return map;
667 },
668 {}
669 );
670 var CASE_SENSITIVE_SVG_ATTRIBUTES = [
671 "allowReorder",
672 "attributeName",
673 "attributeType",
674 "autoReverse",
675 "baseFrequency",
676 "baseProfile",
677 "calcMode",
678 "clipPathUnits",
679 "contentScriptType",
680 "contentStyleType",
681 "diffuseConstant",
682 "edgeMode",
683 "externalResourcesRequired",
684 "filterRes",
685 "filterUnits",
686 "glyphRef",
687 "gradientTransform",
688 "gradientUnits",
689 "kernelMatrix",
690 "kernelUnitLength",
691 "keyPoints",
692 "keySplines",
693 "keyTimes",
694 "lengthAdjust",
695 "limitingConeAngle",
696 "markerHeight",
697 "markerUnits",
698 "markerWidth",
699 "maskContentUnits",
700 "maskUnits",
701 "numOctaves",
702 "pathLength",
703 "patternContentUnits",
704 "patternTransform",
705 "patternUnits",
706 "pointsAtX",
707 "pointsAtY",
708 "pointsAtZ",
709 "preserveAlpha",
710 "preserveAspectRatio",
711 "primitiveUnits",
712 "refX",
713 "refY",
714 "repeatCount",
715 "repeatDur",
716 "requiredExtensions",
717 "requiredFeatures",
718 "specularConstant",
719 "specularExponent",
720 "spreadMethod",
721 "startOffset",
722 "stdDeviation",
723 "stitchTiles",
724 "suppressContentEditableWarning",
725 "suppressHydrationWarning",
726 "surfaceScale",
727 "systemLanguage",
728 "tableValues",
729 "targetX",
730 "targetY",
731 "textLength",
732 "viewBox",
733 "viewTarget",
734 "xChannelSelector",
735 "yChannelSelector"
736 ].reduce(
737 (map, attribute) => {
738 map[attribute.toLowerCase()] = attribute;
739 return map;
740 },
741 {}
742 );
743 var SVG_ATTRIBUTES_WITH_COLONS = [
744 "xlink:actuate",
745 "xlink:arcrole",
746 "xlink:href",
747 "xlink:role",
748 "xlink:show",
749 "xlink:title",
750 "xlink:type",
751 "xml:base",
752 "xml:lang",
753 "xml:space",
754 "xmlns:xlink"
755 ].reduce(
756 (map, attribute) => {
757 map[attribute.replace(":", "").toLowerCase()] = attribute;
758 return map;
759 },
760 {}
761 );
762 function getNormalAttributeName(attribute) {
763 switch (attribute) {
764 case "htmlFor":
765 return "for";
766 case "className":
767 return "class";
768 }
769 const attributeLowerCase = attribute.toLowerCase();
770 if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
771 return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
772 } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
773 return paramCase(
774 SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]
775 );
776 } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
777 return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
778 }
779 return attributeLowerCase;
780 }
781 function getNormalStylePropertyName(property) {
782 if (property.startsWith("--")) {
783 return property;
784 }
785 if (hasPrefix(property, ["ms", "O", "Moz", "Webkit"])) {
786 return "-" + paramCase(property);
787 }
788 return paramCase(property);
789 }
790 function getNormalStylePropertyValue(property, value) {
791 if (typeof value === "number" && 0 !== value && !hasPrefix(property, ["--"]) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
792 return value + "px";
793 }
794 return value;
795 }
796 function renderElement(element, context, legacyContext = {}) {
797 if (null === element || void 0 === element || false === element) {
798 return "";
799 }
800 if (Array.isArray(element)) {
801 return renderChildren(element, context, legacyContext);
802 }
803 switch (typeof element) {
804 case "string":
805 return (0, import_escape_html.escapeHTML)(element);
806 case "number":
807 return element.toString();
808 }
809 const { type, props } = element;
810 switch (type) {
811 case import_react.StrictMode:
812 case import_react.Fragment:
813 return renderChildren(props.children, context, legacyContext);
814 case RawHTML:
815 const { children, ...wrapperProps } = props;
816 return renderNativeComponent(
817 !Object.keys(wrapperProps).length ? null : "div",
818 {
819 ...wrapperProps,
820 dangerouslySetInnerHTML: { __html: children }
821 },
822 context,
823 legacyContext
824 );
825 }
826 switch (typeof type) {
827 case "string":
828 return renderNativeComponent(type, props, context, legacyContext);
829 case "function":
830 if (type.prototype && typeof type.prototype.render === "function") {
831 return renderComponent(type, props, context, legacyContext);
832 }
833 return renderElement(
834 type(props, legacyContext),
835 context,
836 legacyContext
837 );
838 }
839 switch (type && type.$$typeof) {
840 case Provider.$$typeof:
841 return renderChildren(props.children, props.value, legacyContext);
842 case Consumer.$$typeof:
843 return renderElement(
844 props.children(
845 context || type._currentValue || type._context._currentValue
846 ),
847 context,
848 legacyContext
849 );
850 case ForwardRef.$$typeof:
851 return renderElement(
852 type.render(props),
853 context,
854 legacyContext
855 );
856 }
857 return "";
858 }
859 function renderNativeComponent(type, props, context, legacyContext = {}) {
860 let content = "";
861 if (type === "textarea" && props.hasOwnProperty("value")) {
862 content = renderChildren(props.value, context, legacyContext);
863 const { value, ...restProps } = props;
864 props = restProps;
865 } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === "string") {
866 content = props.dangerouslySetInnerHTML.__html;
867 } else if (typeof props.children !== "undefined") {
868 content = renderChildren(props.children, context, legacyContext);
869 }
870 if (!type) {
871 return content;
872 }
873 const attributes = renderAttributes(props);
874 if (SELF_CLOSING_TAGS.has(type)) {
875 return "<" + type + attributes + "/>";
876 }
877 return "<" + type + attributes + ">" + content + "</" + type + ">";
878 }
879 function renderComponent(Component2, props, context, legacyContext = {}) {
880 const instance = new Component2(props, legacyContext);
881 if (typeof instance.getChildContext === "function") {
882 Object.assign(legacyContext, instance.getChildContext());
883 }
884 const html = renderElement(instance.render(), context, legacyContext);
885 return html;
886 }
887 function renderChildren(children, context, legacyContext = {}) {
888 let result = "";
889 const childrenArray = Array.isArray(children) ? children : [children];
890 for (let i = 0; i < childrenArray.length; i++) {
891 const child = childrenArray[i];
892 result += renderElement(child, context, legacyContext);
893 }
894 return result;
895 }
896 function renderAttributes(props) {
897 let result = "";
898 for (const key in props) {
899 const attribute = getNormalAttributeName(key);
900 if (!(0, import_escape_html.isValidAttributeName)(attribute)) {
901 continue;
902 }
903 let value = getNormalAttributeValue(key, props[key]);
904 if (!ATTRIBUTES_TYPES.has(typeof value)) {
905 continue;
906 }
907 if (isInternalAttribute(key)) {
908 continue;
909 }
910 const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
911 if (isBooleanAttribute && value === false) {
912 continue;
913 }
914 const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ["data-", "aria-"]) || ENUMERATED_ATTRIBUTES.has(attribute);
915 if (typeof value === "boolean" && !isMeaningfulAttribute) {
916 continue;
917 }
918 result += " " + attribute;
919 if (isBooleanAttribute) {
920 continue;
921 }
922 if (typeof value === "string") {
923 value = (0, import_escape_html.escapeAttribute)(value);
924 }
925 result += '="' + value + '"';
926 }
927 return result;
928 }
929 function renderStyle(style) {
930 if (!isPlainObject(style)) {
931 return style;
932 }
933 let result;
934 const styleObj = style;
935 for (const property in styleObj) {
936 const value = styleObj[property];
937 if (null === value || void 0 === value) {
938 continue;
939 }
940 if (result) {
941 result += ";";
942 } else {
943 result = "";
944 }
945 const normalName = getNormalStylePropertyName(property);
946 const normalValue = getNormalStylePropertyValue(property, value);
947 result += normalName + ":" + normalValue;
948 }
949 return result;
950 }
951 var serialize_default = renderElement;
952
953 // packages/element/build-module/react-polyfill.mjs
954 var import_deprecated = __toESM(require_deprecated(), 1);
955
956 // packages/element/build-module/react-polyfill-base.mjs
957 var import_react_dom2 = __toESM(require_react_dom(), 1);
958 var import_client2 = __toESM(require_client(), 1);
959 var internalsKey = "_reactInternals";
960 var HostComponent = 5;
961 var HostText = 6;
962 function findCurrentFiber(fiber) {
963 if (!fiber.alternate) {
964 return fiber;
965 }
966 let node = fiber;
967 while (node.return) {
968 node = node.return;
969 }
970 if (node.stateNode.current === node) {
971 return fiber;
972 }
973 return fiber.alternate;
974 }
975 function findHostFiber(fiber) {
976 const current = findCurrentFiber(fiber);
977 if (!current) {
978 return null;
979 }
980 return findHostFiberImpl(current);
981 }
982 function findHostFiberImpl(fiber) {
983 if (fiber.tag === HostComponent || fiber.tag === HostText) {
984 return fiber;
985 }
986 let child = fiber.child;
987 while (child) {
988 const hostFiber = findHostFiberImpl(child);
989 if (hostFiber) {
990 return hostFiber;
991 }
992 child = child.sibling;
993 }
994 return null;
995 }
996 function findDOMNode(instance) {
997 if (instance === null || instance === void 0) {
998 return null;
999 }
1000 if (instance.nodeType !== void 0) {
1001 return instance;
1002 }
1003 const fiber = instance[internalsKey];
1004 if (fiber === void 0) {
1005 if (typeof instance.render === "function") {
1006 throw new Error("Unable to find node on an unmounted component.");
1007 }
1008 const keys = Object.keys(instance).join(",");
1009 throw new Error(
1010 `Argument appears to not be a ReactComponent. Keys: ${keys}`
1011 );
1012 }
1013 const hostFiber = findHostFiber(fiber);
1014 return hostFiber?.stateNode ?? null;
1015 }
1016 var roots = /* @__PURE__ */ new WeakMap();
1017 function render(element, container, callback) {
1018 let root = roots.get(container);
1019 if (!root) {
1020 root = (0, import_client2.createRoot)(container);
1021 roots.set(container, root);
1022 }
1023 (0, import_react_dom2.flushSync)(() => {
1024 root.render(element);
1025 });
1026 if (typeof callback === "function") {
1027 callback();
1028 }
1029 }
1030 function hydrate(element, container, callback) {
1031 let root = roots.get(container);
1032 if (!root) {
1033 root = (0, import_client2.hydrateRoot)(container, element);
1034 roots.set(container, root);
1035 } else {
1036 root.render(element);
1037 }
1038 if (typeof callback === "function") {
1039 callback();
1040 }
1041 }
1042 function unmountComponentAtNode(container) {
1043 const root = roots.get(container);
1044 if (!root) {
1045 return false;
1046 }
1047 (0, import_react_dom2.flushSync)(() => {
1048 root.unmount();
1049 });
1050 roots.delete(container);
1051 return true;
1052 }
1053
1054 // packages/element/build-module/react-polyfill.mjs
1055 function findDOMNode2(instance) {
1056 (0, import_deprecated.default)("wp.element.findDOMNode", {
1057 since: "7.1",
1058 alternative: "DOM refs",
1059 link: "https://react.dev/reference/react-dom/findDOMNode"
1060 });
1061 return findDOMNode(instance);
1062 }
1063 function render2(element, container, callback) {
1064 (0, import_deprecated.default)("wp.element.render", {
1065 since: "6.2",
1066 alternative: "wp.element.createRoot",
1067 link: "https://react.dev/reference/react-dom/client/createRoot"
1068 });
1069 render(element, container, callback);
1070 }
1071 function hydrate2(element, container, callback) {
1072 (0, import_deprecated.default)("wp.element.hydrate", {
1073 since: "6.2",
1074 alternative: "wp.element.hydrateRoot",
1075 link: "https://react.dev/reference/react-dom/client/hydrateRoot"
1076 });
1077 hydrate(element, container, callback);
1078 }
1079 function unmountComponentAtNode2(container) {
1080 (0, import_deprecated.default)("wp.element.unmountComponentAtNode", {
1081 since: "6.2",
1082 alternative: "root.unmount()",
1083 link: "https://react.dev/reference/react-dom/client/createRoot#root-unmount"
1084 });
1085 return unmountComponentAtNode(container);
1086 }
1087 return __toCommonJS(index_exports);
1088 })();
1089 /*! Bundled license information:
1090
1091 is-plain-object/dist/is-plain-object.mjs:
1092 (*!
1093 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
1094 *
1095 * Copyright (c) 2014-2017, Jon Schlinkert.
1096 * Released under the MIT License.
1097 *)
1098 */
1099 //# sourceMappingURL=index.js.map
1100