PluginProbe
Gutenberg / 18.9.0
Gutenberg v18.9.0
24.0.0 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 All 403 releases
gutenberg / build / element / index.js

index.js in Gutenberg 18.9.0, at build/element/index.js

1,899 lines 65.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ 4470:
6 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7
8
9
10 var m = __webpack_require__(1850);
11 if (true) {
12 exports.s = m.createRoot;
13 exports.a = m.hydrateRoot;
14 } else { var i; }
15
16
17 /***/ }),
18
19 /***/ 1850:
20 /***/ ((module) => {
21
22 module.exports = window["ReactDOM"];
23
24 /***/ })
25
26 /******/ });
27 /************************************************************************/
28 /******/ // The module cache
29 /******/ var __webpack_module_cache__ = {};
30 /******/
31 /******/ // The require function
32 /******/ function __webpack_require__(moduleId) {
33 /******/ // Check if module is in cache
34 /******/ var cachedModule = __webpack_module_cache__[moduleId];
35 /******/ if (cachedModule !== undefined) {
36 /******/ return cachedModule.exports;
37 /******/ }
38 /******/ // Create a new module (and put it into the cache)
39 /******/ var module = __webpack_module_cache__[moduleId] = {
40 /******/ // no module.id needed
41 /******/ // no module.loaded needed
42 /******/ exports: {}
43 /******/ };
44 /******/
45 /******/ // Execute the module function
46 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
47 /******/
48 /******/ // Return the exports of the module
49 /******/ return module.exports;
50 /******/ }
51 /******/
52 /************************************************************************/
53 /******/ /* webpack/runtime/define property getters */
54 /******/ (() => {
55 /******/ // define getter functions for harmony exports
56 /******/ __webpack_require__.d = (exports, definition) => {
57 /******/ for(var key in definition) {
58 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
59 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
60 /******/ }
61 /******/ }
62 /******/ };
63 /******/ })();
64 /******/
65 /******/ /* webpack/runtime/hasOwnProperty shorthand */
66 /******/ (() => {
67 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
68 /******/ })();
69 /******/
70 /******/ /* webpack/runtime/make namespace object */
71 /******/ (() => {
72 /******/ // define __esModule on exports
73 /******/ __webpack_require__.r = (exports) => {
74 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
75 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
76 /******/ }
77 /******/ Object.defineProperty(exports, '__esModule', { value: true });
78 /******/ };
79 /******/ })();
80 /******/
81 /************************************************************************/
82 var __webpack_exports__ = {};
83 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
84 (() => {
85 // ESM COMPAT FLAG
86 __webpack_require__.r(__webpack_exports__);
87
88 // EXPORTS
89 __webpack_require__.d(__webpack_exports__, {
90 Children: () => (/* reexport */ external_React_namespaceObject.Children),
91 Component: () => (/* reexport */ external_React_namespaceObject.Component),
92 Fragment: () => (/* reexport */ external_React_namespaceObject.Fragment),
93 Platform: () => (/* reexport */ platform),
94 PureComponent: () => (/* reexport */ external_React_namespaceObject.PureComponent),
95 RawHTML: () => (/* reexport */ RawHTML),
96 StrictMode: () => (/* reexport */ external_React_namespaceObject.StrictMode),
97 Suspense: () => (/* reexport */ external_React_namespaceObject.Suspense),
98 cloneElement: () => (/* reexport */ external_React_namespaceObject.cloneElement),
99 concatChildren: () => (/* reexport */ concatChildren),
100 createContext: () => (/* reexport */ external_React_namespaceObject.createContext),
101 createElement: () => (/* reexport */ external_React_namespaceObject.createElement),
102 createInterpolateElement: () => (/* reexport */ create_interpolate_element),
103 createPortal: () => (/* reexport */ external_ReactDOM_.createPortal),
104 createRef: () => (/* reexport */ external_React_namespaceObject.createRef),
105 createRoot: () => (/* reexport */ client/* createRoot */.s),
106 findDOMNode: () => (/* reexport */ external_ReactDOM_.findDOMNode),
107 flushSync: () => (/* reexport */ external_ReactDOM_.flushSync),
108 forwardRef: () => (/* reexport */ external_React_namespaceObject.forwardRef),
109 hydrate: () => (/* reexport */ external_ReactDOM_.hydrate),
110 hydrateRoot: () => (/* reexport */ client/* hydrateRoot */.a),
111 isEmptyElement: () => (/* reexport */ isEmptyElement),
112 isValidElement: () => (/* reexport */ external_React_namespaceObject.isValidElement),
113 lazy: () => (/* reexport */ external_React_namespaceObject.lazy),
114 memo: () => (/* reexport */ external_React_namespaceObject.memo),
115 render: () => (/* reexport */ external_ReactDOM_.render),
116 renderToString: () => (/* reexport */ serialize),
117 startTransition: () => (/* reexport */ external_React_namespaceObject.startTransition),
118 switchChildrenNodeName: () => (/* reexport */ switchChildrenNodeName),
119 unmountComponentAtNode: () => (/* reexport */ external_ReactDOM_.unmountComponentAtNode),
120 useCallback: () => (/* reexport */ external_React_namespaceObject.useCallback),
121 useContext: () => (/* reexport */ external_React_namespaceObject.useContext),
122 useDebugValue: () => (/* reexport */ external_React_namespaceObject.useDebugValue),
123 useDeferredValue: () => (/* reexport */ external_React_namespaceObject.useDeferredValue),
124 useEffect: () => (/* reexport */ external_React_namespaceObject.useEffect),
125 useId: () => (/* reexport */ external_React_namespaceObject.useId),
126 useImperativeHandle: () => (/* reexport */ external_React_namespaceObject.useImperativeHandle),
127 useInsertionEffect: () => (/* reexport */ external_React_namespaceObject.useInsertionEffect),
128 useLayoutEffect: () => (/* reexport */ external_React_namespaceObject.useLayoutEffect),
129 useMemo: () => (/* reexport */ external_React_namespaceObject.useMemo),
130 useReducer: () => (/* reexport */ external_React_namespaceObject.useReducer),
131 useRef: () => (/* reexport */ external_React_namespaceObject.useRef),
132 useState: () => (/* reexport */ external_React_namespaceObject.useState),
133 useSyncExternalStore: () => (/* reexport */ external_React_namespaceObject.useSyncExternalStore),
134 useTransition: () => (/* reexport */ external_React_namespaceObject.useTransition)
135 });
136
137 ;// CONCATENATED MODULE: external "React"
138 const external_React_namespaceObject = window["React"];
139 ;// CONCATENATED MODULE: ./packages/element/build-module/create-interpolate-element.js
140 /**
141 * Internal dependencies
142 */
143
144
145 /**
146 * Object containing a React element.
147 *
148 * @typedef {import('react').ReactElement} Element
149 */
150
151 let indoc, offset, output, stack;
152
153 /**
154 * Matches tags in the localized string
155 *
156 * This is used for extracting the tag pattern groups for parsing the localized
157 * string and along with the map converting it to a react element.
158 *
159 * There are four references extracted using this tokenizer:
160 *
161 * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)
162 * isClosing: The closing slash, if it exists.
163 * name: The name portion of the tag (strong, br) (if )
164 * isSelfClosed: The slash on a self closing tag, if it exists.
165 *
166 * @type {RegExp}
167 */
168 const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
169
170 /**
171 * The stack frame tracking parse progress.
172 *
173 * @typedef Frame
174 *
175 * @property {Element} element A parent element which may still have
176 * @property {number} tokenStart Offset at which parent element first
177 * appears.
178 * @property {number} tokenLength Length of string marking start of parent
179 * element.
180 * @property {number} [prevOffset] Running offset at which parsing should
181 * continue.
182 * @property {number} [leadingTextStart] Offset at which last closing element
183 * finished, used for finding text between
184 * elements.
185 * @property {Element[]} children Children.
186 */
187
188 /**
189 * Tracks recursive-descent parse state.
190 *
191 * This is a Stack frame holding parent elements until all children have been
192 * parsed.
193 *
194 * @private
195 * @param {Element} element A parent element which may still have
196 * nested children not yet parsed.
197 * @param {number} tokenStart Offset at which parent element first
198 * appears.
199 * @param {number} tokenLength Length of string marking start of parent
200 * element.
201 * @param {number} [prevOffset] Running offset at which parsing should
202 * continue.
203 * @param {number} [leadingTextStart] Offset at which last closing element
204 * finished, used for finding text between
205 * elements.
206 *
207 * @return {Frame} The stack frame tracking parse progress.
208 */
209 function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
210 return {
211 element,
212 tokenStart,
213 tokenLength,
214 prevOffset,
215 leadingTextStart,
216 children: []
217 };
218 }
219
220 /**
221 * This function creates an interpolated element from a passed in string with
222 * specific tags matching how the string should be converted to an element via
223 * the conversion map value.
224 *
225 * @example
226 * For example, for the given string:
227 *
228 * "This is a <span>string</span> with <a>a link</a> and a self-closing
229 * <CustomComponentB/> tag"
230 *
231 * You would have something like this as the conversionMap value:
232 *
233 * ```js
234 * {
235 * span: <span />,
236 * a: <a href={ 'https://github.com' } />,
237 * CustomComponentB: <CustomComponent />,
238 * }
239 * ```
240 *
241 * @param {string} interpolatedString The interpolation string to be parsed.
242 * @param {Record<string, Element>} conversionMap The map used to convert the string to
243 * a react element.
244 * @throws {TypeError}
245 * @return {Element} A wp element.
246 */
247 const createInterpolateElement = (interpolatedString, conversionMap) => {
248 indoc = interpolatedString;
249 offset = 0;
250 output = [];
251 stack = [];
252 tokenizer.lastIndex = 0;
253 if (!isValidConversionMap(conversionMap)) {
254 throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are React Elements');
255 }
256 do {
257 // twiddle our thumbs
258 } while (proceed(conversionMap));
259 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, ...output);
260 };
261
262 /**
263 * Validate conversion map.
264 *
265 * A map is considered valid if it's an object and every value in the object
266 * is a React Element
267 *
268 * @private
269 *
270 * @param {Object} conversionMap The map being validated.
271 *
272 * @return {boolean} True means the map is valid.
273 */
274 const isValidConversionMap = conversionMap => {
275 const isObject = typeof conversionMap === 'object';
276 const values = isObject && Object.values(conversionMap);
277 return isObject && values.length && values.every(element => (0,external_React_namespaceObject.isValidElement)(element));
278 };
279
280 /**
281 * This is the iterator over the matches in the string.
282 *
283 * @private
284 *
285 * @param {Object} conversionMap The conversion map for the string.
286 *
287 * @return {boolean} true for continuing to iterate, false for finished.
288 */
289 function proceed(conversionMap) {
290 const next = nextToken();
291 const [tokenType, name, startOffset, tokenLength] = next;
292 const stackDepth = stack.length;
293 const leadingTextStart = startOffset > offset ? offset : null;
294 if (!conversionMap[name]) {
295 addText();
296 return false;
297 }
298 switch (tokenType) {
299 case 'no-more-tokens':
300 if (stackDepth !== 0) {
301 const {
302 leadingTextStart: stackLeadingText,
303 tokenStart
304 } = stack.pop();
305 output.push(indoc.substr(stackLeadingText, tokenStart));
306 }
307 addText();
308 return false;
309 case 'self-closed':
310 if (0 === stackDepth) {
311 if (null !== leadingTextStart) {
312 output.push(indoc.substr(leadingTextStart, startOffset - leadingTextStart));
313 }
314 output.push(conversionMap[name]);
315 offset = startOffset + tokenLength;
316 return true;
317 }
318
319 // Otherwise we found an inner element.
320 addChild(createFrame(conversionMap[name], startOffset, tokenLength));
321 offset = startOffset + tokenLength;
322 return true;
323 case 'opener':
324 stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
325 offset = startOffset + tokenLength;
326 return true;
327 case 'closer':
328 // If we're not nesting then this is easy - close the block.
329 if (1 === stackDepth) {
330 closeOuterElement(startOffset);
331 offset = startOffset + tokenLength;
332 return true;
333 }
334
335 // Otherwise we're nested and we have to close out the current
336 // block and add it as a innerBlock to the parent.
337 const stackTop = stack.pop();
338 const text = indoc.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
339 stackTop.children.push(text);
340 stackTop.prevOffset = startOffset + tokenLength;
341 const frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
342 frame.children = stackTop.children;
343 addChild(frame);
344 offset = startOffset + tokenLength;
345 return true;
346 default:
347 addText();
348 return false;
349 }
350 }
351
352 /**
353 * Grabs the next token match in the string and returns it's details.
354 *
355 * @private
356 *
357 * @return {Array} An array of details for the token matched.
358 */
359 function nextToken() {
360 const matches = tokenizer.exec(indoc);
361 // We have no more tokens.
362 if (null === matches) {
363 return ['no-more-tokens'];
364 }
365 const startedAt = matches.index;
366 const [match, isClosing, name, isSelfClosed] = matches;
367 const length = match.length;
368 if (isSelfClosed) {
369 return ['self-closed', name, startedAt, length];
370 }
371 if (isClosing) {
372 return ['closer', name, startedAt, length];
373 }
374 return ['opener', name, startedAt, length];
375 }
376
377 /**
378 * Pushes text extracted from the indoc string to the output stack given the
379 * current rawLength value and offset (if rawLength is provided ) or the
380 * indoc.length and offset.
381 *
382 * @private
383 */
384 function addText() {
385 const length = indoc.length - offset;
386 if (0 === length) {
387 return;
388 }
389 output.push(indoc.substr(offset, length));
390 }
391
392 /**
393 * Pushes a child element to the associated parent element's children for the
394 * parent currently active in the stack.
395 *
396 * @private
397 *
398 * @param {Frame} frame The Frame containing the child element and it's
399 * token information.
400 */
401 function addChild(frame) {
402 const {
403 element,
404 tokenStart,
405 tokenLength,
406 prevOffset,
407 children
408 } = frame;
409 const parent = stack[stack.length - 1];
410 const text = indoc.substr(parent.prevOffset, tokenStart - parent.prevOffset);
411 if (text) {
412 parent.children.push(text);
413 }
414 parent.children.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children));
415 parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
416 }
417
418 /**
419 * This is called for closing tags. It creates the element currently active in
420 * the stack.
421 *
422 * @private
423 *
424 * @param {number} endOffset Offset at which the closing tag for the element
425 * begins in the string. If this is greater than the
426 * prevOffset attached to the element, then this
427 * helps capture any remaining nested text nodes in
428 * the element.
429 */
430 function closeOuterElement(endOffset) {
431 const {
432 element,
433 leadingTextStart,
434 prevOffset,
435 tokenStart,
436 children
437 } = stack.pop();
438 const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
439 if (text) {
440 children.push(text);
441 }
442 if (null !== leadingTextStart) {
443 output.push(indoc.substr(leadingTextStart, tokenStart - leadingTextStart));
444 }
445 output.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children));
446 }
447 /* harmony default export */ const create_interpolate_element = (createInterpolateElement);
448
449 ;// CONCATENATED MODULE: ./packages/element/build-module/react.js
450 /**
451 * External dependencies
452 */
453 // eslint-disable-next-line @typescript-eslint/no-restricted-imports
454
455
456 /**
457 * Object containing a React element.
458 *
459 * @typedef {import('react').ReactElement} Element
460 */
461
462 /**
463 * Object containing a React component.
464 *
465 * @typedef {import('react').ComponentType} ComponentType
466 */
467
468 /**
469 * Object containing a React synthetic event.
470 *
471 * @typedef {import('react').SyntheticEvent} SyntheticEvent
472 */
473
474 /**
475 * Object containing a React synthetic event.
476 *
477 * @template T
478 * @typedef {import('react').RefObject<T>} RefObject<T>
479 */
480
481 /**
482 * Object that provides utilities for dealing with React children.
483 */
484
485
486 /**
487 * Creates a copy of an element with extended props.
488 *
489 * @param {Element} element Element
490 * @param {?Object} props Props to apply to cloned element
491 *
492 * @return {Element} Cloned element.
493 */
494
495
496 /**
497 * A base class to create WordPress Components (Refs, state and lifecycle hooks)
498 */
499
500
501 /**
502 * Creates a context object containing two components: a provider and consumer.
503 *
504 * @param {Object} defaultValue A default data stored in the context.
505 *
506 * @return {Object} Context object.
507 */
508
509
510 /**
511 * Returns a new element of given type. Type can be either a string tag name or
512 * another function which itself returns an element.
513 *
514 * @param {?(string|Function)} type Tag name or element creator
515 * @param {Object} props Element properties, either attribute
516 * set to apply to DOM node or values to
517 * pass through to element creator
518 * @param {...Element} children Descendant elements
519 *
520 * @return {Element} Element.
521 */
522
523
524 /**
525 * Returns an object tracking a reference to a rendered element via its
526 * `current` property as either a DOMElement or Element, dependent upon the
527 * type of element rendered with the ref attribute.
528 *
529 * @return {Object} Ref object.
530 */
531
532
533 /**
534 * Component enhancer used to enable passing a ref to its wrapped component.
535 * Pass a function argument which receives `props` and `ref` as its arguments,
536 * returning an element using the forwarded ref. The return value is a new
537 * component which forwards its ref.
538 *
539 * @param {Function} forwarder Function passed `props` and `ref`, expected to
540 * return an element.
541 *
542 * @return {Component} Enhanced component.
543 */
544
545
546 /**
547 * A component which renders its children without any wrapping element.
548 */
549
550
551 /**
552 * Checks if an object is a valid React Element.
553 *
554 * @param {Object} objectToCheck The object to be checked.
555 *
556 * @return {boolean} true if objectToTest is a valid React Element and false otherwise.
557 */
558
559
560 /**
561 * @see https://react.dev/reference/react/memo
562 */
563
564
565 /**
566 * Component that activates additional checks and warnings for its descendants.
567 */
568
569
570 /**
571 * @see https://react.dev/reference/react/useCallback
572 */
573
574
575 /**
576 * @see https://react.dev/reference/react/useContext
577 */
578
579
580 /**
581 * @see https://react.dev/reference/react/useDebugValue
582 */
583
584
585 /**
586 * @see https://react.dev/reference/react/useDeferredValue
587 */
588
589
590 /**
591 * @see https://react.dev/reference/react/useEffect
592 */
593
594
595 /**
596 * @see https://react.dev/reference/react/useId
597 */
598
599
600 /**
601 * @see https://react.dev/reference/react/useImperativeHandle
602 */
603
604
605 /**
606 * @see https://react.dev/reference/react/useInsertionEffect
607 */
608
609
610 /**
611 * @see https://react.dev/reference/react/useLayoutEffect
612 */
613
614
615 /**
616 * @see https://react.dev/reference/react/useMemo
617 */
618
619
620 /**
621 * @see https://react.dev/reference/react/useReducer
622 */
623
624
625 /**
626 * @see https://react.dev/reference/react/useRef
627 */
628
629
630 /**
631 * @see https://react.dev/reference/react/useState
632 */
633
634
635 /**
636 * @see https://react.dev/reference/react/useSyncExternalStore
637 */
638
639
640 /**
641 * @see https://react.dev/reference/react/useTransition
642 */
643
644
645 /**
646 * @see https://react.dev/reference/react/startTransition
647 */
648
649
650 /**
651 * @see https://react.dev/reference/react/lazy
652 */
653
654
655 /**
656 * @see https://react.dev/reference/react/Suspense
657 */
658
659
660 /**
661 * @see https://react.dev/reference/react/PureComponent
662 */
663
664
665 /**
666 * Concatenate two or more React children objects.
667 *
668 * @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.
669 *
670 * @return {Array} The concatenated value.
671 */
672 function concatChildren(...childrenArguments) {
673 return childrenArguments.reduce((accumulator, children, i) => {
674 external_React_namespaceObject.Children.forEach(children, (child, j) => {
675 if (child && 'string' !== typeof child) {
676 child = (0,external_React_namespaceObject.cloneElement)(child, {
677 key: [i, j].join()
678 });
679 }
680 accumulator.push(child);
681 });
682 return accumulator;
683 }, []);
684 }
685
686 /**
687 * Switches the nodeName of all the elements in the children object.
688 *
689 * @param {?Object} children Children object.
690 * @param {string} nodeName Node name.
691 *
692 * @return {?Object} The updated children object.
693 */
694 function switchChildrenNodeName(children, nodeName) {
695 return children && external_React_namespaceObject.Children.map(children, (elt, index) => {
696 if (typeof elt?.valueOf() === 'string') {
697 return (0,external_React_namespaceObject.createElement)(nodeName, {
698 key: index
699 }, elt);
700 }
701 const {
702 children: childrenProp,
703 ...props
704 } = elt.props;
705 return (0,external_React_namespaceObject.createElement)(nodeName, {
706 key: index,
707 ...props
708 }, childrenProp);
709 });
710 }
711
712 // EXTERNAL MODULE: external "ReactDOM"
713 var external_ReactDOM_ = __webpack_require__(1850);
714 // EXTERNAL MODULE: ./node_modules/react-dom/client.js
715 var client = __webpack_require__(4470);
716 ;// CONCATENATED MODULE: ./packages/element/build-module/react-platform.js
717 /**
718 * External dependencies
719 */
720
721
722
723 /**
724 * Creates a portal into which a component can be rendered.
725 *
726 * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235
727 *
728 * @param {import('react').ReactElement} child Any renderable child, such as an element,
729 * string, or fragment.
730 * @param {HTMLElement} container DOM node into which element should be rendered.
731 */
732
733
734 /**
735 * Finds the dom node of a React component.
736 *
737 * @param {import('react').ComponentType} component Component's instance.
738 */
739
740
741 /**
742 * Forces React to flush any updates inside the provided callback synchronously.
743 *
744 * @param {Function} callback Callback to run synchronously.
745 */
746
747
748 /**
749 * Renders a given element into the target DOM node.
750 *
751 * @deprecated since WordPress 6.2.0. Use `createRoot` instead.
752 * @see https://react.dev/reference/react-dom/render
753 */
754
755
756 /**
757 * Hydrates a given element into the target DOM node.
758 *
759 * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.
760 * @see https://react.dev/reference/react-dom/hydrate
761 */
762
763
764 /**
765 * Creates a new React root for the target DOM node.
766 *
767 * @since 6.2.0 Introduced in WordPress core.
768 * @see https://react.dev/reference/react-dom/client/createRoot
769 */
770
771
772 /**
773 * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.
774 *
775 * @since 6.2.0 Introduced in WordPress core.
776 * @see https://react.dev/reference/react-dom/client/hydrateRoot
777 */
778
779
780 /**
781 * Removes any mounted element from the target DOM node.
782 *
783 * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.
784 * @see https://react.dev/reference/react-dom/unmountComponentAtNode
785 */
786
787
788 ;// CONCATENATED MODULE: ./packages/element/build-module/utils.js
789 /**
790 * Checks if the provided WP element is empty.
791 *
792 * @param {*} element WP element to check.
793 * @return {boolean} True when an element is considered empty.
794 */
795 const isEmptyElement = element => {
796 if (typeof element === 'number') {
797 return false;
798 }
799 if (typeof element?.valueOf() === 'string' || Array.isArray(element)) {
800 return !element.length;
801 }
802 return !element;
803 };
804
805 ;// CONCATENATED MODULE: ./packages/element/build-module/platform.js
806 /**
807 * Parts of this source were derived and modified from react-native-web,
808 * released under the MIT license.
809 *
810 * Copyright (c) 2016-present, Nicolas Gallagher.
811 * Copyright (c) 2015-present, Facebook, Inc.
812 *
813 */
814 const Platform = {
815 OS: 'web',
816 select: spec => 'web' in spec ? spec.web : spec.default,
817 isWeb: true
818 };
819 /**
820 * Component used to detect the current Platform being used.
821 * Use Platform.OS === 'web' to detect if running on web enviroment.
822 *
823 * This is the same concept as the React Native implementation.
824 *
825 * @see https://reactnative.dev/docs/platform-specific-code#platform-module
826 *
827 * Here is an example of how to use the select method:
828 * @example
829 * ```js
830 * import { Platform } from '@wordpress/element';
831 *
832 * const placeholderLabel = Platform.select( {
833 * native: __( 'Add media' ),
834 * web: __( 'Drag images, upload new ones or select files from your library.' ),
835 * } );
836 * ```
837 */
838 /* harmony default export */ const platform = (Platform);
839
840 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
841 /*!
842 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
843 *
844 * Copyright (c) 2014-2017, Jon Schlinkert.
845 * Released under the MIT License.
846 */
847
848 function isObject(o) {
849 return Object.prototype.toString.call(o) === '[object Object]';
850 }
851
852 function isPlainObject(o) {
853 var ctor,prot;
854
855 if (isObject(o) === false) return false;
856
857 // If has modified constructor
858 ctor = o.constructor;
859 if (ctor === undefined) return true;
860
861 // If has modified prototype
862 prot = ctor.prototype;
863 if (isObject(prot) === false) return false;
864
865 // If constructor does not have an Object-specific method
866 if (prot.hasOwnProperty('isPrototypeOf') === false) {
867 return false;
868 }
869
870 // Most likely a plain Object
871 return true;
872 }
873
874
875
876 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
877 /******************************************************************************
878 Copyright (c) Microsoft Corporation.
879
880 Permission to use, copy, modify, and/or distribute this software for any
881 purpose with or without fee is hereby granted.
882
883 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
884 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
885 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
886 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
887 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
888 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
889 PERFORMANCE OF THIS SOFTWARE.
890 ***************************************************************************** */
891 /* global Reflect, Promise, SuppressedError, Symbol */
892
893 var extendStatics = function(d, b) {
894 extendStatics = Object.setPrototypeOf ||
895 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
896 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
897 return extendStatics(d, b);
898 };
899
900 function __extends(d, b) {
901 if (typeof b !== "function" && b !== null)
902 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
903 extendStatics(d, b);
904 function __() { this.constructor = d; }
905 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
906 }
907
908 var __assign = function() {
909 __assign = Object.assign || function __assign(t) {
910 for (var s, i = 1, n = arguments.length; i < n; i++) {
911 s = arguments[i];
912 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
913 }
914 return t;
915 }
916 return __assign.apply(this, arguments);
917 }
918
919 function __rest(s, e) {
920 var t = {};
921 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
922 t[p] = s[p];
923 if (s != null && typeof Object.getOwnPropertySymbols === "function")
924 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
925 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
926 t[p[i]] = s[p[i]];
927 }
928 return t;
929 }
930
931 function __decorate(decorators, target, key, desc) {
932 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
933 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
934 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
935 return c > 3 && r && Object.defineProperty(target, key, r), r;
936 }
937
938 function __param(paramIndex, decorator) {
939 return function (target, key) { decorator(target, key, paramIndex); }
940 }
941
942 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
943 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
944 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
945 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
946 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
947 var _, done = false;
948 for (var i = decorators.length - 1; i >= 0; i--) {
949 var context = {};
950 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
951 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
952 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
953 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
954 if (kind === "accessor") {
955 if (result === void 0) continue;
956 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
957 if (_ = accept(result.get)) descriptor.get = _;
958 if (_ = accept(result.set)) descriptor.set = _;
959 if (_ = accept(result.init)) initializers.unshift(_);
960 }
961 else if (_ = accept(result)) {
962 if (kind === "field") initializers.unshift(_);
963 else descriptor[key] = _;
964 }
965 }
966 if (target) Object.defineProperty(target, contextIn.name, descriptor);
967 done = true;
968 };
969
970 function __runInitializers(thisArg, initializers, value) {
971 var useValue = arguments.length > 2;
972 for (var i = 0; i < initializers.length; i++) {
973 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
974 }
975 return useValue ? value : void 0;
976 };
977
978 function __propKey(x) {
979 return typeof x === "symbol" ? x : "".concat(x);
980 };
981
982 function __setFunctionName(f, name, prefix) {
983 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
984 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
985 };
986
987 function __metadata(metadataKey, metadataValue) {
988 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
989 }
990
991 function __awaiter(thisArg, _arguments, P, generator) {
992 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
993 return new (P || (P = Promise))(function (resolve, reject) {
994 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
995 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
996 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
997 step((generator = generator.apply(thisArg, _arguments || [])).next());
998 });
999 }
1000
1001 function __generator(thisArg, body) {
1002 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1003 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1004 function verb(n) { return function (v) { return step([n, v]); }; }
1005 function step(op) {
1006 if (f) throw new TypeError("Generator is already executing.");
1007 while (g && (g = 0, op[0] && (_ = 0)), _) try {
1008 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1009 if (y = 0, t) op = [op[0] & 2, t.value];
1010 switch (op[0]) {
1011 case 0: case 1: t = op; break;
1012 case 4: _.label++; return { value: op[1], done: false };
1013 case 5: _.label++; y = op[1]; op = [0]; continue;
1014 case 7: op = _.ops.pop(); _.trys.pop(); continue;
1015 default:
1016 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
1017 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
1018 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
1019 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
1020 if (t[2]) _.ops.pop();
1021 _.trys.pop(); continue;
1022 }
1023 op = body.call(thisArg, _);
1024 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
1025 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
1026 }
1027 }
1028
1029 var __createBinding = Object.create ? (function(o, m, k, k2) {
1030 if (k2 === undefined) k2 = k;
1031 var desc = Object.getOwnPropertyDescriptor(m, k);
1032 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1033 desc = { enumerable: true, get: function() { return m[k]; } };
1034 }
1035 Object.defineProperty(o, k2, desc);
1036 }) : (function(o, m, k, k2) {
1037 if (k2 === undefined) k2 = k;
1038 o[k2] = m[k];
1039 });
1040
1041 function __exportStar(m, o) {
1042 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
1043 }
1044
1045 function __values(o) {
1046 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1047 if (m) return m.call(o);
1048 if (o && typeof o.length === "number") return {
1049 next: function () {
1050 if (o && i >= o.length) o = void 0;
1051 return { value: o && o[i++], done: !o };
1052 }
1053 };
1054 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1055 }
1056
1057 function __read(o, n) {
1058 var m = typeof Symbol === "function" && o[Symbol.iterator];
1059 if (!m) return o;
1060 var i = m.call(o), r, ar = [], e;
1061 try {
1062 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1063 }
1064 catch (error) { e = { error: error }; }
1065 finally {
1066 try {
1067 if (r && !r.done && (m = i["return"])) m.call(i);
1068 }
1069 finally { if (e) throw e.error; }
1070 }
1071 return ar;
1072 }
1073
1074 /** @deprecated */
1075 function __spread() {
1076 for (var ar = [], i = 0; i < arguments.length; i++)
1077 ar = ar.concat(__read(arguments[i]));
1078 return ar;
1079 }
1080
1081 /** @deprecated */
1082 function __spreadArrays() {
1083 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1084 for (var r = Array(s), k = 0, i = 0; i < il; i++)
1085 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1086 r[k] = a[j];
1087 return r;
1088 }
1089
1090 function __spreadArray(to, from, pack) {
1091 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1092 if (ar || !(i in from)) {
1093 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1094 ar[i] = from[i];
1095 }
1096 }
1097 return to.concat(ar || Array.prototype.slice.call(from));
1098 }
1099
1100 function __await(v) {
1101 return this instanceof __await ? (this.v = v, this) : new __await(v);
1102 }
1103
1104 function __asyncGenerator(thisArg, _arguments, generator) {
1105 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1106 var g = generator.apply(thisArg, _arguments || []), i, q = [];
1107 return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
1108 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
1109 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
1110 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
1111 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
1112 function fulfill(value) { resume("next", value); }
1113 function reject(value) { resume("throw", value); }
1114 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
1115 }
1116
1117 function __asyncDelegator(o) {
1118 var i, p;
1119 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
1120 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
1121 }
1122
1123 function __asyncValues(o) {
1124 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1125 var m = o[Symbol.asyncIterator], i;
1126 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
1127 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
1128 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
1129 }
1130
1131 function __makeTemplateObject(cooked, raw) {
1132 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
1133 return cooked;
1134 };
1135
1136 var __setModuleDefault = Object.create ? (function(o, v) {
1137 Object.defineProperty(o, "default", { enumerable: true, value: v });
1138 }) : function(o, v) {
1139 o["default"] = v;
1140 };
1141
1142 function __importStar(mod) {
1143 if (mod && mod.__esModule) return mod;
1144 var result = {};
1145 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1146 __setModuleDefault(result, mod);
1147 return result;
1148 }
1149
1150 function __importDefault(mod) {
1151 return (mod && mod.__esModule) ? mod : { default: mod };
1152 }
1153
1154 function __classPrivateFieldGet(receiver, state, kind, f) {
1155 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1156 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1157 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1158 }
1159
1160 function __classPrivateFieldSet(receiver, state, value, kind, f) {
1161 if (kind === "m") throw new TypeError("Private method is not writable");
1162 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1163 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1164 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1165 }
1166
1167 function __classPrivateFieldIn(state, receiver) {
1168 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
1169 return typeof state === "function" ? receiver === state : state.has(receiver);
1170 }
1171
1172 function __addDisposableResource(env, value, async) {
1173 if (value !== null && value !== void 0) {
1174 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
1175 var dispose, inner;
1176 if (async) {
1177 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
1178 dispose = value[Symbol.asyncDispose];
1179 }
1180 if (dispose === void 0) {
1181 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
1182 dispose = value[Symbol.dispose];
1183 if (async) inner = dispose;
1184 }
1185 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
1186 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
1187 env.stack.push({ value: value, dispose: dispose, async: async });
1188 }
1189 else if (async) {
1190 env.stack.push({ async: true });
1191 }
1192 return value;
1193 }
1194
1195 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1196 var e = new Error(message);
1197 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1198 };
1199
1200 function __disposeResources(env) {
1201 function fail(e) {
1202 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
1203 env.hasError = true;
1204 }
1205 function next() {
1206 while (env.stack.length) {
1207 var rec = env.stack.pop();
1208 try {
1209 var result = rec.dispose && rec.dispose.call(rec.value);
1210 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
1211 }
1212 catch (e) {
1213 fail(e);
1214 }
1215 }
1216 if (env.hasError) throw env.error;
1217 }
1218 return next();
1219 }
1220
1221 /* harmony default export */ const tslib_es6 = ({
1222 __extends,
1223 __assign,
1224 __rest,
1225 __decorate,
1226 __param,
1227 __metadata,
1228 __awaiter,
1229 __generator,
1230 __createBinding,
1231 __exportStar,
1232 __values,
1233 __read,
1234 __spread,
1235 __spreadArrays,
1236 __spreadArray,
1237 __await,
1238 __asyncGenerator,
1239 __asyncDelegator,
1240 __asyncValues,
1241 __makeTemplateObject,
1242 __importStar,
1243 __importDefault,
1244 __classPrivateFieldGet,
1245 __classPrivateFieldSet,
1246 __classPrivateFieldIn,
1247 __addDisposableResource,
1248 __disposeResources,
1249 });
1250
1251 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
1252 /**
1253 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
1254 */
1255 var SUPPORTED_LOCALE = {
1256 tr: {
1257 regexp: /\u0130|\u0049|\u0049\u0307/g,
1258 map: {
1259 İ: "\u0069",
1260 I: "\u0131",
1261 : "\u0069",
1262 },
1263 },
1264 az: {
1265 regexp: /\u0130/g,
1266 map: {
1267 İ: "\u0069",
1268 I: "\u0131",
1269 : "\u0069",
1270 },
1271 },
1272 lt: {
1273 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
1274 map: {
1275 I: "\u0069\u0307",
1276 J: "\u006A\u0307",
1277 Į: "\u012F\u0307",
1278 Ì: "\u0069\u0307\u0300",
1279 Í: "\u0069\u0307\u0301",
1280 Ĩ: "\u0069\u0307\u0303",
1281 },
1282 },
1283 };
1284 /**
1285 * Localized lower case.
1286 */
1287 function localeLowerCase(str, locale) {
1288 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
1289 if (lang)
1290 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
1291 return lowerCase(str);
1292 }
1293 /**
1294 * Lower case as a function.
1295 */
1296 function lowerCase(str) {
1297 return str.toLowerCase();
1298 }
1299
1300 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
1301
1302 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
1303 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
1304 // Remove all non-word characters.
1305 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
1306 /**
1307 * Normalize the string into something other libraries can manipulate easier.
1308 */
1309 function noCase(input, options) {
1310 if (options === void 0) { options = {}; }
1311 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;
1312 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
1313 var start = 0;
1314 var end = result.length;
1315 // Trim the delimiter from around the output string.
1316 while (result.charAt(start) === "\0")
1317 start++;
1318 while (result.charAt(end - 1) === "\0")
1319 end--;
1320 // Transform each token independently.
1321 return result.slice(start, end).split("\0").map(transform).join(delimiter);
1322 }
1323 /**
1324 * Replace `re` in the input string with the replacement value.
1325 */
1326 function replace(input, re, value) {
1327 if (re instanceof RegExp)
1328 return input.replace(re, value);
1329 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
1330 }
1331
1332 ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
1333
1334
1335 function dotCase(input, options) {
1336 if (options === void 0) { options = {}; }
1337 return noCase(input, __assign({ delimiter: "." }, options));
1338 }
1339
1340 ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
1341
1342
1343 function paramCase(input, options) {
1344 if (options === void 0) { options = {}; }
1345 return dotCase(input, __assign({ delimiter: "-" }, options));
1346 }
1347
1348 ;// CONCATENATED MODULE: external ["wp","escapeHtml"]
1349 const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"];
1350 ;// CONCATENATED MODULE: ./packages/element/build-module/raw-html.js
1351 /**
1352 * Internal dependencies
1353 */
1354
1355
1356 /** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
1357
1358 /**
1359 * Component used as equivalent of Fragment with unescaped HTML, in cases where
1360 * it is desirable to render dangerous HTML without needing a wrapper element.
1361 * To preserve additional props, a `div` wrapper _will_ be created if any props
1362 * aside from `children` are passed.
1363 *
1364 * @param {RawHTMLProps} props Children should be a string of HTML or an array
1365 * of strings. Other props will be passed through
1366 * to the div wrapper.
1367 *
1368 * @return {JSX.Element} Dangerously-rendering component.
1369 */
1370 function RawHTML({
1371 children,
1372 ...props
1373 }) {
1374 let rawHtml = '';
1375
1376 // Cast children as an array, and concatenate each element if it is a string.
1377 external_React_namespaceObject.Children.toArray(children).forEach(child => {
1378 if (typeof child === 'string' && child.trim() !== '') {
1379 rawHtml += child;
1380 }
1381 });
1382
1383 // The `div` wrapper will be stripped by the `renderElement` serializer in
1384 // `./serialize.js` unless there are non-children props present.
1385 return (0,external_React_namespaceObject.createElement)('div', {
1386 dangerouslySetInnerHTML: {
1387 __html: rawHtml
1388 },
1389 ...props
1390 });
1391 }
1392
1393 ;// CONCATENATED MODULE: ./packages/element/build-module/serialize.js
1394 /**
1395 * Parts of this source were derived and modified from fast-react-render,
1396 * released under the MIT license.
1397 *
1398 * https://github.com/alt-j/fast-react-render
1399 *
1400 * Copyright (c) 2016 Andrey Morozov
1401 *
1402 * Permission is hereby granted, free of charge, to any person obtaining a copy
1403 * of this software and associated documentation files (the "Software"), to deal
1404 * in the Software without restriction, including without limitation the rights
1405 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1406 * copies of the Software, and to permit persons to whom the Software is
1407 * furnished to do so, subject to the following conditions:
1408 *
1409 * The above copyright notice and this permission notice shall be included in
1410 * all copies or substantial portions of the Software.
1411 *
1412 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1413 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1414 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1415 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1416 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1417 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1418 * THE SOFTWARE.
1419 */
1420
1421 /**
1422 * External dependencies
1423 */
1424
1425
1426
1427 /**
1428 * WordPress dependencies
1429 */
1430
1431
1432 /**
1433 * Internal dependencies
1434 */
1435
1436
1437
1438 /** @typedef {import('react').ReactElement} ReactElement */
1439
1440 const {
1441 Provider,
1442 Consumer
1443 } = (0,external_React_namespaceObject.createContext)(undefined);
1444 const ForwardRef = (0,external_React_namespaceObject.forwardRef)(() => {
1445 return null;
1446 });
1447
1448 /**
1449 * Valid attribute types.
1450 *
1451 * @type {Set<string>}
1452 */
1453 const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
1454
1455 /**
1456 * Element tags which can be self-closing.
1457 *
1458 * @type {Set<string>}
1459 */
1460 const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
1461
1462 /**
1463 * Boolean attributes are attributes whose presence as being assigned is
1464 * meaningful, even if only empty.
1465 *
1466 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
1467 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
1468 *
1469 * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
1470 * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
1471 * .reduce( ( result, tr ) => Object.assign( result, {
1472 * [ tr.firstChild.textContent.trim() ]: true
1473 * } ), {} ) ).sort();
1474 *
1475 * @type {Set<string>}
1476 */
1477 const BOOLEAN_ATTRIBUTES = new Set(['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']);
1478
1479 /**
1480 * Enumerated attributes are attributes which must be of a specific value form.
1481 * Like boolean attributes, these are meaningful if specified, even if not of a
1482 * valid enumerated value.
1483 *
1484 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
1485 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
1486 *
1487 * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
1488 * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
1489 * .reduce( ( result, tr ) => Object.assign( result, {
1490 * [ tr.firstChild.textContent.trim() ]: true
1491 * } ), {} ) ).sort();
1492 *
1493 * Some notable omissions:
1494 *
1495 * - `alt`: https://blog.whatwg.org/omit-alt
1496 *
1497 * @type {Set<string>}
1498 */
1499 const ENUMERATED_ATTRIBUTES = new Set(['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']);
1500
1501 /**
1502 * Set of CSS style properties which support assignment of unitless numbers.
1503 * Used in rendering of style properties, where `px` unit is assumed unless
1504 * property is included in this set or value is zero.
1505 *
1506 * Generated via:
1507 *
1508 * Object.entries( document.createElement( 'div' ).style )
1509 * .filter( ( [ key ] ) => (
1510 * ! /^(webkit|ms|moz)/.test( key ) &&
1511 * ( e.style[ key ] = 10 ) &&
1512 * e.style[ key ] === '10'
1513 * ) )
1514 * .map( ( [ key ] ) => key )
1515 * .sort();
1516 *
1517 * @type {Set<string>}
1518 */
1519 const CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set(['animation', 'animationIterationCount', 'baselineShift', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'columnCount', 'cx', 'cy', 'fillOpacity', 'flexGrow', 'flexShrink', 'floodOpacity', 'fontWeight', 'gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart', 'lineHeight', 'opacity', 'order', 'orphans', 'r', 'rx', 'ry', 'shapeImageThreshold', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'tabSize', 'widows', 'x', 'y', 'zIndex', 'zoom']);
1520
1521 /**
1522 * Returns true if the specified string is prefixed by one of an array of
1523 * possible prefixes.
1524 *
1525 * @param {string} string String to check.
1526 * @param {string[]} prefixes Possible prefixes.
1527 *
1528 * @return {boolean} Whether string has prefix.
1529 */
1530 function hasPrefix(string, prefixes) {
1531 return prefixes.some(prefix => string.indexOf(prefix) === 0);
1532 }
1533
1534 /**
1535 * Returns true if the given prop name should be ignored in attributes
1536 * serialization, or false otherwise.
1537 *
1538 * @param {string} attribute Attribute to check.
1539 *
1540 * @return {boolean} Whether attribute should be ignored.
1541 */
1542 function isInternalAttribute(attribute) {
1543 return 'key' === attribute || 'children' === attribute;
1544 }
1545
1546 /**
1547 * Returns the normal form of the element's attribute value for HTML.
1548 *
1549 * @param {string} attribute Attribute name.
1550 * @param {*} value Non-normalized attribute value.
1551 *
1552 * @return {*} Normalized attribute value.
1553 */
1554 function getNormalAttributeValue(attribute, value) {
1555 switch (attribute) {
1556 case 'style':
1557 return renderStyle(value);
1558 }
1559 return value;
1560 }
1561 /**
1562 * This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
1563 * We need this to render e.g strokeWidth as stroke-width.
1564 *
1565 * List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
1566 */
1567 const SVG_ATTRIBUTE_WITH_DASHES_LIST = ['accentHeight', 'alignmentBaseline', 'arabicForm', 'baselineShift', 'capHeight', 'clipPath', 'clipRule', 'colorInterpolation', 'colorInterpolationFilters', 'colorProfile', 'colorRendering', 'dominantBaseline', 'enableBackground', 'fillOpacity', 'fillRule', 'floodColor', 'floodOpacity', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'glyphName', 'glyphOrientationHorizontal', 'glyphOrientationVertical', 'horizAdvX', 'horizOriginX', 'imageRendering', 'letterSpacing', 'lightingColor', 'markerEnd', 'markerMid', 'markerStart', 'overlinePosition', 'overlineThickness', 'paintOrder', 'panose1', 'pointerEvents', 'renderingIntent', 'shapeRendering', 'stopColor', 'stopOpacity', 'strikethroughPosition', 'strikethroughThickness', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'textAnchor', 'textDecoration', 'textRendering', 'underlinePosition', 'underlineThickness', 'unicodeBidi', 'unicodeRange', 'unitsPerEm', 'vAlphabetic', 'vHanging', 'vIdeographic', 'vMathematical', 'vectorEffect', 'vertAdvY', 'vertOriginX', 'vertOriginY', 'wordSpacing', 'writingMode', 'xmlnsXlink', 'xHeight'].reduce((map, attribute) => {
1568 // The keys are lower-cased for more robust lookup.
1569 map[attribute.toLowerCase()] = attribute;
1570 return map;
1571 }, {});
1572
1573 /**
1574 * This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
1575 * The keys are lower-cased for more robust lookup.
1576 * Note that this list only contains attributes that contain at least one capital letter.
1577 * Lowercase attributes don't need mapping, since we lowercase all attributes by default.
1578 */
1579 const CASE_SENSITIVE_SVG_ATTRIBUTES = ['allowReorder', 'attributeName', 'attributeType', 'autoReverse', 'baseFrequency', 'baseProfile', 'calcMode', 'clipPathUnits', 'contentScriptType', 'contentStyleType', 'diffuseConstant', 'edgeMode', 'externalResourcesRequired', 'filterRes', 'filterUnits', 'glyphRef', 'gradientTransform', 'gradientUnits', 'kernelMatrix', 'kernelUnitLength', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'limitingConeAngle', 'markerHeight', 'markerUnits', 'markerWidth', 'maskContentUnits', 'maskUnits', 'numOctaves', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'refX', 'refY', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'specularConstant', 'specularExponent', 'spreadMethod', 'startOffset', 'stdDeviation', 'stitchTiles', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textLength', 'viewBox', 'viewTarget', 'xChannelSelector', 'yChannelSelector'].reduce((map, attribute) => {
1580 // The keys are lower-cased for more robust lookup.
1581 map[attribute.toLowerCase()] = attribute;
1582 return map;
1583 }, {});
1584
1585 /**
1586 * This is a map of all SVG attributes that have colons.
1587 * Keys are lower-cased and stripped of their colons for more robust lookup.
1588 */
1589 const SVG_ATTRIBUTES_WITH_COLONS = ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'xmlns:xlink'].reduce((map, attribute) => {
1590 map[attribute.replace(':', '').toLowerCase()] = attribute;
1591 return map;
1592 }, {});
1593
1594 /**
1595 * Returns the normal form of the element's attribute name for HTML.
1596 *
1597 * @param {string} attribute Non-normalized attribute name.
1598 *
1599 * @return {string} Normalized attribute name.
1600 */
1601 function getNormalAttributeName(attribute) {
1602 switch (attribute) {
1603 case 'htmlFor':
1604 return 'for';
1605 case 'className':
1606 return 'class';
1607 }
1608 const attributeLowerCase = attribute.toLowerCase();
1609 if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
1610 return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
1611 } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
1612 return paramCase(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
1613 } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
1614 return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
1615 }
1616 return attributeLowerCase;
1617 }
1618
1619 /**
1620 * Returns the normal form of the style property name for HTML.
1621 *
1622 * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'
1623 * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'
1624 * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'
1625 *
1626 * @param {string} property Property name.
1627 *
1628 * @return {string} Normalized property name.
1629 */
1630 function getNormalStylePropertyName(property) {
1631 if (property.startsWith('--')) {
1632 return property;
1633 }
1634 if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
1635 return '-' + paramCase(property);
1636 }
1637 return paramCase(property);
1638 }
1639
1640 /**
1641 * Returns the normal form of the style property value for HTML. Appends a
1642 * default pixel unit if numeric, not a unitless property, and not zero.
1643 *
1644 * @param {string} property Property name.
1645 * @param {*} value Non-normalized property value.
1646 *
1647 * @return {*} Normalized property value.
1648 */
1649 function getNormalStylePropertyValue(property, value) {
1650 if (typeof value === 'number' && 0 !== value && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
1651 return value + 'px';
1652 }
1653 return value;
1654 }
1655
1656 /**
1657 * Serializes a React element to string.
1658 *
1659 * @param {import('react').ReactNode} element Element to serialize.
1660 * @param {Object} [context] Context object.
1661 * @param {Object} [legacyContext] Legacy context object.
1662 *
1663 * @return {string} Serialized element.
1664 */
1665 function renderElement(element, context, legacyContext = {}) {
1666 if (null === element || undefined === element || false === element) {
1667 return '';
1668 }
1669 if (Array.isArray(element)) {
1670 return renderChildren(element, context, legacyContext);
1671 }
1672 switch (typeof element) {
1673 case 'string':
1674 return (0,external_wp_escapeHtml_namespaceObject.escapeHTML)(element);
1675 case 'number':
1676 return element.toString();
1677 }
1678 const {
1679 type,
1680 props
1681 } = /** @type {{type?: any, props?: any}} */
1682 element;
1683 switch (type) {
1684 case external_React_namespaceObject.StrictMode:
1685 case external_React_namespaceObject.Fragment:
1686 return renderChildren(props.children, context, legacyContext);
1687 case RawHTML:
1688 const {
1689 children,
1690 ...wrapperProps
1691 } = props;
1692 return renderNativeComponent(!Object.keys(wrapperProps).length ? null : 'div', {
1693 ...wrapperProps,
1694 dangerouslySetInnerHTML: {
1695 __html: children
1696 }
1697 }, context, legacyContext);
1698 }
1699 switch (typeof type) {
1700 case 'string':
1701 return renderNativeComponent(type, props, context, legacyContext);
1702 case 'function':
1703 if (type.prototype && typeof type.prototype.render === 'function') {
1704 return renderComponent(type, props, context, legacyContext);
1705 }
1706 return renderElement(type(props, legacyContext), context, legacyContext);
1707 }
1708 switch (type && type.$$typeof) {
1709 case Provider.$$typeof:
1710 return renderChildren(props.children, props.value, legacyContext);
1711 case Consumer.$$typeof:
1712 return renderElement(props.children(context || type._currentValue), context, legacyContext);
1713 case ForwardRef.$$typeof:
1714 return renderElement(type.render(props), context, legacyContext);
1715 }
1716 return '';
1717 }
1718
1719 /**
1720 * Serializes a native component type to string.
1721 *
1722 * @param {?string} type Native component type to serialize, or null if
1723 * rendering as fragment of children content.
1724 * @param {Object} props Props object.
1725 * @param {Object} [context] Context object.
1726 * @param {Object} [legacyContext] Legacy context object.
1727 *
1728 * @return {string} Serialized element.
1729 */
1730 function renderNativeComponent(type, props, context, legacyContext = {}) {
1731 let content = '';
1732 if (type === 'textarea' && props.hasOwnProperty('value')) {
1733 // Textarea children can be assigned as value prop. If it is, render in
1734 // place of children. Ensure to omit so it is not assigned as attribute
1735 // as well.
1736 content = renderChildren(props.value, context, legacyContext);
1737 const {
1738 value,
1739 ...restProps
1740 } = props;
1741 props = restProps;
1742 } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') {
1743 // Dangerous content is left unescaped.
1744 content = props.dangerouslySetInnerHTML.__html;
1745 } else if (typeof props.children !== 'undefined') {
1746 content = renderChildren(props.children, context, legacyContext);
1747 }
1748 if (!type) {
1749 return content;
1750 }
1751 const attributes = renderAttributes(props);
1752 if (SELF_CLOSING_TAGS.has(type)) {
1753 return '<' + type + attributes + '/>';
1754 }
1755 return '<' + type + attributes + '>' + content + '</' + type + '>';
1756 }
1757
1758 /** @typedef {import('react').ComponentType} ComponentType */
1759
1760 /**
1761 * Serializes a non-native component type to string.
1762 *
1763 * @param {ComponentType} Component Component type to serialize.
1764 * @param {Object} props Props object.
1765 * @param {Object} [context] Context object.
1766 * @param {Object} [legacyContext] Legacy context object.
1767 *
1768 * @return {string} Serialized element
1769 */
1770 function renderComponent(Component, props, context, legacyContext = {}) {
1771 const instance = new ( /** @type {import('react').ComponentClass} */
1772 Component)(props, legacyContext);
1773 if (typeof
1774 // Ignore reason: Current prettier reformats parens and mangles type assertion
1775 // prettier-ignore
1776 /** @type {{getChildContext?: () => unknown}} */
1777 instance.getChildContext === 'function') {
1778 Object.assign(legacyContext, /** @type {{getChildContext?: () => unknown}} */instance.getChildContext());
1779 }
1780 const html = renderElement(instance.render(), context, legacyContext);
1781 return html;
1782 }
1783
1784 /**
1785 * Serializes an array of children to string.
1786 *
1787 * @param {import('react').ReactNodeArray} children Children to serialize.
1788 * @param {Object} [context] Context object.
1789 * @param {Object} [legacyContext] Legacy context object.
1790 *
1791 * @return {string} Serialized children.
1792 */
1793 function renderChildren(children, context, legacyContext = {}) {
1794 let result = '';
1795 children = Array.isArray(children) ? children : [children];
1796 for (let i = 0; i < children.length; i++) {
1797 const child = children[i];
1798 result += renderElement(child, context, legacyContext);
1799 }
1800 return result;
1801 }
1802
1803 /**
1804 * Renders a props object as a string of HTML attributes.
1805 *
1806 * @param {Object} props Props object.
1807 *
1808 * @return {string} Attributes string.
1809 */
1810 function renderAttributes(props) {
1811 let result = '';
1812 for (const key in props) {
1813 const attribute = getNormalAttributeName(key);
1814 if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(attribute)) {
1815 continue;
1816 }
1817 let value = getNormalAttributeValue(key, props[key]);
1818
1819 // If value is not of serializable type, skip.
1820 if (!ATTRIBUTES_TYPES.has(typeof value)) {
1821 continue;
1822 }
1823
1824 // Don't render internal attribute names.
1825 if (isInternalAttribute(key)) {
1826 continue;
1827 }
1828 const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
1829
1830 // Boolean attribute should be omitted outright if its value is false.
1831 if (isBooleanAttribute && value === false) {
1832 continue;
1833 }
1834 const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute);
1835
1836 // Only write boolean value as attribute if meaningful.
1837 if (typeof value === 'boolean' && !isMeaningfulAttribute) {
1838 continue;
1839 }
1840 result += ' ' + attribute;
1841
1842 // Boolean attributes should write attribute name, but without value.
1843 // Mere presence of attribute name is effective truthiness.
1844 if (isBooleanAttribute) {
1845 continue;
1846 }
1847 if (typeof value === 'string') {
1848 value = (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(value);
1849 }
1850 result += '="' + value + '"';
1851 }
1852 return result;
1853 }
1854
1855 /**
1856 * Renders a style object as a string attribute value.
1857 *
1858 * @param {Object} style Style object.
1859 *
1860 * @return {string} Style attribute value.
1861 */
1862 function renderStyle(style) {
1863 // Only generate from object, e.g. tolerate string value.
1864 if (!isPlainObject(style)) {
1865 return style;
1866 }
1867 let result;
1868 for (const property in style) {
1869 const value = style[property];
1870 if (null === value || undefined === value) {
1871 continue;
1872 }
1873 if (result) {
1874 result += ';';
1875 } else {
1876 result = '';
1877 }
1878 const normalName = getNormalStylePropertyName(property);
1879 const normalValue = getNormalStylePropertyValue(property, value);
1880 result += normalName + ':' + normalValue;
1881 }
1882 return result;
1883 }
1884 /* harmony default export */ const serialize = (renderElement);
1885
1886 ;// CONCATENATED MODULE: ./packages/element/build-module/index.js
1887
1888
1889
1890
1891
1892
1893
1894
1895 })();
1896
1897 (window.wp = window.wp || {}).element = __webpack_exports__;
1898 /******/ })()
1899 ;