PluginProbe
Gutenberg / 21.7.0
Gutenberg v21.7.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 21.7.0, at build/element/index.js

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