[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ var __webpack_modules__ = ({ 2 3 /***/ 622: 4 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 5 6 /* harmony export */ __webpack_require__.d(__webpack_exports__, { 7 /* harmony export */ Ob: () => (/* binding */ G), 8 /* harmony export */ Qv: () => (/* binding */ E), 9 /* harmony export */ XX: () => (/* binding */ D), 10 /* harmony export */ fF: () => (/* binding */ l), 11 /* harmony export */ h: () => (/* binding */ g), 12 /* harmony export */ q6: () => (/* binding */ J), 13 /* harmony export */ uA: () => (/* binding */ x), 14 /* harmony export */ zO: () => (/* binding */ t) 15 /* harmony export */ }); 16 /* unused harmony exports Fragment, createElement, createRef, toChildArray */ 17 var n,l,u,t,i,r,o,e,f,c,s,a,h,p={},v=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,d=Array.isArray;function w(n,l){for(var u in l)n[u]=l[u];return n}function _(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function g(l,u,t){var i,r,o,e={};for(o in u)"key"==o?i=u[o]:"ref"==o?r=u[o]:e[o]=u[o];if(arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===e[o]&&(e[o]=l.defaultProps[o]);return m(l,e,i,r,null)}function m(n,t,i,r,o){var e={type:n,props:t,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==o?++u:o,__i:-1,__u:0};return null==o&&null!=l.vnode&&l.vnode(e),e}function b(){return{current:null}}function k(n){return n.children}function x(n,l){this.props=n,this.context=l}function C(n,l){if(null==l)return n.__?C(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?C(n):null}function S(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return S(n)}}function M(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!P.__r++||r!==l.debounceRendering)&&((r=l.debounceRendering)||o)(P)}function P(){var n,u,t,r,o,f,c,s;for(i.sort(e);n=i.shift();)n.__d&&(u=i.length,r=void 0,f=(o=(t=n).__v).__e,c=[],s=[],t.__P&&((r=w({},o)).__v=o.__v+1,l.vnode&&l.vnode(r),j(t.__P,r,o,t.__n,t.__P.namespaceURI,32&o.__u?[f]:null,c,null==f?C(o):f,!!(32&o.__u),s),r.__v=o.__v,r.__.__k[r.__i]=r,z(c,r,s),r.__e!=f&&S(r)),i.length>u&&i.sort(e));P.__r=0}function $(n,l,u,t,i,r,o,e,f,c,s){var a,h,y,d,w,_,g=t&&t.__k||v,m=l.length;for(f=I(u,l,g,f,m),a=0;a<m;a++)null!=(y=u.__k[a])&&(h=-1===y.__i?p:g[y.__i]||p,y.__i=a,_=j(n,y,h,i,r,o,e,f,c,s),d=y.__e,y.ref&&h.ref!=y.ref&&(h.ref&&V(h.ref,null,y),s.push(y.ref,y.__c||d,y)),null==w&&null!=d&&(w=d),4&y.__u||h.__k===y.__k?f=A(y,f,n):"function"==typeof y.type&&void 0!==_?f=_:d&&(f=d.nextSibling),y.__u&=-7);return u.__e=w,f}function I(n,l,u,t,i){var r,o,e,f,c,s=u.length,a=s,h=0;for(n.__k=new Array(i),r=0;r<i;r++)null!=(o=l[r])&&"boolean"!=typeof o&&"function"!=typeof o?(f=r+h,(o=n.__k[r]="string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?m(null,o,null,null,null):d(o)?m(k,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?m(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=n,o.__b=n.__b+1,e=null,-1!==(c=o.__i=L(o,u,f,a))&&(a--,(e=u[c])&&(e.__u|=2)),null==e||null===e.__v?(-1==c&&h--,"function"!=typeof o.type&&(o.__u|=4)):c!=f&&(c==f-1?h--:c==f+1?h++:(c>f?h--:h++,o.__u|=4))):n.__k[r]=null;if(a)for(r=0;r<s;r++)null!=(e=u[r])&&0==(2&e.__u)&&(e.__e==t&&(t=C(e)),q(e,e));return t}function A(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=A(t[i],l,u));return l}n.__e!=l&&(l&&n.type&&!u.contains(l)&&(l=C(n)),u.insertBefore(n.__e,l||null),l=n.__e);do{l=l&&l.nextSibling}while(null!=l&&8==l.nodeType);return l}function H(n,l){return l=l||[],null==n||"boolean"==typeof n||(d(n)?n.some(function(n){H(n,l)}):l.push(n)),l}function L(n,l,u,t){var i,r,o=n.key,e=n.type,f=l[u];if(null===f||f&&o==f.key&&e===f.type&&0==(2&f.__u))return u;if(t>(null!=f&&0==(2&f.__u)?1:0))for(i=u-1,r=u+1;i>=0||r<l.length;){if(i>=0){if((f=l[i])&&0==(2&f.__u)&&o==f.key&&e===f.type)return i;i--}if(r<l.length){if((f=l[r])&&0==(2&f.__u)&&o==f.key&&e===f.type)return r;r++}}return-1}function T(n,l,u){"-"==l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||y.test(l)?u:u+"px"}function F(n,l,u,t,i){var r;n:if("style"==l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||T(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||T(n.style,l,u[l])}else if("o"==l[0]&&"n"==l[1])r=l!=(l=l.replace(f,"$1")),l=l.toLowerCase()in n||"onFocusOut"==l||"onFocusIn"==l?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?t?u.u=t.u:(u.u=c,n.addEventListener(l,r?a:s,r)):n.removeEventListener(l,r?a:s,r);else{if("http://www.w3.org/2000/svg"==i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=l&&"height"!=l&&"href"!=l&&"list"!=l&&"form"!=l&&"tabIndex"!=l&&"download"!=l&&"rowSpan"!=l&&"colSpan"!=l&&"role"!=l&&"popover"!=l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!=l[4]?n.removeAttribute(l):n.setAttribute(l,"popover"==l&&1==u?"":u))}}function O(n){return function(u){if(this.l){var t=this.l[u.type+n];if(null==u.t)u.t=c++;else if(u.t<t.u)return;return t(l.event?l.event(u):u)}}}function j(n,u,t,i,r,o,e,f,c,s){var a,h,p,v,y,g,m,b,C,S,M,P,I,A,H,L,T,F=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),o=[f=u.__e=t.__e]),(a=l.__b)&&a(u);n:if("function"==typeof F)try{if(b=u.props,C="prototype"in F&&F.prototype.render,S=(a=F.contextType)&&i[a.__c],M=a?S?S.props.value:a.__:i,t.__c?m=(h=u.__c=t.__c).__=h.__E:(C?u.__c=h=new F(b,M):(u.__c=h=new x(b,M),h.constructor=F,h.render=B),S&&S.sub(h),h.props=b,h.state||(h.state={}),h.context=M,h.__n=i,p=h.__d=!0,h.__h=[],h._sb=[]),C&&null==h.__s&&(h.__s=h.state),C&&null!=F.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=w({},h.__s)),w(h.__s,F.getDerivedStateFromProps(b,h.__s))),v=h.props,y=h.state,h.__v=u,p)C&&null==F.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),C&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(C&&null==F.getDerivedStateFromProps&&b!==v&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(b,M),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(b,h.__s,M)||u.__v==t.__v)){for(u.__v!=t.__v&&(h.props=b,h.state=h.__s,h.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.some(function(n){n&&(n.__=u)}),P=0;P<h._sb.length;P++)h.__h.push(h._sb[P]);h._sb=[],h.__h.length&&e.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(b,h.__s,M),C&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(v,y,g)})}if(h.context=M,h.props=b,h.__P=n,h.__e=!1,I=l.__r,A=0,C){for(h.state=h.__s,h.__d=!1,I&&I(u),a=h.render(h.props,h.state,h.context),H=0;H<h._sb.length;H++)h.__h.push(h._sb[H]);h._sb=[]}else do{h.__d=!1,I&&I(u),a=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++A<25);h.state=h.__s,null!=h.getChildContext&&(i=w(w({},i),h.getChildContext())),C&&!p&&null!=h.getSnapshotBeforeUpdate&&(g=h.getSnapshotBeforeUpdate(v,y)),f=$(n,d(L=null!=a&&a.type===k&&null==a.key?a.props.children:a)?L:[L],u,t,i,r,o,e,f,c,s),h.base=u.__e,u.__u&=-161,h.__h.length&&e.push(h),m&&(h.__E=h.__=null)}catch(n){if(u.__v=null,c||null!=o)if(n.then){for(u.__u|=c?160:128;f&&8==f.nodeType&&f.nextSibling;)f=f.nextSibling;o[o.indexOf(f)]=null,u.__e=f}else for(T=o.length;T--;)_(o[T]);else u.__e=t.__e,u.__k=t.__k;l.__e(n,u,t)}else null==o&&u.__v==t.__v?(u.__k=t.__k,u.__e=t.__e):f=u.__e=N(t.__e,u,t,i,r,o,e,c,s);return(a=l.diffed)&&a(u),128&u.__u?void 0:f}function z(n,u,t){for(var i=0;i<t.length;i++)V(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function N(u,t,i,r,o,e,f,c,s){var a,h,v,y,w,g,m,b=i.props,k=t.props,x=t.type;if("svg"==x?o="http://www.w3.org/2000/svg":"math"==x?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=e)for(a=0;a<e.length;a++)if((w=e[a])&&"setAttribute"in w==!!x&&(x?w.localName==x:3==w.nodeType)){u=w,e[a]=null;break}if(null==u){if(null==x)return document.createTextNode(k);u=document.createElementNS(o,x,k.is&&k),c&&(l.__m&&l.__m(t,e),c=!1),e=null}if(null===x)b===k||c&&u.data===k||(u.data=k);else{if(e=e&&n.call(u.childNodes),b=i.props||p,!c&&null!=e)for(b={},a=0;a<u.attributes.length;a++)b[(w=u.attributes[a]).name]=w.value;for(a in b)if(w=b[a],"children"==a);else if("dangerouslySetInnerHTML"==a)v=w;else if(!(a in k)){if("value"==a&&"defaultValue"in k||"checked"==a&&"defaultChecked"in k)continue;F(u,a,null,w,o)}for(a in k)w=k[a],"children"==a?y=w:"dangerouslySetInnerHTML"==a?h=w:"value"==a?g=w:"checked"==a?m=w:c&&"function"!=typeof w||b[a]===w||F(u,a,w,b[a],o);if(h)c||v&&(h.__html===v.__html||h.__html===u.innerHTML)||(u.innerHTML=h.__html),t.__k=[];else if(v&&(u.innerHTML=""),$(u,d(y)?y:[y],t,i,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":o,e,f,e?e[0]:i.__k&&C(i,0),c,s),null!=e)for(a=e.length;a--;)_(e[a]);c||(a="value","progress"==x&&null==g?u.removeAttribute("value"):void 0!==g&&(g!==u[a]||"progress"==x&&!g||"option"==x&&g!==b[a])&&F(u,a,g,b[a],o),a="checked",void 0!==m&&m!==u[a]&&F(u,a,m,b[a],o))}return u}function V(n,u,t){try{if("function"==typeof n){var i="function"==typeof n.__u;i&&n.__u(),i&&null==u||(n.__u=n(u))}else n.current=u}catch(n){l.__e(n,t)}}function q(n,u,t){var i,r;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||V(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&q(i[r],u,t||"function"!=typeof n.type);t||_(n.__e),n.__c=n.__=n.__e=void 0}function B(n,l,u){return this.constructor(n,u)}function D(u,t,i){var r,o,e,f;t==document&&(t=document.documentElement),l.__&&l.__(u,t),o=(r="function"==typeof i)?null:i&&i.__k||t.__k,e=[],f=[],j(t,u=(!r&&i||t).__k=g(k,null,[u]),o||p,p,t.namespaceURI,!r&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,e,!r&&i?i:o?o.__e:t.firstChild,r,f),z(e,u,f)}function E(n,l){D(n,l,E)}function G(l,u,t){var i,r,o,e,f=w({},l.props);for(o in l.type&&l.type.defaultProps&&(e=l.type.defaultProps),u)"key"==o?i=u[o]:"ref"==o?r=u[o]:f[o]=void 0===u[o]&&void 0!==e?e[o]:u[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),m(l.type,f,i||l.key,r||l.ref,null)}function J(n,l){var u={__c:l="__cC"+h++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=new Set,(t={})[l]=this,this.getChildContext=function(){return t},this.componentWillUnmount=function(){u=null},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.forEach(function(n){n.__e=!0,M(n)})},this.sub=function(n){u.add(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u&&u.delete(n),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=v.slice,l={__e:function(n,l,u,t){for(var i,r,o;l=l.__;)if((i=l.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(n)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),o=i.__d),o)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&null==n.constructor},x.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=w({},this.state),"function"==typeof n&&(n=n(w({},u),this.props)),n&&w(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),M(this))},x.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),M(this))},x.prototype.render=k,i=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,e=function(n,l){return n.__v.__b-l.__v.__b},P.__r=0,f=/(PointerCapture)$|Capture$/i,c=0,s=O(!1),a=O(!0),h=0; 18 19 20 /***/ }) 21 22 /******/ }); 23 /************************************************************************/ 24 /******/ // The module cache 25 /******/ var __webpack_module_cache__ = {}; 26 /******/ 27 /******/ // The require function 28 /******/ function __webpack_require__(moduleId) { 29 /******/ // Check if module is in cache 30 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 31 /******/ if (cachedModule !== undefined) { 32 /******/ return cachedModule.exports; 33 /******/ } 34 /******/ // Create a new module (and put it into the cache) 35 /******/ var module = __webpack_module_cache__[moduleId] = { 36 /******/ // no module.id needed 37 /******/ // no module.loaded needed 38 /******/ exports: {} 39 /******/ }; 40 /******/ 41 /******/ // Execute the module function 42 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 43 /******/ 44 /******/ // Return the exports of the module 45 /******/ return module.exports; 46 /******/ } 47 /******/ 48 /************************************************************************/ 49 /******/ /* webpack/runtime/define property getters */ 50 /******/ (() => { 51 /******/ // define getter functions for harmony exports 52 /******/ __webpack_require__.d = (exports, definition) => { 53 /******/ for(var key in definition) { 54 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 55 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 56 /******/ } 57 /******/ } 58 /******/ }; 59 /******/ })(); 60 /******/ 61 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 62 /******/ (() => { 63 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 64 /******/ })(); 65 /******/ 66 /************************************************************************/ 67 var __webpack_exports__ = {}; 68 69 // EXPORTS 70 __webpack_require__.d(__webpack_exports__, { 71 zj: () => (/* reexport */ getConfig), 72 SD: () => (/* reexport */ getContext), 73 V6: () => (/* reexport */ getElement), 74 $K: () => (/* reexport */ getServerContext), 75 vT: () => (/* reexport */ getServerState), 76 jb: () => (/* binding */ privateApis), 77 yT: () => (/* reexport */ splitTask), 78 M_: () => (/* reexport */ store), 79 hb: () => (/* reexport */ useCallback), 80 vJ: () => (/* reexport */ useEffect), 81 ip: () => (/* reexport */ useInit), 82 Nf: () => (/* reexport */ useLayoutEffect), 83 Kr: () => (/* reexport */ useMemo), 84 li: () => (/* reexport */ A), 85 J0: () => (/* reexport */ h), 86 FH: () => (/* reexport */ useWatch), 87 v4: () => (/* reexport */ withScope) 88 }); 89 90 // EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js 91 var preact_module = __webpack_require__(622); 92 ;// ./node_modules/preact/hooks/dist/hooks.module.js 93 var hooks_module_t,r,hooks_module_u,i,hooks_module_o=0,hooks_module_f=[],hooks_module_c=preact_module/* options */.fF,e=hooks_module_c.__b,a=hooks_module_c.__r,v=hooks_module_c.diffed,l=hooks_module_c.__c,m=hooks_module_c.unmount,s=hooks_module_c.__;function d(n,t){hooks_module_c.__h&&hooks_module_c.__h(r,n,hooks_module_o||t),hooks_module_o=0;var u=r.__H||(r.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({}),u.__[n]}function h(n){return hooks_module_o=1,p(D,n)}function p(n,u,i){var o=d(hooks_module_t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):D(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return!!n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=o.__c.props!==n;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),c&&c.call(this,n,t,r)||i};r.u=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function y(n,u){var i=d(hooks_module_t++,3);!hooks_module_c.__s&&C(i.__H,u)&&(i.__=n,i.i=u,r.__H.__h.push(i))}function _(n,u){var i=d(hooks_module_t++,4);!hooks_module_c.__s&&C(i.__H,u)&&(i.__=n,i.i=u,r.__h.push(i))}function A(n){return hooks_module_o=5,T(function(){return{current:n}},[])}function F(n,t,r){hooks_module_o=6,_(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function T(n,r){var u=d(hooks_module_t++,7);return C(u.__H,r)&&(u.__=n(),u.__H=r,u.__h=n),u.__}function q(n,t){return hooks_module_o=8,T(function(){return n},t)}function x(n){var u=r.context[n.__c],i=d(hooks_module_t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function P(n,t){hooks_module_c.useDebugValue&&hooks_module_c.useDebugValue(t?t(n):n)}function b(n){var u=d(hooks_module_t++,10),i=h();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function g(){var n=d(hooks_module_t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__="P"+i[0]+"-"+i[1]++}return n.__}function j(){for(var n;n=hooks_module_f.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(z),n.__H.__h.forEach(B),n.__H.__h=[]}catch(t){n.__H.__h=[],hooks_module_c.__e(t,n.__v)}}hooks_module_c.__b=function(n){r=null,e&&e(n)},hooks_module_c.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),s&&s(n,t)},hooks_module_c.__r=function(n){a&&a(n),hooks_module_t=0;var i=(r=n.__c).__H;i&&(hooks_module_u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(i.__h.forEach(z),i.__h.forEach(B),i.__h=[],hooks_module_t=0)),hooks_module_u=r},hooks_module_c.diffed=function(n){v&&v(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==hooks_module_f.push(t)&&i===hooks_module_c.requestAnimationFrame||((i=hooks_module_c.requestAnimationFrame)||w)(j)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),hooks_module_u=r=null},hooks_module_c.__c=function(n,t){t.some(function(n){try{n.__h.forEach(z),n.__h=n.__h.filter(function(n){return!n.__||B(n)})}catch(r){t.some(function(n){n.__h&&(n.__h=[])}),t=[],hooks_module_c.__e(r,n.__v)}}),l&&l(n,t)},hooks_module_c.unmount=function(n){m&&m(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{z(n)}catch(n){t=n}}),r.__H=void 0,t&&hooks_module_c.__e(t,r.__v))};var k="function"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);k&&(t=requestAnimationFrame(r))}function z(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function B(n){var t=r;n.__c=n.__(),r=t}function C(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function D(n,t){return"function"==typeof t?t(n):t} 94 95 ;// ./node_modules/@preact/signals-core/dist/signals-core.module.js 96 var signals_core_module_i=Symbol.for("preact-signals");function signals_core_module_t(){if(!(signals_core_module_s>1)){var i,t=!1;while(void 0!==signals_core_module_h){var r=signals_core_module_h;signals_core_module_h=void 0;signals_core_module_f++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&signals_core_module_c(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=o}}signals_core_module_f=0;signals_core_module_s--;if(t)throw i}else signals_core_module_s--}function signals_core_module_r(i){if(signals_core_module_s>0)return i();signals_core_module_s++;try{return i()}finally{signals_core_module_t()}}var signals_core_module_o=void 0;function n(i){var t=signals_core_module_o;signals_core_module_o=void 0;try{return i()}finally{signals_core_module_o=t}}var signals_core_module_h=void 0,signals_core_module_s=0,signals_core_module_f=0,signals_core_module_v=0;function signals_core_module_e(i){if(void 0!==signals_core_module_o){var t=i.n;if(void 0===t||t.t!==signals_core_module_o){t={i:0,S:i,p:signals_core_module_o.s,n:void 0,t:signals_core_module_o,e:void 0,x:void 0,r:t};if(void 0!==signals_core_module_o.s)signals_core_module_o.s.n=t;signals_core_module_o.s=t;i.n=t;if(32&signals_core_module_o.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=signals_core_module_o.s;t.n=void 0;signals_core_module_o.s.n=t;signals_core_module_o.s=t}return t}}}function signals_core_module_u(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}signals_core_module_u.prototype.brand=signals_core_module_i;signals_core_module_u.prototype.h=function(){return!0};signals_core_module_u.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};signals_core_module_u.prototype.U=function(i){if(void 0!==this.t){var t=i.e,r=i.x;if(void 0!==t){t.x=r;i.e=void 0}if(void 0!==r){r.e=t;i.x=void 0}if(i===this.t)this.t=r}};signals_core_module_u.prototype.subscribe=function(i){var t=this;return E(function(){var r=t.value,n=signals_core_module_o;signals_core_module_o=void 0;try{i(r)}finally{signals_core_module_o=n}})};signals_core_module_u.prototype.valueOf=function(){return this.value};signals_core_module_u.prototype.toString=function(){return this.value+""};signals_core_module_u.prototype.toJSON=function(){return this.value};signals_core_module_u.prototype.peek=function(){var i=signals_core_module_o;signals_core_module_o=void 0;try{return this.value}finally{signals_core_module_o=i}};Object.defineProperty(signals_core_module_u.prototype,"value",{get:function(){var i=signals_core_module_e(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(signals_core_module_f>100)throw new Error("Cycle detected");this.v=i;this.i++;signals_core_module_v++;signals_core_module_s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{signals_core_module_t()}}}});function signals_core_module_d(i){return new signals_core_module_u(i)}function signals_core_module_c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function signals_core_module_a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function signals_core_module_l(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=r}function signals_core_module_y(i){signals_core_module_u.call(this,void 0);this.x=i;this.s=void 0;this.g=signals_core_module_v-1;this.f=4}(signals_core_module_y.prototype=new signals_core_module_u).h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===signals_core_module_v)return!0;this.g=signals_core_module_v;this.f|=1;if(this.i>0&&!signals_core_module_c(this)){this.f&=-2;return!0}var i=signals_core_module_o;try{signals_core_module_a(this);signals_core_module_o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}signals_core_module_o=i;signals_core_module_l(this);this.f&=-2;return!0};signals_core_module_y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}signals_core_module_u.prototype.S.call(this,i)};signals_core_module_y.prototype.U=function(i){if(void 0!==this.t){signals_core_module_u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};signals_core_module_y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(signals_core_module_y.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=signals_core_module_e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function signals_core_module_w(i){return new signals_core_module_y(i)}function signals_core_module_(i){var r=i.u;i.u=void 0;if("function"==typeof r){signals_core_module_s++;var n=signals_core_module_o;signals_core_module_o=void 0;try{r()}catch(t){i.f&=-2;i.f|=8;signals_core_module_g(i);throw t}finally{signals_core_module_o=n;signals_core_module_t()}}}function signals_core_module_g(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;signals_core_module_(i)}function signals_core_module_p(i){if(signals_core_module_o!==this)throw new Error("Out-of-order effect");signals_core_module_l(this);signals_core_module_o=i;this.f&=-2;if(8&this.f)signals_core_module_g(this);signals_core_module_t()}function signals_core_module_b(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32}signals_core_module_b.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};signals_core_module_b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;signals_core_module_(this);signals_core_module_a(this);signals_core_module_s++;var i=signals_core_module_o;signals_core_module_o=this;return signals_core_module_p.bind(this,i)};signals_core_module_b.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=signals_core_module_h;signals_core_module_h=this}};signals_core_module_b.prototype.d=function(){this.f|=8;if(!(1&this.f))signals_core_module_g(this)};function E(i){var t=new signals_core_module_b(i);try{t.c()}catch(i){t.d();throw i}return t.d.bind(t)} 97 ;// ./node_modules/@preact/signals/dist/signals.module.js 98 var signals_module_v,signals_module_s;function signals_module_l(i,n){preact_module/* options */.fF[i]=n.bind(null,preact_module/* options */.fF[i]||function(){})}function signals_module_d(i){if(signals_module_s)signals_module_s();signals_module_s=i&&i.S()}function signals_module_h(i){var r=this,f=i.data,o=useSignal(f);o.value=f;var e=T(function(){var i=r.__v;while(i=i.__)if(i.__c){i.__c.__$f|=4;break}r.__$u.c=function(){var i,t=r.__$u.S(),f=e.value;t();if((0,preact_module/* isValidElement */.zO)(f)||3!==(null==(i=r.base)?void 0:i.nodeType)){r.__$f|=1;r.setState({})}else r.base.data=f};return signals_core_module_w(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""})},[]);return e.value}signals_module_h.displayName="_st";Object.defineProperties(signals_core_module_u.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:signals_module_h},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});signals_module_l("__b",function(i,r){if("string"==typeof r.type){var n,t=r.props;for(var f in t)if("children"!==f){var o=t[f];if(o instanceof signals_core_module_u){if(!n)r.__np=n={};n[f]=o;t[f]=o.peek()}}}i(r)});signals_module_l("__r",function(i,r){signals_module_d();var n,t=r.__c;if(t){t.__$f&=-2;if(void 0===(n=t.__$u))t.__$u=n=function(i){var r;E(function(){r=this});r.c=function(){t.__$f|=1;t.setState({})};return r}()}signals_module_v=t;signals_module_d(n);i(r)});signals_module_l("__e",function(i,r,n,t){signals_module_d();signals_module_v=void 0;i(r,n,t)});signals_module_l("diffed",function(i,r){signals_module_d();signals_module_v=void 0;var n;if("string"==typeof r.type&&(n=r.__e)){var t=r.__np,f=r.props;if(t){var o=n.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in t)){u.d();o[e]=void 0}}else n.U=o={};for(var a in t){var c=o[a],s=t[a];if(void 0===c){c=signals_module_p(n,a,s,f);o[a]=c}else c.o(s,f)}}}i(r)});function signals_module_p(i,r,n,t){var f=r in i&&void 0===i.ownerSVGElement,o=signals_core_module_d(n);return{o:function(i,r){o.value=i;t=r},d:E(function(){var n=o.value.value;if(t[r]!==n){t[r]=n;if(f)i[r]=n;else if(n)i.setAttribute(r,n);else i.removeAttribute(r)}})}}signals_module_l("unmount",function(i,r){if("string"==typeof r.type){var n=r.__e;if(n){var t=n.U;if(t){n.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}}else{var e=r.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}i(r)});signals_module_l("__h",function(i,r,n,t){if(t<3||9===t)r.__$f|=2;i(r,n,t)});preact_module/* Component */.uA.prototype.shouldComponentUpdate=function(i,r){var n=this.__$u,t=n&&void 0!==n.s;for(var f in r)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(t||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(t||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var o in i)if("__source"!==o&&i[o]!==this.props[o])return!0;for(var e in this.props)if(!(e in i))return!0;return!1};function useSignal(i){return T(function(){return signals_core_module_d(i)},[])}function useComputed(i){var r=f(i);r.current=i;signals_module_v.__$f|=4;return t(function(){return u(function(){return r.current()})},[])}function useSignalEffect(i){var r=f(i);r.current=i;o(function(){return c(function(){return r.current()})},[])} 99 ;// ./node_modules/@wordpress/interactivity/build-module/namespaces.js 100 const namespaceStack = []; 101 const getNamespace = () => namespaceStack.slice(-1)[0]; 102 const setNamespace = namespace => { 103 namespaceStack.push(namespace); 104 }; 105 const resetNamespace = () => { 106 namespaceStack.pop(); 107 }; 108 109 ;// ./node_modules/@wordpress/interactivity/build-module/scopes.js 110 /** 111 * External dependencies 112 */ 113 114 /** 115 * Internal dependencies 116 */ 117 118 // Store stacks for the current scope and the default namespaces and export APIs 119 // to interact with them. 120 const scopeStack = []; 121 const getScope = () => scopeStack.slice(-1)[0]; 122 const setScope = scope => { 123 scopeStack.push(scope); 124 }; 125 const resetScope = () => { 126 scopeStack.pop(); 127 }; 128 129 // Wrap the element props to prevent modifications. 130 const immutableMap = new WeakMap(); 131 const immutableError = () => { 132 throw new Error('Please use `data-wp-bind` to modify the attributes of an element.'); 133 }; 134 const immutableHandlers = { 135 get(target, key, receiver) { 136 const value = Reflect.get(target, key, receiver); 137 return !!value && typeof value === 'object' ? deepImmutable(value) : value; 138 }, 139 set: immutableError, 140 deleteProperty: immutableError 141 }; 142 const deepImmutable = target => { 143 if (!immutableMap.has(target)) { 144 immutableMap.set(target, new Proxy(target, immutableHandlers)); 145 } 146 return immutableMap.get(target); 147 }; 148 149 /** 150 * Retrieves the context inherited by the element evaluating a function from the 151 * store. The returned value depends on the element and the namespace where the 152 * function calling `getContext()` exists. 153 * 154 * @param namespace Store namespace. By default, the namespace where the calling 155 * function exists is used. 156 * @return The context content. 157 */ 158 const getContext = namespace => { 159 const scope = getScope(); 160 if (true) { 161 if (!scope) { 162 throw Error('Cannot call `getContext()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); 163 } 164 } 165 return scope.context[namespace || getNamespace()]; 166 }; 167 168 /** 169 * Retrieves a representation of the element where a function from the store 170 * is being evaluated. Such representation is read-only, and contains a 171 * reference to the DOM element, its props and a local reactive state. 172 * 173 * @return Element representation. 174 */ 175 const getElement = () => { 176 const scope = getScope(); 177 if (true) { 178 if (!scope) { 179 throw Error('Cannot call `getElement()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); 180 } 181 } 182 const { 183 ref, 184 attributes 185 } = scope; 186 return Object.freeze({ 187 ref: ref.current, 188 attributes: deepImmutable(attributes) 189 }); 190 }; 191 192 /** 193 * Retrieves the part of the inherited context defined and updated from the 194 * server. 195 * 196 * The object returned is read-only, and includes the context defined in PHP 197 * with `wp_interactivity_data_wp_context()`, including the corresponding 198 * inherited properties. When `actions.navigate()` is called, this object is 199 * updated to reflect the changes in the new visited page, without affecting the 200 * context returned by `getContext()`. Directives can subscribe to those changes 201 * to update the context if needed. 202 * 203 * @example 204 * ```js 205 * store('...', { 206 * callbacks: { 207 * updateServerContext() { 208 * const context = getContext(); 209 * const serverContext = getServerContext(); 210 * // Override some property with the new value that came from the server. 211 * context.overridableProp = serverContext.overridableProp; 212 * }, 213 * }, 214 * }); 215 * ``` 216 * 217 * @param namespace Store namespace. By default, the namespace where the calling 218 * function exists is used. 219 * @return The server context content. 220 */ 221 const getServerContext = namespace => { 222 const scope = getScope(); 223 if (true) { 224 if (!scope) { 225 throw Error('Cannot call `getServerContext()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); 226 } 227 } 228 return scope.serverContext[namespace || getNamespace()]; 229 }; 230 231 ;// ./node_modules/@wordpress/interactivity/build-module/utils.js 232 /** 233 * External dependencies 234 */ 235 236 237 238 /** 239 * Internal dependencies 240 */ 241 242 243 /** 244 * Executes a callback function after the next frame is rendered. 245 * 246 * @param callback The callback function to be executed. 247 * @return A promise that resolves after the callback function is executed. 248 */ 249 const afterNextFrame = callback => { 250 return new Promise(resolve => { 251 const done = () => { 252 clearTimeout(timeout); 253 window.cancelAnimationFrame(raf); 254 setTimeout(() => { 255 callback(); 256 resolve(); 257 }); 258 }; 259 const timeout = setTimeout(done, 100); 260 const raf = window.requestAnimationFrame(done); 261 }); 262 }; 263 264 /** 265 * Returns a promise that resolves after yielding to main. 266 * 267 * @return Promise<void> 268 */ 269 const splitTask = typeof window.scheduler?.yield === 'function' ? window.scheduler.yield.bind(window.scheduler) : () => { 270 return new Promise(resolve => { 271 setTimeout(resolve, 0); 272 }); 273 }; 274 275 /** 276 * Creates a Flusher object that can be used to flush computed values and notify listeners. 277 * 278 * Using the mangled properties: 279 * this.c: this._callback 280 * this.x: this._compute 281 * https://github.com/preactjs/signals/blob/main/mangle.json 282 * 283 * @param compute The function that computes the value to be flushed. 284 * @param notify The function that notifies listeners when the value is flushed. 285 * @return The Flusher object with `flush` and `dispose` properties. 286 */ 287 function createFlusher(compute, notify) { 288 let flush = () => undefined; 289 const dispose = E(function () { 290 flush = this.c.bind(this); 291 this.x = compute; 292 this.c = notify; 293 return compute(); 294 }); 295 return { 296 flush, 297 dispose 298 }; 299 } 300 301 /** 302 * Custom hook that executes a callback function whenever a signal is triggered. 303 * Version of `useSignalEffect` with a `useEffect`-like execution. This hook 304 * implementation comes from this PR, but we added short-cirtuiting to avoid 305 * infinite loops: https://github.com/preactjs/signals/pull/290 306 * 307 * @param callback The callback function to be executed. 308 */ 309 function utils_useSignalEffect(callback) { 310 y(() => { 311 let eff = null; 312 let isExecuting = false; 313 const notify = async () => { 314 if (eff && !isExecuting) { 315 isExecuting = true; 316 await afterNextFrame(eff.flush); 317 isExecuting = false; 318 } 319 }; 320 eff = createFlusher(callback, notify); 321 return eff.dispose; 322 }, []); 323 } 324 325 /** 326 * Returns the passed function wrapped with the current scope so it is 327 * accessible whenever the function runs. This is primarily to make the scope 328 * available inside hook callbacks. 329 * 330 * Asynchronous functions should use generators that yield promises instead of awaiting them. 331 * See the documentation for details: https://developer.wordpress.org/block-editor/reference-guides/packages/packages-interactivity/packages-interactivity-api-reference/#the-store 332 * 333 * @param func The passed function. 334 * @return The wrapped function. 335 */ 336 337 function withScope(func) { 338 const scope = getScope(); 339 const ns = getNamespace(); 340 if (func?.constructor?.name === 'GeneratorFunction') { 341 return async (...args) => { 342 const gen = func(...args); 343 let value; 344 let it; 345 while (true) { 346 setNamespace(ns); 347 setScope(scope); 348 try { 349 it = gen.next(value); 350 } finally { 351 resetScope(); 352 resetNamespace(); 353 } 354 try { 355 value = await it.value; 356 } catch (e) { 357 setNamespace(ns); 358 setScope(scope); 359 gen.throw(e); 360 } finally { 361 resetScope(); 362 resetNamespace(); 363 } 364 if (it.done) { 365 break; 366 } 367 } 368 return value; 369 }; 370 } 371 return (...args) => { 372 setNamespace(ns); 373 setScope(scope); 374 try { 375 return func(...args); 376 } finally { 377 resetNamespace(); 378 resetScope(); 379 } 380 }; 381 } 382 383 /** 384 * Accepts a function that contains imperative code which runs whenever any of 385 * the accessed _reactive_ properties (e.g., values from the global state or the 386 * context) is modified. 387 * 388 * This hook makes the element's scope available so functions like 389 * `getElement()` and `getContext()` can be used inside the passed callback. 390 * 391 * @param callback The hook callback. 392 */ 393 function useWatch(callback) { 394 utils_useSignalEffect(withScope(callback)); 395 } 396 397 /** 398 * Accepts a function that contains imperative code which runs only after the 399 * element's first render, mainly useful for initialization logic. 400 * 401 * This hook makes the element's scope available so functions like 402 * `getElement()` and `getContext()` can be used inside the passed callback. 403 * 404 * @param callback The hook callback. 405 */ 406 function useInit(callback) { 407 y(withScope(callback), []); 408 } 409 410 /** 411 * Accepts a function that contains imperative, possibly effectful code. The 412 * effects run after browser paint, without blocking it. 413 * 414 * This hook is equivalent to Preact's `useEffect` and makes the element's scope 415 * available so functions like `getElement()` and `getContext()` can be used 416 * inside the passed callback. 417 * 418 * @param callback Imperative function that can return a cleanup 419 * function. 420 * @param inputs If present, effect will only activate if the 421 * values in the list change (using `===`). 422 */ 423 function useEffect(callback, inputs) { 424 y(withScope(callback), inputs); 425 } 426 427 /** 428 * Accepts a function that contains imperative, possibly effectful code. Use 429 * this to read layout from the DOM and synchronously re-render. 430 * 431 * This hook is equivalent to Preact's `useLayoutEffect` and makes the element's 432 * scope available so functions like `getElement()` and `getContext()` can be 433 * used inside the passed callback. 434 * 435 * @param callback Imperative function that can return a cleanup 436 * function. 437 * @param inputs If present, effect will only activate if the 438 * values in the list change (using `===`). 439 */ 440 function useLayoutEffect(callback, inputs) { 441 _(withScope(callback), inputs); 442 } 443 444 /** 445 * Returns a memoized version of the callback that only changes if one of the 446 * inputs has changed (using `===`). 447 * 448 * This hook is equivalent to Preact's `useCallback` and makes the element's 449 * scope available so functions like `getElement()` and `getContext()` can be 450 * used inside the passed callback. 451 * 452 * @param callback Callback function. 453 * @param inputs If present, the callback will only be updated if the 454 * values in the list change (using `===`). 455 * 456 * @return The callback function. 457 */ 458 function useCallback(callback, inputs) { 459 return q(withScope(callback), inputs); 460 } 461 462 /** 463 * Pass a factory function and an array of inputs. `useMemo` will only recompute 464 * the memoized value when one of the inputs has changed. 465 * 466 * This hook is equivalent to Preact's `useMemo` and makes the element's scope 467 * available so functions like `getElement()` and `getContext()` can be used 468 * inside the passed factory function. 469 * 470 * @param factory Factory function that returns that value for memoization. 471 * @param inputs If present, the factory will only be run to recompute if 472 * the values in the list change (using `===`). 473 * 474 * @return The memoized value. 475 */ 476 function useMemo(factory, inputs) { 477 return T(withScope(factory), inputs); 478 } 479 480 /** 481 * Creates a root fragment by replacing a node or an array of nodes in a parent element. 482 * For wrapperless hydration. 483 * See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c 484 * 485 * @param parent The parent element where the nodes will be replaced. 486 * @param replaceNode The node or array of nodes to replace in the parent element. 487 * @return The created root fragment. 488 */ 489 const createRootFragment = (parent, replaceNode) => { 490 replaceNode = [].concat(replaceNode); 491 const sibling = replaceNode[replaceNode.length - 1].nextSibling; 492 function insert(child, root) { 493 parent.insertBefore(child, root || sibling); 494 } 495 return parent.__k = { 496 nodeType: 1, 497 parentNode: parent, 498 firstChild: replaceNode[0], 499 childNodes: replaceNode, 500 insertBefore: insert, 501 appendChild: insert, 502 removeChild(c) { 503 parent.removeChild(c); 504 } 505 }; 506 }; 507 508 /** 509 * Transforms a kebab-case string to camelCase. 510 * 511 * @param str The kebab-case string to transform to camelCase. 512 * @return The transformed camelCase string. 513 */ 514 function kebabToCamelCase(str) { 515 return str.replace(/^-+|-+$/g, '').toLowerCase().replace(/-([a-z])/g, function (_match, group1) { 516 return group1.toUpperCase(); 517 }); 518 } 519 const logged = new Set(); 520 521 /** 522 * Shows a warning with `message` if environment is not `production`. 523 * 524 * Based on the `@wordpress/warning` package. 525 * 526 * @param message Message to show in the warning. 527 */ 528 const warn = message => { 529 if (true) { 530 if (logged.has(message)) { 531 return; 532 } 533 534 // eslint-disable-next-line no-console 535 console.warn(message); 536 537 // Throwing an error and catching it immediately to improve debugging 538 // A consumer can use 'pause on caught exceptions' 539 try { 540 throw Error(message); 541 } catch (e) { 542 // Do nothing. 543 } 544 logged.add(message); 545 } 546 }; 547 548 /** 549 * Checks if the passed `candidate` is a plain object with just the `Object` 550 * prototype. 551 * 552 * @param candidate The item to check. 553 * @return Whether `candidate` is a plain object. 554 */ 555 const isPlainObject = candidate => Boolean(candidate && typeof candidate === 'object' && candidate.constructor === Object); 556 557 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/registry.js 558 /** 559 * Proxies for each object. 560 */ 561 const objToProxy = new WeakMap(); 562 const proxyToObj = new WeakMap(); 563 564 /** 565 * Namespaces for each created proxy. 566 */ 567 const proxyToNs = new WeakMap(); 568 569 /** 570 * Object types that can be proxied. 571 */ 572 const supported = new Set([Object, Array]); 573 574 /** 575 * Returns a proxy to the passed object with the given handlers, assigning the 576 * specified namespace to it. If a proxy for the passed object was created 577 * before, that proxy is returned. 578 * 579 * @param namespace The namespace that will be associated to this proxy. 580 * @param obj The object to proxify. 581 * @param handlers Handlers that the proxy will use. 582 * 583 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to 584 * check if a proxy can be created for a specific object. 585 * 586 * @return The created proxy. 587 */ 588 const createProxy = (namespace, obj, handlers) => { 589 if (!shouldProxy(obj)) { 590 throw Error('This object cannot be proxified.'); 591 } 592 if (!objToProxy.has(obj)) { 593 const proxy = new Proxy(obj, handlers); 594 objToProxy.set(obj, proxy); 595 proxyToObj.set(proxy, obj); 596 proxyToNs.set(proxy, namespace); 597 } 598 return objToProxy.get(obj); 599 }; 600 601 /** 602 * Returns the proxy for the given object. If there is no associated proxy, the 603 * function returns `undefined`. 604 * 605 * @param obj Object from which to know the proxy. 606 * @return Associated proxy or `undefined`. 607 */ 608 const getProxyFromObject = obj => objToProxy.get(obj); 609 610 /** 611 * Gets the namespace associated with the given proxy. 612 * 613 * Proxies have a namespace assigned upon creation. See {@link createProxy}. 614 * 615 * @param proxy Proxy. 616 * @return Namespace. 617 */ 618 const getNamespaceFromProxy = proxy => proxyToNs.get(proxy); 619 620 /** 621 * Checks if a given object can be proxied. 622 * 623 * @param candidate Object to know whether it can be proxied. 624 * @return True if the passed instance can be proxied. 625 */ 626 const shouldProxy = candidate => { 627 if (typeof candidate !== 'object' || candidate === null) { 628 return false; 629 } 630 return !proxyToNs.has(candidate) && supported.has(candidate.constructor); 631 }; 632 633 /** 634 * Returns the target object for the passed proxy. If the passed object is not a registered proxy, the 635 * function returns `undefined`. 636 * 637 * @param proxy Proxy from which to know the target. 638 * @return The target object or `undefined`. 639 */ 640 const getObjectFromProxy = proxy => proxyToObj.get(proxy); 641 642 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/signals.js 643 /** 644 * External dependencies 645 */ 646 647 648 /** 649 * Internal dependencies 650 */ 651 652 653 654 655 656 /** 657 * Identifier for property computeds not associated to any scope. 658 */ 659 const NO_SCOPE = {}; 660 661 /** 662 * Structure that manages reactivity for a property in a state object. It uses 663 * signals to keep track of property value or getter modifications. 664 */ 665 class PropSignal { 666 /** 667 * Proxy that holds the property this PropSignal is associated with. 668 */ 669 670 /** 671 * Relation of computeds by scope. These computeds are read-only signals 672 * that depend on whether the property is a value or a getter and, 673 * therefore, can return different values depending on the scope in which 674 * the getter is accessed. 675 */ 676 677 /** 678 * Signal with the value assigned to the related property. 679 */ 680 681 /** 682 * Signal with the getter assigned to the related property. 683 */ 684 685 /** 686 * Structure that manages reactivity for a property in a state object, using 687 * signals to keep track of property value or getter modifications. 688 * 689 * @param owner Proxy that holds the property this instance is associated 690 * with. 691 */ 692 constructor(owner) { 693 this.owner = owner; 694 this.computedsByScope = new WeakMap(); 695 } 696 697 /** 698 * Changes the internal value. If a getter was set before, it is set to 699 * `undefined`. 700 * 701 * @param value New value. 702 */ 703 setValue(value) { 704 this.update({ 705 value 706 }); 707 } 708 709 /** 710 * Changes the internal getter. If a value was set before, it is set to 711 * `undefined`. 712 * 713 * @param getter New getter. 714 */ 715 setGetter(getter) { 716 this.update({ 717 get: getter 718 }); 719 } 720 721 /** 722 * Returns the computed that holds the result of evaluating the prop in the 723 * current scope. 724 * 725 * These computeds are read-only signals that depend on whether the property 726 * is a value or a getter and, therefore, can return different values 727 * depending on the scope in which the getter is accessed. 728 * 729 * @return Computed that depends on the scope. 730 */ 731 getComputed() { 732 const scope = getScope() || NO_SCOPE; 733 if (!this.valueSignal && !this.getterSignal) { 734 this.update({}); 735 } 736 if (!this.computedsByScope.has(scope)) { 737 const callback = () => { 738 const getter = this.getterSignal?.value; 739 return getter ? getter.call(this.owner) : this.valueSignal?.value; 740 }; 741 setNamespace(getNamespaceFromProxy(this.owner)); 742 this.computedsByScope.set(scope, signals_core_module_w(withScope(callback))); 743 resetNamespace(); 744 } 745 return this.computedsByScope.get(scope); 746 } 747 748 /** 749 * Update the internal signals for the value and the getter of the 750 * corresponding prop. 751 * 752 * @param param0 753 * @param param0.get New getter. 754 * @param param0.value New value. 755 */ 756 update({ 757 get, 758 value 759 }) { 760 if (!this.valueSignal) { 761 this.valueSignal = signals_core_module_d(value); 762 this.getterSignal = signals_core_module_d(get); 763 } else if (value !== this.valueSignal.peek() || get !== this.getterSignal.peek()) { 764 signals_core_module_r(() => { 765 this.valueSignal.value = value; 766 this.getterSignal.value = get; 767 }); 768 } 769 } 770 } 771 772 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/state.js 773 /* wp:polyfill */ 774 /** 775 * External dependencies 776 */ 777 778 779 /** 780 * Internal dependencies 781 */ 782 783 784 785 786 787 /** 788 * Set of built-in symbols. 789 */ 790 const wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(value => typeof value === 'symbol')); 791 792 /** 793 * Relates each proxy with a map of {@link PropSignal} instances, representing 794 * the proxy's accessed properties. 795 */ 796 const proxyToProps = new WeakMap(); 797 798 /** 799 * Checks whether a {@link PropSignal | `PropSignal`} instance exists for the 800 * given property in the passed proxy. 801 * 802 * @param proxy Proxy of a state object or array. 803 * @param key The property key. 804 * @return `true` when it exists; false otherwise. 805 */ 806 const hasPropSignal = (proxy, key) => proxyToProps.has(proxy) && proxyToProps.get(proxy).has(key); 807 const readOnlyProxies = new WeakSet(); 808 809 /** 810 * Returns the {@link PropSignal | `PropSignal`} instance associated with the 811 * specified prop in the passed proxy. 812 * 813 * The `PropSignal` instance is generated if it doesn't exist yet, using the 814 * `initial` parameter to initialize the internal signals. 815 * 816 * @param proxy Proxy of a state object or array. 817 * @param key The property key. 818 * @param initial Initial data for the `PropSignal` instance. 819 * @return The `PropSignal` instance. 820 */ 821 const getPropSignal = (proxy, key, initial) => { 822 if (!proxyToProps.has(proxy)) { 823 proxyToProps.set(proxy, new Map()); 824 } 825 key = typeof key === 'number' ? `$key}` : key; 826 const props = proxyToProps.get(proxy); 827 if (!props.has(key)) { 828 const ns = getNamespaceFromProxy(proxy); 829 const prop = new PropSignal(proxy); 830 props.set(key, prop); 831 if (initial) { 832 const { 833 get, 834 value 835 } = initial; 836 if (get) { 837 prop.setGetter(get); 838 } else { 839 const readOnly = readOnlyProxies.has(proxy); 840 prop.setValue(shouldProxy(value) ? proxifyState(ns, value, { 841 readOnly 842 }) : value); 843 } 844 } 845 } 846 return props.get(key); 847 }; 848 849 /** 850 * Relates each proxied object (i.e., the original object) with a signal that 851 * tracks changes in the number of properties. 852 */ 853 const objToIterable = new WeakMap(); 854 855 /** 856 * When this flag is `true`, it avoids any signal subscription, overriding state 857 * props' "reactive" behavior. 858 */ 859 let peeking = false; 860 861 /** 862 * Handlers for reactive objects and arrays in the state. 863 */ 864 const stateHandlers = { 865 get(target, key, receiver) { 866 /* 867 * The property should not be reactive for the following cases: 868 * 1. While using the `peek` function to read the property. 869 * 2. The property exists but comes from the Object or Array prototypes. 870 * 3. The property key is a known symbol. 871 */ 872 if (peeking || !target.hasOwnProperty(key) && key in target || typeof key === 'symbol' && wellKnownSymbols.has(key)) { 873 return Reflect.get(target, key, receiver); 874 } 875 876 // At this point, the property should be reactive. 877 const desc = Object.getOwnPropertyDescriptor(target, key); 878 const prop = getPropSignal(receiver, key, desc); 879 const result = prop.getComputed().value; 880 881 /* 882 * Check if the property is a synchronous function. If it is, set the 883 * default namespace. Synchronous functions always run in the proper scope, 884 * which is set by the Directives component. 885 */ 886 if (typeof result === 'function') { 887 const ns = getNamespaceFromProxy(receiver); 888 return (...args) => { 889 setNamespace(ns); 890 try { 891 return result.call(receiver, ...args); 892 } finally { 893 resetNamespace(); 894 } 895 }; 896 } 897 return result; 898 }, 899 set(target, key, value, receiver) { 900 if (readOnlyProxies.has(receiver)) { 901 return false; 902 } 903 setNamespace(getNamespaceFromProxy(receiver)); 904 try { 905 return Reflect.set(target, key, value, receiver); 906 } finally { 907 resetNamespace(); 908 } 909 }, 910 defineProperty(target, key, desc) { 911 if (readOnlyProxies.has(getProxyFromObject(target))) { 912 return false; 913 } 914 const isNew = !(key in target); 915 const result = Reflect.defineProperty(target, key, desc); 916 if (result) { 917 const receiver = getProxyFromObject(target); 918 const prop = getPropSignal(receiver, key); 919 const { 920 get, 921 value 922 } = desc; 923 if (get) { 924 prop.setGetter(get); 925 } else { 926 const ns = getNamespaceFromProxy(receiver); 927 prop.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); 928 } 929 if (isNew && objToIterable.has(target)) { 930 objToIterable.get(target).value++; 931 } 932 933 /* 934 * Modify the `length` property value only if the related 935 * `PropSignal` exists, which means that there are subscriptions to 936 * this property. 937 */ 938 if (Array.isArray(target) && proxyToProps.get(receiver)?.has('length')) { 939 const length = getPropSignal(receiver, 'length'); 940 length.setValue(target.length); 941 } 942 } 943 return result; 944 }, 945 deleteProperty(target, key) { 946 if (readOnlyProxies.has(getProxyFromObject(target))) { 947 return false; 948 } 949 const result = Reflect.deleteProperty(target, key); 950 if (result) { 951 const prop = getPropSignal(getProxyFromObject(target), key); 952 prop.setValue(undefined); 953 if (objToIterable.has(target)) { 954 objToIterable.get(target).value++; 955 } 956 } 957 return result; 958 }, 959 ownKeys(target) { 960 if (!objToIterable.has(target)) { 961 objToIterable.set(target, signals_core_module_d(0)); 962 } 963 /* 964 *This subscribes to the signal while preventing the minifier from 965 * deleting this line in production. 966 */ 967 objToIterable._ = objToIterable.get(target).value; 968 return Reflect.ownKeys(target); 969 } 970 }; 971 972 /** 973 * Returns the proxy associated with the given state object, creating it if it 974 * does not exist. 975 * 976 * @param namespace The namespace that will be associated to this proxy. 977 * @param obj The object to proxify. 978 * @param options Options. 979 * @param options.readOnly Read-only. 980 * 981 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to 982 * check if a proxy can be created for a specific object. 983 * 984 * @return The associated proxy. 985 */ 986 const proxifyState = (namespace, obj, options) => { 987 const proxy = createProxy(namespace, obj, stateHandlers); 988 if (options?.readOnly) { 989 readOnlyProxies.add(proxy); 990 } 991 return proxy; 992 }; 993 994 /** 995 * Reads the value of the specified property without subscribing to it. 996 * 997 * @param obj The object to read the property from. 998 * @param key The property key. 999 * @return The property value. 1000 */ 1001 const peek = (obj, key) => { 1002 peeking = true; 1003 try { 1004 return obj[key]; 1005 } finally { 1006 peeking = false; 1007 } 1008 }; 1009 1010 /** 1011 * Internal recursive implementation for {@link deepMerge | `deepMerge`}. 1012 * 1013 * @param target The target object. 1014 * @param source The source object containing new values and props. 1015 * @param override Whether existing props should be overwritten or not (`true` 1016 * by default). 1017 */ 1018 const deepMergeRecursive = (target, source, override = true) => { 1019 // If target is not a plain object and the source is, we don't need to merge 1020 // them because the source will be used as the new value of the target. 1021 if (!(isPlainObject(target) && isPlainObject(source))) { 1022 return; 1023 } 1024 let hasNewKeys = false; 1025 for (const key in source) { 1026 const isNew = !(key in target); 1027 hasNewKeys = hasNewKeys || isNew; 1028 const desc = Object.getOwnPropertyDescriptor(source, key); 1029 const proxy = getProxyFromObject(target); 1030 const propSignal = !!proxy && hasPropSignal(proxy, key) && getPropSignal(proxy, key); 1031 1032 // Handle getters and setters 1033 if (typeof desc.get === 'function' || typeof desc.set === 'function') { 1034 if (override || isNew) { 1035 // Because we are setting a getter or setter, we need to use 1036 // Object.defineProperty to define the property on the target object. 1037 Object.defineProperty(target, key, { 1038 ...desc, 1039 configurable: true, 1040 enumerable: true 1041 }); 1042 // Update the getter in the property signal if it exists 1043 if (desc.get && propSignal) { 1044 propSignal.setGetter(desc.get); 1045 } 1046 } 1047 1048 // Handle nested objects 1049 } else if (isPlainObject(source[key])) { 1050 const targetValue = Object.getOwnPropertyDescriptor(target, key)?.value; 1051 if (isNew || override && !isPlainObject(targetValue)) { 1052 // Create a new object if the property is new or needs to be overridden 1053 target[key] = {}; 1054 if (propSignal) { 1055 // Create a new proxified state for the nested object 1056 const ns = getNamespaceFromProxy(proxy); 1057 propSignal.setValue(proxifyState(ns, target[key])); 1058 } 1059 deepMergeRecursive(target[key], source[key], override); 1060 } 1061 // Both target and source are plain objects, merge them recursively 1062 else if (isPlainObject(targetValue)) { 1063 deepMergeRecursive(target[key], source[key], override); 1064 } 1065 1066 // Handle primitive values and non-plain objects 1067 } else if (override || isNew) { 1068 Object.defineProperty(target, key, desc); 1069 if (propSignal) { 1070 const { 1071 value 1072 } = desc; 1073 const ns = getNamespaceFromProxy(proxy); 1074 // Proxify the value if necessary before setting it in the signal 1075 propSignal.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); 1076 } 1077 } 1078 } 1079 if (hasNewKeys && objToIterable.has(target)) { 1080 objToIterable.get(target).value++; 1081 } 1082 }; 1083 1084 /** 1085 * Recursively update prop values inside the passed `target` and nested plain 1086 * objects, using the values present in `source`. References to plain objects 1087 * are kept, only updating props containing primitives or arrays. Arrays are 1088 * replaced instead of merged or concatenated. 1089 * 1090 * If the `override` parameter is set to `false`, then all values in `target` 1091 * are preserved, and only new properties from `source` are added. 1092 * 1093 * @param target The target object. 1094 * @param source The source object containing new values and props. 1095 * @param override Whether existing props should be overwritten or not (`true` 1096 * by default). 1097 */ 1098 const deepMerge = (target, source, override = true) => signals_core_module_r(() => deepMergeRecursive(getObjectFromProxy(target) || target, source, override)); 1099 1100 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/store.js 1101 /** 1102 * Internal dependencies 1103 */ 1104 1105 /** 1106 * External dependencies 1107 */ 1108 1109 1110 1111 /** 1112 * Identifies the store proxies handling the root objects of each store. 1113 */ 1114 const storeRoots = new WeakSet(); 1115 1116 /** 1117 * Handlers for store proxies. 1118 */ 1119 const storeHandlers = { 1120 get: (target, key, receiver) => { 1121 const result = Reflect.get(target, key); 1122 const ns = getNamespaceFromProxy(receiver); 1123 1124 /* 1125 * Check if the proxy is the store root and no key with that name exist. In 1126 * that case, return an empty object for the requested key. 1127 */ 1128 if (typeof result === 'undefined' && storeRoots.has(receiver)) { 1129 const obj = {}; 1130 Reflect.set(target, key, obj); 1131 return proxifyStore(ns, obj, false); 1132 } 1133 1134 /* 1135 * Check if the property is a function. If it is, add the store 1136 * namespace to the stack and wrap the function with the current scope. 1137 * The `withScope` util handles both synchronous functions and generator 1138 * functions. 1139 */ 1140 if (typeof result === 'function') { 1141 setNamespace(ns); 1142 const scoped = withScope(result); 1143 resetNamespace(); 1144 return scoped; 1145 } 1146 1147 // Check if the property is an object. If it is, proxyify it. 1148 if (isPlainObject(result) && shouldProxy(result)) { 1149 return proxifyStore(ns, result, false); 1150 } 1151 return result; 1152 } 1153 }; 1154 1155 /** 1156 * Returns the proxy associated with the given store object, creating it if it 1157 * does not exist. 1158 * 1159 * @param namespace The namespace that will be associated to this proxy. 1160 * @param obj The object to proxify. 1161 * 1162 * @param isRoot Whether the passed object is the store root object. 1163 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to 1164 * check if a proxy can be created for a specific object. 1165 * 1166 * @return The associated proxy. 1167 */ 1168 const proxifyStore = (namespace, obj, isRoot = true) => { 1169 const proxy = createProxy(namespace, obj, storeHandlers); 1170 if (proxy && isRoot) { 1171 storeRoots.add(proxy); 1172 } 1173 return proxy; 1174 }; 1175 1176 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/context.js 1177 const contextObjectToProxy = new WeakMap(); 1178 const contextObjectToFallback = new WeakMap(); 1179 const contextProxies = new WeakSet(); 1180 const descriptor = Reflect.getOwnPropertyDescriptor; 1181 1182 // TODO: Use the proxy registry to avoid multiple proxies on the same object. 1183 const contextHandlers = { 1184 get: (target, key) => { 1185 const fallback = contextObjectToFallback.get(target); 1186 // Always subscribe to prop changes in the current context. 1187 const currentProp = target[key]; 1188 1189 /* 1190 * Return the value from `target` if it exists, or from `fallback` 1191 * otherwise. This way, in the case the property doesn't exist either in 1192 * `target` or `fallback`, it also subscribes to changes in the parent 1193 * context. 1194 */ 1195 return key in target ? currentProp : fallback[key]; 1196 }, 1197 set: (target, key, value) => { 1198 const fallback = contextObjectToFallback.get(target); 1199 1200 // If the property exists in the current context, modify it. Otherwise, 1201 // add it to the current context. 1202 const obj = key in target || !(key in fallback) ? target : fallback; 1203 obj[key] = value; 1204 return true; 1205 }, 1206 ownKeys: target => [...new Set([...Object.keys(contextObjectToFallback.get(target)), ...Object.keys(target)])], 1207 getOwnPropertyDescriptor: (target, key) => descriptor(target, key) || descriptor(contextObjectToFallback.get(target), key), 1208 has: (target, key) => Reflect.has(target, key) || Reflect.has(contextObjectToFallback.get(target), key) 1209 }; 1210 1211 /** 1212 * Wrap a context object with a proxy to reproduce the context stack. The proxy 1213 * uses the passed `inherited` context as a fallback to look up for properties 1214 * that don't exist in the given context. Also, updated properties are modified 1215 * where they are defined, or added to the main context when they don't exist. 1216 * 1217 * @param current Current context. 1218 * @param inherited Inherited context, used as fallback. 1219 * 1220 * @return The wrapped context object. 1221 */ 1222 const proxifyContext = (current, inherited = {}) => { 1223 if (contextProxies.has(current)) { 1224 throw Error('This object cannot be proxified.'); 1225 } 1226 // Update the fallback object reference when it changes. 1227 contextObjectToFallback.set(current, inherited); 1228 if (!contextObjectToProxy.has(current)) { 1229 const proxy = new Proxy(current, contextHandlers); 1230 contextObjectToProxy.set(current, proxy); 1231 contextProxies.add(proxy); 1232 } 1233 return contextObjectToProxy.get(current); 1234 }; 1235 1236 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/index.js 1237 /** 1238 * Internal dependencies 1239 */ 1240 1241 1242 1243 1244 ;// ./node_modules/@wordpress/interactivity/build-module/store.js 1245 /* wp:polyfill */ 1246 /** 1247 * Internal dependencies 1248 */ 1249 1250 /** 1251 * External dependencies 1252 */ 1253 1254 1255 const stores = new Map(); 1256 const rawStores = new Map(); 1257 const storeLocks = new Map(); 1258 const storeConfigs = new Map(); 1259 const serverStates = new Map(); 1260 1261 /** 1262 * Get the defined config for the store with the passed namespace. 1263 * 1264 * @param namespace Store's namespace from which to retrieve the config. 1265 * @return Defined config for the given namespace. 1266 */ 1267 const getConfig = namespace => storeConfigs.get(namespace || getNamespace()) || {}; 1268 1269 /** 1270 * Get the part of the state defined and updated from the server. 1271 * 1272 * The object returned is read-only, and includes the state defined in PHP with 1273 * `wp_interactivity_state()`. When using `actions.navigate()`, this object is 1274 * updated to reflect the changes in its properties, without affecting the state 1275 * returned by `store()`. Directives can subscribe to those changes to update 1276 * the state if needed. 1277 * 1278 * @example 1279 * ```js 1280 * const { state } = store('myStore', { 1281 * callbacks: { 1282 * updateServerState() { 1283 * const serverState = getServerState(); 1284 * // Override some property with the new value that came from the server. 1285 * state.overridableProp = serverState.overridableProp; 1286 * }, 1287 * }, 1288 * }); 1289 * ``` 1290 * 1291 * @param namespace Store's namespace from which to retrieve the server state. 1292 * @return The server state for the given namespace. 1293 */ 1294 const getServerState = namespace => { 1295 const ns = namespace || getNamespace(); 1296 if (!serverStates.has(ns)) { 1297 serverStates.set(ns, proxifyState(ns, {}, { 1298 readOnly: true 1299 })); 1300 } 1301 return serverStates.get(ns); 1302 }; 1303 const universalUnlock = 'I acknowledge that using a private store means my plugin will inevitably break on the next store release.'; 1304 1305 /** 1306 * Extends the Interactivity API global store adding the passed properties to 1307 * the given namespace. It also returns stable references to the namespace 1308 * content. 1309 * 1310 * These props typically consist of `state`, which is the reactive part of the 1311 * store ― which means that any directive referencing a state property will be 1312 * re-rendered anytime it changes ― and function properties like `actions` and 1313 * `callbacks`, mostly used for event handlers. These props can then be 1314 * referenced by any directive to make the HTML interactive. 1315 * 1316 * @example 1317 * ```js 1318 * const { state } = store( 'counter', { 1319 * state: { 1320 * value: 0, 1321 * get double() { return state.value * 2; }, 1322 * }, 1323 * actions: { 1324 * increment() { 1325 * state.value += 1; 1326 * }, 1327 * }, 1328 * } ); 1329 * ``` 1330 * 1331 * The code from the example above allows blocks to subscribe and interact with 1332 * the store by using directives in the HTML, e.g.: 1333 * 1334 * ```html 1335 * <div data-wp-interactive="counter"> 1336 * <button 1337 * data-wp-text="state.double" 1338 * data-wp-on--click="actions.increment" 1339 * > 1340 * 0 1341 * </button> 1342 * </div> 1343 * ``` 1344 * @param namespace The store namespace to interact with. 1345 * @param storePart Properties to add to the store namespace. 1346 * @param options Options for the given namespace. 1347 * 1348 * @return A reference to the namespace content. 1349 */ 1350 1351 // Overload for when the types are inferred. 1352 1353 // Overload for when types are passed via generics and they contain state. 1354 1355 // Overload for when types are passed via generics and they don't contain state. 1356 1357 // Overload for when types are divided into multiple parts. 1358 1359 function store(namespace, { 1360 state = {}, 1361 ...block 1362 } = {}, { 1363 lock = false 1364 } = {}) { 1365 if (!stores.has(namespace)) { 1366 // Lock the store if the passed lock is different from the universal 1367 // unlock. Once the lock is set (either false, true, or a given string), 1368 // it cannot change. 1369 if (lock !== universalUnlock) { 1370 storeLocks.set(namespace, lock); 1371 } 1372 const rawStore = { 1373 state: proxifyState(namespace, isPlainObject(state) ? state : {}), 1374 ...block 1375 }; 1376 const proxifiedStore = proxifyStore(namespace, rawStore); 1377 rawStores.set(namespace, rawStore); 1378 stores.set(namespace, proxifiedStore); 1379 } else { 1380 // Lock the store if it wasn't locked yet and the passed lock is 1381 // different from the universal unlock. If no lock is given, the store 1382 // will be public and won't accept any lock from now on. 1383 if (lock !== universalUnlock && !storeLocks.has(namespace)) { 1384 storeLocks.set(namespace, lock); 1385 } else { 1386 const storeLock = storeLocks.get(namespace); 1387 const isLockValid = lock === universalUnlock || lock !== true && lock === storeLock; 1388 if (!isLockValid) { 1389 if (!storeLock) { 1390 throw Error('Cannot lock a public store'); 1391 } else { 1392 throw Error('Cannot unlock a private store with an invalid lock code'); 1393 } 1394 } 1395 } 1396 const target = rawStores.get(namespace); 1397 deepMerge(target, block); 1398 deepMerge(target.state, state); 1399 } 1400 return stores.get(namespace); 1401 } 1402 const parseServerData = (dom = document) => { 1403 var _dom$getElementById; 1404 const jsonDataScriptTag = // Preferred Script Module data passing form 1405 (_dom$getElementById = dom.getElementById('wp-script-module-data-@wordpress/interactivity')) !== null && _dom$getElementById !== void 0 ? _dom$getElementById : 1406 // Legacy form 1407 dom.getElementById('wp-interactivity-data'); 1408 if (jsonDataScriptTag?.textContent) { 1409 try { 1410 return JSON.parse(jsonDataScriptTag.textContent); 1411 } catch {} 1412 } 1413 return {}; 1414 }; 1415 const populateServerData = data => { 1416 if (isPlainObject(data?.state)) { 1417 Object.entries(data.state).forEach(([namespace, state]) => { 1418 const st = store(namespace, {}, { 1419 lock: universalUnlock 1420 }); 1421 deepMerge(st.state, state, false); 1422 deepMerge(getServerState(namespace), state); 1423 }); 1424 } 1425 if (isPlainObject(data?.config)) { 1426 Object.entries(data.config).forEach(([namespace, config]) => { 1427 storeConfigs.set(namespace, config); 1428 }); 1429 } 1430 }; 1431 1432 // Parse and populate the initial state and config. 1433 const data = parseServerData(); 1434 populateServerData(data); 1435 1436 ;// ./node_modules/@wordpress/interactivity/build-module/hooks.js 1437 /* wp:polyfill */ 1438 // eslint-disable-next-line eslint-comments/disable-enable-pair 1439 /* eslint-disable react-hooks/exhaustive-deps */ 1440 1441 /** 1442 * External dependencies 1443 */ 1444 1445 1446 /** 1447 * Internal dependencies 1448 */ 1449 1450 1451 1452 function isNonDefaultDirectiveSuffix(entry) { 1453 return entry.suffix !== null; 1454 } 1455 function isDefaultDirectiveSuffix(entry) { 1456 return entry.suffix === null; 1457 } 1458 // Main context. 1459 const context = (0,preact_module/* createContext */.q6)({ 1460 client: {}, 1461 server: {} 1462 }); 1463 1464 // WordPress Directives. 1465 const directiveCallbacks = {}; 1466 const directivePriorities = {}; 1467 1468 /** 1469 * Register a new directive type in the Interactivity API runtime. 1470 * 1471 * @example 1472 * ```js 1473 * directive( 1474 * 'alert', // Name without the `data-wp-` prefix. 1475 * ( { directives: { alert }, element, evaluate } ) => { 1476 * const defaultEntry = alert.find( isDefaultDirectiveSuffix ); 1477 * element.props.onclick = () => { alert( evaluate( defaultEntry ) ); } 1478 * } 1479 * ) 1480 * ``` 1481 * 1482 * The previous code registers a custom directive type for displaying an alert 1483 * message whenever an element using it is clicked. The message text is obtained 1484 * from the store under the inherited namespace, using `evaluate`. 1485 * 1486 * When the HTML is processed by the Interactivity API, any element containing 1487 * the `data-wp-alert` directive will have the `onclick` event handler, e.g., 1488 * 1489 * ```html 1490 * <div data-wp-interactive="messages"> 1491 * <button data-wp-alert="state.alert">Click me!</button> 1492 * </div> 1493 * ``` 1494 * Note that, in the previous example, the directive callback gets the path 1495 * value (`state.alert`) from the directive entry with suffix `null`. A 1496 * custom suffix can also be specified by appending `--` to the directive 1497 * attribute, followed by the suffix, like in the following HTML snippet: 1498 * 1499 * ```html 1500 * <div data-wp-interactive="myblock"> 1501 * <button 1502 * data-wp-color--text="state.text" 1503 * data-wp-color--background="state.background" 1504 * >Click me!</button> 1505 * </div> 1506 * ``` 1507 * 1508 * This could be an hypothetical implementation of the custom directive used in 1509 * the snippet above. 1510 * 1511 * @example 1512 * ```js 1513 * directive( 1514 * 'color', // Name without prefix and suffix. 1515 * ( { directives: { color: colors }, ref, evaluate } ) => 1516 * colors.forEach( ( color ) => { 1517 * if ( color.suffix = 'text' ) { 1518 * ref.style.setProperty( 1519 * 'color', 1520 * evaluate( color.text ) 1521 * ); 1522 * } 1523 * if ( color.suffix = 'background' ) { 1524 * ref.style.setProperty( 1525 * 'background-color', 1526 * evaluate( color.background ) 1527 * ); 1528 * } 1529 * } ); 1530 * } 1531 * ) 1532 * ``` 1533 * 1534 * @param name Directive name, without the `data-wp-` prefix. 1535 * @param callback Function that runs the directive logic. 1536 * @param options Options object. 1537 * @param options.priority Option to control the directive execution order. The 1538 * lesser, the highest priority. Default is `10`. 1539 */ 1540 const directive = (name, callback, { 1541 priority = 10 1542 } = {}) => { 1543 directiveCallbacks[name] = callback; 1544 directivePriorities[name] = priority; 1545 }; 1546 1547 // Resolve the path to some property of the store object. 1548 const resolve = (path, namespace) => { 1549 if (!namespace) { 1550 warn(`Namespace missing for "$path}". The value for that path won't be resolved.`); 1551 return; 1552 } 1553 let resolvedStore = stores.get(namespace); 1554 if (typeof resolvedStore === 'undefined') { 1555 resolvedStore = store(namespace, {}, { 1556 lock: universalUnlock 1557 }); 1558 } 1559 const current = { 1560 ...resolvedStore, 1561 context: getScope().context[namespace] 1562 }; 1563 try { 1564 // TODO: Support lazy/dynamically initialized stores 1565 return path.split('.').reduce((acc, key) => acc[key], current); 1566 } catch (e) {} 1567 }; 1568 1569 // Generate the evaluate function. 1570 const getEvaluate = ({ 1571 scope 1572 }) => (entry, ...args) => { 1573 let { 1574 value: path, 1575 namespace 1576 } = entry; 1577 if (typeof path !== 'string') { 1578 throw new Error('The `value` prop should be a string path'); 1579 } 1580 // If path starts with !, remove it and save a flag. 1581 const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1)); 1582 setScope(scope); 1583 const value = resolve(path, namespace); 1584 const result = typeof value === 'function' ? value(...args) : value; 1585 resetScope(); 1586 return hasNegationOperator ? !result : result; 1587 }; 1588 1589 // Separate directives by priority. The resulting array contains objects 1590 // of directives grouped by same priority, and sorted in ascending order. 1591 const getPriorityLevels = directives => { 1592 const byPriority = Object.keys(directives).reduce((obj, name) => { 1593 if (directiveCallbacks[name]) { 1594 const priority = directivePriorities[name]; 1595 (obj[priority] = obj[priority] || []).push(name); 1596 } 1597 return obj; 1598 }, {}); 1599 return Object.entries(byPriority).sort(([p1], [p2]) => parseInt(p1) - parseInt(p2)).map(([, arr]) => arr); 1600 }; 1601 1602 // Component that wraps each priority level of directives of an element. 1603 const Directives = ({ 1604 directives, 1605 priorityLevels: [currentPriorityLevel, ...nextPriorityLevels], 1606 element, 1607 originalProps, 1608 previousScope 1609 }) => { 1610 // Initialize the scope of this element. These scopes are different per each 1611 // level because each level has a different context, but they share the same 1612 // element ref, state and props. 1613 const scope = A({}).current; 1614 scope.evaluate = q(getEvaluate({ 1615 scope 1616 }), []); 1617 const { 1618 client, 1619 server 1620 } = x(context); 1621 scope.context = client; 1622 scope.serverContext = server; 1623 /* eslint-disable react-hooks/rules-of-hooks */ 1624 scope.ref = previousScope?.ref || A(null); 1625 /* eslint-enable react-hooks/rules-of-hooks */ 1626 1627 // Create a fresh copy of the vnode element and add the props to the scope, 1628 // named as attributes (HTML Attributes). 1629 element = (0,preact_module/* cloneElement */.Ob)(element, { 1630 ref: scope.ref 1631 }); 1632 scope.attributes = element.props; 1633 1634 // Recursively render the wrapper for the next priority level. 1635 const children = nextPriorityLevels.length > 0 ? (0,preact_module.h)(Directives, { 1636 directives, 1637 priorityLevels: nextPriorityLevels, 1638 element, 1639 originalProps, 1640 previousScope: scope 1641 }) : element; 1642 const props = { 1643 ...originalProps, 1644 children 1645 }; 1646 const directiveArgs = { 1647 directives, 1648 props, 1649 element, 1650 context, 1651 evaluate: scope.evaluate 1652 }; 1653 setScope(scope); 1654 for (const directiveName of currentPriorityLevel) { 1655 const wrapper = directiveCallbacks[directiveName]?.(directiveArgs); 1656 if (wrapper !== undefined) { 1657 props.children = wrapper; 1658 } 1659 } 1660 resetScope(); 1661 return props.children; 1662 }; 1663 1664 // Preact Options Hook called each time a vnode is created. 1665 const old = preact_module/* options */.fF.vnode; 1666 preact_module/* options */.fF.vnode = vnode => { 1667 if (vnode.props.__directives) { 1668 const props = vnode.props; 1669 const directives = props.__directives; 1670 if (directives.key) { 1671 vnode.key = directives.key.find(isDefaultDirectiveSuffix).value; 1672 } 1673 delete props.__directives; 1674 const priorityLevels = getPriorityLevels(directives); 1675 if (priorityLevels.length > 0) { 1676 vnode.props = { 1677 directives, 1678 priorityLevels, 1679 originalProps: props, 1680 type: vnode.type, 1681 element: (0,preact_module.h)(vnode.type, props), 1682 top: true 1683 }; 1684 vnode.type = Directives; 1685 } 1686 } 1687 if (old) { 1688 old(vnode); 1689 } 1690 }; 1691 1692 ;// ./node_modules/@wordpress/interactivity/build-module/directives.js 1693 /* wp:polyfill */ 1694 // eslint-disable-next-line eslint-comments/disable-enable-pair 1695 /* eslint-disable react-hooks/exhaustive-deps */ 1696 1697 /** 1698 * External dependencies 1699 */ 1700 1701 1702 1703 /** 1704 * Internal dependencies 1705 */ 1706 1707 1708 1709 1710 1711 /** 1712 * Recursively clone the passed object. 1713 * 1714 * @param source Source object. 1715 * @return Cloned object. 1716 */ 1717 function deepClone(source) { 1718 if (isPlainObject(source)) { 1719 return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, deepClone(value)])); 1720 } 1721 if (Array.isArray(source)) { 1722 return source.map(i => deepClone(i)); 1723 } 1724 return source; 1725 } 1726 const newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g; 1727 const ruleClean = /\/\*[^]*?\*\/| +/g; 1728 const ruleNewline = /\n+/g; 1729 const empty = ' '; 1730 1731 /** 1732 * Convert a css style string into a object. 1733 * 1734 * Made by Cristian Bote (@cristianbote) for Goober. 1735 * https://unpkg.com/browse/goober@2.1.13/src/core/astish.js 1736 * 1737 * @param val CSS string. 1738 * @return CSS object. 1739 */ 1740 const cssStringToObject = val => { 1741 const tree = [{}]; 1742 let block, left; 1743 while (block = newRule.exec(val.replace(ruleClean, ''))) { 1744 if (block[4]) { 1745 tree.shift(); 1746 } else if (block[3]) { 1747 left = block[3].replace(ruleNewline, empty).trim(); 1748 tree.unshift(tree[0][left] = tree[0][left] || {}); 1749 } else { 1750 tree[0][block[1]] = block[2].replace(ruleNewline, empty).trim(); 1751 } 1752 } 1753 return tree[0]; 1754 }; 1755 1756 /** 1757 * Creates a directive that adds an event listener to the global window or 1758 * document object. 1759 * 1760 * @param type 'window' or 'document' 1761 */ 1762 const getGlobalEventDirective = type => { 1763 return ({ 1764 directives, 1765 evaluate 1766 }) => { 1767 directives[`on-$type}`].filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1768 const eventName = entry.suffix.split('--', 1)[0]; 1769 useInit(() => { 1770 const cb = event => evaluate(entry, event); 1771 const globalVar = type === 'window' ? window : document; 1772 globalVar.addEventListener(eventName, cb); 1773 return () => globalVar.removeEventListener(eventName, cb); 1774 }); 1775 }); 1776 }; 1777 }; 1778 1779 /** 1780 * Creates a directive that adds an async event listener to the global window or 1781 * document object. 1782 * 1783 * @param type 'window' or 'document' 1784 */ 1785 const getGlobalAsyncEventDirective = type => { 1786 return ({ 1787 directives, 1788 evaluate 1789 }) => { 1790 directives[`on-async-$type}`].filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1791 const eventName = entry.suffix.split('--', 1)[0]; 1792 useInit(() => { 1793 const cb = async event => { 1794 await splitTask(); 1795 evaluate(entry, event); 1796 }; 1797 const globalVar = type === 'window' ? window : document; 1798 globalVar.addEventListener(eventName, cb, { 1799 passive: true 1800 }); 1801 return () => globalVar.removeEventListener(eventName, cb); 1802 }); 1803 }); 1804 }; 1805 }; 1806 /* harmony default export */ const directives = (() => { 1807 // data-wp-context 1808 directive('context', ({ 1809 directives: { 1810 context 1811 }, 1812 props: { 1813 children 1814 }, 1815 context: inheritedContext 1816 }) => { 1817 const { 1818 Provider 1819 } = inheritedContext; 1820 const defaultEntry = context.find(isDefaultDirectiveSuffix); 1821 const { 1822 client: inheritedClient, 1823 server: inheritedServer 1824 } = x(inheritedContext); 1825 const ns = defaultEntry.namespace; 1826 const client = A(proxifyState(ns, {})); 1827 const server = A(proxifyState(ns, {}, { 1828 readOnly: true 1829 })); 1830 1831 // No change should be made if `defaultEntry` does not exist. 1832 const contextStack = T(() => { 1833 const result = { 1834 client: { 1835 ...inheritedClient 1836 }, 1837 server: { 1838 ...inheritedServer 1839 } 1840 }; 1841 if (defaultEntry) { 1842 const { 1843 namespace, 1844 value 1845 } = defaultEntry; 1846 // Check that the value is a JSON object. Send a console warning if not. 1847 if (!isPlainObject(value)) { 1848 warn(`The value of data-wp-context in "$namespace}" store must be a valid stringified JSON object.`); 1849 } 1850 deepMerge(client.current, deepClone(value), false); 1851 deepMerge(server.current, deepClone(value)); 1852 result.client[namespace] = proxifyContext(client.current, inheritedClient[namespace]); 1853 result.server[namespace] = proxifyContext(server.current, inheritedServer[namespace]); 1854 } 1855 return result; 1856 }, [defaultEntry, inheritedClient, inheritedServer]); 1857 return (0,preact_module.h)(Provider, { 1858 value: contextStack 1859 }, children); 1860 }, { 1861 priority: 5 1862 }); 1863 1864 // data-wp-watch--[name] 1865 directive('watch', ({ 1866 directives: { 1867 watch 1868 }, 1869 evaluate 1870 }) => { 1871 watch.forEach(entry => { 1872 useWatch(() => { 1873 let start; 1874 if (false) {} 1875 const result = evaluate(entry); 1876 if (false) {} 1877 return result; 1878 }); 1879 }); 1880 }); 1881 1882 // data-wp-init--[name] 1883 directive('init', ({ 1884 directives: { 1885 init 1886 }, 1887 evaluate 1888 }) => { 1889 init.forEach(entry => { 1890 // TODO: Replace with useEffect to prevent unneeded scopes. 1891 useInit(() => { 1892 let start; 1893 if (false) {} 1894 const result = evaluate(entry); 1895 if (false) {} 1896 return result; 1897 }); 1898 }); 1899 }); 1900 1901 // data-wp-on--[event] 1902 directive('on', ({ 1903 directives: { 1904 on 1905 }, 1906 element, 1907 evaluate 1908 }) => { 1909 const events = new Map(); 1910 on.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1911 const event = entry.suffix.split('--')[0]; 1912 if (!events.has(event)) { 1913 events.set(event, new Set()); 1914 } 1915 events.get(event).add(entry); 1916 }); 1917 events.forEach((entries, eventType) => { 1918 const existingHandler = element.props[`on$eventType}`]; 1919 element.props[`on$eventType}`] = event => { 1920 entries.forEach(entry => { 1921 if (existingHandler) { 1922 existingHandler(event); 1923 } 1924 let start; 1925 if (false) {} 1926 evaluate(entry, event); 1927 if (false) {} 1928 }); 1929 }; 1930 }); 1931 }); 1932 1933 // data-wp-on-async--[event] 1934 directive('on-async', ({ 1935 directives: { 1936 'on-async': onAsync 1937 }, 1938 element, 1939 evaluate 1940 }) => { 1941 const events = new Map(); 1942 onAsync.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1943 const event = entry.suffix.split('--')[0]; 1944 if (!events.has(event)) { 1945 events.set(event, new Set()); 1946 } 1947 events.get(event).add(entry); 1948 }); 1949 events.forEach((entries, eventType) => { 1950 const existingHandler = element.props[`on$eventType}`]; 1951 element.props[`on$eventType}`] = event => { 1952 if (existingHandler) { 1953 existingHandler(event); 1954 } 1955 entries.forEach(async entry => { 1956 await splitTask(); 1957 evaluate(entry, event); 1958 }); 1959 }; 1960 }); 1961 }); 1962 1963 // data-wp-on-window--[event] 1964 directive('on-window', getGlobalEventDirective('window')); 1965 // data-wp-on-document--[event] 1966 directive('on-document', getGlobalEventDirective('document')); 1967 1968 // data-wp-on-async-window--[event] 1969 directive('on-async-window', getGlobalAsyncEventDirective('window')); 1970 // data-wp-on-async-document--[event] 1971 directive('on-async-document', getGlobalAsyncEventDirective('document')); 1972 1973 // data-wp-class--[classname] 1974 directive('class', ({ 1975 directives: { 1976 class: classNames 1977 }, 1978 element, 1979 evaluate 1980 }) => { 1981 classNames.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1982 const className = entry.suffix; 1983 const result = evaluate(entry); 1984 const currentClass = element.props.class || ''; 1985 const classFinder = new RegExp(`(^|\\s)$className}(\\s|$)`, 'g'); 1986 if (!result) { 1987 element.props.class = currentClass.replace(classFinder, ' ').trim(); 1988 } else if (!classFinder.test(currentClass)) { 1989 element.props.class = currentClass ? `$currentClass} $className}` : className; 1990 } 1991 useInit(() => { 1992 /* 1993 * This seems necessary because Preact doesn't change the class 1994 * names on the hydration, so we have to do it manually. It doesn't 1995 * need deps because it only needs to do it the first time. 1996 */ 1997 if (!result) { 1998 element.ref.current.classList.remove(className); 1999 } else { 2000 element.ref.current.classList.add(className); 2001 } 2002 }); 2003 }); 2004 }); 2005 2006 // data-wp-style--[style-prop] 2007 directive('style', ({ 2008 directives: { 2009 style 2010 }, 2011 element, 2012 evaluate 2013 }) => { 2014 style.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 2015 const styleProp = entry.suffix; 2016 const result = evaluate(entry); 2017 element.props.style = element.props.style || {}; 2018 if (typeof element.props.style === 'string') { 2019 element.props.style = cssStringToObject(element.props.style); 2020 } 2021 if (!result) { 2022 delete element.props.style[styleProp]; 2023 } else { 2024 element.props.style[styleProp] = result; 2025 } 2026 useInit(() => { 2027 /* 2028 * This seems necessary because Preact doesn't change the styles on 2029 * the hydration, so we have to do it manually. It doesn't need deps 2030 * because it only needs to do it the first time. 2031 */ 2032 if (!result) { 2033 element.ref.current.style.removeProperty(styleProp); 2034 } else { 2035 element.ref.current.style[styleProp] = result; 2036 } 2037 }); 2038 }); 2039 }); 2040 2041 // data-wp-bind--[attribute] 2042 directive('bind', ({ 2043 directives: { 2044 bind 2045 }, 2046 element, 2047 evaluate 2048 }) => { 2049 bind.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 2050 const attribute = entry.suffix; 2051 const result = evaluate(entry); 2052 element.props[attribute] = result; 2053 2054 /* 2055 * This is necessary because Preact doesn't change the attributes on the 2056 * hydration, so we have to do it manually. It only needs to do it the 2057 * first time. After that, Preact will handle the changes. 2058 */ 2059 useInit(() => { 2060 const el = element.ref.current; 2061 2062 /* 2063 * We set the value directly to the corresponding HTMLElement instance 2064 * property excluding the following special cases. We follow Preact's 2065 * logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L110-L129 2066 */ 2067 if (attribute === 'style') { 2068 if (typeof result === 'string') { 2069 el.style.cssText = result; 2070 } 2071 return; 2072 } else if (attribute !== 'width' && attribute !== 'height' && attribute !== 'href' && attribute !== 'list' && attribute !== 'form' && 2073 /* 2074 * The value for `tabindex` follows the parsing rules for an 2075 * integer. If that fails, or if the attribute isn't present, then 2076 * the browsers should "follow platform conventions to determine if 2077 * the element should be considered as a focusable area", 2078 * practically meaning that most elements get a default of `-1` (not 2079 * focusable), but several also get a default of `0` (focusable in 2080 * order after all elements with a positive `tabindex` value). 2081 * 2082 * @see https://html.spec.whatwg.org/#tabindex-value 2083 */ 2084 attribute !== 'tabIndex' && attribute !== 'download' && attribute !== 'rowSpan' && attribute !== 'colSpan' && attribute !== 'role' && attribute in el) { 2085 try { 2086 el[attribute] = result === null || result === undefined ? '' : result; 2087 return; 2088 } catch (err) {} 2089 } 2090 /* 2091 * aria- and data- attributes have no boolean representation. 2092 * A `false` value is different from the attribute not being 2093 * present, so we can't remove it. 2094 * We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136 2095 */ 2096 if (result !== null && result !== undefined && (result !== false || attribute[4] === '-')) { 2097 el.setAttribute(attribute, result); 2098 } else { 2099 el.removeAttribute(attribute); 2100 } 2101 }); 2102 }); 2103 }); 2104 2105 // data-wp-ignore 2106 directive('ignore', ({ 2107 element: { 2108 type: Type, 2109 props: { 2110 innerHTML, 2111 ...rest 2112 } 2113 } 2114 }) => { 2115 // Preserve the initial inner HTML. 2116 const cached = T(() => innerHTML, []); 2117 return (0,preact_module.h)(Type, { 2118 dangerouslySetInnerHTML: { 2119 __html: cached 2120 }, 2121 ...rest 2122 }); 2123 }); 2124 2125 // data-wp-text 2126 directive('text', ({ 2127 directives: { 2128 text 2129 }, 2130 element, 2131 evaluate 2132 }) => { 2133 const entry = text.find(isDefaultDirectiveSuffix); 2134 if (!entry) { 2135 element.props.children = null; 2136 return; 2137 } 2138 try { 2139 const result = evaluate(entry); 2140 element.props.children = typeof result === 'object' ? null : result.toString(); 2141 } catch (e) { 2142 element.props.children = null; 2143 } 2144 }); 2145 2146 // data-wp-run 2147 directive('run', ({ 2148 directives: { 2149 run 2150 }, 2151 evaluate 2152 }) => { 2153 run.forEach(entry => evaluate(entry)); 2154 }); 2155 2156 // data-wp-each--[item] 2157 directive('each', ({ 2158 directives: { 2159 each, 2160 'each-key': eachKey 2161 }, 2162 context: inheritedContext, 2163 element, 2164 evaluate 2165 }) => { 2166 if (element.type !== 'template') { 2167 return; 2168 } 2169 const { 2170 Provider 2171 } = inheritedContext; 2172 const inheritedValue = x(inheritedContext); 2173 const [entry] = each; 2174 const { 2175 namespace 2176 } = entry; 2177 const iterable = evaluate(entry); 2178 if (typeof iterable?.[Symbol.iterator] !== 'function') { 2179 return; 2180 } 2181 const itemProp = isNonDefaultDirectiveSuffix(entry) ? kebabToCamelCase(entry.suffix) : 'item'; 2182 const result = []; 2183 for (const item of iterable) { 2184 const itemContext = proxifyContext(proxifyState(namespace, {}), inheritedValue.client[namespace]); 2185 const mergedContext = { 2186 client: { 2187 ...inheritedValue.client, 2188 [namespace]: itemContext 2189 }, 2190 server: { 2191 ...inheritedValue.server 2192 } 2193 }; 2194 2195 // Set the item after proxifying the context. 2196 mergedContext.client[namespace][itemProp] = item; 2197 const scope = { 2198 ...getScope(), 2199 context: mergedContext.client, 2200 serverContext: mergedContext.server 2201 }; 2202 const key = eachKey ? getEvaluate({ 2203 scope 2204 })(eachKey[0]) : item; 2205 result.push((0,preact_module.h)(Provider, { 2206 value: mergedContext, 2207 key 2208 }, element.props.content)); 2209 } 2210 return result; 2211 }, { 2212 priority: 20 2213 }); 2214 directive('each-child', () => null, { 2215 priority: 1 2216 }); 2217 }); 2218 2219 ;// ./node_modules/@wordpress/interactivity/build-module/constants.js 2220 const directivePrefix = 'wp'; 2221 2222 ;// ./node_modules/@wordpress/interactivity/build-module/vdom.js 2223 /* wp:polyfill */ 2224 /** 2225 * External dependencies 2226 */ 2227 2228 /** 2229 * Internal dependencies 2230 */ 2231 2232 2233 const ignoreAttr = `data-$directivePrefix}-ignore`; 2234 const islandAttr = `data-$directivePrefix}-interactive`; 2235 const fullPrefix = `data-$directivePrefix}-`; 2236 const namespaces = []; 2237 const currentNamespace = () => { 2238 var _namespaces; 2239 return (_namespaces = namespaces[namespaces.length - 1]) !== null && _namespaces !== void 0 ? _namespaces : null; 2240 }; 2241 const isObject = item => Boolean(item && typeof item === 'object' && item.constructor === Object); 2242 2243 // Regular expression for directive parsing. 2244 const directiveParser = new RegExp(`^data-$directivePrefix}-` + 2245 // ${p} must be a prefix string, like 'wp'. 2246 // Match alphanumeric characters including hyphen-separated 2247 // segments. It excludes underscore intentionally to prevent confusion. 2248 // E.g., "custom-directive". 2249 '([a-z0-9]+(?:-[a-z0-9]+)*)' + 2250 // (Optional) Match '--' followed by any alphanumeric characters. It 2251 // excludes underscore intentionally to prevent confusion, but it can 2252 // contain multiple hyphens. E.g., "--custom-prefix--with-more-info". 2253 '(?:--([a-z0-9_-]+))?$', 'i' // Case insensitive. 2254 ); 2255 2256 // Regular expression for reference parsing. It can contain a namespace before 2257 // the reference, separated by `::`, like `some-namespace::state.somePath`. 2258 // Namespaces can contain any alphanumeric characters, hyphens, underscores or 2259 // forward slashes. References don't have any restrictions. 2260 const nsPathRegExp = /^([\w_\/-]+)::(.+)$/; 2261 const hydratedIslands = new WeakSet(); 2262 2263 /** 2264 * Recursive function that transforms a DOM tree into vDOM. 2265 * 2266 * @param root The root element or node to start traversing on. 2267 * @return The resulting vDOM tree. 2268 */ 2269 function toVdom(root) { 2270 const treeWalker = document.createTreeWalker(root, 205 // TEXT + CDATA_SECTION + COMMENT + PROCESSING_INSTRUCTION + ELEMENT 2271 ); 2272 function walk(node) { 2273 const { 2274 nodeType 2275 } = node; 2276 2277 // TEXT_NODE (3) 2278 if (nodeType === 3) { 2279 return [node.data]; 2280 } 2281 2282 // CDATA_SECTION_NODE (4) 2283 if (nodeType === 4) { 2284 var _nodeValue; 2285 const next = treeWalker.nextSibling(); 2286 node.replaceWith(new window.Text((_nodeValue = node.nodeValue) !== null && _nodeValue !== void 0 ? _nodeValue : '')); 2287 return [node.nodeValue, next]; 2288 } 2289 2290 // COMMENT_NODE (8) || PROCESSING_INSTRUCTION_NODE (7) 2291 if (nodeType === 8 || nodeType === 7) { 2292 const next = treeWalker.nextSibling(); 2293 node.remove(); 2294 return [null, next]; 2295 } 2296 const elementNode = node; 2297 const { 2298 attributes 2299 } = elementNode; 2300 const localName = elementNode.localName; 2301 const props = {}; 2302 const children = []; 2303 const directives = []; 2304 let ignore = false; 2305 let island = false; 2306 for (let i = 0; i < attributes.length; i++) { 2307 const attributeName = attributes[i].name; 2308 const attributeValue = attributes[i].value; 2309 if (attributeName[fullPrefix.length] && attributeName.slice(0, fullPrefix.length) === fullPrefix) { 2310 if (attributeName === ignoreAttr) { 2311 ignore = true; 2312 } else { 2313 var _regexResult$, _regexResult$2; 2314 const regexResult = nsPathRegExp.exec(attributeValue); 2315 const namespace = (_regexResult$ = regexResult?.[1]) !== null && _regexResult$ !== void 0 ? _regexResult$ : null; 2316 let value = (_regexResult$2 = regexResult?.[2]) !== null && _regexResult$2 !== void 0 ? _regexResult$2 : attributeValue; 2317 try { 2318 const parsedValue = JSON.parse(value); 2319 value = isObject(parsedValue) ? parsedValue : value; 2320 } catch {} 2321 if (attributeName === islandAttr) { 2322 island = true; 2323 const islandNamespace = 2324 // eslint-disable-next-line no-nested-ternary 2325 typeof value === 'string' ? value : typeof value?.namespace === 'string' ? value.namespace : null; 2326 namespaces.push(islandNamespace); 2327 } else { 2328 directives.push([attributeName, namespace, value]); 2329 } 2330 } 2331 } else if (attributeName === 'ref') { 2332 continue; 2333 } 2334 props[attributeName] = attributeValue; 2335 } 2336 if (ignore && !island) { 2337 return [(0,preact_module.h)(localName, { 2338 ...props, 2339 innerHTML: elementNode.innerHTML, 2340 __directives: { 2341 ignore: true 2342 } 2343 })]; 2344 } 2345 if (island) { 2346 hydratedIslands.add(elementNode); 2347 } 2348 if (directives.length) { 2349 props.__directives = directives.reduce((obj, [name, ns, value]) => { 2350 const directiveMatch = directiveParser.exec(name); 2351 if (directiveMatch === null) { 2352 warn(`Found malformed directive name: $name}.`); 2353 return obj; 2354 } 2355 const prefix = directiveMatch[1] || ''; 2356 const suffix = directiveMatch[2] || null; 2357 obj[prefix] = obj[prefix] || []; 2358 obj[prefix].push({ 2359 namespace: ns !== null && ns !== void 0 ? ns : currentNamespace(), 2360 value: value, 2361 suffix 2362 }); 2363 return obj; 2364 }, {}); 2365 } 2366 if (localName === 'template') { 2367 props.content = [...elementNode.content.childNodes].map(childNode => toVdom(childNode)); 2368 } else { 2369 let child = treeWalker.firstChild(); 2370 if (child) { 2371 while (child) { 2372 const [vnode, nextChild] = walk(child); 2373 if (vnode) { 2374 children.push(vnode); 2375 } 2376 child = nextChild || treeWalker.nextSibling(); 2377 } 2378 treeWalker.parentNode(); 2379 } 2380 } 2381 2382 // Restore previous namespace. 2383 if (island) { 2384 namespaces.pop(); 2385 } 2386 return [(0,preact_module.h)(localName, props, children)]; 2387 } 2388 return walk(treeWalker.currentNode); 2389 } 2390 2391 ;// ./node_modules/@wordpress/interactivity/build-module/init.js 2392 /** 2393 * External dependencies 2394 */ 2395 2396 /** 2397 * Internal dependencies 2398 */ 2399 2400 2401 2402 2403 // Keep the same root fragment for each interactive region node. 2404 const regionRootFragments = new WeakMap(); 2405 const getRegionRootFragment = region => { 2406 if (!region.parentElement) { 2407 throw Error('The passed region should be an element with a parent.'); 2408 } 2409 if (!regionRootFragments.has(region)) { 2410 regionRootFragments.set(region, createRootFragment(region.parentElement, region)); 2411 } 2412 return regionRootFragments.get(region); 2413 }; 2414 2415 // Initial vDOM regions associated with its DOM element. 2416 const initialVdom = new WeakMap(); 2417 2418 // Initialize the router with the initial DOM. 2419 const init = async () => { 2420 const nodes = document.querySelectorAll(`[data-$directivePrefix}-interactive]`); 2421 2422 /* 2423 * This `await` with setTimeout is required to apparently ensure that the interactive blocks have their stores 2424 * fully initialized prior to hydrating the blocks. If this is not present, then an error occurs, for example: 2425 * > view.js:46 Uncaught (in promise) ReferenceError: Cannot access 'state' before initialization 2426 * This occurs when splitTask() is implemented with scheduler.yield() as opposed to setTimeout(), as with the former 2427 * split tasks are added to the front of the task queue whereas with the latter they are added to the end of the queue. 2428 */ 2429 await new Promise(resolve => { 2430 setTimeout(resolve, 0); 2431 }); 2432 for (const node of nodes) { 2433 if (!hydratedIslands.has(node)) { 2434 await splitTask(); 2435 const fragment = getRegionRootFragment(node); 2436 const vdom = toVdom(node); 2437 initialVdom.set(node, vdom); 2438 await splitTask(); 2439 (0,preact_module/* hydrate */.Qv)(vdom, fragment); 2440 } 2441 } 2442 }; 2443 2444 ;// ./node_modules/@wordpress/interactivity/build-module/index.js 2445 /** 2446 * External dependencies 2447 */ 2448 2449 2450 2451 /** 2452 * Internal dependencies 2453 */ 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 const requiredConsent = 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'; 2467 const privateApis = lock => { 2468 if (lock === requiredConsent) { 2469 return { 2470 directivePrefix: directivePrefix, 2471 getRegionRootFragment: getRegionRootFragment, 2472 initialVdom: initialVdom, 2473 toVdom: toVdom, 2474 directive: directive, 2475 getNamespace: getNamespace, 2476 h: preact_module.h, 2477 cloneElement: preact_module/* cloneElement */.Ob, 2478 render: preact_module/* render */.XX, 2479 proxifyState: proxifyState, 2480 parseServerData: parseServerData, 2481 populateServerData: populateServerData, 2482 batch: signals_core_module_r 2483 }; 2484 } 2485 throw new Error('Forbidden access.'); 2486 }; 2487 directives(); 2488 init(); 2489 2490 var __webpack_exports__getConfig = __webpack_exports__.zj; 2491 var __webpack_exports__getContext = __webpack_exports__.SD; 2492 var __webpack_exports__getElement = __webpack_exports__.V6; 2493 var __webpack_exports__getServerContext = __webpack_exports__.$K; 2494 var __webpack_exports__getServerState = __webpack_exports__.vT; 2495 var __webpack_exports__privateApis = __webpack_exports__.jb; 2496 var __webpack_exports__splitTask = __webpack_exports__.yT; 2497 var __webpack_exports__store = __webpack_exports__.M_; 2498 var __webpack_exports__useCallback = __webpack_exports__.hb; 2499 var __webpack_exports__useEffect = __webpack_exports__.vJ; 2500 var __webpack_exports__useInit = __webpack_exports__.ip; 2501 var __webpack_exports__useLayoutEffect = __webpack_exports__.Nf; 2502 var __webpack_exports__useMemo = __webpack_exports__.Kr; 2503 var __webpack_exports__useRef = __webpack_exports__.li; 2504 var __webpack_exports__useState = __webpack_exports__.J0; 2505 var __webpack_exports__useWatch = __webpack_exports__.FH; 2506 var __webpack_exports__withScope = __webpack_exports__.v4; 2507 export { __webpack_exports__getConfig as getConfig, __webpack_exports__getContext as getContext, __webpack_exports__getElement as getElement, __webpack_exports__getServerContext as getServerContext, __webpack_exports__getServerState as getServerState, __webpack_exports__privateApis as privateApis, __webpack_exports__splitTask as splitTask, __webpack_exports__store as store, __webpack_exports__useCallback as useCallback, __webpack_exports__useEffect as useEffect, __webpack_exports__useInit as useInit, __webpack_exports__useLayoutEffect as useLayoutEffect, __webpack_exports__useMemo as useMemo, __webpack_exports__useRef as useRef, __webpack_exports__useState as useState, __webpack_exports__useWatch as useWatch, __webpack_exports__withScope as withScope };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Feb 22 08:20:01 2025 | Cross-referenced by PHPXref |