File: /home/axxoncom/domains/adrap.click/private_html/wp-content/plugins/kubio/build/editor/index.js
(()=>{var e={1874:e=>{e.exports='<html> <head> <style>body,html{background:#f1f3f5}.content{display:flex;flex-direction:column;align-items:center;justify-items:center;justify-content:center;position:fixed;left:0;top:0;width:100vw;height:100vh}.container{text-align:center}.message{font-size:1.2rem;color:#15192b;font-family:-apple-system,BlinkMacSystemFont,\'Segoe UI\',Roboto,Oxygen-Sans,Ubuntu,Cantarell,\'Helvetica Neue\',sans-serif}#eKIDzSscbEO1{overflow:visible;width:120px!important;height:120px!important;max-width:120px!important;fill:#a4afb7!important}#eKIDzSscbEO3_tr{animation:eKIDzSscbEO3_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO3_tr__tr{0%{transform:translate(193.209984px,190.850067px) rotate(0)}12%{transform:translate(193.209984px,190.850067px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}20%{transform:translate(193.209984px,190.850067px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}52%{transform:translate(193.209984px,190.850067px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}60%{transform:translate(193.209984px,190.850067px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}68%{transform:translate(193.209984px,190.850067px) rotate(0)}100%{transform:translate(193.209984px,190.850067px) rotate(0)}}#eKIDzSscbEO5_tr{animation:eKIDzSscbEO5_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO5_tr__tr{0%{transform:translate(193.219933px,61.519987px) rotate(360deg)}20%{transform:translate(193.219933px,61.519987px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}28%{transform:translate(193.219933px,61.519987px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}84%{transform:translate(193.219933px,61.519987px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}92%{transform:translate(193.219933px,61.519987px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}100%{transform:translate(193.219933px,61.519987px) rotate(360deg)}}#eKIDzSscbEO7_tr{animation:eKIDzSscbEO7_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO7_tr__tr{0%{transform:translate(59.18501px,193.18499px) rotate(0)}28%{transform:translate(59.18501px,193.18499px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}36%{transform:translate(59.18501px,193.18499px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}68%{transform:translate(59.18501px,193.18499px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}76%{transform:translate(59.18501px,193.18499px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}84%{transform:translate(59.18501px,193.18499px) rotate(0)}100%{transform:translate(59.18501px,193.18499px) rotate(0)}}#eKIDzSscbEO9_tr{animation:eKIDzSscbEO9_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO9_tr__tr{0%{transform:translate(59.149774px,59.150009px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}8%{transform:translate(59.149774px,59.150009px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}36%{transform:translate(59.149774px,59.150009px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}44%{transform:translate(59.149774px,59.150009px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t\t)}52%{transform:translate(59.149774px,59.150009px) rotate(360deg)}100%{transform:translate(59.149774px,59.150009px) rotate(360deg)}}</style> </head> <body> <div class="content"> <div class="container"> {svg_image} <p class="message">{message}</p> </div> </div> </body> </html> '},9457:e=>{e.exports='<html> <head> <style>.kubio-loading-logo{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);z-index:0}.kubio-loading-logo svg{width:120px!important;height:120px!important;max-width:120px!important;fill:#a4afb7!important}#eKIDzSscbEO1{overflow:visible;max-width:90px}#eKIDzSscbEO3_tr{animation:eKIDzSscbEO3_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO3_tr__tr{0%{transform:translate(193.209984px,190.850067px) rotate(0)}12%{transform:translate(193.209984px,190.850067px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}20%{transform:translate(193.209984px,190.850067px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}52%{transform:translate(193.209984px,190.850067px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}60%{transform:translate(193.209984px,190.850067px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}68%{transform:translate(193.209984px,190.850067px) rotate(0)}100%{transform:translate(193.209984px,190.850067px) rotate(0)}}#eKIDzSscbEO5_tr{animation:eKIDzSscbEO5_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO5_tr__tr{0%{transform:translate(193.219933px,61.519987px) rotate(360deg)}20%{transform:translate(193.219933px,61.519987px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}28%{transform:translate(193.219933px,61.519987px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}84%{transform:translate(193.219933px,61.519987px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}92%{transform:translate(193.219933px,61.519987px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}100%{transform:translate(193.219933px,61.519987px) rotate(360deg)}}#eKIDzSscbEO7_tr{animation:eKIDzSscbEO7_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO7_tr__tr{0%{transform:translate(59.18501px,193.18499px) rotate(0)}28%{transform:translate(59.18501px,193.18499px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}36%{transform:translate(59.18501px,193.18499px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}68%{transform:translate(59.18501px,193.18499px) rotate(90deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}76%{transform:translate(59.18501px,193.18499px) rotate(0);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}84%{transform:translate(59.18501px,193.18499px) rotate(0)}100%{transform:translate(59.18501px,193.18499px) rotate(0)}}#eKIDzSscbEO9_tr{animation:eKIDzSscbEO9_tr__tr 2s linear infinite normal forwards}@keyframes eKIDzSscbEO9_tr__tr{0%{transform:translate(59.149774px,59.150009px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}8%{transform:translate(59.149774px,59.150009px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}36%{transform:translate(59.149774px,59.150009px) rotate(270deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}44%{transform:translate(59.149774px,59.150009px) rotate(360deg);animation-timing-function:cubic-bezier(\n\t\t\t\t\t\t.39,\n\t\t\t\t\t\t.575,\n\t\t\t\t\t\t.565,\n\t\t\t\t\t\t1\n\t\t\t\t)}52%{transform:translate(59.149774px,59.150009px) rotate(360deg)}100%{transform:translate(59.149774px,59.150009px) rotate(360deg)}}</style> </head> <body> <div id="content"> </div> </body> </html> '},1143:e=>{"use strict";e.exports=function(e,t,o,n,i,r,a,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[o,n,i,r,a,s],u=0;(l=new Error(t.replace(/%s/g,(function(){return c[u++]})))).name="Invariant Violation"}throw l.framesToPop=1,l}}},2703:(e,t,o)=>{"use strict";var n=o(414);function i(){}function r(){}r.resetWarningCache=i,e.exports=function(){function e(e,t,o,i,r,a){if(a!==n){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var o={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:r,resetWarningCache:i};return o.PropTypes=o,o}},5697:(e,t,o)=>{e.exports=o(2703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},5800:function(e,t,o){!function(e,t){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var n=o(t);function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}var r={error:null},a=function(e){function t(){for(var t,o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).state=r,t.resetErrorBoundary=function(){for(var e,o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];null==t.props.onReset||(e=t.props).onReset.apply(e,n),t.reset()},t}var o,a;a=e,(o=t).prototype=Object.create(a.prototype),o.prototype.constructor=o,i(o,a),t.getDerivedStateFromError=function(e){return{error:e}};var s=t.prototype;return s.reset=function(){this.setState(r)},s.componentDidCatch=function(e,t){var o,n;null==(o=(n=this.props).onError)||o.call(n,e,t)},s.componentDidUpdate=function(e,t){var o,n,i,r,a=this.state.error,s=this.props.resetKeys;null!==a&&null!==t.error&&(void 0===(i=e.resetKeys)&&(i=[]),void 0===(r=s)&&(r=[]),i.length!==r.length||i.some((function(e,t){return!Object.is(e,r[t])})))&&(null==(o=(n=this.props).onResetKeysChange)||o.call(n,e.resetKeys,s),this.reset())},s.render=function(){var e=this.state.error,t=this.props,o=t.fallbackRender,i=t.FallbackComponent,r=t.fallback;if(null!==e){var a={error:e,resetErrorBoundary:this.resetErrorBoundary};if(n.isValidElement(r))return r;if("function"==typeof o)return o(a);if(i)return n.createElement(i,a);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(n.Component);e.ErrorBoundary=a,e.useErrorHandler=function(e){var t=n.useState(null),o=t[0],i=t[1];if(null!=e)throw e;if(null!=o)throw o;return i},e.withErrorBoundary=function(e,t){var o=function(o){return n.createElement(a,t,n.createElement(e,o))},i=e.displayName||e.name||"Unknown";return o.displayName="withErrorBoundary("+i+")",o},Object.defineProperty(e,"__esModule",{value:!0})}(t,o(9196))},9590:e=>{var t="undefined"!=typeof Element,o="function"==typeof Map,n="function"==typeof Set,i="function"==typeof ArrayBuffer&&!!ArrayBuffer.isView;function r(e,a){if(e===a)return!0;if(e&&a&&"object"==typeof e&&"object"==typeof a){if(e.constructor!==a.constructor)return!1;var s,l,c,u;if(Array.isArray(e)){if((s=e.length)!=a.length)return!1;for(l=s;0!=l--;)if(!r(e[l],a[l]))return!1;return!0}if(o&&e instanceof Map&&a instanceof Map){if(e.size!==a.size)return!1;for(u=e.entries();!(l=u.next()).done;)if(!a.has(l.value[0]))return!1;for(u=e.entries();!(l=u.next()).done;)if(!r(l.value[1],a.get(l.value[0])))return!1;return!0}if(n&&e instanceof Set&&a instanceof Set){if(e.size!==a.size)return!1;for(u=e.entries();!(l=u.next()).done;)if(!a.has(l.value[0]))return!1;return!0}if(i&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(a)){if((s=e.length)!=a.length)return!1;for(l=s;0!=l--;)if(e[l]!==a[l])return!1;return!0}if(e.constructor===RegExp)return e.source===a.source&&e.flags===a.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===a.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===a.toString();if((s=(c=Object.keys(e)).length)!==Object.keys(a).length)return!1;for(l=s;0!=l--;)if(!Object.prototype.hasOwnProperty.call(a,c[l]))return!1;if(t&&e instanceof Element)return!1;for(l=s;0!=l--;)if(("_owner"!==c[l]&&"__v"!==c[l]&&"__o"!==c[l]||!e.$$typeof)&&!r(e[c[l]],a[c[l]]))return!1;return!0}return e!=e&&a!=a}e.exports=function(e,t){try{return r(e,t)}catch(e){if((e.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw e}}},7761:(e,t,o)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),i=o(9196),r=s(i),a=s(o(5697));function s(e){return e&&e.__esModule?e:{default:e}}var l=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.scrollListener=o.scrollListener.bind(o),o.eventListenerOptions=o.eventListenerOptions.bind(o),o.mousewheelListener=o.mousewheelListener.bind(o),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"componentDidMount",value:function(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}},{key:"componentDidUpdate",value:function(){if(this.props.isReverse&&this.loadMore){var e=this.getParentElement(this.scrollComponent);e.scrollTop=e.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function(){var e=!1,t={get passive(){e=!0}};try{document.addEventListener("test",null,t),document.removeEventListener("test",null,t)}catch(e){}return e}},{key:"eventListenerOptions",value:function(){return this.props.useCapture,this.isPassiveSupported()?{useCapture:this.props.useCapture,passive:!0}:{passive:!1}}},{key:"setDefaultLoader",value:function(e){this.defaultLoader=e}},{key:"detachMousewheelListener",value:function(){var e=window;!1===this.props.useWindow&&(e=this.scrollComponent.parentNode),e.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function(){var e=window;!1===this.props.useWindow&&(e=this.getParentElement(this.scrollComponent)),e.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),e.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function(e){var t=this.props.getScrollParent&&this.props.getScrollParent();return null!=t?t:e&&e.parentNode}},{key:"filterProps",value:function(e){return e}},{key:"attachScrollListener",value:function(){var e=this.getParentElement(this.scrollComponent);if(this.props.hasMore&&e){var t=window;!1===this.props.useWindow&&(t=e),t.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),t.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),t.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}}},{key:"mousewheelListener",value:function(e){1!==e.deltaY||this.isPassiveSupported()||e.preventDefault()}},{key:"scrollListener",value:function(){var e=this.scrollComponent,t=window,o=this.getParentElement(e),n=void 0;if(this.props.useWindow){var i=document.documentElement||document.body.parentNode||document.body,r=void 0!==t.pageYOffset?t.pageYOffset:i.scrollTop;n=this.props.isReverse?r:this.calculateOffset(e,r)}else n=this.props.isReverse?o.scrollTop:e.scrollHeight-o.scrollTop-o.clientHeight;n<Number(this.props.threshold)&&e&&null!==e.offsetParent&&(this.detachScrollListener(),this.beforeScrollHeight=o.scrollHeight,this.beforeScrollTop=o.scrollTop,"function"==typeof this.props.loadMore&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}},{key:"calculateOffset",value:function(e,t){return e?this.calculateTopPosition(e)+(e.offsetHeight-t-window.innerHeight):0}},{key:"calculateTopPosition",value:function(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0}},{key:"render",value:function(){var e=this,t=this.filterProps(this.props),o=t.children,n=t.element,i=t.hasMore,a=(t.initialLoad,t.isReverse),s=t.loader,l=(t.loadMore,t.pageStart,t.ref),c=(t.threshold,t.useCapture,t.useWindow,t.getScrollParent,function(e,t){var o={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o}(t,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]));c.ref=function(t){e.scrollComponent=t,l&&l(t)};var u=[o];return i&&(s?a?u.unshift(s):u.push(s):this.defaultLoader&&(a?u.unshift(this.defaultLoader):u.push(this.defaultLoader))),r.default.createElement(n,c,u)}}]),t}(i.Component);l.propTypes={children:a.default.node.isRequired,element:a.default.node,hasMore:a.default.bool,initialLoad:a.default.bool,isReverse:a.default.bool,loader:a.default.node,loadMore:a.default.func.isRequired,pageStart:a.default.number,ref:a.default.func,getScrollParent:a.default.func,threshold:a.default.number,useCapture:a.default.bool,useWindow:a.default.bool},l.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},t.default=l,e.exports=t.default},246:(e,t,o)=>{e.exports=o(7761)},5251:(e,t,o)=>{"use strict";var n=o(9196),i=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,o){var n,r={},c=null,u=null;for(n in void 0!==o&&(c=""+o),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,n)&&!l.hasOwnProperty(n)&&(r[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===r[n]&&(r[n]=t[n]);return{$$typeof:i,type:e,key:c,ref:u,props:r,_owner:s.current}}t.Fragment=r,t.jsx=c,t.jsxs=c},5893:(e,t,o)=>{"use strict";e.exports=o(5251)},6255:e=>{var t="complete",o="canceled";function n(e,t,o){Math.max(0,t),Math.max(0,o),e.self===e?e.scrollTo(t,o):(e.scrollLeft=t,e.scrollTop=o)}function i(e){var o=e._scrollSettings;if(o){var r=o.maxSynchronousAlignments,a=function(e,t){var o,n,i,r,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,p=c&&null!=c.top?c.top:.5,h=c&&null!=c.leftOffset?c.leftOffset:0,m=c&&null!=c.topOffset?c.topOffset:0,g=d,f=p;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),n=u.left+t.pageXOffset-t.innerWidth*g+s*g,i=u.top+t.pageYOffset-t.innerHeight*f+l*f,n-=h,i-=m,n=e.align.lockX?t.pageXOffset:n,i=e.align.lockY?t.pageYOffset:i,r=n-t.pageXOffset,a=i-t.pageYOffset;else{s=u.width,l=u.height,o=t.getBoundingClientRect();var b=u.left-(o.left-t.scrollLeft),_=u.top-(o.top-t.scrollTop);n=b+s*g-t.clientWidth*g,i=_+l*f-t.clientHeight*f,n-=h,i-=m,n=Math.max(Math.min(n,t.scrollWidth-t.clientWidth),0),i=Math.max(Math.min(i,t.scrollHeight-t.clientHeight),0),n=e.align.lockX?t.scrollLeft:n,i=e.align.lockY?t.scrollTop:i,r=n-t.scrollLeft,a=i-t.scrollTop}return{x:n,y:i,differenceX:r,differenceY:a}}(o,e),s=Date.now()-o.startTime,l=Math.min(1/o.time*s,1);if(o.endIterations>=r)return n(e,a.x,a.y),e._scrollSettings=null,o.end(t);var c=1-o.ease(l);if(n(e,a.x-a.differenceX*c,a.y-a.differenceY*c),s>=o.time)return o.endIterations++,o.scrollAncestor&&i(o.scrollAncestor),void i(e);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(i.bind(null,e))}}function r(e){return e.self===e}function a(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function s(){return!0}function l(e){if(e.assignedSlot)return l(e.assignedSlot);if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}e.exports=function(e,n,c){if(e){"function"==typeof n&&(c=n,n=null),n||(n={}),n.time=isNaN(n.time)?1e3:n.time,n.ease=n.ease||function(e){return 1-Math.pow(1-e,e/2)},n.align=n.align||{};var u=l(e),d=1,p=n.validTarget||s,h=n.isScrollable;n.debug&&(console.log("About to scroll to",e),u||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var m=[];u;)if(n.debug&&console.log("Scrolling parent node",u),p(u,d)&&(h?h(u,a):a(u))&&(d++,m.push(u)),!(u=l(u))){g(t);break}return m.reduce(((t,a,s)=>function(e,t,n,a,s){var l,c=!t._scrollSettings,u=t._scrollSettings,d=Date.now(),p={passive:!0};function h(e){t._scrollSettings=null,t.parentElement&&t.parentElement._scrollSettings&&t.parentElement._scrollSettings.end(e),n.debug&&console.log("Scrolling ended with type",e,"for",t),s(e),l&&(t.removeEventListener("touchstart",l,p),t.removeEventListener("wheel",l,p))}u&&u.end(o);var m=n.maxSynchronousAlignments;return null==m&&(m=3),t._scrollSettings={startTime:d,endIterations:0,target:e,time:n.time,ease:n.ease,align:n.align,isWindow:n.isWindow||r,maxSynchronousAlignments:m,end:h,scrollAncestor:a},"cancellable"in n&&!n.cancellable||(l=h.bind(null,o),t.addEventListener("touchstart",l,p),t.addEventListener("wheel",l,p)),c&&i(t),l}(e,a,n,m[s+1],g)),null)}function g(e){--d||c&&c(e)}}},4670:(e,t,o)=>{"use strict";e.exports=o(5607)},9829:(e,t,o)=>{"use strict";var n,i,r,a=o(8946),s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function l(){r=!1}function c(e){if(e){if(e!==n){if(e.length!==s.length)throw new Error("Custom alphabet for shortid must be "+s.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,o){return t!==o.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+s.length+" unique characters. These characters were not unique: "+t.join(", "));n=e,l()}}else n!==s&&(n=s,l())}function u(){return r||(r=function(){n||c(s);for(var e,t=n.split(""),o=[],i=a.nextValue();t.length>0;)i=a.nextValue(),e=Math.floor(i*t.length),o.push(t.splice(e,1)[0]);return o.join("")}())}e.exports={get:function(){return n||s},characters:function(e){return c(e),n},seed:function(e){a.seed(e),i!==e&&(l(),i=e)},lookup:function(e){return u()[e]},shuffled:u}},480:(e,t,o)=>{"use strict";var n,i,r=o(8416);o(9829),e.exports=function(e){var t="",o=Math.floor(.001*(Date.now()-1567752802062));return o===i?n++:(n=0,i=o),t+=r(7),t+=r(e),n>0&&(t+=r(n)),t+r(o)}},8416:(e,t,o)=>{"use strict";var n=o(9829),i=o(3766),r=o(296);e.exports=function(e){for(var t,o=0,a="";!t;)a+=r(i,n.get(),1),t=e<Math.pow(16,o+1),o++;return a}},5607:(e,t,o)=>{"use strict";var n=o(9829),i=o(480),r=o(1082),a=o(5636)||0;function s(){return i(a)}e.exports=s,e.exports.generate=s,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return a=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=r},1082:(e,t,o)=>{"use strict";var n=o(9829);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))}},3766:e=>{"use strict";var t,o="object"==typeof window&&(window.crypto||window.msCrypto);t=o&&o.getRandomValues?function(e){return o.getRandomValues(new Uint8Array(e))}:function(e){for(var t=[],o=0;o<e;o++)t.push(Math.floor(256*Math.random()));return t},e.exports=t},8946:e=>{"use strict";var t=1;e.exports={nextValue:function(){return(t=(9301*t+49297)%233280)/233280},seed:function(e){t=e}}},5636:e=>{"use strict";e.exports=0},296:e=>{e.exports=function(e,t,o){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*n*o/t.length),r="";;)for(var a=e(i),s=i;s--;)if((r+=t[a[s]&n]||"").length===+o)return r}},989:(e,t,o)=>{e.exports=o(3268)},3268:function(e,t){var o;!function(n){"use strict";var i={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"Ae",Å:"A",Æ:"AE",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"Oe",Ő:"O",Ø:"O",Ù:"U",Ú:"U",Û:"U",Ü:"Ue",Ű:"U",Ý:"Y",Þ:"TH",ß:"ss",à:"a",á:"a",â:"a",ã:"a",ä:"ae",å:"a",æ:"ae",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"oe",ő:"o",ø:"o",ù:"u",ú:"u",û:"u",ü:"ue",ű:"u",ý:"y",þ:"th",ÿ:"y",ẞ:"SS",ا:"a",أ:"a",إ:"i",آ:"aa",ؤ:"u",ئ:"e",ء:"a",ب:"b",ت:"t",ث:"th",ج:"j",ح:"h",خ:"kh",د:"d",ذ:"th",ر:"r",ز:"z",س:"s",ش:"sh",ص:"s",ض:"dh",ط:"t",ظ:"z",ع:"a",غ:"gh",ف:"f",ق:"q",ك:"k",ل:"l",م:"m",ن:"n",ه:"h",و:"w",ي:"y",ى:"a",ة:"h",ﻻ:"la",ﻷ:"laa",ﻹ:"lai",ﻵ:"laa",گ:"g",چ:"ch",پ:"p",ژ:"zh",ک:"k",ی:"y","َ":"a","ً":"an","ِ":"e","ٍ":"en","ُ":"u","ٌ":"on","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9",က:"k",ခ:"kh",ဂ:"g",ဃ:"ga",င:"ng",စ:"s",ဆ:"sa",ဇ:"z",စျ:"za",ည:"ny",ဋ:"t",ဌ:"ta",ဍ:"d",ဎ:"da",ဏ:"na",တ:"t",ထ:"ta",ဒ:"d",ဓ:"da",န:"n",ပ:"p",ဖ:"pa",ဗ:"b",ဘ:"ba",မ:"m",ယ:"y",ရ:"ya",လ:"l",ဝ:"w",သ:"th",ဟ:"h",ဠ:"la",အ:"a","ြ":"y","ျ":"ya","ွ":"w","ြွ":"yw","ျွ":"ywa","ှ":"h",ဧ:"e","၏":"-e",ဣ:"i",ဤ:"-i",ဉ:"u",ဦ:"-u",ဩ:"aw",သြော:"aw",ဪ:"aw","၀":"0","၁":"1","၂":"2","၃":"3","၄":"4","၅":"5","၆":"6","၇":"7","၈":"8","၉":"9","္":"","့":"","း":"",č:"c",ď:"d",ě:"e",ň:"n",ř:"r",š:"s",ť:"t",ů:"u",ž:"z",Č:"C",Ď:"D",Ě:"E",Ň:"N",Ř:"R",Š:"S",Ť:"T",Ů:"U",Ž:"Z",ހ:"h",ށ:"sh",ނ:"n",ރ:"r",ބ:"b",ޅ:"lh",ކ:"k",އ:"a",ވ:"v",މ:"m",ފ:"f",ދ:"dh",ތ:"th",ލ:"l",ގ:"g",ޏ:"gn",ސ:"s",ޑ:"d",ޒ:"z",ޓ:"t",ޔ:"y",ޕ:"p",ޖ:"j",ޗ:"ch",ޘ:"tt",ޙ:"hh",ޚ:"kh",ޛ:"th",ޜ:"z",ޝ:"sh",ޞ:"s",ޟ:"d",ޠ:"t",ޡ:"z",ޢ:"a",ޣ:"gh",ޤ:"q",ޥ:"w","ަ":"a","ާ":"aa","ި":"i","ީ":"ee","ު":"u","ޫ":"oo","ެ":"e","ޭ":"ey","ޮ":"o","ޯ":"oa","ް":"",ა:"a",ბ:"b",გ:"g",დ:"d",ე:"e",ვ:"v",ზ:"z",თ:"t",ი:"i",კ:"k",ლ:"l",მ:"m",ნ:"n",ო:"o",პ:"p",ჟ:"zh",რ:"r",ს:"s",ტ:"t",უ:"u",ფ:"p",ქ:"k",ღ:"gh",ყ:"q",შ:"sh",ჩ:"ch",ც:"ts",ძ:"dz",წ:"ts",ჭ:"ch",ხ:"kh",ჯ:"j",ჰ:"h",α:"a",β:"v",γ:"g",δ:"d",ε:"e",ζ:"z",η:"i",θ:"th",ι:"i",κ:"k",λ:"l",μ:"m",ν:"n",ξ:"ks",ο:"o",π:"p",ρ:"r",σ:"s",τ:"t",υ:"y",φ:"f",χ:"x",ψ:"ps",ω:"o",ά:"a",έ:"e",ί:"i",ό:"o",ύ:"y",ή:"i",ώ:"o",ς:"s",ϊ:"i",ΰ:"y",ϋ:"y",ΐ:"i",Α:"A",Β:"B",Γ:"G",Δ:"D",Ε:"E",Ζ:"Z",Η:"I",Θ:"TH",Ι:"I",Κ:"K",Λ:"L",Μ:"M",Ν:"N",Ξ:"KS",Ο:"O",Π:"P",Ρ:"R",Σ:"S",Τ:"T",Υ:"Y",Φ:"F",Χ:"X",Ψ:"PS",Ω:"O",Ά:"A",Έ:"E",Ί:"I",Ό:"O",Ύ:"Y",Ή:"I",Ώ:"O",Ϊ:"I",Ϋ:"Y",ā:"a",ē:"e",ģ:"g",ī:"i",ķ:"k",ļ:"l",ņ:"n",ū:"u",Ā:"A",Ē:"E",Ģ:"G",Ī:"I",Ķ:"k",Ļ:"L",Ņ:"N",Ū:"U",Ќ:"Kj",ќ:"kj",Љ:"Lj",љ:"lj",Њ:"Nj",њ:"nj",Тс:"Ts",тс:"ts",ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ś:"s",ź:"z",ż:"z",Ą:"A",Ć:"C",Ę:"E",Ł:"L",Ń:"N",Ś:"S",Ź:"Z",Ż:"Z",Є:"Ye",І:"I",Ї:"Yi",Ґ:"G",є:"ye",і:"i",ї:"yi",ґ:"g",ă:"a",Ă:"A",ș:"s",Ș:"S",ț:"t",Ț:"T",ţ:"t",Ţ:"T",а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"yo",ж:"zh",з:"z",и:"i",й:"i",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"c",ч:"ch",ш:"sh",щ:"sh",ъ:"",ы:"y",ь:"",э:"e",ю:"yu",я:"ya",А:"A",Б:"B",В:"V",Г:"G",Д:"D",Е:"E",Ё:"Yo",Ж:"Zh",З:"Z",И:"I",Й:"I",К:"K",Л:"L",М:"M",Н:"N",О:"O",П:"P",Р:"R",С:"S",Т:"T",У:"U",Ф:"F",Х:"Kh",Ц:"C",Ч:"Ch",Ш:"Sh",Щ:"Sh",Ъ:"",Ы:"Y",Ь:"",Э:"E",Ю:"Yu",Я:"Ya",ђ:"dj",ј:"j",ћ:"c",џ:"dz",Ђ:"Dj",Ј:"j",Ћ:"C",Џ:"Dz",ľ:"l",ĺ:"l",ŕ:"r",Ľ:"L",Ĺ:"L",Ŕ:"R",ş:"s",Ş:"S",ı:"i",İ:"I",ğ:"g",Ğ:"G",ả:"a",Ả:"A",ẳ:"a",Ẳ:"A",ẩ:"a",Ẩ:"A",đ:"d",Đ:"D",ẹ:"e",Ẹ:"E",ẽ:"e",Ẽ:"E",ẻ:"e",Ẻ:"E",ế:"e",Ế:"E",ề:"e",Ề:"E",ệ:"e",Ệ:"E",ễ:"e",Ễ:"E",ể:"e",Ể:"E",ỏ:"o",ọ:"o",Ọ:"o",ố:"o",Ố:"O",ồ:"o",Ồ:"O",ổ:"o",Ổ:"O",ộ:"o",Ộ:"O",ỗ:"o",Ỗ:"O",ơ:"o",Ơ:"O",ớ:"o",Ớ:"O",ờ:"o",Ờ:"O",ợ:"o",Ợ:"O",ỡ:"o",Ỡ:"O",Ở:"o",ở:"o",ị:"i",Ị:"I",ĩ:"i",Ĩ:"I",ỉ:"i",Ỉ:"i",ủ:"u",Ủ:"U",ụ:"u",Ụ:"U",ũ:"u",Ũ:"U",ư:"u",Ư:"U",ứ:"u",Ứ:"U",ừ:"u",Ừ:"U",ự:"u",Ự:"U",ữ:"u",Ữ:"U",ử:"u",Ử:"ư",ỷ:"y",Ỷ:"y",ỳ:"y",Ỳ:"Y",ỵ:"y",Ỵ:"Y",ỹ:"y",Ỹ:"Y",ạ:"a",Ạ:"A",ấ:"a",Ấ:"A",ầ:"a",Ầ:"A",ậ:"a",Ậ:"A",ẫ:"a",Ẫ:"A",ắ:"a",Ắ:"A",ằ:"a",Ằ:"A",ặ:"a",Ặ:"A",ẵ:"a",Ẵ:"A","⓪":"0","①":"1","②":"2","③":"3","④":"4","⑤":"5","⑥":"6","⑦":"7","⑧":"8","⑨":"9","⑩":"10","⑪":"11","⑫":"12","⑬":"13","⑭":"14","⑮":"15","⑯":"16","⑰":"17","⑱":"18","⑲":"18","⑳":"18","⓵":"1","⓶":"2","⓷":"3","⓸":"4","⓹":"5","⓺":"6","⓻":"7","⓼":"8","⓽":"9","⓾":"10","⓿":"0","⓫":"11","⓬":"12","⓭":"13","⓮":"14","⓯":"15","⓰":"16","⓱":"17","⓲":"18","⓳":"19","⓴":"20","Ⓐ":"A","Ⓑ":"B","Ⓒ":"C","Ⓓ":"D","Ⓔ":"E","Ⓕ":"F","Ⓖ":"G","Ⓗ":"H","Ⓘ":"I","Ⓙ":"J","Ⓚ":"K","Ⓛ":"L","Ⓜ":"M","Ⓝ":"N","Ⓞ":"O","Ⓟ":"P","Ⓠ":"Q","Ⓡ":"R","Ⓢ":"S","Ⓣ":"T","Ⓤ":"U","Ⓥ":"V","Ⓦ":"W","Ⓧ":"X","Ⓨ":"Y","Ⓩ":"Z","ⓐ":"a","ⓑ":"b","ⓒ":"c","ⓓ":"d","ⓔ":"e","ⓕ":"f","ⓖ":"g","ⓗ":"h","ⓘ":"i","ⓙ":"j","ⓚ":"k","ⓛ":"l","ⓜ":"m","ⓝ":"n","ⓞ":"o","ⓟ":"p","ⓠ":"q","ⓡ":"r","ⓢ":"s","ⓣ":"t","ⓤ":"u","ⓦ":"v","ⓥ":"w","ⓧ":"x","ⓨ":"y","ⓩ":"z","“":'"',"”":'"',"‘":"'","’":"'","∂":"d",ƒ:"f","™":"(TM)","©":"(C)",œ:"oe",Œ:"OE","®":"(R)","†":"+","℠":"(SM)","…":"...","˚":"o",º:"o",ª:"a","•":"*","၊":",","။":".",$:"USD","€":"EUR","₢":"BRN","₣":"FRF","£":"GBP","₤":"ITL","₦":"NGN","₧":"ESP","₩":"KRW","₪":"ILS","₫":"VND","₭":"LAK","₮":"MNT","₯":"GRD","₱":"ARS","₲":"PYG","₳":"ARA","₴":"UAH","₵":"GHS","¢":"cent","¥":"CNY",元:"CNY",円:"YEN","﷼":"IRR","₠":"EWE","฿":"THB","₨":"INR","₹":"INR","₰":"PF","₺":"TRY","؋":"AFN","₼":"AZN",лв:"BGN","៛":"KHR","₡":"CRC","₸":"KZT",ден:"MKD",zł:"PLN","₽":"RUB","₾":"GEL"},r=["်","ް"],a={"ာ":"a","ါ":"a","ေ":"e","ဲ":"e","ိ":"i","ီ":"i","ို":"o","ု":"u","ူ":"u","ေါင်":"aung","ော":"aw","ော်":"aw","ေါ":"aw","ေါ်":"aw","်":"်",က်:"et","ိုက်":"aik","ောက်":"auk",င်:"in","ိုင်":"aing","ောင်":"aung",စ်:"it",ည်:"i",တ်:"at","ိတ်":"eik","ုတ်":"ok","ွတ်":"ut","ေတ်":"it",ဒ်:"d","ိုဒ်":"ok","ုဒ်":"ait",န်:"an","ာန်":"an","ိန်":"ein","ုန်":"on","ွန်":"un",ပ်:"at","ိပ်":"eik","ုပ်":"ok","ွပ်":"ut",န်ုပ်:"nub",မ်:"an","ိမ်":"ein","ုမ်":"on","ွမ်":"un",ယ်:"e","ိုလ်":"ol",ဉ်:"in","ံ":"an","ိံ":"ein","ုံ":"on","ައް":"ah","ަށް":"ah"},s={en:{},az:{ç:"c",ə:"e",ğ:"g",ı:"i",ö:"o",ş:"s",ü:"u",Ç:"C",Ə:"E",Ğ:"G",İ:"I",Ö:"O",Ş:"S",Ü:"U"},cs:{č:"c",ď:"d",ě:"e",ň:"n",ř:"r",š:"s",ť:"t",ů:"u",ž:"z",Č:"C",Ď:"D",Ě:"E",Ň:"N",Ř:"R",Š:"S",Ť:"T",Ů:"U",Ž:"Z"},fi:{ä:"a",Ä:"A",ö:"o",Ö:"O"},hu:{ä:"a",Ä:"A",ö:"o",Ö:"O",ü:"u",Ü:"U",ű:"u",Ű:"U"},lt:{ą:"a",č:"c",ę:"e",ė:"e",į:"i",š:"s",ų:"u",ū:"u",ž:"z",Ą:"A",Č:"C",Ę:"E",Ė:"E",Į:"I",Š:"S",Ų:"U",Ū:"U"},lv:{ā:"a",č:"c",ē:"e",ģ:"g",ī:"i",ķ:"k",ļ:"l",ņ:"n",š:"s",ū:"u",ž:"z",Ā:"A",Č:"C",Ē:"E",Ģ:"G",Ī:"i",Ķ:"k",Ļ:"L",Ņ:"N",Š:"S",Ū:"u",Ž:"Z"},pl:{ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ó:"o",ś:"s",ź:"z",ż:"z",Ą:"A",Ć:"C",Ę:"e",Ł:"L",Ń:"N",Ó:"O",Ś:"S",Ź:"Z",Ż:"Z"},sv:{ä:"a",Ä:"A",ö:"o",Ö:"O"},sk:{ä:"a",Ä:"A"},sr:{љ:"lj",њ:"nj",Љ:"Lj",Њ:"Nj",đ:"dj",Đ:"Dj"},tr:{Ü:"U",Ö:"O",ü:"u",ö:"o"}},l={ar:{"∆":"delta","∞":"la-nihaya","♥":"hob","&":"wa","|":"aw","<":"aqal-men",">":"akbar-men","∑":"majmou","¤":"omla"},az:{},ca:{"∆":"delta","∞":"infinit","♥":"amor","&":"i","|":"o","<":"menys que",">":"mes que","∑":"suma dels","¤":"moneda"},cs:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"nebo","<":"mensi nez",">":"vetsi nez","∑":"soucet","¤":"mena"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},dv:{"∆":"delta","∞":"kolunulaa","♥":"loabi","&":"aai","|":"noonee","<":"ah vure kuda",">":"ah vure bodu","∑":"jumula","¤":"faisaa"},en:{"∆":"delta","∞":"infinity","♥":"love","&":"and","|":"or","<":"less than",">":"greater than","∑":"sum","¤":"currency"},es:{"∆":"delta","∞":"infinito","♥":"amor","&":"y","|":"u","<":"menos que",">":"mas que","∑":"suma de los","¤":"moneda"},fa:{"∆":"delta","∞":"bi-nahayat","♥":"eshgh","&":"va","|":"ya","<":"kamtar-az",">":"bishtar-az","∑":"majmooe","¤":"vahed"},fi:{"∆":"delta","∞":"aarettomyys","♥":"rakkaus","&":"ja","|":"tai","<":"pienempi kuin",">":"suurempi kuin","∑":"summa","¤":"valuutta"},fr:{"∆":"delta","∞":"infiniment","♥":"Amour","&":"et","|":"ou","<":"moins que",">":"superieure a","∑":"somme des","¤":"monnaie"},ge:{"∆":"delta","∞":"usasruloba","♥":"siqvaruli","&":"da","|":"an","<":"naklebi",">":"meti","∑":"jami","¤":"valuta"},gr:{},hu:{"∆":"delta","∞":"vegtelen","♥":"szerelem","&":"es","|":"vagy","<":"kisebb mint",">":"nagyobb mint","∑":"szumma","¤":"penznem"},it:{"∆":"delta","∞":"infinito","♥":"amore","&":"e","|":"o","<":"minore di",">":"maggiore di","∑":"somma","¤":"moneta"},lt:{"∆":"delta","∞":"begalybe","♥":"meile","&":"ir","|":"ar","<":"maziau nei",">":"daugiau nei","∑":"suma","¤":"valiuta"},lv:{"∆":"delta","∞":"bezgaliba","♥":"milestiba","&":"un","|":"vai","<":"mazak neka",">":"lielaks neka","∑":"summa","¤":"valuta"},my:{"∆":"kwahkhyaet","∞":"asaonasme","♥":"akhyait","&":"nhin","|":"tho","<":"ngethaw",">":"kyithaw","∑":"paungld","¤":"ngwekye"},mk:{},nl:{"∆":"delta","∞":"oneindig","♥":"liefde","&":"en","|":"of","<":"kleiner dan",">":"groter dan","∑":"som","¤":"valuta"},pl:{"∆":"delta","∞":"nieskonczonosc","♥":"milosc","&":"i","|":"lub","<":"mniejsze niz",">":"wieksze niz","∑":"suma","¤":"waluta"},pt:{"∆":"delta","∞":"infinito","♥":"amor","&":"e","|":"ou","<":"menor que",">":"maior que","∑":"soma","¤":"moeda"},ro:{"∆":"delta","∞":"infinit","♥":"dragoste","&":"si","|":"sau","<":"mai mic ca",">":"mai mare ca","∑":"suma","¤":"valuta"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"},sk:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"alebo","<":"menej ako",">":"viac ako","∑":"sucet","¤":"mena"},sr:{},tr:{"∆":"delta","∞":"sonsuzluk","♥":"ask","&":"ve","|":"veya","<":"kucuktur",">":"buyuktur","∑":"toplam","¤":"para birimi"},uk:{"∆":"delta","∞":"bezkinechnist","♥":"lubov","&":"i","|":"abo","<":"menshe",">":"bilshe","∑":"suma","¤":"valjuta"},vn:{"∆":"delta","∞":"vo cuc","♥":"yeu","&":"va","|":"hoac","<":"nho hon",">":"lon hon","∑":"tong","¤":"tien te"}},c=[";","?",":","@","&","=","+","$",",","/"].join(""),u=[";","?",":","@","&","=","+","$",","].join(""),d=[".","!","~","*","'","(",")"].join(""),p=function(e,t){var o,n,p,g,f,b,_,v,y,k,x,S,w,C,I="-",j="",T="",P=!0,E={},R="";if("string"!=typeof e)return"";if("string"==typeof t&&(I=t),_=l.en,v=s.en,"object"==typeof t)for(x in o=t.maintainCase||!1,E=t.custom&&"object"==typeof t.custom?t.custom:E,p=+t.truncate>1&&t.truncate||!1,g=t.uric||!1,f=t.uricNoSlash||!1,b=t.mark||!1,P=!1!==t.symbols&&!1!==t.lang,I=t.separator||I,g&&(R+=c),f&&(R+=u),b&&(R+=d),_=t.lang&&l[t.lang]&&P?l[t.lang]:P?l.en:{},v=t.lang&&s[t.lang]?s[t.lang]:!1===t.lang||!0===t.lang?{}:s.en,t.titleCase&&"number"==typeof t.titleCase.length&&Array.prototype.toString.call(t.titleCase)?(t.titleCase.forEach((function(e){E[e+""]=e+""})),n=!0):n=!!t.titleCase,t.custom&&"number"==typeof t.custom.length&&Array.prototype.toString.call(t.custom)&&t.custom.forEach((function(e){E[e+""]=e+""})),Object.keys(E).forEach((function(t){var o;o=t.length>1?new RegExp("\\b"+h(t)+"\\b","gi"):new RegExp(h(t),"gi"),e=e.replace(o,E[t])})),E)R+=x;for(R=h(R+=I),w=!1,C=!1,k=0,S=(e=e.replace(/(^\s+|\s+$)/g,"")).length;k<S;k++)x=e[k],m(x,E)?w=!1:v[x]?(x=w&&v[x].match(/[A-Za-z0-9]/)?" "+v[x]:v[x],w=!1):x in i?(k+1<S&&r.indexOf(e[k+1])>=0?(T+=x,x=""):!0===C?(x=a[T]+i[x],T=""):x=w&&i[x].match(/[A-Za-z0-9]/)?" "+i[x]:i[x],w=!1,C=!1):x in a?(T+=x,x="",k===S-1&&(x=a[T]),C=!0):!_[x]||g&&-1!==c.indexOf(x)||f&&-1!==u.indexOf(x)?(!0===C?(x=a[T]+x,T="",C=!1):w&&(/[A-Za-z0-9]/.test(x)||j.substr(-1).match(/A-Za-z0-9]/))&&(x=" "+x),w=!1):(x=w||j.substr(-1).match(/[A-Za-z0-9]/)?I+_[x]:_[x],x+=void 0!==e[k+1]&&e[k+1].match(/[A-Za-z0-9]/)?I:"",w=!0),j+=x.replace(new RegExp("[^\\w\\s"+R+"_-]","g"),I);return n&&(j=j.replace(/(\w)(\S*)/g,(function(e,t,o){var n=t.toUpperCase()+(null!==o?o:"");return Object.keys(E).indexOf(n.toLowerCase())<0?n:n.toLowerCase()}))),j=j.replace(/\s+/g,I).replace(new RegExp("\\"+I+"+","g"),I).replace(new RegExp("(^\\"+I+"+|\\"+I+"+$)","g"),""),p&&j.length>p&&(y=j.charAt(p)===I,j=j.slice(0,p),y||(j=j.slice(0,j.lastIndexOf(I)))),o||n||(j=j.toLowerCase()),j},h=function(e){return e.replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&")},m=function(e,t){for(var o in t)if(t[o]===e)return!0};e.exports?(e.exports=p,e.exports.createSlug=function(e){return function(t){return p(t,e)}}):void 0===(o=function(){return p}.apply(t,[]))||(e.exports=o)}()},5358:(e,t,o)=>{"use strict";Object.defineProperty(t,"Ls",{enumerable:!0,get:function(){return n.STORE_KEY}});var n=o(9527);n.STORE_KEY},9196:e=>{"use strict";e.exports=window.React},9527:e=>{"use strict";e.exports=window.kubio.constants},9307:e=>{"use strict";e.exports=window.wp.element},3967:(e,t)=>{var o;!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e="",t=0;t<arguments.length;t++){var o=arguments[t];o&&(e=a(e,r(o)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return i.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var o in e)n.call(e,o)&&e[o]&&(t=a(t,o));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(i.default=i,e.exports=i):void 0===(o=function(){return i}.apply(t,[]))||(e.exports=o)}()}},t={};function o(n){var i=t[n];if(void 0!==i)return i.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";o.r(n),o.d(n,{SidebarArea:()=>st,SubSidebarArea:()=>tt,__experimentalFullscreenModeClose:()=>XS,initialize:()=>tw,registerEditSiteStore:()=>jk,registerSidebarArea:()=>rt,registerSubSidebarArea:()=>at});var e={};o.r(e),o.d(e,{disableComplementaryArea:()=>ue,enableComplementaryArea:()=>ce,pinItem:()=>de,setDefaultComplementaryArea:()=>le,setFeatureDefaults:()=>ge,setFeatureValue:()=>me,toggleFeature:()=>he,unpinItem:()=>pe});var t={};o.r(t),o.d(t,{getActiveComplementaryArea:()=>fe,isFeatureActive:()=>_e,isItemPinned:()=>be});var i={};o.r(i),o.d(i,{__experimentalSetPreviewDeviceType:()=>Yv,addSubSidebar:()=>ly,addTemplate:()=>Xv,closeSidebar:()=>uy,openInserterSidebar:()=>sy,openNavigationPanelToMenu:()=>ny,openSidebar:()=>ay,removeSubSidebar:()=>cy,removeTemplate:()=>Jv,setCurrentAncestor:()=>my,setHomeTemplateId:()=>ey,setIsListViewOpened:()=>gy,setIsNavigationPanelOpened:()=>iy,setKubioEditorMode:()=>by,setOpenInserter:()=>hy,setPage:()=>ty,setTemplate:()=>Zv,setTemplatePart:()=>Qv,setUIVersion:()=>fy,showHomepage:()=>oy,toggleAICapabilities:()=>_y,toggleFeature:()=>qv,toggleGlobalStyleEditing:()=>dy,toggleGutentagDebug:()=>py,updateAIInfo:()=>vy,updateExcludedSectionCategories:()=>yy,updateFlagSettings:()=>ky,updateSettings:()=>ry});var r={};o.r(r),o.d(r,{__experimentalGetInsertionPoint:()=>rk,__experimentalGetPreviewDeviceType:()=>Ry,currentPageHasFSETemplate:()=>ck,getAIInfo:()=>xk,getAvailablePageTemplates:()=>gk,getCanUserCreateMedia:()=>Ay,getCanvasMode:()=>wk,getClassicTemplateId:()=>fk,getCurrentAncestor:()=>Qy,getCurrentKubioTemplateSource:()=>sk,getCurrentPageTemplate:()=>lk,getCurrentPostId:()=>dk,getCurrentPostType:()=>uk,getEditedPostId:()=>Dy,getEditedPostType:()=>By,getEditorOpenedSidebar:()=>ek,getEntity:()=>Ky,getExcludedSectionCategories:()=>Ck,getGlobalStyleEditingPreviousEntity:()=>nk,getHomeTemplateId:()=>Ny,getIsBlogPage:()=>pk,getIsFrontPage:()=>hk,getIsInnerPage:()=>mk,getIsWooCommercePage:()=>bk,getKubioEditorMode:()=>yk,getKubioEditorModeIsSimple:()=>kk,getNavigationMenu:()=>zy,getOpenedInsertedClientId:()=>Zy,getOpenedInsertedShouldCloseOnSelect:()=>Jy,getOpenedInsertedShouldReplace:()=>Xy,getOpenedInserter:()=>Yy,getPage:()=>My,getSettings:()=>Oy,getShowOnFront:()=>$y,getSubSidebars:()=>tk,getTemplateId:()=>Gy,getTemplateIds:()=>Wy,getTemplatePartId:()=>Hy,getTemplatePartIds:()=>Vy,getTemplateType:()=>Uy,getUIVersion:()=>_k,isAICapabilityEnabled:()=>vk,isChangingPage:()=>Sk,isEditorSidebarOpened:()=>qy,isFeatureActive:()=>Ey,isGlobalStyleEditing:()=>ok,isGutentagDebug:()=>ik,isInserterOpened:()=>Fy,isListViewOpened:()=>ak,isNavigationOpened:()=>Ly});const a=window.kubio.blockPatterns,s=window.kubio.core,l=window.wp.data,c=window.wp.blockLibrary;var u=o(9307);const d=window.wp.hooks,p=window.wp.compose,h=window.wp.components,m=window.wp.i18n;var g=o(5893);const f=(0,p.createHigherOrderComponent)((e=>t=>{const{dataHelper:o}=(0,s.useKubioBlockContext)(),n=!!top.imageHubMediaTabReactApp;if(!o||!n&&!top.imageHubMediaTabInitedFromKubio)return(0,g.jsx)(e,{...t});const i=(0,u.useCallback)((({type:e,open:t})=>"image"!==e?(0,g.jsx)(g.Fragment,{}):(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>{top.kubioOpenImageHubOnNextOpenedMediaPicker=!0,t()},className:"kubio-button-100 kubio-ai-button kubio-free-images-button",children:(0,m.__)("Free Images","kubio")})),[]);return(0,g.jsx)(e,{...t,secondaryButton:i})}),"withImageHubImageControl");(0,d.addFilter)("kubio.control.media-picker","kubio/control/image-hub-media-picker",f,4);const b=window.wp.notices,_=window.lodash;var v=o.n(_),y=o(9527);const k=window.kubio.coreHooks,x=window.kubio.editorData,S=window.kubio.ai,w=window.kubio.globalData,C=window.kubio.wpGlobalStyles,I=window.wp.blockEditor,j=window.wp.coreData,T=window.kubio.utils;let P=!1;const E=()=>{const[e,t]=(0,u.useState)(!1);return!(0,u.useMemo)((()=>{if(P)return!1;if(!(0,T.getBackendData)("multilanguage.isWpmlActive"))return!1;try{if(new URL(location).searchParams.get("isTranslateRedirect"))return!0}catch(e){return!1}return!1}),[e])||P?(0,g.jsx)(g.Fragment,{}):(0,g.jsx)(R,{onEditInDefaultLanguage:()=>{P=!0,t(Math.random())}})},R=({onEditInDefaultLanguage:e})=>{const t=(0,s.useUnloadStoreEntities)();return(0,g.jsxs)(h.Modal,{className:"kubio-wpml-redirect-modal",title:(0,m.__)("You are trying to to edit a translation","kubio"),onRequestClose:()=>{},shouldCloseOnEsc:!1,shouldCloseOnClickOutside:!1,isDismissible:!1,children:[(0,g.jsx)("p",{children:(0,g.jsx)("strong",{children:(0,m.__)("You must update the design by editing the page in default language and then update the translations","kubio")})}),(0,g.jsx)("p",{children:(0,m.__)('To update the design please use the "Edit page in the default language" button.',"kubio")}),(0,g.jsx)("p",{children:(0,m.__)('If you want to translate the content please use the "Translate" button to edit the translated content',"kubio")}),(0,g.jsxs)(h.ButtonGroup,{className:"h-template-part-modal__button-group",children:[(0,g.jsx)(h.Button,{isLink:!0,onClick:e,children:(0,m.__)("Edit page in the default language","kubio")}),(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>{t();let e=(0,T.getBackendData)("admin_url")+"/admin.php";try{let t=new URL(e);t.searchParams.append("page","tm/menu/main.php");let o=t.toString();window.location=o}catch(e){console.error(e),window.location=(0,T.getBackendData)("admin_url")}},children:(0,m.__)("Translate")})]})]})},A=window.wp.apiFetch;var O=o.n(A);const N=(0,T.getBackendData)("showFrontPageRevertNotice");let B=!1;const D=()=>{const[e,t]=(0,u.useState)(!1),{isFrontPage:o}=(0,l.useSelect)((e=>{const{getIsFrontPage:t}=e("kubio/edit-site")||{};return{isFrontPage:null==t?void 0:t()}}),[]);return(0,d.applyFilters)("kubio.frontPageRevertEnabled",!0)&&N&&!e&&o&&!B?(0,g.jsx)(G,{onClose:()=>{t(!0),B=!0}}):(0,g.jsx)(g.Fragment,{})},M=(0,T.getBackendData)("frontPageRevertBackupData"),L="posts"===(null==M?void 0:M.showOnFront),z=(0,T.getBackendData)("frontPageRevertNoticeNonce");let F=!1;const G=({onClose:e})=>{const[t,o]=(0,u.useState)(""),[n,i]=(0,u.useState)(!1);(0,u.useEffect)((()=>{(async()=>{const e=await $();e&&o(e)})()}),[]);const{onClickInContainer:r,onDiscardHomePage:a,onKeepHomePage:s}=U({onClose:e,setShowDiscardModal:i});return(0,u.useEffect)((()=>{const e=document.querySelector(".edit-site-save-button__button");return e&&e.addEventListener("click",s),()=>{const e=document.querySelector(".edit-site-save-button__button");e&&e.removeEventListener("click",s)}}),[]),(0,g.jsxs)(g.Fragment,{children:[(0,u.createPortal)((0,g.jsx)("div",{className:"kubio-front-page-revert-popup__container",dangerouslySetInnerHTML:{__html:t},onClick:r}),document.body),n&&(0,g.jsx)(H,{onClose:()=>i(!1),onSuccess:a})]})},H=({onClose:e,onSuccess:t})=>{let o;return o=L?(0,m.__)("Your previous home page was showing the most recent blog posts. Are you sure you want to restore your previous home page?","kubio"):(0,m.__)("Are you sure you want to restore your previous home page?","kubio"),(0,g.jsxs)(h.Modal,{title:(0,m.__)("Confirm home page restore","kubio"),onRequestClose:e,shouldCloseOnEsc:!1,shouldCloseOnClickOutside:!1,className:"kubio-front-page-revert-notice__modal",children:[(0,g.jsx)("p",{children:o}),(0,g.jsx)("div",{children:(0,g.jsxs)(h.ButtonGroup,{className:"kubio-front-page-revert-notice__modal__footer",children:[(0,g.jsx)(h.Button,{isLink:!0,onClick:e,children:(0,m.__)("Cancel","kubio")}),(0,g.jsx)(h.Button,{isDestructive:!0,isPrimary:!0,onClick:()=>{t(),e()},children:(0,m.__)("Restore home page","kubio")})]})})]})},U=({onClose:e,setShowDiscardModal:t})=>{const{onDiscardEntities:o}=W(),n=async()=>{F||(F=!0,e(),wp.ajax.send("kubio_front_page_revert_action",{data:{_wpnonce:z}}))};return{onClickInContainer:e=>{const o=e.target,i=o.closest(".kubio-front-page-revert-notice__footer__keep, .kubio-front-page-revert-notice__header__close"),r=o.closest(".kubio-front-page-revert-notice__footer__restore");i&&n(),r&&t(!0)},onDiscardHomePage:async()=>{F||(document.body.classList.remove("kubio-iframe-holder--show"),document.body.classList.add("kubio-iframe-holder--hide"),F=!0,e(),wp.ajax.send("kubio_restore_front_page",{data:{_wpnonce:z}}).done((e=>{(async()=>{await o();const e=(0,T.getBackendData)("kubioEditorURL");window.location.href=e})()})).fail((e=>{})))},onKeepHomePage:n}},W=()=>{const{entitiesToSave:e}=(0,l.useSelect)((e=>{const{__experimentalGetDirtyEntityRecords:t}=e("core");return{entitiesToSave:t()}})),t=(0,s.useUnloadStoreEntities)();return{entitiesToSave:e,onDiscardEntities:async()=>{const o=(null==e?void 0:e.length)>0;t(),o&&await(0,T.sleep)(1e3)}}};let V=!1,K=null;const $=async()=>{if(K)return K;if(!V){V=!0;try{const e=await O()({path:"/kubio/v1/get-kubio-front-page-revert-notice-editor-html",method:"GET"});return K=e,e}catch(e){console.error(e)}finally{V=!1}}},q=window.wp.editor;function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)({}).hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},Y.apply(null,arguments)}var Z=o(3967),X=o.n(Z),J=o(9196);const Q=window.wp.primitives,ee=(0,J.createElement)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,J.createElement)(Q.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),te=(0,J.createElement)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,J.createElement)(Q.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})),oe=(0,J.createElement)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,J.createElement)(Q.Path,{fillRule:"evenodd",d:"M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",clipRule:"evenodd"})),ne=window.wp.viewport,ie=(0,J.createElement)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,J.createElement)(Q.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})),re=window.wp.deprecated;var ae=o.n(re);const se=window.wp.preferences,le=(e,t)=>({type:"SET_DEFAULT_COMPLEMENTARY_AREA",scope:e,area:t}),ce=(e,t)=>o=>{let{registry:n,dispatch:i}=o;t&&(n.select(se.store).get(e,"isComplementaryAreaVisible")||n.dispatch(se.store).set(e,"isComplementaryAreaVisible",!0),i({type:"ENABLE_COMPLEMENTARY_AREA",scope:e,area:t}))},ue=e=>t=>{let{registry:o}=t;o.select(se.store).get(e,"isComplementaryAreaVisible")&&o.dispatch(se.store).set(e,"isComplementaryAreaVisible",!1)},de=(e,t)=>o=>{let{registry:n}=o;if(!t)return;const i=n.select(se.store).get(e,"pinnedItems");!0!==(null==i?void 0:i[t])&&n.dispatch(se.store).set(e,"pinnedItems",{...i,[t]:!0})},pe=(e,t)=>o=>{let{registry:n}=o;if(!t)return;const i=n.select(se.store).get(e,"pinnedItems");n.dispatch(se.store).set(e,"pinnedItems",{...i,[t]:!1})};function he(e,t){return function(o){let{registry:n}=o;ae()("dispatch( 'core/interface' ).toggleFeature",{since:"6.0",alternative:"dispatch( 'core/preferences' ).toggle"}),n.dispatch(se.store).toggle(e,t)}}function me(e,t,o){return function(n){let{registry:i}=n;ae()("dispatch( 'core/interface' ).setFeatureValue",{since:"6.0",alternative:"dispatch( 'core/preferences' ).set"}),i.dispatch(se.store).set(e,t,!!o)}}function ge(e,t){return function(o){let{registry:n}=o;ae()("dispatch( 'core/interface' ).setFeatureDefaults",{since:"6.0",alternative:"dispatch( 'core/preferences' ).setDefaults"}),n.dispatch(se.store).setDefaults(e,t)}}const fe=(0,l.createRegistrySelector)((e=>(t,o)=>{var n;const i=e(se.store).get(o,"isComplementaryAreaVisible");if(void 0!==i)return i?null==t||null===(n=t.complementaryAreas)||void 0===n?void 0:n[o]:null})),be=(0,l.createRegistrySelector)((e=>(t,o,n)=>{var i;const r=e(se.store).get(o,"pinnedItems");return null===(i=null==r?void 0:r[n])||void 0===i||i})),_e=(0,l.createRegistrySelector)((e=>(t,o,n)=>(ae()("select( 'core/interface' ).isFeatureActive( scope, featureName )",{since:"6.0",alternative:"select( 'core/preferences' ).get( scope, featureName )"}),!!e(se.store).get(o,n)))),ve=(0,l.combineReducers)({complementaryAreas:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_DEFAULT_COMPLEMENTARY_AREA":{const{scope:o,area:n}=t;return e[o]?e:{...e,[o]:n}}case"ENABLE_COMPLEMENTARY_AREA":{const{scope:o,area:n}=t;return{...e,[o]:n}}}return e}}),ye=(0,l.createReduxStore)("core/interface",{reducer:ve,actions:e,selectors:t});(0,l.register)(ye);const ke=window.wp.plugins,xe=(0,ke.withPluginContext)(((e,t)=>({icon:t.icon||e.icon,identifier:t.identifier||`${e.name}/${t.name}`}))),Se=xe((function(e){let{as:t=h.Button,scope:o,identifier:n,icon:i,selectedIcon:r,name:a,...s}=e;const c=t,d=(0,l.useSelect)((e=>e(ye).getActiveComplementaryArea(o)===n),[n]),{enableComplementaryArea:p,disableComplementaryArea:m}=(0,l.useDispatch)(ye);return(0,u.createElement)(c,Y({icon:r&&d?r:i,onClick:()=>{d?m(o):p(o,n)}},s))})),we=e=>{let{smallScreenTitle:t,children:o,className:n,toggleButtonProps:i}=e;const r=(0,u.createElement)(Se,Y({icon:ie},i));return(0,u.createElement)(u.Fragment,null,(0,u.createElement)("div",{className:"components-panel__header interface-complementary-area-header__small"},t&&(0,u.createElement)("span",{className:"interface-complementary-area-header__small-title"},t),r),(0,u.createElement)("div",{className:X()("components-panel__header","interface-complementary-area-header",n),tabIndex:-1},o,r))},Ce=()=>{};function Ie(e){let{name:t,as:o=h.Button,onClick:n,...i}=e;return(0,u.createElement)(h.Fill,{name:t},(e=>{let{onClick:t}=e;return(0,u.createElement)(o,Y({onClick:n||t?function(){(n||Ce)(...arguments),(t||Ce)(...arguments)}:void 0},i))}))}Ie.Slot=function(e){let{name:t,as:o=h.ButtonGroup,fillProps:n={},bubblesVirtually:i,...r}=e;return(0,u.createElement)(h.Slot,{name:t,bubblesVirtually:i,fillProps:n},(e=>{if(!u.Children.toArray(e).length)return null;const t=[];u.Children.forEach(e,(e=>{let{props:{__unstableExplicitMenuItem:o,__unstableTarget:n}}=e;n&&o&&t.push(n)}));const n=u.Children.map(e,(e=>!e.props.__unstableExplicitMenuItem&&t.includes(e.props.__unstableTarget)?null:e));return(0,u.createElement)(o,r,n)}))};const je=Ie,Te=e=>{let{__unstableExplicitMenuItem:t,__unstableTarget:o,...n}=e;return(0,u.createElement)(h.MenuItem,n)};function Pe(e){let{scope:t,target:o,__unstableExplicitMenuItem:n,...i}=e;return(0,u.createElement)(Se,Y({as:e=>(0,u.createElement)(je,Y({__unstableExplicitMenuItem:n,__unstableTarget:`${t}/${o}`,as:Te,name:`${t}/plugin-more-menu`},e)),role:"menuitemcheckbox",selectedIcon:ee,name:o,scope:t},i))}function Ee(e){let{scope:t,...o}=e;return(0,u.createElement)(h.Fill,Y({name:`PinnedItems/${t}`},o))}Ee.Slot=function(e){let{scope:t,className:o,...n}=e;return(0,u.createElement)(h.Slot,Y({name:`PinnedItems/${t}`},n),(e=>(null==e?void 0:e.length)>0&&(0,u.createElement)("div",{className:X()(o,"interface-pinned-items")},e)))};const Re=Ee;function Ae(e){let{scope:t,children:o,className:n}=e;return(0,u.createElement)(h.Fill,{name:`ComplementaryArea/${t}`},(0,u.createElement)("div",{className:n},o))}const Oe=xe((function(e){let{children:t,className:o,closeLabel:n=(0,m.__)("Close plugin"),identifier:i,header:r,headerClassName:a,icon:s,isPinnable:c=!0,panelClassName:d,scope:p,name:g,smallScreenTitle:f,title:b,toggleShortcut:_,isActiveByDefault:v,showIconLabels:y=!1}=e;const{isActive:k,isPinned:x,activeArea:S,isSmall:w,isLarge:C}=(0,l.useSelect)((e=>{const{getActiveComplementaryArea:t,isItemPinned:o}=e(ye),n=t(p);return{isActive:n===i,isPinned:o(p,i),activeArea:n,isSmall:e(ne.store).isViewportMatch("< medium"),isLarge:e(ne.store).isViewportMatch("large")}}),[i,p]);!function(e,t,o,n,i){const r=(0,u.useRef)(!1),a=(0,u.useRef)(!1),{enableComplementaryArea:s,disableComplementaryArea:c}=(0,l.useDispatch)(ye);(0,u.useEffect)((()=>{n&&i&&!r.current?(c(e),a.current=!0):a.current&&!i&&r.current?(a.current=!1,s(e,t)):a.current&&o&&o!==t&&(a.current=!1),i!==r.current&&(r.current=i)}),[n,i,e,t,o])}(p,i,S,k,w);const{enableComplementaryArea:I,disableComplementaryArea:j,pinItem:T,unpinItem:P}=(0,l.useDispatch)(ye);return(0,u.useEffect)((()=>{v&&void 0===S&&!w&&I(p,i)}),[S,v,p,i,w]),(0,u.createElement)(u.Fragment,null,c&&(0,u.createElement)(Re,{scope:p},x&&(0,u.createElement)(Se,{scope:p,identifier:i,isPressed:k&&(!y||C),"aria-expanded":k,label:b,icon:y?ee:s,showTooltip:!y,variant:y?"tertiary":void 0})),g&&c&&(0,u.createElement)(Pe,{target:g,scope:p,icon:s},b),k&&(0,u.createElement)(Ae,{className:X()("interface-complementary-area",o),scope:p},(0,u.createElement)(we,{className:a,closeLabel:n,onClose:()=>j(p),smallScreenTitle:f,toggleButtonProps:{label:n,shortcut:_,scope:p,identifier:i}},r||(0,u.createElement)(u.Fragment,null,(0,u.createElement)("strong",null,b),c&&(0,u.createElement)(h.Button,{className:"interface-complementary-area__pin-unpin-item",icon:x?te:oe,label:x?(0,m.__)("Unpin from toolbar"):(0,m.__)("Pin to toolbar"),onClick:()=>(x?P:T)(p,i),isPressed:x,"aria-expanded":x}))),(0,u.createElement)(h.Panel,{className:d},t)))}));Oe.Slot=function(e){let{scope:t,...o}=e;return(0,u.createElement)(h.Slot,Y({name:`ComplementaryArea/${t}`},o))};const Ne=Oe,Be=e=>{let{isActive:t}=e;return(0,u.useEffect)((()=>{let e=!1;return document.body.classList.contains("sticky-menu")&&(e=!0,document.body.classList.remove("sticky-menu")),()=>{e&&document.body.classList.add("sticky-menu")}}),[]),(0,u.useEffect)((()=>(t?document.body.classList.add("is-fullscreen-mode"):document.body.classList.remove("is-fullscreen-mode"),()=>{t&&document.body.classList.remove("is-fullscreen-mode")})),[t]),null},De=(0,u.forwardRef)((function(e,t){let{footer:o,header:n,sidebar:i,secondarySidebar:r,notices:a,content:s,drawer:l,actions:c,labels:d,className:g,shortcuts:f}=e;const b=(0,h.__unstableUseNavigateRegions)(f);!function(e){(0,u.useEffect)((()=>{const t=document&&document.querySelector(`html:not(.${e})`);if(t)return t.classList.toggle(e),()=>{t.classList.toggle(e)}}),[e])}("interface-interface-skeleton__html-container");const _={/* translators: accessibility text for the nav bar landmark region. */drawer:(0,m.__)("Drawer"),/* translators: accessibility text for the top bar landmark region. */header:(0,m.__)("Header"),/* translators: accessibility text for the content landmark region. */body:(0,m.__)("Content"),/* translators: accessibility text for the secondary sidebar landmark region. */secondarySidebar:(0,m.__)("Block Library"),/* translators: accessibility text for the settings landmark region. */sidebar:(0,m.__)("Settings"),/* translators: accessibility text for the publish landmark region. */actions:(0,m.__)("Publish"),/* translators: accessibility text for the footer landmark region. */footer:(0,m.__)("Footer"),...d};return(0,u.createElement)("div",Y({},b,{ref:(0,p.useMergeRefs)([t,b.ref]),className:X()(g,"interface-interface-skeleton",b.className,!!o&&"has-footer")}),!!l&&(0,u.createElement)("div",{className:"interface-interface-skeleton__drawer",role:"region","aria-label":_.drawer,tabIndex:"-1"},l),(0,u.createElement)("div",{className:"interface-interface-skeleton__editor"},!!n&&(0,u.createElement)("div",{className:"interface-interface-skeleton__header",role:"region","aria-label":_.header,tabIndex:"-1"},n),(0,u.createElement)("div",{className:"interface-interface-skeleton__body"},!!r&&(0,u.createElement)("div",{className:"interface-interface-skeleton__secondary-sidebar",role:"region","aria-label":_.secondarySidebar,tabIndex:"-1"},r),!!a&&(0,u.createElement)("div",{className:"interface-interface-skeleton__notices"},a),(0,u.createElement)("div",{className:"interface-interface-skeleton__content",role:"region","aria-label":_.body,tabIndex:"-1"},s),!!i&&(0,u.createElement)("div",{className:"interface-interface-skeleton__sidebar",role:"region","aria-label":_.sidebar,tabIndex:"-1"},i),!!c&&(0,u.createElement)("div",{className:"interface-interface-skeleton__actions",role:"region","aria-label":_.actions,tabIndex:"-1"},c))),!!o&&(0,u.createElement)("div",{className:"interface-interface-skeleton__footer",role:"region","aria-label":_.footer,tabIndex:"-1"},o))})),Me=window.wp.keyboardShortcuts,Le=y.STORE_KEY;function ze(){return(0,g.jsx)(g.Fragment,{})}const Fe=window.kubio.inspectors,Ge=window.kubio.pro,He=window.kubio.icons,Ue=(0,u.forwardRef)((function({icon:e,size:t=24,...o},n){return(0,u.cloneElement)(e,{width:t,height:t,...o,ref:n})})),We=window.kubio.blockLibrary,Ve=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"})}),Ke=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),$e=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),qe="kubio-dragging-from-inserter--active",Ye=()=>{setTimeout((()=>{const e=top.document.querySelector("body");e.classList.contains(qe)&&e.classList.remove(qe)}),10)},Ze=()=>{const{setOpenInserter:e}=(0,l.useDispatch)(y.STORE_KEY),{insertionPoint:t,currentSelectedBlock:o}=(0,l.useSelect)((e=>({insertionPoint:e(y.STORE_KEY).getOpenedInserter(),currentSelectedBlock:e("core/block-editor").getSelectedBlockClientId()||null})),[]),n=(0,p.usePrevious)(o),{uiVersion:i}=(0,k.useUIVersion)();(0,u.useEffect)((()=>{2===i&&void 0!==n&&n!==o&&(e(!1),Ye())}),[n,o,i]);const r=(0,x.useBlocksOwnerDocument)(),a=(0,p.useViewportMatch)("medium","<"),c=(0,u.useRef)(),d=(0,u.useCallback)((o=>{!1!==t&&(o.target.closest(".kubio-inserter-button")||o.target.closest(".kubio-sidebar-add-section-button")||o.target.classList.contains("edit-site-header-toolbar__inserter-toggle")||o.target.closest(".edit-site-header-toolbar__inserter-toggle")||o.target.closest(".kubio-inserter-ignore-click-outisde")||e(!1))}),[t,e]);return(0,s.useOnClickOutside)(c,d),(0,g.jsxs)("div",{ref:c,className:"edit-site-editor__inserter-panel",children:[(0,g.jsx)("div",{className:"edit-site-editor__inserter-panel-header",children:(0,g.jsx)(h.Button,{icon:Ve,onClick:()=>e(!1)})}),(0,g.jsx)("div",{className:"edit-site-editor__inserter-panel-content",children:t&&(0,g.jsx)(I.__experimentalLibrary,{shouldFocusBlock:a,shouldSelectBlock:1===i,rootClientId:null==t?void 0:t.rootClientId,__experimentalInsertionIndex:null==t?void 0:t.insertionIndex,ownerDocument:r,insertionPoint:t,isAppender:null==t?void 0:t.isAppender})})]})},Xe=(0,We.getNamesOfBlocks)(),Je=["core/column","core/post-content","core/template-part",Xe.HEADER,Xe.FOOTER,Xe.SIDEBAR,Xe.COLUMN,Xe.LOOP_ITEM,Xe.SLIDER_CONTENT],Qe=({variant:e="secondary",className:t="edit-site-header-toolbar__inserter-toggle"})=>{const{rootClientId:o,isInserterOpen:n}=(0,l.useSelect)((e=>{var t;const{getBlockListSettings:o,getSelectedBlockClientId:n,getBlockRootClientId:i,getBlock:r,getBlockIndex:a}=e("core/block-editor");let s,l=n(),c=o(l);((0,_.isUndefined)(c)||c.templateLock)&&(s=a(l),l=i(l),c=o(l));const u=l&&Je.includes(null===(t=r(l))||void 0===t?void 0:t.name)&&((0,_.isUndefined)(c)||!c.templateLock);return{isInserterOpen:e(y.STORE_KEY).getOpenedInserter(),rootClientId:u?l:null,insertionIndex:s}}),[]),{setOpenInserter:i}=(0,l.useDispatch)(y.STORE_KEY),{selectBlock:r}=(0,l.useDispatch)("core/block-editor"),a=(0,u.useRef)(),{uiVersion:s}=(0,k.useUIVersion)(),c=(0,u.useCallback)((e=>{a.current.focus(),e.preventDefault(),e.stopPropagation()}),[]),d=(0,u.useCallback)((e=>{const t=!n&&"block-inserter";2!==s?(t?r(null):c(e),i(t,o),top.document.body.classList.remove("kubio-dragging-from-inserter--active")):t?(i("pattern-inserter/content",null),Ye()):(c(e),i(!1,null))}),[n,o]);return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(h.Button,{ref:a,variant:e,isPressed:n,className:t,onClick:d,icon:n?Ke:$e,onMouseDown:e=>{e.preventDefault()},label:(p=n,p?(0,m.__)("Close","kubio"):(0,m.__)("Add block","kubio"))})});var p},et=[];function tt({title:e,label:t,children:o,areaIdentifier:n,className:i,backCallback:r,parentAreaIdentifier:a,onOpen:s,buttonOnly:c=!1,showArrow:d=!0,proOnly:p=!1,urlArgs:f}){const{clearSelectedBlock:b}=(0,l.useDispatch)("core/block-editor"),{openSidebar:v}=(0,l.useDispatch)(y.STORE_KEY),k=()=>{b().then((()=>v(a||"document")))},x=r?()=>r(k):k,S=(0,l.useSelect)((e=>e(y.STORE_KEY).getSubSidebars[n])),{addSubSidebar:w}=(0,l.useDispatch)(y.STORE_KEY);(0,u.useLayoutEffect)((()=>{S||(w({areaIdentifier:n,sidebar:(0,g.jsx)(h.Animate,{type:"slide-in",children:({className:t})=>(0,g.jsxs)(st,{title:e,backCallback:x,areaIdentifier:n,className:`${t} kubio-subsidebar-content`,children:[o,it(n)]})})}),et.push(n))}),[S]);const C=p?Ge.ProItem:h.Button;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"kubio-subsidebar-container",children:(0,g.jsx)("div",{className:X()("components-panel__header","interface-complementary-area-header","kubio-subsidebar-title",i),tabIndex:-1,children:(0,g.jsxs)(C,{isProItem:p,tag:h.Button,urlArgs:f,label:(0,m.__)("Open","kubio"),onClick:()=>(c||b().then((()=>v(n))),void((0,_.isFunction)(s)&&s())),children:[(0,g.jsx)("strong",{children:t||e}),d&&(0,g.jsx)(Ue,{icon:He.ArrowRight,className:"components-panel__arrow arrow_general_settings"})]})})}),(0,g.jsx)("div",{style:{display:"none"},children:o})]})}const ot=[],nt=({name:e,title:t=null,parent:o="document",render:n,isSubsidebar:i=!1})=>{(0,_.find)(ot,{name:e})&&console.error(`sidebar ${e} already added`),ot.push({name:e,parent:o,render:n,title:t||e,isSubsidebar:i})},it=e=>(e=>ot.filter((({parent:t})=>t===e)))(e).map((({title:t,render:o,name:n,isSubsidebar:i})=>{const r=i?tt:st;return(0,g.jsx)(r,{title:t,parentAreaIdentifier:e,areaIdentifier:n,children:o()},`${e}.${n}`)})),rt=({name:e,title:t,parent:o="document",render:n})=>nt({name:e,title:t,parent:o,render:n,isSubsidebar:!1}),at=({name:e,title:t,parent:o="document",render:n})=>nt({name:e,title:t,parent:o,render:n,isSubsidebar:!0});function st({areaIdentifier:e,title:t,backCallback:o=null,children:n,className:i}){const{uiVersion:r}=(0,k.useUIVersion)(),a="function"==typeof t?t():t;return(0,g.jsxs)(Ne,{scope:`${y.STORE_KEY}/sidebars`,complementaryAreaIdentifier:`${y.STORE_KEY}/sidebar/${e}`,identifier:`${y.STORE_KEY}/sidebar/${e}`,isPinnable:!1,className:X()(i,o?"kubio-sidebar-header-block":""),header:(0,g.jsxs)("div",{className:X()("components-panel__header","kubio-sidebar-header","accordion-section-title",o?"kubio-sidebar-header--has-back":""),tabIndex:-1,children:[o&&(0,g.jsx)(h.Button,{className:"kubio-sidebar-header-back-button",onClick:o,showTooltip:!0,label:(0,m.__)("Back","kubio"),children:(0,g.jsx)(Ue,{icon:He.ArrowLeft,className:"kubio-sidebar-header-arrow"})}),(0,g.jsx)("strong",{title:(0,_.isString)(a)?a:null,children:a}),2===r&&(0,g.jsx)(Qe,{className:"kubio-inserter-button",variant:"primary"})]}),children:[n,it(e)]})}const lt=window.wp.blocks;function ct({children:e}){const{clearSelectedBlock:t}=(0,l.useDispatch)("core/block-editor"),{openSidebar:o}=(0,l.useDispatch)(y.STORE_KEY),{blockType:n,isMultiSelection:i}=(0,l.useSelect)((e=>{const{getSelectedBlockClientId:t,getBlockName:o,hasMultiSelection:n}=e("core/block-editor"),i=t(),r=i&&o(i);return{blockType:i&&(0,lt.getBlockType)(r),isMultiSelection:n()}}));return(0,g.jsxs)(st,{areaIdentifier:"block-inspector",title:()=>(0,g.jsxs)("span",{className:"kubio-header-active-section",children:[(0,g.jsx)(I.BlockIcon,{icon:null==n?void 0:n.icon}),(0,g.jsx)("span",{className:"kubio-header-active-section page-title",title:null==n?void 0:n.title,children:i?(0,m.__)("Multiple selection","kubio"):null==n?void 0:n.title})]}),backCallback:()=>{o("document"),t()},children:[!i&&e,i&&(0,g.jsx)(g.Fragment,{children:(0,g.jsx)("div",{className:"kubio-multiple-selection",children:(0,g.jsx)("p",{children:(0,m.__)("Sidebar controls are not availble on multiple blocks selection","kubio")})})})]})}const ut=window.kubio.controls,dt=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{fillRule:"evenodd",d:"M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",clipRule:"evenodd"})});function pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o<t;o++)n[o]=e[o];return n}function ht(e,t){if(e){if("string"==typeof e)return pt(e,t);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?pt(e,t):void 0}}function mt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var n,i,r,a,s=[],l=!0,c=!1;try{if(r=(o=o.call(e)).next,0===t){if(Object(o)!==o)return;l=!1}else for(;!(l=(n=r.call(o)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=o.return&&(a=o.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||ht(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gt(e){return gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gt(e)}function ft(e){var t=function(e,t){if("object"!=gt(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gt(t)?t:t+""}function bt(e,t,o){return(t=ft(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _t(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?Object(arguments[t]):{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&n.push.apply(n,Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach((function(t){bt(e,t,o[t])}))}return e}function vt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yt(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ft(n.key),n)}}function kt(e,t,o){return t&&yt(e.prototype,t),o&&yt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function xt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function St(e,t){if(t&&("object"==gt(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return xt(e)}function wt(e){return wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},wt(e)}function Ct(e,t){return Ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ct(e,t)}function It(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ct(e,t)}var jt=o(5697),Tt=o.n(jt);const Pt=window.ReactDOM;var Et=o(1143),Rt=o.n(Et);function At(e){return function(e){if(Array.isArray(e))return pt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ht(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Ot=function(){function e(){vt(this,e),bt(this,"refs",{})}return kt(e,[{key:"add",value:function(e,t){this.refs[e]||(this.refs[e]=[]),this.refs[e].push(t)}},{key:"remove",value:function(e,t){var o=this.getIndex(e,t);-1!==o&&this.refs[e].splice(o,1)}},{key:"isActive",value:function(){return this.active}},{key:"getActive",value:function(){var e=this;return this.refs[this.active.collection].find((function(t){return t.node.sortableInfo.index==e.active.index}))}},{key:"getIndex",value:function(e,t){return this.refs[e].indexOf(t)}},{key:"getOrderedRefs",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.active.collection;return this.refs[e].sort(Nt)}}]),e}();function Nt(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}function Bt(e,t){return Object.keys(e).reduce((function(o,n){return-1===t.indexOf(n)&&(o[n]=e[n]),o}),{})}var Dt={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},Mt=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1];return"ms"===t?"ms":t&&t.length?t[0].toUpperCase()+t.substr(1):""}();function Lt(e,t){Object.keys(t).forEach((function(o){e.style[o]=t[o]}))}function zt(e,t){e.style["".concat(Mt,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function Ft(e,t){e.style["".concat(Mt,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function Gt(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function Ht(e,t,o){return Math.max(e,Math.min(o,t))}function Ut(e){return"px"===e.substr(-2)?parseFloat(e):0}function Wt(e,t){var o=t.displayName||t.name;return o?"".concat(e,"(").concat(o,")"):e}function Vt(e,t){var o=e.getBoundingClientRect();return{top:o.top+t.top,left:o.left+t.left}}function Kt(e){return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:e.changedTouches&&e.changedTouches.length?{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}:{x:e.pageX,y:e.pageY}}function $t(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{left:0,top:0};if(e){var n={left:o.left+e.offsetLeft,top:o.top+e.offsetTop};return e.parentNode===t?n:$t(e.parentNode,t,n)}}function qt(e){var t=e.lockOffset,o=e.width,n=e.height,i=t,r=t,a="px";if("string"==typeof t){var s=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);Rt()(null!==s,'lockOffset value should be a number or a string of a number followed by "px" or "%". Given %s',t),i=parseFloat(t),r=parseFloat(t),a=s[1]}return Rt()(isFinite(i)&&isFinite(r),"lockOffset value should be a finite. Given %s",t),"%"===a&&(i=i*o/100,r=r*n/100),{x:i,y:r}}function Yt(e){return e instanceof HTMLElement?function(e){var t=window.getComputedStyle(e),o=/(auto|scroll)/;return["overflow","overflowX","overflowY"].find((function(e){return o.test(t[e])}))}(e)?e:Yt(e.parentNode):null}var Zt={Anchor:"A",Button:"BUTTON",Canvas:"CANVAS",Input:"INPUT",Option:"OPTION",Textarea:"TEXTAREA",Select:"SELECT"};function Xt(e){return null!=e.sortableHandle}var Jt=function(){function e(t,o){vt(this,e),this.container=t,this.onScrollCallback=o}return kt(e,[{key:"clear",value:function(){null!=this.interval&&(clearInterval(this.interval),this.interval=null)}},{key:"update",value:function(e){var t=this,o=e.translate,n=e.minTranslate,i=e.maxTranslate,r=e.width,a=e.height,s={x:0,y:0},l={x:1,y:1},c=this.container,u=c.scrollTop,d=c.scrollLeft,p=c.scrollHeight,h=c.scrollWidth,m=0===u,g=p-u-c.clientHeight==0,f=0===d,b=h-d-c.clientWidth==0;o.y>=i.y-a/2&&!g?(s.y=1,l.y=10*Math.abs((i.y-a/2-o.y)/a)):o.x>=i.x-r/2&&!b?(s.x=1,l.x=10*Math.abs((i.x-r/2-o.x)/r)):o.y<=n.y+a/2&&!m?(s.y=-1,l.y=10*Math.abs((o.y-a/2-n.y)/a)):o.x<=n.x+r/2&&!f&&(s.x=-1,l.x=10*Math.abs((o.x-r/2-n.x)/r)),this.interval&&(this.clear(),this.isAutoScrolling=!1),0===s.x&&0===s.y||(this.interval=setInterval((function(){t.isAutoScrolling=!0;var e={left:l.x*s.x,top:l.y*s.y};t.container.scrollTop+=e.top,t.container.scrollLeft+=e.left,t.onScrollCallback(e)}),5))}}]),e}(),Qt={axis:Tt().oneOf(["x","y","xy"]),contentWindow:Tt().any,disableAutoscroll:Tt().bool,distance:Tt().number,getContainer:Tt().func,getHelperDimensions:Tt().func,helperClass:Tt().string,helperContainer:Tt().oneOfType([Tt().func,"undefined"==typeof HTMLElement?Tt().any:Tt().instanceOf(HTMLElement)]),hideSortableGhost:Tt().bool,keyboardSortingTransitionDuration:Tt().number,lockAxis:Tt().string,lockOffset:Tt().oneOfType([Tt().number,Tt().string,Tt().arrayOf(Tt().oneOfType([Tt().number,Tt().string]))]),lockToContainerEdges:Tt().bool,onSortEnd:Tt().func,onSortMove:Tt().func,onSortOver:Tt().func,onSortStart:Tt().func,pressDelay:Tt().number,pressThreshold:Tt().number,keyCodes:Tt().shape({lift:Tt().arrayOf(Tt().number),drop:Tt().arrayOf(Tt().number),cancel:Tt().arrayOf(Tt().number),up:Tt().arrayOf(Tt().number),down:Tt().arrayOf(Tt().number)}),shouldCancelStart:Tt().func,transitionDuration:Tt().number,updateBeforeSortStart:Tt().func,useDragHandle:Tt().bool,useWindowAsScrollContainer:Tt().bool},eo={lift:[32],drop:[32],cancel:[27],up:[38,37],down:[40,39]},to={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:function(e){var t=e.node;return{height:t.offsetHeight,width:t.offsetWidth}},hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:eo,shouldCancelStart:function(e){return-1!==[Zt.Input,Zt.Textarea,Zt.Select,Zt.Option,Zt.Button].indexOf(e.target.tagName)||!!Gt(e.target,(function(e){return"true"===e.contentEditable}))},transitionDuration:300,useWindowAsScrollContainer:!1},oo=Object.keys(Qt),no={index:Tt().number.isRequired,collection:Tt().oneOfType([Tt().number,Tt().string]),disabled:Tt().bool},io=Object.keys(no),ro=o(989),ao=o.n(ro);const so=(0,g.jsx)(Q.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})}),lo=function(e){var t,o,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return o=t=function(t){function o(){return vt(this,o),St(this,wt(o).apply(this,arguments))}return It(o,t),kt(o,[{key:"componentDidMount",value:function(){(0,Pt.findDOMNode)(this).sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return Rt()(n.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableHandle() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var t=n.withRef?"wrappedInstance":null;return(0,J.createElement)(e,Y({ref:t},this.props))}}]),o}(J.Component),bt(t,"displayName",Wt("sortableHandle",e)),o}((()=>(0,g.jsx)(h.Tooltip,{text:(0,m.__)("Move","kubio"),children:(0,g.jsx)("div",{className:"d-flex",children:(0,g.jsx)(Ue,{icon:so,className:"draggable-item"})})}))),co=window.kubio.menuData,uo=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M5 5v1.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z"})}),po=(0,u.createContext)(null),ho=({children:e})=>{const t=(0,co.usePrimaryMenuBlockEditor)();return(0,g.jsx)(po.Provider,{value:t,children:e})},mo=(0,g.jsx)(Q.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)(Q.Path,{d:"M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"})}),go=({containerRef:e,afterMenuCreation:t,onClose:o})=>{const[n,i]=(0,u.useState)(""),[r,a]=(0,u.useState)(!1);return(0,g.jsx)(h.Popover,{className:"kubio-options-popover kubio-create-menu-popover",anchorRef:e,position:"middle right",onClose:o,children:(0,g.jsx)(h.Placeholder,{className:"wp-block-navigation-placeholder kubio-menu-placeholder",icon:mo,label:(0,m.__)("Kubio Menu","kubio"),children:(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"kubio-create-menu-popover-description",children:(0,g.jsx)("span",{children:(0,m.__)("There is no header menu created. Please create a new one","kubio")})}),(0,g.jsx)("div",{className:"wp-block-navigation-placeholder__actions",children:(0,g.jsx)(h.Flex,{children:(0,g.jsxs)(h.FlexBlock,{children:[(0,g.jsxs)(h.BaseControl,{className:"kubio-create-menu-popover-input-control",children:[(0,g.jsx)(h.BaseControl.VisualLabel,{children:(0,m.__)("Menu name","kubio")}),(0,g.jsx)(h.__experimentalInputControl,{value:n,onChange:i,placeholder:(0,m.__)("Please set a name","kubio")})]}),(0,g.jsx)(h.Button,{isSecondary:!0,className:"wp-block-navigation-placeholder__button",disabled:0===n.length,isBusy:r,onClick:async()=>{a(!0),await(0,co.createPrimaryMenu)(n),a(!1),t()},children:(0,m.__)("Create new Menu","kubio")})]})})})]})})})},fo=({dataHelper:e,containerRef:t})=>{const[o,n]=(0,u.useState)(!1),[i,r]=(0,u.useState)(!1),{exists:a,items:s,setItems:c,hasResolved:d}=(0,u.useContext)(po),p=(0,l.useSelect)((e=>{var t,o;const{getPage:n,getEntity:i}=e(y.STORE_KEY),r=(null===(t=n())||void 0===t?void 0:t.link)||null,a=(null===(o=i())||void 0===o?void 0:o.path)||null;return(r||a||"").replace(/\/$/,"")}),[]),f=(0,u.useMemo)((()=>Array.isArray(s)?s:[]),[s]),b="#"+(null==e?void 0:e.getAttribute("anchor")),_=(0,u.useMemo)((()=>{if(!a)return[];const e=f.filter((({url:e})=>e===`${p}/${b}`||e===`${p}${b}`));return e.length?e:[]}),[a,f,p,b]);(0,u.useEffect)((()=>{i&&a&&d&&(c([{...(0,co.generateItemInitialData)(),label:null==e?void 0:e.getAttribute("attrs.name"),url:`${p}/${b}`}],!0),r(!1))}),[a,i,c,d,e,p,b]);const v=(0,u.useCallback)((()=>{if(_.length){const e=_.map((({id:e})=>e)),t=f.filter((t=>-1===e.indexOf(t.id)));c([...t],!0)}else{const t=Math.max.apply(null,f.filter((({parent:e})=>0===e)).map((({order:e})=>e)).filter(Boolean))+1;c([...f,{...(0,co.generateItemInitialData)(),label:null==e?void 0:e.getAttribute("attrs.name"),url:`${p}/${b}`,order:t}],!0)}}),[_,f,c,e,p,b]),k=(0,u.useCallback)((()=>{a?v():n(!0)}),[a,v]),x=_.length>0;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Tooltip,{text:x?(0,m.__)("Remove from menu","kubio"):(0,m.__)("Add to menu","kubio"),position:"top left",children:(0,g.jsx)("div",{className:"d-flex",children:(0,g.jsx)(h.Button,{isSmall:!0,onClick:()=>k(),icon:uo,className:X()(["icon-menu",{active:x}])})})}),o&&(0,g.jsx)(go,{containerRef:null==t?void 0:t.current,afterMenuCreation:()=>{r(!0),n(!1)},onClose:()=>n(!1)})]})},bo=({onRemove:e,onSelect:t,dataHelper:o,area:n})=>{const{selectBlock:i,toggleBlockHighlight:r}=(0,l.useDispatch)("core/block-editor"),a=o.getAttribute("anchor"),c=o.getAttribute("attrs.name"),[d,p]=(0,u.useState)(!1),[f,b]=(0,u.useState)(a),[y,k]=(0,u.useState)(c),S=(0,x.useBlocksOwnerDocument)(),w=(0,u.useRef)(!1),C=(0,u.useCallback)((e=>{b(e),w.current=!0}),[]);(0,u.useEffect)((()=>{f!==a&&C(a),y!==c&&k(c)}),[a,c]);const I=(0,u.useRef)(),j=(0,u.useRef)(),P=v().debounce((e=>{e=e||f;let t=ao()(e);t=(0,T.getUniqueSlug)(t,S),t&&(t!==f&&C(t),t!==a&&(o.setAttribute("anchor",t),w.current=!1))}),100),{clientId:E}=(0,s.useHoveredSection)(),R=()=>{f===a&&y===c||P()};(0,u.useEffect)((()=>{!d&&w.current&&R()}),[d]);const A=(0,u.useCallback)((()=>{d&&p(!1)}),[d,p]),O=(e,t=_.noop)=>{const o=null==e?void 0:e.clientId,n=(0,T.getPreviewElementByModelId)(o,S);n&&(0,T.scrollIntoView)(n,{behavior:"smooth",onScrollEnd:t}),r(o,!0)},N=n!==wo.FOOTER||!1;return(0,s.useOnClickOutside)(I,A),(0,g.jsx)("div",{ref:j,className:"page-section-item",children:(0,g.jsxs)("div",{className:(e=>{const t=["kubio-section-list-item"];return e&&t.push("list-item-full-height"),E===o.clientId&&t.push("hovered"),t.join(" ")})(d),children:[(0,g.jsx)("div",{className:"align-items-center drag-icon",children:(0,g.jsx)(lo,{})}),(0,g.jsxs)("div",{className:"input-container",ref:I,children:[(0,g.jsxs)("div",{className:"input-drag-text",children:[(0,g.jsx)("input",{type:"text",value:y,className:"input-name",onChange:e=>{const t=e.target.value;k(t)},onFocus:e=>{O(o),d||p(!0)},onBlur:()=>{y!==c&&(o.setAttribute("attrs.name",y),P(y))}}),(0,g.jsx)("span",{className:"input-drag-text__size",children:y})]}),d&&(0,g.jsxs)("div",{className:"id-div",children:["ID:#",(0,g.jsx)("input",{type:"text",value:f,className:"input-name input-id",onFocus:()=>{O(o)},onChange:e=>{C(e.target.value)},onBlur:R})]})]}),(0,g.jsx)("div",{onClick:()=>{O(o,(()=>{i(null==o?void 0:o.clientId)}))},className:"page-section-item__select-area",role:"button",tabIndex:0}),(0,g.jsxs)("div",{className:"align-items-center",children:[N&&(0,g.jsx)(h.Button,{isSmall:!0,icon:He.DeleteItemIcon,className:"icon-close",onClick:e,showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Remove","kubio")}),(0,g.jsx)(fo,{dataHelper:o,containerRef:j}),(0,g.jsx)(h.Button,{isSmall:!0,icon:dt,className:"icon-settings",onClick:()=>O(o,t),showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Settings","kubio")})]})]})})},_o="kubio/edit-site",vo=({name:e="",area:t})=>{const o=(0,u.useRef)(),{setOpenInserter:n}=(0,l.useDispatch)(_o),i=(0,l.useSelect)((e=>{e(_o).getOpenedInserter()})),r=Co[t],a=async(e=t)=>{const o=`pattern-inserter/${v().get(To,e,To[wo.CONTENT])}`;i!==o&&await n(!1,null),n(o,t)},s=null==r?void 0:r.toLowerCase();return(0,g.jsx)(u.Fragment,{children:(0,g.jsxs)("div",{ref:o,className:["kubio-full-section","kubio-full-section--placeholder"].join(" "),children:[(0,g.jsx)("div",{className:"kubio-subsidebar-container",children:(0,g.jsxs)("div",{className:X()("components-panel__header","interface-complementary-area-header","kubio-subsidebar-title","kubio-subsidebar-title-header"),tabIndex:-1,children:[(0,g.jsx)("div",{className:"kubio-sidebar-title-text",children:r}),(0,g.jsx)("div",{className:"dummy-column"}),(0,g.jsx)("div",{className:"section-list-header-buttons-holder",children:(0,g.jsx)(h.Button,{isSmall:!0,icon:$e,className:"section-icon-container",onClick:function(){a(wo.CONTENT)},showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Add block/section","kubio")})})]})}),(0,g.jsx)(ut.ControlNotice,{content:(0,m.sprintf)(// translators: %1$s , %1$s - template names
// translators: %1$s , %1$s - template names
(0,m.__)("The current page uses the theme %1$s. Use the button below to replace it with a Kubio %2$s","kubio"),s,s)}),(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>a(),className:((e,o=[])=>t===wo.HEADER?["btn-primary","header-button"].concat(o).join(" "):["btn-primary"].concat(o).join(" "))(0,["kubio-button-add-blocks"]),children:(0,g.jsx)("span",{className:X()("kubio-header-section-main-button",{"header-button":e===wo.HEADER}),children:(()=>{switch(t){case wo.HEADER:return(0,m.__)("Choose header design","kubio");case wo.FOOTER:return(0,m.__)("Choose footer design","kubio");case wo.SIDEBAR:return(0,m.__)("Add section","kubio");default:return(0,m.__)("Add predesigned section","kubio")}})()})})]})})};function yo(e){const{templateParts:t,selectBlock:o,removeBlocks:n,reorderBlocks:i}=e,{blockTypes:r,getBlocks:a,isPage:s}=(0,l.useSelect)((e=>{const{getPage:t}=e(y.STORE_KEY),o=(0,l.select)("core").getEditedEntityRecord("root","site");let n;t&&(n=t());const i=v().get(n,"context",{}),{postType:r,postId:a}=i,s="page"===(null==o?void 0:o.show_on_front)&&parseInt(null==o?void 0:o.page_for_posts)===parseInt(a);return{isPage:"page"===r&&!s,blockTypes:e("core/blocks").getBlockTypes(),getBlocks:e("core/block-editor").getBlocks}})),[c]=(0,x.useGlobalSessionProp)("currentPageHasBlocksContent",!0,[]),d=(0,u.useMemo)((()=>{const e={selectBlock:o,removeBlocks:n,reorderBlocks:i,innerBlocks:a(),templatePart:{},blockTypes:r,label:(0,m.__)("Content","kubio")};return c&&(0,g.jsx)(Oo,{...e})}),[t,c]);return(0,g.jsxs)(g.Fragment,{children:[s&&(0,g.jsx)(vo,{area:"header"}),d,s&&(0,g.jsx)(vo,{area:"footer"})]})}function ko(e){const{templateParts:t,selectBlock:o,removeBlocks:n,reorderBlocks:i}=e,{blockTypes:r}=(0,l.useSelect)((e=>({blockTypes:e("core/blocks").getBlockTypes(),getBlocks:e("core/block-editor").getBlocks})));return(0,g.jsx)(g.Fragment,{children:t.map(((e,t)=>{const{name:a,clientId:s}=e,l={selectBlock:o,removeBlocks:n,reorderBlocks:i,name:a,templatePart:e,templatePartClientId:s,blockTypes:r};return(0,g.jsx)(Oo,{...l},"template-sections-"+t)}))})}function xo({templateParts:e,...t}){const o=(0,l.useSelect)((e=>{const{currentPageHasFSETemplate:t}=e(y.STORE_KEY);return t()}),[]),n=(0,l.useSelect)((e=>e("core").getEntityRecords("postType","wp_template_part",{per_page:-1})||[]),[]),i=(0,s.useDeepMemo)((()=>e.map((e=>{const t=n.find((t=>{var o;return(null==t?void 0:t.slug)===(null==e||null===(o=e.attributes)||void 0===o?void 0:o.slug)})),o=null==t?void 0:t.area;return{...e,area:o}}))),[e,n]),r=(0,s.useDeepMemo)((()=>v().orderBy(i,(e=>v().findIndex(Io,(t=>t===v().get(e,"area",wo.CONTENT)))))),[i]);let a=null;return a=o?ko:yo,(0,g.jsx)(a,{...t,templateParts:r})}const So=({onRemove:e,onSelect:t,item:o,dataHelper:n})=>{const{blockTypes:i}=(0,l.useSelect)((e=>({blockTypes:e("core/blocks").getBlockTypes()}))),{selectBlock:r}=(0,l.useDispatch)("core/block-editor"),{clientId:a}=(0,s.useHoveredSection)(),c=X()("kubio-section-list-item",{hovered:a===o.clientId}),d=(0,u.useRef)();return(0,u.useEffect)((()=>{a===o.clientId&&d.current.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),[a]),(0,g.jsx)("div",{ref:d,className:"page-section-item",children:(0,g.jsxs)("div",{className:c,children:[(0,g.jsx)("div",{className:"align-items-center",children:(0,g.jsx)(lo,{})}),(0,g.jsx)("div",{className:"input-container",children:(0,g.jsx)("span",{className:"input-name",children:(0,g.jsx)("span",{className:"input-name-text",children:(e=>{const t=(0,_.find)(i,{name:e});return(null==t?void 0:t.title)||e})(o.name)})})}),(0,g.jsx)("div",{onClick:()=>{r(null==n?void 0:n.clientId)},className:"page-section-item__select-area",role:"button",tabIndex:"0"}),(0,g.jsxs)("div",{className:"align-items-center",children:[(0,g.jsx)(h.Button,{isSmall:!0,icon:He.DeleteItemIcon,className:"icon-close",onClick:e,showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Remove","kubio")}),(0,g.jsx)(h.Button,{isSmall:!0,icon:dt,className:"icon-settings",onClick:t,showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Settings","kubio")})]})]})})},wo={HEADER:"header",FOOTER:"footer",SIDEBAR:"sidebar",CONTENT:"content"},Co={[wo.HEADER]:(0,m.__)("Header","kubio"),[wo.FOOTER]:(0,m.__)("Footer","kubio"),[wo.SIDEBAR]:(0,m.__)("Sidebar","kubio"),[wo.CONTENT]:(0,m.__)("Content","kubio")},Io=[wo.HEADER,wo.CONTENT,wo.SIDEBAR,wo.FOOTER],jo=["kubio/header","kubio/footer","core/post-content","core/template-part"],To={[wo.HEADER]:"header",[wo.FOOTER]:"footer",[wo.SIDEBAR]:"sidebar",[wo.CONTENT]:"post-content"},Po=function(e){var t,o,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return o=t=function(t){function o(){return vt(this,o),St(this,wt(o).apply(this,arguments))}return It(o,t),kt(o,[{key:"componentDidMount",value:function(){this.register()}},{key:"componentDidUpdate",value:function(e){this.node&&(e.index!==this.props.index&&(this.node.sortableInfo.index=this.props.index),e.disabled!==this.props.disabled&&(this.node.sortableInfo.disabled=this.props.disabled)),e.collection!==this.props.collection&&(this.unregister(e.collection),this.register())}},{key:"componentWillUnmount",value:function(){this.unregister()}},{key:"register",value:function(){var e=this.props,t=e.collection,o=e.disabled,n=e.index,i=(0,Pt.findDOMNode)(this);i.sortableInfo={collection:t,disabled:o,index:n,manager:this.context.manager},this.node=i,this.ref={node:i},this.context.manager.add(t,this.ref)}},{key:"unregister",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.collection;this.context.manager.remove(e,this.ref)}},{key:"getWrappedInstance",value:function(){return Rt()(n.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var t=n.withRef?"wrappedInstance":null;return(0,J.createElement)(e,Y({ref:t},Bt(this.props,io)))}}]),o}(J.Component),bt(t,"displayName",Wt("sortableElement",e)),bt(t,"contextTypes",{manager:Tt().object.isRequired}),bt(t,"propTypes",no),bt(t,"defaultProps",{collection:0}),o}((({item:e,onRemove:t=_.noop,onSelect:o=_.noop,dataHelper:n,area:i})=>(0,T.isGutentagPrefixed)(e.name)?(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(bo,{onRemove:()=>t(e),onSelect:()=>o(e),item:e,dataHelper:n,area:i})}):(0,g.jsx)(So,{onRemove:()=>t(e),onSelect:()=>o(e),item:e,dataHelper:n}))),Eo=e=>{var t;const o=(0,u.useMemo)((()=>Ro()),[]);return(0,g.jsx)(o,{clientId:null===(t=e.item)||void 0===t?void 0:t.clientId,...e})},Ro=()=>(0,s.WithKubioDataHelperProp)(Po),Ao=function(e){var t,o,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return o=t=function(t){function o(e){var t;return vt(this,o),bt(xt(xt(t=St(this,wt(o).call(this,e)))),"state",{}),bt(xt(xt(t)),"handleStart",(function(e){var o=t.props,n=o.distance,i=o.shouldCancelStart;if(2!==e.button&&!i(e)){t.touched=!0,t.position=Kt(e);var r=Gt(e.target,(function(e){return null!=e.sortableInfo}));if(r&&r.sortableInfo&&t.nodeIsChild(r)&&!t.state.sorting){var a=t.props.useDragHandle,s=r.sortableInfo,l=s.index,c=s.collection;if(s.disabled)return;if(a&&!Gt(e.target,Xt))return;t.manager.active={collection:c,index:l},function(e){return e.touches&&e.touches.length||e.changedTouches&&e.changedTouches.length}(e)||e.target.tagName!==Zt.Anchor||e.preventDefault(),n||(0===t.props.pressDelay?t.handlePress(e):t.pressTimer=setTimeout((function(){return t.handlePress(e)}),t.props.pressDelay))}}})),bt(xt(xt(t)),"nodeIsChild",(function(e){return e.sortableInfo.manager===t.manager})),bt(xt(xt(t)),"handleMove",(function(e){var o=t.props,n=o.distance,i=o.pressThreshold;if(!t.state.sorting&&t.touched&&!t._awaitingUpdateBeforeSortStart){var r=Kt(e),a={x:t.position.x-r.x,y:t.position.y-r.y},s=Math.abs(a.x)+Math.abs(a.y);t.delta=a,n||i&&!(s>=i)?n&&s>=n&&t.manager.isActive()&&t.handlePress(e):(clearTimeout(t.cancelTimer),t.cancelTimer=setTimeout(t.cancel,0))}})),bt(xt(xt(t)),"handleEnd",(function(){t.touched=!1,t.cancel()})),bt(xt(xt(t)),"cancel",(function(){var e=t.props.distance;t.state.sorting||(e||clearTimeout(t.pressTimer),t.manager.active=null)})),bt(xt(xt(t)),"handlePress",(function(e){try{var o=t.manager.getActive(),n=function(){if(o){var n=function(){var o,n,i,c,g,f,b=p.sortableInfo.index,_=(o=p,{bottom:Ut((n=window.getComputedStyle(o)).marginBottom),left:Ut(n.marginLeft),right:Ut(n.marginRight),top:Ut(n.marginTop)}),v=function(e){var t=window.getComputedStyle(e);return"grid"===t.display?{x:Ut(t.gridColumnGap),y:Ut(t.gridRowGap)}:{x:0,y:0}}(t.container),y=t.scrollContainer.getBoundingClientRect(),k=a({index:b,node:p,collection:h});if(t.node=p,t.margin=_,t.gridGap=v,t.width=k.width,t.height=k.height,t.marginOffset={x:t.margin.left+t.margin.right+t.gridGap.x,y:Math.max(t.margin.top,t.margin.bottom,t.gridGap.y)},t.boundingClientRect=p.getBoundingClientRect(),t.containerBoundingRect=y,t.index=b,t.newIndex=b,t.axis={x:r.indexOf("x")>=0,y:r.indexOf("y")>=0},t.offsetEdge=$t(p,t.container),t.initialOffset=Kt(m?_t({},e,{pageX:t.boundingClientRect.left,pageY:t.boundingClientRect.top}):e),t.initialScroll={left:t.scrollContainer.scrollLeft,top:t.scrollContainer.scrollTop},t.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},t.helper=t.helperContainer.appendChild((c="input, textarea, select, canvas, [contenteditable]",g=(i=p).querySelectorAll(c),At((f=i.cloneNode(!0)).querySelectorAll(c)).forEach((function(e,t){"file"!==e.type&&(e.value=g[t].value),"radio"===e.type&&e.name&&(e.name="__sortableClone__".concat(e.name)),e.tagName===Zt.Canvas&&g[t].width>0&&g[t].height>0&&e.getContext("2d").drawImage(g[t],0,0)})),f)),Lt(t.helper,{boxSizing:"border-box",height:"".concat(t.height,"px"),left:"".concat(t.boundingClientRect.left-_.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(t.boundingClientRect.top-_.top,"px"),width:"".concat(t.width,"px")}),m&&t.helper.focus(),l&&(t.sortableGhost=p,Lt(p,{opacity:0,visibility:"hidden"})),t.minTranslate={},t.maxTranslate={},m){var x=d?{top:0,left:0,width:t.contentWindow.innerWidth,height:t.contentWindow.innerHeight}:t.containerBoundingRect,S=x.top,w=x.left,C=x.width,I=S+x.height,j=w+C;t.axis.x&&(t.minTranslate.x=w-t.boundingClientRect.left,t.maxTranslate.x=j-(t.boundingClientRect.left+t.width)),t.axis.y&&(t.minTranslate.y=S-t.boundingClientRect.top,t.maxTranslate.y=I-(t.boundingClientRect.top+t.height))}else t.axis.x&&(t.minTranslate.x=(d?0:y.left)-t.boundingClientRect.left-t.width/2,t.maxTranslate.x=(d?t.contentWindow.innerWidth:y.left+y.width)-t.boundingClientRect.left-t.width/2),t.axis.y&&(t.minTranslate.y=(d?0:y.top)-t.boundingClientRect.top-t.height/2,t.maxTranslate.y=(d?t.contentWindow.innerHeight:y.top+y.height)-t.boundingClientRect.top-t.height/2);s&&s.split(" ").forEach((function(e){return t.helper.classList.add(e)})),t.listenerNode=e.touches?p:t.contentWindow,m?(t.listenerNode.addEventListener("wheel",t.handleKeyEnd,!0),t.listenerNode.addEventListener("mousedown",t.handleKeyEnd,!0),t.listenerNode.addEventListener("keydown",t.handleKeyDown)):(Dt.move.forEach((function(e){return t.listenerNode.addEventListener(e,t.handleSortMove,!1)})),Dt.end.forEach((function(e){return t.listenerNode.addEventListener(e,t.handleSortEnd,!1)}))),t.setState({sorting:!0,sortingIndex:b}),u&&u({node:p,index:b,collection:h,isKeySorting:m,nodes:t.manager.getOrderedRefs(),helper:t.helper},e),m&&t.keyMove(0)},i=t.props,r=i.axis,a=i.getHelperDimensions,s=i.helperClass,l=i.hideSortableGhost,c=i.updateBeforeSortStart,u=i.onSortStart,d=i.useWindowAsScrollContainer,p=o.node,h=o.collection,m=t.manager.isKeySorting,g=function(){if("function"==typeof c){t._awaitingUpdateBeforeSortStart=!0;var o=function(t,o){try{var n=(i=p.sortableInfo.index,Promise.resolve(c({collection:h,index:i,node:p,isKeySorting:m},e)).then((function(){})))}catch(e){return o(!0,e)}var i;return n&&n.then?n.then(o.bind(null,!1),o.bind(null,!0)):o(!1,value)}(0,(function(e,o){if(t._awaitingUpdateBeforeSortStart=!1,e)throw o;return o}));if(o&&o.then)return o.then((function(){}))}}();return g&&g.then?g.then(n):n()}}();return Promise.resolve(n&&n.then?n.then((function(){})):void 0)}catch(e){return Promise.reject(e)}})),bt(xt(xt(t)),"handleSortMove",(function(e){var o=t.props.onSortMove;"function"==typeof e.preventDefault&&e.preventDefault(),t.updateHelperPosition(e),t.animateNodes(),t.autoscroll(),o&&o(e)})),bt(xt(xt(t)),"handleSortEnd",(function(e){var o=t.props,n=o.hideSortableGhost,i=o.onSortEnd,r=t.manager,a=r.active.collection,s=r.isKeySorting,l=t.manager.getOrderedRefs();t.listenerNode&&(s?(t.listenerNode.removeEventListener("wheel",t.handleKeyEnd,!0),t.listenerNode.removeEventListener("mousedown",t.handleKeyEnd,!0),t.listenerNode.removeEventListener("keydown",t.handleKeyDown)):(Dt.move.forEach((function(e){return t.listenerNode.removeEventListener(e,t.handleSortMove)})),Dt.end.forEach((function(e){return t.listenerNode.removeEventListener(e,t.handleSortEnd)})))),t.helper.parentNode.removeChild(t.helper),n&&t.sortableGhost&&Lt(t.sortableGhost,{opacity:"",visibility:""});for(var c=0,u=l.length;c<u;c++){var d=l[c],p=d.node;d.edgeOffset=null,d.boundingClientRect=null,zt(p,null),Ft(p,null),d.translate=null}t.autoScroller.clear(),t.manager.active=null,t.manager.isKeySorting=!1,t.setState({sorting:!1,sortingIndex:null}),"function"==typeof i&&i({collection:a,newIndex:t.newIndex,oldIndex:t.index,isKeySorting:s,nodes:l},e),t.touched=!1})),bt(xt(xt(t)),"autoscroll",(function(){var e=t.props.disableAutoscroll,o=t.manager.isKeySorting;if(e)t.autoScroller.clear();else{if(o){var n=_t({},t.translate),i=0,r=0;return t.axis.x&&(n.x=Math.min(t.maxTranslate.x,Math.max(t.minTranslate.x,t.translate.x)),i=t.translate.x-n.x),t.axis.y&&(n.y=Math.min(t.maxTranslate.y,Math.max(t.minTranslate.y,t.translate.y)),r=t.translate.y-n.y),t.translate=n,zt(t.helper,t.translate),t.scrollContainer.scrollLeft+=i,void(t.scrollContainer.scrollTop+=r)}t.autoScroller.update({height:t.height,maxTranslate:t.maxTranslate,minTranslate:t.minTranslate,translate:t.translate,width:t.width})}})),bt(xt(xt(t)),"onAutoScroll",(function(e){t.translate.x+=e.left,t.translate.y+=e.top,t.animateNodes()})),bt(xt(xt(t)),"handleKeyDown",(function(e){var o=e.keyCode,n=t.props,i=n.shouldCancelStart,r=n.keyCodes,a=_t({},eo,void 0===r?{}:r);t.manager.active&&!t.manager.isKeySorting||!(t.manager.active||a.lift.includes(o)&&!i(e)&&t.isValidSortingTarget(e))||(e.stopPropagation(),e.preventDefault(),a.lift.includes(o)&&!t.manager.active?t.keyLift(e):a.drop.includes(o)&&t.manager.active?t.keyDrop(e):a.cancel.includes(o)?(t.newIndex=t.manager.active.index,t.keyDrop(e)):a.up.includes(o)?t.keyMove(-1):a.down.includes(o)&&t.keyMove(1))})),bt(xt(xt(t)),"keyLift",(function(e){var o=e.target,n=Gt(o,(function(e){return null!=e.sortableInfo})).sortableInfo,i=n.index,r=n.collection;t.initialFocusedNode=o,t.manager.isKeySorting=!0,t.manager.active={index:i,collection:r},t.handlePress(e)})),bt(xt(xt(t)),"keyMove",(function(e){var o=t.manager.getOrderedRefs(),n=o[o.length-1].node.sortableInfo.index,i=t.newIndex+e,r=t.newIndex;if(!(i<0||i>n)){t.prevIndex=r,t.newIndex=i;var a=function(e,t,o){return e<o&&e>t?e-1:e>o&&e<t?e+1:e}(t.newIndex,t.prevIndex,t.index),s=o.find((function(e){return e.node.sortableInfo.index===a})),l=s.node,c=t.containerScrollDelta,u=s.boundingClientRect||Vt(l,c),d=s.translate||{x:0,y:0},p=u.top+d.y-c.top,h=u.left+d.x-c.left,m=r<i,g=m&&t.axis.x?l.offsetWidth-t.width:0,f=m&&t.axis.y?l.offsetHeight-t.height:0;t.handleSortMove({pageX:h+g,pageY:p+f,ignoreTransition:0===e})}})),bt(xt(xt(t)),"keyDrop",(function(e){t.handleSortEnd(e),t.initialFocusedNode&&t.initialFocusedNode.focus()})),bt(xt(xt(t)),"handleKeyEnd",(function(e){t.manager.active&&t.keyDrop(e)})),bt(xt(xt(t)),"isValidSortingTarget",(function(e){var o=t.props.useDragHandle,n=e.target,i=Gt(n,(function(e){return null!=e.sortableInfo}));return i&&i.sortableInfo&&!i.sortableInfo.disabled&&(o?Xt(n):n.sortableInfo)})),function(e){Rt()(!(e.distance&&e.pressDelay),"Attempted to set both `pressDelay` and `distance` on SortableContainer, you may only use one or the other, not both at the same time.")}(e),t.manager=new Ot,t.events={end:t.handleEnd,move:t.handleMove,start:t.handleStart},t}return It(o,t),kt(o,[{key:"getChildContext",value:function(){return{manager:this.manager}}},{key:"componentDidMount",value:function(){var e=this,t=this.props.useWindowAsScrollContainer,o=this.getContainer();Promise.resolve(o).then((function(o){e.container=o,e.document=e.container.ownerDocument||document;var n=e.props.contentWindow||e.document.defaultView||window;e.contentWindow="function"==typeof n?n():n,e.scrollContainer=t?e.document.scrollingElement||e.document.documentElement:Yt(e.container)||e.container,e.autoScroller=new Jt(e.scrollContainer,e.onAutoScroll),Object.keys(e.events).forEach((function(t){return Dt[t].forEach((function(o){return e.container.addEventListener(o,e.events[t],!1)}))})),e.container.addEventListener("keydown",e.handleKeyDown)}))}},{key:"componentWillUnmount",value:function(){var e=this;this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.container&&(Object.keys(this.events).forEach((function(t){return Dt[t].forEach((function(o){return e.container.removeEventListener(o,e.events[t])}))})),this.container.removeEventListener("keydown",this.handleKeyDown))}},{key:"updateHelperPosition",value:function(e){var t=this.props,o=t.lockAxis,n=t.lockOffset,i=t.lockToContainerEdges,r=t.transitionDuration,a=t.keyboardSortingTransitionDuration,s=void 0===a?r:a,l=this.manager.isKeySorting,c=e.ignoreTransition,u=Kt(e),d={x:u.x-this.initialOffset.x,y:u.y-this.initialOffset.y};if(d.y-=window.pageYOffset-this.initialWindowScroll.top,d.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=d,i){var p=function(e){var t=e.height,o=e.width,n=e.lockOffset,i=Array.isArray(n)?n:[n,n];Rt()(2===i.length,"lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given %s",n);var r=mt(i,2),a=r[0],s=r[1];return[qt({height:t,lockOffset:a,width:o}),qt({height:t,lockOffset:s,width:o})]}({height:this.height,lockOffset:n,width:this.width}),h=mt(p,2),m=h[0],g=h[1],f={x:this.width/2-m.x,y:this.height/2-m.y},b={x:this.width/2-g.x,y:this.height/2-g.y};d.x=Ht(this.minTranslate.x+f.x,this.maxTranslate.x-b.x,d.x),d.y=Ht(this.minTranslate.y+f.y,this.maxTranslate.y-b.y,d.y)}"x"===o?d.y=0:"y"===o&&(d.x=0),l&&s&&!c&&Ft(this.helper,s),zt(this.helper,d)}},{key:"animateNodes",value:function(){var e=this.props,t=e.transitionDuration,o=e.hideSortableGhost,n=e.onSortOver,i=this.containerScrollDelta,r=this.windowScrollDelta,a=this.manager.getOrderedRefs(),s=this.offsetEdge.left+this.translate.x+i.left,l=this.offsetEdge.top+this.translate.y+i.top,c=this.manager.isKeySorting,u=this.newIndex;this.newIndex=null;for(var d=0,p=a.length;d<p;d++){var h=a[d].node,m=h.sortableInfo.index,g=h.offsetWidth,f=h.offsetHeight,b={height:this.height>f?f/2:this.height/2,width:this.width>g?g/2:this.width/2},_=c&&m>this.index&&m<=u,v=c&&m<this.index&&m>=u,y={x:0,y:0},k=a[d].edgeOffset;k||(k=$t(h,this.container),a[d].edgeOffset=k,c&&(a[d].boundingClientRect=Vt(h,i)));var x=d<a.length-1&&a[d+1],S=d>0&&a[d-1];x&&!x.edgeOffset&&(x.edgeOffset=$t(x.node,this.container),c&&(x.boundingClientRect=Vt(x.node,i))),m!==this.index?(t&&Ft(h,t),this.axis.x?this.axis.y?v||m<this.index&&(s+r.left-b.width<=k.left&&l+r.top<=k.top+b.height||l+r.top+b.height<=k.top)?(y.x=this.width+this.marginOffset.x,k.left+y.x>this.containerBoundingRect.width-b.width&&x&&(y.x=x.edgeOffset.left-k.left,y.y=x.edgeOffset.top-k.top),null===this.newIndex&&(this.newIndex=m)):(_||m>this.index&&(s+r.left+b.width>=k.left&&l+r.top+b.height>=k.top||l+r.top+b.height>=k.top+f))&&(y.x=-(this.width+this.marginOffset.x),k.left+y.x<this.containerBoundingRect.left+b.width&&S&&(y.x=S.edgeOffset.left-k.left,y.y=S.edgeOffset.top-k.top),this.newIndex=m):_||m>this.index&&s+r.left+b.width>=k.left?(y.x=-(this.width+this.marginOffset.x),this.newIndex=m):(v||m<this.index&&s+r.left<=k.left+b.width)&&(y.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=m)):this.axis.y&&(_||m>this.index&&l+r.top+b.height>=k.top?(y.y=-(this.height+this.marginOffset.y),this.newIndex=m):(v||m<this.index&&l+r.top<=k.top+b.height)&&(y.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=m))),zt(h,y),a[d].translate=y):o&&(this.sortableGhost=h,Lt(h,{opacity:0,visibility:"hidden"}))}null==this.newIndex&&(this.newIndex=this.index),c&&(this.newIndex=u);var w=c?this.prevIndex:u;n&&this.newIndex!==w&&n({collection:this.manager.active.collection,index:this.index,newIndex:this.newIndex,oldIndex:w,isKeySorting:c,nodes:a,helper:this.helper})}},{key:"getWrappedInstance",value:function(){return Rt()(n.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableContainer() call"),this.refs.wrappedInstance}},{key:"getContainer",value:function(){var e=this.props.getContainer;return"function"!=typeof e?(0,Pt.findDOMNode)(this):e(n.withRef?this.getWrappedInstance():void 0)}},{key:"render",value:function(){var t=n.withRef?"wrappedInstance":null;return(0,J.createElement)(e,Y({ref:t},Bt(this.props,oo)))}},{key:"helperContainer",get:function(){var e=this.props.helperContainer;return"function"==typeof e?e():this.props.helperContainer||this.document.body}},{key:"containerScrollDelta",get:function(){return this.props.useWindowAsScrollContainer?{left:0,top:0}:{left:this.scrollContainer.scrollLeft-this.initialScroll.left,top:this.scrollContainer.scrollTop-this.initialScroll.top}}},{key:"windowScrollDelta",get:function(){return{left:this.contentWindow.pageXOffset-this.initialWindowScroll.left,top:this.contentWindow.pageYOffset-this.initialWindowScroll.top}}}]),o}(J.Component),bt(t,"displayName",Wt("sortableList",e)),bt(t,"defaultProps",to),bt(t,"propTypes",Qt),bt(t,"childContextTypes",{manager:Tt().object.isRequired}),o}((({items:e,onRemove:t,onSelect:o,area:n})=>(0,g.jsx)("div",{children:(0,g.jsx)(l.AsyncModeProvider,{value:!0,children:null==e?void 0:e.map(((e,i)=>(0,g.jsx)(Eo,{item:e,onRemove:t,onSelect:o,index:i,area:n},e.clientId)))})}))),Oo=({name:e="",reorderBlocks:t,templatePart:o={},blockTypes:n,removeBlocks:i,selectBlock:r,templatePartClientId:a,label:s})=>{const c=null==o?void 0:o.area,p=To[wo.CONTENT],f=v().get(To,c,p),b=(0,u.useRef)(),x=(0,u.useRef)(),S=(0,u.useRef)(),[w,C]=(0,u.useState)(!1),{setOpenInserter:I}=(0,l.useDispatch)(y.STORE_KEY),j=f,{isUnlocked:T}=(0,ut.useTemplatePartLock)(j),[P,E]=(0,u.useState)(!1),{postType:R,postId:A}=(0,l.useSelect)((e=>{var t,o;return(null===(t=e(y.STORE_KEY))||void 0===t||null===(o=t.getPage())||void 0===o?void 0:o.context)||{}}),[]),O=(0,l.useSelect)((e=>e(y.STORE_KEY).getKubioEditorModeIsSimple()),[]),{uiVersion:N}=(0,k.useUIVersion)(),B=(0,l.useSelect)((e=>e("core/block-editor").getBlocks(a)),[a]);if("core/post-content"===e&&(0,d.applyFilters)("kubio.showRenderedPostContent","page"!==R,R,A))return(0,g.jsx)(g.Fragment,{});const D=e.includes("kubio")&&["header","footer","sidebar"].includes(j),M=["kubio-full-section"];return D&&(T?M.push("kubio-full-section--unlocked"):M.push("kubio-full-section--locked")),(0,g.jsxs)("div",{ref:b,className:M.join(" "),children:[D&&(0,g.jsx)("div",{ref:x,tabIndex:-1,role:"button",className:X()("kubio-full-section-overlay",{"kubio-full-section-overlay--show-popup":w})}),(0,g.jsx)("div",{className:"kubio-subsidebar-container",children:(0,g.jsxs)("div",{className:X()("components-panel__header","interface-complementary-area-header","kubio-subsidebar-title","kubio-subsidebar-title-header"),tabIndex:-1,children:[(0,g.jsx)("div",{className:"kubio-sidebar-title-text",children:s||(()=>{let t=Co[c];return t||(t=(()=>{const t=e,o=(0,_.find)(n,{name:t});return(null==o?void 0:o.title)||t})()),t})()}),(0,g.jsx)("div",{className:"dummy-column"}),(0,g.jsxs)("div",{ref:S,className:"section-list-header-buttons-holder",children:[D&&!T&&(0,g.jsx)(ut.KubioPopup,{position:2===N?"middle right":"top left",className:"kubio-options-popover kubio-template-controls-popover",buttonRef:x,anchorRef:2===N?S:b,selectorToIgnoreOnClickOutside:".h-template-wizard__modal",onOpen:()=>C(!0),onClose:()=>C(!1),children:(0,g.jsx)(ut.TemplateLockModal,{title:(0,m.__)("Choose editing mode","kubio"),children:(0,g.jsx)(ut.TemplateLockControls,{isWizardShown:P,setIsWizardShown:E,templatePart:j})})}),!O&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{isSmall:!0,icon:dt,className:"section-icon-container",onClick:()=>{r(o.clientId)},showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Settings","kubio")}),(0,g.jsx)(h.Button,{isSmall:!0,icon:$e,className:"section-icon-container",onClick:function(){I(`pattern-inserter/${f}-blocks`,o.clientId)},showTooltip:!0,tooltipPosition:"top left",label:(0,m.__)("Add block/section","kubio")})]})]})]})}),(0,g.jsx)(Ao,{helperClass:"kubio-list-item-is-sorting",helperContainer:()=>b.current,onSortEnd:({oldIndex:e,newIndex:o})=>{t(B,e,o)},lockAxis:"y",useDragHandle:!0,items:B,onRemove:e=>{i([e.clientId],!1)},onSelect:e=>{r(e.clientId)},area:c}),f&&(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>(async(e=c)=>{const t=v().get(To,e,p);I(`pattern-inserter/${t}`,o.clientId)})(),className:((e,t=[])=>c===wo.HEADER?["btn-primary","header-button"].concat(t).join(" "):["btn-primary"].concat(t).join(" "))(0,["kubio-button-add-blocks","kubio-sidebar-add-section-button"]),children:(0,g.jsx)("span",{className:"kubio-header-section-main-button",children:(()=>{switch(c){case wo.HEADER:return(0,m.__)("Choose header design","kubio");case wo.FOOTER:return(0,m.__)("Choose footer design","kubio");case wo.SIDEBAR:return(0,m.__)("Add section","kubio");default:return(0,m.__)("Add predesigned section","kubio")}})()})})]})},No=(0,p.compose)((0,l.withSelect)((e=>{const{getSelectedBlockClientId:t,getBlock:o,getBlockParents:n,getClientIdsWithDescendants:i}=e("core/block-editor"),r=i().map(o).filter((({name:e})=>jo.includes(e)));return{selectedBlockClientId:t(),templateParts:r,getBlockParents:n}})),(0,l.withDispatch)(((e,{onSelect:t=_.noop,getBlockParents:o,getBlockAttributes:n})=>{const{removeBlocks:i,moveBlockToPosition:r,updateBlockAttributes:a}=e("core/block-editor");return{selectBlock(o){e("core/block-editor").selectBlock(o),t(o)},removeBlocks:i,reorderBlocks:(e,t,n)=>{const i=o(e[t].clientId).pop();r(e[t].clientId,i,i,n)},updateBlockAttribute:(e,t,o)=>{let i=n(e);i=(0,_.set)(i,t,o),a(e,{...i})}}})))((e=>(0,g.jsx)(ho,{children:(0,g.jsx)("div",{className:"block-editor-block-navigation__container kubio-interface kubio-section-list",children:(0,g.jsx)("div",{className:"block-editor-block-navigation__label",children:(0,g.jsx)(xo,{...e})})})}))),Bo={isDismissable:!0,duration:1e4},Do=()=>{const[e]=(0,S.useIsAIConnected)(),[t,o]=(0,u.useState)(!1),n=(0,u.useRef)(_.noop),i=(0,u.useCallback)((e=>{o(!0),n.current=e}),[]),r=(0,u.useCallback)((t=>{e?null==t||t():i(t)}),[e,i]),{createSuccessNotice:a}=(0,s.useKubioNotices)(),l=(0,u.useCallback)((()=>{o(!1),(0,_.isFunction)(n.current)?n.current():a((0,m.__)("Kubio AI connected successfully!","kubio"),Bo)}),[a]);return[t&&(0,g.jsx)(S.AIWizard,{onFinish:l,onCancel:()=>o(!1),isFrontPage:!1,isSetup:!0}),r,e,i]},Mo=({parentAreaIdentifier:e})=>{const t=`${e}/page-settings`,{isAICapabilityEnabled:o}=(0,l.useSelect)((e=>{const{isAICapabilityEnabled:t=v().noop}=e(y.STORE_KEY)||{};return{isAICapabilityEnabled:t()}}),[]),[n,,,i]=Do();return o?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(tt,{title:(0,g.jsxs)("span",{className:"kubio-sidebar-panel-with-icon__title",children:[(0,g.jsx)(Ue,{icon:He.KubioAI,size:18}),(0,g.jsx)("span",{children:(0,m.__)("AI Settings","kubio")})]}),areaIdentifier:t,onOpen:i,buttonOnly:!0,showArrow:!1,proOnly:T.AI_IN_PRO,urlArgs:{source:"AI",content:"ai-settings"}}),n]}):(0,g.jsx)(g.Fragment,{})},Lo=async()=>await O()({path:"kubio/v1/3rd_party_themes/import_blog"}),zo=window.wp.url,Fo=["home","index","single","search","archive","singular"],Go=()=>{const e=(0,x.useGetGlobalSessionProp)("ready",!1),t=(0,x.useGetGlobalSessionProp)("urlBasedTemplatesMap",{}),o=(0,x.useSetGlobalSessionProp)("urlBasedTemplatesMap",{}),[n,i]=(0,u.useState)(!1),{getEntity:r,page:a,templateType:s,templateId:c,hasQueryBlock:d}=(0,l.useSelect)((e=>{const{getEditedEntityRecord:t}=e("core"),{getClientIdsWithDescendants:o,getBlock:n}=e("core/block-editor"),{getPage:i,getEditedPostType:r,getEditedPostId:a}=e(y.STORE_KEY);return{getEntity:t,page:i(),templateType:r(),templateId:a(),hasQueryBlock:o().map((e=>n(e))).some((e=>"core/query"===e.name))}}),[]);(0,u.useEffect)((()=>{e||i(!1)}),[e]);const p=(0,u.useCallback)((()=>{const e=r("postType",s,c),t=null==e?void 0:e.kubio_template_source;i(!["kubio","kubio-custom"].includes(t)&&d&&(0,T.getBackendData)("allow3rdPartyBlogOverride",!0))}),[r,d,c,s]),h=(0,u.useCallback)((async()=>{if(null==a||!a.path)return;let e=t[null==a?void 0:a.path],n=!0;if(!e&&null!==e){const i=await window.fetch((0,zo.addQueryArgs)(null==a?void 0:a.path,{"__kubio-classic-page-template-slug":1})).then((e=>e.json()));e=i.data||null,o({...t,[null==a?void 0:a.path]:e}),n=i.success}i(n&&Fo.includes(e)&&(0,T.getBackendData)("allow3rdPartyBlogOverride",!0))}),[null==a?void 0:a.path,o,t]),m=(0,u.useCallback)(((e,t)=>{if(e&&t){var o;const t=null==e||null===(o=e.split("//"))||void 0===o?void 0:o.pop();Fo.includes(t)?p():i(!1)}else h()}),[p,h]);return(0,u.useEffect)((()=>{e&&m(c,s)}),[e,m,c,s]),n},Ho=()=>{const[e,t]=(0,u.useState)(!1),[o,n]=(0,x.useGlobalSessionProp)("thirdPartyBlockInstalled",!1),i=Go(),{createSuccessNotice:r,createErrorNotice:a}=(0,l.useDispatch)("core/notices"),s=(0,u.useCallback)((async()=>{t(!0);try{await Lo()}catch(e){return void a((0,m.__)("There was an error while importing the Kubio blog. Please try again","kubio"))}n(!0),r((0,m.__)("Kubio blog templates were imported successfully! Refresh the editor to enjoy the full site editing experience","kubio"),{isDismissible:!0,actions:[{label:(0,m.__)("Refresh page now","kubio"),onClick:()=>window.location.reload()}]}),t(!1)}),[a,r,n]);return!i||i&&o?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)("div",{className:"kubio-sidebar-blog-area-import",children:[(0,g.jsx)("h2",{children:(0,m.__)("💫 Start with the Kubio blog!","kubio")}),(0,g.jsxs)("p",{children:[(0,m.__)("Kubio comes with a fully customizable blog area for your site.","kubio"),(0,g.jsx)("br",{}),(0,m.__)("Would you like to use the Kubio blog templates? ","kubio")]}),(0,g.jsxs)(h.Button,{isPrimary:!0,isBusy:e,onClick:s,children:[!e&&(0,m.__)("Import Kubio blog","kubio"),e&&(0,m.__)("Importing Kubio blog…","kubio")]})]})};function Uo(){const e=(0,x.useCurrentPageBodyClasses)(),{additionalCSS:t,setAdditionalCSS:o}=(0,w.useGlobalAdditionalCSS)(),[n,i]=(0,u.useState)(t);(0,u.useEffect)((()=>{t!==n&&i(t)}),[t]);const r=(0,p.useDebounce)(o,300);return(0,g.jsxs)(h.PanelBody,{initialOpen:!0,title:(0,m.__)("Additional CSS","kubio"),children:[(0,g.jsx)(ut.CodeMirrorControl,{value:n,onChange:e=>{r(e),i(e)},mode:"css"}),e&&!!e.length&&(0,g.jsx)(ut.ControlNotice,{content:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{children:(0,m.__)("Current page has the following classes that can be used as top selectors:","kubio")}),(0,g.jsx)("div",{children:(0,g.jsx)("strong",{children:e.join(", ")})})]})})]})}const Wo=({areaIdentifier:e})=>{const t=(0,l.useSelect)((e=>e(y.STORE_KEY).getEditorOpenedSidebar()),[]),o=null==t?void 0:t.endsWith(e);return(0,g.jsx)(g.Fragment,{children:o&&(0,g.jsx)(Uo,{})})},Vo=({parentAreaIdentifier:e})=>(0,g.jsx)(tt,{title:(0,m.__)("Additional CSS","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/additional-css`,children:(0,g.jsx)(Wo,{areaIdentifier:`${e}/additional-css`})}),Ko=window.kubio.log;var $o=o(9590),qo=o.n($o);function Yo(e){return Yo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yo(e)}var Zo=/^\s+/,Xo=/\s+$/;function Jo(e,t){if(t=t||{},(e=e||"")instanceof Jo)return e;if(!(this instanceof Jo))return new Jo(e,t);var o=function(e){var t={r:0,g:0,b:0},o=1,n=null,i=null,r=null,a=!1,s=!1;return"string"==typeof e&&(e=function(e){e=e.replace(Zo,"").replace(Xo,"").toLowerCase();var t,o=!1;if(fn[e])e=fn[e],o=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(t=En.rgb.exec(e))?{r:t[1],g:t[2],b:t[3]}:(t=En.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=En.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=En.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=En.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=En.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=En.hex8.exec(e))?{r:xn(t[1]),g:xn(t[2]),b:xn(t[3]),a:In(t[4]),format:o?"name":"hex8"}:(t=En.hex6.exec(e))?{r:xn(t[1]),g:xn(t[2]),b:xn(t[3]),format:o?"name":"hex"}:(t=En.hex4.exec(e))?{r:xn(t[1]+""+t[1]),g:xn(t[2]+""+t[2]),b:xn(t[3]+""+t[3]),a:In(t[4]+""+t[4]),format:o?"name":"hex8"}:!!(t=En.hex3.exec(e))&&{r:xn(t[1]+""+t[1]),g:xn(t[2]+""+t[2]),b:xn(t[3]+""+t[3]),format:o?"name":"hex"}}(e)),"object"==Yo(e)&&(Rn(e.r)&&Rn(e.g)&&Rn(e.b)?(t=function(e,t,o){return{r:255*yn(e,255),g:255*yn(t,255),b:255*yn(o,255)}}(e.r,e.g,e.b),a=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Rn(e.h)&&Rn(e.s)&&Rn(e.v)?(n=wn(e.s),i=wn(e.v),t=function(e,t,o){e=6*yn(e,360),t=yn(t,100),o=yn(o,100);var n=Math.floor(e),i=e-n,r=o*(1-t),a=o*(1-i*t),s=o*(1-(1-i)*t),l=n%6;return{r:255*[o,a,r,r,s,o][l],g:255*[s,o,o,a,r,r][l],b:255*[r,r,s,o,o,a][l]}}(e.h,n,i),a=!0,s="hsv"):Rn(e.h)&&Rn(e.s)&&Rn(e.l)&&(n=wn(e.s),r=wn(e.l),t=function(e,t,o){var n,i,r;function a(e,t,o){return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+6*(t-e)*o:o<.5?t:o<2/3?e+(t-e)*(2/3-o)*6:e}if(e=yn(e,360),t=yn(t,100),o=yn(o,100),0===t)n=i=r=o;else{var s=o<.5?o*(1+t):o+t-o*t,l=2*o-s;n=a(l,s,e+1/3),i=a(l,s,e),r=a(l,s,e-1/3)}return{r:255*n,g:255*i,b:255*r}}(e.h,n,r),a=!0,s="hsl"),e.hasOwnProperty("a")&&(o=e.a)),o=vn(o),{ok:a,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:o}}(e);this._originalInput=e,this._r=o.r,this._g=o.g,this._b=o.b,this._a=o.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||o.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=o.ok}function Qo(e,t,o){e=yn(e,255),t=yn(t,255),o=yn(o,255);var n,i,r=Math.max(e,t,o),a=Math.min(e,t,o),s=(r+a)/2;if(r==a)n=i=0;else{var l=r-a;switch(i=s>.5?l/(2-r-a):l/(r+a),r){case e:n=(t-o)/l+(t<o?6:0);break;case t:n=(o-e)/l+2;break;case o:n=(e-t)/l+4}n/=6}return{h:n,s:i,l:s}}function en(e,t,o){e=yn(e,255),t=yn(t,255),o=yn(o,255);var n,i,r=Math.max(e,t,o),a=Math.min(e,t,o),s=r,l=r-a;if(i=0===r?0:l/r,r==a)n=0;else{switch(r){case e:n=(t-o)/l+(t<o?6:0);break;case t:n=(o-e)/l+2;break;case o:n=(e-t)/l+4}n/=6}return{h:n,s:i,v:s}}function tn(e,t,o,n){var i=[Sn(Math.round(e).toString(16)),Sn(Math.round(t).toString(16)),Sn(Math.round(o).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function on(e,t,o,n){return[Sn(Cn(n)),Sn(Math.round(e).toString(16)),Sn(Math.round(t).toString(16)),Sn(Math.round(o).toString(16))].join("")}function nn(e,t){t=0===t?0:t||10;var o=Jo(e).toHsl();return o.s-=t/100,o.s=kn(o.s),Jo(o)}function rn(e,t){t=0===t?0:t||10;var o=Jo(e).toHsl();return o.s+=t/100,o.s=kn(o.s),Jo(o)}function an(e){return Jo(e).desaturate(100)}function sn(e,t){t=0===t?0:t||10;var o=Jo(e).toHsl();return o.l+=t/100,o.l=kn(o.l),Jo(o)}function ln(e,t){t=0===t?0:t||10;var o=Jo(e).toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(-t/100*255))),o.g=Math.max(0,Math.min(255,o.g-Math.round(-t/100*255))),o.b=Math.max(0,Math.min(255,o.b-Math.round(-t/100*255))),Jo(o)}function cn(e,t){t=0===t?0:t||10;var o=Jo(e).toHsl();return o.l-=t/100,o.l=kn(o.l),Jo(o)}function un(e,t){var o=Jo(e).toHsl(),n=(o.h+t)%360;return o.h=n<0?360+n:n,Jo(o)}function dn(e){var t=Jo(e).toHsl();return t.h=(t.h+180)%360,Jo(t)}function pn(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var o=Jo(e).toHsl(),n=[Jo(e)],i=360/t,r=1;r<t;r++)n.push(Jo({h:(o.h+r*i)%360,s:o.s,l:o.l}));return n}function hn(e){var t=Jo(e).toHsl(),o=t.h;return[Jo(e),Jo({h:(o+72)%360,s:t.s,l:t.l}),Jo({h:(o+216)%360,s:t.s,l:t.l})]}function mn(e,t,o){t=t||6,o=o||30;var n=Jo(e).toHsl(),i=360/o,r=[Jo(e)];for(n.h=(n.h-(i*t>>1)+720)%360;--t;)n.h=(n.h+i)%360,r.push(Jo(n));return r}function gn(e,t){t=t||6;for(var o=Jo(e).toHsv(),n=o.h,i=o.s,r=o.v,a=[],s=1/t;t--;)a.push(Jo({h:n,s:i,v:r})),r=(r+s)%1;return a}Jo.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,o,n=this.toRgb();return e=n.r/255,t=n.g/255,o=n.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))},setAlpha:function(e){return this._a=vn(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=en(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=en(this._r,this._g,this._b),t=Math.round(360*e.h),o=Math.round(100*e.s),n=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+o+"%, "+n+"%)":"hsva("+t+", "+o+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var e=Qo(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Qo(this._r,this._g,this._b),t=Math.round(360*e.h),o=Math.round(100*e.s),n=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+o+"%, "+n+"%)":"hsla("+t+", "+o+"%, "+n+"%, "+this._roundA+")"},toHex:function(e){return tn(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,t,o,n,i){var r=[Sn(Math.round(e).toString(16)),Sn(Math.round(t).toString(16)),Sn(Math.round(o).toString(16)),Sn(Cn(n))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)&&r[3].charAt(0)==r[3].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0)+r[3].charAt(0):r.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*yn(this._r,255))+"%",g:Math.round(100*yn(this._g,255))+"%",b:Math.round(100*yn(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*yn(this._r,255))+"%, "+Math.round(100*yn(this._g,255))+"%, "+Math.round(100*yn(this._b,255))+"%)":"rgba("+Math.round(100*yn(this._r,255))+"%, "+Math.round(100*yn(this._g,255))+"%, "+Math.round(100*yn(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(bn[tn(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+on(this._r,this._g,this._b,this._a),o=t,n=this._gradientType?"GradientType = 1, ":"";if(e){var i=Jo(e);o="#"+on(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+t+",endColorstr="+o+")"},toString:function(e){var t=!!e;e=e||this._format;var o=!1,n=this._a<1&&this._a>=0;return t||!n||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(o=this.toRgbString()),"prgb"===e&&(o=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(o=this.toHexString()),"hex3"===e&&(o=this.toHexString(!0)),"hex4"===e&&(o=this.toHex8String(!0)),"hex8"===e&&(o=this.toHex8String()),"name"===e&&(o=this.toName()),"hsl"===e&&(o=this.toHslString()),"hsv"===e&&(o=this.toHsvString()),o||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Jo(this.toString())},_applyModification:function(e,t){var o=e.apply(null,[this].concat([].slice.call(t)));return this._r=o._r,this._g=o._g,this._b=o._b,this.setAlpha(o._a),this},lighten:function(){return this._applyModification(sn,arguments)},brighten:function(){return this._applyModification(ln,arguments)},darken:function(){return this._applyModification(cn,arguments)},desaturate:function(){return this._applyModification(nn,arguments)},saturate:function(){return this._applyModification(rn,arguments)},greyscale:function(){return this._applyModification(an,arguments)},spin:function(){return this._applyModification(un,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(mn,arguments)},complement:function(){return this._applyCombination(dn,arguments)},monochromatic:function(){return this._applyCombination(gn,arguments)},splitcomplement:function(){return this._applyCombination(hn,arguments)},triad:function(){return this._applyCombination(pn,[3])},tetrad:function(){return this._applyCombination(pn,[4])}},Jo.fromRatio=function(e,t){if("object"==Yo(e)){var o={};for(var n in e)e.hasOwnProperty(n)&&(o[n]="a"===n?e[n]:wn(e[n]));e=o}return Jo(e,t)},Jo.equals=function(e,t){return!(!e||!t)&&Jo(e).toRgbString()==Jo(t).toRgbString()},Jo.random=function(){return Jo.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Jo.mix=function(e,t,o){o=0===o?0:o||50;var n=Jo(e).toRgb(),i=Jo(t).toRgb(),r=o/100;return Jo({r:(i.r-n.r)*r+n.r,g:(i.g-n.g)*r+n.g,b:(i.b-n.b)*r+n.b,a:(i.a-n.a)*r+n.a})},Jo.readability=function(e,t){var o=Jo(e),n=Jo(t);return(Math.max(o.getLuminance(),n.getLuminance())+.05)/(Math.min(o.getLuminance(),n.getLuminance())+.05)},Jo.isReadable=function(e,t,o){var n,i,r=Jo.readability(e,t);switch(i=!1,n=function(e){var t,o;return"AA"!==(t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==t&&(t="AA"),"small"!==(o=(e.size||"small").toLowerCase())&&"large"!==o&&(o="small"),{level:t,size:o}}(o),n.level+n.size){case"AAsmall":case"AAAlarge":i=r>=4.5;break;case"AAlarge":i=r>=3;break;case"AAAsmall":i=r>=7}return i},Jo.mostReadable=function(e,t,o){var n,i,r,a,s=null,l=0;i=(o=o||{}).includeFallbackColors,r=o.level,a=o.size;for(var c=0;c<t.length;c++)(n=Jo.readability(e,t[c]))>l&&(l=n,s=Jo(t[c]));return Jo.isReadable(e,s,{level:r,size:a})||!i?s:(o.includeFallbackColors=!1,Jo.mostReadable(e,["#fff","#000"],o))};var fn=Jo.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},bn=Jo.hexNames=function(e){var t={};for(var o in e)e.hasOwnProperty(o)&&(t[e[o]]=o);return t}(fn);function vn(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function yn(e,t){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var o=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat(e))),o&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function kn(e){return Math.min(1,Math.max(0,e))}function xn(e){return parseInt(e,16)}function Sn(e){return 1==e.length?"0"+e:""+e}function wn(e){return e<=1&&(e=100*e+"%"),e}function Cn(e){return Math.round(255*parseFloat(e)).toString(16)}function In(e){return xn(e)/255}var jn,Tn,Pn,En=(Tn="[\\s|\\(]+("+(jn="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+jn+")[,|\\s]+("+jn+")\\s*\\)?",Pn="[\\s|\\(]+("+jn+")[,|\\s]+("+jn+")[,|\\s]+("+jn+")[,|\\s]+("+jn+")\\s*\\)?",{CSS_UNIT:new RegExp(jn),rgb:new RegExp("rgb"+Tn),rgba:new RegExp("rgba"+Pn),hsl:new RegExp("hsl"+Tn),hsla:new RegExp("hsla"+Pn),hsv:new RegExp("hsv"+Tn),hsva:new RegExp("hsva"+Pn),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function Rn(e){return!!En.CSS_UNIT.exec(e)}const An=y.colorPalettes,On=(e,t,o=null)=>{e=Jo(e).toHsl();const n=o||t,i=t;return Jo({...e,l:Math.floor(Math.random()*(n-i+1)+i)}).toHexString()},Nn=()=>{const{getPalette:e,setPalette:t,getCustomPalette:o}=(0,w.useGlobalDataColors)(),n=e(),i=o(),[r,a]=(0,u.useState)(n),c=(0,u.useCallback)(((e,o)=>{const n=Jo(o),i=[n._r,n._g,n._b],s=[...r];s[e]={...s[e],color:i},qo()(r[e].color,s[e].color)||(a(s),t(s))}),[a,t,r]),d=(0,u.useCallback)((e=>{a([...e]),t([...e])}),[a,t]),p=e=>()=>{d(e.colors)},{isKubioTheme:f}=(0,l.useSelect)((e=>{var t;const{getSettings:o}=e(y.STORE_KEY);return{isKubioTheme:(null===(t=o())||void 0===t?void 0:t.isKubioTheme)||null}})),b=e=>t=>{c(e,t)},_=(0,u.useCallback)((()=>{const e={slug:"kubio-color-"+(parseInt(r.length)+1),color:[255,255,255]};r.push(e),t(r,!1)}),[t,r]),k=(0,u.useCallback)((e=>{r.splice(e,1),t(r)}),[t,r]),x=(0,s.useDeepMemo)((()=>{const e=[];return v().isEmpty(i)||e.push({label:(0,m.__)("Previous","kubio"),colors:i}),e.concat(An)}),[i]);return(0,g.jsxs)(h.PanelBody,{title:(0,m.__)("Color Palette","kubio"),className:"kubio-color-palette-panel",children:[(0,g.jsxs)(h.BaseControl,{children:[(0,g.jsxs)(h.Flex,{justify:"center",className:"",children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)(h.BaseControl,{children:(0,m.__)("Current color scheme","kubio")})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)("span",{className:"c-components-units-list",children:(0,g.jsx)("span",{role:"button",tabIndex:0,className:"c-components-units-list__item is-selected add-colors-button",onClick:_,children:(0,m.__)("Add colors","kubio")},"palette-add-color")})})]}),(0,g.jsx)(h.Flex,{gap:0,className:"kubio-current-colors-palette",children:r.map((({color:e,slug:t},o)=>{const n=`rgb(${e.join(",")})`;return(0,g.jsx)(ut.ColorIndicatorPopover,{color:n,onChange:b(o),alpha:!1,showPalette:!1,returnRawValue:!0,disabled:!1,hasButton:o>5,buttonIcon:!1,buttonText:(0,m.__)("Remove color","kubio"),onReset:()=>k(o)},`${t}-${o}`)}))})]}),(0,g.jsx)(Bn,{onChange:a}),!f&&(0,g.jsx)(ut.ControlNotice,{className:"notice-general-settings no-padding",content:(0,m.__)("These settings are applied to Kubio blocks and the blocks within.","kubio")}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(h.BaseControl,{label:(0,m.__)("More Palettes","kubio"),className:"more_palettes_base",children:x.map(((e,t)=>(0,g.jsx)(h.BaseControl,{label:e.label,className:X()("kubio-color-scheme-base-control"),children:(0,g.jsx)(h.Button,{className:"kubio-color-scheme-selector",onClick:p(e),children:(0,g.jsx)("div",{className:"kubio-color-scheme-selector__grid",children:e.colors.map((({slug:e,color:t})=>(0,g.jsx)(ut.ColorIndicator,{value:`rgb(${t.join(",")})`},e)))})},e.label)},t)))})]})},Bn=({onChange:e=v().noop})=>{const{setPalette:t}=(0,w.useGlobalDataColors)(),{isAICapabilityEnabled:o}=(0,l.useSelect)((e=>{const{isAICapabilityEnabled:t}=e(y.STORE_KEY);return{isAICapabilityEnabled:t()}})),[n,i,r]=Do(),[a]=(0,S.useAIData)(),[s,c]=(0,u.useState)(!1),d=(0,u.useCallback)((async()=>{const{siteContext:o={},pageContext:n={},pageTitle:i=""}=a,{siteMood:r="neutral"}=o;try{c(!0);let a=await(0,S.generateColorScheme)({pageContext:n,siteContext:o,pageTitle:i,mood:r});a=(0,w.normalizeColorPalette)([...a,On(a[1],98,100),On(a[0],5,10)]),t(a),e(a)}catch(e){Ko.Log.error("Error determining site colors",e)}finally{c(!1)}}),[a,t]);return(0,g.jsx)(g.Fragment,{children:o&&(0,g.jsxs)(g.Fragment,{children:[n,(0,g.jsx)(h.BaseControl,{className:"kubio-generate-color-scheme-button",children:(0,g.jsx)(Ge.ProItem,{isProItem:T.AI_IN_PRO,tag:h.Button,icon:He.KubioAI,className:X()("kubio-ai-button"),isBusy:s,onClick:r?d:i,urlArgs:{source:"AI",content:"generate-ai-color-scheme"},children:s?(0,m.__)("Generating color scheme…","kubio"):(0,m.__)("Generate color scheme","kubio")})})]})})},Dn=({areaIdentifier:e})=>(0,l.useSelect)((t=>t(y.STORE_KEY).isEditorSidebarOpened(e)),[])&&(0,g.jsx)(Nn,{});function Mn({parentAreaIdentifier:e}){return(0,g.jsx)(tt,{title:(0,m.__)("Color Scheme","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/color-scheme`,children:(0,g.jsx)(Dn,{areaIdentifier:`${e}/color-scheme`})})}function Ln(){const{globalStyle:e,getStyleDefaultGlobalValue:t}=(0,w.useGlobalDataStyle)(),o={styledComponent:"transition"};return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(h.PanelBody,{initialOpen:!0,title:(0,m.__)("Effects","kubio"),children:(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Transition Duration","kubio"),value:e.getStyle("transition.duration",{unit:"s"},{...o}),onChange:t=>((t,n,i)=>e.setStyle("transition.duration",n,{...o}))(0,t),onReset:()=>((n,i)=>{const r={...o},a=t(n,r);a?e.setStyle(n,a,r):e.setStyle(n,null,{...r,unset:!0})})("transition.duration"),min:0,max:5,step:.01})})})}const zn=({areaIdentifier:e})=>{const t=(0,l.useSelect)((t=>t(y.STORE_KEY).isEditorSidebarOpened(e)),[]),o=(0,l.useSelect)((e=>{var t,o;return(null===(t=e("kubio/edit-site"))||void 0===t||null===(o=t.getSettings())||void 0===o?void 0:o.isKubioTheme)||null}));return t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ln,{}),!o&&(0,g.jsx)(ut.ControlNotice,{className:"notice-general-settings",content:(0,m.__)("These settings are applied to Kubio blocks and the blocks within.","kubio")})]})},Fn=({parentAreaIdentifier:e})=>(0,g.jsx)(tt,{title:(0,m.__)("Global Effects","kubio"),label:(0,m.__)("Effects","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/effects`,children:(0,g.jsx)(zn,{areaIdentifier:`${e}/effects`})}),Gn=window.kubio.advancedPanel,Hn=()=>{const[e,t]=(0,u.useState)(""),{globalStyle:o,resetToInitialData:n}=(0,w.useGlobalDataStyle)(),i="form-fields",r={type:s.WithDataPathTypes.STYLE,style:i,dataHelper:o};return(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Form fields","kubio"),children:(0,g.jsxs)(h.BaseControl,{label:(0,m.__)("State","kubio"),children:[(0,g.jsx)(Gn.StatesControl,{activeState:e,setActiveState:t,availableStates:["normal","hover","focus","disabled"]}),(0,g.jsx)(ut.ColorWithPath,{label:(0,m.__)("Text color","kubio"),path:"typography.color",state:e,...r,onReset:n("typography.color",{styledComponent:i,state:e})}),(0,g.jsx)(ut.ColorWithPath,{label:(0,m.__)("Background color","kubio"),state:e,path:"background.color",showReset:!0,...r,onReset:n("background.color",{styledComponent:i,state:e})}),(0,g.jsx)(ut.ColorWithPath,{label:(0,m.__)("Border color","kubio"),path:["border.top.color","border.bottom.color","border.left.color","border.right.color"],state:e,...r,onReset:n(["border.top.color","border.bottom.color","border.left.color","border.right.color"],{styledComponent:i,state:e})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.TypographyControlPopupWithPath,{path:"typography",...r,onReset:n("typography",{styledComponent:i})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.BoxUnitValueControlWithPath,{label:(0,m.__)("Padding","kubio"),path:"padding",...r,onReset:n("padding",{styledComponent:i})}),(0,g.jsx)(ut.BoxUnitValueControlWithPath,{label:(0,m.__)("Margin","kubio"),path:"margin",...r,onReset:n("margin",{styledComponent:i})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.BordersAndRadiusWithPath,{path:"border",...r,withColor:!1,onReset:n("border",{styledComponent:i})})]})})},Un=({styledElement:e="form-submit-button",title:t=(0,m.__)("Form submit button","kubio")})=>{const[o,n]=(0,u.useState)(""),{globalStyle:i,resetToInitialData:r}=(0,w.useGlobalDataStyle)(),a={type:s.WithDataPathTypes.STYLE,style:e,dataHelper:i};return(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:t,children:(0,g.jsxs)(h.BaseControl,{label:(0,m.__)("State","kubio"),children:[(0,g.jsx)(Gn.StatesControl,{activeState:o,setActiveState:n,availableStates:["normal","hover","disabled"]}),(0,g.jsx)(ut.GradientColorPickerWithPath,{label:(0,m.__)("Background","kubio"),path:"background",state:o,...a,onReset:r("background",{styledComponent:e,state:o})}),(0,g.jsx)(ut.ColorWithPath,{label:(0,m.__)("Text color","kubio"),path:"typography.color",state:o,...a,onReset:r("typography.color",{styledComponent:e,state:o})}),(0,g.jsx)(ut.ColorWithPath,{label:(0,m.__)("Border color","kubio"),path:["border.top.color","border.bottom.color","border.left.color","border.right.color"],state:o,...a,onReset:r(["border.top.color","border.bottom.color","border.left.color","border.right.color"],{styledComponent:e,state:o})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.TypographyControlPopupWithPath,{path:"typography",...a,onReset:r("typography",{styledComponent:e})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.BoxUnitValueControlWithPath,{label:(0,m.__)("Padding","kubio"),path:"padding",...a,onReset:r("padding",{styledComponent:e})}),(0,g.jsx)(ut.BoxUnitValueControlWithPath,{label:(0,m.__)("Margin","kubio"),path:"margin",...a,onReset:r("margin",{styledComponent:e})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.BordersAndRadiusWithPath,{path:"border",...a,withColor:!1,onReset:r("border",{styledComponent:e})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ut.BoxShadowWithPath,{path:"boxShadow",...a,onReset:r("boxShadow",{styledComponent:e})})]})})},Wn=({areaIdentifier:e})=>{const t=(0,l.useSelect)((t=>t(y.STORE_KEY).isEditorSidebarOpened(e)),[]),o=(0,l.useSelect)((e=>{var t,o;return(null===(t=e("kubio/edit-site"))||void 0===t||null===(o=t.getSettings())||void 0===o?void 0:o.isKubioTheme)||null}));return t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Hn,{}),(0,g.jsx)(Un,{styledElement:"form-button",title:(0,m.__)("Form button","kubio")}),(0,g.jsx)(Un,{styledElement:"form-submit-button",title:(0,m.__)("Form submit button","kubio")}),(0,g.jsx)(Un,{styledElement:"form-reset-button",title:(0,m.__)("Form reset button","kubio")}),!o&&(0,g.jsx)(ut.ControlNotice,{className:"notice-general-settings",content:(0,m.__)("These settings are applied to Kubio blocks and the blocks within.","kubio")})]})},Vn=({parentAreaIdentifier:e})=>(0,g.jsx)(tt,{title:(0,m.__)("Form Elements","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/form-elements`,children:(0,g.jsx)(Wn,{areaIdentifier:`${e}/form-elements`})}),Kn={H1:"h1",H2:"h2",H3:"h3",H4:"h4",H5:"h5",H6:"h6"},$n={headingType:{values:Kn,options:[{value:Kn.H1,label:"H1"},{value:Kn.H2,label:"H2"},{value:Kn.H3,label:"H3"},{value:Kn.H4,label:"H4"},{value:Kn.H5,label:"H5"},{value:Kn.H6,label:"H6"}]}},qn=[{value:"dropdown",label:(0,m.__)("Dropdown","kubio")},{value:"flags",label:(0,m.__)("Flags","kubio")}],Yn={show:!0,displayAs:"flags",showFlags:!0,showNames:!1},Zn=()=>{const[e,t]=(0,w.useGlobalDataSetting)("googleFonts.serveLocally");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.ToggleControl,{label:(0,m.__)("Serve Google Fonts locally","kubio"),value:e,onChange:t}),(0,g.jsx)(ut.ControlNotice,{className:"notice-general-settings no-padding",content:(0,m.__)("When this option is turned on the Google Fonts used in your site will be downloaded and served from your server instead of the Google server. This will minimize the DNS requests, reduce the Cumulative Layout Shift and serve your Google Fonts in a 100% GDPR compliant way.","kubio")})]})},{weightOptions:Xn,sizeUnitsOptions:Jn,sizeUnitsConfig:Qn,styleOptions:ei,transformOptions:ti,decorationOptions:oi}=ut.TypographyConfig,ni=e=>{const{globalStyle:t,getStyleDefaultGlobalValue:o,getStyleInitialDefaultGlobalValue:n}=(0,w.useGlobalDataStyle)();return((e,t,o,n)=>{const i={styledComponent:"body"};return{setTypography:(o,n,r={})=>{const a=r.state?`states.${r.state}`:null;r=(0,_.omit)(r,"state");const s=["typography","holders",t,a,o].filter(Boolean).join("."),l=v().merge({},i,r);e.setStyle(s,n,l)},getTypography:(o,n="",r={})=>{const a=r.state?`states.${r.state}`:null;r=(0,_.omit)(r,"state");const s=["typography","holders",t,a,o].filter(Boolean).join("."),l=v().merge({},i,r);return e.getStyle(s,n,l)},unsetTypography:(o,r={})=>{const a=r.state?`states.${r.state}`:null;r=(0,_.omit)(r,"state");const s=["typography","holders",t,a,o].filter(Boolean).join("."),l=v().merge({},i,r),c=n(s,l);e.setStyle(s,c,l)}}})(t,e,0,n)},ii=({getTypography:e,setTypography:t,unsetTypography:o,showTransform:n=!1,showDecoration:i=!0})=>(0,g.jsx)(ut.PopoverOptionsButton,{label:(0,m.__)("Advanced","kubio"),popoverWidth:250,popupContent:(0,g.jsxs)(g.Fragment,{children:[n&&(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Transform","kubio"),options:ti,value:e("transform"),onChange:e=>t("transform",e)}),i&&(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Decoration","kubio"),options:oi,value:e("decoration",""),onChange:e=>t("decoration",e)}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Style","kubio"),options:ei,value:e("style"),onChange:e=>t("style",e)}),(0,g.jsx)(ut.SeparatorHorizontalLine,{fit:!0}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Line Height","kubio"),value:e("lineHeight"),onChange:e=>t("lineHeight",e),onReset:()=>o("lineHeight"),defaultUnit:"",min:0,max:10,step:.1}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Letter Spacing","kubio"),value:e("letterSpacing",{value:"",unit:"px"}),onChange:e=>t("letterSpacing",e),onReset:()=>o("letterSpacing"),min:0,max:10,step:.1,units:Jn})]})}),ri=({element:e="h1"})=>{const{getTypography:t,setTypography:o,unsetTypography:n}=ni(e),{getFontWeights:i}=(0,w.useGlobalDataFonts)(),r=i(t("family")),a=Xn.filter((e=>-1!==r.indexOf(e.value)));return(0,g.jsxs)(h.BaseControl,{children:[(0,g.jsxs)(h.Flex,{className:"kubio-font-family-container general-typography",children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)("span",{className:"kubio-font-family-label",children:(0,m.__)("Font family","kubio")})}),(0,g.jsx)(h.FlexBlock,{className:"kubio-font-family-container__select",children:(0,g.jsx)(ut.FontPicker,{value:t("family"),onChange:e=>o("family",e)})})]}),(0,g.jsx)(ut.GutentagSelectControl,{className:"kubio-select-control-container",label:(0,m.__)("Font weight","kubio"),options:a,value:parseInt(t("weight")),onChange:e=>o("weight",e)}),(0,g.jsx)(ut.InlineLabeledControl,{label:(0,m.__)("Color","kubio"),children:(0,g.jsx)(ut.ColorIndicatorPopover,{color:t("color"),onChange:e=>o("color",e),onReset:()=>n("color"),showReset:!0})}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Size","kubio"),units:Jn,optionsByUnit:Qn,onChange:e=>o("size",e),value:t("size"),onReset:()=>n("size")}),(0,g.jsx)(ii,{getTypography:t,setTypography:o,unsetTypography:n,showTransform:!0})]})},ai=()=>{const[e,t]=(0,u.useState)(""),{getTypography:o,setTypography:n,unsetTypography:i}=ni("a");return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(h.BaseControl,{children:[(0,g.jsxs)(h.Flex,{className:"kubio-font-family-container",children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)("span",{className:"kubio-font-family-label",children:(0,m.__)("Font family","kubio")})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(ut.FontPicker,{label:(0,m.__)("Font family","kubio"),value:o("family"),onChange:e=>n("family",e)})})]}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Font Weight","kubio"),options:Xn,value:parseInt(o("weight")),onChange:e=>n("weight",e)}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Size","kubio"),units:Jn,value:o("size"),onChange:e=>n("size",e),onReset:()=>i("size")}),(0,g.jsx)(h.BaseControl,{label:(0,m.__)("State","kubio"),children:(0,g.jsx)(Gn.StatesControl,{activeState:e,setActiveState:t,availableStates:["normal","hover"]})}),(0,g.jsx)(ut.InlineLabeledControl,{label:(0,m.__)("Color","kubio"),children:(0,g.jsx)(ut.ColorIndicatorPopover,{color:o("color","",{state:e}),onChange:t=>n("color",t,{state:e}),onReset:()=>{i("color",{state:e})},showReset:!0})}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Decoration","kubio"),options:oi,value:o("decoration","",{state:e}),onChange:t=>n("decoration",t,{state:e})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(ii,{getTypography:o,setTypography:n,unsetTypography:i,showTransform:!0,showDecoration:!1})]})})},si=()=>{const[e,t]=(0,u.useState)("h1"),o=(0,l.useSelect)((e=>{var t,o;return(null===(t=e("kubio/edit-site"))||void 0===t||null===(o=t.getSettings())||void 0===o?void 0:o.isKubioTheme)||null}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Headings","kubio"),children:[(0,g.jsx)(ut.ToggleGroup,{label:(0,m.__)("Heading Type","kubio"),options:$n.headingType.options,value:e,onChange:t}),(0,g.jsx)(ri,{element:e})]}),(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Texts","kubio"),children:(0,g.jsx)(ri,{element:"p"})}),(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Lead text","kubio"),children:(0,g.jsx)(ri,{element:"lead"})}),(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Links","kubio"),children:(0,g.jsx)(ai,{})}),(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Adobe TypeKit","kubio"),children:(0,g.jsx)(ut.TypeKitSetupInterface,{showNotice:!0})}),(0,g.jsx)(h.PanelBody,{initialOpen:!1,title:(0,m.__)("Google Fonts Settings","kubio"),children:(0,g.jsx)(Zn,{showNotice:!0})}),!o&&(0,g.jsx)(ut.ControlNotice,{className:"notice-general-settings",content:(0,m.__)("These settings are applied to Kubio blocks and the blocks within.","kubio")})]})},li=({areaIdentifier:e})=>(0,l.useSelect)((t=>t(y.STORE_KEY).isEditorSidebarOpened(e)),[])?(0,g.jsx)(si,{}):(0,g.jsx)(g.Fragment,{}),ci=({parentAreaIdentifier:e})=>(0,g.jsx)(tt,{title:(0,m.__)("Typography","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/typography`,children:(0,g.jsx)(li,{areaIdentifier:`${e}/typography`})});let ui=null;const di=()=>{const{logoImage:e,alternateLogoImage:t,setLogoImage:o,setAlternateLogoImage:n}=(0,w.useSiteLogoImages)(),[i,r]=(0,j.useEntityProp)("root","site","title"),[a,s]=(0,j.useEntityProp)("root","site","description"),{siteIconUrl:c}=(0,l.useSelect)((e=>{const{getEditedEntityRecord:t}=e("core"),o=t("root","site"),n=ui||(null==o?void 0:o.site_icon),i=n&&e("core").getEntityRecord("root","media",n);return{siteIconUrl:null==i?void 0:i.source_url}}),[ui]),{editEntityRecord:d}=(0,l.useDispatch)("core"),p=(0,u.useCallback)((e=>{var t;const o=null!==(t=parseInt(e))&&void 0!==t?t:void 0;ui=o,d("root","site",void 0,{site_icon:o})}),[d]);return(0,g.jsxs)(h.PanelBody,{title:(0,m.__)("Site Identity","kubio"),className:"kubio-site-identity-panel",children:[(0,g.jsx)(h.BaseControl,{label:(0,m.__)("Site title","kubio"),id:"site-title-control",children:(0,g.jsx)(ut.InputControl,{value:i||"",onChange:e=>r(e)})}),(0,g.jsx)(h.BaseControl,{label:(0,m.__)("Tagline","kubio"),id:"tagline-control",children:(0,g.jsx)(ut.InputControl,{value:a||"",onChange:e=>s(e)})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(h.BaseControl,{label:(0,m.__)("Logo image","kubio"),id:"logo-image-control",children:(0,g.jsx)(ut.MediaPicker,{value:e,type:"image",showButton:!0,onReset:()=>{o(null)},buttonLabel:(0,m.__)("Change image","kubio"),removeButtonLabel:(0,m.__)("Reset image","kubio"),onChange:e=>o(e.id)})}),(0,g.jsx)(h.BaseControl,{label:(0,m.__)("Alternate logo image","kubio"),id:"alternate-logo-image-control",children:(0,g.jsx)(ut.MediaPicker,{value:t,type:"image",showButton:!0,showRemoveButton:!0,onReset:()=>{n(null)},buttonLabel:(0,m.__)("Change alternate image","kubio"),removeButtonLabel:(0,m.__)("Reset image","kubio"),onChange:e=>n(e.url)})}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(h.BaseControl,{label:(0,m.__)("Site Icon","kubio"),id:"site-icon-control",help:(0,m.__)("Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. Upload one here!","kubio"),children:(0,g.jsx)(ut.MediaPicker,{value:""!==c?c:null,type:"image",showButton:!0,showRemoveButton:!0,onReset:()=>{p(null)},buttonLabel:(0,m.__)("Set site icon","kubio"),onChange:e=>p(e.id)})})]})},pi=({areaIdentifier:e})=>{const t=(0,l.useSelect)((e=>e(y.STORE_KEY).getEditorOpenedSidebar()),[]),o=null==t?void 0:t.endsWith(e);return(0,g.jsx)(g.Fragment,{children:o&&(0,g.jsx)(di,{})})};function hi({parentAreaIdentifier:e}){return(0,g.jsx)(tt,{title:(0,m.__)("Site Identity","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/site-identity`,children:(0,g.jsx)(pi,{areaIdentifier:`${e}/site-identity`})})}const mi=()=>{const{globalStyle:e,getPropDefaultGlobalValue:t,getStyleDefaultGlobalValue:o}=(0,w.useGlobalDataStyle)(),n=(t,o,n)=>e.getPropInMedia(t,o,{...n}),i=(t,o)=>n=>e.setPropInMedia(t,n,{...o}),r=(o,n={})=>()=>{const i=t(o,n);e.setPropInMedia(o,i,n)},a={styledComponent:"sectionSpacing"};return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(h.PanelBody,{initialOpen:!0,title:(0,m.__)("Spacing","kubio"),children:[(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Horizontal space between buttons/links","kubio"),units:ut.sizeUnitsOptions,onChange:i("hSpace"),value:n("hSpace",{unit:"px"}),onReset:r("hSpace")}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Column contents vertical spacing","kubio"),units:ut.sizeUnitsOptions,onChange:i("vSpace"),value:n("vSpace",{unit:"px"}),onReset:r("vSpace")}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Section vertical spacing","kubio"),units:ut.sizeUnitsOptions,value:e.getStyle("padding.top",{unit:"px"},a),onChange:t=>{e.setStyle("padding.top",t,a),e.setStyle("padding.bottom",t,a)},onReset:()=>{const t=o("padding.top",a);e.setStyle("padding.top",t,a);const n=o("padding.bottom",a);e.setStyle("padding.bottom",n,a)}})]})})},gi=({areaIdentifier:e})=>{const t=(0,l.useSelect)((t=>t(y.STORE_KEY).isEditorSidebarOpened(e)),[]),o=(0,l.useSelect)((e=>{var t,o;return(null===(t=e("kubio/edit-site"))||void 0===t||null===(o=t.getSettings())||void 0===o?void 0:o.isKubioTheme)||null}));return t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(mi,{}),!o&&(0,g.jsx)(ut.ControlNotice,{className:"notice-general-settings",content:(0,m.__)("These settings are applied to Kubio blocks and the blocks within.","kubio")})]})},fi=({parentAreaIdentifier:e})=>(0,g.jsx)(tt,{title:(0,m.__)("Global Spacing","kubio"),label:(0,m.__)("Spacing","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/spacing`,children:(0,g.jsx)(gi,{areaIdentifier:`${e}/spacing`})}),bi="language-selector-outer",_i="language-selector-flags-container",vi="language-selector",yi=()=>{const e=(0,T.getBackendData)("multilanguage.isWpmlActive"),t=(0,T.getBackendData)("multilanguage.isPolylangActive"),{globalStyle:o,resetToInitialData:n}=(0,w.useGlobalDataStyle)(),i=o.getProp("multilanguage",{}),r=v().merge({},Yn,i),{show:a,displayAs:l,showFlags:c,showNames:u}=r;return(0,g.jsxs)(h.PanelBody,{title:(0,m.__)("Language Selector Properties","kubio"),children:[(0,g.jsx)(ut.ToggleControl,{label:(0,m.__)("Show language selector","kubio"),value:a,onChange:e=>{o.setProp("multilanguage.show",e),o.setStyle("display",e?"block":"none",{styledComponent:bi})}}),a&&(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)(h.SelectControl,{options:qn,label:(0,m.__)("Display as","kubio"),type:s.WithDataPathTypes.ATTRIBUTE,value:l,onChange:e=>{o.setProp("multilanguage.displayAs",e)}}),(0,g.jsx)(ut.ColorIndicatorPopover,{label:(0,m.__)("Background color","kubio"),showReset:!0,value:o.getStyle("background.color","white",{styledComponent:bi}),onReset:()=>{o.getStyle("background.color",null,{styledComponent:bi,unset:!0})},onChange:e=>{o.setStyle("background.color",e+" !important",{styledComponent:bi})}}),("flags"===l||e)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.ToggleControl,{label:(0,m.__)("Show flags","kubio"),value:c,onChange:e=>{o.setProp("multilanguage.showFlags",e),o.setStyle("display",e?"inline-block !important":"none",{styledComponent:"language-selector-flags"})},disabled:!u}),(0,g.jsx)(ut.ToggleControl,{label:(0,m.__)("Show names","kubio"),value:u,onChange:e=>{o.setProp("multilanguage.showNames",e),o.setStyle("display",e?"inline-block !important":"none",{styledComponent:"language-selector-names"})},disabled:!c})]}),(0,g.jsx)(ut.BordersAndRadiusControl,{value:o.getStyle("border",null,{styledComponent:bi}),onChange:e=>{o.setStyle("border",e,{styledComponent:bi})},onReset:()=>{o.setStyle("border",null,{styledComponent:bi,unset:!0})},showBorder:!1}),(0,g.jsx)(ut.RangeWithUnitControl,{label:(0,m.__)("Top offset","kubio"),value:o.getStyle("top",150,{styledComponent:vi}),onChange:e=>{o.setStyle("top",e,{styledComponent:vi})},max:300,onReset:()=>{o.setStyle("top",null,{styledComponent:vi,unset:!0})}}),(0,g.jsx)(ut.BoxControl,{label:(0,m.__)("Flags padding","kubio"),values:o.getStyle("padding",null,{styledComponent:_i}),onChange:e=>{o.setStyle("padding",e,{styledComponent:_i})},onReset:()=>o.setStyle("padding",null,{styledComponent:_i,unset:!0})})]})]})};function ki({parentAreaIdentifier:e}){return(0,g.jsx)(tt,{title:(0,m.__)("Multi language","kubio"),parentAreaIdentifier:e,areaIdentifier:`${e}/multilanguage`,children:(0,g.jsx)(yi,{})})}function xi({parentAreaIdentifier:e}){const t=`${e}/general-settings`,o=(0,T.getBackendData)("multilanguage.hasTranslator");return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(tt,{title:(0,m.__)("General Settings","kubio"),areaIdentifier:t,children:[(0,g.jsx)(hi,{parentAreaIdentifier:t}),o&&(0,g.jsx)(ki,{parentAreaIdentifier:t}),(0,g.jsx)(ci,{parentAreaIdentifier:t}),(0,g.jsx)(Vn,{parentAreaIdentifier:t}),(0,g.jsx)(Mn,{parentAreaIdentifier:t}),(0,g.jsx)(fi,{parentAreaIdentifier:t}),(0,g.jsx)(Fn,{parentAreaIdentifier:t}),(0,g.jsx)(Vo,{parentAreaIdentifier:t})]})})}const Si=({addItem:e})=>{const[t,o]=(0,u.useState)(!1),[n,i]=(0,u.useState)((0,co.generateItemInitialData)()),r=(0,u.useRef)(null);return(0,g.jsxs)("div",{ref:r,children:[(0,g.jsx)(h.Button,{onClick:()=>o(!0),className:"kubio-button-100",isPrimary:!0,children:(0,m.__)("Add menu item","kubio")}),t&&(0,g.jsx)(h.Popover,{position:"middle left",className:"kubio-options-popover",onClose:()=>{o(!1)},anchorRef:r.current,offset:6,anchor:r.current,flip:!0,shift:!0,resize:!1,children:(0,g.jsx)(ut.MenuItemOptions,{item:n,isAdd:!0,onChange:t=>{e(t),o(!1),i((0,co.generateItemInitialData)())},afterUpdateClick:()=>o(!1),updateLabel:(0,m.__)("Add item","kubio")})})]})},wi=({item:e,onItemChange:t,onRemoveItem:o,onTogglePopover:n})=>{const[i,r]=(0,u.useState)(e);(0,u.useEffect)((()=>{r(e)}),[e]);const a=e=>{const o={...i,...e};r(o),t(o)},s=(0,u.useRef)();return(0,g.jsx)("div",{ref:s,children:(0,g.jsxs)(h.Flex,{className:"kubio-inspector-menu-item-content",children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)(h.Tooltip,{text:(0,T.stripTags)(i.label),children:(0,g.jsx)("span",{className:"kubio-inspector-menu-item-label",children:(0,T.stripTags)(i.label)})})}),(0,g.jsx)(h.FlexItem,{className:"kubio-inspector-menu-items-settings",children:(0,g.jsxs)(h.Flex,{gap:1,children:[(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Button,{className:"kubio-inspector-menu-remove-item",isSmall:!0,iconSize:18,onClick:()=>o(i),icon:He.DeleteItemIcon})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(ut.PopoverOptionsButton,{iconSize:18,popoverClass:"kubio-menu-edit-popover",popoverAnchorRef:s,popupContent:e=>(0,g.jsx)(ut.MenuItemOptions,{item:i,onChange:a,afterUpdateClick:e}),onPopoverClose:()=>n(!1),onPopoverOpen:()=>n(!0)})})]})})]})})},Ci=(e=[],t=0)=>e.filter((e=>e.parent===t)).map((t=>({...t,children:t.id?Ci(e,t.id):[]}))),Ii=(e,t=0)=>e.map(((e,o)=>[{...(0,_.omit)(e,["children","block"]),order:o+1,parent:t},...Ii(e.children||[],e.id)])).reduce(((e,t)=>e.concat(t)),[]),ji=({items:e=[],setItems:t,isResolving:o,hasResolved:n})=>{const[i,r]=(0,u.useState)(-1/0),a=(0,u.useMemo)((()=>Ci(e)),[e]),s=(0,u.useCallback)((e=>{t(e,!0)}),[t]),l=(0,u.useCallback)((t=>{let o=(0,_.cloneDeep)(e).filter((e=>e.id!==t.id)).map((e=>(e.parent===t.id&&(e.parent=t.parent),e))),n=0;o=o.map((e=>e.parent===t.parent?(n++,{...e,order:n}):e)),s(o)}),[s]),c=(0,u.useCallback)((e=>{const t=Ii(e);s(t)}),[s]),d=(0,u.useCallback)((t=>{if(!t.id)return void console.error("Cannot update item without id");const o=(0,_.cloneDeep)(e).map((e=>e.id===t.id?{...e,...t}:e));s(o)}),[s]),p=(0,u.useCallback)((({item:e})=>(0,g.jsx)(wi,{item:e,onItemChange:d,onRemoveItem:l,onTogglePopover:t=>{r(t?e.id:-1/0)}})),[r,d,l]),f=a.length>0,b=(0,u.useCallback)((e=>e.id===i),[i]);return(0,g.jsx)(h.BaseControl,{children:(0,g.jsxs)("div",{className:"kubio-inspector-menu-tree",children:[o&&(0,g.jsx)(ut.LoadingPlaceholder,{message:(0,m.__)("Loading menu …","kubio")}),n&&f&&(0,g.jsx)(ut.SortableTree,{items:a,renderItem:p,handler:!0,collapsable:!1,onChange:c,isActive:b}),n&&!f&&(0,g.jsx)(ut.SmallPlaceholder,{message:(0,m.__)("Empty menu","kubio")})]})})},Ti=({menu:e})=>{const{setItems:t,items:o=[],isResolving:n,hasResolved:i}=(0,co.useMenuBlockEditor)(e.id),r=(0,u.useCallback)((e=>{t([...o,{...e,order:o.length+1}],!0)}),[o]);return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(h.PanelBody,{title:(0,m.__)("Menu Structure","kubio"),children:[(0,g.jsx)(ji,{menuId:e.id,items:o,setItems:t,isResolving:n,hasResolved:i}),(0,g.jsx)(Si,{addItem:r})]})})},Pi=({menu:e,areaIdentifier:t})=>{const o=(0,l.useSelect)((e=>e(y.STORE_KEY).getEditorOpenedSidebar()));return o&&-1!==o.indexOf(t)&&(0,g.jsx)(Ti,{menu:e})},Ei=({parentAreaIdentifier:e,menu:t})=>{const o=`${e}/menu-${t.id}`;return(0,g.jsx)(tt,{title:(0,m.sprintf)(// translators: %s is for the menu name
// translators: %s is for the menu name
(0,m.__)("Menu: %s","kubio"),t.name||(0,m.__)("Unnamed menu","kubio")),label:t.name||(0,m.__)("Unnamed menu","kubio"),parentAreaIdentifier:e,areaIdentifier:o,children:(0,g.jsx)(Pi,{areaIdentifier:o,menu:t})})},Ri=()=>{const[e,t]=(0,u.useState)(!1),[o,n]=(0,u.useState)(!1),[i,r]=(0,u.useState)(""),a=(0,u.useRef)(),{saveMenu:s}=(0,l.useDispatch)("core"),{createErrorNotice:c,createInfoNotice:d}=(0,l.useDispatch)(b.store),p=(0,u.useCallback)((()=>{o?d((0,m.__)("Another menu creation is in progress","kubio"),{type:"snackbar"}):(t(!e),r(""))}),[e,t,o]),f=(0,u.useCallback)((async()=>{if(!o){n(!0);try{await s({name:i})}catch(e){c((0,m.__)("Menu creation failed","kubio"),{type:"snackbar"})}t(!1),n(!1)}}),[t,s,i,o,n]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.BaseControl,{className:"kubio-create-menu-button",children:(0,g.jsx)(h.Button,{onClick:p,isPrimary:!0,className:"kubio-button-100",ref:a,isBusy:o,children:(0,m.__)("Create menu","kubio")})}),e&&(0,g.jsx)(h.Popover,{position:"middle left",className:"kubio-options-popover",anchorRef:a.current,onClose:()=>t(!1),offset:6,children:(0,g.jsxs)("div",{children:[(0,g.jsx)(h.BaseControl,{children:(0,g.jsx)(ut.InputControl,{label:(0,m.__)("Menu name","kubio"),onChange:r,value:i,disabled:o})}),(0,g.jsx)(h.BaseControl,{children:(0,g.jsx)(h.Button,{onClick:f,isPrimary:!0,disabled:o,isBusy:o,className:"kubio-button-100",children:(0,m.__)("Create menu","kubio")})})]})})]})},Ai=({areaIdentifier:e})=>{const{menus:t}=(0,l.useSelect)((e=>{const{getMenus:t,isResolving:o,hasFinishedResolution:n}=e("core"),i=[{per_page:-1}];return{menus:t(...i),isResolvingMenus:o("getMenus",i),hasResolvedMenus:n("getMenus",i)}}));return(0,g.jsx)(g.Fragment,{children:null==t?void 0:t.map((t=>(0,g.jsx)(Ei,{parentAreaIdentifier:e,menu:t},t.id)))})};function Oi({parentAreaIdentifier:e}){const t=`${e}/menus-settings`;return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(tt,{title:(0,m.__)("Menus","kubio"),areaIdentifier:t,children:[(0,g.jsx)(Ai,{areaIdentifier:t}),(0,g.jsx)(Ri,{})]})})}const Ni=function(){return(0,g.jsx)(q.PostTypeSupportCheck,{supportKeys:["comments","trackbacks"],children:(0,g.jsxs)(h.PanelBody,{title:(0,m.__)("Discussion","kubio"),children:[(0,g.jsx)(q.PostTypeSupportCheck,{supportKeys:"comments",children:(0,g.jsx)(h.PanelRow,{children:(0,g.jsx)(q.PostComments,{})})}),(0,g.jsx)(q.PostTypeSupportCheck,{supportKeys:"trackbacks",children:(0,g.jsx)(h.PanelRow,{children:(0,g.jsx)(q.PostPingbacks,{})})})]})})};var Bi=o(5358);const Di=(0,l.withSelect)((e=>{const{getCurrentPostType:t}=e(Bi.Ls),{getPostType:o}=e(j.store);return{postType:o(t())}})),Mi=(0,p.compose)(Di)((function({postType:e}){return(0,g.jsx)(q.PostFeaturedImageCheck,{children:(0,g.jsx)(h.PanelBody,{title:(0,_.get)(e,["labels","featured_image"],(0,m.__)("Featured image","kubio")),children:(0,g.jsx)(q.PostFeaturedImage,{})})})})),Li=function(){const{postType:e}=(0,l.useSelect)((e=>{const{getCurrentPostType:t}=e(Bi.Ls),{getPostType:o}=e(j.store);return{postType:o(t())}}),[]);return e?(0,g.jsx)(q.PageAttributesCheck,{children:(0,g.jsxs)(h.PanelBody,{title:(0,_.get)(e,["labels","attributes"],(0,m.__)("Page attributes","kubio")),children:[(0,g.jsx)(q.PageAttributesParent,{}),(0,g.jsx)(h.PanelRow,{children:(0,g.jsx)(q.PageAttributesOrder,{})})]})}):null},zi=function(){return(0,g.jsx)(q.PostExcerptCheck,{children:(0,g.jsx)(h.PanelBody,{title:(0,m.__)("Excerpt","kubio"),children:(0,g.jsx)(q.PostExcerpt,{})})})},Fi=(0,p.compose)([(0,l.withSelect)((e=>{const{isPermalinkEditable:t,getCurrentPost:o,isCurrentPostPublished:n,getPermalinkParts:i,getEditedPostAttribute:r,getEditedPostSlug:a}=e(q.store),{getPostType:s}=e(j.store),{link:l}=o(),c=s(r("type")),u=i();return{postLink:l,isEditable:t(),isPublished:n(),isViewable:(0,_.get)(c,["viewable"],!1),postSlug:(0,zo.safeDecodeURIComponent)(a()),postTypeLabel:(0,_.get)(c,["labels","view_item"]),hasPermalinkParts:!!u,permalinkPrefix:null==u?void 0:u.prefix,permalinkSuffix:null==u?void 0:u.suffix}})),(0,p.ifCondition)((({isEnabled:e,postLink:t,isViewable:o,hasPermalinkParts:n})=>e&&t&&o&&n))])((function({postLink:e,permalinkPrefix:t,permalinkSuffix:o,editPermalink:n,postSlug:i,postTypeLabel:r,isEditable:a}){const[s,l]=(0,u.useState)(!1);let c,d,p;return a&&(c=t&&(0,g.jsx)("span",{className:"edit-post-post-link__link-prefix",children:t}),d=i&&(0,g.jsx)("span",{className:"edit-post-post-link__link-post-name",children:i}),p=o&&(0,g.jsx)("span",{className:"edit-post-post-link__link-suffix",children:o})),(0,g.jsxs)(h.PanelBody,{title:(0,m.__)("Permalink","kubio"),children:[a&&(0,g.jsxs)("div",{className:"editor-post-link",children:[(0,g.jsx)(ut.InputControl,{label:(0,m.__)("URL Slug","kubio"),value:s?"":i,onChange:e=>{n(e),e?s&&l(!1):s||l(!0)},onBlur:e=>{n((0,q.cleanForSlug)(e.target.value)),s&&l(!1)}}),(0,g.jsxs)("p",{children:[(0,m.__)("The last part of the URL.","kubio")," ",(0,g.jsx)(h.ExternalLink,{href:"https://wordpress.org/support/article/writing-posts/#post-field-descriptions",children:(0,m.__)("Read about permalinks","kubio")})]})]}),(0,g.jsx)("h3",{className:"edit-post-post-link__preview-label",children:r||(0,m.__)("View post","kubio")}),(0,g.jsx)("div",{className:"edit-post-post-link__preview-link-container",children:(0,g.jsx)(h.ExternalLink,{className:"edit-post-post-link__link",href:e,target:"_blank",children:a?(0,g.jsxs)(g.Fragment,{children:[c,d,p]}):e})})]})})),Gi=function({taxonomy:e,children:t}){const o=(0,_.get)(e,["labels","menu_name"]);return o?(0,g.jsx)(h.PanelBody,{title:o,children:t}):null},Hi=function(){return(0,g.jsx)(q.PostTaxonomiesCheck,{children:(0,g.jsx)(q.PostTaxonomies,{taxonomyWrapper:(e,t)=>(0,g.jsx)(Gi,{taxonomy:t,children:e})})})};function Ui({layoutBlock:e}){const{dataHelper:t}=(0,s.useKubioDataHelper)(e),o=(0,We.useQueryLayout)(t);return(0,g.jsx)(ut.SelectWithIconControl,{label:(0,m.__)("Layout","kubio"),...o})}const Wi=(0,p.compose)([(0,l.withSelect)((e=>{const{getPage:t=v().noop}=e("kubio/edit-site")||{};return{currentPage:t()}}))])((function(e){const{currentPage:t}=e,{getBlocks:o}=(0,l.useSelect)("core/block-editor"),n=v().get(t,["context","postId"]),[i,r]=(0,u.useState)();return(0,u.useEffect)((()=>{const e=o(),t=(0,T.findBlockByName)(e,"kubio/query-layout");r(t)}),[o,n]),i?(0,g.jsx)(h.PanelBody,{title:(0,m.__)("Blog layout","kubio"),initialOpen:!0,children:(0,g.jsx)(Ui,{...e,layoutBlock:i})}):null})),Vi=function({onNewTemplate:e}){const[t,o]=(0,u.useState)(!1);return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("div",{className:"edit-post-template__actions",children:[(0,g.jsx)(Ge.ProItem,{tag:h.Button,isPrimary:!0,onClick:()=>o(!0),urlArgs:{source:"template",content:"create-new"},children:(0,m.__)("Create new template","kubio")}),t&&(0,g.jsx)(ut.TemplateWizard,{onNewTemplate:e,onClose:()=>{o(!1)}})]})})},Ki=function(){const{currentPostType:e,currentTemplate:t,currentTemplateLabel:o,availableTemplates:n}=(0,l.useSelect)((e=>{var t;const{getCurrentPageTemplate:o,getCurrentPostType:n,getAvailablePageTemplates:i}=e(y.STORE_KEY),r=n();let a=o();r===a&&(a="");const s=i();return{currentPostType:r,currentTemplate:a,currentTemplateLabel:(null===(t=(0,_.find)(s,{value:a}))||void 0===t?void 0:t.label)||"",availableTemplates:s}}),[]),{onNewTemplate:i,assignTemplate:r,assignClassicTemplate:a}=(0,s.useTemplateData)("header"),c=(0,s.useDeepMemo)((()=>{const e=n.reduce(((e,t)=>{const o=t.source||"custom";return{...e,[o]:[...e[o]||[],t]}}),{});return y.templateGroupPriorities.map((t=>({label:y.templateGroups[t],items:e[t]}))).filter((e=>{var t;return null===(t=e.items)||void 0===t?void 0:t.length}))}),[n]),u=(0,s.useDeepMemo)((()=>{let e=!1;return c.forEach((o=>{((null==o?void 0:o.items)||[]).forEach((o=>{o.value===t&&(e=!0)}))})),e?t:""}),[t,c]);return"page"!==e||"front-page"===(null==t?void 0:t.replace(".php",""))?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)(h.PanelBody,{title:(0,m.sprintf)(/* translators: %s: template title */ /* translators: %s: template title */(0,m.__)("Template: %s","kubio"),o),children:[(0,g.jsx)(ut.GutentagSelectControl,{hideLabelFromVision:!0,label:(0,m.__)("Template:","kubio"),value:u,onChange:async function(e){Object.values(s.defaultTemplatesByPostType).includes(e)&&(e="");const t=n.find((t=>t.value===e));t&&((null==t?void 0:t.isClassicTemplate)?a(e):r(e))},options:c}),(0,g.jsx)(Vi,{onNewTemplate:i})]})},$i=["page","post"],qi=({areaIdentifier:e})=>{const{currentSidebar:t,isInnerPage:o,isWooPage:n}=(0,l.useSelect)((e=>({isWooPage:e(y.STORE_KEY).getIsWooCommercePage(),currentSidebar:e(y.STORE_KEY).getEditorOpenedSidebar(),isInnerPage:e(y.STORE_KEY).getIsInnerPage()})),[]),i=null==t?void 0:t.endsWith(e),r=o&&!n;return(0,g.jsx)("span",{className:"kubio-page-settings",children:i&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Wi,{}),r&&(0,g.jsx)(Ki,{}),(0,g.jsx)(Fi,{}),(0,g.jsx)(Hi,{}),(0,g.jsx)(Mi,{}),(0,g.jsx)(zi,{}),(0,g.jsx)(Ni,{}),(0,g.jsx)(Li,{})]})})};function Yi({parentAreaIdentifier:e}){const t=`${e}/page-settings`,{postType:o}=(0,l.useSelect)((e=>{const{getCurrentPostType:t}=e(y.STORE_KEY);return{postType:t()}}),[]);return $i.includes(o)?(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(tt,{title:(0,m.__)("Page Settings","kubio"),areaIdentifier:t,children:(0,g.jsx)(qi,{areaIdentifier:t})})}):null}const Zi=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})}),Xi={family:"Open Sans"},Ji={family:"Work Sans"},Qi={family:"Roboto"},er={family:"Playfair Display"},tr={family:"Inter"},or={family:"Offside"},nr={family:"Lekton"},ir={family:"Architects Daughter"},rr={family:"Poppins"},ar={family:"Merriweather"},sr={family:"Hind"},lr={family:"Alice"},cr={family:"Montserrat"},ur={family:"Roboto Mono"},dr={family:"Fauna One"},pr={family:"Josefin Sans"},hr={family:"PT Sans"},mr={family:"Pontano Sans"},gr={family:"Source Sans Pro"},fr={family:"Mulish"},br={family:"Prompt"},_r={family:"La Belle Aurore"},vr={family:"DM Serif Display"},yr={family:"DM Sans"},kr={family:"Abril Fatface"},xr={family:"IBM Plex Sans Condensed"},Sr={family:"Oswald"},wr={family:"Libre Baskerville"},Cr={family:"Nunito"},Ir={family:"Stint Ultra Expanded"},jr={family:"Yeseva One"},Tr={family:"Cinzel"},Pr={family:"Rubik"},Er={family:"Poiret One"},Rr={family:"Della Respira"},Ar={family:"Expletus Sans"},Or={family:"Sacramento"},Nr={family:"IBM Plex Sans"},Br={family:"Oswald"},Dr={h1:{weight:300},h2:{weight:600},h3:{weight:600},h4:{weight:600},h5:{weight:600},h6:{weight:600}},Mr={h1:{weight:400},h2:{weight:400},h3:{weight:400},h4:{weight:400},h5:{weight:400},h6:{weight:400}},Lr=[v().merge({},{h1:vr,h2:vr,h3:vr,h4:vr,h5:vr,h6:vr,p:yr,lead:yr,a:yr},Mr),v().merge({},{h1:kr,h2:kr,h3:kr,h4:kr,h5:kr,h6:kr,p:rr,lead:rr,a:rr},Mr),v().merge({},{h1:xr,h2:xr,h3:xr,h4:xr,h5:xr,h6:xr,p:Nr,lead:Nr,a:Nr},{h1:{weight:500},h2:{weight:600},h3:{weight:500},h4:{weight:600},h5:{weight:500},h6:{weight:500}}),v().merge({},{h1:Ji,h2:Ji,h3:Ji,h4:Ji,h5:Ji,h6:Ji,p:ar,lead:ar,a:ar},{h1:{weight:700},h2:{weight:700},h3:{weight:500},h4:{weight:700},h5:{weight:500},h6:{weight:500}}),v().merge({},{h1:Br,h2:Br,h3:Br,h4:Br,h5:Br,h6:Br,p:gr,lead:gr,a:gr},{h1:{weight:700},h2:{weight:700},h3:{weight:500},h4:{weight:700},h5:{weight:500},h6:{weight:500}}),v().merge({},{h1:jr,h2:jr,h3:jr,h4:jr,h5:jr,h6:jr,p:pr,lead:pr,a:pr},Mr),v().merge({},{h1:Rr,h2:Rr,h3:Rr,h4:Rr,h5:Rr,h6:Rr,p:Xi,lead:Xi,a:Xi},Mr),v().merge({},{h1:Ji,h2:Ji,h3:Ji,h4:Ji,h5:Ji,h6:Ji,p:Qi,lead:Qi,a:Qi},Mr),v().merge({},{h1:er,h2:er,h3:er,h4:tr,h5:er,h6:er,p:tr,lead:tr,a:tr},Dr),v().merge({},{h1:or,h2:or,h3:or,h4:or,h5:or,h6:or,p:nr,lead:nr,a:nr},Mr),v().merge({},{h1:ir,h2:ir,h3:ir,h4:fr,h5:ir,h6:ir,p:fr,lead:fr,a:fr},Mr),v().merge({},{h1:Xi,h2:Xi,h3:Xi,h4:Xi,h5:Xi,h6:Xi,p:Xi,lead:Xi,a:Xi},Dr),v().merge({},{h1:_r,h2:_r,h3:_r,h4:br,h5:_r,h6:br,p:br,lead:br,a:br},Mr),v().merge({},{h1:Sr,h2:Sr,h3:Sr,h4:Sr,h5:Sr,h6:Sr,p:gr,lead:gr,a:gr},{h1:{weight:700},h2:{weight:700},h3:{weight:500},h4:{weight:700},h5:{weight:500},h6:{weight:500},p:{weight:400},lead:{weight:400},a:{weight:400}}),v().merge({},{h1:wr,h2:wr,h3:wr,h4:wr,h5:wr,h6:wr,p:wr,lead:wr,a:wr},{h1:{weight:700},h2:{weight:700},h3:{weight:400},h4:{weight:700},h5:{weight:700},h6:{weight:700},p:{weight:400},lead:{weight:400},a:{weight:400}}),v().merge({},{h1:Cr,h2:Cr,h3:Cr,h4:Cr,h5:Cr,h6:Cr,p:hr,lead:hr,a:hr},{h1:{weight:800},h2:{weight:600},h3:{weight:800},h4:{weight:800},h5:{weight:600},h6:{weight:600},p:{weight:400},lead:{weight:400},a:{weight:400}}),v().merge({},{h1:Ir,h2:Ir,h3:Ir,h4:Ir,h5:Ir,h6:Ir,p:mr,lead:mr,a:mr},Mr),v().merge({},{h1:Tr,h2:Tr,h3:Tr,h4:Tr,h5:Tr,h6:Tr,p:dr,lead:dr,a:dr},Mr),v().merge({},{h1:Pr,h2:Pr,h3:Pr,h4:Pr,h5:Pr,h6:Pr,p:ur,lead:ur,a:ur},Mr),v().merge({},{h1:Er,h2:Er,h3:Er,h4:Er,h5:Er,h6:Er,p:cr,lead:cr,a:cr},Mr),v().merge({},{h1:Ar,h2:Ar,h3:Ar,h4:Ar,h5:Ar,h6:Ar,p:sr,lead:sr,a:sr},Mr),v().merge({},{h1:Or,h2:Or,h3:Or,h4:Or,h5:Or,h6:Or,p:lr,lead:lr,a:lr},Mr)],zr=({children:e,scrollIntoView:t=!0,...o})=>{const n=(0,u.useRef)(),i=(0,u.useCallback)((()=>{if(!t)return;const e=n.current.querySelector(".kubio-style-preset-list__item--active");e&&e.scrollIntoView({behavior:"instant"})}),[]);return(0,u.useEffect)((()=>{i()}),[]),(0,g.jsx)("div",{ref:n,className:"kubio-style-preset-list__container",children:(0,g.jsx)("div",{className:"kubio-style-preset-list",...o,children:e})})};zr.Item=({isActive:e=!1,className:t,children:o,...n})=>(0,g.jsx)("div",{className:X()("kubio-style-preset-list__item",{"kubio-style-preset-list__item--active":e},t),...n,children:o});const Fr=()=>{const{clearSelectedBlock:e}=(0,l.useDispatch)("core/block-editor"),{openSidebar:t}=(0,l.useDispatch)(y.STORE_KEY)||{};return(0,g.jsx)(ut.KubioPanelBody,{title:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{children:(0,m.__)("Typography Presets","kubio")}),(0,g.jsx)(h.Tooltip,{text:(0,m.__)("Advanced Settings","kubio"),children:(0,g.jsx)("div",{className:"kubio-style-preset-list__cog",children:(0,g.jsx)(h.Icon,{icon:dt,onClick:()=>{e().then((()=>{t("document/general-settings/typography")}))}})})})]}),className:"kubio-style-preset-panel",initialOpen:!0,children:(0,g.jsx)(Gr,{})})},Gr=()=>{const{mergedPresets:e,bodyTypographyHolders:t,onSelectPreset:o}=Hr();return(0,g.jsx)(zr,{children:e.map(((e,n)=>(0,g.jsx)(Ur,{preset:e,index:n,bodyTypographyHolders:t,onSelect:o},n)))})},Hr=({typographyPresets:e=Lr}={})=>{const{globalStyle:t}=(0,w.useGlobalDataStyle)(),o=(0,u.useMemo)((()=>t.getStyle("typography.holders",{},{styledComponent:"body"})),[t]),n=(0,u.useMemo)((()=>{const e={};return v().each(o,((t,o)=>{"input"!==o&&v().set(e,o,v().pick(t,["family","weight"]))})),e}),[o]),i=(0,u.useRef)(n),r=(0,u.useRef)(!1),a=(0,u.useMemo)((()=>{const t=i.current,o=!e.find((e=>{let o=!0;return v().each(e,((e,n)=>{e.family!==v().get(t,[n,"family"])&&(o=!1)})),o}));return o?[{isCustom:!0,...t}].concat(e):e}),[]),s=(0,u.useCallback)((e=>{r.current=!0,t.setStyle("typography.holders",v().cloneDeep(e),{styledComponent:"body"})}),[t]);return{mergedPresets:a,bodyTypographyHolders:o,currentTypographyPreset:n,onSelectPreset:s}},Ur=({preset:e,index:t,bodyTypographyHolders:o,onSelect:n})=>{const i=e.h1.family,r={fontFamily:i},a=e.p.family,s={fontFamily:a},l=v().get(o,"h1.family"),c=v().get(o,"p.family"),d=(0,u.useRef)(),p=(0,u.useRef)(),f=(0,u.useCallback)((()=>{var e;null!==(e=d.current)&&void 0!==e&&e.rel&&(d.current.rel="stylesheet")}),[]),b=(0,u.useCallback)((()=>{var e;null!==(e=p.current)&&void 0!==e&&e.rel&&(p.current.rel="stylesheet")}),[]),_=l===i&&c===a;return(0,g.jsxs)(zr.Item,{isActive:_,onClick:()=>{n(e)},children:[(0,g.jsx)("link",{href:`https://fonts.googleapis.com/css?family=${i}&display=swap`,rel:"preload",as:"style",ref:d,onLoad:f}),(0,g.jsx)("link",{href:`https://fonts.googleapis.com/css?family=${a}&display=swap`,rel:"preload",as:"style",ref:p,onLoad:b}),(0,g.jsxs)("div",{className:"kubio-style-preset-list__typography",children:[e.isCustom&&(0,g.jsx)("div",{className:"kubio-style-preset-list__typography__custom",children:(0,m.__)("Custom","kubio")}),(0,g.jsxs)("span",{className:"kubio-style-preset-list__typography__heading-container",children:[(0,g.jsx)("h2",{style:r,children:i}),_&&(0,g.jsx)("div",{className:"kubio-style-preset-list__check",children:(0,g.jsx)(h.Icon,{icon:Zi})})]}),(0,g.jsx)("p",{style:s,children:a})]})]},t)},Wr=y.colorPalettes.map(((e,t)=>({...e,label:(0,m.sprintf)(// translators: %s: number of the preset, Set refers to the color scheme preset
// translators: %s: number of the preset, Set refers to the color scheme preset
(0,m.__)("Set %s","kubio"),t+1)}))),Vr=e=>{const{clearSelectedBlock:t}=(0,l.useDispatch)("core/block-editor"),{openSidebar:o}=(0,l.useDispatch)(y.STORE_KEY)||{};return(0,g.jsx)(ut.KubioPanelBody,{title:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{children:(0,m.__)("Color Scheme Presets","kubio")}),(0,g.jsx)(h.Tooltip,{text:(0,m.__)("Advanced Settings","kubio"),children:(0,g.jsx)("div",{className:"kubio-style-preset-list__cog",children:(0,g.jsx)(h.Icon,{icon:dt,onClick:()=>{t().then((()=>{o("document/general-settings/color-scheme")}))}})})})]}),className:"kubio-style-preset-panel",initialOpen:!0,children:(0,g.jsx)(Kr,{...e})})},Kr=(0,u.memo)((()=>{const{onHandleClick:e,activePaletteValue:t,customPalette:o,currentPaletteIsCustom:n}=$r(),{activePalette:i,restOfPalettes:r}=(0,s.useDeepMemo)((()=>{const e=[];return!v().isEmpty(o)&&e.push({label:(0,m.__)("Previous","kubio"),colors:o}),{activePalette:{label:(0,m.__)("Current","kubio"),colors:t},restOfPalettes:e.concat(Wr)}}),[n,t,o]);return(0,g.jsxs)("div",{className:"kubio-style-presets-color-scheme__container",children:[(0,g.jsx)(zr,{scrollIntoView:!1,children:(0,g.jsx)(qr,{palette:i,index:0,onHandleClick:e,activePaletteValue:t})}),(0,g.jsx)(Bn,{}),(0,g.jsx)(ut.SeparatorHorizontalLine,{}),(0,g.jsx)(zr,{scrollIntoView:!1,children:r.map(((t,o)=>(0,g.jsx)(qr,{palette:t,index:o,onHandleClick:e,activePaletteValue:null},o)))})]})})),$r=()=>{const{getPalette:e,setPalette:t,getCustomPalette:o}=(0,w.useGlobalDataColors)(),n=e(),i=o(),r=(0,u.useCallback)((e=>{t([...e.colors])}),[t]),a=(0,u.useMemo)((()=>{const e=!y.colorPalettes.find((e=>(0,T.getColorPalettesAreEqual)(e.colors,n))),t=(0,T.getColorPalettesAreEqual)(i,n);return e&&!t}),[n,i]);return{mergedPalettes:(0,s.useDeepMemo)((()=>{const e=[];if(!v().isEmpty(i)&&e.push({label:(0,m.__)("Previous","kubio"),colors:i}),a){const t=(0,m.__)("Current","kubio");e.unshift({label:t,isCustom:!0,colors:n})}return e.concat(Wr)}),[a,n,i]),onHandleClick:r,activePaletteValue:n,customPalette:i,currentPaletteIsCustom:a}},qr=({palette:e,index:t,onHandleClick:o,activePaletteValue:n})=>{const i=(0,T.getColorPalettesAreEqual)(e.colors,n);return(0,g.jsxs)(zr.Item,{className:"kubio-style-preset-list__colors",isActive:i,onClick:()=>o(e),children:[!!e.label&&(0,g.jsx)("div",{className:"kubio-style-preset-list__item__title",children:e.label}),(0,g.jsx)("div",{className:"kubio-style-preset-list__colors__item",children:e.colors.map((({slug:e,color:t})=>(0,g.jsx)(ut.ColorIndicator,{value:`rgb(${t.join(",")})`},e)))}),i&&(0,g.jsx)("div",{className:"kubio-style-preset-list__check",children:(0,g.jsx)(h.Icon,{icon:Zi})})]},t)},Yr=({parentAreaIdentifier:e})=>{const t=`${e}/style-presets`,o=(0,m.__)("Style Presets","kubio");return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(tt,{title:(0,g.jsxs)("span",{className:"kubio-sidebar-panel-with-icon__title",children:[(0,g.jsx)(Ue,{icon:He.StylePresetsIcon}),(0,g.jsx)("span",{children:o})]}),areaIdentifier:t,children:(0,g.jsx)(Zr,{AREA_IDENTIFIER:t})})})},Zr=(0,u.memo)((({AREA_IDENTIFIER:e})=>e===(0,l.useSelect)((e=>{var t,o;return null===(t=e(y.STORE_KEY))||void 0===t||null===(o=t.getEditorOpenedSidebar())||void 0===o?void 0:o.replace("kubio/edit-site/sidebar/","")}),[])?(0,g.jsx)(Xr,{}):(0,g.jsx)(g.Fragment,{}))),Xr=(0,u.memo)((()=>(0,g.jsxs)("div",{className:"kubio-style-preset-panel__container",children:[(0,g.jsx)(Vr,{}),(0,g.jsx)(Fr,{})]})));function Jr({beforeSectionsList:e,afterSectionsList:t}){const o=(0,s.usePageTitle)(),{uiVersion:n}=(0,k.useUIVersion)();return(0,g.jsxs)(st,{title:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"preview-notice",children:(0,m.__)("You are editing","kubio")}),(0,g.jsx)("span",{className:"panel-title site-title",children:(0,T.fromHtmlEntities)(o)})]}),areaIdentifier:"document",children:[e,1===n&&(0,g.jsx)(Yi,{parentAreaIdentifier:"document"}),(0,g.jsx)(Ho,{}),(0,g.jsx)(Yr,{parentAreaIdentifier:"document"}),(0,g.jsx)(No,{}),(0,g.jsx)(Mo,{}),2===n&&(0,g.jsx)(Yi,{parentAreaIdentifier:"document"}),(0,g.jsx)(xi,{parentAreaIdentifier:"document"}),(0,g.jsx)(Oi,{parentAreaIdentifier:"document"}),t]})}const{Slot:Qr,Fill:ea}=(0,h.createSlotFill)("ColibriEditSiteBlockEditorSidebarInspector"),ta=()=>{const{currentSidebar:e,selectedBlock:t}=(0,l.useSelect)((e=>{var t,o;return{currentSidebar:(null===(t=e(y.STORE_KEY).getEditorOpenedSidebar())||void 0===t||null===(o=t.split)||void 0===o?void 0:o.call(t,"/sidebar/").at(1))||null,selectedBlock:e("core/block-editor").getSelectedBlock()}}),[]),[o]=(0,Fe.useCurrentInspectorTab)();let n=(0,T.showSupplementaryUpgradeToPRO)()||"document"===e;return n=(0,T.getCanShowProNotice)(n,o),n?(0,g.jsx)(Ge.UpgradeToPro,{urlArgs:{source:t?t.name:e,content:t?o:""}}):(0,g.jsx)(g.Fragment,{})},oa=()=>{const{subsidebars:e}=(0,l.useSelect)((e=>({subsidebars:e(y.STORE_KEY).getSubSidebars()})));return(0,x.useGetGlobalSessionProp)("ready",!1)?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Jr,{}),(0,g.jsx)(ct,{children:(0,g.jsx)(Qr,{bubblesVirtually:!0})}),(0,_.map)(e,((e,t)=>(0,g.jsx)(u.Fragment,{children:e},t)))]}):null},na=ea,ia={content:()=>(0,g.jsx)(Fe.ContentBlockInspector,{}),style:()=>(0,g.jsx)(Fe.StyleBlockInspector,{}),advanced:()=>(0,g.jsx)(Fe.AdvancedStyleBlockInspector,{})},ra=(0,We.getNamesOfBlocks)(),aa=[ra.HEADER,ra.FOOTER,ra.QUERY_LAYOUT,ra.HERO,ra.SECTION,ra.ROW,ra.COLUMN,ra.QUERY,ra.LOOP,ra.LOOP_ITEM],sa=[{name:"content",title:()=>{const e=(0,l.useSelect)((e=>{var t;return null===(t=e("core/block-editor").getSelectedBlock())||void 0===t?void 0:t.name}));let t=(0,m.__)("Layout","kubio");return-1===aa.indexOf(e)&&(t=(0,m.__)("Content","kubio")),(0,g.jsxs)("span",{className:"kubio-tab-panel",children:[(0,g.jsx)(Ue,{icon:He.LayoutIcon}),(0,g.jsx)("span",{className:"kubio-tab-panel-text",children:t})]})},className:"tab-content"},{name:"style",title:()=>(0,g.jsxs)("span",{className:"kubio-tab-panel",children:[(0,g.jsx)(Ue,{icon:He.StyleIcon}),(0,g.jsx)("span",{className:"kubio-tab-panel-text",children:(0,m.__)("Style","kubio")})]}),className:"tab-style"},{name:"advanced",title:()=>(0,g.jsxs)("span",{className:"kubio-tab-panel",children:[(0,g.jsx)(Ue,{icon:He.AdvancedIcon}),(0,g.jsx)("span",{className:"kubio-tab-panel-text",children:(0,m.__)("Advanced","kubio")})]}),className:"tab-advanced"}],la=()=>{const e=ia.content;return(0,g.jsxs)("div",{className:"kubio-block-inspector-tab-content default-inspector",children:[(0,g.jsx)(Fe.BlockInspectorTopControls.Slot,{bubblesVirtually:!0}),(0,g.jsx)(e,{})]})},ca=(0,p.compose)((0,l.withSelect)((e=>{const{getSelectedBlock:t}=e("core/block-editor"),{hasBlockSupport:o}=e("core/blocks"),n=t();return{isBlockSelected:n&&n.clientId,supportsKubio:n&&(n.name.startsWith("kubio/")||"core/post-content"===n.name||o(n.name,"kubio"))}})))((({isBlockSelected:e,supportsKubio:t})=>{const[o,n]=(0,Fe.useCurrentInspectorTab)(),{selectedBlockName:i}=(0,l.useSelect)((e=>{const t=e("core/block-editor").getSelectedBlock();return{selectedBlockName:null==t?void 0:t.name}})),r=(0,u.useRef)(!0);(0,u.useMemo)((()=>{r.current=!0}),[i]);const a=(0,l.useSelect)((e=>{const{getKubioEditorMode:t}=e("kubio/edit-site")||{};return"simple"===(null==t?void 0:t())}),[]),s=(0,u.useMemo)((()=>sa.filter((e=>a&&"advanced"===e.name?null:e))),[a]);return e?t?(0,g.jsx)(ut.TabPanel,{className:"kubio-advanced-block-inspector",currentTab:o,onSelect:n,tabs:s,children:e=>{let t=ia[e.name];return!0===r.current&&(t=ia.content,"content"===e.name&&(r.current=!1)),(0,g.jsxs)("div",{className:"kubio-block-inspector-tab-content kubio-inspector",children:[(0,g.jsx)(Fe.BlockInspectorTopControls.Slot,{bubblesVirtually:!0}),(0,g.jsx)(t,{})]})}}):(0,g.jsx)(la,{}):null})),ua=window.kubio.styleManager,da="editor-styles-wrapper",pa="wp-editor-classic-layout-styles",ha=e=>{if("BUTTON"===e.nodeName){const t=["forminator-ui","wpcf7-form ","wpforms-form","mc4wp-form"],o=e.closest("form"),n=t.some((e=>{var t;return null==o||null===(t=o.classList)||void 0===t?void 0:t.contains(e)}));if(o&&!o.getAttribute("action")&&!n)return}e.addEventListener("click",(e=>{e.preventDefault()}))},ma=(0,u.forwardRef)((function({contentRef:e,children:t,head:o,headHTML:n,contentHolderSelector:i,assetsHolderSelector:r,src:a,onLoad:c=_.noop,execStylesheetCompat:d=!0,...h},f){const[b,v]=(0,u.useState)(),[k,S]=(0,u.useState)(),w=(0,x.useCurrentPageBodyClasses)(),C=(0,x.useSetGlobalSessionProp)("ownerDocument"),I=(0,x.useSetGlobalSessionProp)("blockEditorRootClasses",""),j=(0,u.useRef)(),T=(0,x.useGetGlobalSessionProp)("ready",!1),{currentTemplateSource:P,kubioThemesBaseURL:E}=(0,l.useSelect)((e=>{const{getCurrentKubioTemplateSource:t,getSettings:o}=e(y.STORE_KEY);return{currentTemplateSource:t(),kubioThemesBaseURL:o().kubioThemesBaseURL}}),[]);(0,u.useEffect)((()=>{!T&&a&&(v(null),S(null),C(window.document),(0,ua.removeStyleManager)(b))}),[a,T,C,b]),(0,u.useEffect)((()=>{if(!T||!b)return;const e=T&&a&&b;["kubio-custom","kubio"].includes(P)?(e=>{let t=e.querySelector(".kubio-block-vars-reset");t||(t=e.createElement("style"),t.classList.add("kubio-block-vars-reset"),t.textContent="\n\t\t:root,\n\t\tbody,\n\t\tbody *,\n\t\t.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > *\n\t\t{\n\t\t\t--wp--style--block-gap:0px;\n\t\t\t--gallery-block--gutter-size:0.5em;\n\t\t\t--global-content-width: unset;\n\t\t}",e.head.appendChild(t))})(b):(e=>{const t=e.querySelector(".kubio-block-vars-reset");var o;t&&(null==t||null===(o=t.remove)||void 0===o||o.call(t))})(b),b.querySelectorAll(["wp-reset-editor-styles-css","wp-editor-classic-layout-styles-css","common-css","forms-css"].map((e=>`link#${e}`))).forEach((t=>{t.sheet&&(t.sheet.disabled=e)}))}),[T,a,P,b,E]),(0,u.useEffect)((()=>{if(b&&w.length){const e=Array.from(b.body.classList);b.body.setAttribute("class",(0,_.uniq)(e.concat(w)).join(" "))}}),[b,w]);const[,R]=(0,x.useGlobalSessionProp)("blocksOwnerDocument",null,[]),[,A]=(0,x.useGlobalSessionProp)("currentPageHasBlocksContent",null,[]),O=(0,u.useCallback)((t=>{function o(){const{contentDocument:o}=t,{readyState:r,body:s}=o;if("complete"!==r)return!1;"function"==typeof e?e(s):e&&(e.current=s);const l=["a",'[type="submit"]',"form button"];new o.defaultView.MutationObserver((function(e){(0,_.each)(e,(function(e){e.target.querySelectorAll(l.join(",")).forEach(ha)}))})).observe(o,{childList:!0,subtree:!0}),o.querySelectorAll(l.join(",")).forEach(ha),d&&function(e){const t=new Map;Array.from(document.styleSheets).forEach((o=>{try{o.cssRules}catch(e){return}const{ownerNode:n,cssRules:i}=o;i&&Array.from(i).find((({selectorText:e})=>e&&(e.includes(`.${da}`)||e.includes(".wp-block"))))&&!t.has(n)&&(n.id&&-1!==n.id.indexOf(pa)||n.href&&-1!==n.href.indexOf(pa)?e.head.prepend(n.cloneNode(!0)):e.head.appendChild(n.cloneNode(!0)),t.set(n,!0))}))}(o),o.defaultView.isKubioBlockEditor=!0,o.defaultView.isInsideIframe=!0,o.defaultView.requestIdleCallback=o.defaultView.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)},o.defaultView.cancelIdleCallback=o.defaultView.cancelIdleCallback||function(e){clearTimeout(e)},function(e,t){e.head.innerHTML="<style>/* head style start */</style>"+t+"<style>/* head style end */</style><style>*{scroll-behavior: auto !important; } html#kubio {height:auto!important; margin-top:initial !important}</style>"+e.head.innerHTML}(o,n),function(e){const{defaultView:t}=e,{frameElement:o}=t;function n(e){const{keyCode:n,ctrlKey:i,metaKey:r}=e;if((65===n||95===n)&&(i||r)){const t=e.target.hasAttribute("contenteditable")?e.target:e.target.closest("[contenteditable]");if(t)return((e,t)=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e&&e.ownerDocument.execCommand("selectAll",!1,null),!1))(t,e)}const a=Object.getPrototypeOf(e).constructor.name,s=window[a],l={};for(const t in e)l[t]=e[t];if(e instanceof t.MouseEvent){const e=o.getBoundingClientRect();l.clientX+=e.left,l.clientY+=e.top}const c=new s(e.type,l);c.iframeEvent=!0,!o.dispatchEvent(c)&&e.preventDefault()}const i=["keydown","keypress","dragover"];for(const t of i)e.addEventListener(t,n)}(o),v(o),C(o);let u=i&&o.querySelector(i),p="";if(i&&u){const e=u.parentElement;1===e.children.length&&(u.remove(),u=e),p=u.getAttribute("class"),u.setAttribute("class","kubio-hybrid-template-content-edit")}I(p);let h=o.body;return u?(h=u,A(!0)):(a||i)&&(h.classList.add("kubio-hybrid-no-block-content"),A(!1)),h.classList.add(da),h.classList.add("wp-embed-responsive"),c(t,o),S(h),R(o),!0}t&&(t.contentDocument.body.parentElement.className="kubio-iframe",a?t.addEventListener("load",(()=>{o()})):o()||t.addEventListener("load",(()=>{o()})))}),[]),N=(0,u.useMemo)((()=>!!b&&(r&&b.querySelector(r)||b.head)),[r,b]),B=(0,u.useMemo)((()=>({ownerDocument:b||window.document})),[b]);return(0,g.jsx)(s.OwnerDocumentContext.Provider,{value:B,children:(0,g.jsxs)("iframe",{...h,ref:(0,p.useMergeRefs)([f,O,j]),tabIndex:"0",title:(0,m.__)("Editor canvas","kubio"),className:"kubio-iframe",name:"editor-canvas",src:a,children:[k&&(0,u.createPortal)(t,k),N&&(0,u.createPortal)(o,N)]})})})),ga=async(e,t)=>new Promise((o=>{if(-1!==Array.from(e.ownerDocument.querySelectorAll("script[src]")).map((e=>e.src)).indexOf(t))return;const n=e.ownerDocument.createElement("script");n.async=!0,n.src=t,e.appendChild(n),n.addEventListener("load",o)})),fa=(0,_.debounce)((async(e,t,o=_.noop)=>{for(o(),t=window.structuredClone(t);t.length;){const o=t.shift();await ga(e,o)}}),1e3),ba=[{value:"infographic-label",label:(0,m.__)("infographic label","kubio")},{value:"infographic-number",label:(0,m.__)("infographic number","kubio")},{value:"address",label:(0,m.__)("address","kubio")},{value:"phone",label:(0,m.__)("phone number","kubio")},{value:"email",label:(0,m.__)("email","kubio")}],_a=({setIsModalVisible:e})=>(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(h.MenuGroup,{className:"kubio-block-settings-control kubio-block-settings-ai-desc",children:(0,g.jsx)(h.MenuItem,{onClick:()=>e(!0),children:(0,m.__)("AI block short desc","kubio")})})}),va=()=>{const[e,t]=(0,u.useState)(!1),[o,n]=(0,u.useState)(""),i=(0,u.useRef)({clientId:null,onClose:_.noop}),{dataHelper:r}=(0,s.useKubioDataHelper)({clientId:i.current.clientId});(0,u.useEffect)((()=>{n(r.getAttribute("kubioAI.desc",""))}),[r,i.current.clientId]);const a=(0,u.useCallback)((()=>{r.setAttribute("kubioAI.desc",o||""),t(!1),i.current.onClose()}),[r,o]),l=(0,u.useCallback)((()=>{t(!1),i.current.onClose()}),[]),c=(0,u.useCallback)(((e,o)=>{i.current={clientId:o,onClose:e},t(!0)}),[]);return(0,g.jsxs)(g.Fragment,{children:[e&&(0,g.jsxs)(h.Modal,{title:(0,m.__)("Element short description","kubio"),shouldCloseOnEsc:!1,shouldCloseOnClickOutside:!1,onRequestClose:l,children:[(0,g.jsx)(h.BaseControl,{children:(0,g.jsx)(ut.SuggestionsInput,{label:(0,m.__)("Description","kubio"),options:ba,value:o,onChange:n,filterKeys:["value","label"],onSuggestionClick:(e,t)=>t(e.value),optionRender:e=>(0,g.jsxs)("div",{className:"kubio-ai-language-style-select-item",children:[(0,g.jsx)("span",{children:e.label}),(0,g.jsx)("i",{children:e.value})]})})}),(0,g.jsxs)(h.Flex,{align:"flex-start",children:[(0,g.jsx)(h.Button,{variant:"primary",onClick:a,children:(0,m.__)("Save","kubio")}),(0,g.jsx)(h.Button,{variant:"secondary",onClick:l,children:(0,m.__)("Cancel","kubio")})]})]}),(0,g.jsx)(I.BlockSettingsMenuControls,{children:({onClose:e,firstBlockClientId:t})=>(0,g.jsx)(_a,{setIsModalVisible:()=>c(e,t)})})]})},ya=e=>{const{children:t,className:o}=e,n=(0,u.useRef)(),i=(0,u.useRef)(),[r,a]=(0,x.useGlobalSessionProp)("containerBgMediaUploadRef",{dataHelper:null,ref:null,blockId:null,value:null});(0,u.useEffect)((()=>{null!==i.current&&a({...r,ref:i})}),[i.current]);const s=(0,x.useGetGlobalSessionProp)("ready",!1);return(0,u.useLayoutEffect)((()=>{const e=n.current;if(e&&s){var t;const o=null===(t=e.ownerDocument.querySelector("#kubio-scripts-template"))||void 0===t?void 0:t.content.querySelectorAll("script");o&&fa(e.ownerDocument.head,Array.from(o).map((({src:e})=>e)).filter(Boolean))}}),[s]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{ref:n}),(0,g.jsxs)(I.WritingFlow,{children:[(0,g.jsx)(I.BlockList,{className:X()(o,"edit-site-block-editor__block-list","kubio-block-editor__block-list"),renderAppender:We.KubioBlockAppender}),(0,T.getShowInternalFeatures)("ai")&&(0,g.jsx)(va,{}),t]}),(0,g.jsx)(I.MediaUploadCheck,{children:(0,g.jsx)(I.MediaUpload,{allowedTypes:["image","video"],value:r.value,onSelect:e=>{const{dataHelper:t}=r;if(!t)return;const o=t.getStyle("background");"image"===o.type&&"image"===e.type?o.image[0].source.url=e.url:"video"===o.type&&"video"===e.type&&(o.video.internal.url=e.url),t.setStyle("background",o)},render:({open:e})=>(0,g.jsx)("div",{ref:i,onClick:e})})})]})};var ka=o(9457),xa=o.n(ka);const Sa=()=>(0,g.jsx)("div",{className:"kubio-loading-logo",children:(0,g.jsx)(h.Icon,{icon:He.KubioLoader})}),wa=(0,u.memo)((()=>{const e=(0,p.useRefEffect)((e=>{e.contentWindow.document.open(),e.contentWindow.document.write(xa()),e.contentWindow.document.close();const t=e.contentDocument||e.contentWindow.document,o=null==t?void 0:t.querySelector("#content");o&&(0,s.reactRender)((0,g.jsx)(Sa,{}),o)}),[]);return(0,g.jsx)("iframe",{title:"kubio-loader",ref:e,className:"kubio-loading-logo-iframe"})})),Ca=()=>{const[e,t]=(0,u.useState)(""),o=(0,T.getBackendData)("multilanguage.hasTranslator");(0,u.useEffect)((()=>{n().then((e=>t(e.content))).catch((e=>console.log(e.message)))}),[]);const n=async()=>await O()({path:"/kubio/v1/get-language-selector-html",method:"GET"});return(0,g.jsx)(g.Fragment,{children:o&&(0,g.jsx)(u.RawHTML,{className:"--is-editor",children:e})})};let Ia;const ja=(e,t)=>{var o,n;e&&null!=e&&e.defaultView&&(null===(o=e.querySelector("#kubio-editor-view"))||void 0===o||null===(n=o.classList)||void 0===n||n.remove("device-change-animation"),t?Ia=e.defaultView.setTimeout((()=>{if(e.body.classList.add("kubio-iframe-holder--show"),e.body.classList.remove("kubio-iframe-holder--hide"),e.body.classList.remove("h-ui-disable-transitions"),(0,T.getBackendData)("multilanguage.hasTranslator")){const t=e.createElement("div");t.classList.add("block-editor-block-list__layout");const o=e.createElement("div");o.id="kubio-language-selector",t.append(o),e.querySelector("body").append(t),window.ReactDOM.render(React.createElement(Ca),e.getElementById("kubio-language-selector"))}}),100):(e.defaultView.clearTimeout(Ia),e.body.classList.remove("kubio-iframe-holder--show"),e.body.classList.add("kubio-iframe-holder--hide"),e.body.classList.add("h-ui-disable-transitions")))},Ta=(0,p.pure)((({iframe:e,deviceType:t})=>{const o=(0,I.__experimentalUseResizeCanvas)(t,!0),n=(0,u.useRef)(),i=(0,u.useRef)(),r=(0,u.useRef)(),a=(0,p.useMergeRefs)([n,(0,I.__unstableUseTypingObserver)()]);return(0,x.useEditorIsLoadedChanged)((e=>{var t,o;ja(null===(t=r.current)||void 0===t?void 0:t.ownerDocument,e),ja(null===(o=n.current)||void 0===o?void 0:o.ownerDocument,e)})),(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(I.BlockTools,{className:"kubio-block-tools",__unstableContentRef:n,children:(0,g.jsxs)("div",{id:"kubio-editor-view",ref:i,children:[(0,g.jsx)("div",{id:"kubio-iframe-holder",className:"editor-styles-wrapper edit-site-block-editor__editor-styles-wrapper",style:o,ref:r,children:e(a)}),(0,g.jsx)(wa,{},"kubio-blinking-iframe")]})})})})),Pa="<style>body{width:100%;max-width:100%;overflow-x:hidden;}</style>",Ea=()=>{const[e]=(0,S.useIsAIConnected)(),[t,o]=(0,S.useAIServiceInfo)(),n=(0,x.useGetGlobalSessionProp)("ready"),i=(0,u.useRef)(!1);(0,u.useEffect)((()=>{!i.current&&n&&e&&(i.current=!0,"started"!==t.state&&"ready"!==t.state)&&(o({remainingCredits:0,perPageCredits:1/0,state:"started"}),(async()=>{const{remaining_credits:e=0,per_page_credits:n=480,account_email:i=null,ai_image_cost:r=150,ai_section_cost:a=30}=await(0,S.getAIInfo)();o({...t,state:"ready",remainingCredits:e,perPageCredits:n,email:i,aiImageCost:r,aiSectionCost:a})})())}),[n,e,t])},Ra=window.wp.htmlEntities,Aa=(e,t)=>`<a ${Oa(e)}>${t}</a>`,Oa=e=>`href="${e}" target="_blank" rel="noreferrer noopener"`,Na=e=>{const{title:t,foreign_landing_url:o,creator:n,creator_url:i,license:r,license_version:a,license_url:s}=e,l=((e,t)=>{let o=e.trim();return"pdm"!==e&&(o=e.toUpperCase().replace("SAMPLING","Sampling")),t&&(o+=` ${t}`),["pdm","cc0"].includes(e)||(o=`CC ${o}`),o})(r,a),c=(0,Ra.decodeEntities)(n);let u;return u=c?t?(0,m.sprintf)(// translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
// translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
(0,m._x)('"%1$s" by %2$s/ %3$s',"caption","kubio"),Aa(o,(0,Ra.decodeEntities)(t)),i?Aa(i,c):c,s?Aa(`${s}?ref=openverse`,l):l):(0,m.sprintf)(// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
(0,m._x)("<a %1$s>Work</a> by %2$s/ %3$s","caption","kubio"),Oa(o),i?Aa(i,c):c,s?Aa(`${s}?ref=openverse`,l):l):t?(0,m.sprintf)(// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
(0,m._x)('"%1$s"/ %2$s',"caption","kubio"),Aa(o,(0,Ra.decodeEntities)(t)),s?Aa(`${s}?ref=openverse`,l):l):(0,m.sprintf)(// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
(0,m._x)("<a %1$s>Work</a>/ %3$s","caption","kubio"),Oa(o),s?Aa(`${s}?ref=openverse`,l):l),u.replace(/\s{2}/g," ")},Ba=async(e={})=>(await(0,l.resolveSelect)(j.store).getMediaItems({...e,orderBy:null!=e&&e.search?"relevance":"date"})).map((e=>{var t,o,n,i;return{...e,alt:e.alt_text,url:e.source_url,previewUrl:null===(t=e.media_details)||void 0===t||null===(o=t.sizes)||void 0===o||null===(n=o.medium)||void 0===n?void 0:n.source_url,caption:null===(i=e.caption)||void 0===i?void 0:i.raw}})),Da=[{name:"images",labels:{name:(0,m.__)("Images","kubio"),search_items:(0,m.__)("Search images","kubio")},mediaType:"image",fetch:async(e={})=>Ba({...e,media_type:"image"})},{name:"videos",labels:{name:(0,m.__)("Videos","kubio"),search_items:(0,m.__)("Search videos","kubio")},mediaType:"video",fetch:async(e={})=>Ba({...e,media_type:"video"})},{name:"audio",labels:{name:(0,m.__)("Audio","kubio"),search_items:(0,m.__)("Search audio","kubio")},mediaType:"audio",fetch:async(e={})=>Ba({...e,media_type:"audio"})},{name:"openverse",labels:{name:(0,m.__)("Openverse","kubio"),search_items:(0,m.__)("Search Openverse","kubio")},mediaType:"image",async fetch(e={}){const t={...e,mature:!1,excluded_source:"flickr,inaturalist,wikimedia",license:"pdm,cc0"},o={per_page:"page_size",search:"q"},n=new URL("https://api.openverse.engineering/v1/images/");Object.entries(t).forEach((([e,t])=>{const i=o[e]||e;n.searchParams.set(i,t)}));const i=await window.fetch(n,{headers:{"User-Agent":"WordPress/inserter-media-fetch"}});return(await i.json()).results.map((e=>{var t;return{...e,title:null!==(t=e.title)&&void 0!==t&&t.toLowerCase().startsWith("file:")?e.title.slice(5):e.title,sourceId:e.id,id:void 0,caption:Na(e),previewUrl:e.thumbnail}}))},getReportUrl:({sourceId:e})=>`https://wordpress.org/openverse/image/${e}/report/`,isExternalResource:!0}],Ma=Da;function La(){var e,t;const{setOpenInserter:o}=(0,l.useDispatch)(y.STORE_KEY),{storedSettings:n,canvasMode:i,templateType:r,siteSettings:a}=(0,l.useSelect)((e=>{const{canUser:t,getEntityRecord:n}=e(j.store),{getSettings:i,getCanvasMode:r,getEditedPostType:a}=e(y.STORE_KEY);return{storedSettings:i(o),canvasMode:null==r?void 0:r(),templateType:a(),siteSettings:t("read","settings")?n("root","site"):void 0}}),[]),s=null!==(e=n.__experimentalAdditionalBlockPatterns)&&void 0!==e?e:n.__experimentalBlockPatterns,c=null!==(t=n.__experimentalAdditionalBlockPatternCategories)&&void 0!==t?t:n.__experimentalBlockPatternCategories,{restBlockPatterns:d,restBlockPatternCategories:p,templateSlug:h,userPatternCategories:m}=(0,l.useSelect)((e=>{const{getEditedPostType:t,getEditedPostId:o}=e(y.STORE_KEY),{getEditedEntityRecord:n,getUserPatternCategories:i}=e(j.store),r=n("postType",t(),o());return{restBlockPatterns:e(j.store).getBlockPatterns(),restBlockPatternCategories:e(j.store).getBlockPatternCategories(),templateSlug:r.slug,userPatternCategories:(null==i?void 0:i())||[]}}),[]),g=function(e){const t=null==e?void 0:e.match(/^(category|tag|taxonomy-([^-]+))$|^(((category|tag)|taxonomy-([^-]+))-(.+))$/);let o,n,i,r=!1;if(t)t[1]?o=t[2]?t[2]:t[1]:t[3]&&(o=t[6]?t[6]:t[4],n=t[7]),o="tag"===o?"post_tag":o;else{const t=null==e?void 0:e.match(/^(author)$|^author-(.+)$/);t&&(r=!0,t[2]&&(i=t[2]))}return(0,l.useSelect)((e=>{const{getEntityRecords:t,getTaxonomy:a,getAuthors:s}=e(j.store);let l,c;var u,d;if(o&&(l=null===(u=a(o))||void 0===u||null===(d=u.labels)||void 0===d?void 0:d.singular_name),n){const e=t("taxonomy",o,{slug:n,per_page:1});e&&e[0]&&(c=e[0].name)}if(r&&(l="Author",i)){const e=s({slug:i});e&&e[0]&&(c=e[0].name)}return{archiveTypeLabel:l,archiveNameLabel:c}}),[i,r,o,n])}(h),f=(0,u.useMemo)((()=>[...s||[],...d||[]].filter(((e,t,o)=>t===o.findIndex((t=>e.name===t.name)))).filter((({postTypes:e})=>!e||Array.isArray(e)&&e.includes(r)))),[s,d,r]),b=(0,u.useMemo)((()=>[...c||[],...p||[]].filter(((e,t,o)=>t===o.findIndex((t=>e.name===t.name))))),[c,p]);return(0,u.useMemo)((()=>{const{__experimentalAdditionalBlockPatterns:e,__experimentalAdditionalBlockPatternCategories:t,focusMode:o,...r}=n;return{...r,inserterMediaCategories:Ma,__experimentalBlockPatterns:f,__experimentalBlockPatternCategories:b,__experimentalUserPatternCategories:m,focusMode:("view"!==i||!o)&&o,__experimentalArchiveTitleTypeLabel:g.archiveTypeLabel,__experimentalArchiveTitleNameLabel:g.archiveNameLabel,pageOnFront:null==a?void 0:a.page_on_front,pageForPosts:null==a?void 0:a.page_for_posts}}),[n,f,b,m,i,g.archiveTypeLabel,g.archiveNameLabel,null==a?void 0:a.page_on_front,null==a?void 0:a.page_for_posts])}const za=(0,p.createHigherOrderComponent)((e=>t=>{const{templateType:o,page:n,deviceType:i,templateId:r}=(0,l.useSelect)((e=>{const{getTemplateType:t,getTemplateId:o,getPage:n,__experimentalGetPreviewDeviceType:i}=e(y.STORE_KEY);return{templateType:t(),templateId:o(),page:n(),deviceType:i()}}),[]),a={settings:La(),templateType:o,page:n,deviceType:i,templateId:r};return n||o?(0,g.jsx)(e,{...t,...a}):null}),"currentEditorEntity"),Fa=(0,p.compose)(za,p.pure)((function({settings:e,templateType:t,page:o,deviceType:n,templateId:i}){Ea();const[r,a,s]=(0,j.useEntityBlockEditor)("postType",t,{id:i}),{setPage:c}=(0,l.useDispatch)(y.STORE_KEY),d=(0,I.__unstableUseMouseMoveTypingReset)(),p=window.__kubioEditorStyles.html+Pa,h=(0,l.useSelect)((e=>{const t=e(y.STORE_KEY).getCurrentKubioTemplateSource();return null==t?void 0:t.startsWith("kubio")}),[t,i]),m=(0,u.useMemo)((()=>e.styles),[h,e.styles]),f=(0,u.useCallback)((e=>(0,g.jsx)(ma,{headHTML:p,ref:d,head:(0,g.jsx)(I.__unstableEditorStyles,{styles:m}),contentRef:e,children:(0,g.jsx)(ya,{})})),[d,p,m]);return(0,g.jsxs)(I.BlockEditorProvider,{settings:e,value:r,onInput:a,onChange:s,useSubRegistry:!1,children:[(0,g.jsx)(I.BlockEditorKeyboardShortcuts,{}),(0,g.jsx)(I.__experimentalLinkControl.ViewerFill,{children:(0,u.useCallback)((e=>(0,g.jsx)(ze,{...e,activePage:o,onActivePageChange:c})),[o])}),(0,g.jsx)(na,{children:(0,g.jsx)(ca,{})}),(0,g.jsx)(Ta,{deviceType:n,iframe:f})]})})),Ga=function(){var e,t;Ea();const{setOpenInserter:o}=(0,l.useDispatch)(y.STORE_KEY),[n,i]=(0,u.useState)({}),{page:r,deviceType:a,classicTemplateId:s}=(0,l.useSelect)((e=>{const{getEntity:t,getPage:o,getClassicTemplateId:n,__experimentalGetPreviewDeviceType:i}=e(y.STORE_KEY);return{entity:t(),page:o(),classicTemplateId:n(),deviceType:i()}}),[o]),c=La();(0,u.useEffect)((()=>{qo()(r,n)||i(r)}),[r]);const[d,p,h]=(0,j.useEntityBlockEditor)("postType",null==n||null===(e=n.context)||void 0===e?void 0:e.postType,{id:null==n||null===(t=n.context)||void 0===t?void 0:t.postId}),{setPage:m}=(0,l.useDispatch)(y.STORE_KEY),f=(0,I.__unstableUseMouseMoveTypingReset)(),b=(0,x.useSetGlobalSessionProp)("ready"),_=(e,t)=>{t.body.id="kubio",b(!0)},v=window.__kubioEditorStyles.html+Pa,k=(0,x.useGetGlobalSessionProp)("blockEditorRootClasses",""),S=(0,u.useCallback)((e=>(null==n?void 0:n.path)&&(0,g.jsx)(ma,{headHTML:v,ref:f,contentRef:e,src:(0,zo.addQueryArgs)(null==n?void 0:n.path,{"__kubio-site-edit-iframe-preview":!0,"__kubio-site-edit-iframe-classic-template":s}),contentHolderSelector:"#kubio-site-edit-content-holder",assetsHolderSelector:"#kubio-site-edit-assets-holder",onLoad:_,execStylesheetCompat:!1,children:(0,g.jsx)(ya,{className:k,children:(0,g.jsx)(ut.LayoutPicker,{})})})),[null==n?void 0:n.path,f,v,v,c.styles,k]);return(0,g.jsxs)(I.BlockEditorProvider,{settings:c,value:d,onInput:p,onChange:h,useSubRegistry:!1,children:[(0,g.jsx)(I.BlockEditorKeyboardShortcuts,{}),(0,g.jsx)(I.__experimentalLinkControl.ViewerFill,{children:(0,u.useCallback)((e=>(0,g.jsx)(ze,{...e,activePage:n,onActivePageChange:m})),[n,m])}),(0,g.jsx)(na,{children:(0,g.jsx)(ca,{})}),(0,g.jsx)(Ta,{deviceType:a,iframe:S})]})},Ha=()=>{const[e,t]=(0,u.useState)([]),o=(0,l.useSelect)((e=>{const{getEntityRecords:t}=e("core");return t("postType","kubio_section",{per_page:-1})}),[]),n="kubio-content/custom";return(0,u.useEffect)((()=>{let i=e;null==o||o.forEach((t=>{if(e.includes(t.id))return;const o={name:`${n}/custom-section/${t.id}`,title:t.title.rendered,categories:[n],description:(0,m.__)("Custom section","kubio"),screenshot:!1,fromColibri:!0,fromFirebase:!0,isCustomSection:!0,isProOnFree:!1,isGutentagPattern:!0,content:JSON.parse(t.content.raw),internalTags:[],publicTags:[]};(0,a.registerPattern)(o),i=[...i,t.id]})),t(i)}),[o,e]),null};function Ua({record:e,checked:t,onChange:o,closePanel:n}){const{name:i,kind:r,title:a,key:s}=e,c=(0,l.useSelect)((e=>{var t;const{blocks:o=[]}=e("core").getEditedEntityRecord(r,i,s),n=e("core/block-editor").getBlockParents(null===(t=o[0])||void 0===t?void 0:t.clientId);return n[n.length-1]}),[]),d=(0,l.useSelect)((e=>{if("postType"!==r||"wp_template"!==i)return a;const t=e("core").getEditedEntityRecord(r,i,s);return e("core/editor").__experimentalGetTemplateInfo(t).title}),[i,r,a,s]),p=(0,l.useSelect)((e=>e("core/block-editor").getSelectedBlockClientId()===c),[c]),f=p?(0,m.__)("Selected","kubio"):(0,m.__)("Select","kubio"),{selectBlock:b}=(0,l.useDispatch)("core/block-editor"),_=(0,u.useCallback)((()=>b(c)),[c]),v=(0,u.useCallback)((()=>{b(c),n()}),[c]);return(0,g.jsxs)(h.PanelRow,{children:[(0,g.jsx)(h.CheckboxControl,{label:(0,g.jsx)("strong",{children:d||(0,m.__)("Untitled","kubio")}),checked:t,onChange:o}),c?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{onClick:_,className:"entities-saved-states__find-entity",disabled:p,children:f}),(0,g.jsx)(h.Button,{onClick:v,className:"entities-saved-states__find-entity-small",disabled:p,children:f})]}):null]})}const Wa={site:(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"})}),page:(0,g.jsxs)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,g.jsx)(Q.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,g.jsx)(Q.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]})};function Va({list:e,unselectedEntities:t,setUnselectedEntities:o,closePanel:n}){const i=e[0],r=(0,l.useSelect)((e=>e("core").getEntity(i.kind,i.name)),[i.kind,i.name]),{name:a}=i,s=Wa[a];return(0,g.jsx)(h.PanelBody,{title:r.label,initialOpen:!0,icon:s,children:e.map((e=>(0,g.jsx)(Ua,{record:e,checked:!(0,_.some)(t,(t=>t.kind===e.kind&&t.name===e.name&&t.key===e.key)),onChange:t=>o(e,t),closePanel:n},e.key||`${e.kind}-${e.name}-${e.property}`)))})}const Ka={title:(0,m.__)("Title","kubio"),description:(0,m.__)("Tagline","kubio"),site_logo:(0,m.__)("Logo","kubio"),sitelogo:(0,m.__)("Logo","kubio"),show_on_front:(0,m.__)("Show on front","kubio"),page_on_front:(0,m.__)("Page on front","kubio")},$a={wp_template_part:e=>(0,m._n)("template part","template parts",e,"kubio"),wp_template:e=>(0,m._n)("template","templates",e,"kubio"),post:e=>(0,m._n)("post","posts",e,"kubio"),page:e=>(0,m._n)("page","pages",e,"kubio"),site:e=>(0,m._n)("site","sites",e,"kubio")},qa=(0,h.withFocusReturn)((function({isOpen:e,close:t}){const{dirtyEntityRecords:o}=(0,l.useSelect)((e=>{const t=e(j.store).__experimentalGetDirtyEntityRecords().filter((e=>!("root"===e.kind&&"site"===e.name))),o=e(j.store).getEntityRecordEdits("root","site"),n=[];for(const e in o)n.push({kind:"root",name:"site",title:Ka[e]||e,property:e});return{dirtyEntityRecords:[...t,...n]}}),[]),{saveEditedEntityRecord:n}=(0,l.useDispatch)("core"),i=Object.values((0,_.groupBy)(o,"name")),r=[];i.forEach((e=>{$a[e[0].name]&&r.push($a[e[0].name](e.length))}));const[a,s]=(0,u.useState)([]),c=({kind:e,name:t,key:o},n)=>{s(n?a.filter((n=>n.kind!==e||n.name!==t||n.key!==o)):[...a,{kind:e,name:t,key:o}])},d=(0,u.useCallback)((()=>t()),[t]),p=(0,m.__)("Save","kubio");return e?(0,g.jsxs)("div",{className:"entities-saved-states__panel kubio-entities-saved-states__panel",children:[(0,g.jsxs)("div",{className:"entities-saved-states__panel-header",children:[(0,g.jsx)(h.Button,{isPrimary:!0,disabled:o.length-a.length==0,onClick:()=>{const e=(()=>{const e=o.filter((({kind:e,name:t,key:o})=>!(0,_.some)(a,(n=>n.kind===e&&n.name===t&&n.key===o))));return e})();t(e),e.forEach((({kind:e,name:t,key:o})=>{n(e,t,o)}))},className:"editor-entities-saved-states__save-button",children:p}),(0,g.jsx)(h.Button,{onClick:d,icon:Ve,label:(0,m.__)("Close panel","kubio")})]}),(0,g.jsxs)("div",{className:"entities-saved-states__text-prompt",children:[(0,g.jsx)("strong",{children:(0,m.__)("Select the changes you want to save","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("Some changes may affect other areas of your site.","kubio")})]}),i.map((e=>(0,g.jsx)(Va,{list:e,closePanel:d,unselectedEntities:a,setUnselectedEntities:c},e[0].name)))]}):null})),Ya=(0,g.jsx)(Q.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)(Q.Path,{d:"M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z"})});var Za=o(4670),Xa=o.n(Za);const Ja="IS_AI_PAGE_GENERATING_"+Xa().generate(),Qa=()=>(0,x.useGlobalSessionProp)(Ja),es=["front-page","single-post","page","archive","search","404","index"],ts="root",os="template-parts",ns="templates",is="templates-general",rs="templates-pages",as="templates-posts",ss="kubio__custom-templates",ls="kubio__theme-templates",cs="kubio__kubio-templates",us=[{area:"header",menu:"template-parts-headers",title:(0,m.__)("Headers","kubio")},{area:"footer",menu:"template-parts-footers",title:(0,m.__)("Footers","kubio")},{area:"sidebar",menu:"template-parts-sidebars",title:(0,m.__)("Sidebars","kubio")},{area:"uncategorized",menu:"template-parts-general",title:(0,m.__)("General","kubio")}];function ds({openEntitiesSavedStates:e}){const{saveEditedEntityRecord:t}=(0,l.useDispatch)("core"),{isSaving:o,isDirty:n}=(0,l.useSelect)((e=>{const{__experimentalGetDirtyEntityRecords:t,isSavingEntityRecord:o}=e("core"),n=t();return{isDirty:n.length>0,isSaving:(0,_.some)(n,(e=>o(e.kind,e.name,e.key)))}})),i=!n||o,r=(0,m.__)("Save","kubio"),{dirtyEntityRecords:a}=(0,l.useSelect)((e=>{const t=e(j.store).__experimentalGetDirtyEntityRecords().filter((e=>!("root"===e.kind&&"site"===e.name))),o=e(j.store).getEntityRecordEdits("root","site"),n=[];for(const e in o)n.push({kind:"root",name:"site",property:e});return{dirtyEntityRecords:[...t,...n]}}),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{isPrimary:!0,className:"edit-site-save-button__button","aria-disabled":i,disabled:i,isBusy:o,onClick:i?void 0:()=>{a.forEach((({kind:e,name:o,key:n})=>{t(e,o,n)}))},children:r}),(0,g.jsx)(h.Button,{isPrimary:!0,icon:He.ArrowDown,iconSize:24,className:"edit-site-save-button__dropdown","aria-disabled":i,disabled:i,onClick:i?void 0:e})]})}const ps=(0,u.memo)((({onClose:e})=>{const t=(0,T.isAdvancedMode)()?(0,m.__)("Switch to quick mode","kubio"):(0,m.__)("Switch to advanced mode","kubio");return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(h.MenuGroup,{className:"kubio-block-settings-control",children:(0,g.jsx)(h.MenuItem,{tag:h.MenuItem,onClick:()=>{e(),(0,T.toggleAdvancedMode)()},children:t})})})})),hs=((0,p.createHigherOrderComponent)((e=>t=>{const{isSelected:o}=t;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(e,{...t}),o&&(0,g.jsx)(I.BlockSettingsMenuControls,{children:({onClose:e})=>(0,g.jsx)(ps,{onClose:e})})]})})),(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})),ms=window.wp.a11y;function gs({feature:e,label:t,info:o,messageActivated:n,messageDeactivated:i}){const r=(0,l.useSelect)((t=>t(y.STORE_KEY).isFeatureActive(e)),[]),{toggleFeature:a}=(0,l.useDispatch)(y.STORE_KEY);return(0,g.jsx)(h.MenuItem,{icon:r&&Zi,isSelected:r,onClick:(0,_.flow)(a.bind(null,e),(()=>{r?(0,ms.speak)(i||(0,m.__)("Feature deactivated","kubio")):(0,ms.speak)(n||(0,m.__)("Feature activated","kubio"))})),role:"menuitemcheckbox",info:o,children:t})}const fs=e=>(0,s.convertTemplateFormatToBlock)([e]).map((e=>(0,T.refreshBlockStyleRefs)(e))),{getClientIdsWithDescendants:bs,getBlock:_s}=(0,l.select)("core/block-editor"),vs=(e,t=[])=>{const o=(0,S.getFromGenerationSession)("sectionsGeneratedAnchors",new Set),n=bs().filter((e=>!t.includes(e))).map((e=>{var t,o;return null===(t=_s(e))||void 0===t||null===(o=t.attributes)||void 0===o?void 0:o.anchor})).filter(Boolean).concat([...o]),i=(0,T.slugify)(e);let r=0,a=i;for(;-1!==n.indexOf(a);)r++,a=`${i}-${r}`;o.add(a),(0,S.setInGenerationSession)("sectionsGeneratedAnchors",o);let s=r?`${e} ${r}`:e;return s=s.split(" ").map(_.upperFirst).join(" "),{name:s,anchor:a}},ys=async({section:e,pageTitle:t,siteContext:o,pageContext:n,generateAnchorAndName:i=!0,isGuest:r,sectionParams:s,pregeneratedStructure:l,shouldUpdateAnchorAndName:c})=>{const u=(0,a.sectionCategoryToLabel)(e.category);let d,p,h;const{name:m,anchor:g}=i?vs(u):{};try{[h,p]=await(0,S.fillSectionTemplate)({...e,pageTitle:t,siteContext:o,pageContext:n,label:m,anchor:g,isGuest:r,sectionParams:s,pregeneratedStructure:l,shouldUpdateAnchorAndName:c}),d=fs(h),d=ks(d,o,n)}catch(e){throw e}return[d,p]},ks=(e,t,o)=>(e=(0,T.cleanFontFamilyFromBlocks)(e),(0,T.walkBlocks)(e,(n=>(0,d.applyFilters)("kubio.ai.generateSectionBlocks.afterBlockGenerated",n,t,o,e))),e),xs=async({clientId:e,sectionCategory:t,pageContext:o,siteContext:n,pageTitle:i,replaceBlocks:r,clearSelectedBlock:a=_.noop,setAIData:s=_.noop,summary:l="",currentSectionCloudId:c=null,usedSections:u=null},d)=>{let p=[];u&&u.items.has(e)&&(p=[...u.items.get(e)]);try{if(!d){Ko.Log.info(`Used sections: ${p.join()||"N/A"} | Section id: ${c}`);const e=(0,S.getPageContentSectionTemplate)({category:t,siteContext:n,returnAll:!0,skipIds:(0,_.isNumber)(c)?[c]:[]});let o=null;const i=e.filter((e=>!p.includes(e.cloudPresetId)));if(i.length)o=i[0],p.push(o.cloudPresetId);else{const t=p.shift();o=e.find((e=>e.cloudPresetId===t))||e[0]}(0,_.isNumber)(c)&&!p.includes(c)&&p.push(c),d=o.template}const[h]=await ys({section:{category:t,template:d,summary:l},pageContext:o,siteContext:n,pageTitle:i});r(e,h);const m=h[0].clientId;if(u){const t=new Map(u.items);t.delete(e),t.set(m,(0,_.uniq)(p)),u.setItems(t)}if(o.isFrontPage&&"cta"===t){const e=(0,T.kubioCloneDeep)(n);(0,_.set)(e,["cta","pattern"],{category:t,template:h.map(T.transformBlockToTemplate),summary:l}),s(e,"siteContext"),(0,S.saveAiGeneralSettings)(e)}window.requestIdleCallback((()=>{a(m)}))}catch(e){Ko.Log.error("contentSectionReplaceDesign",e)}},Ss=async({clientId:e,sectionCategory:t,pageContext:o,siteContext:n,pageTitle:i,replaceBlocks:r,block:a,setAIData:s=_.noop,summary:l="",isGuest:c,sectionParams:u,pregeneratedStructure:d,shouldUpdateAnchorAndName:p})=>{try{const h=(0,T.transformBlockToTemplate)(a),m=await(async({section:e,pageTitle:t,siteContext:o,pageContext:n,includeContent:i=!0,clientId:r,isGuest:a,sectionParams:s,pregeneratedStructure:l,shouldUpdateAnchorAndName:c})=>{const u=e.category.replaceAll(".",""),{name:d,anchor:p}=vs(u,[r]),[h]=await(0,S.rephraseSectionTemplate)({...e,pageTitle:t,siteContext:o,pageContext:n,label:d,anchor:p,includeContent:i,isGuest:a,sectionParams:s,pregeneratedStructure:l,shouldUpdateAnchorAndName:c});let m=fs(h);return m=ks(m,o,n),m})({section:{category:t,template:h,summary:l},pageContext:o,siteContext:n,pageTitle:i,includeContent:!0,clientId:e,isGuest:c,sectionParams:u,pregeneratedStructure:d,shouldUpdateAnchorAndName:p});if(r(e,m),o.isFrontPage&&"cta"===t){const e=(0,T.kubioCloneDeep)(n);(0,_.set)(e,["cta","pattern"],{category:t,template:m.map(T.transformBlockToTemplate),summary:l}),s(e,"siteContext"),(0,S.saveAiGeneralSettings)(e)}}catch(e){Ko.Log.error("contentSectionReplaceContent",e)}},{NAVIGATION:ws,NAVIGATION_TOP_BAR:Cs,NAVIGATION_ITEMS:Is,NAVIGATION_STICKY_ITEMS:js}=(0,We.getNamesOfBlocks)(),Ts=async(e,{pageContext:t,siteContext:o,pageTitle:n,skipNavigationGeneration:i}={})=>{if(e=e.map((e=>(0,lt.cloneBlock)(e))),i){const n=(0,T.transformBlockToTemplate)(e[0]);let i=fs(n);return i=ks(i,o,t),i}const r=[];return(0,s.walkBlockTree)(e,(async e=>{[Cs,Is,js].includes(e.name)&&!i&&r.push((async()=>{try{const[i]=await ys({section:{category:Cs===e.name?"navigation-top-bar":"navigation",template:(0,T.transformBlockToTemplate)(e)},pageTitle:n,siteContext:o,pageContext:t}),{attributes:r,innerBlocks:a}=i[0];v().set(e,"attributes",r),v().set(e,"innerBlocks",a)}catch(t){Ko.Log.error(`Kubio AI section generation error - navigation section: ${e.name}`,t,e)}}))})),await Promise.allSettled(r.map((e=>e()))),e},Ps=async({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,innerBlocks:r,clearSelectedBlock:a=_.noop,isGuest:s,sectionParams:l,pregeneratedStructure:c,skipNavigationGeneration:u=!1,shouldUpdateAnchorAndName:d})=>{const p=r.filter((e=>e.name!==ws)),h=r.filter((e=>[ws].includes(e.name)));for(let r=0;r<p.length;r++){const a=p[r];await Es({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,block:a,isGuest:s,sectionParams:l,pregeneratedStructure:c,shouldUpdateAnchorAndName:d})}for(let r=0;r<h.length;r++){const a=h[r];await Es({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,block:a,isGuest:s,sectionParams:l,pregeneratedStructure:c,skipNavigationGeneration:u,shouldUpdateAnchorAndName:d})}a()},Es=async({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,block:r,isGuest:a,sectionParams:s,pregeneratedStructure:l,skipNavigationGeneration:c,shouldUpdateAnchorAndName:u})=>{try{const d=(0,T.transformBlockToTemplate)(r);if(r.name===ws){const[e]=await Ts([r],{pageTitle:n,siteContext:o,pageContext:t,skipNavigationGeneration:c});return void i(r.clientId,e,0)}const[p]=await ys({section:{category:e,template:d},pageContext:t,siteContext:o,pageTitle:n,includeContent:!1,isGuest:a,sectionParams:s,pregeneratedStructure:l,shouldUpdateAnchorAndName:u});i(r.clientId,p,0)}catch(e){Ko.Log.error("headerInnerBlocksReplaceContent",e)}},Rs=()=>(0,g.jsx)(g.Fragment,{children:(0,u.createPortal)((0,g.jsx)("div",{id:"kubio-editor-view",className:"kubio-black-wizard-onboarding__editor-loader",children:(0,g.jsx)(Sa,{})}),document.querySelector("body"))}),As=(0,u.memo)((({message:e,withFooter:t=!0,icon:o=He.KubioAI})=>(0,u.createPortal)((0,g.jsxs)("div",{className:"kubio-ai-page-generator-overlay",children:[(0,g.jsx)(h.Flex,{align:"center",justify:"center",children:(0,g.jsxs)(h.FlexBlock,{children:[(0,g.jsx)(Ue,{className:"kubio-ai-logo-animated kubio-ai-logo-colored",icon:o}),(0,g.jsx)("h2",{children:e})]})}),t&&(0,g.jsx)("div",{className:"kubio-ai-page-generator-overlay__footer",children:(0,g.jsx)("p",{dangerouslySetInnerHTML:{__html:(0,m.sprintf)(// translators: %s is the url to pexels
// translators: %s is the url to pexels
(0,m.__)("The media items like photos and videos are provided by %s","kubio"),"<a href='https://www.pexels.com/' target='_blank'>Pexels</a>")}})})]}),window.document.body))),Os="{sitename}",Ns=()=>(0,d.applyFilters)("kubio.backWizardOnboard.shouldReplacePlaceholderTextOnInsert",!0),Bs={h1:{weight:400},h2:{weight:400},h3:{weight:400},h4:{weight:400},h5:{weight:400},h6:{weight:400}},Ds={family:"Open Sans"},Ms={family:"Merriweather"},Ls={family:"DM Serif Display"},zs={family:"Abril Fatface"},Fs={family:"Poppins"},Gs={family:"IBM Plex Sans Condensed"},Hs={family:"IBM Plex Sans"},Us={family:"Work Sans"},Ws={family:"Oswald"},Vs={family:"Source Sans Pro"},Ks={family:"Yeseva One"},$s={family:"Josefin Sans"},qs={family:"Della Respira"},Ys={family:"DM Sans"},Zs=[v().merge({},{h1:Ls,h2:Ls,h3:Ls,h4:Ls,h5:Ls,h6:Ls,p:Ys,lead:Ys,a:Ys},Bs),v().merge({},{h1:zs,h2:zs,h3:zs,h4:zs,h5:zs,h6:zs,p:Fs,lead:Fs,a:Fs},Bs),v().merge({},{h1:Gs,h2:Gs,h3:Gs,h4:Gs,h5:Gs,h6:Gs,p:Hs,lead:Hs,a:Hs},{h1:{weight:500},h2:{weight:600},h3:{weight:500},h4:{weight:600},h5:{weight:500},h6:{weight:500}}),v().merge({},{h1:Us,h2:Us,h3:Us,h4:Us,h5:Us,h6:Us,p:Ms,lead:Ms,a:Ms},{h1:{weight:700},h2:{weight:700},h3:{weight:500},h4:{weight:700},h5:{weight:500},h6:{weight:500}}),v().merge({},{h1:Ws,h2:Ws,h3:Ws,h4:Ws,h5:Ws,h6:Ws,p:Vs,lead:Vs,a:Vs},{h1:{weight:700},h2:{weight:700},h3:{weight:500},h4:{weight:700},h5:{weight:500},h6:{weight:500}}),v().merge({},{h1:Ks,h2:Ks,h3:Ks,h4:Ks,h5:Ks,h6:Ks,p:$s,lead:$s,a:$s},Bs),v().merge({},{h1:qs,h2:qs,h3:qs,h4:qs,h5:qs,h6:qs,p:Ds,lead:Ds,a:Ds},Bs)],{NAVIGATION:Xs,HERO:Js}=(0,We.getNamesOfBlocks)(),Qs=async()=>{const{getEntityRecords:e}=(0,l.resolveSelect)("core");return(await e("postType","wp_template_part",{per_page:-1})||[]).find((({kubio_template_source:e,slug:t})=>"kubio"===e&&["header","","kubio-header"].includes(t)))||null},el=async(e=!1)=>{const t=await Qs();if(!t)return Ko.Log.error("Inner header not found"),[];let o=[];try{o=(0,lt.parse)((0,_.get)(t,["content","raw"]))}catch(e){Ko.Log.error("Inner header content not ok",e)}return e?o.map(T.transformBlockToTemplate):o},tl=async(e,t,o,n,i=!1,r=null,a=null,s=!0)=>{let c=[];const u=await Qs();if(!u)return;const p=v().get(e,"2",[]),h=(0,T.kubioCloneDeep)(p.find((e=>e[0]===Xs)));let m=(0,T.kubioCloneDeep)(p.find((e=>e[0]===Js)));if(h&&(c=ks(c.concat((0,_.castArray)(fs(h))),o,n)),m){m=(0,d.applyFilters)("kubio.ai.generateSectionBlocks.beforeBlockGenerated",m);const[e]=await ys({section:{category:"hero",template:m},pageTitle:t,siteContext:o,pageContext:n,pregeneratedStructure:a,isGuest:i,sectionParams:r,shouldUpdateAnchorAndName:s});c=c.concat((0,_.castArray)(e))}if((0,_.isEmpty)(c))return;const g={blocks:c,content:({blocks:e=[]})=>(0,lt.__unstableSerializeAndClean)(e)},{editEntityRecord:f}=(0,l.dispatch)("core");f("postType","wp_template_part",u.id,g)},ol=(0,T.getBackendData)("importDesignIndex"),nl=e=>{const t=(0,T.getBackendData)("importDesignAiStructure");return null==t?void 0:t[e]},il=e=>t=>Array.isArray(t)?(t.forEach((t=>{var o,n;const i=e;null!=t&&null!==(o=t.content)&&void 0!==o&&null!==(n=o.includes)&&void 0!==n&&n.call(o,Os)&&i&&Ns()&&(t.content=t.content.replace(Os,i))})),t):t,rl=async e=>{const t=v().merge({retries:1},e),{sections:o,retries:n,setCurrentlyGeneratingMessage:i,pageTitle:r,siteContext:a,pageContext:s,currentTheme:l,initialBusinessName:c,colorSchemeAndTypography:u,categories:d,websiteType:p}=t;i((0,m.__)("Tailoring page structure","kubio"));let h=null;try{h=await(0,S.getDefaultHomepageSectionsSummariesByAnchor)({pageTitle:r,siteContext:a,pageContext:s,theme:l,importDesignIndex:ol,colorSchemeAndTypography:u,retries:n})}catch(e){console.error(e)}return v().isEmpty(h)?n>0?rl({...t,retries:n-1}):o:ll({sectionBlocks:o,summariesByAnchor:h,initialBusinessName:c,categories:d,websiteType:p})},al=({activePaletteColors:e,mergedPalettes:t})=>{let o={label:"Theme defaults",value:e.map((e=>`rgb(${e.color.join(",")})`))};return t.forEach(((t,n)=>{if((0,T.getColorPalettesAreEqual)(null==t?void 0:t.colors,e)){const e=null!=t&&t.isCustom?"Theme defaults":`Preset ${n+1}`;o={label:e,value:t.colors.map((e=>`rgb(${e.color.join(",")})`))}}})),o},sl=({bodyTypographyHolders:e})=>{const t=v().get(e,"h1.family"),o=v().get(e,"p.family");let n={};return n={label:"Theme defaults",value:[t,o]},Zs.forEach(((e,i)=>{const r=v().get(e,"h1.family"),a=v().get(e,"p.family");if(r===t&&a===o){const e=`Preset ${i+2}`;n.label=e}})),n},ll=({sectionBlocks:e,summariesByAnchor:t,initialBusinessName:o,categories:n,websiteType:i})=>{e.forEach((e=>{const n=v().get(e,"attributes.anchor");let i=v().get(t,`${n}.summary`,"");Ns()&&(i=i.replace(Os,o));const r=v().get(t,`${n}.category`,"");v().set(e,"attributes.kubioAI.meta.category",r),v().set(e,"attributes.kubioAI.meta.summary",i)}));const r=e.map((e=>({category:v().get(e,"attributes.kubioAI.meta.category"),template:(0,T.transformBlockToTemplate)(e)}))),{pageStructure:a,unusedCategories:s}=(0,S.onAddCategoriesMetaToPageStructure)({pageStructure:r,categories:n,websiteType:i});return a.map((e=>(0,T.transformTemplateToBlock)(e.template)))},cl=e=>{const t="kubio/header"===e.name,o=e.attributes,n=t?"hero":"section";let i=(v().get(o,"anchor",n)||n).replace(/\-\d+/,"");i=(0,S.normalizeCategorySlug)(i);const r=v().get(o,"kubioAI.meta.category",i);if(!S.allowedSections.includes(r)){if(r.includes("service"))return"features";if(r.includes("project"))return"portfolio";if(r.includes("hero"))return"hero";if(r.includes("number"))return"counters"}return r},ul=()=>{const e=document.querySelector(".kubio-iframe");return null==e?void 0:e.contentDocument},dl="kubio-black-wizard-onboarding-generating",pl=()=>{ul().body.classList.remove(dl)},hl="generated",ml=["cta","website-main-cta-section"];class gl{constructor({generateFunction:e,ownerDocument:t,notify:o,sections:n,customNotifier:i,generateFunctionExtraParams:r={},showAnimation:a=!0}){bt(this,"generateFunction",void 0),bt(this,"queue",[]),bt(this,"insertedSections",[]),bt(this,"queuedSections",new Map),bt(this,"customNotifier",void 0),bt(this,"ownerDocument",void 0),bt(this,"showAnimation",!0),bt(this,"generateFunctionExtraParams",{}),this.notify=o,this.ownerDocument=t,this.generateFunction=e,this.showAnimation=a,this.customNotifier=i,this.generateFunctionExtraParams=r,this.initialize(n)}initialize(e){for(const t of e){let e=t.slug;const o=Xa().generate();ml.includes(t.category)||(e=`${t.slug}::${o}`),this.queuedSections.set(e,{id:o,itemSlug:t.slug,category:t.category,section:t,block:t.block,inserted:!1,status:null,isHeader:t.isHeader,contentIndex:t.contentIndex,isVisible:!1}),this.queue.push(e)}}async start(){this.hideSections(),this.generate(),await this.showGeneratedSectionsInOrder(),this.removeStyleNode()}hideSections(){this.updateHideSectionStyle()}getStyleNode(){let e=this.ownerDocument.querySelector("style[data-black-wizard-sections-style]");return e||(e=document.createElement("style"),e.setAttribute("data-black-wizard-sections-style",!0),this.ownerDocument.head.append(e)),e}removeStyleNode(){var e,t;const o=this.getStyleNode();o&&(null==o||null===(e=o.parentNode)||void 0===e||null===(t=e.removeChild)||void 0===t||t.call(e,o))}updateHideSectionStyle(){const e=[];let t=" ";this.queuedSections.forEach((t=>{if(!t.isVisible)return;if(t.isHeader)return void e.push('[data-type="kubio/header"]:not(#extra-1)');const o=t.contentIndex;e.push(`[data-type="core/post-content"]:not(#extra-1) [data-type="kubio/section"]:nth-child(${o+1})`)})),t+=e.join(",")+" { opacity: 1 !important;}",this.getStyleNode().innerHTML=t}async generateSection(e){const t=this.queuedSections.get(e);if(null===t.status)try{this.logInfo((0,m.sprintf)("Start tailoring - %1$s ( %2$s )",t.itemSlug,t.id)),this.queuedSections.set(e,{...t,status:"generating"}),await this.generateFunction({block:t.block,...this.generateFunctionExtraParams}),this.queuedSections.set(e,{...t,status:hl})}catch(o){this.queue.map(((t,o)=>t===e?o:-1)).filter((e=>e>=0)).forEach((e=>this.queue.splice(e,1))),this.logError("Kubio AI section generation error",o,t.section)}}async generate(e){e&&this.notify((0,m.__)("Preparing page content","kubio"));const t=this.queue[0],o=this.queue.slice(1);await this.executeChunk([t]);const n=(0,_.chunk)(o,4);for(const e of n)await this.executeChunk(e)}async executeChunk(e){await Promise.allSettled(e.map(((e,t)=>this.generateSection(e,t)))),this.showAnimation&&await(0,T.sleep)(1e3)}getInsertedSections(){return this.insertedSections}async showGeneratedSectionsInOrder(){const e=this.queue[0],t=this.queuedSections.get(e);if(this.showAnimation){const e=this.customNotifier&&this.customNotifier(t);this.notify(e||((e="")=>(0,m.sprintf)(// translators: %s section name
// translators: %s section name
(0,m.__)('Tailoring "%s" section',"kubio"),(0,a.sectionCategoryToLabel)(e)))(t.category))}else this.notify("Tailoring content sections");return t.status!==hl?(await(0,T.sleep)(200),await this.showGeneratedSectionsInOrder()):(this.queue.shift(),this.logInfo((0,m.sprintf)("Inserted - %1$s ( %2$s )",t.itemSlug,t.id)),this.showAnimation&&(await this.showSection(e,t),await(0,T.sleep)(700)),this.queue.length?await this.showGeneratedSectionsInOrder():void 0)}async showSection(e,t){this.queuedSections.set(e,{...t,isVisible:!0});const o=t.isHeader,n=t.contentIndex,i=o?'[data-type="kubio/header"]':`[data-type="core/post-content"] [data-type="kubio/section"]:nth-child(${n+1})`,r=this.ownerDocument.querySelector(i);r&&r.scrollIntoView({behavior:"smooth",block:"center"}),await(0,T.sleep)(500),this.updateHideSectionStyle()}logInfo(e,...t){Ko.Log.info(`[SectionsQueue] ${e}`,...t)}logError(e,...t){Ko.Log.error(`[SectionsQueue] ${e}`,...t)}}function fl(e){var t,o,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(o=fl(e[t]))&&(n&&(n+=" "),n+=o)}else for(o in e)e[o]&&(n&&(n+=" "),n+=o);return n}const bl=function(){for(var e,t,o=0,n="",i=arguments.length;o<i;o++)(e=arguments[o])&&(t=fl(e))&&(n&&(n+=" "),n+=t);return n},_l=({className:e,error:t,children:o})=>(0,g.jsx)("div",{className:bl(e,"kubio-black-wizard-onboarding__control",{"kubio-black-wizard-onboarding__control--with-error":t}),children:o});_l.Label=({children:e})=>(0,g.jsx)("label",{children:e}),_l.Error=({children:e})=>(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__control__error",children:e});const vl=({typography:e,onClick:t,activeTypography:o})=>{const n=o,i=e,r=i.h1.family,a={fontFamily:r},s=i.p.family,l={fontFamily:s},c=v().get(n,"h1.family"),d=v().get(n,"p.family"),p=(0,u.useRef)(),h=(0,u.useRef)(),m=(0,u.useCallback)((()=>{var e;null!==(e=p.current)&&void 0!==e&&e.rel&&(p.current.rel="stylesheet")}),[]),f=(0,u.useCallback)((()=>{var e;null!==(e=h.current)&&void 0!==e&&e.rel&&(h.current.rel="stylesheet")}),[]),b=c===r&&d===s;return(0,g.jsxs)("div",{className:bl("kubio-black-wizard-onboarding__typography__item",{"kubio-black-wizard-onboarding__typography__item--active":b}),onClick:()=>{t(e)},"aria-hidden":"true",children:[(0,g.jsx)("link",{href:`https://fonts.googleapis.com/css?family=${r}&display=swap`,rel:"preload",as:"style",ref:p,onLoad:m}),(0,g.jsx)("link",{href:`https://fonts.googleapis.com/css?family=${s}&display=swap`,rel:"preload",as:"style",ref:h,onLoad:f}),(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__typography__item__background",children:(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__typography__item__inner",children:[(0,g.jsx)("span",{style:a,children:"Aa"}),(0,g.jsx)("span",{style:l,children:"Bb"})]})})]})},yl=({typographyList:e,onClick:t,activeTypography:o})=>(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__typography__list",children:e.map(((e,n)=>(0,g.jsx)(vl,{typography:e,onClick:t,activeTypography:o},n)))}),kl=()=>{const{typographyList:e,onSelectPreset:t,bodyTypographyHolders:o}=xl();return(0,g.jsxs)(_l,{children:[(0,g.jsx)(_l.Label,{children:(0,m.__)("Typography","kubio")}),(0,g.jsx)(yl,{typographyList:e,onClick:t,activeTypography:o})]})},xl=()=>{const{mergedPresets:e,bodyTypographyHolders:t,onSelectPreset:o}=Hr({typographyPresets:Zs});return{bodyTypographyHolders:t,typographyList:(0,u.useMemo)((()=>e),[e]),onSelectPreset:o}},Sl=[{label:(0,m.__)("Color Scheme 1","kubio"),colors:[{slug:"kubio-color-1",color:[16,111,95]},{slug:"kubio-color-2",color:[30,132,115]},{slug:"kubio-color-3",color:[83,164,150]},{slug:"kubio-color-4",color:[244,119,40]},{slug:"kubio-color-5",color:[255,255,255]},{slug:"kubio-color-6",color:[40,44,43]}]},{label:(0,m.__)("Color Scheme 2","kubio"),colors:[{slug:"kubio-color-1",color:[65,70,243]},{slug:"kubio-color-2",color:[96,101,255]},{slug:"kubio-color-3",color:[132,135,242]},{slug:"kubio-color-4",color:[22,226,175]},{slug:"kubio-color-5",color:[255,255,255]},{slug:"kubio-color-6",color:[38,38,44]}]},{label:(0,m.__)("Color Scheme 3","kubio"),colors:[{slug:"kubio-color-1",color:[206,28,202]},{slug:"kubio-color-2",color:[238,99,232]},{slug:"kubio-color-3",color:[245,178,211]},{slug:"kubio-color-4",color:[105,54,104]},{slug:"kubio-color-5",color:[255,255,255]},{slug:"kubio-color-6",color:[28,29,31]}]},{label:(0,m.__)("Color Scheme 4","kubio"),colors:[{slug:"kubio-color-1",color:[217,34,34]},{slug:"kubio-color-2",color:[245,127,127]},{slug:"kubio-color-3",color:[247,221,212]},{slug:"kubio-color-4",color:[92,145,58]},{slug:"kubio-color-5",color:[244,244,247]},{slug:"kubio-color-6",color:[41,46,56]}]},{label:(0,m.__)("Color Scheme 5","kubio"),colors:[{slug:"kubio-color-1",color:[251,133,0]},{slug:"kubio-color-2",color:[255,172,79]},{slug:"kubio-color-3",color:[255,233,207]},{slug:"kubio-color-4",color:[184,196,203]},{slug:"kubio-color-5",color:[255,255,255]},{slug:"kubio-color-6",color:[59,60,77]}]},{label:(0,m.__)("Color Scheme 6","kubio"),colors:[{slug:"kubio-color-1",color:[129,37,208]},{slug:"kubio-color-2",color:[142,59,213]},{slug:"kubio-color-3",color:[169,107,221]},{slug:"kubio-color-4",color:[251,129,69]},{slug:"kubio-color-5",color:[255,255,255]},{slug:"kubio-color-6",color:[35,35,38]}]},{label:(0,m.__)("Color Scheme 7","kubio"),colors:[{slug:"kubio-color-1",color:[230,176,46]},{slug:"kubio-color-2",color:[238,207,114]},{slug:"kubio-color-3",color:[250,235,188]},{slug:"kubio-color-4",color:[186,219,215]},{slug:"kubio-color-5",color:[255,255,255]},{slug:"kubio-color-6",color:[65,64,68]}]}],wl=({palette:e,onClick:t,activePaletteColors:o})=>{const n=(0,u.useMemo)((()=>{var t,o;return null==e||null===(t=e.colors)||void 0===t||null===(o=t.slice)||void 0===o?void 0:o.call(t,0,3)}),[e]),i=(0,u.useMemo)((()=>(0,T.getColorPalettesAreEqual)(null==e?void 0:e.colors,o)),[o,e]);if(3!==n.length)return;const r=v().get(n,0),a=v().get(n,1),s=v().get(n,2);return(0,g.jsx)("div",{className:bl("kubio-black-wizard-onboarding__color-scheme__item",{"kubio-black-wizard-onboarding__color-scheme__item--active":i}),onClick:()=>{t(e)},"aria-hidden":"true",children:(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__color-scheme__item__background",children:(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__color-scheme__item__inner",children:[(0,g.jsx)(h.ColorIndicator,{colorValue:`rgb(${r.color.join(",")})`}),(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__color-scheme__color-wrapper",children:[(0,g.jsx)(h.ColorIndicator,{colorValue:`rgb(${a.color.join(",")})`}),(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__color-scheme__color-wrapper",children:(0,g.jsx)(h.ColorIndicator,{colorValue:`rgb(${s.color.join(",")})`})})]})]})})})},Cl=({paletteList:e,onClick:t,activePaletteColors:o})=>(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__color-scheme__list",children:e.map(((e,n)=>(0,g.jsx)(wl,{palette:e,onClick:t,activePaletteColors:o},n)))}),Il=()=>{const{mergedPalettes:e,onHandleClick:t,activePaletteColors:o}=jl();return(0,g.jsxs)(_l,{children:[(0,g.jsx)(_l.Label,{children:(0,m.__)("Color Scheme","kubio")}),(0,g.jsx)(Cl,{paletteList:e,onClick:t,activePaletteColors:o})]})},jl=()=>{const{onHandleClick:e,activePaletteValue:t}=$r(),o=(0,u.useMemo)((()=>t),[]),{mergedPalettes:n}=(0,u.useMemo)((()=>({mergedPalettes:[{label:(0,m.__)("Theme colors","kubio"),isCustom:!0,colors:o}].concat(Sl)})),[o]);return{mergedPalettes:n,onHandleClick:e,activePaletteColors:t}},Tl=({pluginsList:e,setPluginsList:t})=>v().isEmpty(e)?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__user-preferences-modal__plugins",children:[(0,g.jsxs)(h.BaseControl,{children:[(0,g.jsx)(h.BaseControl.VisualLabel,{children:(0,m.__)("The following features will be installed:","kubio")}),(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__user-preferences-modal__content__description",children:(0,m.__)("The following plugins will be installed to add features that are needed for this type of website.","kubio")}),e.map(((o,n)=>{const{label:i,checked:r,description:a}=o;return(0,g.jsxs)(h.BaseControl,{children:[(0,g.jsx)(h.CheckboxControl,{__nextHasNoMarginBottom:!0,label:i,onChange:()=>{const o=v().cloneDeep(e);v().set(o,`${n}.checked`,!r),t(o)},checked:r}),(0,g.jsx)("p",{className:"kubio-black-wizard-onboarding__user-preferences-modal__checkbox-description ",children:a})]},n)}))]}),(0,g.jsx)("hr",{})]}),Pl=({siteContext:e,generateFrontPage:t,setGenerateFrontPage:o})=>{const n=null==e?void 0:e.industry;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.BaseControl,{className:"kubio-black-wizard-onboarding__user-preferences-modal__generate-toggle",children:[(0,g.jsx)(h.CheckboxControl,{checked:t,label:(0,m.__)("Home page with tailored content","kubio"),onChange:()=>o(!t)}),(0,g.jsx)("p",{className:"kubio-black-wizard-onboarding__user-preferences-modal__checkbox-description",dangerouslySetInnerHTML:{__html:(0,m.sprintf)((0,m.__)("Our AI will create a first draft of home page content specific for the <strong>%s</strong> industry","kubio"),`<strong>${n}</strong>`)}})]}),(0,g.jsx)("hr",{})]})},El=({pagesList:e,setPagesList:t})=>v().isEmpty(e)?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.BaseControl,{children:[(0,g.jsx)(h.BaseControl.VisualLabel,{children:(0,m.__)("The following pages will be created:","kubio")}),e.map(((o,n)=>{const{label:i,checked:r}=o;return(0,g.jsx)(h.BaseControl,{children:(0,g.jsx)(h.CheckboxControl,{__nextHasNoMarginBottom:!0,label:i,onChange:()=>{const o=v().cloneDeep(e);v().set(o,`${n}.checked`,!r),t(o)},checked:r})},n)}))]}),(0,g.jsx)("hr",{})]}),Rl=({siteContext:e,onFinish:t,onApplySettingWithoutGenerating:o,onCancel:n,importDesignIndex:i,theme:r,sectionsBlocks:a})=>{const[l,c]=(0,u.useState)(!0),[p,f]=(0,u.useState)([]),[b,_]=(0,u.useState)(!1),[k,x]=(0,u.useState)(!1),[w,C]=(0,u.useState)((e=>(e=>{const t={"kubio/contact":y.DEFAULT_PLUGIN_FOR_PURPOSE.CONTACT_FORM,"kubio/subscribe-form":y.DEFAULT_PLUGIN_FOR_PURPOSE.SUBSCRIBE_FORM},o=Object.keys(t),n=[];return(0,s.walkBlockTree)(e,(e=>{if(null!=o&&o.includes(null==e?void 0:e.name)){const o=null==t?void 0:t[null==e?void 0:e.name];o&&!n.includes(n)&&n.push(o)}})),n})(e).map((e=>{var t,o;return{value:e,label:(null===y.THIRD_PARTY_PLUGINS_DETAILS||void 0===y.THIRD_PARTY_PLUGINS_DETAILS||null===(t=y.THIRD_PARTY_PLUGINS_DETAILS[e])||void 0===t?void 0:t.label)||e,checked:!0,description:(null===y.THIRD_PARTY_PLUGINS_DETAILS||void 0===y.THIRD_PARTY_PLUGINS_DETAILS||null===(o=y.THIRD_PARTY_PLUGINS_DETAILS[e])||void 0===o?void 0:o.description)||""}})))(a)),I=(0,d.applyFilters)("kubio.guestAiGeneration.userPreferencesAutoContinue",!1),j=async()=>{x(!0),l||await(0,T.sleep)(100);const e=p.filter((e=>e.checked)).map((e=>e.label)),n=w.filter((e=>e.checked)).map((e=>e.value)),i={generateFrontPage:l,pageNamesToGenerate:e,pluginsNamesToActivate:n};(e=>{e.forEach((({checked:e,value:t})=>{if(e)return;const o=t;(0,T.onToggleAllowPluginToInstall)(o,!1)}))})(w),l?t(i):o(i)};return(0,u.useEffect)((()=>{b&&I&&setTimeout((()=>{j()}),200)}),[b]),(0,u.useEffect)((()=>{try{(async()=>{try{const t=(await(0,S.generateSiteStructure)({siteContext:v().omit(e,"otherPages"),theme:r,importDesignIndex:i})).map((e=>({label:e,checked:!0})));f(t)}catch(e){console.error(e)}finally{_(!0)}})()}catch(e){console.error(e)}}),[]),!b||I?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)(h.Modal,{title:(0,m.__)("Here's how we will tailor your website","kubio"),className:"kubio-black-wizard-onboarding__user-preferences-modal",shouldCloseOnClickOutside:!1,onRequestClose:n,shouldCloseOnEsc:!1,isDismissible:!1,children:[(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__user-preferences-modal__content",children:[(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__user-preferences-modal__content__description",children:(0,m.__)("You can deselect any of the suggested customizations if you don't think they would fit your website.","kubio")}),(0,g.jsx)(Pl,{siteContext:e,generateFrontPage:l,setGenerateFrontPage:c}),(0,g.jsx)(El,{pagesList:p,setPagesList:f}),(0,g.jsx)(Tl,{pluginsList:w,setPluginsList:C})]}),(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__user-preferences-modal__footer",children:[(0,g.jsx)(h.Button,{isLink:!0,onClick:n,children:(0,m.__)("Skip","kubio")}),(0,g.jsx)(h.Button,{variant:"primary",onClick:j,isBusy:k,children:(0,m.__)("Continue","kubio")})]})]})};let Al=!1,Ol=!1;const Nl=(0,T.getBackendData)("importDesignIndex"),Bl=({onFinish:e})=>{const[t,o]=(0,u.useState)((0,m.__)("","kubio")),[n,i]=(0,u.useState)(!1),r=(0,u.useMemo)((()=>{const e=document.querySelector(".kubio-iframe");return null==e?void 0:e.contentDocument}),[]),[a,c]=(0,u.useState)(),[p,h]=(0,u.useState)(!1),[f,b]=(0,S.useAIData)(),{pageContext:_,siteContext:k,pageTitle:x,getAIDataInRealTime:C,frontPageEntity:I}=f,{replaceBlocks:P,replaceInnerBlocks:E}=(0,l.useDispatch)("core/block-editor"),R=(0,u.useMemo)((()=>({language:"en_US",...k,business_name:Os})),[k]),A=null==R?void 0:R.structure_type,O=!!v().get(k,"industry");(0,u.useEffect)((()=>{O||e()}),[]);const N=(0,u.useMemo)((()=>null==k?void 0:k.business_name),[]),{postContentClientId:B,contentSectionsBlocks:D,currentTheme:M}=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlocks:n}=e("core/block-editor"),{currentPageHasFSETemplate:i}=e(y.STORE_KEY)||{},r=null==i?void 0:i();let a=null;const s=e("core").getCurrentTheme().stylesheet;return r&&(a=t().find((e=>{var t;return"core/post-content"===(null===(t=o(e))||void 0===t?void 0:t.name)})),a)?{postContentClientId:a,contentSectionsBlocks:n(a),currentTheme:s}:{postContentClientId:null,contentSectionsBlocks:[],currentTheme:s}}),[]),L=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlocks:n}=e("core/block-editor"),i=(e=>{const n=v().castArray("kubio/header"),i=t().map((e=>o(e))).find((e=>n.includes(e.name)));return null==i?void 0:i.clientId})();return i?o(i):null}),[]),{setPalette:z}=(0,w.useGlobalDataColors)(),{globalStyle:F}=(0,w.useGlobalDataStyle)(),{editEntityRecord:G,saveEntityRecord:H}=(0,l.useDispatch)("core"),{setLogoImage:U}=(0,w.useSiteLogoImages)(),[,W]=(0,j.useEntityProp)("root","site","title"),{getBlockOrder:V,getBlock:K}=(0,l.select)("core/block-editor"),$=(0,u.useRef)(),q=async({block:e,siteContext:t,pageContext:n,categoryWithSavedItems:i})=>{await Ml({block:e,siteContext:t,pageContext:n,pageTitle:x,setCurrentlyGeneratingMessage:o,websiteType:A});const{clientId:a}=e,s=null==r?void 0:r.querySelector(`[data-block="${a}"]`);if(!s)return;$.current||($.current=s);const l=(({block:e,siteContext:t,pageContext:o,categoryWithSavedItems:n})=>{var i,r,a,s;const l="kubio/header"===e.name,c={};let u=null==e||null===(i=e.attributes)||void 0===i?void 0:i.anchor;if(l){var d,p;c.innerBlocks=(0,T.kubioCloneDeep)(V(e.clientId).map(K));const t=null===(d=c.innerBlocks)||void 0===d?void 0:d[1];u=null==t||null===(p=t.attributes)||void 0===p?void 0:p.anchor,n&&v().set(t,["attributes","kubioAI","meta","blogCategoryAttributes"],n)}return{sectionCategory:cl(e),clientId:e.clientId,pageContext:o,siteContext:t,pageTitle:x,replaceBlocks:P,block:e,setAIData:b,summary:null==e||null===(r=e.attributes)||void 0===r||null===(a=r.kubioAI)||void 0===a||null===(s=a.meta)||void 0===s?void 0:s.summary,isGuest:!0,sectionParams:{anchor:u,theme:M,importDesignIndex:Nl},pregeneratedStructure:nl(u),shouldUpdateAnchorAndName:!1,...c}})({block:e,siteContext:t,pageContext:n,categoryWithSavedItems:i});if(null==l?void 0:l.pregeneratedStructure){try{"kubio/header"===e.name?await Ps({...l,skipNavigationGeneration:!0}):await Ss(l)}catch(e){console.error(e)}"about"===l.sectionCategory&&(async({siteContext:e,pageContext:t,pageTitle:o,currentTheme:n}={})=>{const i=nl(y.INNER_HERO_ANCHOR);if(!i)return;const r=await el();v().set(r,"1.attributes.anchor",y.INNER_HERO_ANCHOR);const a={anchor:y.INNER_HERO_ANCHOR,theme:n,importDesignIndex:ol},s=["kubio/header",{},r.map(T.transformBlockToTemplate)];tl(s,o,e,t,!0,a,i,!1)})({siteContext:t,pageContext:n,pageTitle:x,currentTheme:M})}},{bodyTypographyHolders:Y}=xl(),{activePaletteColors:Z,mergedPalettes:X}=jl(),{setItems:J}=(0,co.usePrimaryMenuBlockEditor)(),{saveEditedEntityRecord:Q}=(0,l.useDispatch)("core"),ee=(0,u.useMemo)((()=>{var e;let t=null==k||null===(e=k.customizerData)||void 0===e?void 0:e.colorScheme;return t?(t=v().cloneDeep(t),t=t.map((e=>({...e,color:e.color.map((e=>parseInt(e)))}))),t):null}),[]),te=(0,u.useMemo)((()=>{var e;return null===(e=k.customizerData)||void 0===e?void 0:e.typography}),[]),oe=async()=>{var e;const t=C(),{pageContext:o,siteContext:n,pageTitle:i,record:r,isFrontPage:a}=t;G("postType",r.type,r.id,{meta:{saved_in_kubio:!0},title:i,kubio_ai_page_context:o}),null!==(e=n.website_logo)&&void 0!==e&&e.id&&U(n.website_logo.id),N&&W(N),ee&&z(ee),te&&F.setStyle("typography.holders",v().cloneDeep(te),{styledComponent:"body",media:"desktop"})},ne=async()=>{await(0,T.sleep)(2e3);const{getEntityRecordEdits:e,__experimentalGetDirtyEntityRecords:t}=(0,l.resolveSelect)("core"),o=(await t()).filter((e=>!("root"===e.kind&&"site"===e.name))),n=await e("root","site"),i=[];for(const e in n)i.push({kind:"root",name:"site",property:e});const r=[...o,...i];for(const e of r)await Q(e.kind,e.name,e.key)},ie=()=>{Al=!1,top.skipSaveAiData=!1,(0,d.removeFilter)("kubio.rephraseSectionTemplate.onReplacePlaceholderTextsFromAi","blackWizardGenerator"),(0,d.removeFilter)("kubio.fillSectionTemplate.beforeFillSectionContent","blackWizardGenerator"),(0,d.removeFilter)("kubio.aiFetch.isGuest","blackWizardGenerator"),pl(),(0,d.removeFilter)("kubio.aiFetch.prefetchedResponse","blackWizardGenerator")},re=e=>{const t={localAIData:{...f,siteContext:R},frontPageEntity:I,setMenuItems:J,blogPageEntity:f.blogPageEntity,addBlogToMenu:!0,theme:M,importDesignIndex:Nl,setCurrentlyGeneratingMessage:o,generatingMessage:(0,m.__)("Preparing site structure","kubio"),pageNamesPregenerated:e,usePregeneratedInnerPages:!0};switch(A){case y.WEBSITE_TYPES.MULTIPAGE:return(0,S.createSiteStructureAndUpdateMenu)(t);case y.WEBSITE_TYPES.BLOG:return(0,S.createSiteStructureAndUpdateMenuForBlog)(t)}},ae=()=>{const e=(({bodyTypographyHolders:e,activePaletteColors:t,mergedPalettes:o})=>({typography:sl({bodyTypographyHolders:e}),colorScheme:al({activePaletteColors:t,mergedPalettes:o})}))({bodyTypographyHolders:te||Y,activePaletteColors:ee||Z,mergedPalettes:X});return e};(0,u.useLayoutEffect)((()=>{try{!Al&&O&&(Al=!0,ul().body.classList.add(dl),top.skipSaveAiData=!0,(0,d.addFilter)("kubio.aiFetch.isGuest","blackWizardGenerator",(e=>!0)),i(!0))}catch(e){console.error(e)}}),[]);const se=async()=>{await oe(),ie();const t=(0,T.kubioCloneDeep)(C());v().set(t,"siteContext.business_name",N),v().unset(t,"siteContext.customizerData"),b(t),(0,S.saveAiGeneralSettings)(t.siteContext),e(),i(!1),ne()},{retrieve:le}=(0,We.useContactFormApi)();if((0,u.useEffect)((()=>{p||(async()=>{const e=ae();let t;try{t=await(0,S.getGeneratedDataStoredInTheDatabase)({pageTitle:x,siteContext:k,pageContext:_,theme:M,colorSchemeAndTypography:e,importDesignIndex:Nl})}catch(e){console.error(e)}v().isEmpty(t)||((e={})=>{(0,d.addFilter)("kubio.aiFetch.prefetchedResponse","blackWizardGenerator",((t,{endpoint:o,...n})=>{var i,r;switch(o){case"get-default-homepage-sections-used-images":const t=null==e?void 0:e.images;if(!v().isEmpty(t))return t;break;case"get-default-homepage-sections-summaries-by-anchor":const o=null==e?void 0:e.summaries;if(!v().isEmpty(o))return o;break;case"generate-section-content":case"rephrase-section-content":const a=null==e?void 0:e.sections,s=null==n||null===(i=n.sectionParams)||void 0===i?void 0:i.anchor,l=null==a?void 0:a[s];if(!v().isEmpty(l))return l;break;case"generate-site-structure":let c=null==e?void 0:e.innerPages;if(!v().isEmpty(c))return c;if(c=null==e||null===(r=e.generatedPage)||void 0===r?void 0:r.innerPages,!v().isEmpty(c))return c}return t}),9999,2)})(t),c(t),h(!0)})()}),[]),!O)return(0,g.jsx)(g.Fragment,{});const ce=[L,...D].filter(Boolean);return n?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Rs,{}),p&&(0,g.jsx)(Rl,{sectionsBlocks:ce,siteContext:k,theme:M,importDesignIndex:Nl,onFinish:t=>{if(Ol)return;Ol=!0;const{pageNamesToGenerate:n}=t;i(!1);try{(async({pageNamesToGenerate:t})=>{top.isInitialBlackWizardOnboardingGenerating=!0,oe();const n=ae(),i=null==a?void 0:a.generatedPage;v().isEmpty(null==i?void 0:i.content),await(async({pageNamesToGenerate:t,colorSchemeAndTypography:n,pregeneratedData:i})=>{var a,s;let l=(0,T.kubioCloneDeep)(R),c=[],u=[],p=null,h=!1;const g=(0,S.initGenerationSession)();let f=D,w={};try{w=await re(t)}catch(e){console.error(e)}u=null===(a=w)||void 0===a?void 0:a.pages,c=null===(s=w)||void 0===s?void 0:s.categories,p=w.categoryWithSavedItems,l={...l,otherPages:u,categories:c};let I=(0,T.kubioCloneDeep)(C());I={...I,siteContext:l},top.skipSaveAiData=!1,(0,S.saveAiGeneralSettings)(I.siteContext),b(I),top.skipSaveAiData=!0;try{const e=rl({sections:D,setCurrentlyGeneratingMessage:o,pageTitle:x,siteContext:l,pageContext:_,currentTheme:M,initialBusinessName:N,colorSchemeAndTypography:n,categories:c,websiteType:A}),t=await(async({siteContext:e,theme:t,importDesignIndex:o})=>{if(top.kubioGuestAiSkipCache)return!1;const n=await(0,S.getDefaultHomepageSectionsUsedImages)({siteContext:e,theme:t,importDesignIndex:o});return!(v().isEmpty(n)||!Array.isArray(n)||((0,S.initializeAiOnboardingCachedImagesByAnchor)(n),0))})({siteContext:k,theme:M,importDesignIndex:Nl}),[i,r]=await Promise.allSettled([e,t]);"fulfilled"===i.status&&(f=i.value),"fulfilled"===r.status&&(h=r.value),E(B,f)}catch(e){console.error(e)}const j=[L,...f].filter(Boolean);(0,d.addFilter)("kubio.rephraseSectionTemplate.beforeFillSectionContent","blackWizardGenerator",il(N)),(0,d.addFilter)("kubio.fillSectionTemplate.beforeFillSectionContent","blackWizardGenerator",il(N));try{const e=(null==i?void 0:i.sections)||{};let t=!0;const n=j.map(((o,n)=>{var i;let r=null==o||null===(i=o.attributes)||void 0===i?void 0:i.anchor;const a="kubio/header"===o.name;if(a){var s;const e=V(o.clientId).map(K),t=null==e?void 0:e[1];r=null==t||null===(s=t.attributes)||void 0===s?void 0:s.anchor}return r&&null!=e&&e[r]||(t=!1),{isHeader:a,index:n,block:o,category:cl(o),slug:r,contentIndex:a?0:n-1}})),a=e=>{const t=v().get(e,"block.attributes.kubioAI.meta.blogCategoryAttributes",!1);return t?(0,m.sprintf)(/* translators: %s: category name */ /* translators: %s: category name */(0,m.__)("Generating section for articles in %s category","kubio"),t.title):null};let s=null;A===y.WEBSITE_TYPES.BLOG&&(s=a);const c=new gl({generateFunction:q,ownerDocument:r,notify:o,sections:n,customNotifier:s,generateFunctionExtraParams:{siteContext:l,pageContext:_,categoryWithSavedItems:p}});await c.start()}catch(e){console.error(e)}(0,d.removeFilter)("kubio.rephraseSectionTemplate.onReplacePlaceholderTextsFromAi","blackWizardGenerator"),(0,d.removeFilter)("kubio.fillSectionTemplate.beforeFillSectionContent","blackWizardGenerator"),pl(),r.body.scrollIntoView({behavior:"smooth",block:"start"});try{(({siteContext:e,theme:t,importDesignIndex:o})=>{const n=(0,S.getFromGenerationSession)("previousQueries",new Map),i=v().cloneDeep(n),r=Object.fromEntries(i);let a=!1;const s={};v().each(r,((e,t)=>{if(v().isEmpty(e.items))return void(a=!0);const o=e.items.slice(0,15);s[t]=o}));const l=(0,S.getAiOnboardingAllCachedImages)();(0,S.initializeAiOnboardingCachedImagesByAnchor)([]),(0,S.updateDefaultHomepageSectionsUsedImages)({siteContext:e,theme:t,importDesignIndex:o,content:JSON.stringify(s),content:JSON.stringify(l)})})({siteContext:k,theme:M,importDesignIndex:Nl})}catch(e){console.error(e)}const P=(0,T.kubioCloneDeep)(C());v().set(P,"siteContext.business_name",N),v().set(P,"siteContext.otherPages",u),v().unset(P,"siteContext.customizerData"),ie(),b(P),(0,S.saveAiGeneralSettings)(P.siteContext),g(),ne(),e()})({pageNamesToGenerate:t,colorSchemeAndTypography:n,pregeneratedData:a}),top.isInitialBlackWizardOnboardingGenerating=!1})({pageNamesToGenerate:n})}catch(e){console.error(e)}},onApplySettingWithoutGenerating:async e=>{if(Ol)return;Ol=!0;const{pageNamesToGenerate:t,pluginsNamesToActivate:o}=e;try{t.length>0&&await re(t)}catch(e){console.error(e)}try{(async e=>{for(const t of e)try{await(0,s.installAndActivatePlugin)(t),t===y.DEFAULT_PLUGIN_FOR_PURPOSE.CONTACT_FORM&&le()}catch(e){console.error(e)}})(o)}catch(e){console.error(e)}await se()},onCancel:async()=>{Ol||(Ol=!0,se())}})]}):(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(As,{message:t,icon:He.KubioLoader})})},Dl=[],Ml=async e=>{const{websiteType:t}=e;t===y.WEBSITE_TYPES.BLOG&&await Ll(e)},Ll=async({block:e,pageContext:t,siteContext:o,pageTitle:n})=>{const i=v().get(e,"attributes.kubioAI.meta.blogCategoryAttributes",!1);if(!(!i||i&&Dl.includes(null==i?void 0:i.id))){Dl.push(null==i?void 0:i.id);try{await(0,S.saveArticlesByCategory)({siteContext:o,pageContext:t,pageTitle:n,category:i})}catch(e){console.error(e)}}},zl=async()=>{const e=await el();if(v().isEmpty(e))return null;const t=e[1];return v().set(t,"attributes.anchor",y.INNER_HERO_ANCHOR),t},Fl={className:"edit-site-more-menu__content",position:"bottom left"},Gl={tooltipPosition:"bottom"},Hl=()=>{const{isGutentagDebug:e,baseUrl:t,currentPage:o,hasBlockSelected:n,isAICapabilityEnabled:i}=(0,l.useSelect)((e=>{const{isGutentagDebug:t=v().noop,getPage:o=v().noop,isAICapabilityEnabled:n}=e(y.STORE_KEY)||{},{url:i}=e("core").getEntityRecord("root","site")||{};return{isGutentagDebug:t(),currentPage:o(),baseUrl:i,hasBlockSelected:!!e("core/block-editor").getSelectedBlockClientId(),isAICapabilityEnabled:n()}}),[]),r=(0,u.useRef)(_.noop),a=()=>{const e=null==o?void 0:o.link,n=encodeURIComponent(e);window.open(`${t}/wp-admin/customize.php?url=${n}`).focus()},{toggleGutentagDebug:c}=(0,l.useDispatch)(y.STORE_KEY),{onExportAiStructure:d}=(()=>{const{contentSectionsBlocks:e}=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlocks:n}=e("core/block-editor"),{currentPageHasFSETemplate:i}=e(y.STORE_KEY)||{};let r=null;return(null==i?void 0:i())&&(r=t().find((e=>{var t;return"core/post-content"===(null===(t=o(e))||void 0===t?void 0:t.name)})),r)?{contentSectionsBlocks:n(r)}:{contentSectionsBlocks:[]}}),[]),t=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlockOrder:n}=e("core/block-editor"),i=(e=>{const n=v().castArray("kubio/header"),i=t().map((e=>o(e))).find((e=>n.includes(e.name)));return null==i?void 0:i.clientId})();return i?n(i).map(o).find((e=>"kubio/hero"===e.name)):null}),[]);return{onExportAiStructure:async()=>{const o=await zl(),n=[t,o,...e].filter(Boolean);let i=!1;const r={};if(n.forEach((e=>{if(i)return;const t=v().get(e,"attributes.anchor");if(!t)return window.alert(`Section with clientId: ${e.clientId} does not have anchor. Please update the design and reexport`),void(i=!0);if(r[t])return window.alert(`Multiple sections use the anchor ${t}, the id should be unique. Please update the design and reexport`),void(i=!0);const o=(0,T.transformBlockToTemplate)(e),n=cl(e),a=(0,S.normalizeSection)(o,n,{includeContent:!0});r[t]=a})),i)return;const a=JSON.stringify(r),s=new Blob([a],{type:"application/json"}),l=document.createElement("a");l.href=URL.createObjectURL(s),l.download="ai-structure.json",l.click(),URL.revokeObjectURL(l.href)}}})(),p=(0,T.getShowInternalFeatures)();let f=(0,g.jsx)(g.Fragment,{});p&&(f=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.MenuItem,{icon:e&&Zi,isSelected:e,onClick:()=>c(!e),role:"menuitemcheckbox",children:(0,m.__)("Toggle Kubio debug","kubio")}),(0,g.jsx)(h.MenuItem,{onClick:d,role:"menuitemcheckbox",children:(0,m.__)("Export AI structure","kubio")})]}));const{uiVersion:b,setUIVersion:x}=(0,k.useUIVersion)(),{openSidebar:w,toggleAICapabilities:C}=(0,l.useDispatch)(y.STORE_KEY),I=()=>{const e=2===b?1:2;x(e),2===e&&w(n?"block-inspector":"document")},[j,P]=Do(),[E,R]=(0,S.useIsAIConnected)(),A=(0,u.useCallback)((()=>{const e=!i;C(e),e&&!E&&(P(),r.current())}),[P,i,E,C]),O=1===b?(0,m.__)("Switch to Kubio Editor layout","kubio"):(0,m.__)("Switch to WordPress Editor layout","kubio"),N=1===b?(0,m.__)("Switch to the new Kubio editor layout for a more friendly editing experience","kubio"):(0,m.__)("Switch to the WordPress editor layout to have the default editing experience","kubio"),B=i?(0,m.__)("Disable Kubio AI capabilities","kubio"):(0,m.__)("Enable Kubio AI capabilities","kubio"),D=i?(0,m.__)("Hide Kubio AI buttons in editors interface","kubio"):(0,m.__)("Show Kubio AI buttons in editors interface","kubio"),[M]=(0,S.useAIServiceInfo)();(0,u.useCallback)((()=>{R(!1),(0,S.setAIKey)("")}),[R]);let L,z=(0,g.jsx)(g.Fragment,{});if((0,T.getShowInternalFeatures)("cloud")){const[e,t,o]=(0,s.useKubioCloudConnect)();z=(0,g.jsx)(h.MenuGroup,{label:"Kubio Cloud",children:"connected"!==e.status?(0,g.jsx)(h.MenuItem,{iconPosition:"left",onClick:t,info:(0,m.__)("Connect this site to Kubio Cloud","kubio"),children:(0,m.__)("Connect to Kubio Cloud","kubio")}):(0,g.jsx)(h.MenuItem,{onClick:o,iconPosition:"left",info:(0,g.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,m.sprintf)(// translators: %s is Kubio Cloud the account email
// translators: %s is Kubio Cloud the account email
(0,m.__)("Currently connected as %s","kubio"),`<strong><em>${e.email}</em></strong>`)}}),children:(0,m.__)("Disconnect from Kubio Cloud","kubio")})})}return T.AI_IN_PRO||(L=(0,g.jsx)(h.MenuGroup,{label:"Kubio AI",children:(0,g.jsx)(h.MenuItem,{onClick:A,iconPosition:"left",info:D,children:B})})),(0,g.jsxs)(g.Fragment,{children:[j,(0,g.jsx)(h.DropdownMenu,{className:"edit-site-more-menu",icon:hs,label:(0,m.__)("More tools & options","kubio"),popoverProps:Fl,toggleProps:Gl,children:({onClose:e})=>(r.current=e,(0,g.jsxs)(g.Fragment,{children:[z,L,(0,g.jsxs)(h.MenuGroup,{label:(0,m._x)("View","noun","kubio"),children:[(0,g.jsx)(h.MenuItem,{onClick:I,info:N,children:O}),(0,g.jsx)(gs,{feature:"focusMode",label:(0,m.__)("Spotlight mode","kubio"),info:(0,m.__)("Focus on one block at a time","kubio"),messageActivated:(0,m.__)("Spotlight mode activated","kubio"),messageDeactivated:(0,m.__)("Spotlight mode deactivated","kubio")}),f,(0,g.jsx)(h.MenuItem,{onClick:a,children:(0,m.__)("Open theme customizer","kubio")}),(0,g.jsx)(je.Slot,{name:"kubio/edit-site/plugin-more-menu",label:(0,m.__)("Plugins","kubio"),as:[h.MenuGroup,h.MenuItem],fillProps:{onClick:e}}),!1]})]}))})]})};var Ul=o(5800);function Wl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Vl}=Object.prototype,{getPrototypeOf:Kl}=Object,$l=(ql=Object.create(null),e=>{const t=Vl.call(e);return ql[t]||(ql[t]=t.slice(8,-1).toLowerCase())});var ql;const Yl=e=>(e=e.toLowerCase(),t=>$l(t)===e),Zl=e=>t=>typeof t===e,{isArray:Xl}=Array,Jl=Zl("undefined"),Ql=Yl("ArrayBuffer"),ec=Zl("string"),tc=Zl("function"),oc=Zl("number"),nc=e=>null!==e&&"object"==typeof e,ic=e=>{if("object"!==$l(e))return!1;const t=Kl(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},rc=Yl("Date"),ac=Yl("File"),sc=Yl("Blob"),lc=Yl("FileList"),cc=Yl("URLSearchParams");function uc(e,t,{allOwnKeys:o=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),Xl(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=o?Object.getOwnPropertyNames(e):Object.keys(e),r=i.length;let a;for(n=0;n<r;n++)a=i[n],t.call(null,e[a],a,e)}}function dc(e,t){t=t.toLowerCase();const o=Object.keys(e);let n,i=o.length;for(;i-- >0;)if(n=o[i],t===n.toLowerCase())return n;return null}const pc="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,hc=e=>!Jl(e)&&e!==pc,mc=(gc="undefined"!=typeof Uint8Array&&Kl(Uint8Array),e=>gc&&e instanceof gc);var gc;const fc=Yl("HTMLFormElement"),bc=(({hasOwnProperty:e})=>(t,o)=>e.call(t,o))(Object.prototype),_c=Yl("RegExp"),vc=(e,t)=>{const o=Object.getOwnPropertyDescriptors(e),n={};uc(o,((o,i)=>{let r;!1!==(r=t(o,i,e))&&(n[i]=r||o)})),Object.defineProperties(e,n)},yc="abcdefghijklmnopqrstuvwxyz",kc="0123456789",xc={DIGIT:kc,ALPHA:yc,ALPHA_DIGIT:yc+yc.toUpperCase()+kc},Sc=Yl("AsyncFunction"),wc={isArray:Xl,isArrayBuffer:Ql,isBuffer:function(e){return null!==e&&!Jl(e)&&null!==e.constructor&&!Jl(e.constructor)&&tc(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||tc(e.append)&&("formdata"===(t=$l(e))||"object"===t&&tc(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ql(e.buffer),t},isString:ec,isNumber:oc,isBoolean:e=>!0===e||!1===e,isObject:nc,isPlainObject:ic,isUndefined:Jl,isDate:rc,isFile:ac,isBlob:sc,isRegExp:_c,isFunction:tc,isStream:e=>nc(e)&&tc(e.pipe),isURLSearchParams:cc,isTypedArray:mc,isFileList:lc,forEach:uc,merge:function e(){const{caseless:t}=hc(this)&&this||{},o={},n=(n,i)=>{const r=t&&dc(o,i)||i;ic(o[r])&&ic(n)?o[r]=e(o[r],n):ic(n)?o[r]=e({},n):Xl(n)?o[r]=n.slice():o[r]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&uc(arguments[e],n);return o},extend:(e,t,o,{allOwnKeys:n}={})=>(uc(t,((t,n)=>{o&&tc(t)?e[n]=Wl(t,o):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,o,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),o&&Object.assign(e.prototype,o)},toFlatObject:(e,t,o,n)=>{let i,r,a;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),r=i.length;r-- >0;)a=i[r],n&&!n(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==o&&Kl(e)}while(e&&(!o||o(e,t))&&e!==Object.prototype);return t},kindOf:$l,kindOfTest:Yl,endsWith:(e,t,o)=>{e=String(e),(void 0===o||o>e.length)&&(o=e.length),o-=t.length;const n=e.indexOf(t,o);return-1!==n&&n===o},toArray:e=>{if(!e)return null;if(Xl(e))return e;let t=e.length;if(!oc(t))return null;const o=new Array(t);for(;t-- >0;)o[t]=e[t];return o},forEachEntry:(e,t)=>{const o=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=o.next())&&!n.done;){const o=n.value;t.call(e,o[0],o[1])}},matchAll:(e,t)=>{let o;const n=[];for(;null!==(o=e.exec(t));)n.push(o);return n},isHTMLForm:fc,hasOwnProperty:bc,hasOwnProp:bc,reduceDescriptors:vc,freezeMethods:e=>{vc(e,((t,o)=>{if(tc(e)&&-1!==["arguments","caller","callee"].indexOf(o))return!1;const n=e[o];tc(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+o+"'")}))}))},toObjectSet:(e,t)=>{const o={},n=e=>{e.forEach((e=>{o[e]=!0}))};return Xl(e)?n(e):n(String(e).split(t)),o},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,o){return t.toUpperCase()+o})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:dc,global:pc,isContextDefined:hc,ALPHABET:xc,generateString:(e=16,t=xc.ALPHA_DIGIT)=>{let o="";const{length:n}=t;for(;e--;)o+=t[Math.random()*n|0];return o},isSpecCompliantForm:function(e){return!!(e&&tc(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),o=(e,n)=>{if(nc(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=Xl(e)?[]:{};return uc(e,((e,t)=>{const r=o(e,n+1);!Jl(r)&&(i[t]=r)})),t[n]=void 0,i}}return e};return o(e,0)},isAsyncFn:Sc,isThenable:e=>e&&(nc(e)||tc(e))&&tc(e.then)&&tc(e.catch)};function Cc(e,t,o,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),o&&(this.config=o),n&&(this.request=n),i&&(this.response=i)}wc.inherits(Cc,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:wc.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ic=Cc.prototype,jc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{jc[e]={value:e}})),Object.defineProperties(Cc,jc),Object.defineProperty(Ic,"isAxiosError",{value:!0}),Cc.from=(e,t,o,n,i,r)=>{const a=Object.create(Ic);return wc.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Cc.call(a,e.message,t,o,n,i),a.cause=e,a.name=e.name,r&&Object.assign(a,r),a};const Tc=Cc;function Pc(e){return wc.isPlainObject(e)||wc.isArray(e)}function Ec(e){return wc.endsWith(e,"[]")?e.slice(0,-2):e}function Rc(e,t,o){return e?e.concat(t).map((function(e,t){return e=Ec(e),!o&&t?"["+e+"]":e})).join(o?".":""):t}const Ac=wc.toFlatObject(wc,{},null,(function(e){return/^is[A-Z]/.test(e)})),Oc=function(e,t,o){if(!wc.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(o=wc.toFlatObject(o,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!wc.isUndefined(t[e])}))).metaTokens,i=o.visitor||c,r=o.dots,a=o.indexes,s=(o.Blob||"undefined"!=typeof Blob&&Blob)&&wc.isSpecCompliantForm(t);if(!wc.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(wc.isDate(e))return e.toISOString();if(!s&&wc.isBlob(e))throw new Tc("Blob is not supported. Use a Buffer instead.");return wc.isArrayBuffer(e)||wc.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,o,i){let s=e;if(e&&!i&&"object"==typeof e)if(wc.endsWith(o,"{}"))o=n?o:o.slice(0,-2),e=JSON.stringify(e);else if(wc.isArray(e)&&function(e){return wc.isArray(e)&&!e.some(Pc)}(e)||(wc.isFileList(e)||wc.endsWith(o,"[]"))&&(s=wc.toArray(e)))return o=Ec(o),s.forEach((function(e,n){!wc.isUndefined(e)&&null!==e&&t.append(!0===a?Rc([o],n,r):null===a?o:o+"[]",l(e))})),!1;return!!Pc(e)||(t.append(Rc(i,o,r),l(e)),!1)}const u=[],d=Object.assign(Ac,{defaultVisitor:c,convertValue:l,isVisitable:Pc});if(!wc.isObject(e))throw new TypeError("data must be an object");return function e(o,n){if(!wc.isUndefined(o)){if(-1!==u.indexOf(o))throw Error("Circular reference detected in "+n.join("."));u.push(o),wc.forEach(o,(function(o,r){!0===(!(wc.isUndefined(o)||null===o)&&i.call(t,o,wc.isString(r)?r.trim():r,n,d))&&e(o,n?n.concat(r):[r])})),u.pop()}}(e),t};function Nc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Bc(e,t){this._pairs=[],e&&Oc(e,this,t)}const Dc=Bc.prototype;Dc.append=function(e,t){this._pairs.push([e,t])},Dc.toString=function(e){const t=e?function(t){return e.call(this,t,Nc)}:Nc;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};const Mc=Bc;function Lc(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function zc(e,t,o){if(!t)return e;const n=o&&o.encode||Lc,i=o&&o.serialize;let r;if(r=i?i(t,o):wc.isURLSearchParams(t)?t.toString():new Mc(t,o).toString(n),r){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}const Fc=class{constructor(){this.handlers=[]}use(e,t,o){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!o&&o.synchronous,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){wc.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Gc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Hc={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Mc,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&"undefined"!=typeof window&&"undefined"!=typeof document})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]},Uc=function(e){function t(e,o,n,i){let r=e[i++];const a=Number.isFinite(+r),s=i>=e.length;return r=!r&&wc.isArray(n)?n.length:r,s?(wc.hasOwnProp(n,r)?n[r]=[n[r],o]:n[r]=o,!a):(n[r]&&wc.isObject(n[r])||(n[r]=[]),t(e,o,n[r],i)&&wc.isArray(n[r])&&(n[r]=function(e){const t={},o=Object.keys(e);let n;const i=o.length;let r;for(n=0;n<i;n++)r=o[n],t[r]=e[r];return t}(n[r])),!a)}if(wc.isFormData(e)&&wc.isFunction(e.entries)){const o={};return wc.forEachEntry(e,((e,n)=>{t(function(e){return wc.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,o,0)})),o}return null},Wc={transitional:Gc,adapter:["xhr","http"],transformRequest:[function(e,t){const o=t.getContentType()||"",n=o.indexOf("application/json")>-1,i=wc.isObject(e);if(i&&wc.isHTMLForm(e)&&(e=new FormData(e)),wc.isFormData(e))return n&&n?JSON.stringify(Uc(e)):e;if(wc.isArrayBuffer(e)||wc.isBuffer(e)||wc.isStream(e)||wc.isFile(e)||wc.isBlob(e))return e;if(wc.isArrayBufferView(e))return e.buffer;if(wc.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let r;if(i){if(o.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Oc(e,new Hc.classes.URLSearchParams,Object.assign({visitor:function(e,t,o,n){return Hc.isNode&&wc.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((r=wc.isFileList(e))||o.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Oc(r?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,o){if(wc.isString(e))try{return(0,JSON.parse)(e),wc.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Wc.transitional,o=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&wc.isString(e)&&(o&&!this.responseType||n)){const o=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw Tc.from(e,Tc.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Hc.classes.FormData,Blob:Hc.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};wc.forEach(["delete","get","head","post","put","patch"],(e=>{Wc.headers[e]={}}));const Vc=Wc,Kc=wc.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$c=Symbol("internals");function qc(e){return e&&String(e).trim().toLowerCase()}function Yc(e){return!1===e||null==e?e:wc.isArray(e)?e.map(Yc):String(e)}function Zc(e,t,o,n,i){return wc.isFunction(n)?n.call(this,t,o):(i&&(t=o),wc.isString(t)?wc.isString(n)?-1!==t.indexOf(n):wc.isRegExp(n)?n.test(t):void 0:void 0)}class Xc{constructor(e){e&&this.set(e)}set(e,t,o){const n=this;function i(e,t,o){const i=qc(t);if(!i)throw new Error("header name must be a non-empty string");const r=wc.findKey(n,i);(!r||void 0===n[r]||!0===o||void 0===o&&!1!==n[r])&&(n[r||t]=Yc(e))}const r=(e,t)=>wc.forEach(e,((e,o)=>i(e,o,t)));return wc.isPlainObject(e)||e instanceof this.constructor?r(e,t):wc.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?r((e=>{const t={};let o,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),o=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!o||t[o]&&Kc[o]||("set-cookie"===o?t[o]?t[o].push(n):t[o]=[n]:t[o]=t[o]?t[o]+", "+n:n)})),t})(e),t):null!=e&&i(t,e,o),this}get(e,t){if(e=qc(e)){const o=wc.findKey(this,e);if(o){const e=this[o];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),o=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=o.exec(e);)t[n[1]]=n[2];return t}(e);if(wc.isFunction(t))return t.call(this,e,o);if(wc.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=qc(e)){const o=wc.findKey(this,e);return!(!o||void 0===this[o]||t&&!Zc(0,this[o],o,t))}return!1}delete(e,t){const o=this;let n=!1;function i(e){if(e=qc(e)){const i=wc.findKey(o,e);!i||t&&!Zc(0,o[i],i,t)||(delete o[i],n=!0)}}return wc.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let o=t.length,n=!1;for(;o--;){const i=t[o];e&&!Zc(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,o={};return wc.forEach(this,((n,i)=>{const r=wc.findKey(o,i);if(r)return t[r]=Yc(n),void delete t[i];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,o)=>t.toUpperCase()+o))}(i):String(i).trim();a!==i&&delete t[i],t[a]=Yc(n),o[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return wc.forEach(this,((o,n)=>{null!=o&&!1!==o&&(t[n]=e&&wc.isArray(o)?o.join(", "):o)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const o=new this(e);return t.forEach((e=>o.set(e))),o}static accessor(e){const t=(this[$c]=this[$c]={accessors:{}}).accessors,o=this.prototype;function n(e){const n=qc(e);t[n]||(function(e,t){const o=wc.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+o,{value:function(e,o,i){return this[n].call(this,t,e,o,i)},configurable:!0})}))}(o,e),t[n]=!0)}return wc.isArray(e)?e.forEach(n):n(e),this}}Xc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),wc.reduceDescriptors(Xc.prototype,(({value:e},t)=>{let o=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[o]=e}}})),wc.freezeMethods(Xc);const Jc=Xc;function Qc(e,t){const o=this||Vc,n=t||o,i=Jc.from(n.headers);let r=n.data;return wc.forEach(e,(function(e){r=e.call(o,r,i.normalize(),t?t.status:void 0)})),i.normalize(),r}function eu(e){return!(!e||!e.__CANCEL__)}function tu(e,t,o){Tc.call(this,null==e?"canceled":e,Tc.ERR_CANCELED,t,o),this.name="CanceledError"}wc.inherits(tu,Tc,{__CANCEL__:!0});const ou=tu,nu=Hc.isStandardBrowserEnv?{write:function(e,t,o,n,i,r){const a=[];a.push(e+"="+encodeURIComponent(t)),wc.isNumber(o)&&a.push("expires="+new Date(o).toGMTString()),wc.isString(n)&&a.push("path="+n),wc.isString(i)&&a.push("domain="+i),!0===r&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function iu(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ru=Hc.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let o;function n(o){let n=o;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return o=n(window.location.href),function(e){const t=wc.isString(e)?n(e):e;return t.protocol===o.protocol&&t.host===o.host}}():function(){return!0};function au(e,t){let o=0;const n=function(e,t){e=e||10;const o=new Array(e),n=new Array(e);let i,r=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),c=n[a];i||(i=l),o[r]=s,n[r]=l;let u=a,d=0;for(;u!==r;)d+=o[u++],u%=e;if(r=(r+1)%e,r===a&&(a=(a+1)%e),l-i<t)return;const p=c&&l-c;return p?Math.round(1e3*d/p):void 0}}(50,250);return i=>{const r=i.loaded,a=i.lengthComputable?i.total:void 0,s=r-o,l=n(s);o=r;const c={loaded:r,total:a,progress:a?r/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&r<=a?(a-r)/l:void 0,event:i};c[t?"download":"upload"]=!0,e(c)}}const su="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,o){let n=e.data;const i=Jc.from(e.headers).normalize(),r=e.responseType;let a,s;function l(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}wc.isFormData(n)&&(Hc.isStandardBrowserEnv||Hc.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.getContentType(/^\s*multipart\/form-data/)?wc.isString(s=i.getContentType())&&i.setContentType(s.replace(/^\s*(multipart\/form-data);+/,"$1")):i.setContentType("multipart/form-data"));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",o=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(t+":"+o))}const u=iu(e.baseURL,e.url);function d(){if(!c)return;const n=Jc.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,o){const n=o.config.validateStatus;o.status&&n&&!n(o.status)?t(new Tc("Request failed with status code "+o.status,[Tc.ERR_BAD_REQUEST,Tc.ERR_BAD_RESPONSE][Math.floor(o.status/100)-4],o.config,o.request,o)):e(o)}((function(e){t(e),l()}),(function(e){o(e),l()}),{data:r&&"text"!==r&&"json"!==r?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),zc(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=d:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(d)},c.onabort=function(){c&&(o(new Tc("Request aborted",Tc.ECONNABORTED,e,c)),c=null)},c.onerror=function(){o(new Tc("Network Error",Tc.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||Gc;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),o(new Tc(t,n.clarifyTimeoutError?Tc.ETIMEDOUT:Tc.ECONNABORTED,e,c)),c=null},Hc.isStandardBrowserEnv){const t=ru(u)&&e.xsrfCookieName&&nu.read(e.xsrfCookieName);t&&i.set(e.xsrfHeaderName,t)}void 0===n&&i.setContentType(null),"setRequestHeader"in c&&wc.forEach(i.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),wc.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),r&&"json"!==r&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",au(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",au(e.onUploadProgress)),(e.cancelToken||e.signal)&&(a=t=>{c&&(o(!t||t.type?new ou(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(a),e.signal&&(e.signal.aborted?a():e.signal.addEventListener("abort",a)));const p=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(u);p&&-1===Hc.protocols.indexOf(p)?o(new Tc("Unsupported protocol "+p+":",Tc.ERR_BAD_REQUEST,e)):c.send(n||null)}))},lu={http:null,xhr:su};wc.forEach(lu,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const cu=e=>`- ${e}`,uu=e=>wc.isFunction(e)||null===e||!1===e,du=e=>{e=wc.isArray(e)?e:[e];const{length:t}=e;let o,n;const i={};for(let r=0;r<t;r++){let t;if(o=e[r],n=o,!uu(o)&&(n=lu[(t=String(o)).toLowerCase()],void 0===n))throw new Tc(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+r]=n}if(!n){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));let o=t?e.length>1?"since :\n"+e.map(cu).join("\n"):" "+cu(e[0]):"as no adapter specified";throw new Tc("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n};function pu(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ou(null,e)}function hu(e){return pu(e),e.headers=Jc.from(e.headers),e.data=Qc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),du(e.adapter||Vc.adapter)(e).then((function(t){return pu(e),t.data=Qc.call(e,e.transformResponse,t),t.headers=Jc.from(t.headers),t}),(function(t){return eu(t)||(pu(e),t&&t.response&&(t.response.data=Qc.call(e,e.transformResponse,t.response),t.response.headers=Jc.from(t.response.headers))),Promise.reject(t)}))}const mu=e=>e instanceof Jc?e.toJSON():e;function gu(e,t){t=t||{};const o={};function n(e,t,o){return wc.isPlainObject(e)&&wc.isPlainObject(t)?wc.merge.call({caseless:o},e,t):wc.isPlainObject(t)?wc.merge({},t):wc.isArray(t)?t.slice():t}function i(e,t,o){return wc.isUndefined(t)?wc.isUndefined(e)?void 0:n(void 0,e,o):n(e,t,o)}function r(e,t){if(!wc.isUndefined(t))return n(void 0,t)}function a(e,t){return wc.isUndefined(t)?wc.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(o,i,r){return r in t?n(o,i):r in e?n(void 0,o):void 0}const l={url:r,method:r,data:r,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t)=>i(mu(e),mu(t),!0)};return wc.forEach(Object.keys(Object.assign({},e,t)),(function(n){const r=l[n]||i,a=r(e[n],t[n],n);wc.isUndefined(a)&&r!==s||(o[n]=a)})),o}const fu={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{fu[e]=function(o){return typeof o===e||"a"+(t<1?"n ":" ")+e}}));const bu={};fu.transitional=function(e,t,o){function n(e,t){return"[Axios v1.6.0] Transitional option '"+e+"'"+t+(o?". "+o:"")}return(o,i,r)=>{if(!1===e)throw new Tc(n(i," has been removed"+(t?" in "+t:"")),Tc.ERR_DEPRECATED);return t&&!bu[i]&&(bu[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(o,i,r)}};const _u={assertOptions:function(e,t,o){if("object"!=typeof e)throw new Tc("options must be an object",Tc.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const r=n[i],a=t[r];if(a){const t=e[r],o=void 0===t||a(t,r,e);if(!0!==o)throw new Tc("option "+r+" must be "+o,Tc.ERR_BAD_OPTION_VALUE)}else if(!0!==o)throw new Tc("Unknown option "+r,Tc.ERR_BAD_OPTION)}},validators:fu},vu=_u.validators;class yu{constructor(e){this.defaults=e,this.interceptors={request:new Fc,response:new Fc}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=gu(this.defaults,t);const{transitional:o,paramsSerializer:n,headers:i}=t;void 0!==o&&_u.assertOptions(o,{silentJSONParsing:vu.transitional(vu.boolean),forcedJSONParsing:vu.transitional(vu.boolean),clarifyTimeoutError:vu.transitional(vu.boolean)},!1),null!=n&&(wc.isFunction(n)?t.paramsSerializer={serialize:n}:_u.assertOptions(n,{encode:vu.function,serialize:vu.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=i&&wc.merge(i.common,i[t.method]);i&&wc.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=Jc.concat(r,i);const a=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!s){const e=[hu.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=a.length;let p=t;for(d=0;d<u;){const e=a[d++],t=a[d++];try{p=e(p)}catch(e){t.call(this,e);break}}try{c=hu.call(this,p)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return zc(iu((e=gu(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}wc.forEach(["delete","get","head","options"],(function(e){yu.prototype[e]=function(t,o){return this.request(gu(o||{},{method:e,url:t,data:(o||{}).data}))}})),wc.forEach(["post","put","patch"],(function(e){function t(t){return function(o,n,i){return this.request(gu(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:o,data:n}))}}yu.prototype[e]=t(),yu.prototype[e+"Form"]=t(!0)}));const ku=yu;class xu{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const o=this;this.promise.then((e=>{if(!o._listeners)return;let t=o._listeners.length;for(;t-- >0;)o._listeners[t](e);o._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{o.subscribe(e),t=e})).then(e);return n.cancel=function(){o.unsubscribe(t)},n},e((function(e,n,i){o.reason||(o.reason=new ou(e,n,i),t(o.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new xu((function(t){e=t})),cancel:e}}}const Su=xu,wu={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(wu).forEach((([e,t])=>{wu[t]=e}));const Cu=wu,Iu=function e(t){const o=new ku(t),n=Wl(ku.prototype.request,o);return wc.extend(n,ku.prototype,o,{allOwnKeys:!0}),wc.extend(n,o,null,{allOwnKeys:!0}),n.create=function(o){return e(gu(t,o))},n}(Vc);Iu.Axios=ku,Iu.CanceledError=ou,Iu.CancelToken=Su,Iu.isCancel=eu,Iu.VERSION="1.6.0",Iu.toFormData=Oc,Iu.AxiosError=Tc,Iu.Cancel=Iu.CanceledError,Iu.all=function(e){return Promise.all(e)},Iu.spread=function(e){return function(t){return e.apply(null,t)}},Iu.isAxiosError=function(e){return wc.isObject(e)&&!0===e.isAxiosError},Iu.mergeConfig=gu,Iu.AxiosHeaders=Jc,Iu.formToJSON=e=>Uc(wc.isHTMLForm(e)?new FormData(e):e),Iu.getAdapter=du,Iu.HttpStatusCode=Cu,Iu.default=Iu;const ju=Iu,Tu={demoParts:null,demoSitesList:null,demoSitesListBySlug:null,demoPartsContentById:{pages:{},templates:{},templateParts:{},globalData:{}}};function Pu(e){if(!e)return;const t=["demoPartsContentById","globalData",e.id];if(v().get(Tu,t))return;const o={contentUrlPath:e.content_url_path,content:null};v().set(Tu,t,o)}async function Eu(e){return Ru(e,"globalData")}async function Ru(e,t){const o=v().get(Tu,["demoPartsContentById",t,e]);let n=null==o?void 0:o.content;if(n)await(10,new Promise((e=>setTimeout((()=>{e()}),10))));else{const e=null==o?void 0:o.contentUrlPath;if(!e)return;try{const t=await ju.get(e);n=null==t?void 0:t.data,o.content=n}catch(e){console.error(e)}}return n}async function Au(){if(Tu.demoParts)return Tu.demoParts;let e=v().get(window,["kubioUtilsData","demo_parts_by_slug"]);v().isEmpty(e)&&(e=await async function(){try{var e;const t=v().get(window,["kubioUtilsData","demo_parts_url"],""),o=await ju.get(t);return(null==o||null===(e=o.data)||void 0===e?void 0:e.body)||{}}catch(e){return console.error(e),[]}}());const t=[];return v().each(e,((e,o)=>{t[o]=function(e,t){const o=v().get(window,["kubioUtilsData","demo_sites"],{}),n=v().get(o,t),i=v().get(n,"thumb",""),r=["index","home"],a=[],s=r.concat(["single","search","404"]);let l=e.filter((({slug:e,type:t})=>"template"===t?(r.includes(e)&&a.push(e),s.includes(e)):"page"!==t||"sample-page"!==e));if(a.length>1){const e=r.filter((e=>a.includes(e)));e.pop(),l=l.filter((({slug:t,type:o})=>"template"!==o||!e.includes(t)))}const c={};return l.forEach(((e,t)=>{c[e.content_url_path]=t})),v().sortBy(l,(e=>"page"===e.type?c[e.content_url_path]:100+v().indexOf(s,e.slug))).map((({content_url_path:e,id:o,preview_image_url:r,preview_image_url_full:a,page_preview_url:s,title:l,type:c,slug:u})=>{return{contentUrlPath:e,id:o,slug:u,uniqueId:Xa().generate(),screenshot:r||i,screenshotFull:a||i,label:(d=Ou({title:l,slug:u,type:c}),function(e){return e.split(" ").map((e=>{return(t=e).charAt(0).toUpperCase()+t.slice(1);var t})).join(" ")}((p=d,Mu.innerHTML=p,Mu.innerText))),isPro:!(null==n||!n.is_pro),type:c,demoSiteSlug:t,pagePreviewUrl:Lu({page_preview_url:s,currentDemoSite:n,type:c,slug:u}),categories:(null==n?void 0:n.categories)||[]};var d,p}))}(e,o)})),o=e,v().each(o,((e,t)=>{e.forEach((e=>{"page"===(null==e?void 0:e.type)?function(e){var t,o;const n={templateId:null==e||null===(t=e.template)||void 0===t?void 0:t.id,globalDataId:null==e||null===(o=e.globalData)||void 0===o?void 0:o.id,contentUrlPath:e.content_url_path,content:null},i=e.globalData;i&&(n.globalDataId=null==i?void 0:i.id),v().set(Tu,["demoPartsContentById","pages",e.id],n),Pu(i)}(e):function(e){const t=["demoPartsContentById","templates",e.id],o=v().get(e,"templateParts",[]);o.forEach((e=>{!function(e){const t=["demoPartsContentById","templateParts",e.id];if(v().get(Tu,t))return;const o={area:e.area,contentUrlPath:e.content_url_path,content:null};v().set(Tu,t,o)}(e)}));const n=null==e?void 0:e.globalData;if(Pu(),v().get(Tu,t))return;const i={templatePartsIds:o.map((e=>e.id)),contentUrlPath:e.content_url_path,content:null};n&&(i.globalDataId=null==n?void 0:n.id),v().set(Tu,t,i)}(e)}))})),Tu.demoParts=t,v().isEmpty(t)?{}:Tu.demoParts;var o}function Ou({title:e,slug:t,type:o}){if("template"===o)switch(t){case"index":case"home":return(0,m.__)("Blog","kubio");case"search":return(0,m.__)("Search","kubio");case"single":return(0,m.__)("Post Page","kubio");default:return e}return e}async function Nu(){if(Tu.demoSitesList)return Tu.demoSitesList;let e=v().get(window,["kubioUtilsData","demo_sites"],null);if(v().isEmpty(e)&&(e=await async function(){const e=v().get(window,["kubioUtilsData","demo_sites_url"],null);if(e){try{var t;const o=await ju.get(e),n=(null==o||null===(t=o.data)||void 0===t?void 0:t.body)||{};n.forEach((e=>{const t=v().get(e,"plugins",[]),o=[];v().each(t,((e,t)=>{const n=null==t?void 0:t.split("/")[0];o.push({label:e,slug:n})})),e.plugins=o}));const i=v().keyBy(n,"slug");return v().set(window,["kubioUtilsData","demo_sites"],i),i}catch(e){console.error(e)}return null}}()),v().isEmpty(e))return[];const t=Object.values(e).map((({is_pro:e,name:t,thumb:o,categories:n,slug:i,preview:r,pro_template_slug:a,plugins:s})=>({isPro:!!e,label:Du(t),preview:r,screenshot:o,proTemplateSlug:a,categories:n,slug:i,plugins:s}))),o=v().keyBy(t,"slug");return t.forEach((e=>{const{proTemplateSlug:t}=e;if(!t)return;const n=v().get(o,t);n&&(e.relatedDemoSite=n,n.relatedDemoSite=e)})),Tu.demoSitesList=t,Tu.demoSitesListBySlug=o,Tu.demoSitesList}const Bu=e=>{e&&setTimeout((()=>{const t=document.querySelector(".kubio-iframe");if(t){const o=null==t?void 0:t.contentDocument,n=null==o?void 0:o.querySelector(`[data-block="${e}"]`);null==n||n.scrollIntoView({behavior:"smooth"})}}),100)};function Du(e=""){return(e=e.replace(/ (Free|Pro)/i,"")).trim()}const Mu=document.createElement("div");function Lu({page_preview_url:e,currentDemoSite:t,type:o,slug:n}){if("page"===o||!["404","search"].includes(n))return e;const i=null==t?void 0:t.preview;switch(n){case"404":return`${i}/404-page`;case"search":return`${i}?s="lorem"`}}!async function(){await Nu(),await Au()}();const zu={currentDemoParts:[],demoPartsIsLoaded:!1,selectedDemoPart:null,setSelectedDemoPart:v().noop},Fu=(0,u.createContext)(zu),Gu=(0,u.memo)((({children:e})=>{const{selectedDemoSlug:t,initialDemoPart:o,setInitialDemoPart:n,demosPartsPerSlug:i,demoPartsIsLoaded:r,currentDemoSite:a}=rf(),s=(0,u.useMemo)((()=>v().get(i,null==a?void 0:a.slug,[])),[a,i]),l=null==a?void 0:a.relatedDemoSite,c=(0,u.useMemo)((()=>v().get(i,null==l?void 0:l.slug,[])),[l,i]),d=(0,u.useMemo)((()=>{const e=v().get(s,[0]);if(!o)return e;return s.find((e=>(null==e?void 0:e.uniqueId)===(null==o?void 0:o.uniqueId)))||e}),[t,o]),[p,h]=(0,u.useState)(d),m=(0,u.useCallback)((e=>{o&&n(null),h(e)}),[h,o,n]);(0,u.useEffect)((()=>{o&&m(o)}),[o]),(0,u.useEffect)((()=>{m(d)}),[t]);const f=(0,u.useMemo)((()=>({currentDemoParts:s,demoPartsIsLoaded:r,selectedDemoPart:p,setSelectedDemoPart:m,relatedDemoParts:c})),[s,r,p,m,c]);return(0,g.jsx)(Fu.Provider,{value:f,children:e})})),Hu=()=>(0,u.useContext)(Fu),Uu="content",Wu="wholePage",Vu=((0,m.__)("Content","kubio"),(0,m.__)("Full page","kubio"),"onlyThisPage"),Ku="allPages",$u=((0,m.__)("Only this page","kubio"),(0,m.__)("All pages","kubio"),["singular","single"]),qu=["index","archive","home"],Yu=$u.concat(qu),Zu=(0,u.createContext)({}),Xu="starterSite",Ju="pages",Qu="sections",ed="favorites",td=[{label:(0,m.__)("Starter sites","kubio"),value:Xu},{label:(0,m.__)("Pages","kubio"),value:Ju},{label:(0,m.__)("Sections","kubio"),value:Qu},{label:(0,m.__)("Favorites","kubio"),value:ed}],od=(0,u.memo)((({onClose:e,children:t,initialParams:o})=>{const n=v().get(o,"page",Xu),[i,r]=(0,u.useState)(n),[a,s]=(0,u.useState)(n),c=(0,u.useCallback)((e=>{s(i),r(e)}),[i]),[d,p]=(0,u.useState)(!1),{templateId:h,postId:m}=(0,l.useSelect)((e=>{const{getPage:t=v().noop,getTemplateId:o=v().noop}=e("kubio/edit-site")||{},n=t();return{templateId:o()||"",postId:v().get(n,"context.postId")}}),[]);(0,u.useEffect)((()=>{d&&p(!1)}),[h,m]);const f=(0,u.useMemo)((()=>({activePage:i,setActivePage:c,onClose:e,showLoadingOverlay:d,setShowLoadingOverlay:p,initialParams:o,previousActivePage:a})),[i,c,e,d,p,o,a]);return(0,g.jsx)(Zu.Provider,{value:f,children:t})})),nd=()=>(0,u.useContext)(Zu),id={isImporting:!1,importDemoPart:v().noop},rd=(0,u.createContext)(id),ad=(0,u.memo)((({children:e})=>{const t=(0,u.useRef)(!1),[o,n]=(0,u.useState)(!1),{selectedDemoPart:i}=Hu(),[r,a]=(0,u.useState)(Uu),[s,l]=(0,u.useState)(Vu),[c,d]=(0,u.useState)(),p=t.current,h=(0,u.useCallback)((e=>{t.current=e}),[t]),m=(0,u.useCallback)((()=>{p||d(i)}),[p,d,i]),f=(0,u.useMemo)((()=>({isImporting:p,setIsImporting:h,importDemoPart:m,demoPartThatIsImporting:c,setDemoPartThatIsImporting:d,whatToImport:r,setWhatToImport:a,whereToApplyChanges:s,setWhereToApplyChanges:l,shouldConvertGlobalColors:o,setShouldConvertGlobalColors:n})),[p,h,c,d,m,r,a,s,l,o,n]);return(0,g.jsx)(rd.Provider,{value:f,children:e})})),sd=()=>(0,u.useContext)(rd),ld={typography:{holders:{}}};["a","lead","p","h1","h2","h3","h4","h5","h6"].forEach((e=>{v().set(ld,`typography.holders.${e}`,{transform:"none",style:"normal",decoration:"none"})}));const cd=e=>(e.forEach((e=>{switch(null==e?void 0:e.name){case"kubio/contact":case"kubio/subscribe-form":v().set(e,["attributes","shortcode"],""),v().set(e,["attributes","formId"],"");break;case"kubio/shortcode":v().set(e,["attributes","shortcode"],"")}const t=v().get(e,"innerBlocks",[]);cd(t)})),e),ud=e=>v().cloneDeep(v().get(e,"globalStyle.style.descendants.body",{}));function dd(e){return v()(e).pickBy(v().isObject).mapValues(dd).omitBy(v().isEmpty).assign(v().omitBy(e,(e=>v().isObject(e)&&!Array.isArray(e)))).value()}const pd=["header","footer","sidebar"],hd={header:"kubio/header",footer:"kubio/footer",sidebar:"kubio/sidebar"},md=e=>{const t=top.document;e?t.defaultView.setTimeout((()=>{t.body.classList.add("kubio-iframe-holder--show"),t.body.classList.remove("kubio-iframe-holder--hide"),t.body.classList.remove("h-ui-disable-transitions")}),100):(t.body.classList.remove("kubio-iframe-holder--show"),t.body.classList.add("kubio-iframe-holder--hide"),t.body.classList.add("h-ui-disable-transitions"))};let gd=!1;const fd=(0,u.memo)((()=>{const{isImporting:e,setIsImporting:t,demoPartThatIsImporting:o,setDemoPartThatIsImporting:n,whereToApplyChanges:i,whatToImport:r,shouldConvertGlobalColors:a}=sd(),{onClose:c=v().noop}=nd(),{contentClientId:d,nrOfBlocksInsideContent:h,postType:f,postId:b,isClassicTemplate:_,pagePath:y,isFrontPageClassic:k,currentTheme:S,currentPostTitle:C}=(0,l.useSelect)((e=>{var t,o;const{getBlocks:n,getBlockOrder:i}=e("core/block-editor"),{getPage:r=v().noop,getTemplateId:a}=e("kubio/edit-site")||{},{getEditedEntityRecord:s,getCurrentTheme:l,getEntityRecord:c}=e("core"),u=s("root","site"),d=null===(t=l())||void 0===t?void 0:t.stylesheet,p=r()||{},{path:h}=p,{postType:m,postId:g}=(null==p?void 0:p.context)||{},f=a()||"",b=!v().get(f.split("//"),"[1]"),_=null==u?void 0:u.page_on_front,y="page"===u.show_on_front,k=b&&y&&parseInt(_)===parseInt(g),x=n()||[],S=(0,T.findBlockByName)(x,"core/post-content"),w=null==S?void 0:S.clientId,C=null===(o=i(w))||void 0===o?void 0:o.length,I=c("postType",m,g);return{contentClientId:w,nrOfBlocksInsideContent:C,postType:m,postId:g,pagePath:h,isClassicTemplate:b,isFrontPageClassic:k,currentTheme:d,currentPost:I,currentPostTitle:v().get(I,"title.rendered","Kubio")}}),[]),{saveEntityRecord:I,editEntityRecord:j}=(0,l.useDispatch)("core"),{insertBlocks:P,replaceInnerBlocks:E,resetBlocks:R,selectBlock:A,removeBlocks:O}=(0,l.useDispatch)("core/block-editor"),{createErrorNotice:N}=(0,s.useKubioNotices)(),B=(0,x.useGetGlobalSessionProp)("urlBasedTemplatesMap",{})[y],D=(0,u.useRef)(),[,M=v().noop]=(0,x.useGlobalSessionProp)("thirdPartyBlockInstalled",!1),{onProcessGlobalDataSettings:L}=(({shouldConvertGlobalColors:e,whatToImport:t,contentClientId:o,isClassicTemplate:n})=>{const{parseVariableColor:i,setPalette:r,getPalette:a}=(0,w.useGlobalDataColors)(),{updateBlockAttributes:c}=(0,l.useDispatch)("core/block-editor"),{editEntityRecord:d}=(0,l.useDispatch)("core"),p=(0,u.useRef)(!1),h=(0,u.useRef)(!1),m="globalStyle.style.descendants.body",{globalStyle:g}=(0,w.useGlobalDataStyle)(),f=(0,u.useMemo)((()=>a()),[]),b=(0,u.useMemo)((()=>g.getStyle("",{},{styledComponent:"body",fromRoot:!0})),[g]),_=(0,u.useMemo)((()=>g.getStyle("",{},{styledComponent:"sectionSpacing",fromRoot:!0})),[g]),{getBlocks:y,pages:k,templateParts:x,templates:S,currentPostId:C}=(0,l.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor"),{getEntityRecords:o}=e("core"),{getPage:n=v().noop}=e("kubio/edit-site")||{},i=n(),{postId:r}=(null==i?void 0:i.context)||{},a=e=>o("postType",e,{per_page:-1});return{currentPostId:r,getBlocks:t,pages:a("page"),templateParts:a("wp_template_part"),templates:a("wp_template").filter((({slug:e})=>Yu.includes(e)))}})),I=(0,u.useCallback)((e=>{r(e)}),[r]),j=(0,u.useCallback)((e=>{g.setStyle("",e,{styledComponent:"body"})}),[g]),P=(0,u.useCallback)((e=>{g.setStyle("",e,{styledComponent:"sectionSpacing"})}),[g]),E=(0,u.useCallback)(((e,t)=>{const o=t.colors;return v().isEqual(o,f)||(e=(0,T.removeThemeColorsFromBlocks)({blocks:e,colorPalette:o,parseVariableColor:i,generateColorVariants:w.generateColorVariants,shouldUpdateAttributes:!1})),e}),[f,I,i]),R=(0,u.useCallback)(((e,t)=>{const o=ud(t);let n=v().merge({},ld,o);const r=t.colors;n=(0,T.removeThemeColorsFromObject)(n,{colorPalette:r,parseVariableColor:i,generateColorVariants:w.generateColorVariants});const a=v().merge({},ld,b);let l=(0,T.getObjectDifference)(n,a);if(l=dd(l),v().isEmpty(l))return e;const c="typography.holders.lead";v().set(l,c,v().merge({},v().get(b,c),v().get(l,c))),v().each(v().get(l,"typography.holders"),((e,t)=>{v().isEmpty(e)||null==e||!e.family||null!=e&&e.weight||(e.weight=v().get(o,`typography.holders.${t}.weight`))}));const u=["kubio/header","kubio/footer","kubio/sidebar","core/post-content"],d="typography.holders.lead.color",p=v().get(l,d);return e.forEach((e=>{var t;const o=!!v().get(e,"attributes.kubio");if(u.includes(null==e?void 0:e.name)||!o)return;const n=`attributes.kubio.style.descendants.${null===(t=(0,s.getBlockDefaultElement)(null==e?void 0:e.name))||void 0===t?void 0:t.name}`;let i=v().get(e,n,{});const r=v().get(i,"typography.holders.p.color");r&&p&&(i=v().cloneDeep(i),v().set(i,d,r));const a=v().merge({},l,i);v().set(e,n,a)})),e}),[b,i,w.generateColorVariants]),A=(0,u.useCallback)((e=>{const t=e.colors;v().isEqual(t,f)||I(t)}),[f,I]),O=(0,u.useCallback)((e=>{const t=v().get(e,m,{}),o=v().merge({},ld,t),n=v().merge({},ld,b),i=dd((0,T.getObjectDifference)(o,n));v().isEmpty(i)||j(o)}),[b,m]),N=(0,u.useCallback)((e=>{const t=v().get(e,"globalStyle.style.descendants.sectionSpacing",{});v().isEqual(_,t)||P(t)}),[_,P]),B=(0,u.useCallback)((e=>{p.current||(p.current=!0,A(e),O(e),N(e))}),[A,O,N,p]),D=(0,u.useCallback)(((e,t,o=!0)=>{const n=t.colors;let i=!1;const r=e.map((e=>{if(!v().get(e,"attributes.kubio"))return e;const{updatedBlock:r,hasUpdates:a}=(({block:e,colorPalette:t})=>{t=v().cloneDeep(t);const o=v().cloneDeep(e);let n=!1;const i=(0,w.generateColorVariants)(t),r=e=>{if(!Array.isArray(e))return e;let t;return t=4===e.length?"rgba":"rgb",`${t}(${e.join(", ")})`};t.forEach((e=>{e.color=r(e.color)})),i.forEach((e=>{e.color=r(e.color)}));const a=e=>{const o=v().get(e,"attributes.kubio",{});v().eachDeep(o,((e,o,r)=>{if("string"==typeof e&&(e.startsWith("#")&&(e=Jo(e).toRgbString()),e.startsWith("rgb"))){const a=({color:t,slug:i})=>{if(t===e){n=!0;const e=Jo(t);return r[o]=`rgba(var(--${i}),${e.getAlpha()})`,!0}return!1};t.find(a)||i.find(a)}}),{leavesOnly:!0});const{innerBlocks:r}=e;r.forEach((e=>{a(e)}))};return a(o),{updatedBlock:o,hasUpdates:n}})({block:e,colorPalette:n}),l=ud(t),{updatedBlock:u,hasUpdates:d}=(({block:e,generalBodyStyle:t})=>{var o;let n=!1;const i=`attributes.kubio.style.descendants.${null===(o=(0,s.getBlockDefaultElement)(null==e?void 0:e.name))||void 0===o?void 0:o.name}`,r=v().get(e,i,{}),a=v().merge({},ld,t),l=dd((0,T.getObjectDifference)(r,a));return v().isEmpty(l)||v().isEqual(l,r)||(v().set(e,i,l),n=!0),{updatedBlock:e,hasUpdates:n}})({block:r,generalBodyStyle:l});return i=i||d||a,o&&(d||a)&&c(null==u?void 0:u.clientId,u.attributes),u}));return{blocks:r,blocksHaveChanges:i}}),[c]),M=(0,u.useCallback)((e=>{if(h.current=!0,t===Wu)return;let i=[],r=[];n||(r=y(),["kubio/header","kubio/footer","kubio/sidebar"].forEach((e=>{const t=(0,T.findBlockByName)(r,e);if(!t)return;const o=y(null==t?void 0:t.clientId);i=i.concat(o)})));const a=y(o),s=r.concat(i,a);D(s,e)}),[t,o,n,D]),L=((0,u.useCallback)((e=>{k.concat(x,S).forEach((t=>{if(t.id===C)return;const o=v().get(t,"content.raw",""),n=(0,lt.parse)(o);if(v().isEmpty(n))return;const{blocks:i,blocksHaveChanges:r}=D(n,e,!1);if(!r)return;const a={content:(0,lt.serialize)(i)},{id:s,type:l}=t;d("postType",l,s,a)}))}),[D,k,x,S,C]),(0,u.useCallback)((e=>{h.current||M(e)}),[M])),z=(0,u.useCallback)(((e,t)=>{const o=v().get(t,"globalStyle.style.descendants.sectionSpacing",{});if(v().isEqual(_,o))return e;let n=(0,T.getObjectDifference)(o,_);n=dd(n);const i=["kubio/section","kubio/navigation","kubio/hero","kubio/query-layout"];return e.forEach((e=>{var t;const o=!!v().get(e,"attributes.kubio");if(!i.includes(null==e?void 0:e.name)||!o)return;const r=`attributes.kubio.style.descendants.${null===(t=(0,s.getBlockDefaultElement)(null==e?void 0:e.name))||void 0===t?void 0:t.name}`,a=v().get(e,r,{}),l=v().merge({},n,a);v().set(e,r,l)})),e}),[_]);return{onProcessGlobalDataSettings:(0,u.useCallback)(((t,o)=>(e?(B(o),L(o)):(t=E(t,o),t=R(t,o),t=z(t,o)),t)),[E,R,z,L,e,B])}})({shouldConvertGlobalColors:a,whatToImport:r,contentClientId:d,isClassicTemplate:_}),z=(0,u.useCallback)(((e,t)=>(e=cd(e),e=L(e,t),(0,s.getBlocksWithNewRefs)(e))),[L]),F=(0,p.useDebounce)((0,u.useCallback)((e=>{clearTimeout(D.current),md(!0),D.current=setTimeout((()=>{Bu(e)}),100)}),[]),100);(0,u.useEffect)((()=>()=>{clearTimeout(D.current)}),[]);const G=(0,u.useCallback)((()=>{n(null),t(!1)}),[n,t]),{templatePartIsUsedOnMultipleTemplates:H,templatePartIsFoundOnPage:U,refreshPage:W,templateIsUsedOnMultiplePages:V}=(0,s.useTemplateData)("header"),{templatePartIsUsedOnMultipleTemplates:K,templatePartIsFoundOnPage:$}=(0,s.useTemplateData)("footer"),{templatePartIsUsedOnMultipleTemplates:q,templatePartIsFoundOnPage:Y}=(0,s.useTemplateData)("sidebar"),Z=(0,u.useMemo)((()=>({header:H,footer:K,sidebar:q})),[H,K,q]),X=(0,u.useMemo)((()=>({header:U,footer:$,sidebar:Y})),[U,$,Y]),{getBlocks:J}=(0,l.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor"),{getEntityRecords:o}=e("core");return{getBlocks:t,getEntityRecords:o}})),Q=(0,u.useCallback)((()=>{t(!0),c(),md(!1)}),[t,c]),ee=(0,u.useCallback)((({templatePartName:e,templateBlocks:t,newSlug:o,newTheme:n})=>{const i=(0,T.findBlockByName)(t,e);i&&(i.attributes.slug=o,i.attributes.theme=n)}),[]),te=(0,u.useCallback)((async(e,t,o)=>{var n;const i=J(),r=hd[t],a=(0,T.findBlockByName)(i,r),s=null==a?void 0:a.clientId;if(!s)return;await E(s,e);const l=null==a||null===(n=a.attributes)||void 0===n?void 0:n.slug;ee({templateBlocks:o,templatePartName:r,newSlug:l,newTheme:S})}),[J,E,S,ee]),oe=(0,u.useCallback)((async(e,t,o)=>{const n=`${C} ${t}`,i={title:n,slug:n,area:t,kubio_template_source:"kubio-custom",content:(0,lt.serialize)(e)},r=await I("postType","wp_template_part",i),a=hd[t],s=null==r?void 0:r.slug,l=null==r?void 0:r.theme;s&&l&&ee({templateBlocks:o,templatePartName:a,newSlug:s,newTheme:l})}),[C,I,ee]),ne=(0,u.useCallback)((async e=>{const{title:t,slug:o,assignTemplateToPage:n}=(({isFrontPageClassic:e,isClassicTemplate:t,classicTemplateSlug:o,postType:n,currentPostTitle:i})=>{let r="page"===n,a=`${i} template`,s=a;const l=$u,c="search"===o,u="404"===o,d=t&&qu.includes(o),p=t&&l.includes(o);return e?(a="Front page",s="front-page",r=!1):d?(a="Index",s="index",r=!1):p?(a="Single Post",s="single",r=!1):c?(a="Search",s="search",r=!1):u?(a="404",s="404",r=!1):n&&(s=`${n}-${s}`),{title:a,slug:s,assignTemplateToPage:r}})({isFrontPageClassic:k,isClassicTemplate:_,classicTemplateSlug:B,postType:f,currentPostTitle:C}),i={title:t,slug:o,kubio_template_source:n?"kubio-custom":"kubio",content:(0,lt.serialize)(e)},r=await I("postType","wp_template",i);return n&&await j("postType",f,b,{template:null==r?void 0:r.slug}),M(!0),await W(r),r}),[k,_,B,f,C,I,M,W,j,b]),ie=(0,u.useCallback)((async({templateBlocks:e,templateParts:t,globalData:o})=>{const n=J(),i={};if(pd.forEach((e=>{const t=hd[e];i[e]=(0,T.findBlockByName)(n,t)})),await Promise.all(t.map((async({area:t,content:n})=>{var r;const a=z((0,lt.parse)(n),o),s=null===(r=i[t])||void 0===r?void 0:r.clientId;s?await E(s,a):await oe(a,t,e)}))),!v().isEmpty(t)){const o=Object.values(i),n=t.map((({area:e})=>hd[e]));o.forEach((t=>{var o;if(!t)return;const i=null==t?void 0:t.name;if(!n.includes(i))return;const r=null==t||null===(o=t.attributes)||void 0===o?void 0:o.slug;ee({templateBlocks:e,templatePartName:i,newSlug:r,newTheme:S})}))}_?await ne(e):await R(e),F()}),[J,_,F,z,E,oe,S,ee,ne,R]),re=(0,u.useCallback)((async({templateBlocks:e,templateParts:t,globalData:o})=>{await Promise.all(t.map((async({area:t,content:n})=>{const i=z((0,lt.parse)(n),o);Z[t]||!X[t]?await oe(i,t,e):await te(i,t,e)}))),await R(e)}),[R,z,Z,X,oe,te]),ae=(0,u.useCallback)((async({templateBlocks:e,templateParts:t,globalData:o})=>{await Promise.all(t.map((async({area:t,content:n})=>{const i=z((0,lt.parse)(n),o);await oe(i,t,e)}))),await ne(e)}),[oe,ne,z]),se=(0,u.useCallback)((async({templateBlocks:e,templateParts:t,globalData:o})=>{V||_?await ae({templateBlocks:e,templateParts:t,globalData:o}):await re({templateBlocks:e,templateParts:t,globalData:o}),M(!0),F()}),[V,_,M,F,ae,re]),le=(0,u.useCallback)((async({templateBlocks:e,templateParts:t,globalData:o})=>{let n=i;f&&"page"!==f&&!_&&(n=Ku);const r=Ku===n;Vu===n&&await se({templateBlocks:e,templateParts:t,globalData:o}),r&&await re({templateBlocks:e,templateParts:t,globalData:o})}),[_,f,i,re,se]),ce=(0,u.useCallback)((async({templateBlocks:e,templateParts:t,globalData:o})=>{const n=J(),i=e[1];let r,a;n.forEach(((e,t)=>{("kubio/header"===e.name||"core/template-part"===e.name&&"header"===(null==e?void 0:e.area))&&(r=t),("kubio/footer"===e.name||"core/template-part"===e.name&&"footer"===(null==e?void 0:e.area))&&(a=t)}));let s=[];s=s.concat(n.slice(0,r+1)),s.push(i),s=s.concat(n.slice(a));const l=t.filter((({area:e})=>!["footer","header"].includes(e)));ie({templateBlocks:s,templateParts:l,globalData:o}),F()}),[J,F,ie]),ue=(0,u.useCallback)((async e=>{let t=r===Uu;_&&(t=!1);const{template:o,templateParts:n,globalData:i}=await async function(e,t=!0){const o=["demoPartsContentById","templates",e],n=v().get(Tu,o),i=v().get(n,"templatePartsIds",[]);let r={template:await async function(e){return Ru(e,"templates")}(e),templateParts:await Promise.all(i.map((async e=>({area:v().get(Tu,["demoPartsContentById","templateParts",e,"area"]),content:await async function(e){return Ru(e,"templateParts")}(e)}))))};if(t){const e=null==n?void 0:n.globalDataId,t=await Eu(e);r.globalData=t}return r=v().cloneDeep(r),r}(e);if(!o)return void G();const a=z((0,lt.parse)(o),i);t?await ce({templateBlocks:a,templateParts:n,globalData:i}):await le({templateBlocks:a,templateParts:n,globalData:i})}),[r,_,Q,z,G,ce,le]),de=(0,u.useCallback)((async({pageBlocks:e,globalData:t})=>{const o=v().get(e,[0,"clientId"]);await P(e,h,d,!1),F(o)}),[P,h,d,F]),pe=(0,u.useCallback)((async({pageBlocks:e,pageId:t})=>{_&&await R([]),await E(d,e);const o=(n=t,v().get(Tu,["demoPartsContentById","pages",n]));var n;const i=null==o?void 0:o.templateId;await ue(i),F()}),[_,E,d,ue,F,R]),he=(0,u.useCallback)((async e=>{const t=r===Uu,o=r===Wu,{page:n,globalData:i}=await async function(e){const t=["demoPartsContentById","pages",e],o=v().get(Tu,t),n=await async function(e){return Ru(e,"pages")}(e),i=null==o?void 0:o.globalDataId;let r={page:n,globalData:await Eu(i)};return r=v().cloneDeep(r),r}(e);if(!n)return void G();const a=z((0,lt.parse)(n),i);t&&await de({pageBlocks:a,globalData:i,pageId:e}),o&&await pe({pageBlocks:a,globalData:i,pageId:e})}),[r,z,G,de,pe]),me=(0,u.useCallback)((async()=>{if(!o||e||gd)return;gd=!0;const t="page"===(null==o?void 0:o.type),n="template"===(null==o?void 0:o.type),i=null==o?void 0:o.id;if(i)try{Q(),t&&await he(i),n&&await ue(i)}catch(e){console.error(e),N((0,m.__)("Could not import content. Please try again later","kubio"))}finally{gd=!1,F()}}),[o,e,Q,he,ue,N,F]);return(0,s.useEffectDeep)((()=>{me()}),[o]),(0,g.jsx)(g.Fragment,{})})),bd=(0,u.memo)((()=>{const{categoriesList:e=[],selectedCategory:t,setSelectedCategory:o,nrOfItemsPerCategory:n}=Qg(),i=(0,l.useSelect)((e=>{const{getExcludedSectionCategories:t}=e("kubio/edit-site");return t()})),r=e.filter((e=>!i.includes(e.value))),[a,s]=(0,u.useState)(t),c=(0,u.useCallback)((e=>{e!==t&&(s(e),o(e))}),[o,t,s]);return(0,u.useEffect)((()=>{a!==t&&s(t)}),[t]),(0,g.jsxs)("div",{className:"kubio-predefined-layouts__category-list",onClick:e=>e.stopPropagation(),children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__category-list__title",children:"CATEGORIES"}),r.map((({label:e,value:t})=>(0,g.jsxs)(h.Button,{onClick:()=>c(t),className:X()("kubio-predefined-layouts__category-list__item",{"kubio-predefined-layouts__category-list__item--active":t===a}),children:[e,(0,g.jsx)("span",{children:n[t]})]},t)))]})})),_d=(0,u.memo)((({type:e,id:t,relatedFavoriteId:o})=>{const{favoritesDataByType:n,onAddToFavorites:i}=uf(),r=(0,u.useMemo)((()=>v().get(n,[e,t],!1)),[n]),[a,s]=(0,u.useState)(r);(0,u.useEffect)((()=>{r!==a&&s(r)}),[r]);const l=(0,u.useMemo)((()=>a?"font-awesome/heart":"font-awesome/heart-o"),[a]),c=(0,u.useCallback)((async n=>{n.stopPropagation();const r=!a;s(r),i(e,o?[t,o]:t,r)}),[a,i,s,o]);return(0,g.jsx)(ut.CanvasIcon,{onClick:c,className:"kubio-predefined-layouts__favorite-button",name:l})})),vd=(0,u.memo)((({fontsToLoad:e})=>{const t=(0,u.useCallback)((e=>{e.target.rel="stylesheet"}),[e]);return Array.isArray(e)?(0,g.jsx)(g.Fragment,{children:e.map((e=>(0,g.jsx)("link",{href:`https://fonts.googleapis.com/css?family=${e}&display=swap`,rel:"preload",as:"style",onLoad:t},e)))}):(0,g.jsx)(g.Fragment,{})})),yd=(0,u.memo)((()=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__img__placeholder"}))),kd=({src:e,uniqueId:t,showAnimationAtLoad:o,addImageType:n=!0,onLoad:i=v().noop,...r})=>{const[a,s]=(0,u.useState)(!0),l=(0,u.useRef)(),c=(0,u.useRef)(),d=(0,u.useRef)(!1),p=(0,u.useRef)(),h=(0,u.useRef)(!1),m=(0,u.useRef)(!1);(0,u.useEffect)((()=>{a||s(!0)}),[e]);const f=(0,u.useCallback)((()=>{var e,t;const o=l.current;if(!o)return;const n=parseInt((null===(e=c.current)||void 0===e?void 0:e.naturalWidth)||0),i=parseInt((null===(t=c.current)||void 0===t?void 0:t.naturalHeight)||0),r=o.parentNode;let a=!1;if(0!==n&&0!==i){const e=(i+10)/n;a=parseInt(r.clientHeight)/parseInt(r.clientWidth)>e}}),[l,c]),b=(0,u.useCallback)((()=>{m.current=!0;const t=l.current;t&&(t.src=e,t.setAttribute("data-is-loaded",""),s(!1),d.current&&i(),n&&f())}),[e,s,n,f]),_=(0,u.useMemo)((()=>{if(e.startsWith("data:image/"))return!0;m.current=!1,h.current=!1;const t=new Image;return c.current=t,clearTimeout(h.current),p.current=setTimeout((()=>{h.current=!0,m.current||t.complete&&b()}),350),t.onload=()=>{h.current&&b()},t.src=e,t.complete}),[e]);return(0,u.useEffect)((()=>()=>{clearTimeout(h.current)}),[]),(0,u.useLayoutEffect)((()=>{var e;null!==(e=c.current)&&void 0!==e&&e.complete&&f()}),[]),(0,g.jsxs)("div",{className:X()("kubio-predefined-layouts__img__outer",{"kubio-predefined-layouts__img__outer--with-placeholder":!_&&a}),...r,children:[(0,g.jsx)("img",{className:X()("kubio-predefined-layouts__img",{"kubio-predefined-layouts__img--with-animation":!_}),ref:l,src:e,onLoad:()=>{a||(d.current=!0,i())}}),!_&&a&&(0,g.jsx)(yd,{})]})},xd=(0,u.memo)((({list:e,children:t=v().noop})=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__screenshot-list",children:e.map((e=>t(e)))}))),Sd=(0,u.memo)((0,u.forwardRef)((({screenshot:e,screenshotFull:t,label:o="",isPack:n=!1,labelSlot:i,showFull:r=!1,uniqueId:a,isPro:s=!1,showFavorite:l=!0,isLandscape:c=!1,showLabel:d=!0,addUniquePreviewAttribute:p=!0,showAnimationAtLoad:h,onClick:m,onLoad:f,favoriteType:b,favoriteId:_,relatedFavoriteId:v,children:y,addImageType:k,...x},S)=>{const w=r?t:e;a=a||w;const C=(0,u.useMemo)((()=>Math.random()),[a]),I=s;let j={};return p&&(j={"data-unique-id":a}),(0,g.jsxs)("div",{className:"kubio-predefined-layouts__screenshot-preview__outer",...j,...x,children:[(0,g.jsxs)("div",{ref:S,className:X()("kubio-predefined-layouts__screenshot-preview__parent",{"kubio-predefined-layouts__screenshot-preview__parent--with-pack":n,"kubio-predefined-layouts__screenshot-preview__parent--is-landscape":c}),children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__screenshot-preview kubio-pro-item--small",onClick:m,children:(0,g.jsx)(kd,{src:w,uniqueId:a,showAnimationAtLoad:h,onLoad:f,addImageType:k})}),d&&(0,g.jsxs)("div",{className:"kubio-predefined-layouts__screenshot-preview__label",children:[(0,g.jsxs)("div",{className:"kubio-predefined-layouts__screenshot-preview__label__with-badge",children:[I&&(0,g.jsx)("span",{className:"kubio-pro-item__badge",children:"PRO"}),o]}),l&&(0,g.jsx)(_d,{type:b,id:_,relatedFavoriteId:v}),i]}),y]}),n&&(0,g.jsxs)("div",{className:"kubio-predefined-layouts__screenshot-preview__pack",children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__screenshot-preview__pack__layer kubio-predefined-layouts__screenshot-preview__pack--layer-1"}),(0,g.jsx)("div",{className:"kubio-predefined-layouts__screenshot-preview__pack__layer kubio-predefined-layouts__screenshot-preview__pack--layer-2"})]})]},C)}))),wd=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"})}),Cd=(0,u.memo)((({placeholder:e="Search"})=>{const{searchString:t,setSearchString:o}=Jg(),[n,i]=(0,u.useState)(t),r=(0,s.useDebounce)(o,300),a=(0,u.useCallback)((e=>{const t=e.target.value;i(t),r(t)}),[i,r]);return(0,u.useEffect)((()=>{n!==t&&i(t)}),[t]),(0,g.jsx)(ut.InputControl,{className:"kubio-predefined-layouts__search-input",value:n,onInput:a,placeholder:e,suffix:(0,g.jsx)(h.Icon,{icon:wd})})})),Id=(0,u.memo)((({label:e=(0,m.__)("PRO","kubio"),className:t})=>(0,g.jsxs)("div",{className:X()("kubio-predefined-layouts__free-pro-separator",t),children:[e,(0,g.jsx)("div",{className:"kubio-predefined-layouts__free-pro-separator__line"})]})));function jd(){var e=this.constructor.getDerivedStateFromProps(this.props,this.state);null!=e&&this.setState(e)}function Td(e){this.setState(function(t){var o=this.constructor.getDerivedStateFromProps(e,t);return null!=o?o:null}.bind(this))}function Pd(e,t){try{var o=this.props,n=this.state;this.props=e,this.state=t,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(o,n)}finally{this.props=o,this.state=n}}function Ed(e){var t=e.prototype;if(!t||!t.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof e.getDerivedStateFromProps&&"function"!=typeof t.getSnapshotBeforeUpdate)return e;var o=null,n=null,i=null;if("function"==typeof t.componentWillMount?o="componentWillMount":"function"==typeof t.UNSAFE_componentWillMount&&(o="UNSAFE_componentWillMount"),"function"==typeof t.componentWillReceiveProps?n="componentWillReceiveProps":"function"==typeof t.UNSAFE_componentWillReceiveProps&&(n="UNSAFE_componentWillReceiveProps"),"function"==typeof t.componentWillUpdate?i="componentWillUpdate":"function"==typeof t.UNSAFE_componentWillUpdate&&(i="UNSAFE_componentWillUpdate"),null!==o||null!==n||null!==i){var r=e.displayName||e.name,a="function"==typeof e.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+r+" uses "+a+" but also contains the following legacy lifecycles:"+(null!==o?"\n "+o:"")+(null!==n?"\n "+n:"")+(null!==i?"\n "+i:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof e.getDerivedStateFromProps&&(t.componentWillMount=jd,t.componentWillReceiveProps=Td),"function"==typeof t.getSnapshotBeforeUpdate){if("function"!=typeof t.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");t.componentWillUpdate=Pd;var s=t.componentDidUpdate;t.componentDidUpdate=function(e,t,o){var n=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:o;s.call(this,e,t,n)}}return e}function Rd(e){var t,o,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(o=Rd(e[t]))&&(n&&(n+=" "),n+=o);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}(0,m.__)("ALL","kubio"),(0,m.__)("FREE","kubio"),(0,m.__)("PRO","kubio"),jd.__suppressDeprecationWarning=!0,Td.__suppressDeprecationWarning=!0,Pd.__suppressDeprecationWarning=!0;const Ad=function(){for(var e,t,o=0,n="";o<arguments.length;)(e=arguments[o++])&&(t=Rd(e))&&(n&&(n+=" "),n+=t);return n};function Od(e){var t=e.cellCount,o=e.cellSize,n=e.computeMetadataCallback,i=e.computeMetadataCallbackProps,r=e.nextCellsCount,a=e.nextCellSize,s=e.nextScrollToIndex,l=e.scrollToIndex,c=e.updateScrollOffsetForScrollToIndex;t===r&&("number"!=typeof o&&"number"!=typeof a||o===a)||(n(i),l>=0&&l===s&&c())}function Nd(e,t){if(null==e)return{};var o,n,i=function(e,t){if(null==e)return{};var o={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;o[n]=e[n]}return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)o=r[n],t.includes(o)||{}.propertyIsEnumerable.call(e,o)&&(i[o]=e[o])}return i}var Bd=function(){function e(t){var o=t.cellCount,n=t.cellSizeGetter,i=t.estimatedCellSize;vt(this,e),bt(this,"_cellSizeAndPositionData",{}),bt(this,"_lastMeasuredIndex",-1),bt(this,"_lastBatchedIndex",-1),bt(this,"_cellCount",void 0),bt(this,"_cellSizeGetter",void 0),bt(this,"_estimatedCellSize",void 0),this._cellSizeGetter=n,this._cellCount=o,this._estimatedCellSize=i}return kt(e,[{key:"areOffsetsAdjusted",value:function(){return!1}},{key:"configure",value:function(e){var t=e.cellCount,o=e.estimatedCellSize,n=e.cellSizeGetter;this._cellCount=t,this._estimatedCellSize=o,this._cellSizeGetter=n}},{key:"getCellCount",value:function(){return this._cellCount}},{key:"getEstimatedCellSize",value:function(){return this._estimatedCellSize}},{key:"getLastMeasuredIndex",value:function(){return this._lastMeasuredIndex}},{key:"getOffsetAdjustment",value:function(){return 0}},{key:"getSizeAndPositionOfCell",value:function(e){if(e<0||e>=this._cellCount)throw Error("Requested index ".concat(e," is outside of range 0..").concat(this._cellCount));if(e>this._lastMeasuredIndex)for(var t=this.getSizeAndPositionOfLastMeasuredCell(),o=t.offset+t.size,n=this._lastMeasuredIndex+1;n<=e;n++){var i=this._cellSizeGetter({index:n});if(void 0===i||isNaN(i))throw Error("Invalid size returned for cell ".concat(n," of value ").concat(i));null===i?(this._cellSizeAndPositionData[n]={offset:o,size:0},this._lastBatchedIndex=e):(this._cellSizeAndPositionData[n]={offset:o,size:i},o+=i,this._lastMeasuredIndex=e)}return this._cellSizeAndPositionData[e]}},{key:"getSizeAndPositionOfLastMeasuredCell",value:function(){return this._lastMeasuredIndex>=0?this._cellSizeAndPositionData[this._lastMeasuredIndex]:{offset:0,size:0}}},{key:"getTotalSize",value:function(){var e=this.getSizeAndPositionOfLastMeasuredCell();return e.offset+e.size+(this._cellCount-this._lastMeasuredIndex-1)*this._estimatedCellSize}},{key:"getUpdatedOffsetForIndex",value:function(e){var t=e.align,o=void 0===t?"auto":t,n=e.containerSize,i=e.currentOffset,r=e.targetIndex;if(n<=0)return 0;var a,s=this.getSizeAndPositionOfCell(r),l=s.offset,c=l-n+s.size;switch(o){case"start":a=l;break;case"end":a=c;break;case"center":a=l-(n-s.size)/2;break;default:a=Math.max(c,Math.min(l,i))}var u=this.getTotalSize();return Math.max(0,Math.min(u-n,a))}},{key:"getVisibleCellRange",value:function(e){var t=e.containerSize,o=e.offset;if(0===this.getTotalSize())return{};var n=o+t,i=this._findNearestCell(o),r=this.getSizeAndPositionOfCell(i);o=r.offset+r.size;for(var a=i;o<n&&a<this._cellCount-1;)a++,o+=this.getSizeAndPositionOfCell(a).size;return{start:i,stop:a}}},{key:"resetCell",value:function(e){this._lastMeasuredIndex=Math.min(this._lastMeasuredIndex,e-1)}},{key:"_binarySearch",value:function(e,t,o){for(;t<=e;){var n=t+Math.floor((e-t)/2),i=this.getSizeAndPositionOfCell(n).offset;if(i===o)return n;i<o?t=n+1:i>o&&(e=n-1)}return t>0?t-1:0}},{key:"_exponentialSearch",value:function(e,t){for(var o=1;e<this._cellCount&&this.getSizeAndPositionOfCell(e).offset<t;)e+=o,o*=2;return this._binarySearch(Math.min(e,this._cellCount-1),Math.floor(e/2),t)}},{key:"_findNearestCell",value:function(e){if(isNaN(e))throw Error("Invalid offset ".concat(e," specified"));e=Math.max(0,e);var t=this.getSizeAndPositionOfLastMeasuredCell(),o=Math.max(0,this._lastMeasuredIndex);return t.offset>=e?this._binarySearch(o,0,e):this._exponentialSearch(o,e)}}]),e}(),Dd=function(){function e(t){var o=t.maxScrollSize,n=void 0===o?"undefined"!=typeof window&&window.chrome?16777100:15e5:o,i=Nd(t,["maxScrollSize"]);vt(this,e),bt(this,"_cellSizeAndPositionManager",void 0),bt(this,"_maxScrollSize",void 0),this._cellSizeAndPositionManager=new Bd(i),this._maxScrollSize=n}return kt(e,[{key:"areOffsetsAdjusted",value:function(){return this._cellSizeAndPositionManager.getTotalSize()>this._maxScrollSize}},{key:"configure",value:function(e){this._cellSizeAndPositionManager.configure(e)}},{key:"getCellCount",value:function(){return this._cellSizeAndPositionManager.getCellCount()}},{key:"getEstimatedCellSize",value:function(){return this._cellSizeAndPositionManager.getEstimatedCellSize()}},{key:"getLastMeasuredIndex",value:function(){return this._cellSizeAndPositionManager.getLastMeasuredIndex()}},{key:"getOffsetAdjustment",value:function(e){var t=e.containerSize,o=e.offset,n=this._cellSizeAndPositionManager.getTotalSize(),i=this.getTotalSize(),r=this._getOffsetPercentage({containerSize:t,offset:o,totalSize:i});return Math.round(r*(i-n))}},{key:"getSizeAndPositionOfCell",value:function(e){return this._cellSizeAndPositionManager.getSizeAndPositionOfCell(e)}},{key:"getSizeAndPositionOfLastMeasuredCell",value:function(){return this._cellSizeAndPositionManager.getSizeAndPositionOfLastMeasuredCell()}},{key:"getTotalSize",value:function(){return Math.min(this._maxScrollSize,this._cellSizeAndPositionManager.getTotalSize())}},{key:"getUpdatedOffsetForIndex",value:function(e){var t=e.align,o=void 0===t?"auto":t,n=e.containerSize,i=e.currentOffset,r=e.targetIndex;i=this._safeOffsetToOffset({containerSize:n,offset:i});var a=this._cellSizeAndPositionManager.getUpdatedOffsetForIndex({align:o,containerSize:n,currentOffset:i,targetIndex:r});return this._offsetToSafeOffset({containerSize:n,offset:a})}},{key:"getVisibleCellRange",value:function(e){var t=e.containerSize,o=e.offset;return o=this._safeOffsetToOffset({containerSize:t,offset:o}),this._cellSizeAndPositionManager.getVisibleCellRange({containerSize:t,offset:o})}},{key:"resetCell",value:function(e){this._cellSizeAndPositionManager.resetCell(e)}},{key:"_getOffsetPercentage",value:function(e){var t=e.containerSize,o=e.offset,n=e.totalSize;return n<=t?0:o/(n-t)}},{key:"_offsetToSafeOffset",value:function(e){var t=e.containerSize,o=e.offset,n=this._cellSizeAndPositionManager.getTotalSize(),i=this.getTotalSize();if(n===i)return o;var r=this._getOffsetPercentage({containerSize:t,offset:o,totalSize:n});return Math.round(r*(i-t))}},{key:"_safeOffsetToOffset",value:function(e){var t=e.containerSize,o=e.offset,n=this._cellSizeAndPositionManager.getTotalSize(),i=this.getTotalSize();if(n===i)return o;var r=this._getOffsetPercentage({containerSize:t,offset:o,totalSize:i});return Math.round(r*(n-t))}}]),e}();function Md(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t={};return function(o){var n=o.callback,i=o.indices,r=Object.keys(i),a=!e||r.every((function(e){var t=i[e];return Array.isArray(t)?t.length>0:t>=0})),s=r.length!==Object.keys(t).length||r.some((function(e){var o=t[e],n=i[e];return Array.isArray(n)?o.join(",")!==n.join(","):o!==n}));t=i,a&&s&&n(i)}}function Ld(e){var t=e.cellSize,o=e.cellSizeAndPositionManager,n=e.previousCellsCount,i=e.previousCellSize,r=e.previousScrollToAlignment,a=e.previousScrollToIndex,s=e.previousSize,l=e.scrollOffset,c=e.scrollToAlignment,u=e.scrollToIndex,d=e.size,p=e.sizeJustIncreasedFromZero,h=e.updateScrollIndexCallback,m=o.getCellCount(),g=u>=0&&u<m;g&&(d!==s||p||!i||"number"==typeof t&&t!==i||c!==r||u!==a)?h(u):!g&&m>0&&(d<s||m<n)&&l>o.getTotalSize()-d&&h(m-1)}const zd=!("undefined"==typeof window||!window.document||!window.document.createElement);var Fd,Gd;function Hd(e){if((!Fd&&0!==Fd||e)&&zd){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),Fd=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Fd}var Ud,Wd,Vd=(Gd="undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).requestAnimationFrame||Gd.webkitRequestAnimationFrame||Gd.mozRequestAnimationFrame||Gd.oRequestAnimationFrame||Gd.msRequestAnimationFrame||function(e){return Gd.setTimeout(e,1e3/60)},Kd=Gd.cancelAnimationFrame||Gd.webkitCancelAnimationFrame||Gd.mozCancelAnimationFrame||Gd.oCancelAnimationFrame||Gd.msCancelAnimationFrame||function(e){Gd.clearTimeout(e)},$d=Vd,qd=Kd,Yd=function(e){return qd(e.id)},Zd=function(e,t){var o;Promise.resolve().then((function(){o=Date.now()}));var n={id:$d((function i(){Date.now()-o>=t?e.call():n.id=$d(i)}))};return n};function Xd(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function Jd(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?Xd(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):Xd(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var Qd="requested",ep=(Wd=Ud=function(e){function t(e){var o;vt(this,t),bt(xt(o=St(this,wt(t).call(this,e))),"_onGridRenderedMemoizer",Md()),bt(xt(o),"_onScrollMemoizer",Md(!1)),bt(xt(o),"_deferredInvalidateColumnIndex",null),bt(xt(o),"_deferredInvalidateRowIndex",null),bt(xt(o),"_recomputeScrollLeftFlag",!1),bt(xt(o),"_recomputeScrollTopFlag",!1),bt(xt(o),"_horizontalScrollBarSize",0),bt(xt(o),"_verticalScrollBarSize",0),bt(xt(o),"_scrollbarPresenceChanged",!1),bt(xt(o),"_scrollingContainer",void 0),bt(xt(o),"_childrenToDisplay",void 0),bt(xt(o),"_columnStartIndex",void 0),bt(xt(o),"_columnStopIndex",void 0),bt(xt(o),"_rowStartIndex",void 0),bt(xt(o),"_rowStopIndex",void 0),bt(xt(o),"_renderedColumnStartIndex",0),bt(xt(o),"_renderedColumnStopIndex",0),bt(xt(o),"_renderedRowStartIndex",0),bt(xt(o),"_renderedRowStopIndex",0),bt(xt(o),"_initialScrollTop",void 0),bt(xt(o),"_initialScrollLeft",void 0),bt(xt(o),"_disablePointerEventsTimeoutId",void 0),bt(xt(o),"_styleCache",{}),bt(xt(o),"_cellCache",{}),bt(xt(o),"_debounceScrollEndedCallback",(function(){o._disablePointerEventsTimeoutId=null,o.setState({isScrolling:!1,needToResetStyleCache:!1})})),bt(xt(o),"_invokeOnGridRenderedHelper",(function(){var e=o.props.onSectionRendered;o._onGridRenderedMemoizer({callback:e,indices:{columnOverscanStartIndex:o._columnStartIndex,columnOverscanStopIndex:o._columnStopIndex,columnStartIndex:o._renderedColumnStartIndex,columnStopIndex:o._renderedColumnStopIndex,rowOverscanStartIndex:o._rowStartIndex,rowOverscanStopIndex:o._rowStopIndex,rowStartIndex:o._renderedRowStartIndex,rowStopIndex:o._renderedRowStopIndex}})})),bt(xt(o),"_setScrollingContainerRef",(function(e){o._scrollingContainer=e})),bt(xt(o),"_onScroll",(function(e){e.target===o._scrollingContainer&&o.handleScrollEvent(e.target)}));var n=new Dd({cellCount:e.columnCount,cellSizeGetter:function(o){return t._wrapSizeGetter(e.columnWidth)(o)},estimatedCellSize:t._getEstimatedColumnSize(e)}),i=new Dd({cellCount:e.rowCount,cellSizeGetter:function(o){return t._wrapSizeGetter(e.rowHeight)(o)},estimatedCellSize:t._getEstimatedRowSize(e)});return o.state={instanceProps:{columnSizeAndPositionManager:n,rowSizeAndPositionManager:i,prevColumnWidth:e.columnWidth,prevRowHeight:e.rowHeight,prevColumnCount:e.columnCount,prevRowCount:e.rowCount,prevIsScrolling:!0===e.isScrolling,prevScrollToColumn:e.scrollToColumn,prevScrollToRow:e.scrollToRow,scrollbarSize:0,scrollbarSizeMeasured:!1},isScrolling:!1,scrollDirectionHorizontal:1,scrollDirectionVertical:1,scrollLeft:0,scrollTop:0,scrollPositionChangeReason:null,needToResetStyleCache:!1},e.scrollToRow>0&&(o._initialScrollTop=o._getCalculatedScrollTop(e,o.state)),e.scrollToColumn>0&&(o._initialScrollLeft=o._getCalculatedScrollLeft(e,o.state)),o}return It(t,e),kt(t,[{key:"getOffsetForCell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.alignment,o=void 0===t?this.props.scrollToAlignment:t,n=e.columnIndex,i=void 0===n?this.props.scrollToColumn:n,r=e.rowIndex,a=void 0===r?this.props.scrollToRow:r,s=Jd({},this.props,{scrollToAlignment:o,scrollToColumn:i,scrollToRow:a});return{scrollLeft:this._getCalculatedScrollLeft(s),scrollTop:this._getCalculatedScrollTop(s)}}},{key:"getTotalRowsHeight",value:function(){return this.state.instanceProps.rowSizeAndPositionManager.getTotalSize()}},{key:"getTotalColumnsWidth",value:function(){return this.state.instanceProps.columnSizeAndPositionManager.getTotalSize()}},{key:"handleScrollEvent",value:function(e){var t=e.scrollLeft,o=void 0===t?0:t,n=e.scrollTop,i=void 0===n?0:n;if(!(i<0)){this._debounceScrollEnded();var r=this.props,a=r.autoHeight,s=r.autoWidth,l=r.height,c=r.width,u=this.state.instanceProps,d=u.scrollbarSize,p=u.rowSizeAndPositionManager.getTotalSize(),h=u.columnSizeAndPositionManager.getTotalSize(),m=Math.min(Math.max(0,h-c+d),o),g=Math.min(Math.max(0,p-l+d),i);if(this.state.scrollLeft!==m||this.state.scrollTop!==g){var f={isScrolling:!0,scrollDirectionHorizontal:m!==this.state.scrollLeft?m>this.state.scrollLeft?1:-1:this.state.scrollDirectionHorizontal,scrollDirectionVertical:g!==this.state.scrollTop?g>this.state.scrollTop?1:-1:this.state.scrollDirectionVertical,scrollPositionChangeReason:"observed"};a||(f.scrollTop=g),s||(f.scrollLeft=m),f.needToResetStyleCache=!1,this.setState(f)}this._invokeOnScrollMemoizer({scrollLeft:m,scrollTop:g,totalColumnsWidth:h,totalRowsHeight:p})}}},{key:"invalidateCellSizeAfterRender",value:function(e){var t=e.columnIndex,o=e.rowIndex;this._deferredInvalidateColumnIndex="number"==typeof this._deferredInvalidateColumnIndex?Math.min(this._deferredInvalidateColumnIndex,t):t,this._deferredInvalidateRowIndex="number"==typeof this._deferredInvalidateRowIndex?Math.min(this._deferredInvalidateRowIndex,o):o}},{key:"measureAllCells",value:function(){var e=this.props,t=e.columnCount,o=e.rowCount,n=this.state.instanceProps;n.columnSizeAndPositionManager.getSizeAndPositionOfCell(t-1),n.rowSizeAndPositionManager.getSizeAndPositionOfCell(o-1)}},{key:"recomputeGridSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.columnIndex,o=void 0===t?0:t,n=e.rowIndex,i=void 0===n?0:n,r=this.props,a=r.scrollToColumn,s=r.scrollToRow,l=this.state.instanceProps;l.columnSizeAndPositionManager.resetCell(o),l.rowSizeAndPositionManager.resetCell(i),this._recomputeScrollLeftFlag=a>=0&&(1===this.state.scrollDirectionHorizontal?o<=a:o>=a),this._recomputeScrollTopFlag=s>=0&&(1===this.state.scrollDirectionVertical?i<=s:i>=s),this._styleCache={},this._cellCache={},this.forceUpdate()}},{key:"scrollToCell",value:function(e){var t=e.columnIndex,o=e.rowIndex,n=this.props.columnCount,i=this.props;n>1&&void 0!==t&&this._updateScrollLeftForScrollToColumn(Jd({},i,{scrollToColumn:t})),void 0!==o&&this._updateScrollTopForScrollToRow(Jd({},i,{scrollToRow:o}))}},{key:"componentDidMount",value:function(){var e=this.props,o=e.getScrollbarSize,n=e.height,i=e.scrollLeft,r=e.scrollToColumn,a=e.scrollTop,s=e.scrollToRow,l=e.width,c=this.state.instanceProps;if(this._initialScrollTop=0,this._initialScrollLeft=0,this._handleInvalidatedGridSize(),c.scrollbarSizeMeasured||this.setState((function(e){var t=Jd({},e,{needToResetStyleCache:!1});return t.instanceProps.scrollbarSize=o(),t.instanceProps.scrollbarSizeMeasured=!0,t})),"number"==typeof i&&i>=0||"number"==typeof a&&a>=0){var u=t._getScrollToPositionStateUpdate({prevState:this.state,scrollLeft:i,scrollTop:a});u&&(u.needToResetStyleCache=!1,this.setState(u))}this._scrollingContainer&&(this._scrollingContainer.scrollLeft!==this.state.scrollLeft&&(this._scrollingContainer.scrollLeft=this.state.scrollLeft),this._scrollingContainer.scrollTop!==this.state.scrollTop&&(this._scrollingContainer.scrollTop=this.state.scrollTop));var d=n>0&&l>0;r>=0&&d&&this._updateScrollLeftForScrollToColumn(),s>=0&&d&&this._updateScrollTopForScrollToRow(),this._invokeOnGridRenderedHelper(),this._invokeOnScrollMemoizer({scrollLeft:i||0,scrollTop:a||0,totalColumnsWidth:c.columnSizeAndPositionManager.getTotalSize(),totalRowsHeight:c.rowSizeAndPositionManager.getTotalSize()}),this._maybeCallOnScrollbarPresenceChange()}},{key:"componentDidUpdate",value:function(e,t){var o=this,n=this.props,i=n.autoHeight,r=n.autoWidth,a=n.columnCount,s=n.height,l=n.rowCount,c=n.scrollToAlignment,u=n.scrollToColumn,d=n.scrollToRow,p=n.width,h=this.state,m=h.scrollLeft,g=h.scrollPositionChangeReason,f=h.scrollTop,b=h.instanceProps;this._handleInvalidatedGridSize();var _=a>0&&0===e.columnCount||l>0&&0===e.rowCount;g===Qd&&(!r&&m>=0&&(m!==this._scrollingContainer.scrollLeft||_)&&(this._scrollingContainer.scrollLeft=m),!i&&f>=0&&(f!==this._scrollingContainer.scrollTop||_)&&(this._scrollingContainer.scrollTop=f));var v=(0===e.width||0===e.height)&&s>0&&p>0;if(this._recomputeScrollLeftFlag?(this._recomputeScrollLeftFlag=!1,this._updateScrollLeftForScrollToColumn(this.props)):Ld({cellSizeAndPositionManager:b.columnSizeAndPositionManager,previousCellsCount:e.columnCount,previousCellSize:e.columnWidth,previousScrollToAlignment:e.scrollToAlignment,previousScrollToIndex:e.scrollToColumn,previousSize:e.width,scrollOffset:m,scrollToAlignment:c,scrollToIndex:u,size:p,sizeJustIncreasedFromZero:v,updateScrollIndexCallback:function(){return o._updateScrollLeftForScrollToColumn(o.props)}}),this._recomputeScrollTopFlag?(this._recomputeScrollTopFlag=!1,this._updateScrollTopForScrollToRow(this.props)):Ld({cellSizeAndPositionManager:b.rowSizeAndPositionManager,previousCellsCount:e.rowCount,previousCellSize:e.rowHeight,previousScrollToAlignment:e.scrollToAlignment,previousScrollToIndex:e.scrollToRow,previousSize:e.height,scrollOffset:f,scrollToAlignment:c,scrollToIndex:d,size:s,sizeJustIncreasedFromZero:v,updateScrollIndexCallback:function(){return o._updateScrollTopForScrollToRow(o.props)}}),this._invokeOnGridRenderedHelper(),m!==t.scrollLeft||f!==t.scrollTop){var y=b.rowSizeAndPositionManager.getTotalSize(),k=b.columnSizeAndPositionManager.getTotalSize();this._invokeOnScrollMemoizer({scrollLeft:m,scrollTop:f,totalColumnsWidth:k,totalRowsHeight:y})}this._maybeCallOnScrollbarPresenceChange()}},{key:"componentWillUnmount",value:function(){this._disablePointerEventsTimeoutId&&Yd(this._disablePointerEventsTimeoutId)}},{key:"render",value:function(){var e=this.props,t=e.autoContainerWidth,o=e.autoHeight,n=e.autoWidth,i=e.className,r=e.containerProps,a=e.containerRole,s=e.containerStyle,l=e.height,c=e.id,u=e.noContentRenderer,d=e.role,p=e.style,h=e.tabIndex,m=e.width,g=this.state,f=g.instanceProps,b=g.needToResetStyleCache,_=this._isScrolling(),v={boxSizing:"border-box",direction:"ltr",height:o?"auto":l,position:"relative",width:n?"auto":m,WebkitOverflowScrolling:"touch",willChange:"transform"};b&&(this._styleCache={}),this.state.isScrolling||this._resetStyleCache(),this._calculateChildrenToRender(this.props,this.state);var y=f.columnSizeAndPositionManager.getTotalSize(),k=f.rowSizeAndPositionManager.getTotalSize(),x=k>l?f.scrollbarSize:0,S=y>m?f.scrollbarSize:0;S===this._horizontalScrollBarSize&&x===this._verticalScrollBarSize||(this._horizontalScrollBarSize=S,this._verticalScrollBarSize=x,this._scrollbarPresenceChanged=!0),v.overflowX=y+x<=m?"hidden":"auto",v.overflowY=k+S<=l?"hidden":"auto";var w=this._childrenToDisplay,C=0===w.length&&l>0&&m>0;return J.createElement("div",Y({ref:this._setScrollingContainerRef},r,{"aria-label":this.props["aria-label"],"aria-readonly":this.props["aria-readonly"],className:Ad("ReactVirtualized__Grid",i),id:c,onScroll:this._onScroll,role:d,style:Jd({},v,{},p),tabIndex:h}),w.length>0&&J.createElement("div",{className:"ReactVirtualized__Grid__innerScrollContainer",role:a,style:Jd({width:t?"auto":y,height:k,maxWidth:y,maxHeight:k,overflow:"hidden",pointerEvents:_?"none":"",position:"relative"},s)},w),C&&u())}},{key:"_calculateChildrenToRender",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state,o=e.cellRenderer,n=e.cellRangeRenderer,i=e.columnCount,r=e.deferredMeasurementCache,a=e.height,s=e.overscanColumnCount,l=e.overscanIndicesGetter,c=e.overscanRowCount,u=e.rowCount,d=e.width,p=e.isScrollingOptOut,h=t.scrollDirectionHorizontal,m=t.scrollDirectionVertical,g=t.instanceProps,f=this._initialScrollTop>0?this._initialScrollTop:t.scrollTop,b=this._initialScrollLeft>0?this._initialScrollLeft:t.scrollLeft,_=this._isScrolling(e,t);if(this._childrenToDisplay=[],a>0&&d>0){var v=g.columnSizeAndPositionManager.getVisibleCellRange({containerSize:d,offset:b}),y=g.rowSizeAndPositionManager.getVisibleCellRange({containerSize:a,offset:f}),k=g.columnSizeAndPositionManager.getOffsetAdjustment({containerSize:d,offset:b}),x=g.rowSizeAndPositionManager.getOffsetAdjustment({containerSize:a,offset:f});this._renderedColumnStartIndex=v.start,this._renderedColumnStopIndex=v.stop,this._renderedRowStartIndex=y.start,this._renderedRowStopIndex=y.stop;var S=l({direction:"horizontal",cellCount:i,overscanCellsCount:s,scrollDirection:h,startIndex:"number"==typeof v.start?v.start:0,stopIndex:"number"==typeof v.stop?v.stop:-1}),w=l({direction:"vertical",cellCount:u,overscanCellsCount:c,scrollDirection:m,startIndex:"number"==typeof y.start?y.start:0,stopIndex:"number"==typeof y.stop?y.stop:-1}),C=S.overscanStartIndex,I=S.overscanStopIndex,j=w.overscanStartIndex,T=w.overscanStopIndex;if(r){if(!r.hasFixedHeight())for(var P=j;P<=T;P++)if(!r.has(P,0)){C=0,I=i-1;break}if(!r.hasFixedWidth())for(var E=C;E<=I;E++)if(!r.has(0,E)){j=0,T=u-1;break}}this._childrenToDisplay=n({cellCache:this._cellCache,cellRenderer:o,columnSizeAndPositionManager:g.columnSizeAndPositionManager,columnStartIndex:C,columnStopIndex:I,deferredMeasurementCache:r,horizontalOffsetAdjustment:k,isScrolling:_,isScrollingOptOut:p,parent:this,rowSizeAndPositionManager:g.rowSizeAndPositionManager,rowStartIndex:j,rowStopIndex:T,scrollLeft:b,scrollTop:f,styleCache:this._styleCache,verticalOffsetAdjustment:x,visibleColumnIndices:v,visibleRowIndices:y}),this._columnStartIndex=C,this._columnStopIndex=I,this._rowStartIndex=j,this._rowStopIndex=T}}},{key:"_debounceScrollEnded",value:function(){var e=this.props.scrollingResetTimeInterval;this._disablePointerEventsTimeoutId&&Yd(this._disablePointerEventsTimeoutId),this._disablePointerEventsTimeoutId=Zd(this._debounceScrollEndedCallback,e)}},{key:"_handleInvalidatedGridSize",value:function(){if("number"==typeof this._deferredInvalidateColumnIndex&&"number"==typeof this._deferredInvalidateRowIndex){var e=this._deferredInvalidateColumnIndex,t=this._deferredInvalidateRowIndex;this._deferredInvalidateColumnIndex=null,this._deferredInvalidateRowIndex=null,this.recomputeGridSize({columnIndex:e,rowIndex:t})}}},{key:"_invokeOnScrollMemoizer",value:function(e){var t=this,o=e.scrollLeft,n=e.scrollTop,i=e.totalColumnsWidth,r=e.totalRowsHeight;this._onScrollMemoizer({callback:function(e){var o=e.scrollLeft,n=e.scrollTop,a=t.props,s=a.height;(0,a.onScroll)({clientHeight:s,clientWidth:a.width,scrollHeight:r,scrollLeft:o,scrollTop:n,scrollWidth:i})},indices:{scrollLeft:o,scrollTop:n}})}},{key:"_isScrolling",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state;return Object.hasOwnProperty.call(e,"isScrolling")?Boolean(e.isScrolling):Boolean(t.isScrolling)}},{key:"_maybeCallOnScrollbarPresenceChange",value:function(){if(this._scrollbarPresenceChanged){var e=this.props.onScrollbarPresenceChange;this._scrollbarPresenceChanged=!1,e({horizontal:this._horizontalScrollBarSize>0,size:this.state.instanceProps.scrollbarSize,vertical:this._verticalScrollBarSize>0})}}},{key:"scrollToPosition",value:function(e){var o=e.scrollLeft,n=e.scrollTop,i=t._getScrollToPositionStateUpdate({prevState:this.state,scrollLeft:o,scrollTop:n});i&&(i.needToResetStyleCache=!1,this.setState(i))}},{key:"_getCalculatedScrollLeft",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state;return t._getCalculatedScrollLeft(e,o)}},{key:"_updateScrollLeftForScrollToColumn",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state,n=t._getScrollLeftForScrollToColumnStateUpdate(e,o);n&&(n.needToResetStyleCache=!1,this.setState(n))}},{key:"_getCalculatedScrollTop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state;return t._getCalculatedScrollTop(e,o)}},{key:"_resetStyleCache",value:function(){var e=this._styleCache,t=this._cellCache,o=this.props.isScrollingOptOut;this._cellCache={},this._styleCache={};for(var n=this._rowStartIndex;n<=this._rowStopIndex;n++)for(var i=this._columnStartIndex;i<=this._columnStopIndex;i++){var r="".concat(n,"-").concat(i);this._styleCache[r]=e[r],o&&(this._cellCache[r]=t[r])}}},{key:"_updateScrollTopForScrollToRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state,n=t._getScrollTopForScrollToRowStateUpdate(e,o);n&&(n.needToResetStyleCache=!1,this.setState(n))}}],[{key:"getDerivedStateFromProps",value:function(e,o){var n={};0===e.columnCount&&0!==o.scrollLeft||0===e.rowCount&&0!==o.scrollTop?(n.scrollLeft=0,n.scrollTop=0):(e.scrollLeft!==o.scrollLeft&&e.scrollToColumn<0||e.scrollTop!==o.scrollTop&&e.scrollToRow<0)&&Object.assign(n,t._getScrollToPositionStateUpdate({prevState:o,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}));var i,r,a=o.instanceProps;return n.needToResetStyleCache=!1,e.columnWidth===a.prevColumnWidth&&e.rowHeight===a.prevRowHeight||(n.needToResetStyleCache=!0),a.columnSizeAndPositionManager.configure({cellCount:e.columnCount,estimatedCellSize:t._getEstimatedColumnSize(e),cellSizeGetter:t._wrapSizeGetter(e.columnWidth)}),a.rowSizeAndPositionManager.configure({cellCount:e.rowCount,estimatedCellSize:t._getEstimatedRowSize(e),cellSizeGetter:t._wrapSizeGetter(e.rowHeight)}),0!==a.prevColumnCount&&0!==a.prevRowCount||(a.prevColumnCount=0,a.prevRowCount=0),e.autoHeight&&!1===e.isScrolling&&!0===a.prevIsScrolling&&Object.assign(n,{isScrolling:!1}),Od({cellCount:a.prevColumnCount,cellSize:"number"==typeof a.prevColumnWidth?a.prevColumnWidth:null,computeMetadataCallback:function(){return a.columnSizeAndPositionManager.resetCell(0)},computeMetadataCallbackProps:e,nextCellsCount:e.columnCount,nextCellSize:"number"==typeof e.columnWidth?e.columnWidth:null,nextScrollToIndex:e.scrollToColumn,scrollToIndex:a.prevScrollToColumn,updateScrollOffsetForScrollToIndex:function(){i=t._getScrollLeftForScrollToColumnStateUpdate(e,o)}}),Od({cellCount:a.prevRowCount,cellSize:"number"==typeof a.prevRowHeight?a.prevRowHeight:null,computeMetadataCallback:function(){return a.rowSizeAndPositionManager.resetCell(0)},computeMetadataCallbackProps:e,nextCellsCount:e.rowCount,nextCellSize:"number"==typeof e.rowHeight?e.rowHeight:null,nextScrollToIndex:e.scrollToRow,scrollToIndex:a.prevScrollToRow,updateScrollOffsetForScrollToIndex:function(){r=t._getScrollTopForScrollToRowStateUpdate(e,o)}}),a.prevColumnCount=e.columnCount,a.prevColumnWidth=e.columnWidth,a.prevIsScrolling=!0===e.isScrolling,a.prevRowCount=e.rowCount,a.prevRowHeight=e.rowHeight,a.prevScrollToColumn=e.scrollToColumn,a.prevScrollToRow=e.scrollToRow,a.scrollbarSize=e.getScrollbarSize(),void 0===a.scrollbarSize?(a.scrollbarSizeMeasured=!1,a.scrollbarSize=0):a.scrollbarSizeMeasured=!0,n.instanceProps=a,Jd({},n,{},i,{},r)}},{key:"_getEstimatedColumnSize",value:function(e){return"number"==typeof e.columnWidth?e.columnWidth:e.estimatedColumnSize}},{key:"_getEstimatedRowSize",value:function(e){return"number"==typeof e.rowHeight?e.rowHeight:e.estimatedRowSize}},{key:"_getScrollToPositionStateUpdate",value:function(e){var t=e.prevState,o=e.scrollLeft,n=e.scrollTop,i={scrollPositionChangeReason:Qd};return"number"==typeof o&&o>=0&&(i.scrollDirectionHorizontal=o>t.scrollLeft?1:-1,i.scrollLeft=o),"number"==typeof n&&n>=0&&(i.scrollDirectionVertical=n>t.scrollTop?1:-1,i.scrollTop=n),"number"==typeof o&&o>=0&&o!==t.scrollLeft||"number"==typeof n&&n>=0&&n!==t.scrollTop?i:{}}},{key:"_wrapSizeGetter",value:function(e){return"function"==typeof e?e:function(){return e}}},{key:"_getCalculatedScrollLeft",value:function(e,t){var o=e.columnCount,n=e.height,i=e.scrollToAlignment,r=e.scrollToColumn,a=e.width,s=t.scrollLeft,l=t.instanceProps;if(o>0){var c=o-1,u=r<0?c:Math.min(c,r),d=l.rowSizeAndPositionManager.getTotalSize(),p=l.scrollbarSizeMeasured&&d>n?l.scrollbarSize:0;return l.columnSizeAndPositionManager.getUpdatedOffsetForIndex({align:i,containerSize:a-p,currentOffset:s,targetIndex:u})}return 0}},{key:"_getScrollLeftForScrollToColumnStateUpdate",value:function(e,o){var n=o.scrollLeft,i=t._getCalculatedScrollLeft(e,o);return"number"==typeof i&&i>=0&&n!==i?t._getScrollToPositionStateUpdate({prevState:o,scrollLeft:i,scrollTop:-1}):{}}},{key:"_getCalculatedScrollTop",value:function(e,t){var o=e.height,n=e.rowCount,i=e.scrollToAlignment,r=e.scrollToRow,a=e.width,s=t.scrollTop,l=t.instanceProps;if(n>0){var c=n-1,u=r<0?c:Math.min(c,r),d=l.columnSizeAndPositionManager.getTotalSize(),p=l.scrollbarSizeMeasured&&d>a?l.scrollbarSize:0;return l.rowSizeAndPositionManager.getUpdatedOffsetForIndex({align:i,containerSize:o-p,currentOffset:s,targetIndex:u})}return 0}},{key:"_getScrollTopForScrollToRowStateUpdate",value:function(e,o){var n=o.scrollTop,i=t._getCalculatedScrollTop(e,o);return"number"==typeof i&&i>=0&&n!==i?t._getScrollToPositionStateUpdate({prevState:o,scrollLeft:-1,scrollTop:i}):{}}}]),t}(J.PureComponent),bt(Ud,"propTypes",null),Wd);bt(ep,"defaultProps",{"aria-label":"grid","aria-readonly":!0,autoContainerWidth:!1,autoHeight:!1,autoWidth:!1,cellRangeRenderer:function(e){for(var t=e.cellCache,o=e.cellRenderer,n=e.columnSizeAndPositionManager,i=e.columnStartIndex,r=e.columnStopIndex,a=e.deferredMeasurementCache,s=e.horizontalOffsetAdjustment,l=e.isScrolling,c=e.isScrollingOptOut,u=e.parent,d=e.rowSizeAndPositionManager,p=e.rowStartIndex,h=e.rowStopIndex,m=e.styleCache,g=e.verticalOffsetAdjustment,f=e.visibleColumnIndices,b=e.visibleRowIndices,_=[],v=n.areOffsetsAdjusted()||d.areOffsetsAdjusted(),y=!l&&!v,k=p;k<=h;k++)for(var x=d.getSizeAndPositionOfCell(k),S=i;S<=r;S++){var w=n.getSizeAndPositionOfCell(S),C=S>=f.start&&S<=f.stop&&k>=b.start&&k<=b.stop,I="".concat(k,"-").concat(S),j=void 0;y&&m[I]?j=m[I]:a&&!a.has(k,S)?j={height:"auto",left:0,position:"absolute",top:0,width:"auto"}:(j={height:x.size,left:w.offset+s,position:"absolute",top:x.offset+g,width:w.size},m[I]=j);var T={columnIndex:S,isScrolling:l,isVisible:C,key:I,parent:u,rowIndex:k,style:j},P=void 0;!c&&!l||s||g?P=o(T):(t[I]||(t[I]=o(T)),P=t[I]),null!=P&&!1!==P&&_.push(P)}return _},containerRole:"rowgroup",containerStyle:{},estimatedColumnSize:100,estimatedRowSize:30,getScrollbarSize:Hd,noContentRenderer:function(){return null},onScroll:function(){},onScrollbarPresenceChange:function(){},onSectionRendered:function(){},overscanColumnCount:0,overscanIndicesGetter:function(e){var t=e.cellCount,o=e.overscanCellsCount,n=e.scrollDirection,i=e.startIndex,r=e.stopIndex;return 1===n?{overscanStartIndex:Math.max(0,i),overscanStopIndex:Math.min(t-1,r+o)}:{overscanStartIndex:Math.max(0,i-o),overscanStopIndex:Math.min(t-1,r)}},overscanRowCount:10,role:"grid",scrollingResetTimeInterval:150,scrollToAlignment:"auto",scrollToColumn:-1,scrollToRow:-1,style:{},tabIndex:0,isScrollingOptOut:!1}),Ed(ep);const tp=ep;function op(e){var t=e.cellCount,o=e.overscanCellsCount,n=e.scrollDirection,i=e.startIndex,r=e.stopIndex;return o=Math.max(1,o),1===n?{overscanStartIndex:Math.max(0,i-1),overscanStopIndex:Math.min(t-1,r+o)}:{overscanStartIndex:Math.max(0,i-o),overscanStopIndex:Math.min(t-1,r+1)}}var np,ip;function rp(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}var ap,sp,lp=(ip=np=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"state",{scrollToColumn:0,scrollToRow:0,instanceProps:{prevScrollToColumn:0,prevScrollToRow:0}}),bt(xt(o),"_columnStartIndex",0),bt(xt(o),"_columnStopIndex",0),bt(xt(o),"_rowStartIndex",0),bt(xt(o),"_rowStopIndex",0),bt(xt(o),"_onKeyDown",(function(e){var t=o.props,n=t.columnCount,i=t.disabled,r=t.mode,a=t.rowCount;if(!i){var s=o._getScrollState(),l=s.scrollToColumn,c=s.scrollToRow,u=o._getScrollState(),d=u.scrollToColumn,p=u.scrollToRow;switch(e.key){case"ArrowDown":p="cells"===r?Math.min(p+1,a-1):Math.min(o._rowStopIndex+1,a-1);break;case"ArrowLeft":d="cells"===r?Math.max(d-1,0):Math.max(o._columnStartIndex-1,0);break;case"ArrowRight":d="cells"===r?Math.min(d+1,n-1):Math.min(o._columnStopIndex+1,n-1);break;case"ArrowUp":p="cells"===r?Math.max(p-1,0):Math.max(o._rowStartIndex-1,0)}d===l&&p===c||(e.preventDefault(),o._updateScrollState({scrollToColumn:d,scrollToRow:p}))}})),bt(xt(o),"_onSectionRendered",(function(e){var t=e.columnStartIndex,n=e.columnStopIndex,i=e.rowStartIndex,r=e.rowStopIndex;o._columnStartIndex=t,o._columnStopIndex=n,o._rowStartIndex=i,o._rowStopIndex=r})),o}return It(t,e),kt(t,[{key:"setScrollIndexes",value:function(e){var t=e.scrollToColumn,o=e.scrollToRow;this.setState({scrollToRow:o,scrollToColumn:t})}},{key:"render",value:function(){var e=this.props,t=e.className,o=e.children,n=this._getScrollState(),i=n.scrollToColumn,r=n.scrollToRow;return J.createElement("div",{className:t,onKeyDown:this._onKeyDown},o({onSectionRendered:this._onSectionRendered,scrollToColumn:i,scrollToRow:r}))}},{key:"_getScrollState",value:function(){return this.props.isControlled?this.props:this.state}},{key:"_updateScrollState",value:function(e){var t=e.scrollToColumn,o=e.scrollToRow,n=this.props,i=n.isControlled,r=n.onScrollToChange;"function"==typeof r&&r({scrollToColumn:t,scrollToRow:o}),i||this.setState({scrollToColumn:t,scrollToRow:o})}}],[{key:"getDerivedStateFromProps",value:function(e,t){return e.isControlled?{}:e.scrollToColumn!==t.instanceProps.prevScrollToColumn||e.scrollToRow!==t.instanceProps.prevScrollToRow?function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?rp(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):rp(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},t,{scrollToColumn:e.scrollToColumn,scrollToRow:e.scrollToRow,instanceProps:{prevScrollToColumn:e.scrollToColumn,prevScrollToRow:e.scrollToRow}}):{}}}]),t}(J.PureComponent),bt(np,"propTypes",null),ip);function cp(e,t){var n,i=void 0!==(n=void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:o.g).document&&n.document.attachEvent;if(!i){var r=function(){var e=n.requestAnimationFrame||n.mozRequestAnimationFrame||n.webkitRequestAnimationFrame||function(e){return n.setTimeout(e,20)};return function(t){return e(t)}}(),a=function(){var e=n.cancelAnimationFrame||n.mozCancelAnimationFrame||n.webkitCancelAnimationFrame||n.clearTimeout;return function(t){return e(t)}}(),s=function(e){var t=e.__resizeTriggers__,o=t.firstElementChild,n=t.lastElementChild,i=o.firstElementChild;n.scrollLeft=n.scrollWidth,n.scrollTop=n.scrollHeight,i.style.width=o.offsetWidth+1+"px",i.style.height=o.offsetHeight+1+"px",o.scrollLeft=o.scrollWidth,o.scrollTop=o.scrollHeight},l=function(e){if(!(e.target.className&&"function"==typeof e.target.className.indexOf&&e.target.className.indexOf("contract-trigger")<0&&e.target.className.indexOf("expand-trigger")<0)){var t=this;s(this),this.__resizeRAF__&&a(this.__resizeRAF__),this.__resizeRAF__=r((function(){(function(e){return e.offsetWidth!=e.__resizeLast__.width||e.offsetHeight!=e.__resizeLast__.height})(t)&&(t.__resizeLast__.width=t.offsetWidth,t.__resizeLast__.height=t.offsetHeight,t.__resizeListeners__.forEach((function(o){o.call(t,e)})))}))}},c=!1,u="",d="animationstart",p="Webkit Moz O ms".split(" "),h="webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),m=n.document.createElement("fakeelement");if(void 0!==m.style.animationName&&(c=!0),!1===c)for(var g=0;g<p.length;g++)if(void 0!==m.style[p[g]+"AnimationName"]){u="-"+p[g].toLowerCase()+"-",d=h[g],c=!0;break}var f="resizeanim",b="@"+u+"keyframes "+f+" { from { opacity: 0; } to { opacity: 0; } } ",_=u+"animation: 1ms "+f+"; "}return{addResizeListener:function(t,o){if(i)t.attachEvent("onresize",o);else{if(!t.__resizeTriggers__){var r=t.ownerDocument,a=n.getComputedStyle(t);a&&"static"==a.position&&(t.style.position="relative"),function(t){if(!t.getElementById("detectElementResize")){var o=(b||"")+".resize-triggers { "+(_||"")+'visibility: hidden; opacity: 0; } .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',n=t.head||t.getElementsByTagName("head")[0],i=t.createElement("style");i.id="detectElementResize",i.type="text/css",null!=e&&i.setAttribute("nonce",e),i.styleSheet?i.styleSheet.cssText=o:i.appendChild(t.createTextNode(o)),n.appendChild(i)}}(r),t.__resizeLast__={},t.__resizeListeners__=[],(t.__resizeTriggers__=r.createElement("div")).className="resize-triggers";var c='<div class="expand-trigger"><div></div></div><div class="contract-trigger"></div>';if(window.trustedTypes){var u=trustedTypes.createPolicy("react-virtualized-auto-sizer",{createHTML:function(){return c}});t.__resizeTriggers__.innerHTML=u.createHTML("")}else t.__resizeTriggers__.innerHTML=c;t.appendChild(t.__resizeTriggers__),s(t),t.addEventListener("scroll",l,!0),d&&(t.__resizeTriggers__.__animationListener__=function(e){e.animationName==f&&s(t)},t.__resizeTriggers__.addEventListener(d,t.__resizeTriggers__.__animationListener__))}t.__resizeListeners__.push(o)}},removeResizeListener:function(e,t){if(i)e.detachEvent("onresize",t);else if(e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(t),1),!e.__resizeListeners__.length){e.removeEventListener("scroll",l,!0),e.__resizeTriggers__.__animationListener__&&(e.__resizeTriggers__.removeEventListener(d,e.__resizeTriggers__.__animationListener__),e.__resizeTriggers__.__animationListener__=null);try{e.__resizeTriggers__=!e.removeChild(e.__resizeTriggers__)}catch(e){}}}}}function up(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function dp(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?up(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):up(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}bt(lp,"defaultProps",{disabled:!1,isControlled:!1,mode:"edges",scrollToColumn:0,scrollToRow:0}),Ed(lp);var pp=(sp=ap=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"state",{height:o.props.defaultHeight||0,width:o.props.defaultWidth||0}),bt(xt(o),"_parentNode",void 0),bt(xt(o),"_autoSizer",void 0),bt(xt(o),"_window",void 0),bt(xt(o),"_detectElementResize",void 0),bt(xt(o),"_onResize",(function(){var e=o.props,t=e.disableHeight,n=e.disableWidth,i=e.onResize;if(o._parentNode){var r=o._parentNode.offsetHeight||0,a=o._parentNode.offsetWidth||0,s=(o._window||window).getComputedStyle(o._parentNode)||{},l=parseInt(s.paddingLeft,10)||0,c=parseInt(s.paddingRight,10)||0,u=parseInt(s.paddingTop,10)||0,d=parseInt(s.paddingBottom,10)||0,p=r-u-d,h=a-l-c;(!t&&o.state.height!==p||!n&&o.state.width!==h)&&(o.setState({height:r-u-d,width:a-l-c}),i({height:r,width:a}))}})),bt(xt(o),"_setRef",(function(e){o._autoSizer=e})),o}return It(t,e),kt(t,[{key:"componentDidMount",value:function(){var e=this.props.nonce;this._autoSizer&&this._autoSizer.parentNode&&this._autoSizer.parentNode.ownerDocument&&this._autoSizer.parentNode.ownerDocument.defaultView&&this._autoSizer.parentNode instanceof this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement&&(this._parentNode=this._autoSizer.parentNode,this._window=this._autoSizer.parentNode.ownerDocument.defaultView,this._detectElementResize=cp(e,this._window),this._detectElementResize.addResizeListener(this._parentNode,this._onResize),this._onResize())}},{key:"componentWillUnmount",value:function(){this._detectElementResize&&this._parentNode&&this._detectElementResize.removeResizeListener(this._parentNode,this._onResize)}},{key:"render",value:function(){var e=this.props,t=e.children,o=e.className,n=e.disableHeight,i=e.disableWidth,r=e.style,a=this.state,s=a.height,l=a.width,c={overflow:"visible"},u={};return n||(c.height=0,u.height=s),i||(c.width=0,u.width=l),J.createElement("div",{className:o,ref:this._setRef,style:dp({},c,{},r)},t(u))}}]),t}(J.Component),bt(ap,"propTypes",null),sp);bt(pp,"defaultProps",{onResize:function(){},disableHeight:!1,disableWidth:!1,style:{}});var hp,mp,gp=(mp=hp=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"_child",void 0),bt(xt(o),"_measure",(function(){var e=o.props,t=e.cache,n=e.columnIndex,i=void 0===n?0:n,r=e.parent,a=e.rowIndex,s=void 0===a?o.props.index||0:a,l=o._getCellMeasurements(),c=l.height,u=l.width;c===t.getHeight(s,i)&&u===t.getWidth(s,i)||(t.set(s,i,u,c),r&&"function"==typeof r.recomputeGridSize&&r.recomputeGridSize({columnIndex:i,rowIndex:s}))})),bt(xt(o),"_registerChild",(function(e){!e||e instanceof Element||console.warn("CellMeasurer registerChild expects to be passed Element or null"),o._child=e,e&&o._maybeMeasureCell()})),o}return It(t,e),kt(t,[{key:"componentDidMount",value:function(){this._maybeMeasureCell()}},{key:"componentDidUpdate",value:function(){this._maybeMeasureCell()}},{key:"render",value:function(){var e=this.props.children;return"function"==typeof e?e({measure:this._measure,registerChild:this._registerChild}):e}},{key:"_getCellMeasurements",value:function(){var e=this.props.cache,t=this._child||(0,Pt.findDOMNode)(this);if(t&&t.ownerDocument&&t.ownerDocument.defaultView&&t instanceof t.ownerDocument.defaultView.HTMLElement){var o=t.style.width,n=t.style.height;e.hasFixedWidth()||(t.style.width="auto"),e.hasFixedHeight()||(t.style.height="auto");var i=Math.ceil(t.offsetHeight),r=Math.ceil(t.offsetWidth);return o&&(t.style.width=o),n&&(t.style.height=n),{height:i,width:r}}return{height:0,width:0}}},{key:"_maybeMeasureCell",value:function(){var e=this.props,t=e.cache,o=e.columnIndex,n=void 0===o?0:o,i=e.parent,r=e.rowIndex,a=void 0===r?this.props.index||0:r;if(!t.has(a,n)){var s=this._getCellMeasurements(),l=s.height,c=s.width;t.set(a,n,c,l),i&&"function"==typeof i.invalidateCellSizeAfterRender&&i.invalidateCellSizeAfterRender({columnIndex:n,rowIndex:a})}}}]),t}(J.PureComponent),bt(hp,"propTypes",null),mp);function fp(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function bp(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?fp(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):fp(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}bt(gp,"__internalCellMeasurerFlag",!1);var _p="requested",vp=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"state",{isScrolling:!1,scrollLeft:0,scrollTop:0}),bt(xt(o),"_calculateSizeAndPositionDataOnNextUpdate",!1),bt(xt(o),"_onSectionRenderedMemoizer",Md()),bt(xt(o),"_onScrollMemoizer",Md(!1)),bt(xt(o),"_invokeOnSectionRenderedHelper",(function(){var e=o.props,t=e.cellLayoutManager,n=e.onSectionRendered;o._onSectionRenderedMemoizer({callback:n,indices:{indices:t.getLastRenderedIndices()}})})),bt(xt(o),"_setScrollingContainerRef",(function(e){o._scrollingContainer=e})),bt(xt(o),"_updateScrollPositionForScrollToCell",(function(){var e=o.props,t=e.cellLayoutManager,n=e.height,i=e.scrollToAlignment,r=e.scrollToCell,a=e.width,s=o.state,l=s.scrollLeft,c=s.scrollTop;if(r>=0){var u=t.getScrollPositionForCell({align:i,cellIndex:r,height:n,scrollLeft:l,scrollTop:c,width:a});u.scrollLeft===l&&u.scrollTop===c||o._setScrollPosition(u)}})),bt(xt(o),"_onScroll",(function(e){if(e.target===o._scrollingContainer){o._enablePointerEventsAfterDelay();var t=o.props,n=t.cellLayoutManager,i=t.height,r=t.isScrollingChange,a=t.width,s=o._scrollbarSize,l=n.getTotalSize(),c=l.height,u=l.width,d=Math.max(0,Math.min(u-a+s,e.target.scrollLeft)),p=Math.max(0,Math.min(c-i+s,e.target.scrollTop));if(o.state.scrollLeft!==d||o.state.scrollTop!==p){var h=e.cancelable?"observed":_p;o.state.isScrolling||r(!0),o.setState({isScrolling:!0,scrollLeft:d,scrollPositionChangeReason:h,scrollTop:p})}o._invokeOnScrollMemoizer({scrollLeft:d,scrollTop:p,totalWidth:u,totalHeight:c})}})),o._scrollbarSize=Hd(),void 0===o._scrollbarSize?(o._scrollbarSizeMeasured=!1,o._scrollbarSize=0):o._scrollbarSizeMeasured=!0,o}return It(t,e),kt(t,[{key:"recomputeCellSizesAndPositions",value:function(){this._calculateSizeAndPositionDataOnNextUpdate=!0,this.forceUpdate()}},{key:"componentDidMount",value:function(){var e=this.props,t=e.cellLayoutManager,o=e.scrollLeft,n=e.scrollToCell,i=e.scrollTop;this._scrollbarSizeMeasured||(this._scrollbarSize=Hd(),this._scrollbarSizeMeasured=!0,this.setState({})),n>=0?this._updateScrollPositionForScrollToCell():(o>=0||i>=0)&&this._setScrollPosition({scrollLeft:o,scrollTop:i}),this._invokeOnSectionRenderedHelper();var r=t.getTotalSize(),a=r.height,s=r.width;this._invokeOnScrollMemoizer({scrollLeft:o||0,scrollTop:i||0,totalHeight:a,totalWidth:s})}},{key:"componentDidUpdate",value:function(e,t){var o=this.props,n=o.height,i=o.scrollToAlignment,r=o.scrollToCell,a=o.width,s=this.state,l=s.scrollLeft,c=s.scrollPositionChangeReason,u=s.scrollTop;c===_p&&(l>=0&&l!==t.scrollLeft&&l!==this._scrollingContainer.scrollLeft&&(this._scrollingContainer.scrollLeft=l),u>=0&&u!==t.scrollTop&&u!==this._scrollingContainer.scrollTop&&(this._scrollingContainer.scrollTop=u)),n===e.height&&i===e.scrollToAlignment&&r===e.scrollToCell&&a===e.width||this._updateScrollPositionForScrollToCell(),this._invokeOnSectionRenderedHelper()}},{key:"componentWillUnmount",value:function(){this._disablePointerEventsTimeoutId&&clearTimeout(this._disablePointerEventsTimeoutId)}},{key:"render",value:function(){var e=this.props,t=e.autoHeight,o=e.cellCount,n=e.cellLayoutManager,i=e.className,r=e.height,a=e.horizontalOverscanSize,s=e.id,l=e.noContentRenderer,c=e.style,u=e.verticalOverscanSize,d=e.width,p=this.state,h=p.isScrolling,m=p.scrollLeft,g=p.scrollTop;(this._lastRenderedCellCount!==o||this._lastRenderedCellLayoutManager!==n||this._calculateSizeAndPositionDataOnNextUpdate)&&(this._lastRenderedCellCount=o,this._lastRenderedCellLayoutManager=n,this._calculateSizeAndPositionDataOnNextUpdate=!1,n.calculateSizeAndPositionData());var f=n.getTotalSize(),b=f.height,_=f.width,v=Math.max(0,m-a),y=Math.max(0,g-u),k=Math.min(_,m+d+a),x=Math.min(b,g+r+u),S=r>0&&d>0?n.cellRenderers({height:x-y,isScrolling:h,width:k-v,x:v,y}):[],w={boxSizing:"border-box",direction:"ltr",height:t?"auto":r,position:"relative",WebkitOverflowScrolling:"touch",width:d,willChange:"transform"},C=b>r?this._scrollbarSize:0,I=_>d?this._scrollbarSize:0;return w.overflowX=_+C<=d?"hidden":"auto",w.overflowY=b+I<=r?"hidden":"auto",J.createElement("div",{ref:this._setScrollingContainerRef,"aria-label":this.props["aria-label"],className:Ad("ReactVirtualized__Collection",i),id:s,onScroll:this._onScroll,role:"grid",style:bp({},w,{},c),tabIndex:0},o>0&&J.createElement("div",{className:"ReactVirtualized__Collection__innerScrollContainer",style:{height:b,maxHeight:b,maxWidth:_,overflow:"hidden",pointerEvents:h?"none":"",width:_}},S),0===o&&l())}},{key:"_enablePointerEventsAfterDelay",value:function(){var e=this;this._disablePointerEventsTimeoutId&&clearTimeout(this._disablePointerEventsTimeoutId),this._disablePointerEventsTimeoutId=setTimeout((function(){(0,e.props.isScrollingChange)(!1),e._disablePointerEventsTimeoutId=null,e.setState({isScrolling:!1})}),150)}},{key:"_invokeOnScrollMemoizer",value:function(e){var t=this,o=e.scrollLeft,n=e.scrollTop,i=e.totalHeight,r=e.totalWidth;this._onScrollMemoizer({callback:function(e){var o=e.scrollLeft,n=e.scrollTop,a=t.props,s=a.height;(0,a.onScroll)({clientHeight:s,clientWidth:a.width,scrollHeight:i,scrollLeft:o,scrollTop:n,scrollWidth:r})},indices:{scrollLeft:o,scrollTop:n}})}},{key:"_setScrollPosition",value:function(e){var t=e.scrollLeft,o=e.scrollTop,n={scrollPositionChangeReason:_p};t>=0&&(n.scrollLeft=t),o>=0&&(n.scrollTop=o),(t>=0&&t!==this.state.scrollLeft||o>=0&&o!==this.state.scrollTop)&&this.setState(n)}}],[{key:"getDerivedStateFromProps",value:function(e,t){return 0!==e.cellCount||0===t.scrollLeft&&0===t.scrollTop?e.scrollLeft!==t.scrollLeft||e.scrollTop!==t.scrollTop?{scrollLeft:null!=e.scrollLeft?e.scrollLeft:t.scrollLeft,scrollTop:null!=e.scrollTop?e.scrollTop:t.scrollTop,scrollPositionChangeReason:_p}:null:{scrollLeft:0,scrollTop:0,scrollPositionChangeReason:_p}}}]),t}(J.PureComponent);bt(vp,"defaultProps",{"aria-label":"grid",horizontalOverscanSize:0,noContentRenderer:function(){return null},onScroll:function(){return null},onSectionRendered:function(){return null},scrollToAlignment:"auto",scrollToCell:-1,style:{},verticalOverscanSize:0}),vp.propTypes={},Ed(vp);const yp=vp;var kp=function(){function e(t){var o=t.height,n=t.width,i=t.x,r=t.y;vt(this,e),this.height=o,this.width=n,this.x=i,this.y=r,this._indexMap={},this._indices=[]}return kt(e,[{key:"addCellIndex",value:function(e){var t=e.index;this._indexMap[t]||(this._indexMap[t]=!0,this._indices.push(t))}},{key:"getCellIndices",value:function(){return this._indices}},{key:"toString",value:function(){return"".concat(this.x,",").concat(this.y," ").concat(this.width,"x").concat(this.height)}}]),e}(),xp=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;vt(this,e),this._sectionSize=t,this._cellMetadata=[],this._sections={}}return kt(e,[{key:"getCellIndices",value:function(e){var t=e.height,o=e.width,n=e.x,i=e.y,r={};return this.getSections({height:t,width:o,x:n,y:i}).forEach((function(e){return e.getCellIndices().forEach((function(e){r[e]=e}))})),Object.keys(r).map((function(e){return r[e]}))}},{key:"getCellMetadata",value:function(e){var t=e.index;return this._cellMetadata[t]}},{key:"getSections",value:function(e){for(var t=e.height,o=e.width,n=e.x,i=e.y,r=Math.floor(n/this._sectionSize),a=Math.floor((n+o-1)/this._sectionSize),s=Math.floor(i/this._sectionSize),l=Math.floor((i+t-1)/this._sectionSize),c=[],u=r;u<=a;u++)for(var d=s;d<=l;d++){var p="".concat(u,".").concat(d);this._sections[p]||(this._sections[p]=new kp({height:this._sectionSize,width:this._sectionSize,x:u*this._sectionSize,y:d*this._sectionSize})),c.push(this._sections[p])}return c}},{key:"getTotalSectionCount",value:function(){return Object.keys(this._sections).length}},{key:"toString",value:function(){var e=this;return Object.keys(this._sections).map((function(t){return e._sections[t].toString()}))}},{key:"registerCell",value:function(e){var t=e.cellMetadatum,o=e.index;this._cellMetadata[o]=t,this.getSections(t).forEach((function(e){return e.addCellIndex({index:o})}))}}]),e}();function Sp(e){var t=e.align,o=void 0===t?"auto":t,n=e.cellOffset,i=e.cellSize,r=e.containerSize,a=e.currentOffset,s=n,l=s-r+i;switch(o){case"start":return s;case"end":return l;case"center":return s-(r-i)/2;default:return Math.max(l,Math.min(s,a))}}var Cp=function(e){function t(e,o){var n;return vt(this,t),(n=St(this,wt(t).call(this,e,o)))._cellMetadata=[],n._lastRenderedCellIndices=[],n._cellCache=[],n._isScrollingChange=n._isScrollingChange.bind(xt(n)),n._setCollectionViewRef=n._setCollectionViewRef.bind(xt(n)),n}return It(t,e),kt(t,[{key:"forceUpdate",value:function(){void 0!==this._collectionView&&this._collectionView.forceUpdate()}},{key:"recomputeCellSizesAndPositions",value:function(){this._cellCache=[],this._collectionView.recomputeCellSizesAndPositions()}},{key:"render",value:function(){var e=Y({},this.props);return J.createElement(yp,Y({cellLayoutManager:this,isScrollingChange:this._isScrollingChange,ref:this._setCollectionViewRef},e))}},{key:"calculateSizeAndPositionData",value:function(){var e=this.props,t=function(e){for(var t=e.cellCount,o=e.cellSizeAndPositionGetter,n=[],i=new xp(e.sectionSize),r=0,a=0,s=0;s<t;s++){var l=o({index:s});if(null==l.height||isNaN(l.height)||null==l.width||isNaN(l.width)||null==l.x||isNaN(l.x)||null==l.y||isNaN(l.y))throw Error("Invalid metadata returned for cell ".concat(s,":\n x:").concat(l.x,", y:").concat(l.y,", width:").concat(l.width,", height:").concat(l.height));r=Math.max(r,l.y+l.height),a=Math.max(a,l.x+l.width),n[s]=l,i.registerCell({cellMetadatum:l,index:s})}return{cellMetadata:n,height:r,sectionManager:i,width:a}}({cellCount:e.cellCount,cellSizeAndPositionGetter:e.cellSizeAndPositionGetter,sectionSize:e.sectionSize});this._cellMetadata=t.cellMetadata,this._sectionManager=t.sectionManager,this._height=t.height,this._width=t.width}},{key:"getLastRenderedIndices",value:function(){return this._lastRenderedCellIndices}},{key:"getScrollPositionForCell",value:function(e){var t=e.align,o=e.cellIndex,n=e.height,i=e.scrollLeft,r=e.scrollTop,a=e.width,s=this.props.cellCount;if(o>=0&&o<s){var l=this._cellMetadata[o];i=Sp({align:t,cellOffset:l.x,cellSize:l.width,containerSize:a,currentOffset:i,targetIndex:o}),r=Sp({align:t,cellOffset:l.y,cellSize:l.height,containerSize:n,currentOffset:r,targetIndex:o})}return{scrollLeft:i,scrollTop:r}}},{key:"getTotalSize",value:function(){return{height:this._height,width:this._width}}},{key:"cellRenderers",value:function(e){var t=this,o=e.height,n=e.isScrolling,i=e.width,r=e.x,a=e.y,s=this.props,l=s.cellGroupRenderer,c=s.cellRenderer;return this._lastRenderedCellIndices=this._sectionManager.getCellIndices({height:o,width:i,x:r,y:a}),l({cellCache:this._cellCache,cellRenderer:c,cellSizeAndPositionGetter:function(e){var o=e.index;return t._sectionManager.getCellMetadata({index:o})},indices:this._lastRenderedCellIndices,isScrolling:n})}},{key:"_isScrollingChange",value:function(e){e||(this._cellCache=[])}},{key:"_setCollectionViewRef",value:function(e){this._collectionView=e}}]),t}(J.PureComponent);bt(Cp,"defaultProps",{"aria-label":"grid",cellGroupRenderer:function(e){var t=e.cellCache,o=e.cellRenderer,n=e.cellSizeAndPositionGetter,i=e.indices,r=e.isScrolling;return i.map((function(e){var i=n({index:e}),a={index:e,isScrolling:r,key:e,style:{height:i.height,left:i.x,position:"absolute",top:i.y,width:i.width}};return r?(e in t||(t[e]=o(a)),t[e]):o(a)})).filter((function(e){return!!e}))}}),Cp.propTypes={},(function(e){function t(e,o){var n;return vt(this,t),(n=St(this,wt(t).call(this,e,o)))._registerChild=n._registerChild.bind(xt(n)),n}return It(t,e),kt(t,[{key:"componentDidUpdate",value:function(e){var t=this.props,o=t.columnMaxWidth,n=t.columnMinWidth,i=t.columnCount,r=t.width;o===e.columnMaxWidth&&n===e.columnMinWidth&&i===e.columnCount&&r===e.width||this._registeredChild&&this._registeredChild.recomputeGridSize()}},{key:"render",value:function(){var e=this.props,t=e.children,o=e.columnMaxWidth,n=e.columnMinWidth,i=e.columnCount,r=e.width,a=n||1,s=o?Math.min(o,r):r,l=r/i;return l=Math.max(a,l),l=Math.min(s,l),l=Math.floor(l),t({adjustedWidth:Math.min(r,l*i),columnWidth:l,getColumnWidth:function(){return l},registerChild:this._registerChild})}},{key:"_registerChild",value:function(e){if(e&&"function"!=typeof e.recomputeGridSize)throw Error("Unexpected child type registered; only Grid/MultiGrid children are supported.");this._registeredChild=e,this._registeredChild&&this._registeredChild.recomputeGridSize()}}]),t}(J.PureComponent)).propTypes={};var Ip=function(e){function t(e,o){var n;return vt(this,t),(n=St(this,wt(t).call(this,e,o)))._loadMoreRowsMemoizer=Md(),n._onRowsRendered=n._onRowsRendered.bind(xt(n)),n._registerChild=n._registerChild.bind(xt(n)),n}return It(t,e),kt(t,[{key:"resetLoadMoreRowsCache",value:function(e){this._loadMoreRowsMemoizer=Md(),e&&this._doStuff(this._lastRenderedStartIndex,this._lastRenderedStopIndex)}},{key:"render",value:function(){return(0,this.props.children)({onRowsRendered:this._onRowsRendered,registerChild:this._registerChild})}},{key:"_loadUnloadedRanges",value:function(e){var t=this,o=this.props.loadMoreRows;e.forEach((function(e){var n=o(e);n&&n.then((function(){var o;(o={lastRenderedStartIndex:t._lastRenderedStartIndex,lastRenderedStopIndex:t._lastRenderedStopIndex,startIndex:e.startIndex,stopIndex:e.stopIndex}).startIndex>o.lastRenderedStopIndex||o.stopIndex<o.lastRenderedStartIndex||t._registeredChild&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o="function"==typeof e.recomputeGridSize?e.recomputeGridSize:e.recomputeRowHeights;o?o.call(e,t):e.forceUpdate()}(t._registeredChild,t._lastRenderedStartIndex)}))}))}},{key:"_onRowsRendered",value:function(e){var t=e.startIndex,o=e.stopIndex;this._lastRenderedStartIndex=t,this._lastRenderedStopIndex=o,this._doStuff(t,o)}},{key:"_doStuff",value:function(e,t){var o,n=this,i=this.props,r=i.isRowLoaded,a=i.minimumBatchSize,s=i.rowCount,l=i.threshold,c=function(e){for(var t=e.isRowLoaded,o=e.minimumBatchSize,n=e.rowCount,i=e.stopIndex,r=[],a=null,s=null,l=e.startIndex;l<=i;l++)t({index:l})?null!==s&&(r.push({startIndex:a,stopIndex:s}),a=s=null):(s=l,null===a&&(a=l));if(null!==s){for(var c=Math.min(Math.max(s,a+o-1),n-1),u=s+1;u<=c&&!t({index:u});u++)s=u;r.push({startIndex:a,stopIndex:s})}if(r.length)for(var d=r[0];d.stopIndex-d.startIndex+1<o&&d.startIndex>0;){var p=d.startIndex-1;if(t({index:p}))break;d.startIndex=p}return r}({isRowLoaded:r,minimumBatchSize:a,rowCount:s,startIndex:Math.max(0,e-l),stopIndex:Math.min(s-1,t+l)}),u=(o=[]).concat.apply(o,At(c.map((function(e){return[e.startIndex,e.stopIndex]}))));this._loadMoreRowsMemoizer({callback:function(){n._loadUnloadedRanges(c)},indices:{squashedUnloadedRanges:u}})}},{key:"_registerChild",value:function(e){this._registeredChild=e}}]),t}(J.PureComponent);bt(Ip,"defaultProps",{minimumBatchSize:10,rowCount:0,threshold:15}),Ip.propTypes={};var jp,Tp,Pp=(Tp=jp=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"Grid",void 0),bt(xt(o),"_cellRenderer",(function(e){var t=e.parent,n=e.rowIndex,i=e.style,r=e.isScrolling,a=e.isVisible,s=e.key,l=o.props.rowRenderer,c=Object.getOwnPropertyDescriptor(i,"width");return c&&c.writable&&(i.width="100%"),l({index:n,style:i,isScrolling:r,isVisible:a,key:s,parent:t})})),bt(xt(o),"_setRef",(function(e){o.Grid=e})),bt(xt(o),"_onScroll",(function(e){var t=e.clientHeight,n=e.scrollHeight,i=e.scrollTop;(0,o.props.onScroll)({clientHeight:t,scrollHeight:n,scrollTop:i})})),bt(xt(o),"_onSectionRendered",(function(e){var t=e.rowOverscanStartIndex,n=e.rowOverscanStopIndex,i=e.rowStartIndex,r=e.rowStopIndex;(0,o.props.onRowsRendered)({overscanStartIndex:t,overscanStopIndex:n,startIndex:i,stopIndex:r})})),o}return It(t,e),kt(t,[{key:"forceUpdateGrid",value:function(){this.Grid&&this.Grid.forceUpdate()}},{key:"getOffsetForRow",value:function(e){var t=e.alignment,o=e.index;return this.Grid?this.Grid.getOffsetForCell({alignment:t,rowIndex:o,columnIndex:0}).scrollTop:0}},{key:"invalidateCellSizeAfterRender",value:function(e){var t=e.columnIndex,o=e.rowIndex;this.Grid&&this.Grid.invalidateCellSizeAfterRender({rowIndex:o,columnIndex:t})}},{key:"measureAllRows",value:function(){this.Grid&&this.Grid.measureAllCells()}},{key:"recomputeGridSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.columnIndex,o=void 0===t?0:t,n=e.rowIndex,i=void 0===n?0:n;this.Grid&&this.Grid.recomputeGridSize({rowIndex:i,columnIndex:o})}},{key:"recomputeRowHeights",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.Grid&&this.Grid.recomputeGridSize({rowIndex:e,columnIndex:0})}},{key:"scrollToPosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.Grid&&this.Grid.scrollToPosition({scrollTop:e})}},{key:"scrollToRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.Grid&&this.Grid.scrollToCell({columnIndex:0,rowIndex:e})}},{key:"render",value:function(){var e=this.props,t=e.className,o=e.noRowsRenderer,n=e.scrollToIndex,i=e.width,r=Ad("ReactVirtualized__List",t);return J.createElement(tp,Y({},this.props,{autoContainerWidth:!0,cellRenderer:this._cellRenderer,className:r,columnWidth:i,columnCount:1,noContentRenderer:o,onScroll:this._onScroll,onSectionRendered:this._onSectionRendered,ref:this._setRef,scrollToRow:n}))}}]),t}(J.PureComponent),bt(jp,"propTypes",null),Tp);bt(Pp,"defaultProps",{autoHeight:!1,estimatedRowSize:30,onScroll:function(){},noRowsRenderer:function(){return null},onRowsRendered:function(){},overscanIndicesGetter:op,overscanRowCount:10,scrollToAlignment:"auto",scrollToIndex:-1,style:{}});const Ep=function(e,t,o,n,i){return"function"==typeof o?function(e,t,o,n,i){for(var r=o+1;t<=o;){var a=t+o>>>1;i(e[a],n)>=0?(r=a,o=a-1):t=a+1}return r}(e,void 0===n?0:0|n,void 0===i?e.length-1:0|i,t,o):function(e,t,o,n){for(var i=o+1;t<=o;){var r=t+o>>>1;e[r]>=n?(i=r,o=r-1):t=r+1}return i}(e,void 0===o?0:0|o,void 0===n?e.length-1:0|n,t)};function Rp(e,t,o,n,i){this.mid=e,this.left=t,this.right=o,this.leftPoints=n,this.rightPoints=i,this.count=(t?t.count:0)+(o?o.count:0)+n.length}var Ap=Rp.prototype;function Op(e,t){e.mid=t.mid,e.left=t.left,e.right=t.right,e.leftPoints=t.leftPoints,e.rightPoints=t.rightPoints,e.count=t.count}function Np(e,t){var o=Up(t);e.mid=o.mid,e.left=o.left,e.right=o.right,e.leftPoints=o.leftPoints,e.rightPoints=o.rightPoints,e.count=o.count}function Bp(e,t){var o=e.intervals([]);o.push(t),Np(e,o)}function Dp(e,t){var o=e.intervals([]),n=o.indexOf(t);return n<0?0:(o.splice(n,1),Np(e,o),1)}function Mp(e,t,o){for(var n=0;n<e.length&&e[n][0]<=t;++n){var i=o(e[n]);if(i)return i}}function Lp(e,t,o){for(var n=e.length-1;n>=0&&e[n][1]>=t;--n){var i=o(e[n]);if(i)return i}}function zp(e,t){for(var o=0;o<e.length;++o){var n=t(e[o]);if(n)return n}}function Fp(e,t){return e-t}function Gp(e,t){return e[0]-t[0]||e[1]-t[1]}function Hp(e,t){return e[1]-t[1]||e[0]-t[0]}function Up(e){if(0===e.length)return null;for(var t=[],o=0;o<e.length;++o)t.push(e[o][0],e[o][1]);t.sort(Fp);var n=t[t.length>>1],i=[],r=[],a=[];for(o=0;o<e.length;++o){var s=e[o];s[1]<n?i.push(s):n<s[0]?r.push(s):a.push(s)}var l=a,c=a.slice();return l.sort(Gp),c.sort(Hp),new Rp(n,Up(i),Up(r),l,c)}function Wp(e){this.root=e}Ap.intervals=function(e){return e.push.apply(e,this.leftPoints),this.left&&this.left.intervals(e),this.right&&this.right.intervals(e),e},Ap.insert=function(e){var t=this.count-this.leftPoints.length;if(this.count+=1,e[1]<this.mid)this.left?4*(this.left.count+1)>3*(t+1)?Bp(this,e):this.left.insert(e):this.left=Up([e]);else if(e[0]>this.mid)this.right?4*(this.right.count+1)>3*(t+1)?Bp(this,e):this.right.insert(e):this.right=Up([e]);else{var o=Ep(this.leftPoints,e,Gp),n=Ep(this.rightPoints,e,Hp);this.leftPoints.splice(o,0,e),this.rightPoints.splice(n,0,e)}},Ap.remove=function(e){var t=this.count-this.leftPoints;if(e[1]<this.mid)return this.left?4*(this.right?this.right.count:0)>3*(t-1)?Dp(this,e):2===(r=this.left.remove(e))?(this.left=null,this.count-=1,1):(1===r&&(this.count-=1),r):0;if(e[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(t-1)?Dp(this,e):2===(r=this.right.remove(e))?(this.right=null,this.count-=1,1):(1===r&&(this.count-=1),r):0;if(1===this.count)return this.leftPoints[0]===e?2:0;if(1===this.leftPoints.length&&this.leftPoints[0]===e){if(this.left&&this.right){for(var o=this,n=this.left;n.right;)o=n,n=n.right;if(o===this)n.right=this.right;else{var i=this.left,r=this.right;o.count-=n.count,o.right=n.left,n.left=i,n.right=r}Op(this,n),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?Op(this,this.left):Op(this,this.right);return 1}for(i=Ep(this.leftPoints,e,Gp);i<this.leftPoints.length&&this.leftPoints[i][0]===e[0];++i)if(this.leftPoints[i]===e)for(this.count-=1,this.leftPoints.splice(i,1),r=Ep(this.rightPoints,e,Hp);r<this.rightPoints.length&&this.rightPoints[r][1]===e[1];++r)if(this.rightPoints[r]===e)return this.rightPoints.splice(r,1),1;return 0},Ap.queryPoint=function(e,t){return e<this.mid?this.left&&(o=this.left.queryPoint(e,t))?o:Mp(this.leftPoints,e,t):e>this.mid?this.right&&(o=this.right.queryPoint(e,t))?o:Lp(this.rightPoints,e,t):zp(this.leftPoints,t);var o},Ap.queryInterval=function(e,t,o){var n;return e<this.mid&&this.left&&(n=this.left.queryInterval(e,t,o))||t>this.mid&&this.right&&(n=this.right.queryInterval(e,t,o))?n:t<this.mid?Mp(this.leftPoints,t,o):e>this.mid?Lp(this.rightPoints,e,o):zp(this.leftPoints,o)};var Vp=Wp.prototype;Vp.insert=function(e){this.root?this.root.insert(e):this.root=new Rp(e[0],null,null,[e],[e])},Vp.remove=function(e){if(this.root){var t=this.root.remove(e);return 2===t&&(this.root=null),0!==t}return!1},Vp.queryPoint=function(e,t){if(this.root)return this.root.queryPoint(e,t)},Vp.queryInterval=function(e,t,o){if(e<=t&&this.root)return this.root.queryInterval(e,t,o)},Object.defineProperty(Vp,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(Vp,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}});var Kp,$p,qp=function(){function e(){vt(this,e),bt(this,"_columnSizeMap",{}),bt(this,"_intervalTree",new Wp(null)),bt(this,"_leftMap",{})}return kt(e,[{key:"estimateTotalHeight",value:function(e,t,o){var n=e-this.count;return this.tallestColumnSize+Math.ceil(n/t)*o}},{key:"range",value:function(e,t,o){var n=this;this._intervalTree.queryInterval(e,e+t,(function(e){var t=mt(e,3),i=t[0],r=(t[1],t[2]);return o(r,n._leftMap[r],i)}))}},{key:"setPosition",value:function(e,t,o,n){this._intervalTree.insert([o,o+n,e]),this._leftMap[e]=t;var i=this._columnSizeMap,r=i[t];i[t]=void 0===r?o+n:Math.max(r,o+n)}},{key:"count",get:function(){return this._intervalTree.count}},{key:"shortestColumnSize",get:function(){var e=this._columnSizeMap,t=0;for(var o in e){var n=e[o];t=0===t?n:Math.min(t,n)}return t}},{key:"tallestColumnSize",get:function(){var e=this._columnSizeMap,t=0;for(var o in e){var n=e[o];t=Math.max(t,n)}return t}}]),e}();function Yp(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function Zp(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?Yp(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):Yp(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var Xp=($p=Kp=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"state",{isScrolling:!1,scrollTop:0}),bt(xt(o),"_debounceResetIsScrollingId",void 0),bt(xt(o),"_invalidateOnUpdateStartIndex",null),bt(xt(o),"_invalidateOnUpdateStopIndex",null),bt(xt(o),"_positionCache",new qp),bt(xt(o),"_startIndex",null),bt(xt(o),"_startIndexMemoized",null),bt(xt(o),"_stopIndex",null),bt(xt(o),"_stopIndexMemoized",null),bt(xt(o),"_debounceResetIsScrollingCallback",(function(){o.setState({isScrolling:!1})})),bt(xt(o),"_setScrollingContainerRef",(function(e){o._scrollingContainer=e})),bt(xt(o),"_onScroll",(function(e){var t=o.props.height,n=e.currentTarget.scrollTop,i=Math.min(Math.max(0,o._getEstimatedTotalHeight()-t),n);n===i&&(o._debounceResetIsScrolling(),o.state.scrollTop!==i&&o.setState({isScrolling:!0,scrollTop:i}))})),o}return It(t,e),kt(t,[{key:"clearCellPositions",value:function(){this._positionCache=new qp,this.forceUpdate()}},{key:"invalidateCellSizeAfterRender",value:function(e){var t=e.rowIndex;null===this._invalidateOnUpdateStartIndex?(this._invalidateOnUpdateStartIndex=t,this._invalidateOnUpdateStopIndex=t):(this._invalidateOnUpdateStartIndex=Math.min(this._invalidateOnUpdateStartIndex,t),this._invalidateOnUpdateStopIndex=Math.max(this._invalidateOnUpdateStopIndex,t))}},{key:"recomputeCellPositions",value:function(){var e=this._positionCache.count-1;this._positionCache=new qp,this._populatePositionCache(0,e),this.forceUpdate()}},{key:"componentDidMount",value:function(){this._checkInvalidateOnUpdate(),this._invokeOnScrollCallback(),this._invokeOnCellsRenderedCallback()}},{key:"componentDidUpdate",value:function(e,t){this._checkInvalidateOnUpdate(),this._invokeOnScrollCallback(),this._invokeOnCellsRenderedCallback(),this.props.scrollTop!==e.scrollTop&&this._debounceResetIsScrolling()}},{key:"componentWillUnmount",value:function(){this._debounceResetIsScrollingId&&Yd(this._debounceResetIsScrollingId)}},{key:"render",value:function(){var e,t=this,o=this.props,n=o.autoHeight,i=o.cellCount,r=o.cellMeasurerCache,a=o.cellRenderer,s=o.className,l=o.height,c=o.id,u=o.keyMapper,d=o.overscanByPixels,p=o.role,h=o.style,m=o.tabIndex,g=o.width,f=o.rowDirection,b=this.state,_=b.isScrolling,v=b.scrollTop,y=[],k=this._getEstimatedTotalHeight(),x=this._positionCache.shortestColumnSize,S=this._positionCache.count,w=0;if(this._positionCache.range(Math.max(0,v-d),l+2*d,(function(o,n,i){var s;void 0===e?(w=o,e=o):(w=Math.min(w,o),e=Math.max(e,o)),y.push(a({index:o,isScrolling:_,key:u(o),parent:t,style:(s={height:r.getHeight(o)},bt(s,"ltr"===f?"left":"right",n),bt(s,"position","absolute"),bt(s,"top",i),bt(s,"width",r.getWidth(o)),s)}))})),x<v+l+d&&S<i)for(var C=Math.min(i-S,Math.ceil((v+l+d-x)/r.defaultHeight*g/r.defaultWidth)),I=S;I<S+C;I++)e=I,y.push(a({index:I,isScrolling:_,key:u(I),parent:this,style:{width:r.getWidth(I)}}));return this._startIndex=w,this._stopIndex=e,J.createElement("div",{ref:this._setScrollingContainerRef,"aria-label":this.props["aria-label"],className:Ad("ReactVirtualized__Masonry",s),id:c,onScroll:this._onScroll,role:p,style:Zp({boxSizing:"border-box",direction:"ltr",height:n?"auto":l,overflowX:"hidden",overflowY:k<l?"hidden":"auto",position:"relative",width:g,WebkitOverflowScrolling:"touch",willChange:"transform"},h),tabIndex:m},J.createElement("div",{className:"ReactVirtualized__Masonry__innerScrollContainer",style:{width:"100%",height:k,maxWidth:"100%",maxHeight:k,overflow:"hidden",pointerEvents:_?"none":"",position:"relative"}},y))}},{key:"_checkInvalidateOnUpdate",value:function(){if("number"==typeof this._invalidateOnUpdateStartIndex){var e=this._invalidateOnUpdateStartIndex,t=this._invalidateOnUpdateStopIndex;this._invalidateOnUpdateStartIndex=null,this._invalidateOnUpdateStopIndex=null,this._populatePositionCache(e,t),this.forceUpdate()}}},{key:"_debounceResetIsScrolling",value:function(){var e=this.props.scrollingResetTimeInterval;this._debounceResetIsScrollingId&&Yd(this._debounceResetIsScrollingId),this._debounceResetIsScrollingId=Zd(this._debounceResetIsScrollingCallback,e)}},{key:"_getEstimatedTotalHeight",value:function(){var e=this.props,t=e.cellCount,o=e.cellMeasurerCache,n=e.width,i=Math.max(1,Math.floor(n/o.defaultWidth));return this._positionCache.estimateTotalHeight(t,i,o.defaultHeight)}},{key:"_invokeOnScrollCallback",value:function(){var e=this.props,t=e.height,o=e.onScroll,n=this.state.scrollTop;this._onScrollMemoized!==n&&(o({clientHeight:t,scrollHeight:this._getEstimatedTotalHeight(),scrollTop:n}),this._onScrollMemoized=n)}},{key:"_invokeOnCellsRenderedCallback",value:function(){this._startIndexMemoized===this._startIndex&&this._stopIndexMemoized===this._stopIndex||((0,this.props.onCellsRendered)({startIndex:this._startIndex,stopIndex:this._stopIndex}),this._startIndexMemoized=this._startIndex,this._stopIndexMemoized=this._stopIndex)}},{key:"_populatePositionCache",value:function(e,t){for(var o=this.props,n=o.cellMeasurerCache,i=o.cellPositioner,r=e;r<=t;r++){var a=i(r),s=a.left,l=a.top;this._positionCache.setPosition(r,s,l,n.getHeight(r))}}}],[{key:"getDerivedStateFromProps",value:function(e,t){return void 0!==e.scrollTop&&t.scrollTop!==e.scrollTop?{isScrolling:!0,scrollTop:e.scrollTop}:null}}]),t}(J.PureComponent),bt(Kp,"propTypes",null),$p);function Jp(){}bt(Xp,"defaultProps",{autoHeight:!1,keyMapper:function(e){return e},onCellsRendered:Jp,onScroll:Jp,overscanByPixels:20,role:"grid",scrollingResetTimeInterval:150,style:{},tabIndex:0,rowDirection:"ltr"}),Ed(Xp);var Qp=function(){function e(){var t=this,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};vt(this,e),bt(this,"_cellMeasurerCache",void 0),bt(this,"_columnIndexOffset",void 0),bt(this,"_rowIndexOffset",void 0),bt(this,"columnWidth",(function(e){var o=e.index;t._cellMeasurerCache.columnWidth({index:o+t._columnIndexOffset})})),bt(this,"rowHeight",(function(e){var o=e.index;t._cellMeasurerCache.rowHeight({index:o+t._rowIndexOffset})}));var n=o.cellMeasurerCache,i=o.columnIndexOffset,r=void 0===i?0:i,a=o.rowIndexOffset,s=void 0===a?0:a;this._cellMeasurerCache=n,this._columnIndexOffset=r,this._rowIndexOffset=s}return kt(e,[{key:"clear",value:function(e,t){this._cellMeasurerCache.clear(e+this._rowIndexOffset,t+this._columnIndexOffset)}},{key:"clearAll",value:function(){this._cellMeasurerCache.clearAll()}},{key:"hasFixedHeight",value:function(){return this._cellMeasurerCache.hasFixedHeight()}},{key:"hasFixedWidth",value:function(){return this._cellMeasurerCache.hasFixedWidth()}},{key:"getHeight",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._cellMeasurerCache.getHeight(e+this._rowIndexOffset,t+this._columnIndexOffset)}},{key:"getWidth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._cellMeasurerCache.getWidth(e+this._rowIndexOffset,t+this._columnIndexOffset)}},{key:"has",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._cellMeasurerCache.has(e+this._rowIndexOffset,t+this._columnIndexOffset)}},{key:"set",value:function(e,t,o,n){this._cellMeasurerCache.set(e+this._rowIndexOffset,t+this._columnIndexOffset,o,n)}},{key:"defaultHeight",get:function(){return this._cellMeasurerCache.defaultHeight}},{key:"defaultWidth",get:function(){return this._cellMeasurerCache.defaultWidth}}]),e}();function eh(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function th(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?eh(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):eh(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var oh=function(e){function t(e,o){var n;vt(this,t),bt(xt(n=St(this,wt(t).call(this,e,o))),"state",{scrollLeft:0,scrollTop:0,scrollbarSize:0,showHorizontalScrollbar:!1,showVerticalScrollbar:!1}),bt(xt(n),"_deferredInvalidateColumnIndex",null),bt(xt(n),"_deferredInvalidateRowIndex",null),bt(xt(n),"_bottomLeftGridRef",(function(e){n._bottomLeftGrid=e})),bt(xt(n),"_bottomRightGridRef",(function(e){n._bottomRightGrid=e})),bt(xt(n),"_cellRendererBottomLeftGrid",(function(e){var t=e.rowIndex,o=Nd(e,["rowIndex"]),i=n.props,r=i.cellRenderer,a=i.fixedRowCount;return t===i.rowCount-a?J.createElement("div",{key:o.key,style:th({},o.style,{height:20})}):r(th({},o,{parent:xt(n),rowIndex:t+a}))})),bt(xt(n),"_cellRendererBottomRightGrid",(function(e){var t=e.columnIndex,o=e.rowIndex,i=Nd(e,["columnIndex","rowIndex"]),r=n.props,a=r.cellRenderer,s=r.fixedColumnCount,l=r.fixedRowCount;return a(th({},i,{columnIndex:t+s,parent:xt(n),rowIndex:o+l}))})),bt(xt(n),"_cellRendererTopRightGrid",(function(e){var t=e.columnIndex,o=Nd(e,["columnIndex"]),i=n.props,r=i.cellRenderer,a=i.columnCount,s=i.fixedColumnCount;return t===a-s?J.createElement("div",{key:o.key,style:th({},o.style,{width:20})}):r(th({},o,{columnIndex:t+s,parent:xt(n)}))})),bt(xt(n),"_columnWidthRightGrid",(function(e){var t=e.index,o=n.props,i=o.columnCount,r=o.fixedColumnCount,a=o.columnWidth,s=n.state,l=s.scrollbarSize;return s.showHorizontalScrollbar&&t===i-r?l:"function"==typeof a?a({index:t+r}):a})),bt(xt(n),"_onScroll",(function(e){var t=e.scrollLeft,o=e.scrollTop;n.setState({scrollLeft:t,scrollTop:o});var i=n.props.onScroll;i&&i(e)})),bt(xt(n),"_onScrollbarPresenceChange",(function(e){var t=e.horizontal,o=e.size,i=e.vertical,r=n.state,a=r.showHorizontalScrollbar,s=r.showVerticalScrollbar;if(t!==a||i!==s){n.setState({scrollbarSize:o,showHorizontalScrollbar:t,showVerticalScrollbar:i});var l=n.props.onScrollbarPresenceChange;"function"==typeof l&&l({horizontal:t,size:o,vertical:i})}})),bt(xt(n),"_onScrollLeft",(function(e){var t=e.scrollLeft;n._onScroll({scrollLeft:t,scrollTop:n.state.scrollTop})})),bt(xt(n),"_onScrollTop",(function(e){var t=e.scrollTop;n._onScroll({scrollTop:t,scrollLeft:n.state.scrollLeft})})),bt(xt(n),"_rowHeightBottomGrid",(function(e){var t=e.index,o=n.props,i=o.fixedRowCount,r=o.rowCount,a=o.rowHeight,s=n.state,l=s.scrollbarSize;return s.showVerticalScrollbar&&t===r-i?l:"function"==typeof a?a({index:t+i}):a})),bt(xt(n),"_topLeftGridRef",(function(e){n._topLeftGrid=e})),bt(xt(n),"_topRightGridRef",(function(e){n._topRightGrid=e}));var i=e.deferredMeasurementCache,r=e.fixedColumnCount,a=e.fixedRowCount;return n._maybeCalculateCachedStyles(!0),i&&(n._deferredMeasurementCacheBottomLeftGrid=a>0?new Qp({cellMeasurerCache:i,columnIndexOffset:0,rowIndexOffset:a}):i,n._deferredMeasurementCacheBottomRightGrid=r>0||a>0?new Qp({cellMeasurerCache:i,columnIndexOffset:r,rowIndexOffset:a}):i,n._deferredMeasurementCacheTopRightGrid=r>0?new Qp({cellMeasurerCache:i,columnIndexOffset:r,rowIndexOffset:0}):i),n}return It(t,e),kt(t,[{key:"forceUpdateGrids",value:function(){this._bottomLeftGrid&&this._bottomLeftGrid.forceUpdate(),this._bottomRightGrid&&this._bottomRightGrid.forceUpdate(),this._topLeftGrid&&this._topLeftGrid.forceUpdate(),this._topRightGrid&&this._topRightGrid.forceUpdate()}},{key:"invalidateCellSizeAfterRender",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.columnIndex,o=void 0===t?0:t,n=e.rowIndex,i=void 0===n?0:n;this._deferredInvalidateColumnIndex="number"==typeof this._deferredInvalidateColumnIndex?Math.min(this._deferredInvalidateColumnIndex,o):o,this._deferredInvalidateRowIndex="number"==typeof this._deferredInvalidateRowIndex?Math.min(this._deferredInvalidateRowIndex,i):i}},{key:"measureAllCells",value:function(){this._bottomLeftGrid&&this._bottomLeftGrid.measureAllCells(),this._bottomRightGrid&&this._bottomRightGrid.measureAllCells(),this._topLeftGrid&&this._topLeftGrid.measureAllCells(),this._topRightGrid&&this._topRightGrid.measureAllCells()}},{key:"recomputeGridSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.columnIndex,o=void 0===t?0:t,n=e.rowIndex,i=void 0===n?0:n,r=this.props,a=r.fixedColumnCount,s=r.fixedRowCount,l=Math.max(0,o-a),c=Math.max(0,i-s);this._bottomLeftGrid&&this._bottomLeftGrid.recomputeGridSize({columnIndex:o,rowIndex:c}),this._bottomRightGrid&&this._bottomRightGrid.recomputeGridSize({columnIndex:l,rowIndex:c}),this._topLeftGrid&&this._topLeftGrid.recomputeGridSize({columnIndex:o,rowIndex:i}),this._topRightGrid&&this._topRightGrid.recomputeGridSize({columnIndex:l,rowIndex:i}),this._leftGridWidth=null,this._topGridHeight=null,this._maybeCalculateCachedStyles(!0)}},{key:"componentDidMount",value:function(){var e=this.props,t=e.scrollLeft,o=e.scrollTop;if(t>0||o>0){var n={};t>0&&(n.scrollLeft=t),o>0&&(n.scrollTop=o),this.setState(n)}this._handleInvalidatedGridSize()}},{key:"componentDidUpdate",value:function(){this._handleInvalidatedGridSize()}},{key:"render",value:function(){var e=this.props,t=e.onScroll,o=e.onSectionRendered,n=(e.onScrollbarPresenceChange,e.scrollLeft,e.scrollToColumn),i=(e.scrollTop,e.scrollToRow),r=Nd(e,["onScroll","onSectionRendered","onScrollbarPresenceChange","scrollLeft","scrollToColumn","scrollTop","scrollToRow"]);if(this._prepareForRender(),0===this.props.width||0===this.props.height)return null;var a=this.state,s=a.scrollLeft,l=a.scrollTop;return J.createElement("div",{style:this._containerOuterStyle},J.createElement("div",{style:this._containerTopStyle},this._renderTopLeftGrid(r),this._renderTopRightGrid(th({},r,{onScroll:t,scrollLeft:s}))),J.createElement("div",{style:this._containerBottomStyle},this._renderBottomLeftGrid(th({},r,{onScroll:t,scrollTop:l})),this._renderBottomRightGrid(th({},r,{onScroll:t,onSectionRendered:o,scrollLeft:s,scrollToColumn:n,scrollToRow:i,scrollTop:l}))))}},{key:"_getBottomGridHeight",value:function(e){return e.height-this._getTopGridHeight(e)}},{key:"_getLeftGridWidth",value:function(e){var t=e.fixedColumnCount,o=e.columnWidth;if(null==this._leftGridWidth)if("function"==typeof o){for(var n=0,i=0;i<t;i++)n+=o({index:i});this._leftGridWidth=n}else this._leftGridWidth=o*t;return this._leftGridWidth}},{key:"_getRightGridWidth",value:function(e){return e.width-this._getLeftGridWidth(e)}},{key:"_getTopGridHeight",value:function(e){var t=e.fixedRowCount,o=e.rowHeight;if(null==this._topGridHeight)if("function"==typeof o){for(var n=0,i=0;i<t;i++)n+=o({index:i});this._topGridHeight=n}else this._topGridHeight=o*t;return this._topGridHeight}},{key:"_handleInvalidatedGridSize",value:function(){if("number"==typeof this._deferredInvalidateColumnIndex){var e=this._deferredInvalidateColumnIndex,t=this._deferredInvalidateRowIndex;this._deferredInvalidateColumnIndex=null,this._deferredInvalidateRowIndex=null,this.recomputeGridSize({columnIndex:e,rowIndex:t}),this.forceUpdate()}}},{key:"_maybeCalculateCachedStyles",value:function(e){var t=this.props,o=t.columnWidth,n=t.enableFixedColumnScroll,i=t.enableFixedRowScroll,r=t.height,a=t.fixedColumnCount,s=t.fixedRowCount,l=t.rowHeight,c=t.style,u=t.styleBottomLeftGrid,d=t.styleBottomRightGrid,p=t.styleTopLeftGrid,h=t.styleTopRightGrid,m=t.width,g=e||r!==this._lastRenderedHeight||m!==this._lastRenderedWidth,f=e||o!==this._lastRenderedColumnWidth||a!==this._lastRenderedFixedColumnCount,b=e||s!==this._lastRenderedFixedRowCount||l!==this._lastRenderedRowHeight;(e||g||c!==this._lastRenderedStyle)&&(this._containerOuterStyle=th({height:r,overflow:"visible",width:m},c)),(e||g||b)&&(this._containerTopStyle={height:this._getTopGridHeight(this.props),position:"relative",width:m},this._containerBottomStyle={height:r-this._getTopGridHeight(this.props),overflow:"visible",position:"relative",width:m}),(e||u!==this._lastRenderedStyleBottomLeftGrid)&&(this._bottomLeftGridStyle=th({left:0,overflowX:"hidden",overflowY:n?"auto":"hidden",position:"absolute"},u)),(e||f||d!==this._lastRenderedStyleBottomRightGrid)&&(this._bottomRightGridStyle=th({left:this._getLeftGridWidth(this.props),position:"absolute"},d)),(e||p!==this._lastRenderedStyleTopLeftGrid)&&(this._topLeftGridStyle=th({left:0,overflowX:"hidden",overflowY:"hidden",position:"absolute",top:0},p)),(e||f||h!==this._lastRenderedStyleTopRightGrid)&&(this._topRightGridStyle=th({left:this._getLeftGridWidth(this.props),overflowX:i?"auto":"hidden",overflowY:"hidden",position:"absolute",top:0},h)),this._lastRenderedColumnWidth=o,this._lastRenderedFixedColumnCount=a,this._lastRenderedFixedRowCount=s,this._lastRenderedHeight=r,this._lastRenderedRowHeight=l,this._lastRenderedStyle=c,this._lastRenderedStyleBottomLeftGrid=u,this._lastRenderedStyleBottomRightGrid=d,this._lastRenderedStyleTopLeftGrid=p,this._lastRenderedStyleTopRightGrid=h,this._lastRenderedWidth=m}},{key:"_prepareForRender",value:function(){this._lastRenderedColumnWidth===this.props.columnWidth&&this._lastRenderedFixedColumnCount===this.props.fixedColumnCount||(this._leftGridWidth=null),this._lastRenderedFixedRowCount===this.props.fixedRowCount&&this._lastRenderedRowHeight===this.props.rowHeight||(this._topGridHeight=null),this._maybeCalculateCachedStyles(),this._lastRenderedColumnWidth=this.props.columnWidth,this._lastRenderedFixedColumnCount=this.props.fixedColumnCount,this._lastRenderedFixedRowCount=this.props.fixedRowCount,this._lastRenderedRowHeight=this.props.rowHeight}},{key:"_renderBottomLeftGrid",value:function(e){var t=e.enableFixedColumnScroll,o=e.fixedColumnCount,n=e.fixedRowCount,i=e.rowCount,r=e.hideBottomLeftGridScrollbar,a=this.state.showVerticalScrollbar;if(!o)return null;var s=a?1:0,l=this._getBottomGridHeight(e),c=this._getLeftGridWidth(e),u=this.state.showVerticalScrollbar?this.state.scrollbarSize:0,d=r?c+u:c,p=J.createElement(tp,Y({},e,{cellRenderer:this._cellRendererBottomLeftGrid,className:this.props.classNameBottomLeftGrid,columnCount:o,deferredMeasurementCache:this._deferredMeasurementCacheBottomLeftGrid,height:l,onScroll:t?this._onScrollTop:void 0,ref:this._bottomLeftGridRef,rowCount:Math.max(0,i-n)+s,rowHeight:this._rowHeightBottomGrid,style:this._bottomLeftGridStyle,tabIndex:null,width:d}));return r?J.createElement("div",{className:"BottomLeftGrid_ScrollWrapper",style:th({},this._bottomLeftGridStyle,{height:l,width:c,overflowY:"hidden"})},p):p}},{key:"_renderBottomRightGrid",value:function(e){var t=e.columnCount,o=e.fixedColumnCount,n=e.fixedRowCount,i=e.rowCount,r=e.scrollToColumn,a=e.scrollToRow;return J.createElement(tp,Y({},e,{cellRenderer:this._cellRendererBottomRightGrid,className:this.props.classNameBottomRightGrid,columnCount:Math.max(0,t-o),columnWidth:this._columnWidthRightGrid,deferredMeasurementCache:this._deferredMeasurementCacheBottomRightGrid,height:this._getBottomGridHeight(e),onScroll:this._onScroll,onScrollbarPresenceChange:this._onScrollbarPresenceChange,ref:this._bottomRightGridRef,rowCount:Math.max(0,i-n),rowHeight:this._rowHeightBottomGrid,scrollToColumn:r-o,scrollToRow:a-n,style:this._bottomRightGridStyle,width:this._getRightGridWidth(e)}))}},{key:"_renderTopLeftGrid",value:function(e){var t=e.fixedColumnCount,o=e.fixedRowCount;return t&&o?J.createElement(tp,Y({},e,{className:this.props.classNameTopLeftGrid,columnCount:t,height:this._getTopGridHeight(e),ref:this._topLeftGridRef,rowCount:o,style:this._topLeftGridStyle,tabIndex:null,width:this._getLeftGridWidth(e)})):null}},{key:"_renderTopRightGrid",value:function(e){var t=e.columnCount,o=e.enableFixedRowScroll,n=e.fixedColumnCount,i=e.fixedRowCount,r=e.scrollLeft,a=e.hideTopRightGridScrollbar,s=this.state,l=s.showHorizontalScrollbar,c=s.scrollbarSize;if(!i)return null;var u=l?1:0,d=this._getTopGridHeight(e),p=this._getRightGridWidth(e),h=l?c:0,m=d,g=this._topRightGridStyle;a&&(m=d+h,g=th({},this._topRightGridStyle,{left:0}));var f=J.createElement(tp,Y({},e,{cellRenderer:this._cellRendererTopRightGrid,className:this.props.classNameTopRightGrid,columnCount:Math.max(0,t-n)+u,columnWidth:this._columnWidthRightGrid,deferredMeasurementCache:this._deferredMeasurementCacheTopRightGrid,height:m,onScroll:o?this._onScrollLeft:void 0,ref:this._topRightGridRef,rowCount:i,scrollLeft:r,style:g,tabIndex:null,width:p}));return a?J.createElement("div",{className:"TopRightGrid_ScrollWrapper",style:th({},this._topRightGridStyle,{height:d,width:p,overflowX:"hidden"})},f):f}}],[{key:"getDerivedStateFromProps",value:function(e,t){return e.scrollLeft!==t.scrollLeft||e.scrollTop!==t.scrollTop?{scrollLeft:null!=e.scrollLeft&&e.scrollLeft>=0?e.scrollLeft:t.scrollLeft,scrollTop:null!=e.scrollTop&&e.scrollTop>=0?e.scrollTop:t.scrollTop}:null}}]),t}(J.PureComponent);function nh(e){var t=e.className,o=e.columns,n=e.style;return J.createElement("div",{className:t,role:"row",style:n},o)}bt(oh,"defaultProps",{classNameBottomLeftGrid:"",classNameBottomRightGrid:"",classNameTopLeftGrid:"",classNameTopRightGrid:"",enableFixedColumnScroll:!1,enableFixedRowScroll:!1,fixedColumnCount:0,fixedRowCount:0,scrollToColumn:-1,scrollToRow:-1,style:{},styleBottomLeftGrid:{},styleBottomRightGrid:{},styleTopLeftGrid:{},styleTopRightGrid:{},hideTopRightGridScrollbar:!1,hideBottomLeftGridScrollbar:!1}),oh.propTypes={},Ed(oh),(function(e){function t(e,o){var n;return vt(this,t),(n=St(this,wt(t).call(this,e,o))).state={clientHeight:0,clientWidth:0,scrollHeight:0,scrollLeft:0,scrollTop:0,scrollWidth:0},n._onScroll=n._onScroll.bind(xt(n)),n}return It(t,e),kt(t,[{key:"render",value:function(){var e=this.props.children,t=this.state,o=t.clientHeight,n=t.clientWidth,i=t.scrollHeight,r=t.scrollLeft,a=t.scrollTop,s=t.scrollWidth;return e({clientHeight:o,clientWidth:n,onScroll:this._onScroll,scrollHeight:i,scrollLeft:r,scrollTop:a,scrollWidth:s})}},{key:"_onScroll",value:function(e){var t=e.clientHeight,o=e.clientWidth,n=e.scrollHeight,i=e.scrollLeft,r=e.scrollTop,a=e.scrollWidth;this.setState({clientHeight:t,clientWidth:o,scrollHeight:n,scrollLeft:i,scrollTop:r,scrollWidth:a})}}]),t}(J.PureComponent)).propTypes={},nh.propTypes=null;const ih={ASC:"ASC",DESC:"DESC"};function rh(e){var t=e.sortDirection,o=Ad("ReactVirtualized__Table__sortableHeaderIcon",{"ReactVirtualized__Table__sortableHeaderIcon--ASC":t===ih.ASC,"ReactVirtualized__Table__sortableHeaderIcon--DESC":t===ih.DESC});return J.createElement("svg",{className:o,width:18,height:18,viewBox:"0 0 24 24"},t===ih.ASC?J.createElement("path",{d:"M7 14l5-5 5 5z"}):J.createElement("path",{d:"M7 10l5 5 5-5z"}),J.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}))}function ah(e){var t=e.dataKey,o=e.label,n=e.sortBy,i=e.sortDirection,r=n===t,a=[J.createElement("span",{className:"ReactVirtualized__Table__headerTruncatedText",key:"label",title:"string"==typeof o?o:null},o)];return r&&a.push(J.createElement(rh,{key:"SortIndicator",sortDirection:i})),a}function sh(e){var t=e.className,o=e.columns,n=e.index,i=e.key,r=e.onRowClick,a=e.onRowDoubleClick,s=e.onRowMouseOut,l=e.onRowMouseOver,c=e.onRowRightClick,u=e.rowData,d=e.style,p={"aria-rowindex":n+1};return(r||a||s||l||c)&&(p["aria-label"]="row",p.tabIndex=0,r&&(p.onClick=function(e){return r({event:e,index:n,rowData:u})}),a&&(p.onDoubleClick=function(e){return a({event:e,index:n,rowData:u})}),s&&(p.onMouseOut=function(e){return s({event:e,index:n,rowData:u})}),l&&(p.onMouseOver=function(e){return l({event:e,index:n,rowData:u})}),c&&(p.onContextMenu=function(e){return c({event:e,index:n,rowData:u})})),J.createElement("div",Y({},p,{className:t,key:i,role:"row",style:d}),o)}rh.propTypes={},ah.propTypes=null,sh.propTypes=null;var lh=function(e){function t(){return vt(this,t),St(this,wt(t).apply(this,arguments))}return It(t,e),t}(J.Component);function ch(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function uh(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ch(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ch(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}bt(lh,"defaultProps",{cellDataGetter:function(e){var t=e.dataKey,o=e.rowData;return"function"==typeof o.get?o.get(t):o[t]},cellRenderer:function(e){var t=e.cellData;return null==t?"":String(t)},defaultSortDirection:ih.ASC,flexGrow:0,flexShrink:1,headerRenderer:ah,style:{}}),lh.propTypes={};var dh=function(e){function t(e){var o;return vt(this,t),(o=St(this,wt(t).call(this,e))).state={scrollbarWidth:0},o._createColumn=o._createColumn.bind(xt(o)),o._createRow=o._createRow.bind(xt(o)),o._onScroll=o._onScroll.bind(xt(o)),o._onSectionRendered=o._onSectionRendered.bind(xt(o)),o._setRef=o._setRef.bind(xt(o)),o}return It(t,e),kt(t,[{key:"forceUpdateGrid",value:function(){this.Grid&&this.Grid.forceUpdate()}},{key:"getOffsetForRow",value:function(e){var t=e.alignment,o=e.index;return this.Grid?this.Grid.getOffsetForCell({alignment:t,rowIndex:o}).scrollTop:0}},{key:"invalidateCellSizeAfterRender",value:function(e){var t=e.columnIndex,o=e.rowIndex;this.Grid&&this.Grid.invalidateCellSizeAfterRender({rowIndex:o,columnIndex:t})}},{key:"measureAllRows",value:function(){this.Grid&&this.Grid.measureAllCells()}},{key:"recomputeGridSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.columnIndex,o=void 0===t?0:t,n=e.rowIndex,i=void 0===n?0:n;this.Grid&&this.Grid.recomputeGridSize({rowIndex:i,columnIndex:o})}},{key:"recomputeRowHeights",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.Grid&&this.Grid.recomputeGridSize({rowIndex:e})}},{key:"scrollToPosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.Grid&&this.Grid.scrollToPosition({scrollTop:e})}},{key:"scrollToRow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.Grid&&this.Grid.scrollToCell({columnIndex:0,rowIndex:e})}},{key:"getScrollbarWidth",value:function(){if(this.Grid){var e=(0,Pt.findDOMNode)(this.Grid),t=e.clientWidth||0;return(e.offsetWidth||0)-t}return 0}},{key:"componentDidMount",value:function(){this._setScrollbarWidth()}},{key:"componentDidUpdate",value:function(){this._setScrollbarWidth()}},{key:"render",value:function(){var e=this,t=this.props,o=t.children,n=t.className,i=t.disableHeader,r=t.gridClassName,a=t.gridStyle,s=t.headerHeight,l=t.headerRowRenderer,c=t.height,u=t.id,d=t.noRowsRenderer,p=t.rowClassName,h=t.rowStyle,m=t.scrollToIndex,g=t.style,f=t.width,b=this.state.scrollbarWidth,_=i?c:c-s,v="function"==typeof p?p({index:-1}):p,y="function"==typeof h?h({index:-1}):h;return this._cachedColumnStyles=[],J.Children.toArray(o).forEach((function(t,o){var n=e._getFlexStyleForColumn(t,t.props.style);e._cachedColumnStyles[o]=uh({overflow:"hidden"},n)})),J.createElement("div",{"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-colcount":J.Children.toArray(o).length,"aria-rowcount":this.props.rowCount,className:Ad("ReactVirtualized__Table",n),id:u,role:"grid",style:g},!i&&l({className:Ad("ReactVirtualized__Table__headerRow",v),columns:this._getHeaderColumns(),style:uh({height:s,overflow:"hidden",paddingRight:b,width:f},y)}),J.createElement(tp,Y({},this.props,{"aria-readonly":null,autoContainerWidth:!0,className:Ad("ReactVirtualized__Table__Grid",r),cellRenderer:this._createRow,columnWidth:f,columnCount:1,height:_,id:void 0,noContentRenderer:d,onScroll:this._onScroll,onSectionRendered:this._onSectionRendered,ref:this._setRef,role:"rowgroup",scrollbarWidth:b,scrollToRow:m,style:uh({},a,{overflowX:"hidden"})})))}},{key:"_createColumn",value:function(e){var t=e.column,o=e.columnIndex,n=e.isScrolling,i=e.parent,r=e.rowData,a=e.rowIndex,s=this.props.onColumnClick,l=t.props,c=l.cellDataGetter,u=l.cellRenderer,d=l.className,p=l.columnData,h=l.dataKey,m=l.id,g=u({cellData:c({columnData:p,dataKey:h,rowData:r}),columnData:p,columnIndex:o,dataKey:h,isScrolling:n,parent:i,rowData:r,rowIndex:a}),f=this._cachedColumnStyles[o],b="string"==typeof g?g:null;return J.createElement("div",{"aria-colindex":o+1,"aria-describedby":m,className:Ad("ReactVirtualized__Table__rowColumn",d),key:"Row"+a+"-Col"+o,onClick:function(e){s&&s({columnData:p,dataKey:h,event:e})},role:"gridcell",style:f,title:b},g)}},{key:"_createHeader",value:function(e){var t,o,n,i,r,a=e.column,s=e.index,l=this.props,c=l.headerClassName,u=l.headerStyle,d=l.onHeaderClick,p=l.sort,h=l.sortBy,m=l.sortDirection,g=a.props,f=g.columnData,b=g.dataKey,_=g.defaultSortDirection,v=g.disableSort,y=g.headerRenderer,k=g.id,x=g.label,S=!v&&p,w=Ad("ReactVirtualized__Table__headerColumn",c,a.props.headerClassName,{ReactVirtualized__Table__sortableHeaderColumn:S}),C=this._getFlexStyleForColumn(a,uh({},u,{},a.props.headerStyle)),I=y({columnData:f,dataKey:b,disableSort:v,label:x,sortBy:h,sortDirection:m});if(S||d){var j=h!==b?_:m===ih.DESC?ih.ASC:ih.DESC,T=function(e){S&&p({defaultSortDirection:_,event:e,sortBy:b,sortDirection:j}),d&&d({columnData:f,dataKey:b,event:e})};r=a.props["aria-label"]||x||b,i="none",n=0,t=T,o=function(e){"Enter"!==e.key&&" "!==e.key||T(e)}}return h===b&&(i=m===ih.ASC?"ascending":"descending"),J.createElement("div",{"aria-label":r,"aria-sort":i,className:w,id:k,key:"Header-Col"+s,onClick:t,onKeyDown:o,role:"columnheader",style:C,tabIndex:n},I)}},{key:"_createRow",value:function(e){var t=this,o=e.rowIndex,n=e.isScrolling,i=e.key,r=e.parent,a=e.style,s=this.props,l=s.children,c=s.onRowClick,u=s.onRowDoubleClick,d=s.onRowRightClick,p=s.onRowMouseOver,h=s.onRowMouseOut,m=s.rowClassName,g=s.rowGetter,f=s.rowRenderer,b=s.rowStyle,_=this.state.scrollbarWidth,v="function"==typeof m?m({index:o}):m,y="function"==typeof b?b({index:o}):b,k=g({index:o}),x=J.Children.toArray(l).map((function(e,i){return t._createColumn({column:e,columnIndex:i,isScrolling:n,parent:r,rowData:k,rowIndex:o,scrollbarWidth:_})})),S=Ad("ReactVirtualized__Table__row",v),w=uh({},a,{height:this._getRowHeight(o),overflow:"hidden",paddingRight:_},y);return f({className:S,columns:x,index:o,isScrolling:n,key:i,onRowClick:c,onRowDoubleClick:u,onRowRightClick:d,onRowMouseOver:p,onRowMouseOut:h,rowData:k,style:w})}},{key:"_getFlexStyleForColumn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o="".concat(e.props.flexGrow," ").concat(e.props.flexShrink," ").concat(e.props.width,"px"),n=uh({},t,{flex:o,msFlex:o,WebkitFlex:o});return e.props.maxWidth&&(n.maxWidth=e.props.maxWidth),e.props.minWidth&&(n.minWidth=e.props.minWidth),n}},{key:"_getHeaderColumns",value:function(){var e=this,t=this.props,o=t.children;return(t.disableHeader?[]:J.Children.toArray(o)).map((function(t,o){return e._createHeader({column:t,index:o})}))}},{key:"_getRowHeight",value:function(e){var t=this.props.rowHeight;return"function"==typeof t?t({index:e}):t}},{key:"_onScroll",value:function(e){var t=e.clientHeight,o=e.scrollHeight,n=e.scrollTop;(0,this.props.onScroll)({clientHeight:t,scrollHeight:o,scrollTop:n})}},{key:"_onSectionRendered",value:function(e){var t=e.rowOverscanStartIndex,o=e.rowOverscanStopIndex,n=e.rowStartIndex,i=e.rowStopIndex;(0,this.props.onRowsRendered)({overscanStartIndex:t,overscanStopIndex:o,startIndex:n,stopIndex:i})}},{key:"_setRef",value:function(e){this.Grid=e}},{key:"_setScrollbarWidth",value:function(){var e=this.getScrollbarWidth();this.setState({scrollbarWidth:e})}}]),t}(J.PureComponent);bt(dh,"defaultProps",{disableHeader:!1,estimatedRowSize:30,headerHeight:0,headerStyle:{},noRowsRenderer:function(){return null},onRowsRendered:function(){return null},onScroll:function(){return null},overscanIndicesGetter:op,overscanRowCount:10,rowRenderer:sh,headerRowRenderer:nh,rowStyle:{},scrollToAlignment:"auto",scrollToIndex:-1,style:{}}),dh.propTypes={};var ph=[],hh=null,mh=null;function gh(){mh&&(mh=null,document.body&&null!=hh&&(document.body.style.pointerEvents=hh),hh=null)}function fh(){gh(),ph.forEach((function(e){return e.__resetIsScrolling()}))}function bh(e){e.currentTarget===window&&null==hh&&document.body&&(hh=document.body.style.pointerEvents,document.body.style.pointerEvents="none"),function(){mh&&Yd(mh);var e=0;ph.forEach((function(t){e=Math.max(e,t.props.scrollingResetTimeInterval)})),mh=Zd(fh,e)}(),ph.forEach((function(t){t.props.scrollElement===e.currentTarget&&t.__handleWindowScrollEvent()}))}function _h(e,t){ph.some((function(e){return e.props.scrollElement===t}))||t.addEventListener("scroll",bh),ph.push(e)}function vh(e,t){(ph=ph.filter((function(t){return t!==e}))).length||(t.removeEventListener("scroll",bh),mh&&(Yd(mh),gh()))}var yh,kh,xh=function(e){return e===window},Sh=function(e){return e.getBoundingClientRect()};function wh(e,t){if(e){if(xh(e)){var o=window,n=o.innerHeight,i=o.innerWidth;return{height:"number"==typeof n?n:0,width:"number"==typeof i?i:0}}return Sh(e)}return{height:t.serverHeight,width:t.serverWidth}}function Ch(e){return xh(e)&&document.documentElement?{top:"scrollY"in window?window.scrollY:document.documentElement.scrollTop,left:"scrollX"in window?window.scrollX:document.documentElement.scrollLeft}:{top:e.scrollTop,left:e.scrollLeft}}function Ih(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}var jh=function(){return"undefined"!=typeof window?window:void 0},Th=(kh=yh=function(e){function t(){var e,o;vt(this,t);for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return bt(xt(o=St(this,(e=wt(t)).call.apply(e,[this].concat(i)))),"_window",jh()),bt(xt(o),"_isMounted",!1),bt(xt(o),"_positionFromTop",0),bt(xt(o),"_positionFromLeft",0),bt(xt(o),"_detectElementResize",void 0),bt(xt(o),"_child",void 0),bt(xt(o),"state",function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?Ih(o,!0).forEach((function(t){bt(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):Ih(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},wh(o.props.scrollElement,o.props),{isScrolling:!1,scrollLeft:0,scrollTop:0})),bt(xt(o),"_registerChild",(function(e){!e||e instanceof Element||console.warn("WindowScroller registerChild expects to be passed Element or null"),o._child=e,o.updatePosition()})),bt(xt(o),"_onChildScroll",(function(e){var t=e.scrollTop;if(o.state.scrollTop!==t){var n=o.props.scrollElement;n&&("function"==typeof n.scrollTo?n.scrollTo(0,t+o._positionFromTop):n.scrollTop=t+o._positionFromTop)}})),bt(xt(o),"_registerResizeListener",(function(e){e===window?window.addEventListener("resize",o._onResize,!1):o._detectElementResize.addResizeListener(e,o._onResize)})),bt(xt(o),"_unregisterResizeListener",(function(e){e===window?window.removeEventListener("resize",o._onResize,!1):e&&o._detectElementResize.removeResizeListener(e,o._onResize)})),bt(xt(o),"_onResize",(function(){o.updatePosition()})),bt(xt(o),"__handleWindowScrollEvent",(function(){if(o._isMounted){var e=o.props.onScroll,t=o.props.scrollElement;if(t){var n=Ch(t),i=Math.max(0,n.left-o._positionFromLeft),r=Math.max(0,n.top-o._positionFromTop);o.setState({isScrolling:!0,scrollLeft:i,scrollTop:r}),e({scrollLeft:i,scrollTop:r})}}})),bt(xt(o),"__resetIsScrolling",(function(){o.setState({isScrolling:!1})})),o}return It(t,e),kt(t,[{key:"updatePosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.scrollElement,t=this.props.onResize,o=this.state,n=o.height,i=o.width,r=this._child||Pt.findDOMNode(this);if(r instanceof Element&&e){var a=function(e,t){if(xh(t)&&document.documentElement){var o=document.documentElement,n=Sh(e),i=Sh(o);return{top:n.top-i.top,left:n.left-i.left}}var r=Ch(t),a=Sh(e),s=Sh(t);return{top:a.top+r.top-s.top,left:a.left+r.left-s.left}}(r,e);this._positionFromTop=a.top,this._positionFromLeft=a.left}var s=wh(e,this.props);n===s.height&&i===s.width||(this.setState({height:s.height,width:s.width}),t({height:s.height,width:s.width}))}},{key:"componentDidMount",value:function(){var e=this.props.scrollElement;this._detectElementResize=cp(),this.updatePosition(e),e&&(_h(this,e),this._registerResizeListener(e)),this._isMounted=!0}},{key:"componentDidUpdate",value:function(e,t){var o=this.props.scrollElement,n=e.scrollElement;n!==o&&null!=n&&null!=o&&(this.updatePosition(o),vh(this,n),_h(this,o),this._unregisterResizeListener(n),this._registerResizeListener(o))}},{key:"componentWillUnmount",value:function(){var e=this.props.scrollElement;e&&(vh(this,e),this._unregisterResizeListener(e)),this._isMounted=!1}},{key:"render",value:function(){var e=this.props.children,t=this.state,o=t.isScrolling,n=t.scrollTop,i=t.scrollLeft,r=t.height,a=t.width;return e({onChildScroll:this._onChildScroll,registerChild:this._registerChild,height:r,isScrolling:o,scrollLeft:i,scrollTop:n,width:a})}}]),t}(J.PureComponent),bt(yh,"propTypes",null),kh);bt(Th,"defaultProps",{onResize:function(){},onScroll:function(){},scrollingResetTimeInterval:150,scrollElement:jh(),serverHeight:0,serverWidth:0});const Ph=(0,u.memo)((e=>{const[t,o]=(0,u.useState)(!1),[n,i]=(0,u.useState)(Math.random());return(0,u.useEffect)((()=>{o(!0)}),[]),(0,s.useEffectDeep)((()=>{i(Math.random)}),[e.list]),(0,g.jsx)("div",{className:"kubio-predefined-layouts__virtual-grid",children:t&&(0,g.jsx)(Eh,{...e},n)})})),Eh=(0,u.memo)((({list:e,onSelect:t,ListItemComponent:o})=>{var n;const i=(0,u.useRef)(),[r,a]=(0,u.useState)(Math.random()),[l,c]=(0,u.useState)(Rh()),d=(0,u.useMemo)((()=>{const t=l;let o=0,n=0;const i=[];return e.forEach((e=>{0===o&&(i[n]=[]),i[n][o]=e,o===t-1?(o=0,n++):o++})),i}),[e,l,r]),p=(0,u.useCallback)((({columnIndex:e,key:n,rowIndex:i,style:r})=>{const a=d[i][e];return a?(0,g.jsx)("div",{style:r,children:(0,g.jsx)(o,{value:a,onSelect:t},a.uniqueId)},n):(0,g.jsx)(g.Fragment,{})}),[d,r]),h=(0,u.useMemo)((()=>{const e=document.querySelector(".kubio-predefined-layouts__modal-layout__list");if(!e)return null;const t=window.getComputedStyle(e),o=parseInt(t.paddingLeft)+parseInt(t.paddingRight),n=parseInt(t.paddingTop)+parseInt(t.paddingBottom),i=e.clientWidth-o,r=e.clientHeight-n-5,a=i/l;return{containerWidth:i,containerHeight:r,columnWidth:a,columnHeight:a}}),[l,r]),m=null===(n=v().get(d,"0",[]))||void 0===n?void 0:n.length,f=(0,u.useCallback)((()=>{const e=Rh();e!==l&&c(e),a(Math.random())}),[l,c,a]),b=(0,s.useDebounce)(f,50);return(0,u.useEffect)((()=>(window.addEventListener("resize",b),()=>{window.removeEventListener("resize",b)})),[b]),(0,g.jsx)("div",{ref:i,className:"kubio-predefined-layouts__virtual-grid__inner",children:h&&(0,g.jsx)(tp,{cellRenderer:p,columnCount:m,columnWidth:h.columnWidth,rowCount:d.length,rowHeight:h.columnHeight,height:h.containerHeight,width:h.containerWidth},r)})})),Rh=()=>{const e=document.querySelector(".kubio-predefined-layouts__virtual-grid");if(e)return parseInt(getComputedStyle(e).getPropertyValue("--number-columns"))},Ah=e=>e.preventDefault(),Oh=(0,u.memo)((({title:e,onClose:t=v().noop,className:o,children:n,...i})=>{const r=(0,u.useRef)(),a=(0,u.useMemo)((()=>document.querySelector(".kubio-predefined-layouts__popup-slot")),[]),l=(0,u.useCallback)((e=>{var o;null!=e&&null!==(o=e.target)&&void 0!==o&&o.closest(".kubio-predefined-layouts__inner-modal")||t()}),[t]);return(0,s.useOnClickOutside)(r,l),(0,u.createPortal)((0,g.jsx)("div",{className:X()("kubio-predefined-layouts__inner-modal__overlay",o),onClick:Ah,onMouseDown:Ah,...i,children:(0,g.jsx)("div",{className:"kubio-predefined-layouts__inner-modal",ref:r,children:(0,g.jsxs)("div",{className:" components-modal__content",children:[(0,g.jsxs)("div",{className:"components-modal__header",children:[(0,g.jsx)("div",{className:"components-modal__header-heading-container",children:(0,g.jsx)("h1",{className:"components-modal__header-heading",children:e})}),(0,g.jsx)(h.Button,{onClick:t,icon:Ke,label:(0,m.__)("Close dialog","kubio")})]}),n]})})}),a)})),Nh=(0,u.memo)((()=>(0,g.jsxs)("div",{className:"kubio-predefined-layouts__loading-overlay",children:[(0,g.jsx)(h.Icon,{icon:He.KubioLoader}),";"]}))),Bh=(0,u.memo)((({searchPlaceholder:e=(0,m.__)("Find a starter site…","kubio")})=>(0,g.jsxs)(Fm.Sidebar,{children:[(0,g.jsx)(Fm.Sidebar.Header,{}),(0,g.jsxs)(Fm.Sidebar.Content,{children:[(0,g.jsx)(Am.Slot,{}),(0,g.jsx)(Cd,{placeholder:e}),(0,g.jsx)(bd,{})]})]}))),Dh=(0,u.memo)((({value:e={},onSelect:t})=>{const{screenshot:o,isPro:n,label:i,slug:r,uniqueId:a,relatedDemoSite:s}=e,l=(0,u.useMemo)((()=>!n&&s?null==s?void 0:s.screenshot:o),[a,n,o,s]),c=v().get(s,"slug");return(0,g.jsx)(Sd,{screenshot:l,label:i,isPack:!0,uniqueId:a,isPro:n,onClick:()=>{t(e)},favoriteType:"demoSite",favoriteId:r,relatedFavoriteId:c})}));var Mh=o(246),Lh=o.n(Mh);const zh=(0,u.memo)((({list:e,onSelect:t})=>{const o=(0,u.useRef)(),[n,i]=(0,u.useState)(1),r=(0,u.useMemo)((()=>{let t=20*n;return t=Math.min(e.length,t),e.slice(0,t)}),[n,e]),a=(0,u.useCallback)((()=>{const t=n+1;20*t-20>e.length||i(t)}),[i,n,e]),l=(0,s.useDebounce)(a,100),c=(0,u.useMemo)((()=>e.length!==r.length),[r,e]);return(0,g.jsx)("div",{className:"kubio-predefined-layouts__screenshot-list kubio-predefined-layouts__screenshot-list--infinite-list",ref:o,children:(0,g.jsx)(Lh(),{pageStart:0,initialLoad:!1,useWindow:!1,loadMore:l,hasMore:c,threshold:2e3,loader:(0,g.jsx)("div",{className:"loader"},0),children:r.map(((e,o)=>(0,g.jsx)(Dh,{value:e,onSelect:t},e.slug+"__"+o)))})})})),Fh=()=>{const{onSelectDemo:e}=rf(),{list:t}=Xg(),o=(0,u.useCallback)((t=>{e(null==t?void 0:t.slug)}),[e]);return(0,g.jsx)(Fm.Page.Content,{children:(0,g.jsx)(zh,{list:t,onSelect:o})})},Gh=(0,u.memo)((()=>{const{currentDemoSite:e}=rf();return(0,g.jsxs)(Fm.Sidebar,{className:"kubio-predefined-layouts__preview-page__sidebar",children:[(0,g.jsx)(Fm.Sidebar.Header,{children:(0,m.__)("Import Starter Site","kubio")}),(0,g.jsx)(Fm.Sidebar.Content,{children:(0,g.jsx)(Sd,{showAnimationAtLoad:!0,...e,showFavorite:!1,showLabel:!1})}),(0,g.jsx)(Fm.Sidebar.Footer,{children:(0,g.jsx)("div",{className:"d-flex justify-content-end align-items-center",children:(0,g.jsx)("a",{href:null==e?void 0:e.preview,target:"_blank",rel:"noreferrer",children:(0,m.__)("Preview starter site","kubio")})})})]})})),Hh={ACTIVE:(0,m.__)("Active","kubio"),INSTALLED:(0,m.__)("Installed","kubio"),NOT_INSTALLED:(0,m.__)("Not installed","kubio")},Uh=v().get(window,["kubioUtilsData","plugins_states"],{}),Wh=(0,u.memo)((()=>{const{currentDemoSite:e}=rf(),t=(0,u.useMemo)((()=>{const t=v().get(e,"plugins",[]);return Array.isArray(t)?t.map((e=>{const t=v().get(Uh,null==e?void 0:e.slug),o=v().get(Hh,t);return{...e,statusLabel:o}})):[]}),[e]);return(0,g.jsx)(g.Fragment,{children:t.map((({slug:e,label:t,statusLabel:o})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("li",{className:"kubio-predefined-layouts__demo-site-import-page__plugin",children:(0,g.jsxs)("div",{className:"d-flex justify-content-between",children:[(0,g.jsx)("span",{className:"d-flex align-items-center",children:t}),(0,g.jsx)("span",{className:"kubio-predefined-layouts__demo-site-import-page__plugin__status",children:o})]})},e),(0,g.jsx)("hr",{})]})))})})),Vh=(0,u.memo)((()=>{const{currentDemoSite:e}=rf(),t=!v().isEmpty(null==e?void 0:e.plugins);return(0,g.jsxs)("div",{className:"kubio-predefined-layouts__demo-site-import-page__import-panel",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__demo-site-import-page__import-panel__title",children:(0,m.__)("You are about to import a demo site","kubio")}),(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:(0,m.__)("Current pages will be moved to trash. You can restore the content back at any time.","kubio")}),(0,g.jsx)("li",{children:(0,m.__)("Posts, pages, images, widgets, menus and other theme settings will get imported.","kubio")}),(0,g.jsx)("li",{className:"text-danger",children:(0,m.__)("Your current design will be completely overwritten by the new template. This process is irreversible. If you wish to be able to go back to the current design,please create a backup of your site before proceedingwith the import.","kubio")})]})]}),t&&(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__demo-site-import-page__import-panel__title",children:(0,m.__)("The following plugins will be installed as they are part of the demo","kubio")}),(0,g.jsx)("ul",{className:"kubio-predefined-layouts__demo-site-import-page__plugins-list",children:(0,g.jsx)(Wh,{})})]})]})})),Kh=(0,u.memo)((()=>{const{currentDemoSite:e}=rf(),t=null==e?void 0:e.label;return(0,g.jsxs)(Fm.Page.Content,{children:[(0,g.jsx)(Fm.Page.Content.Title,{children:(0,g.jsx)("span",{className:"kubio-predefined-layouts__preview-page__content__title__name",children:t})}),(0,g.jsx)(Vh,{})]})})),$h=(0,u.memo)((()=>{const{currentDemoSite:e,setShowDemoSiteImportPage:t}=rf(),{baseUrl:o}=(0,l.useSelect)((e=>{const{url:t}=e("core").getEntityRecord("root","site")||{};return{baseUrl:t}}),[]),n=(0,s.useUnloadStoreEntities)(),i=(0,s.useResetUndoStack)(),r=(0,u.useCallback)((()=>{n(),i()}),[n,i]),a=(0,u.useMemo)((()=>!0),[])&&(null==e?void 0:e.isPro)?Ge.ProItem:h.Button,c=(0,u.useCallback)((()=>{t(!1)}),[t]),d=(0,u.useCallback)((async()=>{if(!(null==e?void 0:e.slug))return;const t=new URL(`${o}/wp-admin/admin.php`),n=t.searchParams;n.set("page","kubio-get-started"),n.set("tab","demo-sites"),n.set("import",null==e?void 0:e.slug);const i=t.toString();r(),document.location.href=i}),[e]);return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(Fm.Page.Footer,{children:(0,g.jsxs)("div",{className:" d-flex w-100 justify-content-end align-items-center",children:[(0,g.jsx)(h.Button,{isSecondary:!0,onClick:c,children:(0,m.__)("Cancel","kubio")}),(0,g.jsx)(a,{tag:h.Button,isPrimary:!0,urlArgs:{source:"templates_gallery",content:null==e?void 0:e.label},onClick:d,children:(0,m.__)("Import full starter site","kubio")})]})})})})),qh=(0,u.memo)((e=>(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(Fm,{...e,className:"kubio-predefined-layouts__demo-site-import-page",sidebar:(0,g.jsx)(Gh,{}),pageContent:(0,g.jsx)(Kh,{}),pageFooter:(0,g.jsx)($h,{})})}))),Yh=(0,u.memo)((e=>{const{selectedDemoSlug:t,showDemoSiteImportPage:o}=rf(),{list:n}=Xg();return(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)(Ug,{...e}),o&&(0,g.jsx)(qh,{}),(0,g.jsx)(Fm,{...e,className:"kubio-predefined-layouts__demo-list-page",items:n,sidebar:(0,g.jsx)(Bh,{}),pageContent:(0,g.jsx)(Fh,{}),emptyContent:(0,m.__)("No Starter Site Found","kubio")})]})})),Zh=(0,u.memo)((({children:e})=>{const{rawDemoList:t}=rf(),{favoritesDataByType:o}=hf(),n=(0,u.useMemo)((()=>null===o?t:v().isEmpty(o)?[]:t.filter((e=>!!v().get(o,["demoSite",null==e?void 0:e.slug])))),[t,o]),i=(0,u.useMemo)((()=>{const e=v().cloneDeep(n),t=[];return e.forEach((e=>{const{isPro:o,relatedDemoSite:n}=e;n?!o&&t.push(e):t.push(e)})),t}),[n]),r=(0,u.useMemo)((()=>({list:i})),[i]);return(0,g.jsx)(Wg.Provider,{value:r,children:e})})),Xh=(0,u.memo)((e=>(0,g.jsx)(nf,{children:(0,g.jsx)(Zh,{children:(0,g.jsx)(Yg,{children:(0,g.jsx)(Yh,{...e})})})}))),Jh=(0,u.memo)((({value:e={},onSelect:t})=>{const{screenshot:o,isPro:n,label:i,slug:r,uniqueId:a,demoSiteSlug:s,id:l,type:c}=e,d=(0,u.useMemo)((()=>{const e=(e=>v().get(Tu,["demoSitesListBySlug",e]))(s);return`STARTER SITE: ${null==e?void 0:e.label}`}),[s]),p=(0,u.useMemo)((()=>({favoriteType:`demo-${c}`,favoriteId:l})),[c,l]);return(0,g.jsxs)("div",{className:"kubio-predefined-layouts__demo-part-list-page__item",onClick:()=>{t(e)},children:[(0,g.jsx)(Sd,{screenshot:o,label:i,uniqueId:a,isPro:n,...p}),(0,g.jsx)("div",{className:"kubio-predefined-layouts__demo-part-list-page__item__pack-label",onClick:e=>e.stopPropagation(),children:d})]})})),Qh=(0,u.memo)((({list:e,onSelect:t})=>(0,g.jsx)(Ph,{list:e,onSelect:t,ListItemComponent:Jh}))),em=()=>{const{onSelectDemo:e}=rf(),{list:t}=Xg(),o=(0,u.useCallback)((t=>{e(null==t?void 0:t.demoSiteSlug,t)}),[e]);return(0,g.jsx)(Fm.Page.Content,{children:(0,g.jsx)(Qh,{list:t,onSelect:o})})},tm=(0,u.memo)((e=>{const{selectedDemoSlug:t,showDemoSiteImportPage:o,demoPartsIsLoaded:n}=rf(),{list:i}=Xg();return(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)(Ug,{...e}),o&&(0,g.jsx)(qh,{}),(0,g.jsx)(Fm,{...e,className:"kubio-predefined-layouts__demo-part-list-page",isLoading:!n,items:i,sidebar:(0,g.jsx)(Bh,{searchPlaceholder:(0,m.__)("Find a page…","kubio")}),pageContent:(0,g.jsx)(em,{}),emptyContent:(0,m.__)("No Page Found","kubio")})]})})),om=(0,u.memo)((({children:e})=>{const{rawDemoList:t,demosPartsPerSlug:o}=rf(),{favoritesDataByType:n}=hf(),i=(0,u.useMemo)((()=>{let e=[];return t.forEach((({slug:t,isPro:n,relatedDemoSite:i})=>{if(i){if(n)return;const r=t,a=null==i?void 0:i.slug,s=v().get(o,r,[]),l=v().get(o,a,[]);e=e.concat(s,l)}else{const n=v().get(o,t,[]);e=e.concat(n)}})),e}),[t,o]),r=(0,u.useMemo)((()=>null===n?i:v().isEmpty(n)?[]:i.filter((e=>{const{type:t,id:o}=e,i=[`demo-${t}`,o];return!!v().get(n,i)}))),[i,n]),a=(0,u.useMemo)((()=>({list:r})),[r]);return(0,g.jsx)(Wg.Provider,{value:a,children:e})})),nm=(0,u.memo)((e=>(0,g.jsx)(nf,{children:(0,g.jsx)(om,{children:(0,g.jsx)(Yg,{children:(0,g.jsx)(tm,{...e})})})}))),im=(0,u.memo)((({value:e={},onSelect:t,onLoad:o})=>{const{screenshot:n,isProOnFree:i,label:r,name:a,categoryLabelWithIndex:s}=e,l=(0,u.useRef)(),c=i,d=c?Ge.ProItem:Sd;let p={};return c&&(p={urlArgs:{source:"templates_gallery",content:r}}),(0,g.jsx)(Ge.ProModalTextContext.Provider,{value:(0,m.__)("This section is available only in the PRO version.","kubio"),children:(0,g.jsx)(d,{tag:Sd,ref:l,title:r,screenshot:n,label:s,uniqueId:a,isPro:i,isLandscape:!0,onClick:()=>t(e),favoriteType:"section",favoriteId:a,onLoad:o,addImageType:!1,...p})})})),rm=(0,u.createContext)({}),am=(0,u.memo)((({children:e,filterByPublicTag:t=!0,activeTag:o,setActiveTag:n})=>{const[i,r]=sm(v().noop,"content"),[a]=sm(v().noop,"header"),[s]=sm(v().noop,"footer"),{favoritesDataByType:c}=hf(),{initialParams:d,activePage:p}=nd(),h=v().get(d,["sections","internalTag"]),{isFrontPage:m,postType:f,postId:b,isEditingTemplate:k,isEditingTemplatePart:x,isFrontPageTemplatePart:S}=(0,l.useSelect)((e=>{var t;const{getIsFrontPage:o=v().noop,getEditedPostType:n,getEditedPostId:i}=e("kubio/edit-site")||{},r=o(),a=n(),s=i(),l="wp_template_part"===a,c="wp_template"===a,u=l&&"front-header"===(null==s||null===(t=s.split("//"))||void 0===t?void 0:t[1]);return{isFrontPage:r,postType:a,postId:s,isEditingTemplate:c,isEditingTemplatePart:l,isFrontPageTemplatePart:u}}),[]);let w="kubio-content";var C;w=x?null!=b&&null!==(C=b.includes)&&void 0!==C&&C.call(b,"header")?"kubio-header":"kubio-footer":v().get(d,[p,"categoryType"],"kubio-content");const I=(0,u.useMemo)((()=>a.concat(i,s)),[a,i,s]),j=(0,u.useMemo)((()=>I.filter((e=>{if(!w)return!0;const t=v().get(e,"categories.0"),o=t.split("/")[0];return(!m&&!S||t!==y.INNER_HEADERS_CATEGORY)&&o===w})).filter((e=>!(h&&!((null==e?void 0:e.internalTags)||[]).includes(h))&&!!(0,T.isPatternAvailableInCurrentTheme)(e)))),[I,w,m,h]),P=(0,u.useMemo)((()=>null===c?j:v().isEmpty(c)?[]:j.filter((e=>!!v().get(c,["section",null==e?void 0:e.name])))),[j,c]),E=(0,u.useMemo)((()=>{const e={};return P.map(((t,o)=>{var n;let i=t.screenshot;!i&&t.isCustomSection&&(i="data:image/svg+xml,"+`<svg background='#fff' xmlns='http://www.w3.org/2000/svg' width='400' height='250'>\t<rect x='0' y='0' width='400' height='250' fill='white'></rect>\t<text x='50%' y="50%" fill='#a6adb5' dominant-baseline='middle' font-family='Open Sans, Arial, Helvetica, sans-serif' text-anchor='middle'>\t\t${t.title}\t</text></svg>`.replace(/"/g,"'").replace(/>\s{1,}</g,"><").replace(/\s{2,}/g," ").replace(/[\r\n%#()<>?[\\\]^`{|}]/g,encodeURIComponent));const a=null===(n=(0,_.find)(r,{name:v().get(t,"categories.0")}))||void 0===n?void 0:n.label;v().get(e,a)?e[a]++:e[a]=1;const s=`${a} #${e[a]}`;return{...t,label:t.title,categoryLabelWithIndex:s,screenshot:i}})).filter((e=>{const n=(null==e?void 0:e.publicTags)||[];return!(t&&o!==T.ALL_TAG&&!n.includes(o))})).sort(((e,t)=>0+e.isProPattern-t.isProPattern))}),[r,P,o]),R=(0,u.useMemo)((()=>r.map((({name:e,label:t})=>({label:t,value:e})))),[r]),A=(0,u.useCallback)(((e,t)=>{const o=e=>null==e?void 0:e.toLowerCase().replace("#",""),n=o(t);return e.filter((({label:e,categoryLabelWithIndex:t})=>{var i,r,a,s;return(null===(i=o(e))||void 0===i||null===(r=i.includes)||void 0===r?void 0:r.call(i,n))||(null===(a=o(t))||void 0===a||null===(s=a.includes)||void 0===s?void 0:s.call(a,n))}))}),[]),O=(0,u.useMemo)((()=>({list:E,categories:R,filterFunction:A})),[E,R,A]),N=(0,u.useMemo)((()=>({activeTag:o,setActiveTag:n})),[o,n]);return(0,g.jsx)(rm.Provider,{value:N,children:(0,g.jsx)(Wg.Provider,{value:O,children:e})})})),sm=(e,t="content")=>{const{patternCategories:o,patterns:n}=(0,l.useSelect)((e=>{const{getSettings:o}=e("core/block-editor");return{patterns:o().__experimentalBlockPatterns.filter((e=>e.isGutentagPattern&&0===e.name.indexOf(`kubio-${t}`))),patternCategories:o().__experimentalBlockPatternCategories}}),[t]),i=(0,u.useMemo)((()=>{const e={};o.forEach((({name:t},o)=>e[t]=o));const t=n.map(((t,o)=>{const n=v().get(t,"categories[0]"),i=e[n];return{...t,arrayIndex:o,categoryIndex:i}}));return v().orderBy(t,["categoryIndex","arrayIndex"],["asc","asc"])}),[n,o]),r=(0,u.useCallback)(((t,o)=>{const n=t.isGutentagPattern?(0,T.transformTemplateToBlock)(o):(0,_.map)(o,(e=>(0,lt.cloneBlock)(e)));e(n,t)}),[]);return[i,o,r]},lm=()=>(0,u.useContext)(rm),cm=()=>{const{activeTag:e,setActiveTag:t}=lm();return(0,g.jsx)(am,{activeTag:e,setActiveTag:t,filterByPublicTag:!1,children:(0,g.jsx)(Yg,{children:(0,g.jsx)(um,{})})})},um=()=>{const{list:e}=Xg(),{activeTag:t,setActiveTag:o}=lm(),n=(0,u.useMemo)((()=>{const t=new Set;return e.forEach((e=>{(e.publicTags||[]).forEach((e=>t.add(e)))})),[...t]}),[e]);return(0,g.jsx)(g.Fragment,{children:!!n.length&&(0,g.jsx)(T.KubioSectionsTags,{activeTag:t,setActiveTag:o,availableTagSlugs:n})})},dm=(0,u.memo)((({list:e,onSelect:t})=>{const o=(0,u.useRef)(),[n,i]=(0,u.useState)(1),r=(0,u.useMemo)((()=>{let t=40*n;return t=Math.min(e.length,t),e.slice(0,t).map(((e,t)=>({...e,__internalId:t})))}),[n,e]),a=(0,u.useCallback)((()=>{i((t=>{const o=t+1;return 40*o-40>e.length?t:o}))}),[e]),l=(0,s.useDebounce)(a,100),c=(0,u.useMemo)((()=>e.length!==r.length),[r,e]),{onRestartMasonry:d}=(({containerRef:e})=>{const t=(0,u.useRef)({}),o=(0,u.useRef)({}),n=(0,u.useRef)(0),i="data-masonry-loaded",r=(0,u.useRef)(0),a=(0,u.useRef)(!1),[l,c]=(0,u.useState)(!1),d=(0,u.useRef)(!1),p=(0,u.useCallback)((e=>{if("top"!==e.propertyName)return;const t=e.target;r.current>0&&r.current--,t.removeEventListener("transitionend",p),0===r.current&&a.current&&c(!0)}),[]),h=(0,u.useCallback)((()=>{if(0!==r.current||d.current)return a.current=!0,void(d.current=!1);d.current=!0;const s=e.current.children[0],l=o.current,c=t.current,u=n.current,h=Array.from(s.children).filter((e=>!e.hasAttribute(i)&&e.querySelector("img").hasAttribute("data-is-loaded"))),m=e.current,g=s.offsetHeight;s.style.paddingTop=`${g}px`;const f=s.clientWidth,{getComputedStyle:b}=m.ownerDocument.defaultView,_=parseInt(b(m).getPropertyValue("--number-columns")),v=f/_;h.forEach(((e,t)=>{const o=u+t,n=Math.floor(o/_);void 0===c[n]&&(c[n]=0);const r=0!==n?c[n-1]:0,a=e.offsetHeight+r;if(a>c[n]&&(c[n]=a),o>=_){const t=c[n-1];e.style.top=`${t}px`}else e.style.top=0;const s=o%_*v;e.style.left=`${s}px`,e.style.width=`${v}px`,e.style.position="absolute",e.setAttribute(i,!0)})),h.forEach(((e,t)=>{const o=u+t,n=e.querySelector(".kubio-predefined-layouts__screenshot-preview__parent");let i;if(o>=_){const e=l[o-_];i=`${e}px`,l[o]=e+n.offsetHeight+30}else l[o]=n.offsetHeight+30,i="0.1px";e.style.top!==i&&(r.current++,e.addEventListener("transitionend",p)),e.style.top=i}));let y=0;for(let e=0;e<_;e++){const t=h[h.length-1-e];if(!t)continue;const o=t.offsetHeight+parseFloat(t.style.top);y<o&&(y=o)}n.current+=h.length,s.style.paddingTop=`${y}px`,d.current=!1}),[e,p]);(0,u.useEffect)((()=>{l&&(c(!1),h())}),[l]);const m=(0,u.useCallback)((()=>{t.current={},o.current={},n.current=0;const r=e.current.children[0];r.style.paddingTop="0",Array.from(r.children).forEach((e=>{e.hasAttribute(i)&&e.removeAttribute(i),e.style.left="",e.style.top="",e.style.width="",e.style.position=""})),h()}),[e,h]),g=(0,s.useDebounce)(m,50);return(0,u.useEffect)((()=>(window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)})),[g]),{onRestartMasonry:h}})({containerRef:o}),p=(0,s.useDebounce)((0,u.useCallback)(d,[]),500);return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("div",{className:"kubio-predefined-layouts__screenshot-list kubio-predefined-layouts__screenshot-list--infinite-list",ref:o,children:[(0,g.jsx)(Lh(),{pageStart:0,initialLoad:!1,useWindow:!1,loadMore:l,hasMore:c,threshold:2e3,loader:(0,g.jsx)(g.Fragment,{}),children:r.map(((e,o)=>(0,g.jsx)(im,{onLoad:p,value:e,index:o,onSelect:t},e.name+"__"+o)))}),(0,g.jsx)(cm,{})]})})})),pm=()=>{const{list:e}=Xg(),{initialParams:t,activePage:o}=nd(),n=v().get(t,[o,"onActionFunc"]),{insertBlocks:i}=(0,l.useDispatch)("core/block-editor"),{contentClientId:r,nrOfBlocksInsideContent:a,patternCategories:c,sectionNameAndIdHooks:d}=(0,l.useSelect)((e=>{var t;const{getBlocks:o,getBlockOrder:n,getClientIdsWithDescendants:i,getBlock:r}=e("core/block-editor"),{__experimentalBlockPatternCategories:a}=e("core/block-editor").getSettings(),s=o()||[],l=(0,T.findBlockByName)(s,"core/post-content"),c=null==l?void 0:l.clientId;return{patternCategories:a,contentClientId:c,nrOfBlocksInsideContent:null===(t=n(c))||void 0===t?void 0:t.length,sectionNameAndIdHooks:{getClientIdsWithDescendants:i,getBlock:r}}}),[]),{onClose:p=v().noop}=nd(),h=(0,u.useCallback)((async e=>{var t;const o=null==e?void 0:e.content;let n=(0,T.transformTemplateToBlock)(o);n=function({block:e,pattern:t,patternCategories:o,hooks:n}){var i,r,a;const{categories:s}=t,l=null!==(i=null==s?void 0:s[0])&&void 0!==i?i:"__undefined__category__",c=null!==(r=null===(a=(0,_.find)(o,{name:l}))||void 0===a?void 0:a.label)&&void 0!==r?r:"Custom Section",{anchor:u,name:d}=(0,T.getNextSectionNameAndId)(c,n);return"kubio/section"===e.name&&(e={...e,attributes:{...e.attributes,anchor:u,attrs:{...e.attributes.attrs,name:d}}}),e}({pattern:e,block:n,hooks:d,patternCategories:c});let s=a;var l;-1!==e.categories.indexOf(y.HERO_ACCENT_CATEGORY)&&(s=0),await i((0,T.cleanFontFamilyFromBlocks)(n),s,r,!1),p(),null!==(t=n)&&void 0!==t&&t.clientId&&Bu(null===(l=n)||void 0===l?void 0:l.clientId)}),[r,a,i,p,c,d]),m=(0,s.useDeepMemo)((()=>Xa().generate()),[e]),f=(0,u.useCallback)((async e=>{n?(n(e),p()):h(e)}),[n,p,h]);return(0,g.jsx)(Fm.Page.Content,{children:(0,g.jsx)(dm,{list:e,onSelect:f},m)})},hm="https://s3.us-west-2.amazonaws.com/static-assets.kubiobuilder.com/assets/predesigned-layouts/no+elements+found.png",mm="https://s3.us-west-2.amazonaws.com/static-assets.kubiobuilder.com/assets/predesigned-layouts/no+elements+found+favorites.png";[hm,mm].forEach((e=>{(new Image).src=e}));const gm=(0,u.memo)((({children:e})=>{const{activePage:t}=nd(),o=e||(0,m.__)("NO ELEMENTS FOUND","kubio"),n=(0,u.useMemo)((()=>t===ed?mm:hm),[t]);return(0,g.jsxs)("div",{className:"kubio-predefined-layouts__modal-layout__list--empty-content",children:[(0,g.jsx)("img",{src:n}),o]})})),fm=(0,u.memo)((({children:e})=>{const{activePage:t}=nd(),{activeTag:o,setActiveTag:n}=lm(),i=(0,u.useMemo)((()=>t===ed?mm:hm),[t]);return(0,g.jsxs)("div",{className:"kubio-predefined-layouts__modal-layout__list--empty-content",children:[(0,g.jsx)(T.KubioSectionsTags,{activeTag:o,setActiveTag:n}),(0,g.jsx)("img",{src:i}),(0,m.__)("No Section Found","kubio")]})})),bm=(0,u.memo)((e=>{const{list:t}=Xg(),o=!window.kubioPatternsRegistered;return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(Fm,{...e,className:"kubio-predefined-layouts__sections-page",isLoading:o,items:t,sidebar:(0,g.jsx)(Bh,{searchPlaceholder:(0,m.__)("Find a section…","kubio")}),pageContent:(0,g.jsx)(pm,{}),EmptyContentComponent:fm})})})),_m=(0,u.memo)((e=>{const{initialParams:t,activePage:o}=nd(),n=v().get(t,["sections","tag"],T.ALL_TAG),[i,r]=(0,u.useState)(n);return(0,g.jsx)(am,{activeTag:i,setActiveTag:r,children:(0,g.jsx)(Yg,{children:(0,g.jsx)(bm,{...e})})})})),vm=(0,u.createContext)({value:null}),ym=(0,u.memo)((({children:e})=>{const{previousActivePage:t}=nd(),[o,n]=(0,u.useState)(t),i=(0,u.useMemo)((()=>({activeTab:o,setActiveTab:n})),[o,n]);return(0,g.jsx)(vm.Provider,{value:i,children:e})})),km=()=>(0,u.useContext)(vm),xm=td.filter((({value:e})=>e!==ed)),Sm=(0,u.memo)((()=>{const{activeTab:e,setActiveTab:t}=km(),{initialParams:o}=nd(),n=v().get(o,"disabledPages",[]);return(0,g.jsx)(ut.ToggleGroup,{value:e,onChange:t,disabledOptions:n,options:xm})})),wm=(0,u.memo)((()=>(0,g.jsx)(Am.Fill,{children:(0,g.jsx)(Sm,{})}))),Cm=(0,u.memo)((e=>{const{activeTab:t}=km(),o=(0,u.useMemo)((()=>v().get(jm,t,u.Fragment)),[t]);return(0,g.jsxs)("div",{className:"kubio-predefined-layouts__favorite-page",children:[(0,g.jsx)(o,{...e}),(0,g.jsx)(wm,{})]})})),Im=(0,u.memo)((e=>(0,g.jsx)(ym,{children:(0,g.jsx)(pf,{children:(0,g.jsx)(Cm,{...e})})}))),jm={[Xu]:Xh,[Ju]:nm,[Qu]:_m,[ed]:Im},Tm=(0,u.memo)((e=>{const{activePage:t,onClose:o,showLoadingOverlay:n}=nd(),i=(0,u.useRef)(),r=(0,u.useMemo)((()=>v().get(jm,t,u.Fragment)),[t]),a=(0,u.useCallback)((()=>{o()}),[o]);return(0,s.useOnClickOutside)(i,a),(0,g.jsxs)("div",{ref:i,className:"kubio-predefined-layouts__pages-container position-relative",children:[(0,g.jsx)(r,{...e}),(0,g.jsx)("div",{className:"kubio-predefined-layouts__popup-slot"}),n&&(0,g.jsx)(Nh,{})]})})),Pm=(0,u.memo)((({children:e})=>{const t=e||(0,m.__)("Kubio Library","kubio");return(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__sidebar__header",children:(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__sidebar__header__inner",children:t})})})),Em=(0,u.memo)((({children:e})=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__sidebar__content",children:e}))),Rm=(0,u.memo)((({children:e})=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__sidebar__footer",children:e}))),Am=(0,h.createSlotFill)("PredefinedLayoutsSidebarTop"),Om=(0,u.memo)((({children:e,className:t})=>(0,g.jsx)("div",{className:X()("kubio-predefined-layouts__modal-layout__sidebar",t),children:e})));Om.Header=Pm,Om.Content=Em,Om.Footer=Rm;const Nm=(0,u.memo)((({children:e})=>(0,g.jsx)("div",{children:e}))),Bm=(0,u.memo)((()=>{const{activePage:e,setActivePage:t,initialParams:o}=nd(),n=v().get(o,"disabledPages",[]);return(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__pages-switcher",children:(0,g.jsx)(ut.ToggleGroup,{value:e,onChange:t,disabledOptions:n,options:td})})})),Dm=(0,u.memo)((({children:e})=>(0,g.jsx)(g.Fragment,{children:e}))),Mm=(0,u.memo)((({children:e})=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__list__title",children:e}))),Lm=(0,u.memo)((({children:e})=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__list__footer",children:e}))),zm=(0,u.memo)((()=>(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__list--loading-content",children:(0,g.jsx)(h.Icon,{icon:He.KubioLoader})}))),Fm=(0,u.memo)((({items:e,sidebar:t,pageContent:o,pageFooter:n,className:i,isLoading:r=!1,emptyContent:a,EmptyContentComponent:s=gm})=>{const{onClose:l}=nd();let c;if(Array.isArray(e)){const t=!(null==e?void 0:e.length);c=r?(0,g.jsx)(zm,{}):t?(0,g.jsx)(s,{children:a}):o}else c=o;return(0,g.jsxs)("div",{className:X()("kubio-predefined-layouts__modal-layout",i),children:[t,(0,g.jsxs)("div",{className:"kubio-predefined-layouts__modal-layout__list__container",children:[(0,g.jsxs)("div",{className:"kubio-predefined-layouts__modal-layout__header",children:[(0,g.jsx)(Bm,{}),(0,g.jsx)(h.Button,{className:"kubio-predefined-layouts__modal-layout__close",onClick:l,icon:Ve,size:12,label:(0,m.__)("Close","kubio")})]}),(0,g.jsxs)("div",{className:"kubio-predefined-layouts__modal-layout__list",children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__modal-layout__list__left-gradient"}),c]}),n]})]})}));Fm.Page=Nm,Fm.Page.Content=Dm,Fm.Page.Footer=Lm,Fm.Page.Content.Title=Mm,Fm.Sidebar=Om;const Gm=(0,u.memo)((({onSelectDemo:e})=>{const{activePage:t}=nd(),o=(0,u.useMemo)((()=>{switch(t){case Xu:return(0,m.__)("Back to Starter Sites","kubio");case Ju:return(0,m.__)("Back to Pages","kubio")}return(0,m.__)("Back","kubio")}),[t]);return(0,g.jsx)(Fm.Sidebar.Header,{children:(0,g.jsx)(h.Button,{className:"kubio-predefined-layouts__preview-page__sidebar__back",icon:(0,g.jsx)(h.Dashicon,{icon:"redo"}),onClick:()=>e(null),children:o})})})),Hm=(0,u.createContext)({text:null,isDisabled:!1}),Um=(0,u.memo)((()=>(0,g.jsx)("div",{children:(0,m.__)("You can't import page content","kubio")}))),Wm=(0,u.memo)((({children:e})=>{const{selectedDemoPart:t}=Hu(),o=ag(t),{currentPostIsPage:n}=(0,l.useSelect)((e=>{const{getPage:t=v().noop}=e("kubio/edit-site")||{},o=t(),{postType:n}=(null==o?void 0:o.context)||{};return{currentPostIsPage:"page"===n}}),[]),i=v().isEmpty(t),r=(0,u.useMemo)((()=>{const e=o.find((({isCurrentPageTemplate:e})=>e)),r=o.find((({isSelectedDemoPart:e})=>e));return r&&null!=r&&r.isDisabled?{text:r.noticeText,isDisabled:r.isDisabled}:e&&"page"===(null==t?void 0:t.type)||"page"===(null==t?void 0:t.type)&&!n?{text:lg,isDisabled:!0}:{text:Um,isDisabled:i}}),[o,t,n]);return(0,g.jsx)(Hm.Provider,{value:r,children:e})})),Vm=()=>(0,u.useContext)(Hm),Km=["attachment","kubio_changeset"],$m=({onComplete:e=_.noop,closeModal:t=_.noop,entityName:o=(0,m.__)("other","kubio"),changeEntityText:n,ModalComponent:i=h.Modal,modalProps:r={},changeReadyState:a=!0,changePage:c=!0})=>{const p=(0,s.useUnloadStoreEntities)(),f=(0,s.useResetUndoStack)(),b=(0,x.useSetGlobalSessionProp)("ready"),[v,y]=(0,u.useState)(!1),{hasDirtyEntities:k,entitiesToSave:w}=(0,l.useSelect)((e=>{const{__experimentalGetDirtyEntityRecords:t}=e("core");return{hasDirtyEntities:t().filter((({kind:e,name:t})=>"postType"===e&&!Km.includes(t))).length>0,entitiesToSave:t()}})),{saveEditedEntityRecord:C}=(0,l.useDispatch)("core"),{setIsNavigationPanelOpened:I,setPage:j}=(0,l.useDispatch)(Le),[,T]=(0,S.useAIData)(),P=(0,u.useCallback)((()=>{I(!1),a&&(b(!1),c&&j(null));const{requestIdleCallback:t}=window;t((()=>{p(),f(),(0,s.removeCachedAllMergedAttributes)(),T(null),t(e)})),(0,d.doAction)("kubio.editor.page-changed")}),[I,a,j,b,p,f,T,e]);let E;return(0,u.useEffect)((()=>{k||P()}),[P,k]),E=n||(0,m.sprintf)(// translators: %s: page name
// translators: %s: page name
(0,m.__)("You are being redirected to <strong>%s</strong> page.","kubio"),o),(0,g.jsx)(g.Fragment,{children:k&&(0,g.jsxs)(i,{title:(0,m.__)("You have unsaved changes","kubio"),onRequestClose:t,...r,children:[(0,g.jsxs)("p",{children:[(0,g.jsx)("span",{dangerouslySetInnerHTML:{__html:E}}),(0,g.jsx)("br",{}),(0,m.__)("Would you like to save these changes or discard them?","kubio")]}),(0,g.jsxs)(h.ButtonGroup,{className:"h-template-part-modal__button-group",children:[(0,g.jsx)(h.Button,{isLink:!0,onClick:()=>{P()},children:(0,m.__)("Discard changes","kubio")}),(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>{y(!0),(()=>{const e=w.map((({kind:e,name:t,key:o})=>C(e,t,o)));return Promise.all(e)})().then((()=>{P(),y(!1)}))},isBusy:v,disabled:v,children:(0,m.__)("Save changes","kubio")})]})]})})},qm=(0,u.memo)((({onClose:e=v().noop,children:t})=>{const[o,n]=(0,u.useState)(!1),[,i]=(0,x.useGlobalSessionProp)("displayingEmptyPageChecked"),r=(0,u.useMemo)((()=>({onClose:e})),[e]),a=(0,u.useCallback)((()=>{n(!0),i(!0)}),[i]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)($m,{onComplete:a,onClose:e,ModalComponent:Oh,modalProps:r,changeReadyState:!1}),o&&t]})})),{memo:Ym,useState:Zm}=o(9307),Xm=Ym((({actionLabel:e,description:t,NoticeActionComponent:o,onClose:n=v().noop,onAction:i=v().noop,onShowAction:r=v().noop,fromPopup:a=!1,...s})=>{const[l,c]=Zm(!1),d=(0,u.useCallback)((()=>{n(),c(!1)}),[n,c]),p=e=>{e.stopPropagation(),e.preventDefault(),r(),c(!0)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__disabled-notice__description",children:t}),(0,g.jsxs)("div",{children:[!a&&(0,g.jsx)("a",{className:"kubio-predefined-layouts__disabled-notice__action",onClick:p,children:e}),a&&(0,g.jsx)(h.Button,{isSecondary:!0,onClick:p,children:e})]}),l&&(0,g.jsx)(qm,{onClose:d,children:(0,g.jsx)(o,{onAction:i,...s})})]})})),Jm=(0,u.memo)((({onAction:e,templateSlug:t,thirdPartyUrl:o=null})=>{const n=(0,u.useRef)(!1),{storeData:i}=(0,l.useSelect)((e=>{var t;const{storeData:o={}}=null===(t=e(s.TEMPLATE_STORE_NAME))||void 0===t?void 0:t.getTemplateData();return{storeData:o}}),[]),{createErrorNotice:r}=(0,s.useKubioNotices)(),{setTemplate:a=v().noop}=(0,l.useDispatch)("kubio/edit-site")||{},c=(0,x.useSetGlobalSessionProp)("ready"),{onClose:d}=nd(),p=(0,u.useCallback)((()=>{if(!o)return void r((0,m.__)("Could not redirect to the page you selected","kubio"));const e=document.createElement("a");e.setAttribute("href",o),document.body.append(e),e.click()}),[o,r]),h=(0,u.useMemo)((()=>{const e=(null==i?void 0:i.templates)||[],o=e=>{var t;const o=null==e||null===(t=e.id)||void 0===t?void 0:t.split("//");return v().get(o,"[1]")};if(Array.isArray(t)){let n=null;return v().reverse(t).forEach((t=>{if(n)return;const i=e.find((e=>o(e)===t));i&&(n=i)})),n}return e.find((e=>o(e)===t))}),[null==i?void 0:i.templates]),f=(0,u.useCallback)((()=>{n.current||(n.current=!0,c(!1),e(),d(),h?a(h.id,h.slug,!0):p())}),[h,a,e,n,d,c]);return(0,u.useEffect)((()=>{f()}),[]),(0,g.jsx)(g.Fragment,{})})),Qm=()=>{const{siteUrl:e}=(0,l.useSelect)((e=>{const{getSettings:t=v().noop}=e("kubio/edit-site"),{siteUrl:o}=t()||{};return{siteUrl:o}}),[]);return e},eg=e=>{const t=Qm();return(0,u.useMemo)((()=>{try{const o=new URL(`${t}wp-admin/admin.php`),n=o.searchParams;return n.append("page","kubio"),n.append("pageURL",e),o.toString()}catch(e){return null}}),[e])},tg=(0,u.memo)((e=>{const{blogLink:t}=(0,l.useSelect)((e=>{const{getEditedEntityRecord:t}=e("core"),{getSettings:o=v().noop}=e("kubio/edit-site"),n=t("root","site");let i;if("page"===(null==n?void 0:n.show_on_front)){const e=t("postType","page",parseInt(null==n?void 0:n.page_for_posts));i=v().get(e,"link",null)}else{const{siteUrl:e}=o()||{};i=e}return{blogLink:i}}),[]),o=eg(t);return(0,g.jsx)(Xm,{description:(0,m.__)("This content can be imported only on the blog template","kubio"),actionLabel:(0,m.__)("Switch to the blog template","kubio"),templateSlug:qu,NoticeActionComponent:Jm,thirdPartyUrl:o,...e})})),og=(0,u.memo)((({onAction:e,firstPost:t})=>{const o=(0,u.useRef)(!1),{createErrorNotice:n}=(0,s.useKubioNotices)(),{setTemplate:i=v().noop}=(0,l.useDispatch)("kubio/edit-site")||{},r=(0,x.useSetGlobalSessionProp)("ready"),{onClose:a}=nd(),{setPage:c}=(0,l.useDispatch)(y.STORE_KEY),d=(0,u.useCallback)((()=>{!o.current&&t&&(o.current=!0,r(!1),e(),a(),c({type:t.type,slug:t.slug,path:(0,zo.getPathAndQueryString)(t.link),context:{postType:t.type,postId:t.id}}))}),[t,i,e,o,a,r]);return(0,u.useEffect)((()=>{d()}),[]),(0,g.jsx)(g.Fragment,{})})),ng=(0,u.memo)((e=>{const{firstPost:t}=(0,l.useSelect)((e=>{const{getEntityRecords:t}=e("core"),o=t("postType","post",{per_page:1});return{firstPost:v().get(o,"0")}}),[]);return(0,g.jsx)(Xm,{description:(0,m.__)("This content can be imported only on the singe post template","kubio","kubio"),actionLabel:(0,m.__)("Switch to the singe post template","kubio"),firstPost:t,NoticeActionComponent:og,...e})})),ig=(0,u.memo)((e=>{const t=Qm(),o=eg(`${t}?s=search-page`);return(0,g.jsx)(Xm,{description:(0,m.__)("This content can be imported only on the search template","kubio"),actionLabel:(0,m.__)("Switch to the search template","kubio"),templateSlug:"search",thirdPartyUrl:o,NoticeActionComponent:Jm,...e})})),rg=(0,u.memo)((e=>{const t=Qm(),o=eg(`${t}page-no-found`);return(0,g.jsx)(Xm,{description:(0,m.__)("This content can be imported only on the 404 template","kubio"),actionLabel:(0,m.__)("Switch to the 404 template","kubio"),templateSlug:"404",thirdPartyUrl:o,NoticeActionComponent:Jm,...e})})),ag=e=>{const{fseTemplateSlug:t,page:o}=(0,l.useSelect)((e=>{const{getPage:t=v().noop,getTemplateId:o=v().noop}=e("kubio/edit-site")||{},n=t(),i=o()||"";return{page:n,fseTemplateSlug:v().get(i.split("//"),"[1]")}}),[]),n=(0,x.useGetGlobalSessionProp)("urlBasedTemplatesMap",{})[null==o?void 0:o.path],i=t||n,r=(({templateSlug:e,selectedDemoPart:t={}})=>{const{type:o,slug:n}=t;let i=!1;const r="template"===o&&(null==qu?void 0:qu.includes(n)),a=qu.includes(e);return i=r&&!a,{type:"blog",noticeText:tg,isDisabled:i,isCurrentPageTemplate:a,isSelectedDemoPart:r}})({templateSlug:i,selectedDemoPart:e}),a=(({templateSlug:e,selectedDemoPart:t={}})=>{const{type:o,slug:n}=t;let i=!1;const r="template"===o&&(null==$u?void 0:$u.includes(n)),a=$u.includes(e);return i=r&&!a,{type:"single",noticeText:ng,isDisabled:i,isCurrentPageTemplate:a,isSelectedDemoPart:r}})({templateSlug:i,selectedDemoPart:e}),s=(({templateSlug:e,selectedDemoPart:t={}})=>{const{type:o,slug:n}=t;let i=!1;const r="search"===e,a="template"===o&&"search"===n;return i=a&&!r,{type:"search",noticeText:ig,isDisabled:i,isCurrentPageTemplate:r,isSelectedDemoPart:a}})({templateSlug:i,selectedDemoPart:e}),c=(({templateSlug:e,selectedDemoPart:t={}})=>{const{type:o,slug:n}=t;let i=!1;const r="404"===e,a="template"===o&&"404"===n;return i=a&&!r,{type:"404",noticeText:rg,isDisabled:i,isCurrentPageTemplate:r,isSelectedDemoPart:a}})({templateSlug:i,selectedDemoPart:e});return[a,r,s,c]},sg=(0,u.memo)((({onAction:e})=>{const{saveEntityRecord:t,editEntityRecord:o,saveEditedEntityRecord:n}=(0,l.useDispatch)("core"),{setPage:i}=(0,l.useDispatch)(y.STORE_KEY),r=(0,u.useRef)(!1),{createErrorNotice:a}=(0,s.useKubioNotices)(),c=(0,x.useSetGlobalSessionProp)("ready"),{onClose:d}=nd(),p=(0,u.useCallback)((async()=>{if(r.current)return;r.current=!0,c(!1),e(),d();const s={title:"Kubio page",status:"publish"};try{var l;const e=await t("postType","page",s);if(!e)return;const r=v().capitalize(null==e||null===(l=e.slug)||void 0===l?void 0:l.replaceAll("-"," "));await o("postType","page",e.id,{title:r}),await n("postType","page",e.id),i({type:e.type,slug:e.slug,path:(0,zo.getPathAndQueryString)(e.link),context:{postType:e.type,postId:e.id}})}catch(e){a((0,m.__)("Could not create new page","kubio"))}}),[i,e,d,t,a,o]);return(0,u.useEffect)((()=>{p()}),[]),(0,g.jsx)(g.Fragment,{})})),lg=(0,u.memo)((e=>(0,g.jsx)(Xm,{description:(0,m.__)("This content can be imported only on a page","kubio"),actionLabel:(0,m.__)("Create new page","kubio"),NoticeActionComponent:sg,...e}))),cg=(0,u.memo)((({onAction:e=v().noop,...t})=>{const{text:o,isDisabled:n}=Vm();return(0,g.jsx)("div",{className:"kubio-predefined-layouts__disabled-notice__outer",children:o&&n&&(0,g.jsx)("div",{className:"kubio-predefined-layouts__disabled-notice",children:(0,g.jsx)(o,{onAction:e,...t})})})})),ug=(0,u.memo)((()=>(0,g.jsx)(Fm.Sidebar.Footer,{children:(0,g.jsx)(cg,{})}))),dg=(0,u.memo)((()=>(0,g.jsxs)("div",{className:"kubio-predefined-layouts__preview-page__sidebar__content--is-loading",children:[(0,g.jsx)(h.Icon,{icon:He.KubioLoader}),";"]}))),pg=(0,u.memo)((({currentDemoSite:e,selectedDemoPart:t})=>{const o=null==e?void 0:e.preview,n=(0,u.useRef)(),i=(0,u.useMemo)((()=>{const{pagePreviewUrl:e}=t||{};return e||o}),[o,t]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("a",{ref:n,href:i,target:"_blank",className:"kubio-predefined-layouts__preview-page__sidebar__preview-button",rel:"noreferrer",children:(0,g.jsx)(h.Icon,{icon:He.PreviewIcon})}),(0,g.jsx)(ut.ModalTooltip,{anchorRef:n,children:(0,m.__)("Live Preview","kubio")})]})})),hg=(0,u.memo)((({selectedDemoPart:e,currentDemoSite:t,demoPartsIsLoaded:o,currentDemoParts:n})=>{const[i,r]=(0,u.useState)(!1),{uniqueId:a}=e||{},s=(0,g.jsx)(pg,{currentDemoSite:t,selectedDemoPart:e});return(0,u.useEffect)((()=>{e&&!i&&(r(!0),function(e,t){if(!Array.isArray(e)||!t)return;const o=new Image;o.onload=()=>{e.filter((e=>e.uniqueId!==(null==t?void 0:t.uniqueId))).forEach((e=>{(new Image).src=e.screenshotFull}))},o.src=null==t?void 0:t.screenshotFull}(n,e))}),[e]),(0,g.jsxs)(Fm.Sidebar.Content,{children:[o&&(0,g.jsx)(Sd,{showFull:!0,showAnimationAtLoad:!0,labelSlot:s,showFavorite:!1,addUniquePreviewAttribute:!1,...e},a),!o&&(0,g.jsx)(dg,{})]})})),mg=(0,u.memo)((()=>{const{selectedDemoPart:e,demoPartsIsLoaded:t,currentDemoParts:o}=Hu(),{currentDemoSite:n,onSelectDemo:i}=rf();return(0,g.jsxs)(Fm.Sidebar,{className:"kubio-predefined-layouts__preview-page__sidebar",children:[(0,g.jsx)(Gm,{onSelectDemo:i}),(0,g.jsx)(hg,{selectedDemoPart:e,currentDemoSite:n,demoPartsIsLoaded:t,currentDemoParts:o}),(0,g.jsx)(ug,{})]})})),gg=(0,u.memo)((({colorPalette:e})=>{const t=(0,u.useMemo)((()=>e.map((({color:e})=>`rgb(${e.join(",")}`))),[e]);return(0,g.jsx)("td",{className:"kubio-predefined-layouts__color-palette-previewer__list",children:t.map(((e,t)=>(0,g.jsx)(ut.ColorIndicator,{value:e},t)))})})),fg=(0,u.memo)((({colorPalette:e})=>(0,g.jsxs)("tr",{className:"kubio-predefined-layouts__color-palette-previewer",children:[(0,g.jsx)("td",{children:(0,m.__)("Starter site colors","kubio")}),e&&(0,g.jsx)(gg,{colorPalette:e})]}))),bg=["h1","h2","h3","h4","h5","h6","p"],_g=[{label:(0,m.__)("Heading 1","kubio"),holder:"h1"},{label:(0,m.__)("Heading 2","kubio"),holder:"h2"},{label:(0,m.__)("Heading 3","kubio"),holder:"h3"},{label:(0,m.__)("Heading 4","kubio"),holder:"h4"},{label:(0,m.__)("Heading 5","kubio"),holder:"h5"},{label:(0,m.__)("Heading 6","kubio"),holder:"h6"},{label:(0,m.__)("Paragraph","kubio"),holder:"p"}],vg=(0,u.memo)((({typography:e})=>{const t=(0,u.useMemo)((()=>{const t=v().get(e,"holders",{});return v().pick(t,bg)}),[e]),o=(0,u.useCallback)((e=>{const o=v().get(t,e);if(!o)return{};const n=ua.typographyConfig.getTypographyCss(o,null,!1);return v().omit(n,"color")}),[t]);return e?(0,g.jsx)("td",{className:"kubio-predefined-layouts__typography-previewer__text-container",children:_g.map((({label:e,holder:n})=>{const i=o(n);return(0,g.jsx)(yg,{style:i,holder:n,styleByHolder:t,children:e},n)}))}):(0,g.jsx)(g.Fragment,{})})),yg=(0,u.memo)((({children:e,styleByHolder:t,holder:o,style:n})=>{const i=(0,u.useRef)(),r=(0,u.useMemo)((()=>{const e=v().get(t,o),{family:n,weight:i,size:r}=e;return`${n}, ${i}, ${null==r?void 0:r.value}${null==r?void 0:r.unit}`}),[t,o]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"kubio-predefined-layouts__typography-previewer__text",style:n,ref:i,children:e}),(0,g.jsx)("span",{className:"kubio-predefined-layouts__typography-previewer__text-separator",children:", "}),(0,g.jsx)(ut.ModalTooltip,{anchorRef:i,children:r})]})})),kg=(0,u.memo)((({typography:e})=>(0,g.jsxs)("tr",{className:"kubio-predefined-layouts__typography-previewer",children:[(0,g.jsx)("td",{children:(0,m.__)("Starter site typography","kubio")}),(0,g.jsx)(vg,{typography:e})]}))),xg=(0,u.memo)((({isOpen:e})=>{const[t,o]=(0,u.useState)(),{selectedDemoPart:n}=Hu();(0,u.useEffect)((()=>{!async function(){const e=await async function(e){const t=["demoPartsContentById","page"===(null==e?void 0:e.type)?"pages":"templates",null==e?void 0:e.id],o=v().get(Tu,t);return Eu(null==o?void 0:o.globalDataId)}(n);e&&o(e)}()}),[n]);const i=(0,u.useMemo)((()=>null==t?void 0:t.colors),[t]),r=(0,u.useMemo)((()=>v().get(t,"globalStyle.style.descendants.body.typography")),[t]),a=(0,u.useRef)(),s=(0,u.useMemo)((()=>{var t;return e?{height:`${null==a||null===(t=a.current)||void 0===t?void 0:t.offsetHeight}px`}:{height:0}}),[e]),l=(0,u.useMemo)((()=>{const e=[];return v().get(t,["fonts","google"],[]).forEach((({family:t})=>{e.includes(t)||e.push(t)})),e}),[t]);return(0,g.jsxs)(Sg.Fill,{children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__advanced-settings__control",style:s,children:(0,g.jsx)("div",{ref:a,className:"kubio-predefined-layouts__preview-page__advanced-settings__control__inner",children:(0,g.jsx)("table",{className:"kubio-predefined-layouts__preview-page__advanced-settings__global-data",children:(0,g.jsxs)("tbody",{children:[(0,g.jsx)(fg,{colorPalette:i}),(0,g.jsx)(kg,{typography:r})]})})})}),(0,g.jsx)(vd,{fontsToLoad:l})]})})),Sg=(0,h.createSlotFill)("PredefinedLayoutsAdvancedSettings"),wg=(0,u.memo)((()=>{const{shouldConvertGlobalColors:e,setShouldConvertGlobalColors:t}=sd();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__advanced-settings",children:(0,g.jsx)(ut.ToggleControl,{label:(0,m.__)("Replace global styles","kubio"),value:e,onChange:t})}),(0,g.jsx)(xg,{isOpen:e})]})})),Cg=(0,u.memo)((({value:e={},onSelect:t,selected:o})=>{const{screenshot:n,isPro:i,label:r,uniqueId:a,type:s,id:l}=e,c=a===(null==o?void 0:o.uniqueId),d=(0,u.useMemo)((()=>({favoriteType:`demo-${s}`,favoriteId:l})),[s,l]);return(0,g.jsx)("div",{className:X()("kubio-predefined-layouts__preview-page__item",{"kubio-predefined-layouts__preview-page__item--selected":c}),onClick:()=>{t(e)},children:(0,g.jsx)(Sd,{isPro:i,screenshot:n,label:r,uniqueId:a,...d})})})),Ig=(0,u.memo)((({list:e,value:t,onSelect:o})=>(0,g.jsx)(xd,{list:e,children:e=>(0,g.jsx)(Cg,{value:e,selected:t,onSelect:o},e.slug)}))),jg=e=>{(0,u.useEffect)((()=>{if(!e)return;const t=document.querySelector(`[data-unique-id="${null==e?void 0:e.uniqueId}"]`);t&&(function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}(t)||t.scrollIntoView({block:"center"}))}),[e])},Tg=(0,u.memo)((()=>{const{currentDemoParts:e,setSelectedDemoPart:t,selectedDemoPart:o}=Hu();return jg(o),(0,g.jsx)(Ig,{list:e,onSelect:t,value:o})})),Pg=(0,u.memo)((()=>{const{currentDemoSite:e,onSelectDemo:t}=rf(),{currentDemoParts:o,relatedDemoParts:n,setSelectedDemoPart:i,selectedDemoPart:r}=Hu(),a=!!n,s=null==e?void 0:e.relatedDemoSite;jg(r);const l=(0,u.useMemo)((()=>null!=e&&e.isPro?e:s),[e,s]),c=(0,u.useMemo)((()=>e===l?s:e),[e,l]),d=(0,u.useMemo)((()=>e.isPro?o:e.isPro||n?!e.isPro&&null!=e&&e.relatedDemoSite&&n?n:void 0:o),[o,e,n]),p=(0,u.useMemo)((()=>a&&o&&n?d===o?n:o:null),[a,d]),h=(0,u.useMemo)((()=>o===d),[d,o]),f=!h,b=(0,u.useCallback)((e=>{h?i(e):t(null==l?void 0:l.slug,e)}),[i,h,l]),_=(0,u.useCallback)((e=>{f?i(e):t(null==c?void 0:c.slug,e)}),[i,f,c]);return n?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Id,{label:(0,m.__)("FREE","kubio")}),(0,g.jsx)(Ig,{list:p,onSelect:_,value:r}),(0,g.jsx)(Id,{label:(0,m.__)("PRO","kubio"),className:"kubio-predefined-layouts__free-pro-separator--second"}),(0,g.jsx)(Ig,{list:d,onSelect:b,value:r})]}):(0,g.jsx)(g.Fragment,{})})),Eg=(0,u.memo)((()=>{const{currentDemoSite:e}=rf(),t=null==e?void 0:e.label,o=(0,u.useMemo)((()=>!(null==e||!e.relatedDemoSite)),[e])?Pg:Tg;return(0,g.jsxs)(Fm.Page.Content,{children:[(0,g.jsx)(Fm.Page.Content.Title,{children:(0,g.jsxs)("div",{className:"kubio-predefined-layouts__preview-page__content__title",children:[(0,g.jsxs)("div",{className:"d-flex justify-content-between align-items-center",children:[(0,g.jsx)("span",{className:"kubio-predefined-layouts__preview-page__content__title__name",children:t}),(0,g.jsx)(wg,{})]}),(0,g.jsx)(Sg.Slot,{})]})}),(0,g.jsx)(o,{})]})})),Rg="content",Ag="fullPage",Og="fullStarterSite",Ng=[{label:(0,m.__)("Content","kubio"),value:Rg,description:(0,m.__)("The selected starter site content will be added after your existing sections","kubio"),image:"https://s3.us-west-2.amazonaws.com/static-assets.kubiobuilder.com/assets/predesigned-layouts/content.png"},{label:(0,m.__)("Full page","kubio"),value:Ag,description:(0,m.__)("Your header, content and footer will be all replaced with the ones from the selected page","kubio"),image:"https://s3.us-west-2.amazonaws.com/static-assets.kubiobuilder.com/assets/predesigned-layouts/full+page.png"},{label:(0,m.__)("Full starter site","kubio"),value:Og,description:(0,m.__)("All content will be replaced with the selected full starter site","kubio"),image:"https://s3.us-west-2.amazonaws.com/static-assets.kubiobuilder.com/assets/predesigned-layouts/full+site.png"}],Bg=(0,u.memo)((({value:e,label:t,description:o,image:n,isActive:i,onClick:r,isDisabled:a=!1,isFreeOnPro:s=!1,urlArgs:l})=>{const c=(0,u.useMemo)((()=>[{label:t,value:e}]),[t,e]),d=(0,u.useMemo)((()=>i?e:null),[i,e]),p=(0,u.useCallback)((()=>{a||r()}),[r,a]),m=(0,u.useMemo)((()=>s?Ge.ProItem:Dg),[s]),f=(0,u.useMemo)((()=>s?{tag:Dg,urlArgs:{urlArgs:l}}:{}),[s]);return(0,g.jsxs)(m,{className:X()("kubio-predefined-layouts__preview-page__import-popup__card",{"kubio-predefined-layouts__preview-page__import-popup__card--active":i,"kubio-predefined-layouts__preview-page__import-popup__card--disabled":a}),onClick:p,...f,children:[(0,g.jsx)("img",{className:"kubio-predefined-layouts__preview-page__import-popup__card__image",src:n}),(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__import-popup__card__label",children:(0,g.jsx)(h.RadioControl,{options:c,selected:d})}),(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__import-popup__card__description",children:o}),a&&(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__import-popup__card__disabled-overlay"})]})})),Dg=(0,u.memo)((0,u.forwardRef)((({children:e,...t},o)=>(0,g.jsx)("div",{...t,ref:o,children:e})))),Mg=(0,u.memo)((({onClose:e,onImportContent:t,onImportFullPage:o,onImportStarterSite:n,isFreeBuild:i,currentTemplateIsClassic:r,currentDemoSite:a})=>{const s=(0,u.useMemo)((()=>r?Ag:Rg),[r]),[l,c]=(0,u.useState)(s),d=(0,u.useCallback)((e=>{e!==l&&c(e)}),[l,c]),p=(0,u.useMemo)((()=>Ng.map((e=>{const t={};return e.value===Ag&&i&&!r&&(t.isFreeOnPro=!0,t.urlArgs={source:"templates_gallery",content:null==a?void 0:a.label}),e.value===Rg&&r&&(t.isDisabled=!0),{...e,...t}}))),[r,i,a]);return(0,g.jsx)(Oh,{title:(0,g.jsx)(Lg,{}),onClose:e,children:(0,g.jsxs)("div",{className:"kubio-predefined-layouts__preview-page__import-popup",children:[(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__import-popup__list",children:p.map((e=>(0,g.jsx)(Bg,{...e,isActive:l===e.value,onClick:()=>d(e.value)},e.value)))}),(0,g.jsx)("div",{className:"kubio-predefined-layouts__preview-page__import-popup__footer d-flex justify-content-end",children:(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>{switch(l){case Rg:return void t();case Ag:return void o();case Og:e(),n()}},children:(0,m.__)("Import selection","kubio")})})]})})})),Lg=(0,u.memo)((()=>(0,g.jsx)("span",{style:{fontWeight:"700"},children:(0,m.__)("What to import:","kubio")}))),{memo:zg}=o(9307),Fg=zg((({onClose:e})=>{const[t,o]=(0,u.useState)(!1),n=(0,u.useCallback)((()=>{o(!0)}),[o]),i=(0,u.useMemo)((()=>{if(t)return"invisible"}),[t]);return(0,g.jsx)(Oh,{title:(0,g.jsx)("div",{children:(0,m.__)("This content can't be imported here","kubio")}),onClose:e,className:i,children:(0,g.jsx)(cg,{onAction:e,onClose:e,onShowAction:n,fromPopup:!0})})})),Gg=(0,u.memo)((()=>{const{selectedDemoPart:e}=Hu(),[t,o]=(0,u.useState)(!1),[n,i]=(0,u.useState)(!1),r=(0,u.useCallback)((()=>{o(!1)}),[o]),{currentDemoSite:a,setShowDemoSiteImportPage:s}=rf(),{importDemoPart:c,isImporting:d,whatToImport:p,setWhatToImport:f}=sd(),{isDisabled:b}=Vm(),{type:_,isPro:y}=e||{},{isClassicTemplate:k}=(0,l.useSelect)((e=>{const{getTemplateId:t=v().noop}=e("kubio/edit-site")||{};return{isClassicTemplate:!t()}})),x="template"===_&&k,S=(0,u.useMemo)((()=>!0),[]),w=S&&y,C=w?Ge.ProItem:h.Button,I=S&&(null==a?void 0:a.isPro),j=I?Ge.ProItem:h.Button;let T={};w&&(T={urlArgs:{source:"templates_gallery",content:null==a?void 0:a.label}});let P={};I&&(P={urlArgs:{source:"templates_gallery",content:null==a?void 0:a.label}});const E=(0,u.useCallback)((()=>{s(!0)}),[s]),R=(0,u.useCallback)((()=>{f(Uu),setTimeout((()=>{c()}),0)}),[f,c]),A=(0,u.useCallback)((()=>{f(Wu),setTimeout((()=>{c()}),0)}),[f,c]),O=(0,u.useCallback)((()=>{b?i(!0):o(!0)}),[b,o,i]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Fm.Page.Footer,{children:(0,g.jsx)("div",{className:X()("kubio-predefined-layouts__preview-page__footer d-flex w-100 align-items-center justify-content-end"),children:(0,g.jsxs)("div",{className:"kubio-predefined-layouts__preview-page__footer__buttons",children:[(0,g.jsx)(Ge.ProModalTextContext.Provider,{value:(0,m.__)("This page is only available in the PRO version of Kubio. Please select a free page to import or upgrade to the PRO version.","kubio"),children:(0,g.jsx)(C,{tag:h.Button,isPrimary:!0,onClick:O,isBusy:d,...T,propPopoverClass:"kubio-pro-popover-large",children:(0,m.__)("Import","kubio")})}),(0,g.jsx)(Ge.ProModalTextContext.Provider,{value:(0,m.__)("This starter site is only available in the PRO version of Kubio. Please select a free starter site to import or upgrade to the PRO version.","kubio"),children:(0,g.jsx)(j,{tag:h.Button,isSecondary:!0,onClick:E,...P,children:(0,m.__)("Import full starter site","kubio")})})]})})}),t&&(0,g.jsx)(Mg,{currentTemplateIsClassic:x,currentDemoSite:a,selectedDemoPart:e,isFreeBuild:S,onClose:r,onImportContent:R,onImportFullPage:A,onImportStarterSite:E}),n&&(0,g.jsx)(Fg,{onClose:()=>i(!1)})]})})),Hg=(0,u.memo)((e=>{const{currentDemoParts:t,demoPartsIsLoaded:o}=Hu(),{demoPartThatIsImporting:n}=sd();return(0,g.jsxs)(g.Fragment,{children:[n&&(0,g.jsx)(fd,{}),(0,g.jsx)(Fm,{...e,isLoading:!o,className:"kubio-predefined-layouts__preview-page",items:t,sidebar:(0,g.jsx)(mg,{}),pageContent:(0,g.jsx)(Eg,{}),pageFooter:(0,g.jsx)(Gg,{})})]})})),Ug=(0,u.memo)((e=>(0,g.jsx)(Gu,{children:(0,g.jsx)(ad,{children:(0,g.jsx)(Wm,{children:(0,g.jsx)(Hg,{...e})})})}))),Wg=(0,u.createContext)({list:[],categories:null,filterFunction:null}),Vg=(0,u.createContext)({list:[]}),Kg=(0,u.createContext)({searchString:"",setSearchString:null}),$g=(0,u.createContext)({categoriesList:[],selectedCategory:null,setSelectedCategory:null}),qg=[],Yg=(0,u.memo)((({children:e})=>{const{list:t,categories:o=qg,filterFunction:n=null}=Zg(),i=(0,l.useSelect)((e=>{const{getExcludedSectionCategories:t}=e("kubio/edit-site");return t()})),{selectedCategory:r,setSelectedCategory:a}=Qg(),{searchString:s,setSearchString:c}=Jg(),{initialParams:d,activePage:p}=nd(),h="all",m=v().get(d,[p,"category"],h);let f,b,_,y;if(a)f=r,b=a;else{const[e,t]=(0,u.useState)(m);f=e,b=t}if(c)_=s,y=c;else{const[e,t]=(0,u.useState)("");_=e,y=t}const k=(0,u.useMemo)((()=>{if(v().isEmpty(o))return{};const e={};return o.forEach((({label:t,value:o})=>{e[o]=t})),e}),[o]),x=(0,u.useMemo)((()=>n&&"function"==typeof n?n(t,_):ef(t,_)),[_,t,n]),{resultedCategories:S,nrOfItemsPerCategory:w}=(0,u.useMemo)((()=>{let e=[{value:h,label:"All"}];const t={};if(x.forEach((o=>{const n=(null==o?void 0:o.categories)||[];n.forEach((o=>{if(i.includes(o))return;const r=e.map((e=>e.value));if(n.forEach((e=>{t[e]?t[e]++:t[e]=1})),r.includes(o))return;let a;v().get(k,o)?a=v().get(k,o):(a=v().startCase(o.replace("-"," & ")).trim(),a=a.replace(" "," & "));const s={value:o,label:a};e.push(s)}))})),t[h]=Object.keys(t).reduce(((e,o)=>e+t[o]),0),!v().isEmpty(o)){const t=o.map((({value:e})=>e));e=v().orderBy(e,(e=>v().indexOf(t,e.value)))}return{resultedCategories:e,nrOfItemsPerCategory:t}}),[x,o,i,k]),C=(0,u.useMemo)((()=>x.filter((e=>{const t=(null==e?void 0:e.categories)||[];return!t.some((e=>i.includes(e)))&&(f===h||t.includes(f))}))),[f,h,x,i]),I=(0,u.useMemo)((()=>({searchString:_,setSearchString:y})),[_,y]),j=(0,u.useMemo)((()=>({categoriesList:S,selectedCategory:f,setSelectedCategory:b,nrOfItemsPerCategory:w})),[S,f,b,w]),T=(0,u.useMemo)((()=>({list:C})),[C]);return(0,u.useEffect)((()=>{m&&(S.find((e=>e.value===m))||b(h))}),[]),(0,g.jsx)(Vg.Provider,{value:T,children:(0,g.jsx)(Kg.Provider,{value:I,children:(0,g.jsx)($g.Provider,{value:j,children:e})})})})),Zg=()=>(0,u.useContext)(Wg),Xg=()=>(0,u.useContext)(Vg),Jg=()=>(0,u.useContext)(Kg),Qg=()=>(0,u.useContext)($g),ef=(e,t)=>{if(!t)return e;const o=t.toLowerCase();return e.filter((({label:e})=>e.toLowerCase().includes(o)))},tf={selectedDemoSlug:null,onSelectDemo:v().noop,setSelectedDemoSlug:v().noop,currentDemoSite:null,selectedDemoPartId:null,setSelectedDemoPartId:v().noop},of=(0,u.createContext)(tf),nf=({children:e})=>{const[t,o]=(0,u.useState)(),[n,i]=(0,u.useState)([]),[r,a]=(0,u.useState)({}),[s,l]=(0,u.useState)(!1),[c,d]=(0,u.useState)(),[p,h]=(0,u.useState)(!1);(0,u.useEffect)((()=>{!async function(){const e=await Nu();i(e)}()}),[]),(0,u.useEffect)((()=>{!async function(){const e=await Au();a(e),l(!0)}()}),[]);const m=(0,u.useCallback)(((e,t)=>{d(t),o(e)}),[o,d]),f=(0,u.useMemo)((()=>n.find((e=>e.slug===t))),[t,n]),b=(0,u.useMemo)((()=>({rawDemoList:n,selectedDemoSlug:t,onSelectDemo:m,setSelectedDemoSlug:o,currentDemoSite:f,initialDemoPart:c,setInitialDemoPart:d,demosPartsPerSlug:r,demoPartsIsLoaded:s,showDemoSiteImportPage:p,setShowDemoSiteImportPage:h})),[n,t,m,o,f,c,d,r,s,p,h]);return(0,g.jsx)(of.Provider,{value:b,children:e})},rf=()=>(0,u.useContext)(of),af=(0,u.createContext)({favoritesDataByType:{},onAddToFavorites:v().noop}),sf="kubio_favorites";let lf=!1;const cf=(0,u.memo)((({children:e})=>{const[t,o]=(0,u.useState)({}),{favoritesEntities:n}=(0,l.useSelect)((e=>{const{getEntityRecords:t,getEditedEntityRecord:o}=e("core");return{favoritesEntities:(t("postType",sf,{per_page:-1})||[]).map((e=>o("postType",sf,e.id)))}}),[]),{saveEntityRecord:i,editEntityRecord:r}=(0,l.useDispatch)("core"),a=(0,u.useRef)(!1),s=(0,u.useMemo)((()=>v().get(n,"0")),[n]),c=(0,u.useMemo)((()=>{try{const e=v().get(s,"content","{}");return JSON.parse(e)}catch(e){return{}}}),[s]);(0,u.useEffect)((()=>{v().isEmpty(t)&&!v().isEqual(c,t)&&o(c)}),[c]);const d=(0,u.useCallback)((async()=>{const e={title:"Favorites data",status:"publish",content:JSON.stringify({})};return await i("postType",sf,e)}),[i]),p=(0,u.useCallback)((async(e,n,i)=>{var l,c;const u=v().cloneDeep(t);if(Array.isArray(n)||(n=[n]),n.forEach((t=>{!1===v().get(u,e,!1)&&v().set(u,e,{}),i?v().set(u,`${e}.${t}`,!0):v().unset(u,`${e}.${t}`)})),o(u),a.current)return;a.current=!0;let p=s;if(v().isEmpty(p)&&!lf&&(lf=!0,p=await d()),null===(l=p)||void 0===l||!l.id)return void(a.current=!1);const h={content:JSON.stringify(u)};r("postType",sf,null===(c=p)||void 0===c?void 0:c.id,h),a.current=!1}),[d,a,s,t]),h=(0,u.useMemo)((()=>({favoritesDataByType:t,onAddToFavorites:p})),[t]);return(0,g.jsx)(af.Provider,{value:h,children:e})})),uf=()=>(0,u.useContext)(af),df=(0,u.createContext)({favoritesDataByType:null}),pf=(0,u.memo)((({children:e})=>{const{favoritesDataByType:t}=uf(),o=(0,u.useMemo)((()=>({favoritesDataByType:t})),[t]);return(0,g.jsx)(df.Provider,{value:o,children:e})})),hf=()=>(0,u.useContext)(df),mf=(0,u.memo)((({buttonIconOnly:e=!1})=>{const[t,o]=(0,u.useState)(!1),[n,i]=(0,u.useState)({}),r=(0,u.useRef)(),a=(0,u.useCallback)((()=>{i({}),o(!t)}),[t,o]),{createErrorNotice:c}=(0,s.useKubioNotices)(),{isEditingTemplatePart:d}=(0,l.useSelect)((e=>{const{getEditedPostType:t,getEditedPostId:o}=e("kubio/edit-site")||{};return{isEditingTemplatePart:"wp_template_part"===t()}}),[]),p=(0,u.useCallback)((e=>{"blur"!==(null==e?void 0:e.type)&&o(!1)}),[o]),f=(0,u.useCallback)((e=>{const t=(null==e?void 0:e.detail)||{};i(t),o(!0)}),[o]);(0,u.useEffect)((()=>(document.body.addEventListener("openTemplateGallery",f),()=>{document.body.removeEventListener("openTemplateGallery",f)})),[f]);const b=(0,u.useCallback)((()=>{c((0,m.__)("Something went wrong","kubio"))}),[c]);return d?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{ref:r,onClick:a,isPrimary:!0,icon:He.PredesignedLayoutsIcon,className:X()("kubio-predefined-layouts__button",{"kubio-predefined-layouts__button--icon-only":e}),label:(0,m.__)("Templates Gallery","kubio"),showTooltip:!0,children:e?null:(0,m.__)("Templates Gallery","kubio")}),(0,g.jsx)(Ul.ErrorBoundary,{FallbackComponent:gf,onReset:()=>{o(!1)},onError:b,children:(0,g.jsx)(cf,{children:t&&(0,g.jsx)(h.Modal,{className:"kubio-predefined-layouts__modal",onRequestClose:p,children:(0,g.jsx)(od,{onClose:p,initialParams:n,children:(0,g.jsx)(Tm,{})})})})})]})})),gf=({error:e,resetErrorBoundary:t})=>((0,u.useEffect)((()=>{t()}),[]),(0,g.jsx)(g.Fragment,{})),ff=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"})}),bf=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"})}),_f=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"})});var vf=o(1874),yf=o.n(vf);let kf=null,xf=Math.random();function Sf(e){let t=yf().replace("{message}",(0,m.__)("Generating preview…","kubio"));t=t.replace("{svg_image}",(0,u.renderToString)(He.KubioLoader)),e.write(t),e.title=(0,m.__)("Generating preview…","kubio"),e.close()}function wf(){kf=window.open("",(0,m.__)("Generating preview…","kubio")+xf++)}const Cf="preview",If=[{kind:"kubio",name:"menu"},{kind:"root",name:"site"}];var jf=o(6255),Tf=o.n(jf);const Pf=[{title:(0,m.__)("Desktop","kubio"),name:"Desktop",icon:ff},{title:(0,m.__)("Tablet","kubio"),name:"Tablet",icon:bf},{title:(0,m.__)("Mobile","kubio"),name:"Mobile",icon:_f}],Ef=({deviceType:e,setDeviceType:t})=>{const{isDirty:o}=(0,l.useSelect)((e=>{const{__experimentalGetDirtyEntityRecords:t}=e("core");return{isDirty:t().length>0}})),n=(()=>{const{getDirtyEntityRecords:e,getAutosaves:t,getEntityRecordEdits:o,getEditedEntityRecord:n}=(0,l.useSelect)((e=>({getDirtyEntityRecords:e("core").__experimentalGetDirtyEntityRecords,getAutosaves:e("core").getAutosaves,getEntityRecordEdits:e("core").getEntityRecordEdits,getEditedEntityRecord:e("core").getEditedEntityRecord}))),{saveEditedEntityRecord:i}=(0,l.useDispatch)("core");return async(r,a={})=>{var s;const{autosaveType:l,statusForSave:c}=v().merge({autosaveType:Cf,statusForSave:"autosave"},a);let u=[];u=r||e();const p=u.filter((({kind:e,name:t})=>!(0,_.find)(If,{kind:e,name:t}))),h=u.filter((({kind:e,name:t,key:o})=>!(0,_.find)(p,{kind:e,name:t,key:o}))),m=p.map((({kind:e,name:t,key:o})=>{const r=n(e,t,o);let a;if(null!=r&&r.blocks)a=(0,lt.serialize)(r.blocks);else{if("string"!=typeof(null==r?void 0:r.content))return null;a=null==r?void 0:r.content}return-1!==["wp_template","wp_template_part","page","post","product"].indexOf(r.type)?((e,t="publish",{fieldsToOmit:o=["blocks"],type:n=Cf}={})=>O()({path:"kubio/v1/save-entity",method:"POST",data:{postData:(0,_.omit)({...e,id:e.id||e.wp_id},["selectionStart","selectionEnd"].concat(o)),type:n,status:t}}))({...r,content:a},c,{type:l}):i(e,t,o,{isAutosave:!0})})),g=h.map((({kind:e,name:t,key:n})=>({kind:e,name:t,key:n,...o(e,t,n)}))),f=null===(s=e())||void 0===s?void 0:s.filter((({name:e})=>"page"===e||"post"===e)).reduce(((e,{key:t,name:o,kind:i})=>{const r=n(i,o,t);return{...e,[t]:null==r?void 0:r.template}}),{});return Promise.all(m).then((e=>{const o=p.map((({name:o,key:n},i)=>e[i]?{id:e[i].ID||e[i].id,parent:e[i].post_parent||e[i].parent,data:e[i]}:(0,_.last)(t(o,n))));return Promise.all(o).then((e=>{const t=e.filter(Boolean).map((({id:e,parent:t})=>({id:e,parent:t})));return{updatesRecords:e.map((e=>null==e?void 0:e.data)),autosaves:t,customEntities:g,pageTemplatesMap:f,customData:(0,d.applyFilters)("kubio/custom-preview-data",{})}}))}))}})(),{saveChangeset:i}=(()=>{const[e,t]=(0,x.useGlobalSessionProp)("previewChangest",{}),o=(0,l.useSelect)((e=>{var t;return null===(t=e("core/block-editor").getSettings())||void 0===t?void 0:t.changeset_uuid}));(0,u.useEffect)((()=>{e.id||!o||e.isLoading||(t({...e,isLoading:!0}),O()({path:(0,zo.addQueryArgs)("/wp/v2/kubio/preview-changeset/",{slug:o})}).then((e=>{e&&e.length&&t({...e[0],isLoading:!1})})))}),[e,t,o]);const n=(0,u.useCallback)((()=>{var t,o;e.id&&window.navigator.sendBeacon&&window.navigator.sendBeacon(`${window.ajaxurl}?action=kubio-delete-changeset&uuid=${e.slug}&_wpnonce=${null===(t=top)||void 0===t||null===(o=t.kubioUtilsData)||void 0===o?void 0:o.kubio_ajax_nonce}`)}),[e.id]);return(0,u.useEffect)((()=>(window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n))),[e.id]),{saveChangeset:async n=>{let i=e;return i.id||(i=await O()({path:(0,zo.addQueryArgs)("/wp/v2/kubio/preview-changeset/",{slug:o})}),t(i)),await O()({path:`/wp/v2/kubio/preview-changeset/${i.id}`,method:"POST",data:{...(0,_.pick)(e,["title","slug","type"]),content:JSON.stringify((0,_.omit)(n,"updatesRecords"))}}),o}}})(),{currentPageURL:r}=(0,l.useSelect)((e=>{const t=e(y.STORE_KEY).getPage(),o=v().get(t,"link"),n=v().get(t,"path"),i=o||n;return{currentPageURL:(null!=i?i:"").replace(/\/$/,"")}})),a=(0,l.useSelect)((e=>()=>{const{getSelectedBlockClientIds:t}=e(I.store),o=t();return o.length?o[0]:""})),{hideInsertionPoint:s}=(0,l.useDispatch)("core/block-editor"),c=e=>()=>{t(e),s()},p=(0,x.useBlocksOwnerDocument)();return(0,u.useEffect)((()=>{const t=(0,T.getPreviewElementByModelId)(a(),p);t&&e&&Tf()(t)}),[e]),(0,g.jsxs)("div",{className:"kubio-preview-options",children:[Pf.map((({name:t,title:o,icon:n})=>(0,g.jsx)(h.Button,{icon:n,isPressed:t===e,label:o,onClick:c(t)},t))),""!==r&&(0,g.jsx)(h.Button,{onClick:async({})=>{const e=(()=>{kf&&!kf.closed||wf();try{Sf(kf.document)}catch(e){wf(),Sf(kf.document)}return setTimeout((function(){kf.focus()}),100),kf})();let t="saved";const a=`${Xa().generate()}-${Xa().generate()}`;if(o){const e=await n();t=await i(e)}e.location=(0,zo.addQueryArgs)(r,{"kubio-preview":t,"kubio-random":a})},children:(0,m.__)("Preview","kubio")})]})},Rf=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"})}),Af=window.wp.keycodes;function Of(){const e=(0,l.useSelect)((e=>e("core").hasRedo())),{clearSelectedBlock:t}=(0,l.useDispatch)("core/block-editor"),{redo:o}=(0,l.useDispatch)("core");return(0,g.jsx)(h.Button,{icon:Rf,label:(0,m.__)("Redo","kubio"),shortcut:Af.displayShortcut.primaryShift("z"),"aria-disabled":!e,onClick:e?()=>{t(),o()}:void 0})}const Nf=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})});function Bf(){const e=(0,l.useSelect)((e=>e("core").hasUndo())),{undo:t}=(0,l.useDispatch)("core"),{clearSelectedBlock:o}=(0,l.useDispatch)("core/block-editor");return(0,g.jsx)(h.Button,{icon:Nf,label:(0,m.__)("Undo","kubio"),shortcut:Af.displayShortcut.primary("z"),"aria-disabled":!e,onClick:e?()=>{o(),t()}:void 0})}const Df=(0,h.createSlotFill)("EditorHeaderToolbarSlotFill");function Mf({openEntitiesSavedStates:e}){const{deviceType:t,isEditorSidebarOpened:o,shortcut:n,getBlockSelectionStart:i,isListViewOpen:r,listViewShortcut:a,isAICapabilityEnabled:c}=(0,l.useSelect)((e=>{const{__experimentalGetPreviewDeviceType:t,isFeatureActive:o,getEditedPostType:n,getEditedPostId:i,isInserterOpened:r,getTemplateId:a,getTemplatePartId:s,getEntity:l,getPage:c,getShowOnFront:u,isListViewOpened:d,isAICapabilityEnabled:p}=e(y.STORE_KEY),{getEntityRecord:h}=e("core"),{__experimentalGetTemplateInfo:m}=e("core/editor"),g=a(),f=s(),b=n(),_=h("postType",b,i());let v;var k;v="wp_template"===b?null!=_&&_.title?null==_||null===(k=_.title)||void 0===k?void 0:k.raw:m(_).title:null==_?void 0:_.slug;const{getShortcutRepresentation:x}=e("core/keyboard-shortcuts");return{isListViewOpen:d(),deviceType:t(),entityTitle:v,hasFixedToolbar:o("fixedToolbar"),template:_,templateType:b,isInserterOpen:r(),templateId:g,templatePartId:f,entity:l(),page:c(),showOnFront:u(),isEditorSidebarOpened:e(y.STORE_KEY).isEditorSidebarOpened(),shortcut:x("core/edit-post/toggle-sidebar"),getBlockSelectionStart:e("core/block-editor").getBlockSelectionStart,listViewShortcut:x("kubio/edit-site/toggle-list-view"),isAICapabilityEnabled:p()}}),[]),{__experimentalSetPreviewDeviceType:d,openSidebar:f,closeSidebar:b}=(0,l.useDispatch)(y.STORE_KEY),{hideInsertionPoint:w}=(0,l.useDispatch)("core/block-editor"),C=(0,u.useCallback)((e=>{w(),d(e)}),[]),I=(0,p.useViewportMatch)("medium"),j=o?()=>{b(),O(!1)}:()=>{f(i()?"block-inspector":"document"),O(!1)},P=(0,s.usePageTitle)(),{isNavigationOpened:E}=(0,l.useSelect)(y.STORE_KEY),{setIsNavigationPanelOpened:R,openNavigationPanelToMenu:A,setIsListViewOpened:O}=(0,l.useDispatch)(y.STORE_KEY),{uiVersion:N}=(0,k.useUIVersion)(),B=(0,u.useCallback)((()=>{O(!r)}),[O,r]);let D=!0;2===N&&(D=!1);const M=(0,x.useGetGlobalSessionProp)("ready",!1),L=(0,_.get)(window,["kubioUtilsData","enable_starter_sites"],!0),[z,F]=(0,u.useState)(!1),[,G]=Qa(),{isPage:H,isBlog:U,isWooPage:W}=(0,l.useSelect)((e=>{const{getPage:t=v().noop,getIsBlogPage:o=v().noop}=e("kubio/edit-site")||{},n=t();return{isPage:"page"===v().get(n,"context.postType"),isBlog:o(),isWooPage:e(y.STORE_KEY).getIsWooCommercePage()}}),[]),V=H&&!U&&!W,K=T.AI_IN_PRO?Ge.ProItem:h.Button;return(0,g.jsxs)("div",{className:"edit-site-header",children:[(0,g.jsx)("div",{className:"edit-site-header_start",children:(0,g.jsxs)("div",{className:"edit-site-header__toolbar",children:[I&&(0,g.jsxs)(g.Fragment,{children:[1===N&&(0,g.jsx)(Qe,{}),(0,g.jsx)(Bf,{}),(0,g.jsx)(Of,{}),(0,g.jsx)(h.Button,{className:"edit-site-header-toolbar__list-view-toggle",icon:Ya,isPressed:r/* translators: button label text should, if possible, be under 16 characters. */,label:(0,m.__)("List View","kubio"),onClick:B,shortcut:a}),M&&L&&(0,g.jsx)(mf,{buttonIconOnly:c}),V&&c&&(0,g.jsx)(h.Tooltip,{text:(0,m.__)("AI page generation","kubio"),children:(0,g.jsx)(K,{tag:h.Button,isProItem:T.AI_IN_PRO,urlArgs:{source:"AI",content:"generate-ai-page"},icon:He.KubioAI,className:"kubio-ai-button-in-header kubio-ai-button",onClick:()=>F(!0),children:(0,m.__)("Generate page","kubio")})}),(0,g.jsx)(Df.Slot,{}),z&&(0,g.jsx)(S.AIWizard,{onFinish:()=>{F(!1),G(!0)},onCancel:()=>F(!1),isRegenerate:!0})]}),!1]})}),(0,g.jsx)("div",{className:"edit-site-header_center",children:(0,g.jsx)("div",{className:"edit-site-document-actions",children:(0,g.jsx)("div",{className:"edit-site-document-actions__title-wrapper",children:(0,g.jsx)(h.Button,{className:"edit-site-document-actions__title",onClick:()=>{E()?R(!1):A(2===N?"kubio-content-area-postType-page":ts)},isPressed:E(),iconPosition:"right",showTooltip:!0,label:E()?(0,m.__)("Close the site content panel","kubio"):(0,m.__)("Change page","kubio"),children:(0,g.jsxs)(h.Flex,{align:"center",justify:"center",children:[(0,g.jsx)(h.FlexItem,{className:"edit-site-document-entity-title",children:(0,g.jsx)("span",{className:"kubio-entity-title-text",dangerouslySetInnerHTML:{__html:(0,m.sprintf)(// translators: Editing current page
// translators: Editing current page
(0,m.__)("Editing: %s","kubio"),(0,m.sprintf)('<span class="kubio-entity-title-name">%s</span>',(0,T.fromHtmlEntities)(null!=P?P:(0,m.__)("Page","kubio"))))}})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Icon,{icon:He.SwitchPages,size:22})})]})})})})}),(0,g.jsx)("div",{className:"edit-site-header_end",children:(0,g.jsxs)("div",{className:"edit-site-header__actions",children:[(0,g.jsx)(Ef,{deviceType:t,setDeviceType:C}),(0,g.jsx)(ds,{openEntitiesSavedStates:e}),D&&(0,g.jsx)(h.Button,{icon:dt,label:(0,m.__)("Settings","kubio"),onClick:j,isPressed:o,"aria-expanded":o,className:"kubio-secondary-panel-toggler",shortcut:n}),(0,g.jsx)(Re.Slot,{scope:"kubio/edit-site"}),(0,g.jsx)(Hl,{})]})})]})}function Lf({openEntitiesSavedStates:e}){const{__experimentalGetDirtyEntityRecords:t,isSavingEntityRecord:o}=(0,l.useSelect)(j.store),{redo:n,undo:i}=(0,l.useDispatch)(j.store);return(0,Me.useShortcut)("kubio/edit-site/save",(n=>{n.preventDefault();const i=t(),r=!!i.length;!i.some((e=>o(e.kind,e.name,e.key)))&&r&&e()})),(0,Me.useShortcut)("kubio/edit-site/undo",(e=>{i(),e.preventDefault()})),(0,Me.useShortcut)("kubio/edit-site/redo",(e=>{n(),e.preventDefault()})),null}Lf.Register=function(){const{registerShortcut:e}=(0,l.useDispatch)(Me.store);return(0,u.useEffect)((()=>{e({name:"kubio/edit-site/save",category:"global",description:(0,m.__)("Save your changes.","kubio"),keyCombination:{modifier:"primary",character:"s"}}),e({name:"kubio/edit-site/undo",category:"global",description:(0,m.__)("Undo your last changes.","kubio"),keyCombination:{modifier:"primary",character:"z"}}),e({name:"kubio/edit-site/redo",category:"global",description:(0,m.__)("Redo your last undo.","kubio"),keyCombination:{modifier:"primaryShift",character:"z"}}),e({name:"kubio/edit-site/toggle-list-view",category:"global",description:(0,m.__)("Open the block list view.","kubio"),keyCombination:{modifier:"access",character:"o"}})}),[e]),null};const zf=Lf,Ff=({children:e,templateId:t,templateType:o,page:n})=>{const[i,r]=(0,u.useState)(!1),[a,s]=(0,u.useState)(!1),c=Go(),[d,p]=(0,x.useGlobalSessionProp)("thirdPartyBlockInstalled",!1),{createSuccessNotice:f}=(0,l.useDispatch)("core/notices");(0,u.useEffect)((()=>{r(c)}),[c,t,o,n]);const b=(0,u.useCallback)((()=>{a||r(!1)}),[a]),_=(0,u.useCallback)((async()=>{s(!0);try{await Lo()}catch(e){}p(!0),f((0,m.__)("Kubio blog templates were imported successfully! Refresh the editor to enjoy the full site editing experience","kubio"),{isDismissible:!0,actions:[{label:(0,m.__)("Refresh page now","kubio"),onClick:()=>window.location.reload()}]}),r(!1)}),[f,p]);return(0,g.jsxs)(g.Fragment,{children:[i&&!d&&(0,g.jsxs)(h.Modal,{title:(0,m.__)("💫 Start with the Kubio blog!","kubio"),onRequestClose:b,shouldCloseOnEsc:!1,shouldCloseOnClickOutside:!1,isDismissible:!a,children:[(0,g.jsxs)("p",{children:[(0,m.__)("Kubio comes with a fully customizable blog area for your site.","kubio"),(0,g.jsx)("br",{}),(0,m.__)("Would you like to use the Kubio blog templates? ","kubio")]}),(0,g.jsxs)(h.ButtonGroup,{className:"h-template-part-modal__button-group",children:[!a&&(0,g.jsx)(h.Button,{isLink:!0,onClick:b,children:(0,m.__)("Maybe later","kubio")}),(0,g.jsxs)(h.Button,{isPrimary:!0,isBusy:a,onClick:_,children:[!a&&(0,m.__)("Import Kubio blog","kubio"),a&&(0,m.__)("Importing Kubio blog…","kubio")]})]})]}),e]})},Gf="__experimentalMainDashboardButton",{Fill:Hf,Slot:Uf}=(0,h.createSlotFill)(Gf),Wf=Hf;Wf.Slot=({children:e})=>(0,s.useSlotHasFills)(Gf)?(0,g.jsx)(Uf,{bubblesVirtually:!0}):e;const Vf=Wf,Kf=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z"})}),$f=({setIsModalVisible:e})=>{var t;const{saveEntityRecord:o}=(0,l.useDispatch)("core"),n=(0,x.useSetGlobalSessionProp)("ready"),[,i]=(0,x.useGlobalSessionProp)("displayingEmptyPageChecked"),[r,a]=(0,u.useState)(!0),{setPage:s,setIsNavigationPanelOpened:c}=(0,l.useDispatch)(Le),[p,h]=(0,u.useState)(null),[f,b]=(0,u.useState)(!1),[_,v]=(0,u.useState)(!1),[,y]=Qa(),k=(0,l.useSelect)((e=>e(Le).getAvailablePageTemplates().map((e=>e.value)).find((e=>(0,T.getBackendData)("installedViaFreshSite")?e.endsWith("full-width"):"full-width"===e))||"")),w=(0,u.useCallback)((()=>{p&&(s({type:p.type,slug:p.slug,path:(0,zo.getPathAndQueryString)(p.link),context:{postType:p.type,postId:p.id}}),v(!1),c(!1),i(!1),(0,d.addAction)("kubio.editorIsReady","kubio.editorIsReady.setIsAIGeneratingStarted",(function(){(0,d.removeAction)("kubio.editorIsReady","kubio.editorIsReady.setIsAIGeneratingStarted"),y(!0)})),setTimeout((()=>n(!0)),5e3),e(!1))}),[p,s,c,i,e,y,n]);return(0,g.jsxs)(g.Fragment,{children:[r&&(0,g.jsx)(S.AIWizard,{onFinish:async({pageContext:e})=>{v(!0),a(!1);const{title:t}=e,n=await o("postType","page",{title:t,status:"publish",template:k,meta:{saved_in_kubio:!0},kubio_ai_page_context:e});n&&(v(!1),b(!0),h(n))},onCancel:()=>e(!1),checkPageType:!1,isNewPageWizard:!0}),_&&(0,g.jsx)(As,{message:(0,m.__)("Creating new page…","kubio"),withFooter:!1}),f&&(0,g.jsx)($m,{onComplete:w,closeModal:()=>b(!1),entityName:null==p||null===(t=p.title)||void 0===t?void 0:t.rendered})]})},qf=({onNewAiPage:e,onNewKubioPage:t,showButton:o=!0,initialModalIsVisible:n=!1,title:i=(0,m.__)("How would you like to create your new page?","kubio"),description:r=(0,m.__)("Choose one of the two methods below for creating your new page.","kubio"),onCancel:a=v().noop})=>{const[s,c]=(0,u.useState)(n);return!(0,l.useSelect)((e=>e(Bi.Ls).isAICapabilityEnabled()),[])&&o?(0,g.jsx)(h.Button,{className:"kubio-navigation-new-page__button",icon:$e,variant:"primary",iconSize:24,onClick:()=>t(),children:(0,m.__)("New Page","kubio")}):(0,g.jsxs)(g.Fragment,{children:[o&&(0,g.jsx)(h.Button,{className:"kubio-navigation-new-page__button",icon:$e,variant:"primary",iconSize:24,onClick:()=>c(!0),children:(0,m.__)("New Page","kubio")}),s&&(0,g.jsx)(h.Modal,{title:(0,m.__)("Add page","kubio"),onRequestClose:()=>{c(!1),a()},className:"kubio-navigation-new-page__modal",children:(0,g.jsxs)("div",{className:"kubio-navigation-new-page__modal__content",children:[(0,g.jsx)("h2",{className:"kubio-navigation-new-page__modal__title",children:i}),(0,g.jsx)("span",{className:"kubio-navigation-new-page__modal__description",children:r}),(0,g.jsxs)("div",{className:"kubio-navigation-new-page__modal__cards",children:[(0,g.jsx)(Yf,{icon:He.KubioLogo,title:(0,m.__)("Create from scratch","kubio"),description:(0,m.__)("Build your page by hand starting from a blank canvas. This option is recommended for advanced users who wish to create their own, custom design.","kubio"),onClick:()=>{c(!1),t()}}),(0,g.jsx)(Yf,{icon:He.KubioAI,isProItem:T.AI_IN_PRO,iconClassName:"kubio-ai-logo-animated kubio-ai-logo-colored",title:(0,m.__)("Generate with Kubio AI","kubio"),description:(0,m.__)("Get a head start by letting Kubio Al generate a first draft of the page for you. Then you can further customize the page to your liking.","kubio"),onClick:()=>{c(!1),e()}})]})]})})]})},Yf=({icon:e,title:t,description:o,onClick:n,iconClassName:i,isProItem:r=!1})=>(0,g.jsxs)(Ge.ProItem,{isProItem:r,className:"kubio-navigation-new-page__modal__card",onClick:n,urlArgs:{source:"AI",content:"ai-settings"},children:[(0,g.jsx)(h.Icon,{className:X()("kubio-navigation-new-page__modal__card__icon",i),icon:e}),(0,g.jsx)("h2",{className:"kubio-navigation-new-page__modal__card__title",children:t}),(0,g.jsx)("span",{className:"kubio-navigation-new-page__modal__card__description",children:o})]}),Zf=(0,g.jsx)(Q.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)(Q.Path,{d:"M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z"})}),Xf=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})}),Jf=({post:e,onCloseModal:t,onClickDuplicate:o})=>{const[n,i]=(0,u.useState)(!1),{createErrorNotice:r,createSuccessNotice:a}=(0,s.useKubioNotices)(),[c,d]=(0,u.useState)(""),{saveEntityRecord:p}=(0,l.dispatch)("core"),f=async(t,n,s)=>{i(!0);const l={title:s||c,status:"publish",content:null==e?void 0:e.content,excerpt:null==e?void 0:e.excerpt,meta:{...(null==e?void 0:e.meta)||{},saved_in_kubio:!0},template:null==e?void 0:e.template};let u=!1;try{u=await p(t,n,l),a((0,m.sprintf)(// translators: %s is the name of item that was saved
// translators: %s is the name of item that was saved
(0,m.__)("%s saved successfully!","kubio"),l.title))}catch(e){console.error(e),r((0,m.sprintf)(//translators: %s is the name of item that was not saved
//translators: %s is the name of item that was not saved
(0,m.__)("An error occurred. %s was not saved!","kubio"),l.title))}u&&o(u)};return(0,g.jsx)(h.Modal,{title:(0,m.__)("Duplicate page","kubio"),onRequestClose:e=>{e.stopPropagation(),t()},className:"block-editor-block-new-entity-modal",shouldCloseOnEsc:!n,shouldCloseOnClickOutside:!n,isDismissible:!n,children:(0,g.jsxs)("div",{className:"popover__content",children:[(0,g.jsx)(ut.InputControl,{value:c,onChange:e=>d(e),label:(0,m.__)("Title","kubio"),autoFocus:!0,onKeyPress:t=>{"Enter"===t.key&&f("postType",e.type,t.target.value)}}),(0,g.jsx)(h.__experimentalSpacer,{margin:3}),(0,g.jsx)(h.Button,{isPrimary:!0,isBusy:n,disabled:""===c,onClick:()=>{f("postType",e.type)},className:"add-button",children:(0,m.__)("Duplicate page","kubio")})]})})},Qf=({post:e,onCloseModal:t})=>{var o,n;const[i,r]=(0,u.useState)(!1),{createErrorNotice:a,createSuccessNotice:l}=(0,s.useKubioNotices)();return(0,g.jsxs)(h.Modal,{title:(0,m.__)("Delete ","kubio")+(null==e||null===(o=e.title)||void 0===o?void 0:o.raw)+(0,m.__)(" page?","kubio"),onRequestClose:e=>{e.stopPropagation(),t()},className:"block-editor-block-new-entity-modal",shouldCloseOnEsc:!i,shouldCloseOnClickOutside:!i,isDismissible:!i,children:[(0,g.jsxs)("p",{children:[(0,g.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,m.sprintf)(// translators: %s: page name
// translators: %s: page name
(0,m.__)("The <strong>%s</strong> page will be moved in the trash.","kubio"),null==e||null===(n=e.title)||void 0===n?void 0:n.raw)}}),(0,g.jsx)("br",{}),(0,m.__)("You can recover it later from WP Admin -> Pages -> Trash","kubio")]}),(0,g.jsxs)(h.ButtonGroup,{className:"h-template-part-modal__button-group",children:[(0,g.jsx)(h.Button,{isLink:!0,onClick:t,children:(0,m.__)("Cancel","kubio")}),(0,g.jsx)(h.Button,{isPrimary:!0,onClick:async()=>{r(!0),await eb(e,a,l),t()},children:(0,m.__)("Delete","kubio")})]})]})},eb=(e,t,o)=>{var n;const i=e.id,r=null==e||null===(n=e.title)||void 0===n?void 0:n.raw;try{(0,l.dispatch)("core").deleteEntityRecord("postType",e.type,parseInt(i)),o(r+(0,m.__)(" moved to trash!","kubio"))}catch(e){t((0,m.sprintf)(//translators: %s is the name of item that was not saved
//translators: %s is the name of item that was not saved
(0,m.__)("An error occurred. %s was not saved","kubio"),r))}},tb=e=>{var t;const o=e.taxonomy?e.name:null==e||null===(t=e.title)||void 0===t?void 0:t.rendered,n=document.createElement("div");return n.innerHTML=o,n.textContent||n.innerText||""},ob=(e,t,o,n)=>{var i;let r=!1;var a,s,l;return void 0!==(null==e?void 0:e.taxonomy)?(null==e?void 0:e.id.toString())===(null===(a=o.context)||void 0===a||null===(s=a.postId)||void 0===s?void 0:s.toString())&&void 0===(null==o||null===(l=o.context)||void 0===l?void 0:l.postType)&&(r=!0):(null==o||null===(i=o.context)||void 0===i?void 0:i.postType)===n&&(r=t.includes(e.id.toString())),r};function nb({item:e,entity:t}){const{setPage:o,setIsNavigationPanelOpened:n}=(0,l.useDispatch)(Le),{page_for_posts:i,page_on_front:r,show_on_front:a,wooCommercePagesIds:s,isActive:c}=(0,l.useSelect)((o=>{var n,i,r,a,s;const{page_for_posts:l,page_on_front:c,show_on_front:u}=o("core").getEditedEntityRecord("root","site"),d=null===(n=o("core/block-editor").getSettings())||void 0===n||null===(i=n.kubioBasicWooCommerce)||void 0===i?void 0:i.pagesIds,{getPage:p,getTemplateId:h,getTemplatePartId:m}=o(Le),g=[null===(r=p())||void 0===r||null===(a=r.context)||void 0===a||null===(s=a.postId)||void 0===s?void 0:s.toString(),h(),m()].filter(Boolean),f=ob(e,g,p(),t);return{page_for_posts:l,page_on_front:c,show_on_front:u,wooCommercePagesIds:Object.values(d||{}),isActive:f}}),[t,e]),{duplicateContainerRef:d,delContainerRef:p}=(0,u.useRef)(),[f,b]=(0,u.useState)(!1),[_,v]=(0,u.useState)(!1),[y,k]=(0,u.useState)(!1),[S,w]=(0,u.useState)({}),[,C]=(0,x.useGlobalSessionProp)("displayingEmptyPageChecked"),I=(0,u.useCallback)((()=>{const{type:t,slug:i,link:r,id:a}=null!=S&&S.id?S:e;o({type:t,slug:i,path:(0,zo.getPathAndQueryString)(r),context:{postType:t,postId:a}}),C(!0),n(!1)}),[S,e,o,C,n]),j=(0,u.useCallback)((()=>{c||k(!0)}),[c]),T=(0,u.useCallback)((()=>{b(!0)}),[]),P=(0,u.useCallback)((()=>{v(!0)}),[]);if(!e)return null;const E=tb(e)||(0,m.__)("(no title)","kubio");let R,A;"page"===a&&r===e.id&&"page"===t&&(R=(0,g.jsx)(h.Icon,{title:(0,m.__)("Homepage","kubio"),icon:Kf,size:18})),"page"===a&&i===e.id&&"page"===t&&(R=(0,g.jsx)(h.Icon,{title:(0,m.__)("Posts page","kubio"),icon:Zf,size:18})),-1!==s.indexOf(e.id)&&"page"===t&&(R=(0,g.jsx)(h.Icon,{title:(0,m.__)("Shop page","kubio"),icon:He.WooCommerceSmallLogo,size:18}));const O=r!==e.id&&!c;"page"===a&&"page"===e.type&&i!==e.id&&(A=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.DropdownMenu,{className:"kubio-more-menu",icon:hs,label:(0,m.__)("More tools & options","kubio"),popoverProps:{className:"edit-site-kubio-more-menu__content edit-site-more-menu__content",position:"bottom left",isAlternate:!0},toggleProps:{tooltipPosition:"bottom"},children:({onClose:e})=>(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(h.MenuGroup,{children:[(0,g.jsx)(h.MenuItem,{icon:He.DuplicateItemIcon,ref:d,onClick:t=>{t.preventDefault(),T(t),e()},role:"menuitemcheckbox",children:(0,m.__)("Duplicate","kubio")}),O&&(0,g.jsx)(h.MenuItem,{icon:Xf,ref:p,onClick:t=>{t.preventDefault(),P(t),e()},role:"menuitemcheckbox",children:(0,m.__)("Delete","kubio")})]})})}),f&&(0,g.jsx)(Jf,{post:e,onCloseModal:()=>{b(!1)},onClickDuplicate:e=>{w(e),b(!1),k(!0)}}),_&&(0,g.jsx)(Qf,{post:e,onCloseModal:()=>{v(!1)}})]}));const N=X()("edit-site-navigation-panel__content-item",{"kubio-navigation-item-active":c});return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.__experimentalNavigationItem,{className:N,item:`${e.taxonomy||e.type}-${e.id}`,title:E,children:[(0,g.jsxs)(h.Button,{onClick:j,children:[R&&(0,g.jsx)("span",{className:"components-navigation__item-badge",children:R}),(0,g.jsx)("span",{className:"components-truncate components-text components-navigation__item-title",children:E})]}),A]}),y&&(0,g.jsx)($m,{onComplete:I,closeModal:()=>k(!1),entityName:E})]})}const ib=e=>(0,_.deburr)(e).replace(/^\//,"").toLowerCase(),rb=(e,t)=>-1!==ib(e).indexOf(ib(t));function ab({item:e,icon:t}){const{title:o,description:n,isActive:i}=(0,l.useSelect)((t=>{var o,n,i,r;const{getPage:a,getTemplateId:s,getTemplatePartId:l}=t(Le),c=[null===(o=a())||void 0===o||null===(n=o.context)||void 0===n||null===(i=n.postId)||void 0===i?void 0:i.toString(),s(),l()].filter(Boolean);return{..."wp_template"===e.type?t("core/editor").__experimentalGetTemplateInfo(e):{title:(null==e||null===(r=e.title)||void 0===r?void 0:r.rendered)||(null==e?void 0:e.slug),description:""},isActive:c.includes(e.id.toString())}}),[]),{setTemplate:r,setTemplatePart:a,setIsNavigationPanelOpened:s,setPage:c}=(0,l.useDispatch)(Le),[d,p]=(0,u.useState)(!1),f=(0,u.useCallback)((()=>{i||p(!0)}),[p,i]),[,b]=(0,x.useGlobalSessionProp)("displayingEmptyPageChecked");if(!e)return null;const _=X()("edit-site-navigation-panel__template-item",{"kubio-navigation-item-active":i});return(0,g.jsxs)(h.__experimentalNavigationItem,{className:_,item:`${e.type}-${e.id}`,title:o,icon:t,children:[(0,g.jsx)(h.Button,{onClick:f,children:(0,g.jsxs)("span",{className:"edit-site-navigation-panel__info-wrapper",children:[(0,g.jsxs)("div",{className:"edit-site-navigation-panel__template-item-title",children:["draft"===e.status&&(0,g.jsx)("em",{children:(0,m.__)("[Draft]","kubio")}),o]}),n&&(0,g.jsx)("div",{className:"edit-site-navigation-panel__template-item-description",children:n})]})}),d&&(0,g.jsx)($m,{onComplete:()=>{"wp_template"===e.type?r(e.id,e.slug,!0):a(e.id),b(!1),s(!1)},closeModal:()=>p(!1),entityName:o,changePage:!1})]})}function sb({items:e,search:t}){const o=(null==e?void 0:e.length)>0?e[0].type:null,n=(0,l.useSelect)((t=>{if("wp_template"===o){const{__experimentalGetTemplateInfo:o}=t("core/editor");return e.map((e=>({slug:e.slug,...o(e)})))}return(e||[]).map((e=>{var t,o;return{slug:e.slug,title:null===(t=e.title)||void 0===t?void 0:t.rendered,description:null===(o=e.excerpt)||void 0===o?void 0:o.rendered}}))}),[e,o]),i=(0,u.useMemo)((()=>null===e||0===t.length?[]:e.filter((({slug:e})=>{const{title:o,description:i}=n.find((t=>t.slug===e));return rb(e,t)||rb(o,t)||rb(i,t)}))),[e,n,t]),r="wp_template"===o||"wp_template_part"===o?ab:nb;return(0,g.jsx)(h.__experimentalNavigationGroup,{title:(0,m.__)("Search results","kubio"),children:(0,_.map)(i,(e=>(0,g.jsx)(r,{item:e},`${e.type}-${e.id}`)))})}const lb=({kind:e="postType",entity:t,title:o,hasSearch:n=!0,parentMenu:i=ts})=>{const{search:r,searchQuery:a,onSearch:c,isDebouncing:d}=function(){const[e,t]=(0,u.useState)(""),[o,n]=(0,u.useState)(""),[i,r]=(0,u.useState)(!1);(0,u.useEffect)((()=>{r(!1)}),[o]);const a=(0,u.useCallback)((0,_.debounce)(n,75),[n]);return{search:e,searchQuery:o,isDebouncing:i,onSearch:(0,u.useCallback)((e=>{t(e),a(e),r(!0)}),[t,r,a])}}(),p=(0,l.useRegistry)(),{resetSelection:f}=p.dispatch(I.store),{setPage:b,setIsNavigationPanelOpened:k}=(0,l.useDispatch)(y.STORE_KEY),{saveEntityRecord:S}=(0,l.dispatch)("core"),{items:w,showOnFront:C,pageForPosts:j,pageOnFront:T,isResolved:P,siteURL:E}=(0,l.useSelect)((o=>{const{getEntityRecords:n,getEditedEntityRecord:i,hasFinishedResolution:r,getEntityRecord:s}=o("core"),l=[e,t,{search:a,status:"publish,private",per_page:50}],c=r("getEntityRecords",l),{page_for_posts:u,page_on_front:d}=o("core").getEditedEntityRecord("root","site");let p=n(...l);return"postType"===e&&"page"===t&&(0,_.isArray)(p)&&(p=[s("postType","page",d),s("postType","page",u),...p].filter(Boolean),p=(0,_.uniqBy)(p,(e=>parseInt(null==e?void 0:e.id)))),{items:p,isResolved:c,showOnFront:i("root","site").show_on_front,siteURL:o("core/block-editor").getSettings().siteUrl||"/",pageForPosts:u,pageOnFront:d,getEntityRecord:s}}),[a,t,e]),[R,A]=(0,u.useState)(""),[O,N]=(0,u.useState)(!1),[B,D]=(0,u.useState)(!1),[M,L]=(0,u.useState)(!1),[z,F]=(0,u.useState)({}),[,G]=(0,x.useGlobalSessionProp)("displayingEmptyPageChecked"),H=(0,u.useCallback)((()=>{N(!1),D(!0)}),[D]),U=async(e,t)=>{L(!0);const o={title:R,status:"publish",template:q,meta:{saved_in_kubio:!0}},n=await S(e,t,o);n&&(F(n),H(),L(!1),A(""))},{availableTemplates:W,isKubioTheme:V}=(0,l.useSelect)((e=>{const t=e(y.STORE_KEY),{getSettings:o}=e(I.store);return{availableTemplates:t.getAvailablePageTemplates(),isKubioTheme:o().isKubioTheme}}),[]),{templates:K,defaultTemplate:$}=(0,s.useDeepMemo)((()=>{let e,t=W;return V?(e=v().find(t,{value:"kubio-full-width"})?"kubio-full-width":"full-width",t=W):(e="",(0,_.find)(t,{value:e})||(e=v().find(t,{value:"kubio-full-width"})?"kubio-full-width":"full-width")),{defaultTemplate:e,templates:t}}),[W,V]),[q,Y]=(0,u.useState)($),Z=(0,s.useDeepMemo)((()=>{const e=K.reduce(((e,t)=>{const o=t.source||"custom";return{...e,[o]:[...e[o]||[],t]}}),{}),t=[];return v().forEach(y.templateGroupPriorities,(function(o){var n;null!==(n=e[o])&&void 0!==n&&n.length&&(t.push({value:"template-group-"+o,label:y.templateGroups[o],disabled:!0}),v().forEach(e[o],(function(e){t.push(e)})))})),t}),[K]),[J,Q]=(0,u.useState)(!1),ee=(0,u.useCallback)((()=>{Q(!1),b({type:"page",path:E,context:{queryContext:{page:1}}}),G(!1),k(!1)}),[G,k,b,E]),te=(0,x.useSetGlobalSessionProp)("ready"),oe=(0,u.useCallback)((()=>{z&&(b({type:z.type,slug:z.slug,path:(0,zo.getPathAndQueryString)(z.link),context:{postType:z.type,postId:z.id}}),L(!1),G(!1),k(!1),setTimeout((()=>te(!0)),5e3))}),[z,b,G,k,te]),ne=!P||r&&d,[ie,re]=(0,u.useState)(!1);let ae=(0,g.jsx)(g.Fragment,{});"postType"===e&&"page"===t&&(ae=(0,g.jsxs)(g.Fragment,{children:[O&&(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(h.Modal,{title:(0,m.__)("Add page","kubio"),onRequestClose:()=>{N(!1)},className:"block-editor-block-new-entity-modal",shouldCloseOnEsc:!M,shouldCloseOnClickOutside:!M,isDismissible:!M,children:(0,g.jsxs)("div",{className:"popover__content",children:[(0,g.jsx)(h.__experimentalInputControl,{value:R,onChange:e=>A(e),label:(0,m.__)("Title","kubio"),autoFocus:!0,onKeyPress:o=>{"Enter"===o.key&&U(e,t)}}),(0,g.jsx)(h.__experimentalSpacer,{margin:3}),(0,g.jsx)(h.SelectControl,{value:q,onChange:e=>Y(e),label:(0,m.__)("Template","kubio"),options:Z}),(0,g.jsx)(h.__experimentalSpacer,{margin:6}),(0,g.jsx)(h.Button,{isPrimary:!0,isBusy:M,disabled:M||""===R.trim(),onClick:()=>{f(0,0,null),U(e,t)},className:"add-button",children:(0,m.__)("Add page","kubio")})]})})}),B&&(0,g.jsx)($m,{onComplete:oe,closeModal:()=>D(!1),entityName:R})]}));const se=v().sortBy(w,(e=>"page"!==C||j!==e.id&&T!==e.id?1:0));return(0,g.jsxs)(h.__experimentalNavigationMenu,{menu:`kubio-content-area-${e}-${t}`,title:o,parentMenu:i,hasSearch:n,onSearch:c,search:r,isSearchDebouncing:d||!P,titleAction:(0,g.jsxs)(g.Fragment,{children:["page"===t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(qf,{onNewKubioPage:()=>N(!0),onNewAiPage:()=>re(!0)}),ie&&(0,g.jsx)($f,{setIsModalVisible:re})]}),ae]}),className:X()("kubio-nav-menu-heading",{"kubio-nav-menu-heading--page":"page"===t}),children:[r&&!d&&(0,g.jsx)(sb,{items:se,search:r,disableFilter:!0}),!r&&(0,g.jsxs)(g.Fragment,{children:["posts"===C&&(0,g.jsx)(h.__experimentalNavigationItem,{item:"post-/",title:(0,m.__)("All Posts","kubio"),onClick:()=>Q(!0),children:(0,g.jsx)(h.Button,{className:"components-button css-1g713f0 ejwewyf3",children:(0,g.jsxs)(h.Flex,{align:"center",children:[(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Icon,{icon:Kf,size:18})}),(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)("span",{children:(0,m.__)("All Posts","kubio")})}),J&&(0,g.jsx)($m,{onComplete:ee,closeModal:()=>D(!1),entityName:R})]})})}),null==se?void 0:se.map((e=>(0,g.jsx)(nb,{item:e,entity:t},`${e.type||e.taxonomy}-${e.id}`)))]}),ne&&(0,g.jsx)(h.__experimentalNavigationItem,{title:(0,m.__)("Loading…","kubio"),isText:!0})]})};function cb({onActivateMenu:e,activeMenu:t}){const{page:o}=(0,l.useSelect)((e=>({page:e(y.STORE_KEY).getPage()})),[]),n=(0,u.useMemo)((()=>{var e,t;return[{kind:"postType",entity:"page",title:(0,m.__)("Pages","kubio")},{kind:"postType",entity:"post",title:(0,m.__)("Posts","kubio")},{kind:"taxonomy",entity:"category",title:(0,m.__)("Categories","kubio")},...(null===(e=window)||void 0===e||null===(t=e.kubioEditSiteSettings)||void 0===t?void 0:t.postTypes.filter((e=>"kubio_section"!==e.entity&&"product"!==e.entity)))||[]]}),[]);return(0,g.jsxs)(h.__experimentalNavigation,{activeItem:o&&`content-${o.path}`,activeMenu:t,onActivateMenu:t=>{e(t)},children:[t===ts&&(0,g.jsx)(Vf.Slot,{children:(0,g.jsx)(h.__experimentalNavigationBackButton,{backButtonLabel:(0,m.__)("Dashboard","kubio"),className:"edit-site-navigation-panel__back-to-dashboard",href:"index.php"})}),(0,g.jsx)(h.__experimentalNavigationMenu,{title:(0,m.__)("Site Content","kubio"),children:null==n?void 0:n.map((({kind:e,entity:t,title:o})=>(0,g.jsx)(h.__experimentalNavigationItem,{title:o,navigateToMenu:`kubio-content-area-${e}-${t}`},`${e}-${t}`)))}),null==n?void 0:n.map((e=>(0,J.createElement)(lb,{...e,key:`${e.kind}-${e.entity}`})))]})}function ub({menu:e,title:t,templateParts:o}){return(0,g.jsx)(h.__experimentalNavigationMenu,{menu:e,title:t,parentMenu:os,isEmpty:!o||0===o.length,children:(0,_.map)(o,(e=>(0,g.jsx)(ab,{item:e},`wp_template_part-${e.id}`)))})}function db(){const[e,t]=(0,u.useState)(""),o=(0,u.useCallback)((e=>{t(e)})),{isLoading:n,templateParts:i,templatePartsByArea:r}=(0,l.useSelect)((e=>{const t=e(j.store).getEntityRecords("postType","wp_template_part"),o=t||[],n=(0,_.groupBy)(o.map((e=>({...e,area:e.area||"uncategorized"}))),"area");return{isLoading:null===t,templateParts:o,templatePartsByArea:n}}),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.__experimentalNavigationMenu,{menu:os,title:(0,m.__)("Template Parts","kubio"),parentMenu:ts,hasSearch:!0,onSearch:o,search:e,children:[e&&(0,g.jsx)(sb,{items:i,search:e}),!e&&us.map((({title:e,menu:t})=>(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:t,title:e,hideIfTargetMenuEmpty:!0},`template-parts-navigate-to-${t}`))),!e&&n&&(0,g.jsx)(h.__experimentalNavigationItem,{title:(0,m.__)("Loading…","kubio"),isText:!0})]}),us.map((({area:e,menu:t,title:o})=>(0,g.jsx)(ub,{menu:t,title:o,templateParts:r[e]},`template-parts-menu-${t}`)))]})}function pb(){const{defaultTemplateTypes:e,templates:t,classicThemePrimaryTemplates:o}=(0,l.useSelect)((e=>{const{getSettings:t}=e(Le),o=e("core").getEntityRecords("postType","wp_template");return{defaultTemplateTypes:t().defaultTemplateTypes,classicThemePrimaryTemplates:t().classicThemePrimaryTemplates,templates:o}}),[]),{addTemplate:n}=(0,l.useDispatch)(Le),i=(0,_.map)(t,"slug"),r=(0,_.filter)(e,(e=>(0,_.includes)((0,_.uniq)([...es,...o]),e.slug)&&!(0,_.includes)(i,e.slug)));return r.length?(0,g.jsx)(h.DropdownMenu,{className:"edit-site-navigation-panel__new-template-dropdown",icon:null,label:(0,m.__)("Add Template","kubio"),popoverProps:{noArrow:!1},toggleProps:{children:(0,g.jsx)(h.Button,{isPrimary:!0,icon:$e,iconPosition:"right",className:"kubio-new-page-btn",label:(0,m.__)("New","kubio"),children:(0,m.__)("New","kubio")})},children:({onClose:t})=>(0,g.jsx)(h.NavigableMenu,{className:"edit-site-navigation-panel__new-template-popover",children:(0,g.jsx)(h.MenuGroup,{label:(0,m.__)("Add Template","kubio"),children:(0,_.map)(r,(({title:o,description:i,slug:r})=>(0,g.jsx)(h.MenuItem,{info:i,onClick:()=>{(t=>{const{title:o,description:i}=(0,_.find)(e,{slug:t});n({content:"__KUBIO_REPLACE_WITH_APPROPRIATE_CONTENT__",excerpt:i,slug:t.toString(),status:"publish",title:o,kubio_template_source:"kubio-custom"})})(r),t()},children:o},r)))})})}):null}function hb({menu:e,title:t,templates:o,parentMenu:n}){const i=!o||0===o.length;return!i&&(0,g.jsx)(h.__experimentalNavigationMenu,{menu:e,title:t,parentMenu:n,isEmpty:i,children:(0,_.map)(o,(e=>(0,g.jsx)(ab,{item:e},`wp_template-${e.id}`)))})}const mb=(e,t="custom")=>!!e&&(null==e?void 0:e.filter((({kubio_template_source:e="custom"})=>e===t)));function gb({title:e,templates:t,menu:o,hasAdd:n=!0,parentMenu:i=ns}){const r=(0,u.useMemo)((()=>{const e={},o=mb(t,"kubio"),n=mb(t,"theme"),i=!!t&&(0,_.difference)(t,[...o,...n]);return o&&o.length&&(e.kubio=o),n&&n.length&&(e.theme=n),i&&i.length&&(e.custom=n),e}),[t]),a=Object.keys(r).length<=1;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.__experimentalNavigationMenu,{menu:o,title:e,titleAction:n&&(0,g.jsx)(pb,{}),parentMenu:i,children:[a&&(0,g.jsx)(g.Fragment,{children:(0,_.map)(t,(e=>(0,g.jsx)(ab,{item:e,icon:He.KubioLogo},`wp_template-${e.id}`)))}),!a&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:`${o}--${cs}`,title:(0,m.__)("Kubio templates","kubio"),hideIfTargetMenuEmpty:!0}),(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:`${o}--${ls}`,title:(0,m.__)("Theme templates","kubio"),hideIfTargetMenuEmpty:!0}),(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:`${o}--${ss}`,title:(0,m.__)("Custom templates","kubio"),hideIfTargetMenuEmpty:!0})]})]}),(0,g.jsx)(hb,{menu:`${o}--${cs}`,title:(0,m.__)("Kubio templates","kubio"),templates:r.kubio,parentMenu:o}),(0,g.jsx)(hb,{menu:`${o}--${ls}`,title:(0,m.__)("Theme templates","kubio"),templates:r.theme,parentMenu:o}),(0,g.jsx)(hb,{menu:`${o}--${ss}`,title:(0,m.__)("Custom templates","kubio"),templates:r.custom,parentMenu:o})]})}function fb(){var e,t,o,n,i,r;const[a,c]=(0,u.useState)(""),d=(0,u.useCallback)((e=>{c(e)})),{templates:p}=(0,l.useSelect)((e=>{const{getEntityRecords:t}=e(j.store);return{templates:t("postType","wp_template",{per_page:-1})}}),[]),f=(0,u.useMemo)((()=>(p||[]).reduce(((e,t)=>{let o="general";const n=t.slug;return(0,s.currentTemplateIsPage)(n)&&(o="page"),(0,s.currentTemplateIsPost)(n)&&(o="post"),{...e,[o]:[...e[o]||[],t]}}),{})),[p]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.__experimentalNavigationMenu,{menu:ns,title:(0,m.__)("Templates","kubio"),titleAction:(0,g.jsx)(pb,{}),parentMenu:ts,hasSearch:!0,onSearch:d,search:a,children:[a&&(0,g.jsx)(sb,{items:p,search:a}),!a&&(0,g.jsxs)(g.Fragment,{children:[!(null===(e=f.page)||void 0===e||!e.length)&&(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:rs,title:(0,m.__)("Page templates","kubio"),hideIfTargetMenuEmpty:!0}),!(null===(t=f.post)||void 0===t||!t.length)&&(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:as,title:(0,m.__)("Post templates","kubio"),hideIfTargetMenuEmpty:!0}),!(null===(o=f.general)||void 0===o||!o.length)&&(0,g.jsx)(h.__experimentalNavigationItem,{navigateToMenu:is,title:(0,m.__)("General templates","kubio"),hideIfTargetMenuEmpty:!0})]}),!a&&null===p&&(0,g.jsx)(h.__experimentalNavigationItem,{title:(0,m.__)("Loading…","kubio"),isText:!0})]}),!(null===(n=f.page)||void 0===n||!n.length)&&(0,g.jsx)(gb,{menu:rs,title:(0,m.__)("Page templates","kubio"),templates:f.page,hasAdd:!1,category:"page"}),!(null===(i=f.post)||void 0===i||!i.length)&&(0,g.jsx)(gb,{menu:as,title:(0,m.__)("Post templates","kubio"),templates:f.post,category:"post",hasAdd:!1}),!(null===(r=f.general)||void 0===r||!r.length)&&(0,g.jsx)(gb,{menu:is,title:(0,m.__)("General templates","kubio"),templates:f.general,hasAdd:!1,category:"general"})]})}function bb({activeMenu:e,onActivateMenu:t}){const{postId:o,postType:n}=(0,l.useSelect)((e=>{const{getEditedPostType:t,getEditedPostId:o}=e(Le);return{postId:o(),postType:t()}}),[]);return(0,g.jsx)(h.__experimentalNavigation,{activeItem:`${n}-${o}`,activeMenu:e,onActivateMenu:e=>{t(e)},children:(0,g.jsxs)(h.__experimentalNavigationMenu,{title:(0,m.__)("Advanced","kubio"),children:[(0,g.jsx)(h.__experimentalNavigationItem,{title:(0,m.__)("Templates","kubio"),navigateToMenu:ns}),(0,g.jsx)(h.__experimentalNavigationItem,{title:(0,m.__)("Template Parts","kubio"),navigateToMenu:os}),(0,g.jsx)(fb,{activeMenu:e}),(0,g.jsx)(db,{})]})})}const _b=({isOpen:e})=>{const[t,o]=(0,u.useState)(ts),[n,i]=(0,u.useState)(ts),{siteTitle:r,openedMenu:a}=(0,l.useSelect)((e=>{const{getEntityRecord:t}=e("core");return{siteTitle:(t("root","__unstableBase",void 0)||{}).name,openedMenu:e(Le).getNavigationMenu()}}),[]),s=(0,u.useRef)();(0,u.useEffect)((()=>{e&&s.current.focus()}),[n]);const c=(0,p.usePrevious)(e);(0,u.useEffect)((()=>{a&&e&&!c&&o(a)}),[t,e,a]);const{setIsNavigationPanelOpened:d}=(0,l.useDispatch)(Le);return(0,g.jsx)("div",{className:X()("edit-site-navigation-panel",{"is-open":e}),ref:s,tabIndex:"-1",onKeyDown:e=>{e.keyCode===Af.ESCAPE&&(e.stopPropagation(),d(!1))},children:(0,g.jsxs)("div",{className:"edit-site-navigation-panel__inner",children:[(0,g.jsx)("div",{className:"edit-site-navigation-panel__site-title-container",children:(0,g.jsxs)(h.Flex,{children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)("div",{className:"edit-site-navigation-panel__site-title",children:r})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Tooltip,{text:(0,m.__)("Close panel","kubio"),children:(0,g.jsx)(h.Button,{className:"kubio-edit-site-navigation-panel__close-button",icon:Ve,onClick:()=>d(!1)})})})]})}),(0,g.jsxs)("div",{className:"edit-site-navigation-panel__scroll-container",children:[n===ts&&(0,g.jsx)(cb,{onActivateMenu:o,activeMenu:t}),t===ts&&(0,g.jsx)(bb,{activeMenu:n,onActivateMenu:i})]})]})})},vb=function({isOpen:e}){const{isActive:t}=(0,l.useSelect)((e=>{const{isFeatureActive:t}=e(y.STORE_KEY);return{isActive:t("fullscreenMode")}}),[]),{setIsNavigationPanelOpened:o}=(0,l.useDispatch)(y.STORE_KEY);if(!t)return null;const n=(0,g.jsx)(h.Icon,{size:"36px",icon:He.HamburgerMenu});return(0,g.jsx)("div",{className:"edit-site-navigation-toggle"+(e?" is-open":""),children:(0,g.jsx)(h.Button,{className:"edit-site-navigation-toggle__button has-icon",label:(0,m.__)("Toggle navigation","kubio"),onClick:()=>o(!e),showTooltip:!0,children:n})})},{Fill:yb,Slot:kb}=(0,h.createSlotFill)("EditSiteNavigationPanelPreview");function xb(){const e=(0,l.useSelect)((e=>e(Le).isNavigationOpened()));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(vb,{isOpen:e}),e&&(0,g.jsx)(_b,{isOpen:e}),(0,g.jsx)(kb,{})]})}const Sb=()=>{const e=(0,l.useSelect)((e=>e(b.store).getNotices().filter((e=>"snackbar"===e.type)).map((e=>({...e,className:`is-${e.status}`})))),[]),{removeNotice:t}=(0,l.useDispatch)(b.store);return(0,u.createPortal)((0,g.jsx)(h.SnackbarList,{className:"components-editor-notices__snackbar edit-site-notices",notices:e,onRemove:t}),document.body)},wb=(0,We.getNamesOfBlocks)(),Cb=[wb.SECTION,wb.HERO,wb.NAVIGATION].map((e=>`[data-type="${e}"]`)).join(","),Ib=({children:e})=>{const[t,o]=(0,u.useState)(null),n=(0,x.useBlocksOwnerDocument)(),i=(0,p.useThrottle)((0,u.useCallback)((e=>{var t,n;const i=null==e||null===(t=e.target)||void 0===t||null===(n=t.closest)||void 0===n?void 0:n.call(t,Cb),r=(null==i?void 0:i.getAttribute("data-block"))||null;o(r)}),[]),300);(0,u.useEffect)((()=>{if(n)return n.addEventListener("mousemove",i),()=>n.removeEventListener("mousemove",i)}),[n]);const r=(0,u.useMemo)((()=>({clientId:t})),[t]);return(0,g.jsx)(s.HoveredSectionContext.Provider,{value:r,children:e})};function jb(){const{setIsListViewOpened:e}=(0,l.useDispatch)(y.STORE_KEY),{clearSelectedBlock:t,selectBlock:o}=(0,l.useDispatch)(I.store),n=(0,p.useFocusOnMount)("firstElement"),i=(0,p.useFocusReturn)(),r=`edit-site-editor__list-view-panel-label-${(0,p.useInstanceId)(jb)}`;return(0,g.jsxs)("div",{"aria-labelledby":r,className:"edit-site-editor__list-view-panel",onKeyDown:function(t){t.keyCode!==Af.ESCAPE||t.defaultPrevented||e(!1)},children:[(0,g.jsxs)("div",{className:"edit-site-editor__list-view-panel-header",children:[(0,g.jsx)("strong",{id:r,children:(0,m.__)("List view","kubio")}),(0,g.jsx)(h.Button,{icon:Ke,label:(0,m.__)("Close list view sidebar","kubio"),onClick:()=>e(!1)})]}),(0,g.jsx)("div",{className:"edit-site-editor__list-view-panel-content",ref:(0,p.useMergeRefs)([i,n]),children:(0,g.jsx)(I.__experimentalListView,{onSelect:async function(e){await t(),o(e,-1)},showNestedBlocks:!0,__experimentalFeatures:!0,__experimentalPersistentListViewFeatures:!0})})]})}function Tb(){const{setTemplate:e,setTemplatePart:t,showHomepage:o,setPage:n}=(0,l.useDispatch)(y.STORE_KEY),{siteUrl:i,state:r}=window.kubioEditSiteSettings;(0,u.useEffect)((()=>{var a,s,l,c;const u=window.location.href;let p=(0,zo.getQueryArg)(u,"postId")||(null==r||null===(a=r.entity)||void 0===a||null===(s=a.context)||void 0===s?void 0:s.postId);p=isNaN(parseInt(p))?p:parseInt(p);const h=(0,zo.getQueryArg)(u,"pageURL");if(!p&&!h)return void o();const m=(0,zo.getQueryArg)(u,"postType")||(null==r||null===(l=r.entity)||void 0===l||null===(c=l.context)||void 0===c?void 0:c.postType);if(h)n({path:h});else if("wp_template"===m)e(p);else if("wp_template_part"===m)t(p);else if(m){var g,f,b;const e=(null==r||null===(g=r.entity)||void 0===g||null===(f=g.context)||void 0===f?void 0:f.postId)===p?null==r||null===(b=r.entity)||void 0===b?void 0:b.path:`${i}?p=${p}`;n({context:{postType:m,postId:p},path:e})}else o();(0,d.doAction)("kubio.afterEntitySet")}),[]);const a=function(){const e=(0,u.useRef)(),t=(0,l.useSelect)((e=>{var t,o;const{getEditedPostType:n,getEditedPostId:i,getPage:r}=e(y.STORE_KEY),a=r();let s=i(),l=n();return null!=a&&null!==(t=a.context)&&void 0!==t&&t.postId&&null!=a&&null!==(o=a.context)&&void 0!==o&&o.postType&&(s=a.context.postId,l=a.context.postType),s&&l?{postId:s,postType:l,page:a}:{page:a}}));return qo()(e.current,t)||(e.current=t),e.current}();return(0,u.useEffect)((()=>{const e=(0,zo.removeQueryArgs)(window.location.href,"postType","postId","pageURL"),{page:t,...o}=a||{};if(v().isEmpty(null==t?void 0:t.context))return;const n=a?(0,zo.addQueryArgs)(e,o):e;window.history.replaceState({},"",n)}),[a]),null}const Pb=(0,u.createContext)({}),Eb=[(0,We.getNamesOfBlocks)().HEADER,(0,We.getNamesOfBlocks)().FOOTER,(0,We.getNamesOfBlocks)().SIDEBAR,"core/template-part","core/post-content"],Rb=()=>(0,u.useContext)(Pb),Ab=({children:e,blockContext:t,templateId:o,templateType:n,page:i})=>{const r=(0,u.useRef)([]),[a,s]=(0,u.useState)(!1),c=(0,x.useSetGlobalSessionProp)("ready"),h=(0,x.useGetGlobalSessionProp)("ready",!1),m=(0,u.useRef)(h),{entitiesFinished:f,postLoaded:b,isEmptyPost:v,isPost:y,postEntity:k,isChangingPage:S}=(0,l.useSelect)((e=>{const{getEditedEntityRecord:t,hasFinishedResolution:i}=e("core"),{getCurrentPostType:a,getCurrentPostId:s,isChangingPage:l}=e(Bi.Ls),c=!(!h&&o&&n)||r.current.reduce(((e,{theme:o,slug:n,content:i})=>{let r=!0;var a;return i||(r=!o||!n||!(0,_.isUndefined)(null===(a=t("postType","wp_template_part",`${o}//${n}`))||void 0===a?void 0:a.content)),e&&r}),!0);let u=!0;const d=a(),p=s();let m,g=!1,f=!1;var b;return d&&p&&(["wp_template","wp_template_part"].includes(d)||(g=!0,f=t("postType",d,p),m=null===(b=f)||void 0===b?void 0:b.content,u=!(0,_.isUndefined)(m)&&i("getEditedEntityRecord",["postType",d,p]))),{entitiesFinished:c||u,postLoaded:u,postEntity:f,isEmptyPost:d&&p&&!(0,_.isUndefined)(m)&&(0,_.isString)(m)&&!(m.includes("\x3c!-- wp:")||m.includes("\x3c!--wp:")),isPost:g,isChangingPage:l()}}),[r.current.length,h,t,o,o]),w=(0,p.useDebounce)((0,u.useCallback)((()=>{s(!0)}),[]),200),C=(0,u.useCallback)((e=>{if(c(e),e){if(c(e),top.kubioStartTime){const e=Math.floor(performance.now()-top.kubioStartTime)/1e3;console.log("Kubio ready in: "+e+" seconds"),top.kubioStartTime=null}(0,d.doAction)("kubio.editorIsReady")}}),[c]),I=(0,u.useCallback)((e=>{m.current!==e&&e&&(0,ua.updateAllStyleManagers)((()=>{C(e)}))}),[C]),j=(0,p.useDebounce)(I,500),T=(0,p.useDebounce)((0,u.useCallback)((()=>{I(!0),s(!0)}),[]),2e3),P=(0,p.useDebounce)((0,u.useCallback)((()=>{I(!0),s(!0)}),[]),1e4);(0,u.useEffect)((()=>{(0,_.debounce)(I,15e3)}),[]);const{editEntityRecord:E}=(0,l.useDispatch)("core");(0,u.useEffect)((()=>{const e=k.content;y&&e&&"function"!=typeof e&&!k.blocks&&E("postType",k.type,k.id,{blocks:(0,lt.parse)(e)},{undoIgnore:!0})}),[y,k,v,E]);const R=(0,p.usePrevious)(h);(0,u.useEffect)((()=>{m.current=h,R&&!h&&(s(!1),r.current=[])}),[h,R]),(0,u.useLayoutEffect)((()=>{if(!S&&!h)if(f){if(P.cancel(),T.cancel(),j.cancel(),y&&b&&v)return void T(!0);if(y)return void j(a);j(!0)}else T.cancel(),P(!0)}),[b,y,v,f,a,h,i,o,n,P,T,j,S]);const A=(0,u.useCallback)(((e,{theme:t,slug:o})=>{Eb.includes(e)&&(t&&o?(0,_.find)(r.current,{theme:t,slug:o})||r.current.push({theme:t,slug:o}):"core/post-content"===e&&r.current.push({content:!0})),w()}),[w]),O=(0,u.useMemo)((()=>({isReady:h,markAsLoaded:A})),[h,A]);return(0,g.jsx)(Pb.Provider,{value:O,children:e})},Ob=(0,p.createHigherOrderComponent)((e=>t=>{const{markAsLoaded:o,isReady:n}=Rb();return(0,u.useLayoutEffect)((()=>{n||o(t.name,t.attributes)}),[n,o,t.attributes,t.name]),(0,g.jsx)(e,{...t})}),"BlockListEditorStateReady");function Nb(){return function(){const[e,t]=(0,C.useGlobalStylesOutput)(),{getSettings:o}=(0,l.useSelect)(Le),{updateSettings:n}=(0,l.useDispatch)(Le);(0,u.useEffect)((()=>{var i;if(v().isEmpty(e)||v().isEmpty(t))return;const r=o(),a=(null==r||null===(i=r.styles)||void 0===i?void 0:i.filter((e=>!e.isGlobalStyles||"base-layout"===e.__unstableType)))||[],s=(0,T.mergeNoArrays)({},r,{styles:[...a,...e],__experimentalFeatures:t});n(s)}),[e,t])}(),null}(0,d.addFilter)("editor.BlockListBlock","kubio/style/BlockListEditorStateReady",(0,p.compose)([Ob]),1);const Bb=({className:e,children:t,...o})=>{const n=(0,u.useRef)();return(({ref:e})=>{(0,u.useEffect)((()=>{if(!e.current)return;const t=new ResizeObserver((t=>{for(const s of t){var o,n,i,r;null===(o=e.current)||void 0===o||null===(n=o.classList)||void 0===n||null===(i=(r=n).toggle)||void 0===i||i.call(r,"kubio-has-scrollbar",!!(a=e.current)&&a.scrollHeight>a.clientHeight)}var a}));return t.observe(e.current),()=>{t.disconnect()}}),[e.current])})({ref:n}),(0,g.jsx)("div",{ref:n,className:X()("kubio-editor-ai-post-generate-interface__wizard__list",e),...o,children:t})},Db={BG_IMAGE:"bgImage",BG_SLIDESHOW:"bgSlideshow",COLUMN_BG_IMG:"columnBgImage",IMAGE_BLOCK:"imageBlock"},Mb=e=>()=>{const{activeImage:t,onChangeImage:o,initialImg:n,restOfImages:i,isMultiChoice:r}=Lb({type:e}),a=e===Db.BG_SLIDESHOW,{onWizardDataChange:s}=Xb();return(0,u.useEffect)((()=>{s({currentSelectedImage:t})}),[]),(0,u.useEffect)((()=>{s(r?{currentSelectedImage:v().sortBy(t,(e=>v().indexOf(i,e)))}:{currentSelectedImage:t})}),[t]),(0,g.jsxs)(Bb,{className:"kubio-editor-ai-post-generate-interface__wizard__image-step",children:[(0,g.jsxs)("h2",{children:[!a&&(0,m.__)("Hero Image","kubio"),a&&(0,m.__)("Hero Slideshow","kubio")]}),(0,g.jsxs)("p",{children:[!a&&(0,m.__)("Are you happy with the hero image selected by Kubio AI?","kubio"),a&&(0,m.__)("Are you happy with the hero slideshow images selected by Kubio AI?","kubio")]}),n&&(0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__preset-list__first-item",children:(0,g.jsx)(zr,{scrollIntoView:!1,children:(0,g.jsx)(Fb,{src:n,activeImage:t,setActiveImage:o})})}),(0,g.jsx)("p",{className:"kubio-editor-ai-post-generate-interface__wizard__list__after-first",children:(0,m.__)("Below are a few alternatives. You can also change this later.","kubio")}),(0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__image-step__image-list",children:(0,g.jsx)(zr,{scrollIntoView:!1,children:i.map(((e,n)=>(0,g.jsx)(Fb,{src:e,activeImage:t,setActiveImage:o},n)))})})]})},Lb=({type:e}={})=>{const t=v().get((0,x.useGetGlobalSessionProp)("aiFrontPageHeroImageVariantsData",{}),e,{}),{currentValue:o,variants:n,clientId:i}=t,r=Array.isArray(o);let a,s;r?(s=o.concat(n),a=null):(a=o,s=n);const{wizardContextData:l,onWizardDataChange:c}=Xb(),d=`currentHeroImage${e}`,p=v().get(l,d,o),[h,m]=(0,u.useState)(p),{getBlockWithImageDataHelper:g}=zb(),f=(0,u.useRef)();(0,u.useEffect)((()=>{f.current=void 0}),[e]);const b=(t,o={})=>{const{updateToLocalSlideshowImage:n,slideshowIndex:a}=v().merge({updateToLocalSlideshowImage:!1,slideshowIndex:0},o);let l=[];n||(l=(e=>{var t;if(!r)return m(e),null==c||c({[d]:e}),e;let o;if(null==h||null===(t=h.includes)||void 0===t?void 0:t.call(h,e)){var n;o=null==h||null===(n=h.filter)||void 0===n?void 0:n.call(h,(t=>t!==e)),v().isEmpty(o)&&(o=h),o=v().sortBy(o,(e=>v().indexOf(s,e)))}else{var i;o=null==h||null===(i=h.concat)||void 0===i?void 0:i.call(h,[e]),o=v().sortBy(o,(e=>v().indexOf(s,e)));const t=v().indexOf(o,e);if(t>0&&t<o.length-1){const n=o.slice(0,t),i=o.slice(t+1);o=[e].concat(i,n)}else if(0===t){const n=o.slice(t+1);o=[e].concat(n)}else if(t===o.length-1){const n=o.slice(0,t);o=[e].concat(n)}}Array.isArray(o)||(o=[]),o=v().uniq(o);const a=v().sortBy(o,(e=>v().indexOf(s,e)));return null==c||c({[d]:a}),m(o),o})(t)),f.current||(f.current=g(i));const u=f.current;if(u)switch(e){case Db.BG_IMAGE:case Db.COLUMN_BG_IMG:u.setStyle("background.image.0.source.url",t,{descendants:"outer",media:"desktop"});break;case Db.BG_SLIDESHOW:if(n)u.setStyle(`background.slideshow.slides.${a}.url`,t,{descendants:"outer",media:"desktop",mergeData:!1});else if(Array.isArray(l)){const e=l.map(((e,t)=>({id:t+1,url:e,icon:!1})));u.setStyle("background.slideshow.slides",e,{descendants:"outer",media:"desktop",mergeData:!1})}break;case Db.IMAGE_BLOCK:u.setAttribute("url",t)}};return{activeImage:h,onChangeImage:b,initialImg:a,restOfImages:s,saveImageOnNext:async(e,t="",o)=>{if(""===t)return!1;try{if(e.has(t))b(e.get(t),o);else{const n=await(0,S.aiSearchedImageSave)({selectedImage:t});""!==n&&(b(n.url,o),e.set(t,n.url))}}catch(e){console.log(e)}},isMultiChoice:r}},zb=()=>{const e=(0,s.useColibriDataHooks)();return{getBlockWithImageDataHelper:t=>(0,s.getColibriData)({clientId:t,autoSave:!0,loadColibriData:!0},e)}},Fb=({src:e,activeImage:t,setActiveImage:o})=>{const n=Array.isArray(t)?t.includes(e):e===t;return(0,g.jsxs)(zr.Item,{isActive:n,onClick:()=>o(e),children:[(0,g.jsx)("img",{src:e,alt:""}),n&&(0,g.jsx)("div",{className:"kubio-style-preset-list__check",children:(0,g.jsx)(h.Icon,{icon:Zi})})]})},Gb=[{value:Db.BG_IMAGE,Component:Mb(Db.BG_IMAGE),nextButtonLabel:(0,m.__)("Continue","kubio")},{value:Db.BG_SLIDESHOW,Component:Mb(Db.BG_SLIDESHOW),nextButtonLabel:(0,m.__)("Continue","kubio")},{value:Db.COLUMN_BG_IMG,Component:Mb(Db.COLUMN_BG_IMG),nextButtonLabel:(0,m.__)("Continue","kubio")},{value:Db.IMAGE_BLOCK,Component:Mb(Db.IMAGE_BLOCK),nextButtonLabel:(0,m.__)("Continue","kubio")},{value:"colorScheme",Component:()=>{const{activePaletteWithData:e,restOfPalettes:t,onHandleClick:o,activePaletteValue:n}=(()=>{var e;const{mergedPalettes:t,onHandleClick:o,activePaletteValue:n}=$r(),{wizardContextData:i,onWizardDataChange:r}=Xb(),[a]=(0,S.useAIData)(),s=(null==a||null===(e=a.siteContext)||void 0===e?void 0:e.siteMood)||"neutral",{activePaletteWithData:l,restOfPalettes:c}=(0,u.useMemo)((()=>{let{activePaletteWithData:e=null,restOfPalettes:o=[]}=i;if(e)return{activePaletteWithData:e,restOfPalettes:o};t.forEach((t=>{(0,T.getColorPalettesAreEqual)(t.colors,n)?e={...t,mood:s,label:(0,m.__)("Set 1","kubio")}:o.push(t)})),o=o.filter((e=>e.mood===s)).map(((e,t)=>({...e,label:(0,m.sprintf)(// translators: %s: number of the preset, Set refers to the color scheme preset
// translators: %s: number of the preset, Set refers to the color scheme preset
(0,m.__)("Set %s","kubio"),t+2)})));const a={activePaletteWithData:e,restOfPalettes:o};return r(a),a}),[n,t,s,r,i]);return{activePaletteWithData:l,restOfPalettes:c,onHandleClick:o,activePaletteValue:n}})();return(0,g.jsxs)(Bb,{children:[(0,g.jsx)("h2",{children:(0,m.__)("Color Scheme","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("Are you happy with the color scheme selected by Kubio AI?","kubio")}),(0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__preset-list__first-item",children:(0,g.jsx)(zr,{scrollIntoView:!1,children:(0,g.jsx)(qr,{palette:e,index:0,onHandleClick:o,activePaletteValue:n})})}),(0,g.jsx)("p",{className:"kubio-editor-ai-post-generate-interface__wizard__list__after-first",children:(0,m.__)("Below are a few alternatives. You can also change this later.","kubio")}),(0,g.jsx)(zr,{scrollIntoView:!1,children:t.map(((e,t)=>(0,g.jsx)(qr,{palette:e,index:t+1,onHandleClick:o,activePaletteValue:n},t)))})]})},nextButtonLabel:(0,m.__)("Continue","kubio")},{value:"typography",Component:()=>{const{activePresetWithData:e,restOfPresets:t,onSelectPreset:o,bodyTypographyHolders:n}=(()=>{const{mergedPresets:e,bodyTypographyHolders:t,onSelectPreset:o}=Hr(),{wizardContextData:n,onWizardDataChange:i}=Xb(),{activePresetWithData:r,restOfPresets:a}=(0,u.useMemo)((()=>{let{activePresetWithData:o=null,restOfPresets:r=[]}=n;if(o)return{activePresetWithData:o,restOfPresets:r};const a=v().get(t,"h1.family"),s=v().get(t,"p.family");e.forEach((e=>{const t=e.h1.family,n=e.p.family;a===t&&s===n?o=e:r.push(e)}));const l={activePresetWithData:o,restOfPresets:r};return i(l),l}),[]);return{activePresetWithData:r,restOfPresets:a,onSelectPreset:o,bodyTypographyHolders:t}})();return(0,g.jsxs)(Bb,{children:[(0,g.jsx)("h2",{children:(0,m.__)("Typography","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("Are you happy with the family fonts selected by Kubio AI?","kubio")}),(0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__preset-list__first-item",children:(0,g.jsx)(zr,{scrollIntoView:!1,children:(0,g.jsx)(Ur,{preset:e,index:0,bodyTypographyHolders:n,onSelect:o})})}),(0,g.jsx)("p",{className:"kubio-editor-ai-post-generate-interface__wizard__list__after-first",children:(0,m.__)("Below are a few alternatives. You can also change this later.","kubio")}),(0,g.jsx)(zr,{scrollIntoView:!1,children:t.map(((e,t)=>(0,g.jsx)(Ur,{preset:e,index:t+1,bodyTypographyHolders:n,onSelect:o},t)))})]})},nextButtonLabel:(0,m.__)("Finish","kubio")}],Hb=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),Ub=(0,u.createContext)({}),Wb=(0,h.createSlotFill)("BlackWizardSidebar"),Vb=({children:e})=>{const[t,o]=(0,u.useState)(!1),[n,i]=(0,u.useState)(!1),[r,a]=(0,u.useState)(!0),s=(0,u.useCallback)((e=>{o(e),e||a(!0)}),[]),l=(0,u.useMemo)((()=>{var e,o,n,i;return t&&(null===(e=document.querySelector(".kubio-iframe"))||void 0===e||null===(o=e.contentDocument)||void 0===o||null===(n=o.body)||void 0===n||null===(i=n.querySelector)||void 0===i?void 0:i.call(n,".block-editor-writing-flow > .edit-site-block-editor__block-list"))}),[t]),c=(0,u.useMemo)((()=>({showBlackWizard:t,setShowBlackWizard:s,overlayClicked:n,setOverlayClicked:i,showSidebar:r,setShowSidebar:a})),[t,s,n,i,r,a]);return(0,g.jsx)(Ub.Provider,{value:c,children:(0,g.jsxs)("div",{className:X()("kubio-editor-ai-post-generate-interface",{"kubio-editor-ai-post-generate-interface--show-wizard":t&&r,"kubio-editor-ai-post-generate-interface--hide-sidebar":!r}),children:[(0,g.jsx)(Kb,{showBlackWizard:t}),(0,g.jsxs)("div",{className:"kubio-editor-ai-post-generate-interface__content position-relative",children:[e,t&&l&&(0,u.createPortal)((0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__content__overlay",onClick:()=>i(!0)}),l)]})]})})},Kb=({showBlackWizard:e})=>(0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__sidebar",children:e&&(0,g.jsx)(Wb.Slot,{})}),$b=()=>(0,u.useContext)(Ub),qb=({footerRef:e})=>{const{setOverlayClicked:t}=$b();return(0,g.jsxs)(h.Popover,{anchorRef:e,className:"kubio-options-popover kubio-editor-ai-post-generate-interface__wizard__overlay-popup",position:"top",offset:10,animate:!0,noArrow:!0,onClose:()=>{t(!1)},children:[(0,g.jsx)(h.Button,{icon:Ve,onClick:()=>t(!1)}),(0,g.jsx)("img",{src:(0,T.staticAssetURL)("ai-assets/info-icon.svg")}),(0,g.jsx)("h4",{children:(0,m.__)("You can edit the content of the website after you finish the setup.","kubio")})]})},Yb=(0,u.createContext)({}),Zb=({onFinish:e,overlayClicked:t})=>{const[o,n]=(0,u.useState)(0),[i,r]=(0,u.useState)({}),[a,s]=(0,u.useState)(new Map),c=(0,x.useGetGlobalSessionProp)("aiFrontPageHeroImageVariantsData",null),{clearSelectedBlock:d}=(0,l.useDispatch)("core/block-editor"),{openSidebar:p,setIsNavigationPanelOpened:f}=(0,l.useDispatch)("kubio/edit-site")||{};(0,u.useEffect)((()=>{d().then((()=>{null==p||p("document")})),null==f||f(!1)}),[d,p,f]);const b=(0,u.useRef)(),_=(0,u.useCallback)((e=>{const t=(0,T.mergeNoArrays)({},i,e);r(t)}),[i]),y=Object.values(Db),k=(0,u.useMemo)((()=>Gb.filter((e=>!y.includes(e.value)||!v().isEmpty(v().get(c,e.value))))),[c]),S=k[o],{nextButtonLabel:w,Component:C}=S,{saveImageOnNext:I}=Lb({type:S.value}),j=(0,m.sprintf)(// translators: %1$s is the current step index, %2$s is the total number of steps
// translators: %1$s is the current step index, %2$s is the total number of steps
(0,m.__)("Step %1$s of %2$s","kubio"),o+1,k.length),P=(0,u.useMemo)((()=>({wizardContextData:i,onWizardDataChange:_})),[i,_]);return(0,g.jsx)(Wb.Fill,{children:(0,g.jsxs)("div",{className:"kubio-editor-ai-post-generate-interface__wizard",children:[(0,g.jsxs)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__header",children:[(0,g.jsxs)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__header__container",children:[(0,g.jsx)(Ue,{className:"kubio-ai-logo-animated kubio-ai-logo-colored",icon:He.KubioAI}),(0,g.jsx)("span",{children:(0,m.__)("Finishing Touches","kubio")})]}),(0,g.jsx)("p",{className:"kubio-editor-ai-post-generate-interface__wizard__header__current-step-header",children:j})]}),(0,g.jsx)("div",{className:"kubio-editor-ai-post-generate-interface__wizard__content",children:(0,g.jsx)(Yb.Provider,{value:P,children:(0,g.jsx)(C,{})})}),(0,g.jsxs)("div",{ref:b,className:"kubio-editor-ai-post-generate-interface__wizard__footer",children:[(0,g.jsx)(h.Button,{icon:Hb,onClick:()=>{0!==o&&n(o-1)},disabled:0===o}),(0,g.jsx)(h.Button,{onClick:()=>{if(!v().isEmpty(c)&&y.includes(S.value)){let e=null==i?void 0:i.currentSelectedImage;Array.isArray(e)||(e=[e]),e.forEach(((e,t)=>{let o;S.value===Db.BG_SLIDESHOW&&(o={updateToLocalSlideshowImage:!0,slideshowIndex:t}),I(a,e,o)}))}o===k.length-1?(n(0),null==e||e()):n(o+1)},className:"kubio-ai-button",children:w}),t&&(0,g.jsx)(qb,{footerRef:b})]})]})})},Xb=()=>(0,u.useContext)(Yb),Jb=()=>{const{showBlackWizard:e,setShowBlackWizard:t,overlayClicked:o,setOverlayClicked:n}=$b(),i=(0,x.useGetGlobalSessionProp)("showAiPostGenerateInterface",!1),r=(0,x.useSetGlobalSessionProp)("showAiPostGenerateInterface");return(0,u.useEffect)((()=>{i&&!e&&t(!0)}),[i]),i?(0,g.jsx)(Zb,{onFinish:()=>{r(!1),t(!1)},overlayClicked:o,setOverlayClicked:n}):(0,g.jsx)(g.Fragment,{})},Qb=({updateLocalAIDataPath:e,getSiteContextValue:t,validationErrors:o,getLocalAIDataInRealTime:n})=>{const[i,r]=(0,u.useState)(t("industry",null));(({getSiteContextValue:e,updateLocalAIDataPath:t})=>{const o=e("language",null),n=(0,u.useMemo)((()=>v().map((0,S.getContentLanguages)(),((e,t)=>({label:e,value:t})))),[]);(0,u.useEffect)((()=>{if(!o){const e=(0,T.getBackendData)("adminLanguage");let o=n.find((t=>t.value===e))?e:"en_US";switch(o.split("_")[0]){case"en":o="en_US";break;case"es":o="es_ES";break;case"fr":o="fr_FR";break;case"pt":o="pt_BR";break;case"zh":o="zh_CN"}t("siteContext.language",o)}}),[])})({getSiteContextValue:t,updateLocalAIDataPath:e}),(({getSiteContextValue:e,updateLocalAIDataPath:t})=>{const o=e("structure_type",null);(0,u.useEffect)((()=>{const e=[null===o?["siteContext.structure_type","multi-page"]:null].filter(Boolean);e.length&&t(e)}),[])})({getSiteContextValue:t,updateLocalAIDataPath:e});const a=null==o?void 0:o.industry;return(0,g.jsxs)(_l,{className:"kubio-black-wizard-onboarding__industry",error:a,children:[(0,g.jsx)(_l.Label,{children:(0,m.__)("3. What is your website about?","kubio")}),(0,g.jsx)(S.IndustrySuggestionsControl,{value:i,onChange:t=>{r(t),e([["siteContext.industry",t]])},menuClassName:"kubio-black-wizard-onboarding__industry__menu",dropdownOnTheRight:!0}),a&&(0,g.jsx)(_l.Error,{children:a})]})},e_=window.wp.mediaUtils,t_=({...e})=>{const[t,o]=(0,u.useState)(!1);return(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__logo__container",children:[(0,g.jsx)("a",{className:X()("kubio-black-wizard-onboarding__logo__toggler",{"kubio-black-wizard-onboarding__logo__toggler--active":t}),onClick:()=>o(!t),children:(0,m.__)("Add logo","kubio")}),(0,g.jsx)(o_,{...e,showLogo:t})]})},o_=({updateLocalAIDataPath:e,getSiteContextValue:t,showLogo:o})=>{const n={value:t("website_logo"),onChange:t=>{e([["siteContext.website_logo",t]])}},[i,r]=(0,u.useState)(null),[a,s]=(0,u.useState)(!1),[l,c]=(0,u.useState)(null),d=(0,u.useMemo)((()=>{let e=null;return i?e=i.url:n.value&&(e=n.value.url),e}),[i,n.value]),p=(0,u.useMemo)((()=>{let e=null;return i?e=i.url:n.value&&(e=n.value.url),e?e.split("/").pop():e}),[i,n.value]),f=(e,t)=>{if(null==f||!f.calledOnce)return void(f.calledOnce=!0);r(e[0]);const o={id:e[0].id,url:e[0].url};e[0].id,n.onChange(o),t.value="",s(!1)};return(0,g.jsx)(_l,{children:(0,g.jsxs)("div",{className:X()("kubio-black-wizard-onboarding__logo",{"kubio-black-wizard-onboarding__logo--visible":o,"kubio-black-wizard-onboarding__logo--hidden":!o}),children:[(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__logo__control",children:[(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__logo__button",children:(0,g.jsx)(h.FormFileUpload,{accept:"image/*",onChange:async e=>{s(!0),await(0,e_.uploadMedia)({allowedTypes:["image"],filesList:e.currentTarget.files,onFileChange:t=>f(t,e.target),onError:e=>{"MIME_TYPE_NOT_SUPPORTED"===e.code?c("Sorry, this file type is not supported."):c("Something went wrong. Please, try again."),c(e.message),s(!1)}})},disabled:a,children:(0,m.__)("Choose File","kubio")})}),a&&(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__logo__loader",children:(0,g.jsx)(h.Spinner,{})}),(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__logo__text",children:p}),(i||n.value)&&(0,g.jsx)(h.Icon,{className:"kubio-black-wizard-onboarding__logo__remove",size:17,icon:"trash",onClick:()=>{r(null),n.onChange(null)}}),d&&(0,g.jsx)("img",{src:d,alt:"logo",className:"kubio-black-wizard-onboarding__logo__image"})]}),!a&&l&&(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__logo__errors",children:l})]})})},n_=({localAIDataRef:e,getLocalAIDataInRealTime:t,updateLocalAIDataPath:o,getSiteContextValue:n,validationErrors:i})=>{const[r,a]=(0,u.useState)(n("business_name",null)),[,s]=(0,j.useEntityProp)("root","site","title"),l=null==i?void 0:i.businessName;return(0,g.jsxs)(_l,{error:l,children:[(0,g.jsx)(_l.Label,{children:(0,m.__)("2. What is your website name?","kubio")}),(0,g.jsx)(ut.InputControl,{value:r,onChange:e=>{a(e),o([["siteContext.business_name",e]]),s(e)}}),l&&(0,g.jsx)(_l.Error,{children:l}),(0,g.jsx)(t_,{updateLocalAIDataPath:o,localAIDataRef:e,getLocalAIDataInRealTime:t,getSiteContextValue:n})]})},i_=({updateLocalAIDataPath:e,localAIDataRef:t,getLocalAIDataInRealTime:o,getSiteContextValue:n,validationErrors:i})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(_l,{children:[(0,g.jsx)(_l.Label,{children:(0,m.__)("1. Your Favorite Colors and Fonts","kubio")}),(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__colors-fonts-group",children:[(0,g.jsx)(Il,{}),(0,g.jsx)(kl,{})]})]}),(0,g.jsx)(n_,{updateLocalAIDataPath:e,localAIDataRef:t,getLocalAIDataInRealTime:o,getSiteContextValue:n,validationErrors:i}),(0,g.jsx)(Qb,{updateLocalAIDataPath:e,localAIDataRef:t,getLocalAIDataInRealTime:o,getSiteContextValue:n,validationErrors:i})]}),r_=(0,T.getBackendData)("autoStartBlackWizardOnboarding");let a_=!1;const s_=({onFinish:e,overlayClicked:t})=>{const[o,n]=(0,S.useAIData)(),[i,r]=(0,u.useState)(!1),a=(0,u.useRef)(o),{setShowSidebar:c}=$b(),[d,p]=(0,u.useState)(),f=(0,u.useCallback)((e=>{p((t=>{var o,n;let i=t;const r=null==t?void 0:t.industry,a=null==e||null===(o=e.siteContext)||void 0===o?void 0:o.industry;r&&a&&(i=v().cloneDeep(i),v().unset(i,"industry"));const s=null==t?void 0:t.businessName,l=null==e||null===(n=e.siteContext)||void 0===n?void 0:n.business_name;return s&&l&&(i=v().cloneDeep(i),v().unset(i,"businessName")),i}))}),[]),b=(0,u.useCallback)((e=>{const t={...e};a.current=t,n(t),f(t)}),[]);(0,u.useEffect)((()=>{r_&&!a_&&r(!0)}),[]);const _=(0,u.useCallback)((()=>a.current),[]),y=(0,u.useCallback)(((e,t)=>{let o=(0,T.kubioCloneDeep)(_());v().isArray(e)?(e.forEach((e=>{const[t,n]=e;o=v().set(o,t,(0,T.kubioCloneDeep)(n))})),b(o)):e&&(o=v().set(o,e,(0,T.kubioCloneDeep)(t)),b(o))}),[o,b]),k=(0,u.useCallback)(((e,t)=>(e=Array.isArray(e)?e.join("."):e,v().get(_(),`siteContext.${e}`,t))),[]),{clearSelectedBlock:x}=(0,l.useDispatch)("core/block-editor"),{openSidebar:w,setIsNavigationPanelOpened:C}=(0,l.useDispatch)("kubio/edit-site")||{};(0,u.useEffect)((()=>{x().then((()=>{null==w||w("document")})),null==C||C(!1)}),[x,w,C]);const I=(0,u.useRef)(),j=(0,s.useUnloadStoreEntities)(),P=(0,s.useResetUndoStack)(),E=v().get(o,"siteContext.industry"),R=v().get(o,"siteContext.business_name"),A=(0,u.useRef)(),O=(0,u.useRef)();(0,u.useEffect)((()=>()=>{clearTimeout(O.current)}),[]);const N=(0,m.__)("Finish Setup","kubio");return(0,g.jsxs)(Wb.Fill,{children:[(0,g.jsxs)("div",{ref:A,className:"kubio-black-wizard-onboarding",children:[(0,g.jsxs)("div",{className:"kubio-black-wizard-onboarding__header",children:[(0,g.jsx)("h2",{className:"kubio-black-wizard-onboarding__header__title",children:(0,m.__)("Initial Setup","kubio")}),(0,g.jsx)("p",{className:"kubio-black-wizard-onboarding__header__description",children:(0,m.__)("Let's set up your website essentials.","kubio")})]}),(0,g.jsx)("div",{className:"kubio-black-wizard-onboarding__content",children:(0,g.jsx)(i_,{updateLocalAIDataPath:y,localAIDataRef:a,getLocalAIDataInRealTime:_,getSiteContextValue:k,validationErrors:d})}),(0,g.jsxs)("div",{ref:I,className:"kubio-black-wizard-onboarding__footer",children:[(0,g.jsx)(h.Button,{onClick:()=>{(t=>{const{requestIdleCallback:n}=window;j(),P(),(0,s.removeCachedAllMergedAttributes)();const{onResetAiData:i}=o;null==i||i(),n((()=>{null==e||e()}))})()},variant:"secondary",children:(0,m.__)("Skip","kubio")}),(0,g.jsx)(h.Button,{onClick:()=>{const t=(()=>{const e={};return E||(e.industry=(0,m.__)("Field is Required","kubio")),R||(e.businessName=(0,m.__)("Field is Required","kubio")),e})();p(t),v().isEmpty(t)?(()=>{const t=_();v().get(t,"siteContext.industry")?(c(!1),r(!0)):null==e||e()})():(clearTimeout(O.current),O.current=setTimeout((()=>{(()=>{const e=A.current;if(!e)return;const t=e.querySelector(".kubio-black-wizard-onboarding__control__error");t&&((t=>{if(!t)return;const o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return n.top>=o.top&&n.left>=o.left&&n.bottom<=o.bottom&&n.right<=o.right})(t)||t.scrollIntoView())})()}),100))},className:"kubio-ai-button",children:N}),t&&(0,g.jsx)(qb,{footerRef:I})]})]}),i&&(0,g.jsx)(Bl,{onFinish:()=>{r_&&(a_=!1),null==e||e()}})]})},l_=(0,T.getBackendData)("autoStartBlackWizardOnboarding");let c_=!1;const u_=()=>{const{showBlackWizard:e,setShowBlackWizard:t,overlayClicked:o,setOverlayClicked:n,setShowSidebar:i}=$b(),{canShowBlackWizardOnboarding:r,blackWizardOnboardingWillBeVisible:a}=(({setShowBlackWizard:e,setShowSidebar:t})=>{const o=(0,x.useGetGlobalSessionProp)("ready"),[n,i]=(0,S.useAIData)(),{getAIDataInRealTime:r}=n,{isAIEnabled:a,canStartWithBlackWizardOnboarding:s}=(0,l.useSelect)((e=>{const{isAICapabilityEnabled:t,getSettings:o}=e(y.STORE_KEY),n=o();return{isAIEnabled:t(),canStartWithBlackWizardOnboarding:!!n.startWithBlackWizardOnboarding&&!c_}}),[]),{record:c}=r(),d=(0,T.getBackendData)("importDesignAiStructure",!1),p=s&&o&&a&&d&&!c_&&!!c;return(0,u.useEffect)((()=>{if(p){const n=l_?2e3:0;if(l_){var o;const e="kubio-black-wizard-onboarding-generating";(null===(o=document.querySelector(".kubio-iframe"))||void 0===o?void 0:o.contentDocument).body.classList.add(e),t(!1)}setTimeout((()=>{e(!0)}),n)}}),[p]),{canShowBlackWizardOnboarding:p,blackWizardOnboardingWillBeVisible:s&&!c_}})({showBlackWizard:e,setShowBlackWizard:t,setShowSidebar:i}),{fetchRecommendations:s=_.noop}=(0,l.useDispatch)("kubio/recommendations")||{};return e?(0,g.jsx)(g.Fragment,{children:r&&(0,g.jsx)(s_,{onFinish:()=>{document.body.classList.remove("kubio-will-have-black-wizard-onboarding"),c_=!0,t(!1),s()},overlayClicked:o,setOverlayClicked:n})}):(0,g.jsx)(g.Fragment,{children:a&&(0,g.jsx)(Rs,{})})},d_=()=>(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(h.Icon,{className:"kubio-ai-logo-animated kubio-ai-logo-colored",icon:He.KubioAI})}),p_=(e,t,o,n=!1)=>{const i=null==e?void 0:e.querySelector(`[data-block="${t}"]`);if(i)if(o)if(n){const t=e.createElement("div");t.classList.add("kubio-ai-generating-section-overlay"),i.append(t),(0,s.reactRender)((0,g.jsx)(d_,{}),t)}else{const e=i.querySelector(".kubio-ai-generating-section-overlay");e&&((0,s.reactUnmount)(e),e.remove())}else i.classList[n?"add":"remove"]("kubio-ai-is-generating")},{HEADER:h_,FOOTER:m_,SECTION:g_,COLUMN:f_,IMAGE:b_}=(0,We.getNamesOfBlocks)(),v_=[h_,m_,g_,f_,b_],y_=e=>{const{ownerDocument:t}=(0,s.useOwnerDocumentContext)(),[o,n]=(0,u.useState)(!1),i=(0,l.useSelect)((()=>{const t=(0,l.select)("core/block-editor").getBlock(e);return!!t&&v_.includes(t.name)}),[e]);return[o,(0,u.useCallback)((o=>{n(o),p_(t,e,i,o)}),[e,i,t])]},k_=async({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,block:r,includeContent:a=!0,shouldReplaceBlock:s=!0})=>{try{const l=(0,T.transformBlockToTemplate)(r),[c]=await ys({section:{category:e,template:l},pageContext:t,siteContext:o,pageTitle:n,includeContent:a});return s&&i(r.clientId,c,0),c[0]}catch(e){Ko.Log.error("footerInnerBlocksReplaceContent",e)}},{HEADER:x_,FOOTER:S_}=(0,We.getNamesOfBlocks)(),{HEADER:w_,FOOTER:C_}=(0,We.getNamesOfBlocks)(),I_=e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlockIndex:n}=(0,l.select)("core/block-editor"),{updateBlockAttributes:i,__unstableMarkLastChangeAsPersistent:r}=(0,l.dispatch)("core/block-editor"),a=t().map(o).find((e=>"hero-accent"===(0,_.get)(e,["attributes","kubioAI","meta","category"])));if(a&&0===n(a.clientId)){const t=(0,T.kubioCloneDeep)(a.attributes.kubio);(0,_.set)(t,"style.descendants.inner.margin.top.value",e?-170:0),(0,_.set)(t,"props.overlapSection",e),(0,_.set)(t,"hash",Xa().generate()),r(),i(a.clientId,{kubio:t})}},j_=()=>{const{dataHelper:e,...t}=(()=>{const{dataHelper:e}=(0,s.useKubioBlockContext)(),t=e.clientId,[{pageContext:o,siteContext:n,pageTitle:i},r]=(0,S.useAIData)(),{replaceBlocks:c,replaceInnerBlocks:d,selectBlock:p,clearSelectedBlock:h}=(0,l.useDispatch)("core/block-editor"),{block:m,innerBlocks:g,isFrontPage:f}=(0,l.useSelect)((e=>{const{getBlockParentsByBlockName:o,getBlock:n}=e("core/block-editor"),{getIsFrontPage:i=v().noop}=e("kubio/edit-site")||{},r=n((0,_.first)(o(t,[x_,S_])||[])||t);return{block:r,innerBlocks:e("core/block-editor").getBlocks(r.clientId),isFrontPage:i()}}),[t]),b=(0,u.useMemo)((()=>{let t=(e.getAttribute("anchor","section")||"section").replace(/\-\d+/,"");return t=(0,a.normalizeCategorySlug)(t),e.getAttribute("kubioAI.meta.category",t)}),[e]);return(0,u.useMemo)((()=>({clientId:m.clientId,sectionCategory:b,pageContext:o,siteContext:n,pageTitle:i,replaceBlocks:c,replaceInnerBlocks:d,block:m,innerBlocks:g,name:m.name,selectBlock:p,clearSelectedBlock:h,isFrontPage:f,dataHelper:e,setAIData:r})),[m,b,o,n,i,c,d,g,p,h,f,e,r])})(),[o,n]=(0,x.useGlobalSessionProp)("kubioAISurpriseMeUsedItems",new Map),i=(0,u.useMemo)((()=>({...t,usedSections:{items:o,setItems:n}})),[n,t,o]),[r,c]=y_(i.clientId),{clearSelectedBlock:d}=(0,l.useDispatch)("core/block-editor"),p=(0,u.useCallback)((async(e,t={})=>{if(r)return;const o=v().merge({},i,t);d(),c(!0);const n=(0,S.initGenerationSession)();try{switch(o.name){case w_:const{pair:t,overlappable:n}=await(async({clientId:e,pageContext:t,siteContext:o,pageTitle:n,replaceInnerBlocks:i,clearSelectedBlock:r=_.noop,isFrontPage:a=!0,pairPattern:s,usedSections:l=null},c=null)=>{let u=null;const d=l&&l.items.get(e)||[];try{const{navigation:p,hero:h,pairCloudPresetId:m,name:g,overlappable:f}=(0,S.getPageHederTemplate)(c,a,{skipSlugs:d});Ko.Log.info(`Skipping headers: ${d.join()||"N/A"}`),d.includes(g)||d.push(g);const b=m?(0,S.findPattern)("*",{findBy:{cloudPresetId:m},skipSlugs:d}):null;u=s||b;let _=[];if(p){const e=(0,T.kubioCloneDeep)(p);_=await Ts(fs(e),{pageTitle:n,siteContext:o,pageContext:t})}const[v]=await ys({section:{category:"hero",template:h},pageTitle:n,siteContext:o,pageContext:t});return _=ks(_,o,t),await i(e,[..._,...v].filter(Boolean)),l&&(l.items.set(e,d),l.setItems(new Map(l.items))),r(),{pair:u,overlappable:f}}catch(e){Ko.Log.error("headerReplaceDesign",e)}return{pair:u}})(o,e);o.isFrontPage&&t&&(await tl((0,_.get)(t,["content","2"],[]),o.pageTitle,o.siteContext,o.pageContext),I_(n||o.overlappable));break;case C_:await(async({clientId:e,pageContext:t,siteContext:o,pageTitle:n,replaceInnerBlocks:i,replaceBlocks:r,selectBlock:a=noop},s=null)=>{try{const l="footer",c=s||(0,S.getPageFooterTemplate)(o),u=fs(c)[0].innerBlocks,d=[];for(let e=0;e<u.length;e++){const i=u[e],a=await k_({sectionCategory:l,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:r,block:i,includeContent:!0,shouldReplaceBlock:!0});d.push(a)}await i(e,d),a(e)}catch(e){Ko.Log.error("footerReplaceDesign",e)}})(o,e);break;default:await xs(o,e)}}catch(e){Ko.Log.error("replaceDesign",e)}finally{n()}c(!1)}),[d,r,i,c]),h=(0,u.useCallback)((async(e={})=>{if(r)return;d(),c(!0);const t=(0,S.initGenerationSession)(),o=v().merge({},i,e);try{switch(o.name){case w_:await Ps(o);break;case C_:await(async({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,innerBlocks:r})=>{for(let a=0;a<r.length;a++){const s=r[a];await k_({sectionCategory:e,pageContext:t,siteContext:o,pageTitle:n,replaceBlocks:i,block:s,includeContent:!1})}})(o);break;default:await Ss(o)}}catch(e){Ko.Log.error("replaceDesign",e)}finally{t()}c(!1)}),[d,r,i,c]),m=(0,u.useCallback)(((e=null)=>{if(r)return;const t=(()=>{switch(i.name){case w_:return"kubio-header";case C_:return"kubio-footer";default:return"kubio-content"}})(),o=(0,_.get)(i,"sectionCategory","section"),n="kubio-header"!==t||i.isFrontPage?"section"===o||"kubio-content"!==t?void 0:`${t}/${o}`:y.INNER_HEADERS_CATEGORY;let a=async(e,t="")=>{const o=(0,T.kubioCloneDeep)(e.content),n=e.categories[0].split("/")[1],i=e.pairCloudPresetId?(0,S.findPattern)("*",{findBy:{cloudPresetId:e.pairCloudPresetId}}):null;try{await p(o,{sectionCategory:n,pairPattern:i,summary:t,overlappable:[...e.publicTags||[],...e.internalTags||[]].includes("overlappable")})}catch(e){Ko.Log.error("replaceDesign",e)}};if(e){const t=a;a=o=>e(o,t)}const s={page:"sections",disabledPages:["starterSite","pages"],sections:{categoryType:t,category:n,internalTag:y.AI_READY_TAG,onActionFunc:a}};(0,T.onOpenTemplateGalleryWithParams)(s)}),[r,i,p]);return{replaceDesign:p,replaceContent:h,replaceDesignFromGallery:m,dataHelper:e}},T_=e=>new Promise((t=>{setTimeout(t,e)})),P_="generating",E_="generated",R_=["cta","website-main-cta-section"];class A_{constructor(e,t,o,n,i){bt(this,"insertBlocks",void 0),bt(this,"queue",[]),bt(this,"insertedSections",[]),bt(this,"queuedSections",new Map),bt(this,"preCreatedSections",{}),bt(this,"pageTitle",void 0),bt(this,"siteContext",void 0),bt(this,"pageContext",void 0),this.pageTitle=t,this.siteContext=o,this.pageContext=n,this.notify=i,this.insertBlocks=e}initialize(e){for(const t of e){let e=t.slug;const o=Xa().generate();R_.includes(t.category)||(e=`${t.slug}::${o}`),this.queuedSections.set(e,{id:o,itemSlug:t.slug,category:t.category,section:t,inserted:!1,blocks:null,status:null}),this.queue.push(e)}}async generateSection(e){const t=this.queuedSections.get(e),o=this.preCreatedSections[t.category];if(o)return t.status=P_,this.logInfo((0,m.sprintf)("Section was pre-created - %1$s ( %2$s )",t.itemSlug,t.id)),t.blocks=o.map(T.transformTemplateToBlock),void(t.status=E_);if(null===t.status)try{this.logInfo((0,m.sprintf)("Start generating - %1$s ( %2$s )",t.itemSlug,t.id)),this.queuedSections.set(e,{...t,status:P_});const[o]=await ys({section:t.section,pageTitle:this.pageTitle,siteContext:this.siteContext,pageContext:this.pageContext,generateAnchorAndName:!1});this.queuedSections.set(e,{...t,blocks:o,status:E_})}catch(o){this.queue.map(((t,o)=>t===e?o:-1)).filter((e=>e>=0)).forEach((e=>this.queue.splice(e,1))),this.logError("Kubio AI section generation error",o,t.section)}}async generate(e,t={}){e&&this.notify((0,m.__)("Preparing page content","kubio")),this.preCreatedSections=t;const o=(0,T.getBackendData)("kubioAIParallelCalls",3),n=(0,_.chunk)(this.queue,o);for(const t of n)await this.executeChunk(t,e)}async executeChunk(e,t){await T_(t?1e3:0),await Promise.allSettled(e.map(((e,t)=>this.generateSection(e,t))))}getInsertedSections(){return this.insertedSections}async insert(){const e=this.queue[0],t=this.queuedSections.get(e);if(this.notify(((e="")=>(0,m.sprintf)(// translators: %s section name
// translators: %s section name
(0,m.__)('Generating "%s" section',"kubio"),(0,a.sectionCategoryToLabel)(e)))(t.category)),t.status!==E_)return await T_(200),await this.insert();const o={...t,blocks:t.blocks.map((e=>{const t=(0,lt.cloneBlock)((0,T.kubioCloneDeep)(e)),o=(0,_.get)(e,"attributes.kubioAI.meta.category","section"),n=(0,a.sectionCategoryToLabel)(o),{name:i,anchor:r}=vs(n);return(0,_.set)(t,"attributes.anchor",r),(0,_.set)(t,"attributes.attrs.name",i),t}))};return this.insertedSections.push(o),this.queue.shift(),this.logInfo((0,m.sprintf)("Inserted - %1$s ( %2$s )",t.itemSlug,t.id)),await this.insertBlocks(o.blocks),this.queue.length?(await T_(500),await this.insert()):void 0}logInfo(e,...t){Ko.Log.info(`[SectionsQueue] ${e}`,...t)}logError(e,...t){Ko.Log.error(`[SectionsQueue] ${e}`,...t)}}const O_=(e,t)=>{const o=(0,_.get)(e,["attributes"]),n=(0,_.get)(o,["kubio","style","descendants",t,"background"]);return{blockAttributes:o,blockBg:n,blockBgType:(0,_.get)(n,"type")}},N_=async({imageData:e,block:t,imageDataPath:o="bgImage",styledComponent:n})=>{const{blockAttributes:i,blockBg:r,blockBgType:a}=O_(t,n);if("image"!==a)return;const s=(0,_.get)(r,["image","0","source","url"]),l=(0,_.get)(i,["kubioAI","imageTerms"]);try{const n=await(0,S.searchImages)({...D_,search:l,initialImage:s}),i=B_(n.items,s);v().set(e,o,{currentValue:s,variants:i,clientId:t.clientId,blockName:t.name}),M_(i)}catch(e){console.error(e)}},B_=(e,t)=>e.filter((e=>e.split("?")[0]!==t.split("?")[0])),D_={perPage:11},M_=e=>{e.forEach((e=>{(new window.Image).src=e}))},L_=(0,_.debounce)(T.scrollIntoView,300),{NAVIGATION:z_,HERO:F_}=(0,We.getNamesOfBlocks)(),G_=["home","about","features","portfolio","pricing","team","contact"],H_=(e,t,o=null)=>{e=Jo(e).toHsl();const n=o||t,i=t;return Jo({...e,l:Math.floor(Math.random()*(n-i+1)+i)}).toHexString()},U_=()=>{const[e,t]=(0,u.useState)(!1),[o,n]=(0,u.useState)((0,m.__)("Generating…","kubio")),i=(0,x.useBlocksOwnerDocument)(),{setItems:r}=(0,co.usePrimaryMenuBlockEditor)(),{createErrorNotice:a}=(0,s.useKubioNotices)(),{postContentClientId:c,getHeaderClientId:p,getBlocks:h,isFSETemplate:f,themeSlug:b,nonFSEContentBlocksClientIds:C}=(0,l.useSelect)((e=>{var t;const{getClientIdsWithDescendants:o,getBlock:n,getBlocks:i}=e("core/block-editor"),{currentPageHasFSETemplate:r}=e(y.STORE_KEY),a=r(),s=e=>{const t=(0,_.castArray)(e),i=o().map((e=>n(e))).find((e=>t.includes(e.name)));return null==i?void 0:i.clientId},l=a?s("core/post-content"):null;return{isFSETemplate:a,getBlocks:i,postContentClientId:l,getHeaderClientId:()=>s("kubio/header"),getCurrentHeaderStructure:()=>{const e={};return i(s("kubio/header")).forEach((t=>{t.name===F_&&(e.hero=(0,T.transformBlockToTemplate)(t)),t.name===z_&&(e.navigation=(0,T.transformBlockToTemplate)(t))})),e},themeSlug:null===(t=e("core").getCurrentTheme())||void 0===t?void 0:t.template,nonFSEContentBlocksClientIds:i().map((({clientId:e})=>e))}}),[]),{insertBlocks:I,replaceInnerBlocks:P,clearSelectedBlock:E,removeBlocks:R}=(0,l.useDispatch)("core/block-editor"),{editEntityRecord:A,saveEntityRecord:O}=(0,l.useDispatch)("core"),{setLogoImage:N}=(0,w.useSiteLogoImages)(),[B,D]=Qa(),[M,L]=(0,S.useAIData)(),{globalStyle:z}=(0,w.useGlobalDataStyle)(),{setPalette:F}=(0,w.useGlobalDataColors)(),[,G]=(0,j.useEntityProp)("root","site","title"),H=(0,l.useSelect)((e=>{var t,o;const{getPage:n,getEntity:i}=e(y.STORE_KEY),r=(null===(t=n())||void 0===t?void 0:t.link)||null,a=(null===(o=i())||void 0===o?void 0:o.path)||null;return(r||a||"").replace(/\/$/,"")}),[]),U=(0,u.useCallback)((async e=>{await I(e,h(c).length,null===c?"":c,!1),await new Promise((t=>{setTimeout((()=>{L_(null==i?void 0:i.querySelector(`[data-block="${e[0].clientId}"]`),{block:"center",onScrollEnd:()=>(0,_.delay)(t,200)})}),300)}))}),[i,h,c,I]),W=(0,u.useRef)(null),V=(0,u.useCallback)((e=>{const t=W.current;t&&top.requestIdleCallback((()=>{setTimeout((()=>{L_(null==i?void 0:i.querySelector(`[data-block="${t}"]`),{block:"start",smooth:!0,onScrollEnd:e})}),500)}))}),[i]),K=(0,u.useCallback)((async()=>(E(),c?await P(c,[]):await R(C))),[E,C,c,R,P]),$=(0,u.useCallback)((e=>{const t=p();P(t,e)}),[p,P]),{frontPageEntity:q}=M,Y=(0,u.useCallback)((async e=>{var t;const{pageContext:o,siteContext:n,pageTitle:i,record:r,isFrontPage:a}=e;await A("postType",r.type,r.id,{meta:{saved_in_kubio:!0},title:i,kubio_ai_page_context:o}),null!==(t=n.website_logo)&&void 0!==t&&t.id&&N(n.website_logo.id),a&&n.business_name&&G(n.business_name)}),[A,N,G]),Z=(0,u.useCallback)((e=>{const t=(0,co.generateItemInitialData)();if(e.length){const o=e.filter((e=>G_.includes(e.category))).map(((e,o)=>{const n=(0,_.get)(e.blocks,[0,"attributes","anchor"]),i=(0,_.get)(e.blocks,[0,"attributes","attrs","name"]);return{...t,id:t.id-1-o,objectId:t.id-1-o,url:`${H}/#${n}`,label:i,order:o+2}})),n=[q?{...t,id:t.id,type:"post_type",object:"page",objectId:q.id,label:q.title.rendered,order:1}:null,...o];r(n.filter(Boolean))}}),[H,q,r]),X=(0,u.useCallback)((async e=>{var t,o;const{siteContext:i,isFrontPage:r=!1}=e;let a=(null==i?void 0:i.siteMood)||y.SITE_MOOD_VALUES.NEUTRAL,s="organization",l="both",c="",u="";const d={pattern:r?null:null===(t=e.siteContext)||void 0===t||null===(o=t.cta)||void 0===o?void 0:o.pattern,text:""};if(r){n((0,m.__)("Determine the website particularities","kubio"));try{const{mood:e,websiteSubject:t,ownerType:o,clientType:n,cta:r,coreBusiness:p}=await(0,S.determineSiteMood)({siteContext:(0,_.omit)(i,"otherPages")});a=e,s=o,l=n,u=p,d.text=r,c=t}catch(e){Ko.Log.error("Unable to determine site mood with AI",e)}}return Ko.Log.info(`Site mood is: ${a}`),{siteMood:a,cta:d,ownerType:s,clientType:l,websiteSubject:c,coreBusiness:u}}),[]),J=(0,u.useCallback)((async(e,t=3)=>{const{pageContext:o,siteContext:i,pageTitle:r}=e;n((0,m.__)("Generating page structure","kubio"));let a=await(0,S.getPageSectionsTemplates)({pageTitle:r,siteContext:i,pageContext:{...o,sortSections:!0}});if((0,_.isEmpty)(a)&&t)a=await J(e,t-1);else if((0,_.isEmpty)(a)){const e=(0,m.__)("There was an error with the KubioAI services. If the error persists, please contact support","kubio");throw new S.AIApiError(e,{cause:"empty_page_structure"})}return a}),[]),Q=(0,u.useCallback)((async(e,t)=>{const{pageContext:o,pageTitle:i,siteContext:r,isFrontPage:a=!1}=e;if(!a)return;let s=(0,_.sample)(y.colorPalettes.filter((e=>e.mood===t)));try{n((0,m.__)("Blending colors for an exceptional color palette","kubio"));const e=await(0,S.generateColorScheme)({pageContext:o,siteContext:r,pageTitle:i,mood:t});s={colors:[...e,H_(e[1],98,100),H_(e[0],5,10)]}}catch(e){Ko.Log.error("Error determining site colors",e)}s&&F(s.colors)}),[F]),ee=(0,x.useSetGlobalSessionProp)("aiFrontPageHeroImageVariantsData"),te=(0,u.useCallback)((async(e,t)=>{if(!f)return;const{pageContext:o,pageTitle:i,siteContext:r,isFrontPage:a=!1,isRegenerate:s}=e;if(!a)return;n((0,m.__)("Crafting an engaging website header","kubio"));let l,c=null,u=null,p=null,h=null,g=!0;s||(l=(0,S.getPageHederTemplate)(null,!0,{tag:[`theme-${b}`]})),l||(l=(0,S.getPageHederTemplate)(null,!0,{tag:[t]})),c=l.navigation,u=l.hero,p=l.bodyStyle,h=l.pairTemplate,g=l.overlappable,(0,S.setInGenerationSession)("currentHeaderIsOverlappable",g),u=(0,d.applyFilters)("kubio.ai.generateSectionBlocks.beforeBlockGenerated",u);const[y,k]=await Promise.allSettled([c?Ts(fs(c),{pageContext:o,siteContext:r,pageTitle:i}):new Promise((e=>e([]))),ys({section:{category:"hero",template:u},pageTitle:i,siteContext:r,pageContext:o})]),x=await y.value,[w]=await k.value;if(h)try{tl(h,i,r,{...o,isFrontPage:!1})}catch(e){Ko.Log.error("Generating inner header error",e)}return p&&top.requestIdleCallback((()=>{setTimeout((()=>{z.setStyle("",p,{styledComponent:"body",media:"desktop",mergeData:!1})}),10)})),a&&(async({heroBlock:e,setAiFrontPageHeroImageVariantsData:t})=>{const o={};await N_({imageData:o,block:e,imageDataPath:"bgImage",styledComponent:"outer"}),await(async({imageData:e,block:t,styledComponent:o})=>{const{blockAttributes:n,blockBg:i,blockBgType:r}=O_(t,o);if("slideshow"!==r)return;const a=(0,_.get)(i,["slideshow","slides"],[]).map((e=>null==e?void 0:e.url)),s=v().get(a,0),l=(0,_.get)(n,["kubioAI","slideshowTerms",0]);try{const o=await(0,S.searchImages)({...D_,search:l,initialImage:s}),n=B_(o.items,s);v().set(e,"bgSlideshow",{currentValue:a,variants:n,clientId:t.clientId,blockName:t.name}),M_(n)}catch(e){console.error(e)}})({imageData:o,block:e,styledComponent:"outer"}),await(async({imageData:e,heroBlock:t})=>{const o=(0,T.findBlockByName)(t,"kubio/image");if(!o)return;const n=(0,_.get)(o,["attributes","url"]),i=(0,_.get)(o,["attributes","kubioAI","imageTerms"]);try{const t=await(0,S.searchImages)({...D_,search:i,initialImage:n}),r=B_(t.items,n);v().set(e,"imageBlock",{currentValue:n,variants:r,clientId:o.clientId,blockName:o.name}),M_(r)}catch(e){console.error(e)}})({imageData:o,heroBlock:e}),await(async({imageData:e,heroBlock:t})=>{const o=(0,T.findAllBlocksByName)(t,"kubio/column",[]);for(let t=0;t<o.length;t++){const n=o[t];await N_({imageData:e,block:n,imageDataPath:"columnBgImage",styledComponent:"inner"})}})({imageData:o,heroBlock:e}),v().isEmpty(o)?t(null):t(o)})({heroBlock:w[0],setAiFrontPageHeroImageVariantsData:ee}),$([...x,...w]),w[0].clientId}),[f,$,b,z,ee]),oe=(0,x.useSetGlobalSessionProp)("showAiPostGenerateInterface"),ne=(0,u.useCallback)((async()=>{const{pageContext:e,siteContext:o,pageTitle:i,isFrontPage:a=!1,isMultiPage:s}=M;t(!0),W.current=null,await Y(M);const{pages:l}=await(0,S.createSiteStructureAndUpdateMenu)({localAIData:M,frontPageEntity:q,setMenuItems:r,setCurrentlyGeneratingMessage:n}),{siteMood:c,clientType:u,cta:d,ownerType:p,websiteSubject:h,coreBusiness:m}=await X(M),g={...M,siteContext:{...o,otherPages:l,isMultiPage:s,siteMood:c,clientType:u,cta:d,ownerType:p,websiteSubject:h,coreBusiness:m},pageContext:{...e,isFrontPage:a}},b=new A_(U,i,g.siteContext,g.pageContext,n);let v=await J(g);if(a){const e=v.find((e=>"cta"===e.category));g.siteContext.cta.pattern=(0,T.kubioCloneDeep)(e)}if(v=((e,t)=>{const{isFrontPage:o,siteContext:n}=t,i=n.cta.pattern||null;if(e=[...e],!i)return e;if(o){const t=(0,_.findIndex)(e,(e=>"features"===e.category));t>=0&&e.splice(t+1,0,i)}return e.map((e=>"cta"===e.category?{...i,slug:"website-main-cta-section"}:e))})(v,g),await K(),W.current=await te(g,c),await Q(g,c),b.initialize(v),b.generate(a,{cta:a?null:(0,_.get)(g,"siteContext.cta.pattern.template",null)}),await b.insert(),f){const e=(0,S.getFromGenerationSession)("currentHeaderIsOverlappable",null);null!==e&&I_(e)}t(!1),D(!1);const y=b.getInsertedSections();if(a&&f&&(s||Z(y)),a){const e=y.find((e=>"cta"===e.category));e&&(g.siteContext.cta.pattern.template=e.blocks.map(T.transformBlockToTemplate))}W.current||(W.current=(0,_.get)(y,["0","blocks","0","clientId"])),a&&((0,S.saveAiGeneralSettings)(g.siteContext),L(g)),V((()=>{a&&f&&top.requestIdleCallback((()=>{setTimeout((()=>{oe(!0)}),300)}))}))}),[M,Y,X,U,J,K,te,Q,f,D,V,oe,Z,L]),[ie]=(0,S.useAIServiceInfo)(),re=(0,u.useRef)(!1);return(0,k.useEffectAsync)((async()=>{if(!M.record||!B||!0===re.current)return;if(null===c&&f)return;if(ie.remainingCredits<ie.perPageCredits)return(0,d.doAction)("kubio.ai.zero_credits",{type:"page_generation"}),t(!1),void D(!1);const e=performance.now(),o=(0,S.initGenerationSession)();try{(0,d.addFilter)("kubio.dismissZeroCreditsModal","kubio.dismissZeroCreditsModal.pageGeneration",(()=>!0)),document.body.classList.add("kubio-ai-is-page-generating"),re.current=!0,await ne()}catch(e){e instanceof S.AIApiError?Ko.Log.error("Page generation: AI API Error",e):(Ko.Log.error("Page generation: JS Error",e),a((0,m.__)("KUBIO AI: There was an unknown error. If it persists, please contact support","kubio"),{duration:3e3}))}finally{t(!1),D(!1),re.current=!1,o(),document.body.classList.remove("kubio-ai-is-page-generating"),Ko.Log.success("Generation time: "+Math.ceil((performance.now()-e)/100)/10),(0,d.removeFilter)("kubio.dismissZeroCreditsModal","kubio.dismissZeroCreditsModal.pageGeneration")}}),[ie,M,D,a,ne,f,c]),(0,g.jsx)(g.Fragment,{children:e&&(0,g.jsx)(As,{message:o})})},W_=()=>{const[e]=Qa(),t=(0,x.useGetGlobalSessionProp)("ready"),[o,n]=(0,u.useState)(),i=(0,s.useDebounce)((0,u.useCallback)((e=>n(e)),[]),300);return(0,u.useLayoutEffect)((()=>{t&&e&&i(!0)}),[t,e,i]),(0,g.jsx)(g.Fragment,{children:o&&(0,g.jsx)(U_,{})})},V_=(0,g.jsx)(Q.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)(Q.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z"})}),K_=7500,$_=(0,u.memo)((()=>(0,g.jsx)(h.Icon,{icon:He.DashiconCheckedIcon,className:"kubio-comparison-check-icon"}))),q_=()=>(0,Ge.upgradeToPro)({source:"ai_upgrade_modal",content:"ai_upgrade_modal"}),Y_=(0,u.memo)((()=>(0,g.jsx)(h.Icon,{icon:He.DashiconUncheckedIcon,className:"kubio-comparison-close-icon"}))),Z_=({children:e})=>(0,g.jsx)("div",{className:"kubio-comparison-tooltip",children:e}),X_=["attachment","kubio_changeset"],J_=()=>{const[e]=(0,S.useAIServiceInfo)(),{aiImageCost:t=150,aiSectionCost:o=30}=e;return(0,g.jsxs)(Z_,{children:[(0,g.jsx)("p",{children:(0,m.sprintf)(// translators: %s is the number of credits
// translators: %s is the number of credits
(0,m.__)("With %s credits you'll benefit of:","kubio"),Intl.NumberFormat().format(K_))}),(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:(0,m.sprintf)(// translators: %d is the number
// translators: %d is the number
(0,m.__)("%d full page generations","kubio"),Math.ceil(K_/(10*o)))}),(0,g.jsx)("li",{children:(0,m.sprintf)(// translators: %d is the number
// translators: %d is the number
(0,m.__)("%d page sections generations","kubio"),Math.ceil(K_/o))}),(0,g.jsx)("li",{children:(0,m.sprintf)(// translators: %d is the number
// translators: %d is the number
(0,m.__)("%d text generations","kubio"),Math.ceil(750))}),(0,g.jsx)("li",{children:(0,m.sprintf)(// translators: %d is the number
// translators: %d is the number
(0,m.__)("%d image generations","kubio"),Math.ceil(K_/t))})]}),(0,g.jsx)("p",{children:(0,m.__)("The numbers provided are approximations and may vary based on the size and complexity of the generated content","kubio")})]})},Q_=[{label:(0,m.__)("Generate pages with AI","kubio"),free:(0,m.__)("Homepage only","kubio"),pro:(0,m.__)("Multiple pages","kubio")},{label:(0,m.__)("Regenerate page section","kubio"),free:(0,g.jsx)($_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Search images on Pexels","kubio"),free:(0,g.jsx)($_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Generate images with AI","kubio"),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Kubio AI credits","kubio"),tooltip:()=>(0,g.jsx)(J_,{}),free:500,pro:(0,m.sprintf)(// translators: %s is the amount of credits, e.g 7500
// translators: %s is the amount of credits, e.g 7500
(0,m.__)("Starting from %s","kubio"),Intl.NumberFormat().format(K_))},{label:(0,m.__)("Design variety on AI generated pages","kubio"),free:(0,m.__)("Limited","kubio"),pro:(0,m.__)("Full","kubio")},{label:(0,m.__)("Customize footer text","kubio"),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Sticky navigation","kubio"),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("High converting navigation layouts","kubio"),tooltip:()=>(0,g.jsx)(Z_,{children:(0,m.__)("Navigation layouts containing “call to action” buttons that will lead to better conversion rates.","kubio")}),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Beautiful hero sections","kubio"),free:"9",pro:"35+"},{label:(0,m.__)("Different hero image for each page","kubio"),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Newsletter subscription forms","kubio"),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Pricing tables","kubio"),free:(0,g.jsx)(Y_,{}),pro:(0,g.jsx)($_,{})},{label:(0,m.__)("Technical support","kubio"),free:(0,m.__)("Best effort","kubio"),pro:(0,m.__)("Priority support","kubio")}];let ev=(0,g.jsx)(g.Fragment,{});ev=({onCancel:e})=>{const[t,o]=(0,u.useState)(!1),[n,i]=(0,u.useState)(!1),r=(0,u.useRef)(),{hasDirtyEntities:a,entitiesToSave:c}=(0,l.useSelect)((e=>{const{__experimentalGetDirtyEntityRecords:t}=e("core");return{hasDirtyEntities:t().filter((({kind:e,name:t})=>"postType"===e&&!X_.includes(t))).length>0,entitiesToSave:t()}})),{saveEditedEntityRecord:d}=(0,l.useDispatch)("core"),p=(0,s.useUnloadStoreEntities)(),f=(0,u.useCallback)((()=>{p(),window.location=(0,T.getBackendData)("wpAdminUpgradePage")}),[p]),b=(0,u.useCallback)((async()=>{o(!0);const e=c.map((({kind:e,name:t,key:o})=>d(e,t,o)));await Promise.all(e),window.location=(0,T.getBackendData)("wpAdminUpgradePage")}),[c,d]),v=(0,u.useCallback)((()=>{a?i(!0):window.location=(0,T.getBackendData)("wpAdminUpgradePage")}),[a]);return(0,g.jsx)("div",{className:"kubio-ai-zero-credits-upgrade",children:(0,g.jsxs)("div",{className:"kubio-ai-zero-credits-upgrade__content",children:[(0,g.jsx)("div",{className:"kubio-ai-zero-credits-upgrade__close-modal",children:(0,g.jsx)(h.Button,{icon:Ve,onClick:e})}),(0,g.jsxs)(h.Flex,{children:[(0,g.jsx)(h.FlexBlock,{className:"kubio-ai-zero-credits-upgrade__content-column",children:(0,g.jsxs)("div",{className:"kubio-ai-zero-credits-upgrade__content-column__content",children:[(0,g.jsx)(h.Icon,{icon:He.KubioAI,className:"kubio-ai-logo-colored kubio-ai-logo-animated"}),(0,g.jsx)("h1",{children:(0,m.__)("Looks like you have used all your free Kubio AI credits.","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("To continue generating website content with Kubio AI you will need to upgrade to Kubio PRO.","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("You can also continue using the Kubio builder for free and you can keep the generated content, but you won't be able to enjoy the AI features anymore.","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("On the right, you can see a few advantages offered by the PRO version.","kubio")}),(0,g.jsxs)(h.Flex,{className:"buttons-wrapper",justify:"flex-start",children:[(0,g.jsx)(h.Button,{variant:"primary",onClick:q_,className:"kubio-ai-button",children:(0,m.__)("Upgrade to PRO","kubio")}),(0,g.jsx)(h.Button,{onClick:e,className:"kubio-ai-button-tertiary",children:(0,m.__)("Maybe later","kubio")})]}),(0,g.jsxs)(h.Flex,{align:"center",className:"kubio-zero-credits-already-purchased-wrapper",children:[(0,g.jsx)("span",{children:(0,m.__)("Already purchased?","kubio")}),(0,g.jsx)(h.Button,{ref:r,onClick:v,variant:"link",className:"kubio-ai-button-link is-small kubio-ai-activate-pro",children:(0,m.__)("Activate PRO now","kubio")}),n&&(0,g.jsxs)(h.Popover,{inline:!0,anchor:r.current,placement:"top",offset:10,focusOnMount:!1,className:"kubio-ai-wizard-confirmation",shift:!0,flip:!0,onClose:()=>!t&&i(!1),children:[(0,g.jsxs)(h.Flex,{className:"kubio-ai-wizard-confirmation__message",align:"flex-start",direction:"column",children:[(0,g.jsx)("h3",{children:(0,m.__)("The current page has unsaved changes","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("The Kubio PRO license activation process will take you to the WordPress admin area and the page you are currently editing has unsaved changes.","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("Would you like to save these changes or discard them?","kubio")})]}),(0,g.jsxs)(h.Flex,{justify:"flex-start",gap:5,children:[(0,g.jsx)(h.Button,{className:"kubio-ai-button-tertiary has-text",onClick:f,children:(0,m.__)("Discard & activate","kubio")}),(0,g.jsx)(h.Button,{className:"kubio-ai-button has-text",isBusy:t,onClick:b,children:(0,m.__)("Save & activate","kubio")})]})]})]})]})}),(0,g.jsx)(h.FlexBlock,{className:"kubio-ai-zero-credits-upgrade__bg-column",children:(0,g.jsxs)("table",{children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{className:"clear-border"}),(0,g.jsx)("th",{className:"kubio-comparison-header-free",children:(0,m.__)("FREE","kubio")}),(0,g.jsx)("th",{className:"kubio-comparison-header-pro",children:(0,m.__)("PRO","kubio")})]})}),(0,g.jsx)("tbody",{children:Q_.map((e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{className:"label-column",children:(0,g.jsxs)("span",{children:[!e.tooltip&&(0,g.jsx)("span",{children:e.label}),!!e.tooltip&&(0,g.jsx)(h.Tooltip,{delay:100,className:"kubio-comparison-tooltip-title",placement:"right",text:(0,_.isFunction)(e.tooltip)?e.tooltip():e.tooltip,children:(0,g.jsxs)("span",{className:"item-has-tooltip",children:[e.label,(0,g.jsx)(h.Icon,{className:"tooltip-icon",icon:V_})]})})]})}),(0,g.jsx)("td",{className:"content-column",children:e.free}),(0,g.jsx)("td",{className:"content-column content-column--pro",children:e.pro})]},e.label)))})]})})]})]})})};const tv=()=>{const e=(0,u.useRef)({}),[t,o]=(0,u.useState)(!1),n=(0,u.useCallback)(((t={})=>{if(!(0,d.applyFilters)("kubio.dismissZeroCreditsModal",!1)){switch(t.type||"general"){case"page_generation":e.current={title:(0,m.__)("Credit status","kubio"),message:(0,m.__)("You currently do not have enough credits to generate a new page. To continue using this feature, please consider purchasing more credits.","kubio")};break;case"general":e.current={title:(0,m.__)("Credit status","kubio"),message:(0,m.__)("You currently do not have enough credits. To continue using this feature, please consider purchasing more credits","kubio")}}o(!0)}}),[]);(0,s.useAddWPAction)("kubio.ai.zero_credits",n);const[i,r]=(0,S.useAIServiceInfo)(),{createSuccessNotice:a}=(0,s.useKubioNotices)(),l=(0,u.useCallback)((async()=>{o(!1);try{const{remaining_credits:e=0,per_page_credits:t=30}=await(0,S.getAIInfo)();r({...i,state:"ready",remainingCredits:e,perPageCredits:t}),a((0,m.__)("Credit status updated!","kubio"),{type:"snackbar",duration:3e3})}catch(e){Ko.Log.error("Zero credits modal",e)}}),[i,a,r]),c=(0,u.useCallback)((()=>{o(!1)}),[]);return t&&(0,g.jsx)(h.Modal,{className:X()("kubio-ai-wizard-modal auto kubio-ai-zero-credits-upgrade-modal"),overlayClassName:"kubio-ai-zero-credits-upgrade__close-modal",__experimentalHideHeader:!0,title:null,isDismissible:!1,children:(0,g.jsx)(ev,{message:e.current.message,refresh:l,onCancel:c})})},ov=-1,nv=()=>{const{isReady:e}=Rb(),[t,o]=(0,u.useState)(0),[n,i]=(0,u.useState)(!1),[r,a]=Qa(),[s,c]=(0,x.useGlobalSessionProp)("displayingEmptyPageChecked",!0),{isAIEnabled:d,isWooPage:p}=(0,l.useSelect)((e=>({isAIEnabled:e(y.STORE_KEY).isAICapabilityEnabled(),isWooPage:e(y.STORE_KEY).getIsWooCommercePage()})),[]),{contentLength:h,isFrontPage:f,isPage:b,isBlogPage:_}=(0,l.useSelect)((e=>{var t;const{getBlocks:o,getBlockOrder:n}=e("core/block-editor"),i=o()||[],{getIsFrontPage:r=v().noop,getPage:a=v().noop,getIsBlogPage:s=v().noop}=e("kubio/edit-site")||{},l=a()||{},c=(0,T.findBlockByName)(i,"core/post-content"),u=null==c?void 0:c.clientId;return{isFrontPage:r(),isBlogPage:s(),contentLength:null===(t=n(u))||void 0===t?void 0:t.length,isPage:"page"===v().get(l,"context.postType")}}));return(0,u.useEffect)((()=>{e&&o(0)}),[e]),(0,u.useLayoutEffect)((()=>{if(t!==ov&&e&&d)if(r)o(ov);else if(b&&!f&&!p&&!_)return h?void o(ov):s?o(1):(o(ov),void c(!1))}),[e,h,f,b,r,d,n,t,s,c,p,_]),(0,g.jsxs)(g.Fragment,{children:[1===t&&(0,g.jsx)(qf,{showButton:!1,initialModalIsVisible:!0,onNewAiPage:()=>{o(ov),i(!0)},onNewKubioPage:()=>{o(ov)},onCancel:()=>{o(ov)},title:(0,m.__)("Generate page content","kubio"),description:(0,m.__)("Choose a method to generate content for the current page","kubio")}),n&&(0,g.jsx)(S.AIWizard,{onFinish:()=>{o(ov),i(!1),a(!0)},onCancel:()=>{o(ov),i(!1)},isRegenerate:!0,forceGenerateTitle:!0})]})},iv=({enabled:e})=>{const t=(0,x.useGetGlobalSessionProp)("ready",!1),[o,n]=(0,x.useGlobalSessionProp)("AIFromGetStartedTriggered",!1),[i]=(0,S.useAIData)(),[r,a]=(0,S.useAIServiceInfo)(),[,s]=Qa();return(0,u.useEffect)((()=>{}),[a]),(0,u.useEffect)((()=>{if(e&&!o&&"ready"===r.state&&t&&i.isAIConnected){async function l(){a(await(0,S.getAIInfo)()),n(!0),s(!0)}l()}}),[i.isAIConnected,r.state,e,t,s,n,o,a]),(0,g.jsx)(g.Fragment,{})},rv=()=>{const[e,t]=(0,x.useGlobalSessionProp)("commercialFlowDisabled",!0),o=(0,l.useSelect)((e=>e("core").getCurrentTheme().template));(0,u.useEffect)((()=>{T.AI_IN_PRO&&(async()=>{const e=await O()({path:"kubio/v1/commercial-flow",method:"GET"}).then((e=>e));t(!(null==e||!e.disabled))})()}),[T.AI_IN_PRO]);const n=async()=>{t(!0),await O()({path:"kubio/v1/commercial-flow",method:"POST",data:{disabled:!0}})};if(T.AI_IN_PRO&&!e)return(0,g.jsxs)(h.Modal,{onRequestClose:()=>{},className:"kubio-ai-commercial-flow-modal",overlayClassName:"kubio-ai-commercial-flow-modal__overlay",isDismissible:!1,title:"",onKeyDown:e=>{"Escape"===e.key&&n()},__experimentalHideHeader:!0,children:[(0,g.jsx)("div",{className:"kubio-ai-commercial-flow-modal__close-modal",children:(0,g.jsx)(h.Button,{icon:Ve,onClick:n})}),(0,g.jsxs)("div",{className:"kubio-ai-commercial-flow-modal__content",children:[(0,g.jsx)("div",{className:"kubio-ai-commercial-flow-modal__content__video",children:(0,g.jsx)("iframe",{src:"https://player.vimeo.com/video/901485891?h=28cd98f111&title=0&byline=0&portrait=0&badge=0&autopause=0&player_id=0&app_id=58479&autoplay=1&muted=1",width:"100%",height:"auto",frameBorder:"0",allow:"autoplay; fullscreen;",allowFullScreen:!0,title:(0,m.__)("Get started with Kubio AI","kubio")})}),(0,g.jsxs)("div",{className:"kubio-ai-commercial-flow-modal__content__text",children:[(0,g.jsx)(h.Icon,{icon:He.KubioAI,className:"kubio-ai-logo-colored"}),(0,g.jsx)("h3",{children:(0,m.__)("Let's get your homepage done in 30 seconds, using AI","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("We'll bet you didn't think you could get your website done this fast. Upgrade to Kubio PRO to be able to generate your pages for you in seconds! It's incredibly simple:","kubio")}),(0,g.jsxs)("ul",{children:[(0,g.jsxs)("li",{children:[(0,g.jsxs)("span",{children:[" ",(0,m.__)("Step 1","kubio")," "]}),(0,m.__)("Insert a quick description of your site","kubio")]}),(0,g.jsxs)("li",{children:[(0,g.jsxs)("span",{children:[" ",(0,m.__)("Step 2","kubio")," "]}),(0,m.__)("Get a customized homepage, including text, images, colour schemes, typography, forms and social media integration.","kubio")]})]}),(0,g.jsx)("p",{children:(0,m.__)("It really is that simple! To get started, simply upgrade to PRO below:","kubio")}),(0,g.jsx)("div",{className:"kubio-ai-commercial-flow-modal__content__text__buttons-container",children:(0,g.jsx)(h.Button,{className:"kubio-ai-button",onClick:()=>{window.open((0,zo.addQueryArgs)(window.kubioUtilsData.upgrade_url,{utm_source:"ai-demo-modal",utm_medium:"editor"}),"_blank")},children:(0,m.__)("Upgrade to PRO","kubio")})}),(0,g.jsxs)("div",{className:"kubio-ai-commercial-flow-modal__content__text__footer",children:[(0,g.jsx)("p",{children:(0,m.__)("Curious to see it in action?","kubio")}),(0,g.jsx)("a",{target:"_blank",href:window.kubioUtilsData.try_starter_site.split("?").join(`/${o}?`),rel:"noreferrer",children:(0,m.__)("Try it free on a separate test site.","kubio")})]})]})]})]})},av=()=>{const[e,t]=(0,u.useState)(!0),[,o]=Qa(),n=(0,x.useGetGlobalSessionProp)("ready");return(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[])&&n&&e&&(0,g.jsx)(S.AIWizard,{onFinish:()=>{t(!1),o(!0)},onCancel:()=>t(!1),isFrontPage:!0,startWithAIFrontPage:!0})},sv={sectionAction:null,sectionId:null};function lv(){const e=(0,x.useGetGlobalSessionProp)("ready",!1),t=(0,x.useGetGlobalSessionProp)("variations-loaded"),[o,n]=(0,u.useState)(!1),[i,r]=(0,u.useState)(sv),a=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o}=e("core/block-editor");return t().map((e=>o(e))).map((e=>{var t;const o=null===(t=e.attributes)||void 0===t?void 0:t.anchor;return o?{anchor:o,block:e}:null})).filter(Boolean)})),{selectBlock:s,replaceBlocks:c}=(0,l.useDispatch)("core/block-editor"),d=(0,u.useMemo)((()=>"replace"===i.sectionAction),[i]);return(0,u.useEffect)((()=>{if(e){const e=new URL(window.location.href),t=e.searchParams.get("section_action"),o=e.searchParams.get("section_id");r((e=>e===sv?{sectionAction:t,sectionId:o}:e)),e.searchParams.delete("section_action"),e.searchParams.delete("section_id"),window.history.replaceState(null,"",e.toString())}}),[e]),(0,u.useEffect)((()=>{if(t){const e=setTimeout((()=>{n(!0)}),200);return()=>clearTimeout(e)}}),[t]),(0,u.useEffect)((()=>{const{sectionAction:t,sectionId:n}=i;if(!t||!n)return;const u=!d||o;if(e){var p;const e=null===(p=a.find((e=>e.anchor===n)))||void 0===p?void 0:p.block;if(!e)return;switch(Bu(e.clientId),t){case"select":case"edit":s(e.clientId),r(sv);break;case"replace":s(e.clientId),u&&(((e,t)=>{let o="kubio-content";switch(e.name){case"kubio/hero":case"kubio/header":case"kubio/navigation-section":o="kubio-header";break;case"kubio/footer":o="kubio-footer"}let n=(0,_.get)(e,"attributes.kubioAI.meta.category");if(!n){const t=(e=>{var t;let o=(null===(t=(0,l.select)("core/block-editor").getSettings())||void 0===t?void 0:t.__experimentalBlockPatternCategories)||[];return o=o.filter((({name:t})=>t.startsWith(`${e}/`))).map((({name:t})=>t.replace(`${e}/`,"").replace(/\./gim,"").toLowerCase())),o})(o),i=(0,_.get)(e,"attributes.anchor","").replace(/-\d+$/,"").replace(/\./gim,"").toLowerCase();t.includes(i)&&(n=i)}n&&(n=`${o}/${n}`),(0,T.onOpenTemplateGalleryWithParams)({page:"sections",disabledPages:["starterSite","pages"],sections:{categoryType:o,category:n,onActionFunc:async o=>{const n=(0,T.kubioCloneDeep)(o.content),i=(0,T.transformTemplateToBlock)(n);t(e.clientId,i)}}})})(e,c),r(sv))}}}),[a,e,c,s,t,o,d,i]),null}const cv=e=>!e||!!(null!=e&&e.includes("images.pexels.com")||null!=e&&e.includes("kubiobuilder.com")),uv=({url:e,width:t,height:o})=>{const n=new URL(e);return n.searchParams.set("w",t),n.searchParams.set("h",o),n.searchParams.delete("dpr"),n.searchParams.set("fit","crop"),n.toString()},dv=async e=>{const t=new Promise(((t,o)=>{const n=new Image;n.onload=()=>{t(n)},n.onerror=()=>t(null),n.src=e}));return await t},pv=async e=>{const t=await dv(e);if(!t)return!0;const{naturalWidth:o,naturalHeight:n}=t;return o<=2e3&&n<=2e3},hv=(0,T.getBackendData)("kubio_is_ai_site_editor");let mv=!1;const gv=()=>{const{createErrorNotice:e,createSuccessNotice:t}=(0,s.useKubioNotices)();return{getContentIsValidAndNotifyUserIfNot:({contentSectionsBlocks:t,frontHeaderBlocks:o,innerHeaderBlocks:n})=>{if(v().isEmpty(t))return e("Could not save, missing content blocks"),!1;if(v().isEmpty(o))return e("Could not save, missing front header blocks"),!1;if(v().isEmpty(n))return e("Could not save, missing inner header blocks"),!1;const i=(e=>{let t=null;return e.forEach((e=>{(0,T.walkBlocks)(e,(async o=>{if(t)return;let n=!1;if(v().eachDeep(o.attributes,((e,t,o)=>{n||"string"!=typeof t||"url"!==t||cv(e)||(n=e)}),{leavesOnly:!0}),n){var i;const r=null==e||null===(i=e.attributes)||void 0===i?void 0:i.anchor;t={block:o,message:`The section with id: ${r} has invalid url (${n}), only images from pexels are allowed`}}}))})),t})([...t||[],...o||[],...n||[]]);return!!v().isEmpty(i)||((({block:t,message:o}={})=>{(e=>{const t=null==e?void 0:e.clientId;if(!t)return;const o=document.querySelector("#kubio-iframe-holder iframe"),n=null==o?void 0:o.contentDocument;if(!n)return;const i=(0,T.getPreviewElementByModelId)(t,n);if(!i)return;i.scrollIntoView({behavior:"smooth",block:"center"});const r="kubio-ai-genereted-sites-editor-block-with-error-animation";i.classList.add(r),setTimeout((()=>{var e,t;null==i||null===(e=i.classList)||void 0===e||null===(t=e.remove)||void 0===t||t.call(e,r)}),1e4)})(t),(t=>{e(t)})(o)})(i),!1)}}};let fv=!1;const bv=[],_v=(()=>{const e=(0,T.getBackendData)("importDesignIndex");return null!==e?e:1})(),vv=null===y.importDesignIndexesConfig||void 0===y.importDesignIndexesConfig?void 0:y.importDesignIndexesConfig[_v],yv=null==vv?void 0:vv.isPrimary,kv=({onClose:e})=>{var t,o;const{GutentagSelectControl:n=u.Fragment}=(null===(t=top)||void 0===t||null===(o=t.kubio)||void 0===o?void 0:o.controls)||{},[i,r]=(0,u.useState)(!yv),[a]=(0,S.useAIData)(),{currentTheme:c}=(0,l.useSelect)((e=>({currentTheme:e("core").getCurrentTheme().stylesheet})),[]),d=null==a?void 0:a.siteContext,p=null==d?void 0:d.industry,f=null==d?void 0:d.language;(0,u.useEffect)((()=>{vv||(e(),alert("Import design index config not found"))}),[vv]);const{onSave:b,isBusy:_}=(({currentTheme:e,industry:t,language:o,importDesignIndex:n,onClose:i,saveForAllThemesWithCurrentStyle:r,currentImportDesignConfig:a})=>{const{createErrorNotice:c,createSuccessNotice:d}=(0,s.useKubioNotices)(),[p,h]=(0,u.useState)(!1),{getContentForSave:g}=(({saveForAllThemesWithCurrentStyle:e,currentImportDesignConfig:t,importDesignIndex:o}={})=>{const{menuItemsLabels:n}=(()=>{const{menuLocations:e}=(0,co.useMenusLocations)();return{menuItemsLabels:(0,l.useSelect)((t=>{var o,n;const{getEditedEntityRecord:i}=t("core"),r=i("kubio","menu",null==e||null===(o=e.find)||void 0===o||null===(n=o.call(e,(e=>"header-menu"===(null==e?void 0:e.name))))||void 0===n?void 0:n.menu),a=i("root","site");if(v().isEmpty(r))return null;const s=r.data,l=JSON.parse(s),c=parseInt(null==a?void 0:a.page_on_front),u=parseInt(null==a?void 0:a.page_for_posts);return l.items.filter((e=>"post_type"!==e.type||e.objectId!==c&&e.objectId!==u)).map((e=>e.label))}),[])}})(),{contentSectionsBlocks:i}=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlocks:n}=e("core/block-editor"),{currentPageHasFSETemplate:i}=e(y.STORE_KEY)||{};let r=null,a=[];return(null==i?void 0:i())&&(r=t().find((e=>{var t;return"core/post-content"===(null===(t=o(e))||void 0===t?void 0:t.name)})),r&&(a=n(r))),{contentSectionsBlocks:a}}),[]),r=(0,l.useSelect)((e=>{const{getClientIdsWithDescendants:t,getBlock:o,getBlockOrder:n}=e("core/block-editor"),i=(e=>{const n=v().castArray("kubio/header"),i=t().map((e=>o(e))).find((e=>n.includes(e.name)));return null==i?void 0:i.clientId})();return i?n(i).map(o):null}),[]),{getContentIsValidAndNotifyUserIfNot:a}=gv();return{getContentForSave:async()=>{const s=await el();if(!a({contentSectionsBlocks:i,frontHeaderBlocks:r,innerHeaderBlocks:s}))return null;const l=i.find(T.getSectionIsHeroAccent),c=i.filter((e=>(null==e?void 0:e.clientId)!==(null==l?void 0:l.clientId))),u=(0,T.cleanFontFamilyFromBlocks)(c||[]).map(T.transformBlockToTemplate),d=(0,T.cleanFontFamilyFromBlocks)(r||[]).map(T.transformBlockToTemplate),p=(0,T.cleanFontFamilyFromBlocks)(s||[]).map(T.transformBlockToTemplate);let h=!1;if(l&&(h=(0,T.transformBlockToTemplate)((0,T.cleanFontFamilyFromBlocks)(l))),v().isEmpty(u)||v().isEmpty(d)||v().isEmpty(p)||v().isEmpty(n))return null;const m=t.isPrimary,g={};return e?(g.content=u,v().isEmpty(n)||(g.innerPages=n),m||v().set(g,`dataByImportDesignIndex.index:${o}`,{frontHeader:d,innerHeader:p})):(m&&(g.frontHeader=d,g.innerHeader=p),g.heroAccent=h),g}}})({saveForAllThemesWithCurrentStyle:r,currentImportDesignConfig:a,importDesignIndex:n});return{onSave:async()=>{if(fv)return;h(!0),fv=!0;const a=await g();if(!a)return c((0,m.__)("Content was invalid, try again or contact a dev","kubio")),fv=!1,h(!1),void i();const s={theme:e,industry:t,language:o,importDesignIndex:n,content:JSON.stringify(a)};try{const e=r?"/kubio/v1/update-generated-ai-site-content-by-style":"/kubio/v1/update-generated-ai-site-content",t=await O()({path:e,method:"POST",data:{params:s}});null!=t&&t.success?d((0,m.__)("Updated generated site","kubio")):c((0,m.__)("Could not save generated site","kubio"))}catch(e){c((0,m.__)("Could not save generated site","kubio")),console.error(e)}finally{fv=!1,h(!1),i()}},isBusy:p}})({currentTheme:c,industry:p,language:f,importDesignIndex:_v,onClose:e,saveForAllThemesWithCurrentStyle:i,currentImportDesignConfig:vv});return vv?(0,g.jsxs)(h.Modal,{onRequestClose:e,title:(0,m.__)("Saving generated Ai Site","kubio"),className:"guest-ai-generated-sites-editor__modal",children:[(0,g.jsx)(n,{label:(0,m.__)("Theme","kubio"),value:c,options:bv}),(0,g.jsx)(n,{label:(0,m.__)("Front Page Index","kubio"),value:_v,options:bv}),(0,g.jsx)(n,{label:(0,m.__)("Industry","kubio"),value:p,options:bv}),(0,g.jsx)(n,{label:(0,m.__)("Language","kubio"),value:f,options:bv}),(0,g.jsx)("hr",{}),(0,g.jsx)("h3",{children:(0,m.__)("What to save:","kubio")}),(0,g.jsx)(h.ToggleControl,{label:(0,m.__)("Save for all themes with current style","kubio"),checked:i,onChange:r}),(0,g.jsx)("p",{children:(0,g.jsx)("strong",{children:xv(i)})}),(0,g.jsx)("hr",{}),(0,g.jsx)("div",{className:"guest-ai-generated-sites-editor__modal__footer",children:(0,g.jsx)(h.Button,{isPrimary:!0,onClick:b,isBusy:_,children:(0,m.__)("Save","kubio")})})]}):(0,g.jsx)(g.Fragment,{})},xv=e=>(null===y.importDesignIndexesConfig||void 0===y.importDesignIndexesConfig?void 0:y.importDesignIndexesConfig[_v])?e?yv?(0,m.__)("Saving content and menu","kubio"):(0,m.__)("Saving content, menu and header + inner header","kubio"):yv?(0,m.__)("Saving header + inner header and hero accent if present","kubio"):(0,m.__)("!!!!!!!!!!!!!!Careful, this is not intended in most cases. This will save a different hero accent for this front page index","kubio"):"",Sv=()=>{const[e,t]=(0,u.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Df.Fill,{children:(0,g.jsx)(h.Button,{className:"guest-ai-generated-sites-editor__save-button",isPrimary:!0,onClick:()=>t(!0),children:(0,m.__)("Save Generated AI Site","kubio")})}),e&&(0,g.jsx)(kv,{onClose:()=>{t(!1)}})]})},wv=({urlImageSizes:e,setUrlImageSizes:t})=>{if(v().isEmpty(e))return(0,g.jsx)(g.Fragment,{});const{width:o,height:n}=e||{},i=(o,n)=>{n&&(n=parseInt(n));const i=v().cloneDeep(e);v().set(i,o,n),t(i)};return(0,g.jsxs)("div",{className:"pexels-url-image-size-control",children:[(0,g.jsx)(ut.InputControl,{label:(0,m.__)("Width","kubio"),value:o,type:"number",onChange:e=>i("width",e)}),(0,g.jsx)(ut.InputControl,{label:(0,m.__)("Height","kubio"),value:n,type:"number",onChange:e=>i("height",e)})]})},Cv=({url:e})=>{const[t,o]=(0,u.useState)(null);return(0,u.useEffect)((()=>{(async()=>{const t=await jv(e);o(t)})()}),[]),{urlImageSizes:t,setUrlImageSizes:o}},Iv={width:1e3,height:1e3},jv=async e=>{const t=await dv(e);if(!t)return Iv;const{naturalWidth:o,naturalHeight:n}=t;return{width:o,height:n}},Tv=({url:e})=>(0,g.jsx)("video",{src:e}),Pv=({url:e,onError:t,onLoad:o})=>(0,g.jsx)("img",{src:e,onError:()=>t("image"),onLoad:o}),Ev=({url:e,value:t,onChange:o,onReset:n,type:i="image",showButton:r=!1,showRemoveButton:a=!1,buttonLabel:s=(0,m.__)("Change background image","kubio"),removeButtonLabel:l=(0,m.__)("Remove image","kubio"),label:c,withReset:d=!1,toggable:p=!1,toggleValue:f=!1,updateToggleValue:b=v().noop,isProOnly:_=!1,mediaId:y,upgradeUrlArgs:k={},...x})=>{var S;const[w,C]=(0,u.useState)(!1),[I,j]=(0,u.useState)(),[T,P]=(0,u.useState)(""),[E,R]=(0,u.useState)(!1);e&&!t&&(t=e);const A=null!==(S=t)&&void 0!==S&&S.url?t.url:t,[O,N]=(0,u.useState)(A),{urlImageSizes:B,setUrlImageSizes:D}=Cv({url:O}),M=(0,u.useCallback)((()=>b(!f)),[f,b]),L=(0,u.useRef)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.BaseControl,{className:X()("kubio-media-picker-base-control","kubio-control"),children:[(0,g.jsxs)(h.Flex,{justify:"space-between",style:{marginBottom:5},children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)(h.BaseControl.VisualLabel,{children:c})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsxs)(h.Flex,{children:[p&&(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)("div",{ref:L,className:"kubio-popover-options-button__toggle",children:(0,g.jsx)(h.FormToggle,{checked:f,onChange:e=>{_?C(!0):M(e)}})})}),d&&(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Button,{disabled:p&&!f,isSmall:!0,icon:He.ResetIcon,label:(0,m.__)("Reset","kubio"),className:"kubio-popover-options-icon kubio-color-indicator-popover-reset-icon kubio-border-control-button",onClick:n})})]})})]}),(!p||p&&f)&&(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.BaseControl,{children:(0,g.jsxs)("div",{className:"kubio-media-picker-container",role:"button",tabIndex:"0",children:["image"===i&&(0,g.jsx)(Pv,{url:A,onError:e=>{P(e)},onLoad:()=>{P("")}}),"video"===i&&(0,g.jsx)(Tv,{url:A})]})}),r&&(0,g.jsxs)(h.Flex,{align:"center",children:[(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>C(!0),className:"kubio-button-100",children:s}),v().isFunction(x.secondaryButton)?x.secondaryButton({url:A,type:i,onChange:o}):x.secondaryButton]}),a&&(0,g.jsx)(h.Button,{onClick:n,className:"kubio-button-100 kubio-media-reset-button",children:l})]})})]}),w&&!v().isEmpty(B)&&(0,g.jsx)(h.Modal,{className:"kubio-pexels-media-picker",title:(0,m.__)("Add Pexels URL","kubio"),onRequestClose:()=>C(!1),children:(0,g.jsxs)("div",{className:"kubio-pexels-gallery-picker__content",children:[(0,g.jsx)(ut.InputControl,{label:(0,m.__)("Pexels URL","kubio"),value:O,onChange:e=>N(e)}),(0,g.jsx)("hr",{}),(0,g.jsx)(wv,{urlImageSizes:B,setUrlImageSizes:D}),I&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("hr",{}),(0,g.jsx)(h.Notice,{status:"error",isDismissible:!1,children:I})]}),(0,g.jsx)("hr",{}),(0,g.jsx)(h.Button,{isPrimary:!0,onClick:async()=>{R(!0);const e=null!=B&&B.width?null==B?void 0:B.width:Iv.width,t=null!=B&&B.height?null==B?void 0:B.height:Iv.height,n=uv({url:O,width:e,height:t}),i=await(async e=>cv(e)?!await pv(e)&&"Image size is over full hd. Reduce the image size":"Image url is invalid, only image from pexels are allowed")(n);if(i)return j(i),void R(!1);i&&j(null),o({url:n}),C(!1),R(!1)},isBusy:E,children:(0,m.__)("Update","kubio")})]})})]})},Rv=(0,p.createHigherOrderComponent)((e=>e=>"video"===(null==e?void 0:e.type)?(0,g.jsx)(g.Fragment,{}):(0,g.jsx)(Ev,{...e}))),Av=({urls:e,onSelect:t})=>{const[o,n]=(0,u.useState)(!1),[i,r]=(0,u.useState)(),a=(0,u.useRef)([]),[s,l]=(0,u.useState)(e),[c,d]=(0,u.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.BaseControl,{className:X()("kubio-media-picker-base-control","kubio-control"),children:(0,g.jsx)(h.Flex,{justify:"space-between",style:{marginBottom:5},children:(0,g.jsx)(h.Flex,{align:"center",children:(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>n(!0),className:"kubio-button-100",children:(0,m.__)("Manage images","kubio")})})})}),o&&(0,g.jsx)(h.Modal,{className:"kubio-pexels-gallery-picker",title:(0,m.__)("Add Pexels URLs","kubio"),onRequestClose:()=>n(!1),children:(0,g.jsxs)("div",{className:"kubio-pexels-gallery-picker__content",children:[(0,g.jsx)("p",{children:(0,g.jsx)("strong",{children:"To remove a image leave the input empty"})}),s.map(((e,t)=>(0,g.jsx)(Ov,{ref:e=>a.current[t]=e,url:e,index:t},t))),(0,g.jsx)(h.Button,{isPrimary:!0,onClick:()=>{const e=v().cloneDeep(s);v().set(e,s.length,""),l(e)},icon:$e,children:(0,m.__)("Add new Image","kubio")}),i&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("hr",{}),(0,g.jsx)(h.Notice,{status:"error",isDismissible:!1,children:i})]}),(0,g.jsx)("hr",{}),(0,g.jsx)("div",{className:"kubio-pexels-gallery-picker__footer",children:(0,g.jsx)(h.Button,{isPrimary:!0,onClick:async()=>{d(!0);const e=[];for(const t of a.current){const o=t.getSubmitData(),{url:n,urlImageSizes:i}=o,r=null!=i&&i.width?null==i?void 0:i.width:Iv.width,a=null!=i&&i.height?null==i?void 0:i.height:Iv.height,s=uv({url:n,width:r,height:a});e.push(s)}l(e);const o=e.filter((e=>!!e)),i=await(async e=>{let t=!1;for(const o of e)if(cv(o)||(t="Image url is invalid, only image from pexels are allowed"),!await pv(o))return"Image size is over full hd. Reduce the image size";return t})(o);if(i)return void r(i);i&&r(null);const s=o.map((e=>({id:null,url:e,alt:null,caption:null})));t(s),n(!1),d(!1)},isBusy:c,children:(0,m.__)("Update","kubio")})})]})})]})},Ov=(0,u.forwardRef)((({url:e,index:t},o)=>{const[n,i]=(0,u.useState)(e),{urlImageSizes:r,setUrlImageSizes:a}=Cv({url:n});return(0,u.useImperativeHandle)(o,(()=>({getSubmitData:()=>({url:n,urlImageSizes:r})}))),(0,g.jsxs)(h.BaseControl,{ref:o,children:[(0,g.jsx)(ut.InputControl,{label:(0,m.__)(`Pexels URL #${t+1}`,"kubio"),value:n,onChange:e=>i(e)}),(0,g.jsx)("hr",{}),(0,g.jsx)(wv,{urlImageSizes:r,setUrlImageSizes:a})]},t)})),Nv=(0,p.createHigherOrderComponent)((e=>t=>t.multiple?(0,g.jsx)(Av,{...t}):(0,g.jsx)(e,{...t}))),Bv=()=>{const{isConnectedToCloud:e}=(()=>{const[e,t,o,n]=(0,s.useKubioCloudConnect)(),i="connected"===(null==e?void 0:e.status);return(0,u.useEffect)((()=>{!n||mv||i||(mv=!0,t())}),[n]),{isConnectedToCloud:i}})();return(0,u.useEffect)((()=>{(0,d.addFilter)("kubio.frontPageRevertEnabled","guestAiGeneratedSitesEditor",(()=>!1),9999),(0,d.addFilter)("kubio.guestAiGeneration.userPreferencesAutoContinue","guestAiGeneratedSitesEditor",(()=>!0),9999),(0,d.addFilter)("kubio.ai.contentFromAiStructureId","guestAiGeneratedSitesEditor",(()=>!0),9999),(0,d.addFilter)("kubio.backWizardOnboard.shouldReplacePlaceholderTextOnInsert","guestAiGeneratedSitesEditor",(()=>!1),9999),(0,d.addFilter)("kubio.control.media-picker","guestAiGeneratedSitesEditor",Rv,9999),(0,d.addFilter)("editor.MediaUpload","guestAiGeneratedSitesEditor",Nv,9999)}),[]),e?(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(Sv,{})}):(0,g.jsx)(g.Fragment,{})},Dv=()=>{const{isFrontPage:e}=(0,l.useSelect)((e=>{const{getIsFrontPage:t=v().noop,getPage:o=v().noop}=e("kubio/edit-site")||{},n=o(),i="page"===v().get(n,"context.postType");return{isFrontPage:t()&&i}}),[]);return hv&&e?(0,g.jsx)(Bv,{}):(0,g.jsx)(g.Fragment,{})},Mv={secondarySidebar:(0,m.__)("Block Library","kubio"),drawer:(0,m.__)("Navigation Sidebar","kubio")},Lv=["label",'[class*="-label"]',".components-base-control__label",".component-box-control__label"].join(","),zv=(0,p.createHigherOrderComponent)((e=>({initialSettings:t})=>{var o,n,i,r;const{isFullscreenActive:a,sidebarIsOpened:c,settings:d,templateId:p,templateType:h,page:f,isNavigationOpen:b,isInserterOpen:k,isListViewOpen:x,isFSETemplate:S,currentSidebar:w}=(0,l.useSelect)((e=>{const{isFeatureActive:t,getSettings:o,getEditedPostType:n,getEditedPostId:i,getPage:r,isNavigationOpened:a,isListViewOpened:s,getEditorOpenedSidebar:l}=e(y.STORE_KEY),c=n(),u=i();return{isFullscreenActive:t("fullscreenMode"),sidebarIsOpened:e(y.STORE_KEY).isEditorSidebarOpened(),settings:o(),templateType:c,page:r(),templateId:u,isNavigationOpen:a(),isInserterOpen:e(y.STORE_KEY).getOpenedInserter(),isFSETemplate:!!u&&!!c,isListViewOpen:s(),currentSidebar:l()}}),[]),{postId:C,post:I,currentTemplateId:j,isKubioTheme:T}=(0,l.useSelect)((e=>{const t=v().get(f,["context","postId"]),o=v().get(f,["context","postType"]),{getEntityRecords:n,getEntityRecord:i}=e("core"),{getTemplateId:r=v().noop}=e("kubio/edit-site");if(!t||!o)return{postId:null,currentTemplateId:null,isKubioTheme:null,post:{}};let a;if(["wp_template","wp_template_part"].includes(o)){const e=n("postType",o,{wp_id:t});a=null==e?void 0:e[0]}else a=i("postType",o,parseInt(t));const s=r(),{getEditorSettings:l}=e(q.store);return{postId:t,currentTemplateId:s,isKubioTheme:l().supportsTemplateMode,post:a}}),[null==f||null===(o=f.context)||void 0===o?void 0:o.postId,null==f||null===(n=f.context)||void 0===n?void 0:n.postType]),{openSidebar:P}=(0,l.useDispatch)(y.STORE_KEY),{createInfoNotice:E}=(0,l.useDispatch)("core/notices");(0,u.useEffect)((()=>{P("document")}),[]);const{editEntityRecord:R}=(0,l.useDispatch)("core"),{updateEditorSettings:A,setupEditorState:O}=(0,l.useDispatch)("core/editor"),{defaultTemplateTypes:N}=d;(0,u.useEffect)((()=>{A({...t,defaultTemplateTypes:N})}),[N,t,A]),(0,u.useLayoutEffect)((()=>{const e=v().get(f,["context","postId"]),t=v().get(f,["context","postType"]);e&&t&&O({id:e,type:t})}),[null==f||null===(i=f.context)||void 0===i?void 0:i.postId,null==f||null===(r=f.context)||void 0===r?void 0:r.postType]),(0,u.useLayoutEffect)((()=>{var e;if(I&&"page"===I.type&&(null===(e=I.meta)||void 0===e||!e.saved_in_kubio)&&(0,_.isString)(j)){const e=T?"full-width":"kubio-full-width",t=j.includes(e),o=v().get(I,["content","raw"]),n=v().get(I,"template"),i=v().get(I,"id"),r=v().get(I,"type");!o&&t&&""===n&&((0,s.markLastChangeAsPersistent)(),R("postType",r,i,{template:e}),E((0,m.__)('New empty page detected. Page template was set to "Full Width"',"kubio"),{type:"snackbar"}))}}),[j,R,T,I,C]);const B={startGeneratingAIFrontPage:t.startGeneratingAIFrontPage,isListViewOpen:x,isFullscreenActive:a,sidebarIsOpened:c,templateId:p,templateType:h,page:f,isNavigationOpen:b,isInserterOpen:k,isFSETemplate:S,currentSidebar:w,startWithAIFrontPage:d.startWithAIFrontPage||!1,__experimentalGlobalStylesBaseStyles:d.__experimentalGlobalStylesBaseStyles,__experimentalGlobalStylesUserEntityId:d.__experimentalGlobalStylesUserEntityId};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(e,{...B}),(0,g.jsx)(Tb,{})]})}),"WithEditorCurrentEntity"),Fv=(0,p.compose)(zv,p.pure)((function(e){const{__experimentalGlobalStylesUserEntityId:t,sidebarIsOpened:o,templateId:n,templateType:i,page:r,isNavigationOpen:c,isInserterOpen:d,isListViewOpen:p,isFSETemplate:f,startWithAIFrontPage:b,currentSidebar:_,startGeneratingAIFrontPage:v}=e,{setPage:P}=(0,l.useDispatch)("core/editor"),R=(0,s.useActiveMedia)(),[A,O]=(0,u.useState)(!1),N=(0,u.useCallback)((()=>O(!0)),[]),B=(0,u.useCallback)((()=>{O(!1)}),[]);!function(){const{hasBlockSelection:e,isEditorSidebarOpened:t,isGlobalStyleEditing:o}=(0,l.useSelect)((e=>({hasBlockSelection:!!e("core/block-editor").getBlockSelectionStart(),isEditorSidebarOpened:e(y.STORE_KEY).isEditorSidebarOpened(),isGlobalStyleEditing:e(y.STORE_KEY).isGlobalStyleEditing()})),[]),{openSidebar:n}=(0,l.useDispatch)(y.STORE_KEY);(0,u.useEffect)((function(){t&&n(e?"block-inspector":o?"document/general-settings":"document")}),[e,t,o])}(),(()=>{const[e,t]=(0,u.useState)({}),[,o]=(0,Fe.useCurrentInspectorTab)(),n=(0,l.useSelect)((e=>{const t=e("core/block-editor").getSelectedBlock();return{clientId:null==t?void 0:t.clientId,name:null==t?void 0:t.name}}));(0,u.useEffect)((()=>{(null==e?void 0:e.clientId)!==(null==n?void 0:n.clientId)&&(null==e?void 0:e.name)!==(null==n?void 0:n.name)&&(o("content"),t(n))}),[n,e,t,o])})();const M=(0,x.useGetGlobalSessionProp)("ready",!1),L=(0,u.useMemo)((()=>{var e;return{...null==r?void 0:r.context,queryContext:[null==r||null===(e=r.context)||void 0===e?void 0:e.queryContext,e=>{var t;return P({...r,context:{...null==r?void 0:r.context,queryContext:{...null==r||null===(t=r.context)||void 0===t?void 0:t.queryContext,...e}}})}]}}),[r,P]);(0,u.useEffect)((()=>{c?document.body.classList.add("is-navigation-sidebar-open"):document.body.classList.remove("is-navigation-sidebar-open")}),[c]),(0,u.useEffect)((()=>(0,a.initializeGutentagPatterns)()),[]);const{uiVersion:z}=(0,k.useUIVersion)(),F=X()("kubio-sidebar",{"kubio-sidebar-hidden":(!o||d||p)&&1===z}),G=!(d||p),H=X()("kubio-secondary-sidebar",{"kubio-secondary-sidebar--closed":G,"kubio-secondary-sidebar--opened":!G,"kubio-secondary-sidebar-hidden":!(d||p)&&1===z}),{createErrorNotice:U}=(0,l.useDispatch)("core/notices");let W=(0,g.jsx)(g.Fragment,{}),V=(0,g.jsx)(g.Fragment,{});const K=(0,u.useCallback)((e=>{const t=new MutationObserver((e=>{e.forEach((e=>{e.addedNodes.forEach((e=>{if(!e.querySelectorAll)return;const t=[...e.querySelectorAll(Lv)||[]];e.matches(Lv)&&t.push(e),t.length&&t.forEach((t=>{if(e.getAttribute("label"))return;const o=t.textContent.trim();o&&t.setAttribute("title",o)}))}))}))}));return e&&t.observe(e,{childList:!0,subtree:!0}),()=>{t.disconnect()}}),[]);M&&(2===z?V=(0,g.jsxs)("div",{className:"kubio-sidebar-v2-wrapper",children:[p&&(0,g.jsx)("div",{className:"kubio-sidebar-list-view",children:(0,g.jsx)(jb,{})}),(0,g.jsxs)("div",{id:"kubio-main-sidebar",className:F,"data-sidebar-name":_,ref:K,children:[(0,g.jsx)(Ne.Slot,{scope:`${y.STORE_KEY}/sidebars`}),(0,g.jsx)(ta,{})]}),(0,g.jsx)("div",{className:H,children:d&&(0,g.jsx)(Ze,{})})]}):(W=(0,g.jsxs)("div",{id:"kubio-main-sidebar",className:F,"data-sidebar-name":_,ref:K,children:[(0,g.jsx)(Ne.Slot,{scope:`${y.STORE_KEY}/sidebars`}),(0,g.jsx)(ta,{})]}),V=(0,g.jsxs)("div",{className:H,children:[d&&(0,g.jsx)(Ze,{}),p&&(0,g.jsx)(jb,{})]})));const $=(0,g.jsx)(Ab,{blockContext:L,templateId:n,templateType:i,page:r,children:(0,g.jsxs)(S.AIDataProvider,{children:[(0,g.jsx)(w.KubioGlobalDataContextProvider,{children:(0,g.jsx)(Ib,{children:(0,g.jsx)(C.GlobalStylesProvider,{children:(0,g.jsx)(I.ToolsPanelContext,{children:(0,g.jsxs)(I.BlockContextProvider,{value:L,children:[(0,g.jsx)(Nb,{}),(0,g.jsx)(zf.Register,{}),(0,g.jsx)(oa,{}),(0,g.jsxs)(Vb,{children:[(0,g.jsx)(u_,{}),(0,g.jsx)(Jb,{}),(0,g.jsx)(De,{labels:Mv,drawer:(0,g.jsx)(xb,{}),sidebar:W,secondarySidebar:V,header:(0,g.jsx)(Mf,{openEntitiesSavedStates:N}),notices:(0,g.jsx)(Sb,{}),content:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(q.EditorNotices,{}),f&&(0,g.jsx)(Fa,{}),!f&&(0,g.jsx)(Ga,{}),(0,g.jsx)(zf,{openEntitiesSavedStates:N}),(0,g.jsx)("div",{id:"kubio-toolbar-boundary"})]}),actions:(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(qa,{isOpen:A,close:B})}),footer:(0,g.jsx)(I.BlockBreadcrumb,{})})]}),(0,u.createPortal)((0,g.jsxs)("div",{className:"kubio-popover-slot-container",children:[(0,g.jsx)(h.Popover.Slot,{}),(0,g.jsx)(h.Popover.Slot,{name:"kubio-popover-slot"})]}),document.body),(0,g.jsx)(ke.PluginArea,{onError:function(e){U((0,m.sprintf)(/* translators: %s: plugin name */ /* translators: %s: plugin name */(0,m.__)('The "%s" plugin has encountered an error and cannot be rendered.',"kubio"),e))}}),(0,g.jsx)(W_,{}),(0,g.jsx)(lv,{})]})})})})}),(0,g.jsx)(nv,{}),(0,g.jsx)(iv,{enabled:v}),(0,g.jsx)(Dv,{})]})});return(0,g.jsx)("div",{className:X()("kubio-editor-wrapper",`kubio-editor-wrapper--media-${R}`),children:(0,g.jsxs)(h.SlotFillProvider,{children:[(0,g.jsx)(Be,{isActive:!0}),(0,g.jsx)(q.UnsavedChangesWarning,{}),(0,g.jsx)(Me.ShortcutProvider,{style:{height:"100%"},children:(0,g.jsxs)(j.EntityProvider,{kind:"root",type:"site",children:[f&&(0,g.jsx)(j.EntityProvider,{kind:"postType",type:i,id:n,children:(0,g.jsx)(j.EntityProvider,{kind:"postType",type:"wp_global_styles",id:t,children:$})}),!f&&$]})}),M&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ha,{}),(0,g.jsx)(Ff,{blockContext:L,templateId:n,templateType:i,page:r}),T.AI_IN_PRO&&(0,g.jsx)(rv,{}),(0,g.jsx)(E,{}),(0,g.jsx)(D,{})]}),b&&(0,g.jsx)(av,{}),(0,g.jsx)(tv,{})]})})}));(0,d.addFilter)("editor.MediaUpload","kubio/edit-site/components/media-upload",(()=>e_.MediaUpload)),(0,d.addFilter)("editor.BlockEdit","kubio/advancedPanel",Gn.withInspectorControlsAdvancedPanel);const Gv=window.wp.dataControls,Hv={fullscreenMode:!0},Uv=(0,l.combineReducers)({features:(e=Hv,t)=>"TOGGLE_FEATURE"===t.type?{...e,[t.feature]:!e[t.feature]}:e}),Wv=(0,l.combineReducers)({preferences:Uv,deviceType:function(e="Desktop",t){return"SET_PREVIEW_DEVICE_TYPE"===t.type?t.deviceType:e},settings:function(e={},t){switch(t.type){case"UPDATE_SETTINGS":return{...e,...t.settings};case"UPDATE_UI_VERSION":return O()({path:(0,zo.addQueryArgs)("/kubio/v1/update-ui-version",{version:t.version})}),{...e,kubioGlobalSettings:{...e.kubioGlobalSettings||{},editorUIVersion:t.version}};case"TOGGLE_AI_CAPABILITIES":return O()({path:"/kubio/v1/update-enable-ai-capabilities",method:"POST",data:{value:t.value}}),{...e,kubioGlobalSettings:{...e.kubioGlobalSettings||{},enableAICapabilities:t.value}};case"UPDATE_EDITOR_MODE":return O()({path:"/kubio/v1/update-editor-mode",method:"POST",data:{value:t.value}}),{...e,kubioGlobalSettings:{...e.kubioGlobalSettings||{},editorMode:t.value}};case"UPDATE_EXCLUDED_SECTION_CATEGORIES":return O()({path:"/kubio/v1/update-excluded-section-categories",method:"POST",data:{value:t.value}}),{...e,kubioGlobalSettings:{...e.kubioGlobalSettings||{},excludedSectionCategories:t.value}};case"UPDATE_FLAG_SETTINGS":O()({path:"/kubio/v1/update-flag-settings",method:"POST",data:{value:t.value,path:t.path}});const o={...e.kubioGlobalSettings||{}};return v().set(o,t.path,t.value),{...e,kubioGlobalSettings:{...o}};case"UPDATE_RECOMMENDATION_SETTINGS":const n=t.value;if(!v().isObject(n))return e;const i=(0,T.mergeNoArrays)({},e.kubioRecommendationSettings||{},n);return{...e,kubioRecommendationSettings:i}}return e},editedPost:function(e={},t){switch(t.type){case"SET_TEMPLATE":case"SET_PAGE":return{type:"wp_template",id:t.templateId,page:t.page};case"SET_PAGE_CONTENT":return{page:t.page};case"SET_TEMPLATE_PART":return{type:"wp_template_part",id:t.templatePartId,page:{context:{}}}}return e},homeTemplateId:function(e,t){return"SET_HOME_TEMPLATE"===t.type?t.homeTemplateId:e},navigationPanel:function(e={menu:ts,isOpen:!1},t){switch(t.type){case"OPEN_NAVIGATION_PANEL_TO_MENU":return{...e,isOpen:!0,menu:t.menu};case"SET_IS_NAVIGATION_PANEL_OPENED":return{...e,menu:t.isOpen?e.menu:ts,isOpen:t.isOpen};case"SET_IS_INSERTER_OPENED":return{...e,menu:e.isOpen&&t.isOpen?ts:e.menu,isOpen:!t.isOpen&&e.isOpen}}return e},blockInserterPanel:function(e=!1,t){switch(t.type){case"OPEN_NAVIGATION_PANEL_TO_MENU":return!1;case"SET_IS_NAVIGATION_PANEL_OPENED":return!t.isOpen&&e;case"SET_IS_INSERTER_OPENED":return t.isOpen}return e},currentAncestor:function(e="",t){return"SET_CURRENT_ANCESTOR"===t.type?t.currentAncestor:e},templateId:function(e,t){switch(t.type){case"SET_TEMPLATE":case"ADD_TEMPLATE":case"SET_PAGE":case"SET_ENTITY":return t.templateId;case"SET_TEMPLATE_PART":return}return e},templatePartId:function(e,t){return"SET_TEMPLATE_PART"===t.type?t.templatePartId:e},templateType:function(e,t){switch(t.type){case"SET_TEMPLATE":case"ADD_TEMPLATE":case"SET_PAGE":case"SET_ENTITY":return"wp_template";case"SET_TEMPLATE_PART":return"wp_template_part"}return e},templateIds:function(e=[],t){switch(t.type){case"ADD_TEMPLATE":return[...e,t.templateId];case"REMOVE_TEMPLATE":return e.filter((e=>e!==t.templateId))}return e},templatePartIds:function(e=[]){return e},page:function(e={},t){switch(t.type){case"SET_PAGE":case"SET_PAGE_CONTENT":case"SET_TEMPLATE":return t.page;case"SET_TEMPLATE_PART":return{context:{}}}return e},entity:function(e={},t){return"SET_ENTITY"===t.type?t.entity:e},showOnFront:function(e){return e},subSidebars:function(e={},t){switch(t.type){case"ADD_SUBSIDEBAR":return e[t.areaIdentifier]?e:{...e,[t.areaIdentifier]:t.sidebar};case"REMOVE_SUBSIDEBAR":return{...e,[t.areaIdentifier]:!1}}return e},globalStyleEditing:function(e={value:void 0,previousEntity:null},t){return"TOGGLE_GLOBAL_STYLE_EDITING"===t.type?{...e,value:t.value,previousEntity:t.previousEntity}:e},openedInserter:function(e=!1,t){return"TOGGLE_IS_INSERTER_OPEN"===t.type?(t.options=t.options||{},qo()(e,t)?e:{value:null==t?void 0:t.value,clientId:null==t?void 0:t.rootClientId,options:(null==t?void 0:t.options)||{}}):e},isGutentagDebug:function(e=!1,t){return"TOGGLE_GUTENTAG_DEBUG"===t.type?null==t?void 0:t.value:e},classicTemplate:function(e,t){switch(t.type){case"SET_PAGE":case"SET_PAGE_CONTENT":return{...e,id:null==t?void 0:t.classicTemplateId}}return e},listViewPanel:function(e=!1,t){switch(t.type){case"OPEN_NAVIGATION_PANEL_TO_MENU":return!1;case"SET_IS_NAVIGATION_PANEL_OPENED":return!t.isOpen&&e;case"SET_IS_INSERTER_OPENED":return!t.value&&e;case"SET_IS_LIST_VIEW_OPENED":return t.isOpen}return e},aiInfo:function(e={remainingCredits:0},t){return"UPDATE_AI_INFO"===t.type?(0,_.merge)(e,(0,_.cloneDeep)(t.value||{})):e},isChangingPage:function(e=!1,t){return"SET_PAGE"===t.type&&(e=!!t.changingPage),e}}),{fetch:Vv}=window,{select:Kv,dispatch:$v}=l.controls;function qv(e){return{type:"TOGGLE_FEATURE",feature:e}}function Yv(e){return{type:"SET_PREVIEW_DEVICE_TYPE",deviceType:e}}function*Zv(e,t,o=!1){const n={templateSlug:t};if(!t){const t=yield l.controls.resolveSelect("core","getEntityRecord","postType","wp_template",e);n.templateSlug=null==t?void 0:t.slug}return{type:"SET_TEMPLATE",templateId:e,page:{context:o?{}:n}}}function*Xv(e){const t=yield l.controls.dispatch("core","saveEntityRecord","postType","wp_template",e);return{type:"SET_TEMPLATE",templateId:t.id,page:{context:{templateSlug:t.slug}}}}function*Jv(e){yield(0,Gv.apiFetch)({path:`/wp/v2/templates/${e}`,method:"DELETE"});const t=yield l.controls.select(y.STORE_KEY,"getPage");yield l.controls.dispatch(y.STORE_KEY,"setPage",t)}function Qv(e){return{type:"SET_TEMPLATE_PART",templatePartId:e}}function ey(e){return{type:"SET_HOME_TEMPLATE",homeTemplateId:e}}function*ty(e,t,o=!0){var n;if(null===e)return{type:"SET_PAGE",page:null,templateId:null,changingPage:!0};if(!e.path&&null!==(n=e.context)&&void 0!==n&&n.postId){const t=yield l.controls.resolveSelect("core","getEntityRecord","postType",e.context.postType||"post",e.context.postId);e.path=(0,zo.getPathAndQueryString)(t.link)}if(!o)return void(yield{type:"SET_PAGE_CONTENT",page:e,classicTemplateId:""!==t?t:"page.php"});let i;if(!t&&o){const t=(0,zo.addQueryArgs)(e.path,{_:Date.now()});try{const e=yield(0,Gv.apiFetch)({url:(0,zo.addQueryArgs)(t,{"_wp-find-template":!0})});i=null==e?void 0:e.data}catch(e){console.error(e)}if(!i)return void(yield{type:"SET_PAGE",page:e,templateId:null})}const r=t||i,{id:a,slug:s}=r;return yield{type:"SET_PAGE",page:s?{...e,context:{...e.context,templateSlug:s}}:e,templateId:a},a}function*oy(){const{show_on_front:e,page_on_front:t}=yield l.controls.resolveSelect("core","getEntityRecord","root","site"),{siteUrl:o}=yield l.controls.select(y.STORE_KEY,"getSettings"),n={path:o,context:"page"===e?{postType:"page",postId:t}:{}},i=yield*ty(n);if(!i)return{type:"GUTENTAG_NO_ACTION"};yield ey(i)}function ny(e){return{type:"OPEN_NAVIGATION_PANEL_TO_MENU",menu:e}}function iy(e){return{type:"SET_IS_NAVIGATION_PANEL_OPENED",isOpen:e}}function ry(e){return{type:"UPDATE_SETTINGS",settings:e}}function*ay(e){return yield $v("core/interface","enableComplementaryArea",`${y.STORE_KEY}/sidebars`,`${y.STORE_KEY}/sidebar/${e}`)}function*sy(){return yield $v("core/interface","enableComplementaryArea",`${y.STORE_KEY}/sidebars`,`${y.STORE_KEY}/sidebar/block-inserter`)}function*ly({areaIdentifier:e,sidebar:t}){return{type:"ADD_SUBSIDEBAR",sidebar:t,areaIdentifier:e}}function*cy({areaIdentifier:e}){return{type:"REMOVE_SUBSIDEBAR",areaIdentifier:e}}function*uy(){yield $v("core/interface","disableComplementaryArea",`${y.STORE_KEY}/sidebars`)}function*dy(e,t=null){return{type:"TOGGLE_GLOBAL_STYLE_EDITING",value:e,previousEntity:t}}function*py(e){return{type:"TOGGLE_GUTENTAG_DEBUG",value:e}}function*hy(e,t=!1,o={}){return{type:"TOGGLE_IS_INSERTER_OPEN",value:e,rootClientId:t||!1,options:{closeOnSelect:!1,replace:!1,...o}}}function my(e){return{type:"SET_CURRENT_ANCESTOR",currentAncestor:e}}function gy(e){return{type:"SET_IS_LIST_VIEW_OPENED",isOpen:e}}function fy(e){return{type:"UPDATE_UI_VERSION",version:e}}function by(e){return{type:"UPDATE_EDITOR_MODE",value:e}}function _y(e){return{type:"TOGGLE_AI_CAPABILITIES",value:e}}function vy(e){return{type:"UPDATE_AI_INFO",value:e}}function yy(e){return{type:"UPDATE_EXCLUDED_SECTION_CATEGORIES",value:e}}function ky({path:e,value:t}){return{type:"UPDATE_FLAG_SETTINGS",path:e,value:t}}var xy,Sy;function wy(e){return[e]}function Cy(e){return!!e&&"object"==typeof e}function Iy(){var e={clear:function(){e.head=null}};return e}function jy(e,t,o){var n;if(e.length!==t.length)return!1;for(n=o;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ty(e,t){var o,n;function i(){o=Sy?new WeakMap:Iy()}function r(){var o,i,r,a,s,l=arguments.length;for(a=new Array(l),r=0;r<l;r++)a[r]=arguments[r];for(s=t.apply(null,a),(o=n(s)).isUniqueByDependants||(o.lastDependants&&!jy(s,o.lastDependants,0)&&o.clear(),o.lastDependants=s),i=o.head;i;){if(jy(i.args,a,1))return i!==o.head&&(i.prev.next=i.next,i.next&&(i.next.prev=i.prev),i.next=o.head,i.prev=null,o.head.prev=i,o.head=i),i.val;i=i.next}return i={val:e.apply(null,a)},a[0]=null,i.args=a,o.head&&(o.head.prev=i,i.next=o.head),o.head=i,i.val}return t||(t=wy),n=Sy?function(e){var t,n,i,r,a=o,s=!0;for(t=0;t<e.length;t++){if(!Cy(n=e[t])){s=!1;break}a.has(n)?a=a.get(n):(i=new WeakMap,a.set(n,i),a=i)}return a.has(xy)||((r=Iy()).isUniqueByDependants=s,a.set(xy,r)),a.get(xy)}:function(){return o},r.getDependants=t,r.clear=i,i(),r}xy={},Sy="undefined"!=typeof WeakMap;const Py=Object.values(s.defaultTemplatesByPostType).map((e=>`${e}.php`));function Ey(e,t){return"fullscreenMode"===t||"fixedToolbar"!==t&&(0,_.get)(e.preferences.features,[t],!1)}function Ry(e){return e.deviceType}const Ay=(0,l.createRegistrySelector)((e=>()=>e("core").canUser("create","media"))),Oy=Ty(((e,t)=>{const o={...e.settings,outlineMode:!0,focusMode:Ey(e,"focusMode"),hasFixedToolbar:Ey(e,"fixedToolbar"),__experimentalSetIsInserterOpened:t};return Ay(e)?(o.mediaUpload=({onError:t,...o})=>{(0,e_.uploadMedia)({wpAllowedMimeTypes:e.settings.allowedMimeTypes,onError:({message:e})=>t(e),...o})},o):o}),(e=>[Ay(e),e.settings,Ey(e,"focusMode"),Ey(e,"fixedToolbar")]));function Ny(e){return e.homeTemplateId}function By(e){var t;return null===(t=e.editedPost)||void 0===t?void 0:t.type}function Dy(e){var t;return null===(t=e.editedPost)||void 0===t?void 0:t.id}function My(e){return e.editedPost.page}function Ly(e){return e.navigationPanel.isOpen}function zy(e){var t;return null===(t=e.navigationPanel)||void 0===t?void 0:t.menu}function Fy(e){return e.blockInserterPanel}function Gy(e){return e.templateId}function Hy(e){return e.templatePartId}function Uy(e){return e.templateType}function Wy(e){return e.templateIds}function Vy(e){return e.templatePartIds}function Ky(e){return e.entity}function $y(e){return e.showOnFront}const qy=(0,l.createRegistrySelector)((e=>(t,o=null)=>{const n=e("core/interface").getActiveComplementaryArea(`${y.STORE_KEY}/sidebars`);return o?n===`${y.STORE_KEY}/sidebar/${o}`:!(0,_.isEmpty)(n)}));function Yy(e){var t;return null===(t=e.openedInserter)||void 0===t?void 0:t.value}function Zy(e){var t;return null===(t=e.openedInserter)||void 0===t?void 0:t.clientId}function Xy(e){var t,o;return!(null===(t=e.openedInserter)||void 0===t||null===(o=t.options)||void 0===o||!o.replace)}function Jy(e){var t,o;return!(null===(t=e.openedInserter)||void 0===t||null===(o=t.options)||void 0===o||!o.closeOnSelect)}function Qy(e){return e.currentAncestor}function ek(){return(0,l.select)("core/interface").getActiveComplementaryArea(`${y.STORE_KEY}/sidebars`)}function tk(e){return e.subSidebars}function ok(e){return e.globalStyleEditing.value}function nk(e){return e.globalStyleEditing.previousEntity}function ik(e){return e.isGutentagDebug}function rk(e){const{rootClientId:t,insertionIndex:o}=e.blockInserterPanel;return{rootClientId:t,insertionIndex:o}}function ak(e){return e.listViewPanel}const sk=e=>{var t;const{templateId:o,templateType:n}=e;return o&&n&&(null===(t=(0,l.select)("core").getEditedEntityRecord("postType",n,o))||void 0===t?void 0:t.kubio_template_source)||null},lk=e=>{var t;const o=null==e||null===(t=e.page)||void 0===t?void 0:t.context;let n=null;var i,r,a;n=null!=o&&o.postType&&null!=o&&o.postId?o.templateSlug?o.templateSlug:null!==(i=(0,l.select)("core").getEditedEntityRecord("postType",null==o?void 0:o.postType,null==o?void 0:o.postId).template)&&void 0!==i?i:null:null!==(r=null===(a=e.templateId)||void 0===a?void 0:a.split("//").pop())&&void 0!==r?r:null;const s=(0,l.select)("core").getEditedEntityRecord("root","site");if("page"===s.show_on_front&&s.page_on_front===parseInt(null==o?void 0:o.postId)){const e=((0,l.select)("core").getEntityRecords("postType","wp_template",{per_page:-1})||[]).map((({id:e})=>e.split("//").pop())).includes("front-page"),{classicHasFrontPageTemplate:t}=(0,l.select)("core/block-editor").getSettings();if(e||t)return"front-page"}return""===n&&(n="page"===(null==o?void 0:o.postType)?"page":"single"),n},ck=e=>{const t=lk(e),o=(0,l.select)("core").getEntityRecords("postType","wp_template",{per_page:-1});return!!t&&(o||[]).map((({id:e})=>e.split("//").pop())).includes(t)},uk=e=>{var t;const o=null==e||null===(t=e.page)||void 0===t?void 0:t.context;return(null==o?void 0:o.postType)||null},dk=e=>{var t;const o=null==e||null===(t=e.page)||void 0===t?void 0:t.context;return(null==o?void 0:o.postId)||null},pk=e=>{var t;const o=null==e||null===(t=e.page)||void 0===t?void 0:t.context,n=(0,l.select)("core").getEditedEntityRecord("root","site"),i=null==n?void 0:n.page_for_posts;return parseInt(i)===parseInt(null==o?void 0:o.postId)},hk=e=>{var t,o;const n=My(e),i="front-page"===(null==n||null===(t=n.context)||void 0===t?void 0:t.templateSlug),r=(0,l.select)("core").getEditedEntityRecord("root","site"),a=null==r?void 0:r.page_on_front,s=null==n||null===(o=n.context)||void 0===o?void 0:o.postId,c="page"===r.show_on_front&&parseInt(a)===parseInt(s);return i||c},mk=e=>{const t=(0,l.select)("core").getEditedEntityRecord("root","site"),o=My(e),n=v().get(o,"context",{}),{postType:i,postId:r}=n,a="page"===(null==t?void 0:t.show_on_front),s=null==t?void 0:t.page_on_front,c=a&&parseInt(s)===parseInt(r),u=a&&parseInt(null==t?void 0:t.page_for_posts)===parseInt(r);return"page"===i&&!u&&!c},gk=()=>{var e,t;const o=(null===(e=(0,l.select)("core").getEntityRecords("postType","wp_template",{per_page:-1}))||void 0===e?void 0:e.filter((({slug:e})=>(0,s.currentTemplateIsPage)(e))))||[],n=(null===(t=(0,l.select)("core/block-editor").getSettings())||void 0===t?void 0:t.classicThemeTemplates)||[],i=o.map((({title:e,slug:t,kubio_template_source:o="custom"})=>({value:t,label:"kubio"===o?e.rendered.replace("Kubio","").trim():e.rendered,source:o})));return Object.keys(n).forEach((e=>{const t=n[e];(0,_.find)(o,{slug:e.replace(".php","")})||i.push({value:Py.includes(e)?e.replace(".php",""):e,label:t,isClassicTemplate:!0,source:"theme"})})),i.forEach((e=>{"page"===e.value&&(e.value="")})),v().sortBy(i,["source","label"])};function fk(e){var t;return null==e||null===(t=e.classicTemplate)||void 0===t?void 0:t.id}function bk(e){var t,o;const n=My(e),i=v().get(n,"context",{}),{postType:r,postId:a}=i,s=null===(t=(0,l.select)("core/block-editor").getSettings())||void 0===t||null===(o=t.kubioBasicWooCommerce)||void 0===o?void 0:o.pagesIds;return"product"===r||Object.values(s||{}).includes(parseInt(a))}const _k=Ty((e=>{var t;const o=null===(t=e.settings)||void 0===t?void 0:t.kubioGlobalSettings;return(null==o?void 0:o.editorUIVersion)||1}),(e=>[e.settings])),vk=Ty((e=>{var t;const o=null===(t=e.settings)||void 0===t?void 0:t.kubioGlobalSettings;return(null==o?void 0:o.enableAICapabilities)||!1}),(e=>[e.settings])),yk=Ty((e=>{var t;return null===(t=e.settings)||void 0===t||t.kubioGlobalSettings,"full"}),(e=>[e.settings])),kk=e=>(yk(e),!1),xk=e=>e.aiInfo||{remainingCredits:0,isStub:!0},Sk=e=>!0===e.isChangingPage;function wk(e){return e.canvasMode}const Ck=e=>{var t,o;return(null===(t=e.settings)||void 0===t||null===(o=t.kubioGlobalSettings)||void 0===o?void 0:o.excludedSectionCategories)||[]},Ik={reducer:Wv,actions:i,selectors:r,controls:Gv.controls,persist:["preferences"]};async function jk(e){return(0,l.registerStore)(Le,{...Ik,initialState:e})}const Tk=(0,u.forwardRef)((({menuItems:e,toggleButton:t,onClose:o,onOpen:n,popoverProps:i,className:r},a)=>{const[s,l]=(0,u.useState)(!1),c=(0,u.useCallback)((e=>{l(e),e?null==n||n():null==o||o()}),[l,n,o]),d=(0,u.useRef)();return(0,u.useImperativeHandle)(a,(()=>({getPopupIsVisible:()=>s}))),(0,g.jsx)(ut.DropdownWithHover,{className:X()("kubio-dropdown-with-hover__section-options",r),ref:d,onToggle:c,toggleElement:t,popoverProps:{className:"kubio-ai-design-section-button__dropdown__popup",...i},children:(0,g.jsx)(Pk,{dropdownRef:d,menuItems:e})})})),Pk=({dropdownRef:e,menuItems:t})=>{const o=v().get(e,["current","onClose"],v().noop);return(0,g.jsx)(h.MenuGroup,{children:t.map((({label:e,description:t,icon:n,onClick:i,className:r,isPro:a,urlArgs:s,...l},c)=>{const u=a?Ge.ProItem:h.MenuItem;return(0,J.createElement)(u,{...s,tag:h.MenuItem,key:c,onClick:async()=>{await i(),o()},...l},(0,g.jsxs)("div",{className:X()("kubio-ai-design-section-button__dropdown",r),children:[(0,g.jsx)("div",{className:"kubio-ai-design-section-button__dropdown__icon",children:(0,g.jsx)(h.Icon,{icon:n})}),(0,g.jsxs)("div",{className:"kubio-ai-design-section-button__dropdown__content",children:[(0,g.jsx)("div",{className:"kubio-ai-design-section-button__dropdown__content__label",children:e}),(0,g.jsx)("div",{className:"kubio-ai-design-section-button__dropdown__content__description",children:t})]})]}))}))})},Ek=({setVisible:e,sectionRef:t,onChangeSection:o,askForSummary:n=!0,isNewSection:i=!1})=>{var r,a,s,l;const{replaceDesign:c,replaceContent:d,dataHelper:p}=j_(),[f,b]=(0,u.useState)((()=>i?"":p.getAttribute("kubioAI.meta.summary",""))),_=(0,u.useRef)(!1),v=(0,u.useCallback)((async o=>{if(e(!1),!_.current)try{var n;switch(_.current=!0,null===(n=t.current)||void 0===n?void 0:n.type){case"surprise":await c(null,{summary:o,currentSectionCloudId:p.getAttribute("kubioAI.meta.cloudPresetId","")});break;case"regenerate":await d({summary:o});break;case"hand-pick":await t.current.insert(t.current.pattern,o)}}catch(e){Ko.Log.error("Generate section modal error",e)}finally{_.current=!1}}),[t,e,c,d]),y=(0,u.useCallback)((()=>v(f)),[v,f]);return(0,u.useEffect)((()=>{if(!n){const e=p.getAttribute("kubioAI.meta.summary","");v(e)}}),[v,p,n]),n?(0,g.jsx)(h.Modal,{className:"kubio-ai-wizard-modal kubio-generate-ai-section auto",title:(0,g.jsxs)(h.Flex,{children:[(0,g.jsxs)(h.FlexBlock,{className:"kubio-ai-wizard-modal__title",children:[(0,g.jsx)(h.Icon,{icon:He.KubioAI,className:"kubio-ai-logo-colored kubio-ai-logo-animated"}),"hand-pick"===(null===(r=t.current)||void 0===r?void 0:r.type)?(0,m.__)("Generate new section AI","kubio"):(0,m.__)("Regenerate content","kubio")]}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Button,{onClick:()=>e(!1),icon:Ve,label:(0,m.__)("Close","kubio")})})]}),isDismissible:!1,onRequestClose:()=>{},shouldCloseOnClickOutside:!1,children:(0,g.jsxs)(h.Flex,{className:"kubio-generate-ai-section__content",align:"normal",children:[(0,g.jsx)(h.Flex,{className:"kubio-generate-ai-section__content__section-preview",justify:"center",children:(0,g.jsx)("div",{className:X()("section-preview-image-wrapper",(null===(a=t.current)||void 0===a?void 0:a.pattern)&&"ai-hand-picked-section"),children:(0,g.jsx)("img",{src:null!==(s=t.current)&&void 0!==s&&s.pattern?t.current.pattern.screenshot:(0,T.staticAssetURL)("ai-assets/placeholder.png"),alt:"placeholder"})})}),(0,g.jsxs)(h.Flex,{className:"kubio-generate-ai-section__content__summary-wrapper",direction:"column",gap:3.75,children:[(0,g.jsx)(ut.TextareaControl,{label:(0,m.__)("Write a brief description to Kubio AI about the new section's content.","kubio"),className:X()("kubio-ai-summary-field"),value:f,onChange:b,rows:6}),(0,g.jsxs)(h.Flex,{justify:"flex-end",gap:2.5,children:["hand-pick"===(null===(l=t.current)||void 0===l?void 0:l.type)&&(0,g.jsx)(h.Button,{className:"kubio-ai-change-section",onClick:o,children:(0,m.__)("Change section","kubio")}),(0,g.jsx)(h.Button,{className:"kubio-ai-button",onClick:y,children:(0,m.__)("Generate","kubio")})]})]})]})}):(0,g.jsx)(g.Fragment,{})},Rk=({sectionClientId:e,insertBefore:t=!0,shouldUseSectionClientId:o=!1,aiIntermediateCallback:n=null})=>{const{newSectionIndex:i,parentClientId:r}=(0,l.useSelect)((n=>{const{getBlockIndex:i,getBlockRootClientId:r,getBlockOrder:a}=n("core/block-editor"),s=r(e);let l=i(e);return t||l++,o&&(l=a(e).length),{newSectionIndex:l,parentClientId:o?e:s}}),[e]),{insertBlock:a,replaceBlocks:c,selectBlock:d}=(0,l.useDispatch)("core/block-editor"),{ownerDocument:p}=(0,s.useOwnerDocumentContext)(),[{pageContext:h,siteContext:m,pageTitle:g}]=(0,S.useAIData)();return{onGenerateAiSection:(0,u.useCallback)((({onCallback:e}={})=>{let t=async(t,o="")=>{const n=(0,T.kubioCloneDeep)(t.content),s=(0,T.transformTemplateToBlock)(n);await a(s,i,r,!0),p.defaultView.requestIdleCallback((async()=>{const i=(0,S.initGenerationSession)();p_(p,s.clientId,!0,!0);try{await xs({pageContext:h,siteContext:m,pageTitle:g,clientId:s.clientId,sectionCategory:t.categories.at(0).replace("kubio-content/",""),replaceBlocks:c,selectBlock:d,summary:o},n)}catch(e){throw e}finally{p_(p,s.clientId,!0,!1),null==e||e()}i()}))};if(n){const e=t;t=t=>n(t,e)}const o={page:"sections",disabledPages:["starterSite","pages"],sections:{internalTag:y.AI_READY_TAG,categoryType:"kubio-content",onActionFunc:t}};(0,T.onOpenTemplateGalleryWithParams)(o)}),[n,a,i,p,h,g,r,c,d,m]),onInsertNormalSection:(0,u.useCallback)((()=>{const e={page:"sections",disabledPages:["starterSite","pages"],sections:{categoryType:"kubio-content",onActionFunc:async e=>{const t=(0,T.kubioCloneDeep)(e.content);let o=(0,T.transformTemplateToBlock)(t);const{anchor:n,name:s}=(0,T.getNextSectionNameAndIdForPattern)(e);o=v().merge({},o,{attributes:{anchor:n,attrs:{name:s}}}),await a(o,i,r,!0)}}};(0,T.onOpenTemplateGalleryWithParams)(e)}),[a,i,r])}},Ak=(0,u.forwardRef)(((e,t)=>{const{sectionClientId:o,disabled:n,insertBefore:i=!0,blockTitle:r,hasSingleBlockType:a,dropdownRef:s,onDropdownClose:c,onDropdownOpen:d,onActionStarted:p,onActionEnded:f,...b}=e,_=a?(0,m.sprintf)(// translators: %s: the name of the block when there is only one
// translators: %s: the name of the block when there is only one
(0,m.__)("Add %s","kubio"),r):(0,m.__)("Add block","kubio"),v=(0,u.useRef)(),[k,x]=(0,u.useState)(!1),S=(0,u.useCallback)(((e,t)=>{v.current={type:"hand-pick",pattern:e,insert:t},x(!0)}),[]),{onGenerateAiSection:w,onInsertNormalSection:C}=Rk({sectionClientId:o,insertBefore:i,aiIntermediateCallback:S}),[I,j]=Do(),P=(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[]),E=(0,u.useCallback)(((...e)=>{null==p||p(),j((()=>w({onCallback:()=>{null==f||f()}})))}),[j,w,p,f]),R=(0,u.useCallback)((()=>{x(!1),E()}),[E]),A=(0,u.useMemo)((()=>[P?{label:(0,m.__)("Generate a new AI section","kubio"),description:(0,m.__)("Choose a section and let Kubio AI generate your content.","kubio"),icon:He.KubioAI,isPro:!0,urlArgs:{source:"AI",content:"generate-new-ai-section"},isProItem:T.AI_IN_PRO,onClick:E}:null,{label:(0,m.__)("Select from templates gallery","kubio"),description:(0,m.__)("Choose a section and write your content.","kubio"),icon:He.PredesignedLayoutsIcon,onClick:C,className:"kubio-select-from-template-gallery-button"}].filter(Boolean)),[P,E,C]),O=(0,g.jsx)("div",{className:"kubio-between-sections-inserter__container",children:(0,g.jsx)(h.Button,{ref:t,icon:$e,label:_,isPrimary:!0,tooltipPosition:"bottom",className:"kubio-between-sections-inserter","aria-haspopup":!1,"aria-expanded":!1,disabled:n,...b,children:(0,m.__)("Add section","kubio")})});return(0,g.jsxs)(g.Fragment,{children:[I,k&&(0,g.jsx)(Ek,{setVisible:x,sectionRef:v,onChangeSection:R,askForSummary:!0,isNewSection:!0}),(0,g.jsx)(Tk,{menuItems:A,toggleButton:O,ref:s,onClose:c,onOpen:d,popoverProps:{position:"bottom"}})]})}));(0,d.addFilter)("kubio.BetweenSectionsInserter","BetweenSectionsInserter",(()=>Ak));const Ok=(0,u.createContext)({}),Nk=()=>(0,u.useContext)(Ok),Bk={imageSearch:{slug:"AI-IMAGE-SEARCH",label:(0,m.__)("AI Image","kubio")},imageGenerate:{slug:"AI-IMAGE-GENERATE",label:(0,m.__)("AI Image","kubio")}},Dk={generate:"GENERATE"},Mk=e=>{const t=Object.keys(Bk).filter((t=>Bk[t].slug===e));return t.length>0?Bk[t[0]].label:(0,m.__)("AI Image Editor","kubio")},Lk=({classNames:e,children:t})=>(0,g.jsx)("div",{className:X()("kubio-ai-image-editor-sidebar",e),children:t}),zk=({children:e,classes:t=""})=>(0,g.jsx)("div",{className:`kubio-ai-image-editor-content ${t}`,children:e}),Fk=({image:e,grid:t=4})=>{const{onSelectImageAction:o,editImageAction:n}=Nk();return(0,g.jsxs)("div",{className:X()("kubio-ai-image-generator-single-image",`kubio-ai-single-image-grid-${t}`),children:[(0,g.jsx)("img",{src:e.filename,alt:""}),(0,g.jsxs)("div",{className:"kubio-ai-image-overlay",children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-button",variant:"primary",onClick:()=>{o(e.filename)},children:(0,m.__)("Use this image","kubio")}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action",onClick:()=>{n(e)},children:(0,m.__)("Edit","kubio")})]})]})},Gk=({generatedImages:e,totalImages:t})=>(0,g.jsx)(g.Fragment,{children:e&&e.map(((e,o)=>(0,g.jsx)(Fk,{image:e,grid:t},o)))}),Hk=({label:e,onClick:t,isBusy:o,disabled:n,loadingMessage:i,infoMessage:r,variant:a="primary"})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-sidebar-button",onClick:t,isBusy:o,disabled:n,variant:a,__experimentalIsFocusable:!0,children:e}),i&&o&&(0,g.jsx)("p",{className:"kubio-ai-info kubio-ai-info-loading",children:i}),r&&!o&&(0,g.jsx)("p",{className:"kubio-ai-info",children:r})]}),Uk=((0,m.__)("3D Model","kubio"),(0,m.__)("Analog Film","kubio"),(0,m.__)("Anime","kubio"),(0,m.__)("Cinematic","kubio"),(0,m.__)("Comic Book","kubio"),(0,m.__)("Digital Art","kubio"),(0,m.__)("Enhance","kubio"),(0,m.__)("Fantasy Art","kubio"),(0,m.__)("Isometric","kubio"),(0,m.__)("Line Art","kubio"),(0,m.__)("Low Poly","kubio"),(0,m.__)("Modeling Compound","kubio"),(0,m.__)("Neon Punk","kubio"),(0,m.__)("Origami","kubio"),(0,m.__)("Photographic","kubio"),(0,m.__)("Pixel Art","kubio"),(0,m.__)("Tile Texture","kubio"),()=>(0,T.getBackendData)("aiSDImageTypes",{})),Wk=()=>(0,T.getBackendData)("aiSDImageStyles",{}),Vk=[{label:(0,m.__)("Square (1024x1024)","kubio"),value:"1024x1024"},{label:(0,m.__)("Landscape (1152x896)","kubio"),value:"1152x896"},{label:(0,m.__)("Wide Landscape (1216x832)","kubio"),value:"1216x832"},{label:(0,m.__)("Panoramic (1344x768)","kubio"),value:"1344x768"},{label:(0,m.__)("Tall portrait (768x1344)","kubio"),value:"768x1344"},{label:(0,m.__)("Portrait (832x1216)","kubio"),value:"832x1216"},{label:(0,m.__)("Compact portrait (896x1152)","kubio"),value:"896x1152"}],Kk=()=>{const[e,t]=(0,u.useState)(!1),{imagePrompt:o,setImagePrompt:n,isGenerating:i,setIsGenerating:r,initialImage:a,saveGeneratedImages:s,setEditorSection:l,aspectRatio:c,setAspectRatio:d,imageStyle:p,setImageStyle:f,imageType:b,setImageType:v,imageSize:y,numberOfImages:k,setNumberOfImages:x,setImageSizeFromOptions:S,aiCreditsPerImageCost:w}=Nk(),C=(0,u.useMemo)((()=>(0,_.map)(Uk(),((e,t)=>({label:e,value:t})))),[]),I=(0,u.useMemo)((()=>{const e=Wk(),t={},o={value:"",label:(0,m.__)("None","kubio")};return Object.keys(e).forEach((n=>{t[n]=(0,_.map)(e[n],((e,t)=>({label:e,value:t}))),t[n].unshift(o)})),t}),[]);(0,u.useEffect)((()=>{var e;t(null!==(e=I[b])&&void 0!==e?e:"")}),[I,C,b]);const j=(0,u.useCallback)((async()=>!1),[c,b,o,y,p,a,i,k,l,s,r]);return(0,g.jsxs)("div",{className:"kubio-ai-sidebar-controls",children:[(0,g.jsx)("p",{className:"kubio-ai-info",children:(0,m.__)("Experiment with the latest generative AI and let your imagination define your images.","kubio")}),(0,g.jsx)(h.TextareaControl,{onChange:n,value:o,label:(0,m.__)("Image Description","kubio"),useDebounce:!1}),(0,g.jsx)(h.RangeControl,{label:(0,m.__)("Samples","kubio"),value:k,min:1,max:4,initialPosition:1,withInputField:!0,onChange:x,className:"kubio-ai-range-with-help",help:(0,m.sprintf)(/* translators: %s is replaced with the number of credits */ /* translators: %s is replaced with the number of credits */(0,m.__)("More samples will multiply the cost. Estimated cost: %s credits.","kubio"),w*k)}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Size","kubio"),inlineLabel:!1,value:c,options:Vk,onChange:e=>{d(e),S(e)},size:"__unstable-large"}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Image type","kubio"),inlineLabel:!1,value:b,options:C,onChange:e=>{var o;v(e),f(""),t(null!==(o=I[e])&&void 0!==o&&o)},size:"__unstable-large"}),!1!==e&&(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Image style","kubio"),inlineLabel:!1,value:p,options:e,onChange:f,size:"__unstable-large",disabled:!1===e}),(0,g.jsx)(Hk,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-sidebar-button",onClick:j,isBusy:i,disabled:i||0===o.length,variant:"primary",label:(0,m.__)("Generate image","kubio"),loadingMessage:(0,m.__)("Please wait, this may take a few minutes.","kubio"),infoMessage:(0,m.__)("All generated images will be saved in the Media Library.","kubio")})]})},$k=(0,Ge.isFreeVersion)()?Ge.proBadgeClasses.proItem:"",qk=(0,Ge.isFreeVersion)()?`${Ge.proBadgeClasses.proItem}-wrapper`:"",Yk=()=>(0,Ge.isFreeVersion)()?(0,g.jsx)("span",{className:Ge.proBadgeClasses.badgeClass,children:(0,m.__)("PRO","kubio")}):null,Zk=()=>{const{editorTab:e,setEditorTab:t,backToSection:o}=Nk();return(0,T.getBackendData)("showFreeImagesTab")?(0,g.jsx)(g.Fragment,{}):(0,g.jsxs)("div",{className:"kubio-ai-image-editor-menu",children:[(0,g.jsx)(h.Button,{onClick:()=>{t(Bk.imageSearch.slug),o(Dk.imageSearch)},className:e===Bk.imageSearch.slug?"kubio-ai-button-tab":"",children:(0,m.__)("Search","kubio")}),(0,g.jsxs)(h.Button,{onClick:()=>{t(Bk.imageGenerate.slug),o(Dk.generate)},className:e===Bk.imageGenerate.slug?"kubio-ai-button-tab":"",children:[(0,m.__)("Generate","kubio"),(0,g.jsx)(Yk,{})]})]})},Xk=()=>(0,g.jsxs)("div",{className:"kubio-ai-image-results-empty",children:[(0,g.jsx)(h.Icon,{icon:He.GenerateImageIcon}),(0,g.jsx)("p",{children:(0,m.__)("Your results will appear here.","kubio")})]}),Jk=({grid:e=4,placeholderImage:t=!1})=>(0,g.jsx)("div",{className:X()("kubio-ai-image-generator-single-image",`kubio-ai-single-image-grid-${e}`),children:t&&(0,g.jsx)("img",{src:t,alt:"",className:"kubio-ai-placeholder-image"})}),Qk=({urlArgs:e})=>{const t=(0,u.useCallback)((t=>{t.preventDefault(),(0,Ge.upgradeToPro)(e)}),[e]);return(0,g.jsxs)("div",{className:"kubio-ai-pro-popup-background ",children:[(0,g.jsxs)("div",{className:"kubio-ai-generated-images",children:[(0,g.jsx)(Jk,{}),(0,g.jsx)(Jk,{}),(0,g.jsx)(Jk,{}),(0,g.jsx)(Jk,{})]}),(0,g.jsxs)("div",{className:"kubio-ai-pro-popup",children:[(0,g.jsx)("div",{className:"kubio-ai-pro-content",children:(0,g.jsx)("h1",{children:(0,m.__)("Generate awesome images with Kubio AI","kubio")})}),(0,g.jsx)("img",{src:(0,T.staticAssetURL)("ai-assets/pro-img.png"),alt:"final-message"}),(0,g.jsxs)("div",{className:"kubio-ai-pro-content upgrade-to-pro__content",children:[(0,g.jsx)("p",{className:"kubio-ai-pro-content-lead",children:(0,m.__)("Hello there! 🌈 Did you know you can unlock a whole new world of creativity with Kubio PRO?","kubio")}),(0,g.jsxs)("ul",{className:"kubio-ai-pro-content-features",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)(h.Icon,{icon:Zi,size:16}),(0,m.__)("Generate new images by just writing a few words.","kubio")]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(h.Icon,{icon:Zi,size:16}),(0,m.__)("Create different kinds of images like paintings, 3D models, photographic, etc.","kubio")]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(h.Icon,{icon:Zi,size:16}),(0,m.__)("Easily adjust images using the generative fill feature.","kubio")]})]}),(0,g.jsx)(h.Button,{className:"btn-upgrade",onClick:t,children:(0,Ge.getStringValueWithId)("pro.upgrade.label")})]})]})]})},ex=512,tx=async e=>{const t=new Image;return t.src=e,await t.decode(),t},ox=e=>64*Math.ceil(e/64),nx=(e,t,o)=>{let n=0,i=0;return ox(e)<=ox(t)?(i=512,n=ox(i*o)):(n=ex,i=ox(n*o)),[n,i]},ix=(e,t,o)=>{const n=nx(e,t,o);if(n[0]<ex){const e=ex-n[0];n[0]=ex,n[1]=ox(ex+e)}return n},rx=({totalImages:e})=>{const{numberOfImages:t,imageSize:o}=Nk(),n=[],i=((e,t,o=0)=>{const n=document.createElement("canvas");n.width=e,n.height=t;const i=n.getContext("2d");i.fillStyle="rgba(244, 244, 247, "+o+")",i.fillRect(0,0,e,t);const r=new window.Image(e,t);return r.src=n.toDataURL(),r.src})(o[0],o[1],1);for(let o=0;o<t;o++)n.push((0,g.jsx)(Jk,{grid:e,placeholderImage:i},o));return(0,g.jsx)(g.Fragment,{children:n})},ax=({generatedImages:e,isGenerating:t,totalImages:o})=>(0,g.jsxs)("div",{className:`kubio-ai-generated-images kubio-ai-generated-images-${o}`,children:[e.length>0&&(0,g.jsx)(Gk,{generatedImages:e,totalImages:o}),t&&(0,g.jsx)(rx,{totalImages:o})]}),sx=({generatedImages:e,isGenerating:t,totalImages:o})=>(0,g.jsxs)(g.Fragment,{children:[(e.length>0||!0===t)&&(0,g.jsx)(ax,{generatedImages:e,isGenerating:t,totalImages:o}),0===e.length&&!1===t&&(0,g.jsx)(Xk,{})]}),lx={source:"ai-image-generator",content:"ai-image-generator"},cx=()=>{const{generatedImages:e,isGenerating:t,numberOfImages:o}=Nk(),n=t?o+e.length:e.length;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Lk,{classNames:`${qk}`,children:[(0,g.jsx)(Zk,{}),(0,g.jsx)(Kk,{})]}),(0,g.jsx)(zk,{classes:e.length>0||t?"":"kubio-ai-image-results-empty-wrapper",children:(0,Ge.isFreeVersion)()?(0,g.jsx)(Qk,{urlArgs:lx}):(0,g.jsx)(sx,{generatedImages:e,isGenerating:t,totalImages:n})})]})},ux=()=>{const{onSelectImageAction:e,currentSelectedImage:t}=Nk();return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)("div",{className:"kubio-ai-image-editor-img-holder",children:(0,g.jsxs)("div",{className:"kubio-ai-image-editor-si-wrapper",children:[(0,g.jsx)("span",{children:(0,g.jsx)("img",{src:t.filename,alt:""})}),(0,g.jsx)("div",{className:"kubio-ai-image-editor-action-overlay",children:(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-button",variant:"primary",onClick:()=>{e(t.filename)},children:(0,m.__)("Use this image","kubio")})})]})})})},dx=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"})}),px=()=>{const{backToSection:e}=Nk();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action kubio-ai-button-action-back",onClick:()=>{e(Dk.generate)},icon:dx,children:(0,m.__)("Generate an image","kubio")}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-edit-action kubio-ai-button-edit-action-first",onClick:()=>{e(Dk.generativeFill)},icon:(0,g.jsx)(h.Dashicon,{icon:"admin-appearance"}),children:(0,g.jsxs)("div",{className:"kubio-ai-button-edit-action-content",children:[(0,g.jsx)("h3",{children:(0,m.__)("Generative Fill","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("Use the brush to highlight an area of the image and specify the changes you want for that area.","kubio")})]})}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-edit-action",onClick:()=>{e(Dk.variations)},icon:(0,g.jsx)(h.Dashicon,{icon:"format-gallery"}),children:(0,g.jsxs)("div",{className:"kubio-ai-button-edit-action-content",children:[(0,g.jsx)("h3",{children:(0,m.__)("Variations","kubio")}),(0,g.jsx)("p",{children:(0,m.__)("Describe the changes you would like to make for the current image.","kubio")})]})})]})},hx=()=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Lk,{children:(0,g.jsx)(px,{})}),(0,g.jsx)(zk,{children:(0,g.jsx)(ux,{})})]}),mx=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"})}),gx=()=>{const{onSelectImageAction:e,backToSection:t,currentSelectedImage:o,prevImageAction:n,nextImageAction:i}=Nk();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"kubio-ai-image-editor-action-top-bar",children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action kubio-ai-button-action-back",onClick:()=>{t(Dk.generate)},icon:dx,children:(0,m.__)("Back","kubio")}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-button",variant:"primary",onClick:()=>{e(o.filename)},children:(0,m.__)("Use this image","kubio")})]}),(0,g.jsxs)("div",{className:"kubio-ai-image-editor-img-holder",children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button kubio-ai-nav kubio-ai-prev",onClick:()=>{n(o.filename)},icon:dx,children:(0,m.__)("prev","kubio")}),(0,g.jsx)("img",{src:o.filename,alt:""}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button kubio-ai-nav kubio-ai-next",onClick:()=>{i(o.filename)},icon:mx,children:(0,m.__)("next","kubio")})]})]})},fx=()=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Lk,{children:(0,g.jsx)(Kk,{})}),(0,g.jsx)(zk,{children:(0,g.jsx)(gx,{})})]}),bx=({sectionTitle:e=(0,m.__)("Variations","kubio")})=>{const[t,o]=(0,u.useState)(!1),{imagePrompt:n,setImagePrompt:i,isGenerating:r,setIsGenerating:a,initialImage:s,aspectRatio:l,imageStyle:c,setImageStyle:d,imageSize:p,setImageSize:f,numberOfImages:b,setNumberOfImages:v,addImageVariations:y,currentSelectedImage:k,backToSection:x,imageType:w,setImageType:C,aiCreditsPerImageCost:I}=Nk();(0,u.useEffect)((()=>{(async()=>{if(s){const e=await tx(s);f(((e,t,o)=>{switch(o){case"auto":return((e,t)=>[ox(e),ox(t)])(e,t);case"4/3":return nx(e,t,4/3);case"3/4":return ix(e,t,3/4);case"3/2":return nx(e,t,1.5);case"16/9":return nx(e,t,16/9);case"9/16":return ix(e,t,9/16);default:return[ex,ex]}})(e.naturalWidth,e.naturalHeight,l))}})()}),[s,l,f]);const j=(0,u.useMemo)((()=>(0,_.map)(Uk(),((e,t)=>({label:e,value:t})))),[]),T=(0,u.useMemo)((()=>{const e=Wk(),t={},o={value:"",label:(0,m.__)("None","kubio")};return Object.keys(e).forEach((n=>{t[n]=(0,_.map)(e[n],((e,t)=>({label:e,value:t}))),t[n].unshift(o)})),t}),[]);(0,u.useEffect)((()=>{var e;o(null!==(e=T[w])&&void 0!==e?e:"")}),[T,j,w]);const P=(0,u.useCallback)((async()=>{if(!r){a(!0);try{const e=await(0,S.aiImageVariations)({imagePrompt:n,currentSelectedImage:k.filename,imageSize:p,imageStyle:c,imageType:w,numberOfImages:b});e.length>0&&y(k.filename,e)}catch(e){console.log(e)}a(!1)}}),[r,a,n,k.filename,p,c,w,b,y]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action kubio-ai-button-action-back",onClick:()=>{x(Dk.edit)},icon:dx,children:(0,m.__)("Back","kubio")}),(0,g.jsxs)("div",{className:"kubio-ai-sidebar-heading",children:[(0,g.jsx)("div",{className:"kubio-ai-icon-holder",children:(0,g.jsx)(h.Dashicon,{icon:"format-gallery"})}),(0,g.jsxs)("div",{className:"kubio-ai-text-holder",children:[(0,g.jsx)("h3",{children:e}),(0,g.jsx)("p",{className:"kubio-ai-heading-info",children:(0,m.__)("Describe the changes you would like to make for the current image.","kubio")})]})]}),(0,g.jsx)(h.TextareaControl,{onChange:i,value:n,label:(0,m.__)("Description of changes","kubio"),useDebounce:!1}),(0,g.jsx)(h.RangeControl,{label:(0,m.__)("Samples","kubio"),value:b,min:1,max:4,initialPosition:1,withInputField:!0,onChange:v,className:"kubio-ai-range-with-help",help:(0,m.sprintf)(/* translators: %s is replaced with the number of credits */ /* translators: %s is replaced with the number of credits */(0,m.__)("More samples will multiply the cost. Estimated cost: %s credits.","kubio"),I*b)}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Image type","kubio"),inlineLabel:!1,value:w,options:j,onChange:e=>{var t;C(e),d(""),o(null!==(t=T[e])&&void 0!==t&&t)},size:"__unstable-large"}),!1!==t&&(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Image style","kubio"),inlineLabel:!1,value:c,options:t,onChange:d,size:"__unstable-large",disabled:!1===t}),(0,g.jsx)(Hk,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-sidebar-button",onClick:P,isBusy:r,disabled:r,variant:"primary",label:(0,m.__)("Create variations","kubio"),loadingMessage:(0,m.__)("Please wait, this may take a few minutes.","kubio"),infoMessage:(0,m.__)("All generated images will be saved in the Media Library.","kubio")})]})},vx=({grid:e=1})=>{const{currentSelectedImage:t}=Nk();return(0,g.jsx)("div",{className:X()("kubio-ai-image-generator-single-image","kubio-ai-original",`kubio-ai-single-image-grid-${e}`),"data-label":(0,m.__)("Original","kubio"),children:(0,g.jsx)("img",{src:t.filename,alt:""})})},yx=()=>{const{getImageVariations:e}=Nk(),t=e();return(0,g.jsxs)("div",{className:`kubio-ai-generated-images kubio-ai-generated-images-${t.length+1}`,children:[(0,g.jsx)(vx,{grid:t.length+1}),t.length>0&&t.map(((e,o)=>(0,g.jsx)(Fk,{image:e,grid:t.length+1},o)))]})},kx=()=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Lk,{children:(0,g.jsx)(bx,{})}),(0,g.jsx)(zk,{children:(0,g.jsx)(yx,{})})]});function xx(e,t,o,n,i,r,a){try{var s=e[r](a),l=s.value}catch(e){return void o(e)}s.done?t(l):Promise.resolve(l).then(n,i)}function Sx(){return Sx=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},Sx.apply(this,arguments)}var wx={exports:{}};!function(e){var t=function(e){var t,o=Object.prototype,n=o.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,t,o){return Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,o){return e[t]=o}}function c(e,t,o,n){var i=t&&t.prototype instanceof f?t:f,r=Object.create(i.prototype),a=new T(n||[]);return r._invoke=function(e,t,o){var n=d;return function(i,r){if(n===h)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw r;return E()}for(o.method=i,o.arg=r;;){var a=o.delegate;if(a){var s=C(a,o);if(s){if(s===g)continue;return s}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(n===d)throw n=m,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);n=h;var l=u(e,t,o);if("normal"===l.type){if(n=o.done?m:p,l.arg===g)continue;return{value:l.arg,done:o.done}}"throw"===l.type&&(n=m,o.method="throw",o.arg=l.arg)}}}(e,o,a),r}function u(e,t,o){try{return{type:"normal",arg:e.call(t,o)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",p="suspendedYield",h="executing",m="completed",g={};function f(){}function b(){}function _(){}var v={};l(v,r,(function(){return this}));var y=Object.getPrototypeOf,k=y&&y(y(P([])));k&&k!==o&&n.call(k,r)&&(v=k);var x=_.prototype=f.prototype=Object.create(v);function S(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function o(i,r,a,s){var l=u(e[i],e,r);if("throw"!==l.type){var c=l.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){o("next",e,a,s)}),(function(e){o("throw",e,a,s)})):t.resolve(d).then((function(e){c.value=e,a(c)}),(function(e){return o("throw",e,a,s)}))}s(l.arg)}var i;this._invoke=function(e,n){function r(){return new t((function(t,i){o(e,n,t,i)}))}return i=i?i.then(r,r):r()}}function C(e,o){var n=e.iterator[o.method];if(n===t){if(o.delegate=null,"throw"===o.method){if(e.iterator.return&&(o.method="return",o.arg=t,C(e,o),"throw"===o.method))return g;o.method="throw",o.arg=new TypeError("The iterator does not provide a 'throw' method")}return g}var i=u(n,e.iterator,o.arg);if("throw"===i.type)return o.method="throw",o.arg=i.arg,o.delegate=null,g;var r=i.arg;return r?r.done?(o[e.resultName]=r.value,o.next=e.nextLoc,"return"!==o.method&&(o.method="next",o.arg=t),o.delegate=null,g):r:(o.method="throw",o.arg=new TypeError("iterator result is not an object"),o.delegate=null,g)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function P(e){if(e){var o=e[r];if(o)return o.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function o(){for(;++i<e.length;)if(n.call(e,i))return o.value=e[i],o.done=!1,o;return o.value=t,o.done=!0,o};return a.next=a}}return{next:E}}function E(){return{value:t,done:!0}}return b.prototype=_,l(x,"constructor",_),l(_,"constructor",b),b.displayName=l(_,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,l(e,s,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},S(w.prototype),l(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,o,n,i,r){void 0===r&&(r=Promise);var a=new w(c(t,o,n,i),r);return e.isGeneratorFunction(o)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(x),l(x,s,"Generator"),l(x,r,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var o in e)t.push(o);return t.reverse(),function o(){for(;t.length;){var n=t.pop();if(n in e)return o.value=n,o.done=!1,o}return o.done=!0,o}},e.values=P,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var o in this)"t"===o.charAt(0)&&n.call(this,o)&&!isNaN(+o.slice(1))&&(this[o]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var o=this;function i(n,i){return s.type="throw",s.arg=e,o.next=n,i&&(o.method="next",o.arg=t),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var a=r?r.completion:{};return a.type=e,a.arg=t,r?(this.method="next",this.next=r.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.finallyLoc===e)return this.complete(o.completion,o.afterLoc),j(o),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc===e){var n=o.completion;if("throw"===n.type){var i=n.arg;j(o)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,o,n){return this.delegate={iterator:P(e),resultName:o,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(wx);var Cx=wx.exports,Ix=function(e){var t=e.paths,o=e.id,n=e.strokeWidth,i=e.strokeColor,r=e.command,a=void 0===r?Tx:r;if(1===t.length){var s=t[0],l=s.x,c=s.y,u=n/2;return J.createElement("circle",{key:o,id:o,cx:l,cy:c,r:u,stroke:i,fill:i})}var d=t.reduce((function(e,t,o,n){return 0===o?"M "+t.x+","+t.y:e+" "+a(t,o,n)}),"");return J.createElement("path",{key:o,id:o,d,fill:"none",strokeLinecap:"round",stroke:i,strokeWidth:n})},jx=function(e){var t,o,n,i,r=e.current,a=e.next,s=e.previous,l=e.reverse,c=(t=s||r,n=(o=a||r).x-t.x,i=o.y-t.y,{length:Math.sqrt(Math.pow(n,2)+Math.pow(i,2)),angle:Math.atan2(i,n)}),u=c.angle+(l?Math.PI:0),d=.2*c.length;return[r.x+Math.cos(u)*d,r.y+Math.sin(u)*d]},Tx=function(e,t,o){var n=null,i=null;switch(t){case 0:var r=jx({current:e});n=r[0],i=r[1];break;case 1:var a=jx({current:o[t-1],next:e});n=a[0],i=a[1];break;default:var s=jx({current:o[t-1],previous:o[t-2],next:e});n=s[0],i=s[1]}var l=jx({current:e,previous:o[t-1],next:o[t+1],reverse:!0});return"C "+n+","+i+" "+l[0]+","+l[1]+" "+e.x+", "+e.y},Px=function(e){var t=e.id,o=e.paths;return J.createElement(J.Fragment,null,o.map((function(e,o){return J.createElement(Ix,{key:t+"__"+o,paths:e.paths,id:t+"__"+o,strokeWidth:e.strokeWidth,strokeColor:e.strokeColor,command:Tx})})))},Ex=function(e){return new Promise((function(t,o){var n=new Image;n.addEventListener("load",(function(){n.width>0&&t(n),o("Image not found")})),n.addEventListener("error",(function(e){return o(e)})),n.src=e,n.setAttribute("crossorigin","anonymous")}))};function Rx(e){var t,o=null==(t=e.firstChild)?void 0:t.cloneNode(!0),n=e.offsetWidth,i=e.offsetHeight;return o.setAttribute("viewBox","0 0 "+n+" "+i),o.setAttribute("width",n.toString()),o.setAttribute("height",i.toString()),{svgCanvas:o,width:n,height:i}}var Ax=J.forwardRef((function(e,t){var o=e.paths,n=e.isDrawing,i=e.onPointerDown,r=e.onPointerMove,a=e.onPointerUp,s=e.id,l=void 0===s?"react-sketch-canvas":s,c=e.width,u=void 0===c?"100%":c,d=e.height,p=void 0===d?"100%":d,h=e.className,m=void 0===h?"react-sketch-canvas":h,g=e.canvasColor,f=void 0===g?"red":g,b=e.backgroundImage,_=void 0===b?"":b,v=e.exportWithBackgroundImage,y=void 0!==v&&v,k=e.preserveBackgroundImageAspectRatio,x=void 0===k?"none":k,S=e.allowOnlyPointerType,w=void 0===S?"all":S,C=e.style,I=void 0===C?{border:"0.0625rem solid #9c9c9c",borderRadius:"0.25rem"}:C,j=e.svgStyle,T=void 0===j?{}:j,P=J.useRef(null),E=function(e){var t,o,n,i=null==(t=P.current)?void 0:t.getBoundingClientRect(),r=null!=(o=window.scrollX)?o:0,a=null!=(n=window.scrollY)?n:0;return i?{x:e.pageX-i.left-r,y:e.pageY-i.top-a}:{x:0,y:0}},R=function(e){"mouse"===e.pointerType&&0!==e.button||"all"!==w&&e.pointerType!==w||a()};J.useImperativeHandle(t,(function(){return{exportImage:function(e){return new Promise(function(){var t,o=(t=Cx.mark((function t(o,n){var i,r,a,s,l,c,u,d;return Cx.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,i=P.current){t.next=4;break}throw Error("Canvas not rendered yet");case 4:return r=Rx(i),a=r.svgCanvas,s=r.width,l=r.height,c="data:image/svg+xml;base64,"+btoa(a.outerHTML),t.next=8,Ex(c);case 8:if(t.t0=t.sent,u=[t.t0],!y){t.next=21;break}return t.prev=11,t.next=14,Ex(_);case 14:d=t.sent,u.push(d),t.next=21;break;case 18:t.prev=18,t.t1=t.catch(11),console.warn("exportWithBackgroundImage props is set without a valid background image URL. This option is ignored");case 21:Promise.all(u).then((function(t){var n=document.createElement("canvas");n.setAttribute("width",s.toString()),n.setAttribute("height",l.toString());var i=n.getContext("2d");if(!i)throw Error("Canvas not rendered yet");t.reverse().forEach((function(e){i.drawImage(e,0,0)})),o(n.toDataURL("image/"+e))})).catch((function(e){throw e})),t.next=27;break;case 24:t.prev=24,t.t2=t.catch(0),n(t.t2);case 27:case"end":return t.stop()}}),t,null,[[0,24],[11,18]])})),function(){var e=this,o=arguments;return new Promise((function(n,i){var r=t.apply(e,o);function a(e){xx(r,n,i,a,s,"next",e)}function s(e){xx(r,n,i,a,s,"throw",e)}a(void 0)}))});return function(_x,e){return o.apply(this,arguments)}}())},exportSvg:function(){return new Promise((function(e,t){try{var o,n=null!=(o=P.current)?o:null;if(null!==n){var i,r,a=Rx(n).svgCanvas;if(y)return void e(a.outerHTML);null==(i=a.querySelector("#"+l+"__background"))||i.remove(),null==(r=a.querySelector("#"+l+"__canvas-background"))||r.setAttribute("fill",f),e(a.outerHTML)}t(new Error("Canvas not loaded"))}catch(e){t(e)}}))}}})),J.useEffect((function(){return document.addEventListener("pointerup",R),function(){document.removeEventListener("pointerup",R)}}),[R]);var A=o.filter((function(e){return!e.drawMode})),O=0,N=o.reduce((function(e,t){return t.drawMode?(void 0===e[O]&&(e[O]=[]),e[O].push(t),e):(O+=1,e)}),[[]]);return J.createElement("div",{role:"presentation",ref:P,className:m,style:Sx({touchAction:"none",width:u,height:p},I),"touch-action":"none",onPointerDown:function(e){if(!("all"!==w&&e.pointerType!==w||"mouse"===e.pointerType&&0!==e.button)){var t=E(e);i(t)}},onPointerMove:function(e){if(n&&("all"===w||e.pointerType===w)){var t=E(e);r(t)}},onPointerUp:R},J.createElement("svg",{version:"1.1",baseProfile:"full",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",style:Sx({width:"100%",height:"100%"},T),id:l},J.createElement("g",{id:l+"__eraser-stroke-group",display:"none"},J.createElement("rect",{id:l+"__mask-background",x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),A.map((function(e,t){return J.createElement(Ix,{key:l+"__eraser-"+t,id:l+"__eraser-"+t,paths:e.paths,strokeColor:"#000000",strokeWidth:e.strokeWidth})}))),J.createElement("defs",null,_&&J.createElement("pattern",{id:l+"__background",x:"0",y:"0",width:"100%",height:"100%",patternUnits:"userSpaceOnUse"},J.createElement("image",{x:"0",y:"0",width:"100%",height:"100%",xlinkHref:_,preserveAspectRatio:x})),A.map((function(e,t){return J.createElement("mask",{id:l+"__eraser-mask-"+t,key:l+"__eraser-mask-"+t,maskUnits:"userSpaceOnUse"},J.createElement("use",{href:"#"+l+"__mask-background"}),Array.from({length:A.length-t},(function(e,o){return o+t})).map((function(e){return J.createElement("use",{key:e.toString(),href:"#"+l+"__eraser-"+e.toString()})})))}))),J.createElement("g",{id:l+"__canvas-background-group"},J.createElement("rect",{id:l+"__canvas-background",x:"0",y:"0",width:"100%",height:"100%",fill:_?"url(#"+l+"__background)":f})),N.map((function(e,t){return J.createElement("g",{id:l+"__stroke-group-"+t,key:l+"__stroke-group-"+t,mask:"url(#"+l+"__eraser-mask-"+t+")"},J.createElement(Px,{id:l,paths:e}))}))))})),Ox=J.forwardRef((function(e,t){var o=e.id,n=void 0===o?"react-sketch-canvas":o,i=e.width,r=void 0===i?"100%":i,a=e.height,s=void 0===a?"100%":a,l=e.className,c=void 0===l?"":l,u=e.canvasColor,d=void 0===u?"white":u,p=e.strokeColor,h=void 0===p?"red":p,m=e.backgroundImage,g=void 0===m?"":m,f=e.exportWithBackgroundImage,b=void 0!==f&&f,_=e.preserveBackgroundImageAspectRatio,v=void 0===_?"none":_,y=e.strokeWidth,k=void 0===y?4:y,x=e.eraserWidth,S=void 0===x?8:x,w=e.allowOnlyPointerType,C=void 0===w?"all":w,I=e.style,j=void 0===I?{border:"0.0625rem solid #9c9c9c",borderRadius:"0.25rem"}:I,T=e.svgStyle,P=void 0===T?{}:T,E=e.onChange,R=void 0===E?function(e){}:E,A=e.onStroke,O=void 0===A?function(e,t){}:A,N=e.withTimestamp,B=void 0!==N&&N,D=J.createRef(),M=J.useState(!0),L=M[0],z=M[1],F=J.useState(!1),G=F[0],H=F[1],U=J.useState([]),W=U[0],V=U[1],K=J.useState([]),$=K[0],q=K[1],Y=J.useState([]),Z=Y[0],X=Y[1],Q=J.useCallback((function(){var e,t,o=null!=(e=null==(t=Z.slice(-1))?void 0:t[0])?e:null;null!==o?O(o,!o.drawMode):console.warn("No stroke found!")}),[G]);return J.useEffect((function(){Q()}),[G]),J.useEffect((function(){R(Z)}),[Z]),J.useImperativeHandle(t,(function(){return{eraseMode:function(e){z(!e)},clearCanvas:function(){V([].concat(Z)),X([])},undo:function(){if(0!==W.length)return X([].concat(W)),void V([]);q((function(e){return[].concat(e,Z.slice(-1))})),X((function(e){return e.slice(0,-1)}))},redo:function(){0!==$.length&&(X((function(e){return[].concat(e,$.slice(-1))})),q((function(e){return e.slice(0,-1)})))},exportImage:function(e){var t,o=null==(t=D.current)?void 0:t.exportImage;if(o)return o(e);throw Error("Export function called before canvas loaded")},exportSvg:function(){return new Promise((function(e,t){var o,n=null==(o=D.current)?void 0:o.exportSvg;n?n().then((function(t){e(t)})).catch((function(e){t(e)})):t(Error("Export function called before canvas loaded"))}))},exportPaths:function(){return new Promise((function(e,t){try{e(Z)}catch(e){t(e)}}))},loadPaths:function(e){X((function(t){return[].concat(t,e)}))},getSketchingTime:function(){return new Promise((function(e,t){B||t(new Error("Set 'withTimestamp' prop to get sketching time"));try{e(Z.reduce((function(e,t){var o,n,i=null!=(o=t.startTimestamp)?o:0;return e+((null!=(n=t.endTimestamp)?n:0)-i)}),0))}catch(e){t(e)}}))},resetCanvas:function(){V([]),q([]),X([])}}})),J.createElement(Ax,{ref:D,id:n,width:r,height:s,className:c,canvasColor:d,backgroundImage:g,exportWithBackgroundImage:b,preserveBackgroundImageAspectRatio:v,allowOnlyPointerType:C,style:j,svgStyle:P,paths:Z,isDrawing:G,onPointerDown:function(e){H(!0),q([]);var t={drawMode:L,strokeColor:L?h:"#000000",strokeWidth:L?k:S,paths:[e]};B&&(t=Sx({},t,{startTimestamp:Date.now(),endTimestamp:0})),X((function(e){return[].concat(e,[t])}))},onPointerMove:function(e){if(G){var t=Z.slice(-1)[0],o=Sx({},t,{paths:[].concat(t.paths,[e])});X((function(e){return[].concat(e.slice(0,-1),[o])}))}},onPointerUp:function(){var e,t;if(G&&(H(!1),B)){var o=null!=(e=null==(t=Z.slice(-1))?void 0:t[0])?e:null;if(null!==o){var n=Sx({},o,{endTimestamp:Date.now()});X((function(e){return[].concat(e.slice(0,-1),[n])}))}}}})}));const Nx=(0,u.createContext)({}),Bx=()=>(0,u.useContext)(Nx),Dx={canRedo:!1,canUndo:!1,cursor:0,queue:[],images:[]},Mx={REDO:"redo",UNDO:"undo",INSERT:"insert"},Lx=(e,t)=>{let o=0;const n=e.images.length-1,i=(e,t=!1)=>({canUndo:e>0,canRedo:!1===t&&e<n});switch(t.type){case Mx.UNDO:return o=e.cursor>0?e.cursor-1:0,t.setCurrentSelectedImage(e.images[o]),{...e,...i(o),cursor:o};case Mx.REDO:return o=e.cursor<n?e.cursor+1:n,t.setCurrentSelectedImage(e.images[o]),{...e,...i(o),cursor:o};case Mx.INSERT:const r=e.images,a=r.length>1&&e.cursor>0?r.slice(0,e.cursor):r;return a.push(t.image),o=a.length-1,t.setCurrentSelectedImage(t.image),{...e,images:a,...i(o,a.length),cursor:o}}return e},zx=[{key:20,name:"20",className:"kubio-ai-stroke-option kubio-ai-stroke-20"},{key:30,name:"30",className:"kubio-ai-stroke-option kubio-ai-stroke-30"},{key:40,name:"40",className:"kubio-ai-stroke-option kubio-ai-stroke-40"},{key:50,name:"50",className:"kubio-ai-stroke-option kubio-ai-stroke-50"}],Fx=()=>{const{undoImageAction:e,redoImageAction:t,setStrokeSize:o,strokeSize:n,paintActions:i,resetCanvasAction:r,imageActions:a}=Bx(),{onSelectImageAction:s,currentSelectedImage:l}=Nk();return(0,g.jsx)("div",{className:"kubio-image-editor-mask-editor-toolbar",children:(0,g.jsxs)("div",{className:"kubio-image-editor-toolbar-buttons",children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action",onClick:e,icon:Nf,disabled:!a.canUndo,showTooltip:!0,title:(0,m.__)("Undo","kubio"),iconSize:24}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action",onClick:t,icon:Rf,disabled:!a.canRedo,showTooltip:!0,title:(0,m.__)("Redo","kubio"),iconSize:24}),(0,g.jsx)("div",{className:"kubio-ai-h-divider"}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action kubio-ai-button-action-revert",onClick:r,icon:He.EraserIcon,disabled:!i.isDirty,showTooltip:!0,title:(0,m.__)("Clear drawing","kubio"),iconSize:16}),(0,g.jsx)(h.CustomSelectControl,{__nextUnconstrainedWidth:!0,hideLabelFromVision:!0,label:"Stroke Size",options:zx,onChange:({selectedItem:e})=>{o(e.key)},value:zx.find((e=>e.key===n))}),(0,g.jsx)("div",{className:"kubio-ai-h-divider"}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-button",variant:"primary",onClick:()=>{s(l.filename)},children:(0,m.__)("Use this image","kubio")})]})})},Gx=(e={})=>{const{radius:t=30}=e,o=btoa(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="${t}" height="${t}">\n <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z" fill-opacity="0.7" />\n </svg>`),n=Math.floor(t/2)+1;return{cursor:`url("data:image/svg+xml;base64,${o}") ${n} ${n}, auto`,borderRadius:"100%"}},Hx=()=>{const{currentSelectedImage:e}=Nk(),{setImageSize:t,imageSize:o,strokeSize:n,canvasRef:i,onStrokeAction:r}=Bx(),[a,s]=(0,u.useState)(Gx({radius:n})),[l,c]=(0,u.useState)([o[0],Math.min(512,o[1])]);(0,u.useEffect)((()=>{(async()=>{if(e){const o=await tx(e.filename);t([o.naturalWidth,o.naturalHeight])}})()}),[e.filename]),(0,u.useEffect)((()=>{const e=Math.min(550,o[1]),t=Math.round(o[0]*(e/o[1]));c([t,e])}),[o]),(0,u.useEffect)((()=>{s(Gx({radius:n}))}),[n]);const d=(0,u.useRef)();return(0,u.useEffect)((()=>{if(!d.current)return;const e=new window.MutationObserver((function(){const e=d.current.querySelector("#react-sketch-canvas__stroke-group-0");null==e||e.removeAttribute("mask")}));return e.observe(d.current,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[d.current]),(0,g.jsx)("div",{className:"kubio-ai-image-generative-editor",ref:d,children:o[0]>0&&l[0]>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ox,{ref:i,width:l[0],height:l[1],strokeWidth:n,className:"kubio-ai-generative-editor",strokeColor:"black",backgroundImage:e.filename,canvasColor:"white",exportWithBackgroundImage:!1,style:a,onStroke:r}),(0,g.jsx)(Fx,{})]})})},Ux=()=>(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(Hx,{})}),Wx=()=>{const[e,t]=(0,u.useState)(""),o=(0,u.useRef)(!1),{backToSection:n,isGenerating:i,setIsGenerating:r,currentSelectedImage:a,addImageVersion:s,setCurrentSelectedImage:l}=Nk(),{exportSketchImage:c,resetCanvasAction:d,addGeneratedImageToQueue:p}=Bx();(0,u.useEffect)((()=>{p(a)}),[]);const f=(0,u.useCallback)((async()=>{if(!i){r(!0);try{const t=await(0,S.aiImageMask)({imagePrompt:e,currentSelectedImage:a.filename,maskImage:await c()});if(""!==t){const e=s(t[0]);!1===o.current&&(o.current=e.currentImage),p(e.newImage),d()}}catch(e){console.log(e)}r(!1)}}),[i,r,e,a,c,s,d,p]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action kubio-ai-button-action-back",onClick:()=>{!1!==o.current&&l(o.current),n("EDIT")},icon:dx,children:(0,m.__)("Back","kubio")}),(0,g.jsxs)("div",{className:"kubio-ai-sidebar-heading",children:[(0,g.jsx)("div",{className:"kubio-ai-icon-holder",children:(0,g.jsx)(h.Dashicon,{icon:"admin-appearance"})}),(0,g.jsxs)("div",{className:"kubio-ai-text-holder",children:[(0,g.jsx)("h3",{children:(0,m.__)("Generative Fill","kubio")}),(0,g.jsx)("p",{className:"kubio-ai-heading-info",children:(0,m.__)("Use the brush to highlight an area of the image and specify the changes you want for that area.","kubio")})]})]}),(0,g.jsx)(h.TextareaControl,{onChange:t,value:e,label:(0,m.__)("Description of changes","kubio"),useDebounce:!1}),(0,g.jsx)(Hk,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-sidebar-button",onClick:f,isBusy:i,disabled:i,variant:"primary",label:(0,m.__)("Generate fill","kubio"),loadingMessage:(0,m.__)("Please wait, this may take a few minutes.","kubio"),infoMessage:(0,m.__)("All generated images will be saved in the Media Library.","kubio")})]})},Vx=()=>{const e=(()=>{const{setCurrentSelectedImage:e}=Nk(),t={undo:!1,redo:!1,isDirty:!1,images:[]},o=(0,u.useRef)(!1),[n,i]=(0,u.useState)(30),[r,a]=(0,u.useState)([0,0]),[s,l]=(0,u.useState)(!1),[c,d]=(0,u.useState)(Dx),[p,h]=(0,u.useState)(!1),[m,g]=(0,u.useState)(t),[f,b]=(0,u.useReducer)(Lx,Dx),_=()=>{g({undo:c.cursor>-1,redo:c.cursor<c.queue.length-1,isDirty:!0})},v=e=>{const t=c;t.cursor=t.cursor+e,d((()=>t)),_()},y=()=>{d(Dx),g(t)};return{canvasRef:o,resetCanvasAction:()=>{y(),o.current.resetCanvas()},redoAction:()=>{v(1),o.current.redo()},undoAction:()=>{v(-1),o.current.undo()},strokeSize:n,setStrokeSize:i,exportSketchImage:async()=>{const e=await o.current.exportImage("png"),t=document.createElement("canvas");t.width=r[0],t.height=r[1];const n=t.getContext("2d");n.clearRect(0,0,t.width,t.height),n.fillStyle="white",n.fillRect(0,0,t.width,t.height);const i=new window.Image;return i.src=e,await i.decode(),n.drawImage(i,0,0,r[0],r[1]),t.toDataURL()},imageSize:r,setImageSize:a,onStrokeAction:()=>{if(!1===p)return void h(!0);const e=c;let t=e.queue;e.cursor=e.cursor>=-1?e.cursor+1:-1,e.cursor>-1&&(t=e.queue.slice(0,e.cursor)),t.push(1),e.queue=t,d(e),_(),h(!1)},paintActions:m,newImageGenerated:s,setNewImageGenerated:l,resetPaintQueue:y,clearCanvasAction:()=>{v(-1),o.current.clearCanvas()},undoImageAction:()=>{b({type:Mx.UNDO,setCurrentSelectedImage:e})},redoImageAction:()=>{b({type:Mx.REDO,setCurrentSelectedImage:e})},imageActions:f,addGeneratedImageToQueue:t=>{b({type:Mx.INSERT,setCurrentSelectedImage:e,image:t})},imageActionsDispatch:b,IMAGE_ACTIONS:Mx}})();return(0,g.jsxs)(Nx.Provider,{value:e,children:[(0,g.jsx)(Lk,{children:(0,g.jsx)(Wx,{})}),(0,g.jsx)(zk,{children:(0,g.jsx)(Ux,{})})]})},Kx=(0,u.createContext)({}),$x=()=>(0,u.useContext)(Kx),qx={imagePrompt:"",imageSize:"medium",imageOrientation:"original",aiPrompt:"",initialSearch:!1},Yx=()=>(0,g.jsxs)("div",{className:"kubio-ai-image-results-empty",children:[(0,g.jsx)(h.Icon,{icon:He.SearchImageIcon}),(0,g.jsx)("p",{children:(0,m.__)("Your search results will appear here.","kubio")})]}),Zx=({image:e,saveImage:t,canSave:o})=>{const{isGenerating:n}=Nk();return(0,g.jsxs)("div",{className:"kubio-ai-image-generator-single-image",children:[(0,g.jsx)("img",{src:e["src.medium"],alt:""}),(0,g.jsxs)("div",{className:"kubio-ai-image-overlay",children:[(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-button",variant:"primary",isBusy:n,disabled:n,onClick:()=>{t(e.url,!0)},children:(0,m.__)("Use this image","kubio")}),(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button-action",onClick:()=>{t(e.url)},disabled:!o,isBusy:n,children:o?(0,m.__)("Save for later","kubio"):(0,m.__)("Saved","kubio")})]})]})},Xx=()=>{const e=(0,u.useRef)(),{foundImages:t,foundImagePages:o,galleryPage:n,searchForImages:i,isSearching:r,savedImages:a,saveImage:s,imageSearchOptions:l}=$x(),{isGenerating:c,setIsGenerating:d,onSelectImageAction:p}=Nk(),[f,b]=(0,u.useState)(!1);(0,u.useEffect)((()=>{b(n<o)}),[o,n]);const _=(0,u.useCallback)((async(e,t=!1)=>{if(c||a.has(e)){const o=a.get(e);t&&p(o.url,l.aiPrompt,o.id)}d(!0);try{const o=await(0,S.aiSearchedImageSave)({selectedImage:e});""!==o&&(s(e,o.url,o.id),t&&p(o.url,l.aiPrompt,o.id))}catch(e){console.log(e)}d(!1)}),[l.aiPrompt,c,p,s,a,d]);return(0,g.jsxs)("div",{className:"kubio-ai-generated-images--infinite-list",ref:e,children:[(0,g.jsx)("div",{className:"kubio-ai-search-images ",children:t.map(((e,t)=>(0,g.jsx)(Zx,{image:e,saveImage:_,canSave:!a.has(e.url)},t)))}),f&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"kubio-ai-more",children:(0,g.jsx)(h.Button,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-load-more-button",variant:"primary",onClick:i,isBusy:r,disabled:r,children:(0,m.__)("Get more images","kubio")})}),(0,g.jsx)("p",{className:"kubio-by-pexels",dangerouslySetInnerHTML:{__html:(0,m.sprintf)(// translators: %s is the url to pexels
// translators: %s is the url to pexels
(0,m.__)("The media items like photos and videos are provided by %s","kubio"),"<a href='https://www.pexels.com/' target='_blank'>Pexels</a>")}})]})]})},Jx=[{value:"large",label:(0,m.__)("Large","kubio")},{value:"medium",label:(0,m.__)("Medium","kubio")},{value:"small",label:(0,m.__)("Small","kubio")},{value:"tiny",label:(0,m.__)("Tiny","kubio")}],Qx=[{value:"landscape",label:(0,m.__)("Landscape","kubio")},{value:"portrait",label:(0,m.__)("Portrait","kubio")},{value:"square",label:(0,m.__)("Square","kubio")},{value:"original",label:(0,m.__)("Same as current image","kubio")}],eS=()=>{const{imageSearchOptions:e,setSearchOption:t,isSearching:o,setIsSearching:n,searchForImages:i}=$x(),{isInitialSearch:r,setIsInitialSearch:a,initialPromptText:s,initialImage:l}=Nk();return(0,u.useEffect)((()=>{(async()=>{const o=await(async e=>{if(!e)return"landscape";const t=await tx(e),o=t.width/t.height;switch(!0){case 1===o:return"square";case o>1:return"landscape";case o<1:return"portrait"}return"original"})(l);t("imageOrientation",o),!1===r&&""!==e.aiPrompt&&(n(!0),i(!1),a(!0),s.current="")})()}),[l]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{className:"kubio-ai-info",children:(0,m.__)("Easily search for free images from Pexels. Just type an image description and Kubio AI will extract search terms to find relevant images.","kubio")}),(0,g.jsx)(h.TextareaControl,{onChange:e=>{t("imagePrompt",e)},value:e.imagePrompt,label:(0,m.__)("Image Description","kubio"),useDebounce:!1}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Image Orientation","kubio"),inlineLabel:!1,value:e.imageOrientation,options:Qx,onChange:e=>{t("imageOrientation",e)},size:"__unstable-large"}),(0,g.jsx)(ut.GutentagSelectControl,{label:(0,m.__)("Saved image size","kubio"),inlineLabel:!1,value:e.imageSize,options:Jx,onChange:e=>{t("imageSize",e)},size:"__unstable-large"}),(0,g.jsx)(Hk,{className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-img-sidebar-button",onClick:()=>{n(!0),i(!0)},isBusy:o,disabled:o||0===e.imagePrompt.length,variant:"primary",label:(0,m.__)("Search image","kubio"),loadingMessage:(0,m.__)("Please wait, this may take a few minutes.","kubio")})]})},tS=()=>{const{foundImagePages:e}=$x();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Lk,{children:[(0,g.jsx)(Zk,{}),(0,g.jsx)(eS,{})]}),(0,g.jsx)(zk,{classes:"kubio-ai-image-editor-content-search",children:e>0?(0,g.jsx)(Xx,{}):(0,g.jsx)(Yx,{})})]})},oS=()=>{const e=Nk(),{editorSection:t,editorTab:o,closeModal:n}=e,i=(()=>{const{initialImage:e,initialPromptText:t}=Nk(),[o,n]=(0,u.useState)(!1),[i,r]=(0,u.useState)([]),[a,s]=(0,u.useState)(1),[l,c]=(0,u.useState)(0),[d,p]=(0,u.useState)(new Map),[h,m]=(0,u.useState)({...qx,imagePrompt:t.current,aiPrompt:t.current}),g=(e,t)=>{m((o=>(o[e]=t,{...o})))},f=(e,t=!1)=>{s(e.page+1),c(e.total_pages),r(!0===t?null==e?void 0:e.items:t=>t.concat(null==e?void 0:e.items))},b=(0,u.useCallback)((async(t=!1)=>{if(!o){n(!0);try{const o=await(0,S.aiSearchImages)({initialImage:e,page:a,search:h.imagePrompt,imageSize:h.imageSize,imageOrientation:h.imageOrientation,aiPrompt:t?"":h.aiPrompt});o&&(f(o,t),o.ai_query&&g("aiPrompt",o.ai_query))}catch(e){console.log(e)}n(!1)}}),[o,e,a,h.imagePrompt,h.imageSize,h.imageOrientation,h.aiPrompt]);return{imageSearchOptions:h,setSearchOption:g,isSearching:o,setIsSearching:n,setImageGallery:f,foundImages:i,galleryPage:a,foundImagePages:l,searchForImages:b,savedImages:d,setSavedImages:p,saveImage:(e,t,o=0)=>{p(d.set(e,{url:t,id:o}))}}})();return(0,g.jsx)(Kx.Provider,{value:i,children:(0,g.jsx)(h.Modal,{className:"kubio-ai-image-editor kubio-ai-wizard-modal",overlayClassName:"kubio-ai-close-modal",title:(0,g.jsxs)(h.Flex,{children:[(0,g.jsxs)(h.FlexBlock,{className:"kubio-ai-wizard-modal__title",children:[(0,g.jsx)(h.Icon,{icon:He.KubioAI,className:"kubio-ai-logo-colored kubio-ai-logo-animated"}),Mk(o)]}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Button,{onClick:n,icon:Ve,label:(0,m.__)("Close","kubio")})})]}),isDismissible:!1,children:(0,g.jsxs)("div",{className:X()("kubio-ai-image-editor-wrapper",$k),children:[o===Bk.imageGenerate.slug&&(0,g.jsxs)(g.Fragment,{children:[t===Dk.generate&&(0,g.jsx)(cx,{}),t===Dk.edit&&(0,g.jsx)(hx,{}),t===Dk.view&&(0,g.jsx)(fx,{}),t===Dk.generativeFill&&(0,g.jsx)(Vx,{}),t===Dk.variations&&(0,g.jsx)(kx,{})]}),o===Bk.imageSearch.slug&&(0,g.jsx)(g.Fragment,{children:t===Dk.imageSearch&&(0,g.jsx)(tS,{})})]})})})},nS=({onClose:e,onSelectImage:t,initialImage:o,initialPrompt:n})=>{const i=((e="",t="",o,n)=>{const i=(0,T.getBackendData)("showFreeImagesTab"),[r,a]=(0,u.useState)(i?Dk.generate:Dk.imageSearch),[s,l]=(0,u.useState)(i?Bk.imageGenerate.slug:Bk.imageSearch.slug),[c,d]=(0,u.useState)(""),[p,h]=(0,u.useState)(!1),[m,g]=(0,u.useState)(e),[f,b]=(0,u.useState)(),[_,v]=(0,u.useState)([]),[y,k]=(0,u.useState)(1),[x,w]=(0,u.useState)("1024x1024"),[C,I]=(0,u.useState)(""),[j,P]=(0,u.useState)("photographic"),[E,R]=(0,u.useState)([1024,1024]),A=(0,u.useRef)(t),[O,N]=(0,u.useState)(!1),B=n,[D]=(0,S.useAIServiceInfo)(),{aiImageCost:M=150}=D,L=(e,t="filename")=>_.findIndex((o=>o[t]===e)),z=(e,t={isVariation:!1,isVersion:!1})=>({filename:e,...t});return{editorSection:r,setEditorSection:a,imagePrompt:c,setImagePrompt:d,isGenerating:p,setIsGenerating:h,initialImage:m,setInitialImage:g,generatedImages:_,setGeneratedImages:v,onSelectImageAction:(e,t="",i=0)=>{o(e,t,i),n()},editImageAction:e=>{b(e),a(Dk.edit)},viewImageAction:e=>{b(e),a(Dk.view)},currentSelectedImage:f,setCurrentSelectedImage:b,backToSection:e=>{a(e)},prevImageAction:e=>{const t=L(e);-1!==t&&b(0===t?_[_.length-1]:_[t-1])},nextImageAction:e=>{const t=L(e);-1!==t&&(t===_.length-1?b(_[0]):b(_[t+1]))},aspectRatio:x,setAspectRatio:w,imageStyle:C,setImageStyle:I,imageSize:E,setImageSize:R,numberOfImages:y,setNumberOfImages:k,replaceWithEditedImage:e=>{const t=L(f.filename);if(t>-1){const o=_[t];o.filename=e,b(o),v((e=>(e[t]=o,[...e])))}},saveGeneratedImages:e=>{const t=_;e.forEach((e=>{t.push(z(e))})),v(t)},addImageVariations:(e,t)=>{const o=_;return t.forEach((t=>{o.push(z(t,{isVariation:e}))})),o},getImageVariations:()=>_.filter((e=>e.isVariation===f.filename)),saveNewImage:e=>{const t=z(e);return v((e=>[...e,t])),t},imageType:j,setImageType:P,editorTab:s,setEditorTab:l,setImageSizeFromOptions:e=>{const t=e.split("x");R([t[0],t[1]])},addImageVersion:e=>{const t=_,o=z(e,{isVersion:f.filename});t.push(o);const n={newImage:o,currentImage:f};return v(t),b(o),n},getPreviousImageVersion:()=>{const e=_.find((e=>e.filename===f.filename));if(e){const t=_.find((t=>t.filename===e.isVersion));t&&b(t)}},closeModal:B,initialPromptText:A,isInitialSearch:O,setIsInitialSearch:N,aiCreditsPerImageCost:M}})(o,n,t,e),{getAIInfo:r=_.noop}=(0,l.select)(y.STORE_KEY)||{},{remainingCredits:a=0}=r()||{},s=a>0;return s||(0,d.doAction)("kubio.ai.zero_credits"),(0,g.jsx)(Ok.Provider,{value:i,children:s&&(0,g.jsx)(oS,{})})},iS=({initialImage:e,onChange:t,isSmallButton:o=!1,initialPrompt:n})=>{const i=(0,u.useRef)(),[r,a]=(0,u.useState)(""),[s,l]=Do(),c=(0,u.useCallback)((()=>{l((()=>{a((e=>!e))}))}),[l]);return(0,g.jsxs)(g.Fragment,{children:[s,(0,g.jsx)(Ge.ProItem,{isProItem:T.AI_IN_PRO,tag:h.Button,ref:i,isSmall:o,className:"kubio-popover-options-button__options-item kubio-popover-options-icon kubio-ai-button",onClick:c,icon:He.KubioAI,urlArgs:{source:"AI",content:"ai-image"}}),r&&(0,g.jsx)(nS,{className:"kubio-options-popover",anchor:i.current,onClose:()=>a(!1),onSelectImage:t,initialImage:e,initialPrompt:n})]})},{MULTIPLE_IMAGES:rS,IMAGE:aS}=(0,We.getNamesOfBlocks)(),sS=[rS,aS],lS=({value:e,onChange:t,onlyImages:o=!0,onClose:n})=>{const i=(0,u.useRef)(),[r,a]=(0,u.useState)(!1),[c,d]=Do(),{dataHelper:p}=(0,s.useKubioBlockContext)(),f=p.options.clientId,b=(0,u.useCallback)((()=>{d((()=>{a((e=>!e))}))}),[d]),{insertBlock:_}=(0,l.useDispatch)("core/block-editor"),v=(0,u.useCallback)(((o,i,r=0)=>{const a={url:o,id:r,caption:i,alt:""};if(e)return n(),void t(a);const s=p.withChildren(),l=s[s.length-1],c=(0,lt.createBlock)(l.block.name);c.attributes={url:o,id:r,caption:i},_(c,s.length,f,!0),k()}),[e,p,_,f,n,t]),k=()=>{a((e=>!e))},x=(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[]);if(!o)return(0,g.jsx)(g.Fragment,{});const S=e?(0,m.__)("Replace with AI","kubio"):(0,m.__)("Add with AI","kubio");return(0,g.jsxs)(g.Fragment,{children:[c,x&&(0,g.jsx)(Ge.ProItem,{isProItem:T.AI_IN_PRO,tag:h.MenuItem,ref:i,onClick:b,icon:He.KubioAI,urlArgs:{source:"AI",content:"ai-image"},children:S}),r&&(0,g.jsx)(nS,{className:"kubio-options-popover",anchor:i.current,onClose:k,onSelectImage:v,initialImage:e})]})},cS=(0,p.createHigherOrderComponent)((e=>t=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(lS,{...t}),(0,g.jsx)(e,{...t})]})),"withImageToolbar");(0,d.addFilter)("kubio.blockEditor.mediaReplaceFlow.afterUploadComponent","kubio.control.ImageToolbar",cS,4);const uS=({value:e,BlockEdit:t,...o})=>{const[n,i]=Do(),r=(0,u.useRef)(),a=(0,u.useRef)(""),[l,c]=(0,u.useState)(!1),{dataHelper:d}=(0,s.useKubioBlockContext)(),p=d.getContextProp("activeImageId"),f=d.withChildren(),b=(0,_.get)(d,["localData","kubioAI","imageTerms"])||"",v=(0,u.useCallback)((()=>{i((()=>{c((e=>!e))}))}),[i]);return(0,u.useEffect)((()=>{d.blockName===aS&&(a.current=d.getAttribute("url"))}),[d]),(0,g.jsxs)(g.Fragment,{children:[n,(0,g.jsx)(I.BlockControls,{children:(0,g.jsx)(h.ToolbarGroup,{className:"kubio-toolbar-text-ai",children:(0,g.jsx)(Ge.ProItem,{isProItem:T.AI_IN_PRO,tag:h.ToolbarButton,name:"kubio-ai",icon:He.KubioAI,title:(0,m.__)("Kubio AI","kubio"),className:"kubio-toolbar-text-ai",onClick:v})})}),l&&(0,g.jsx)(nS,{className:"kubio-options-popover",anchor:r.current,onClose:()=>c(!1),onSelectImage:async e=>{if(d.blockName===aS)return d.setAttribute("url",e),void d.setAttribute("id",0);const t=f.find((e=>e.clientId===p)),o=await(async e=>{const t=await tx(e);return t.width/t.height})(e);t&&(t.setAttribute("url",e),t.setAttribute("id",0),t.setAttribute("aspectRatio",o))},initialImage:a.current,initialPrompt:b}),(0,g.jsx)(t,{...o})]})},dS=(0,p.createHigherOrderComponent)((e=>t=>{const{name:o}=t;return(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[])&&sS.includes(o)?(0,g.jsx)(uS,{BlockEdit:e,...t}):(0,g.jsx)(e,{...t})}),"withKubioAIToolbarControls");(0,d.addFilter)("editor.BlockEdit","kubio/ai/with-toolbar-controls",dS,4);const pS=(0,p.createHigherOrderComponent)((e=>t=>{const{dataHelper:o}=(0,s.useKubioBlockContext)(),n=(0,T.getBackendData)("showFreeImagesTab");if(!o||n)return(0,g.jsx)(e,{...t});const i=(0,_.get)(o,["localData","kubioAI","imageTerms"])||"",[r,a]=y_(o.clientId),c=(0,u.useCallback)((({url:e,type:t,onChange:n})=>"image"!==t?(0,g.jsx)(g.Fragment,{}):(0,g.jsx)(iS,{isGenerating:r,setIsGenerating:a,initialImage:e,onChange:(e,t="")=>{n({url:e,id:"",caption:t}),(0,_.set)(o,["localData","kubioAI","imageTerms"],t)},initialPrompt:i})),[r,a,i,o]),d=(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[]),p=t.hideAIImageButton||!1;return(0,g.jsx)(e,{...t,secondaryButton:d&&!p?c:void 0})}),"withAIImageControls");(0,d.addFilter)("kubio.control.media-picker","kubio/control/ai-media-picker",pS,4);const{HERO:hS,HEADER:mS,NAVIGATION:gS}=(0,We.getNamesOfBlocks)(),fS=(0,p.createHigherOrderComponent)((e=>t=>{var o,n,i,r,a;const{replaceDesignFromGallery:s}=j_(),[c,p,f]=Do(),[b,v]=(0,u.useState)(!1),k=(0,u.useRef)(null),x=(0,u.useCallback)((()=>{k.current={type:"surprise"},v(!0)}),[]),S=(0,u.useCallback)((()=>{k.current={type:"regenerate"},v(!0)}),[k]),w=(0,u.useCallback)((()=>{s(((e,t)=>{k.current={type:"hand-pick",pattern:e,insert:t},v(!0)}))}),[s,k]),C=(0,u.useMemo)((()=>[{label:(0,m.__)("Surprise me","kubio"),description:(0,m.__)("Kubio AI chooses a section and writes the content for you.","kubio"),icon:He.KubioAI,onClick:x},{label:(0,m.__)("Hand pick a design","kubio"),description:(0,m.__)("You choose a section, Kubio AI writes your content.","kubio"),icon:He.PredesignedLayoutsIcon,onClick:w},{label:(0,m.__)("Regenerate content","kubio"),description:(0,m.__)("Kubio AI will keep the same design but regenerate the text and images.","kubio"),icon:He.RegenerateContentIcon,onClick:S}]),[x,w,S]),I=null==t||null===(o=t.dataHelper)||void 0===o?void 0:o.blockName,j=null==t||null===(n=t.dataHelper)||void 0===n?void 0:n.clientId,P=(0,u.useMemo)((()=>{const{getBlock:e}=(0,l.select)("core/block-editor"),t=e(j);return!!(0,T.findBlockByName)(t,"core/post-content")}),[j]),{isUnlocked:E,templatePartWithSidebar:R}=bS({clientId:j}),{isEditingTemplatePart:A}=(0,l.useSelect)((e=>{const{getEditedPostType:t,getEditedPostId:o}=e("kubio/edit-site")||{};return{isEditingTemplatePart:"wp_template_part"===t()}}),[]);let O=!1;const N=null==t||null===(i=t.dataHelper)||void 0===i||null===(r=i.getAttribute)||void 0===r?void 0:r.call(i,"kubioAI.meta.summary","");"regenerate"===(null===(a=k.current)||void 0===a?void 0:a.type)?O=!0:[hS,mS,gS].includes(I)||(O=!N);const B=(0,u.useCallback)((({buttonBaseClass:e})=>{if(!(0,d.applyFilters)("kubio.section-ai-options.showRegenerateButton",!0,I)||A||P)return(0,g.jsx)(g.Fragment,{});const t=!f||!E||T.AI_IN_PRO||R,o=(0,g.jsx)(Ge.ProItem,{isProItem:T.AI_IN_PRO,urlArgs:{source:"AI",content:"regenerate-design"},tag:h.Button,className:`${e} kubio-ai-design-section-button kubio-ai-button`,icon:He.KubioAI,label:(0,m.__)("Regenerate design","kubio"),onClick:E?p:_.noop,children:(0,m.__)("Regenerate","kubio")});return(0,g.jsxs)(g.Fragment,{children:[t&&o,!t&&(0,g.jsx)(Tk,{menuItems:C,toggleButton:o,className:"kubio-dropdown-with-hover__section-options--ai"})]})}),[I,f,E,R,p,C]),D=(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[]);return(0,g.jsxs)(g.Fragment,{children:[c,b&&(0,g.jsx)(Ek,{setVisible:v,sectionRef:k,onChangeSection:()=>{v(!1),w()},askForSummary:O}),(0,g.jsx)(e,{...t,beforeSettingsButton:D?B:void 0})]})}),"withSectionHoverControls"),bS=({clientId:e})=>{const{templatePartArea:t,templatePartWithSidebar:o}=(0,l.useSelect)((t=>{const{getBlockRootClientId:o,getBlock:n}=t("core/block-editor"),i=n(o(e)),r=n(e),a=(0,T.findBlockByName)(r,"core/post-content"),s=(0,T.findBlockByName)(r,"kubio/sidebar"),l=void 0!==a&&void 0!==s;return{templatePartArea:v().get({"kubio/header":"header","kubio/footer":"footer","kubio/sidebar":"sidebar"},null==i?void 0:i.name,!1),templatePartWithSidebar:l}}),[]);let{isUnlocked:n}=(0,s.useTemplatePartLock)(t);return t||(n=!0),{isUnlocked:n,templatePartWithSidebar:o}};(0,d.addFilter)("kubio.components.section-hover-options","kubio/control/section-hover-controls",fS,4);const _S=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M5 11.25h14v1.5H5z"})}),vS=(0,g.jsx)(Q.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)(Q.Path,{d:"M7 16.5h10V15H7v1.5zm0-9V9h10V7.5H7z"})}),yS=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M6.13 5.5l1.926 1.927A4.975 4.975 0 007.025 10H5v1.5h2V13H5v1.5h2.1a5.002 5.002 0 009.8 0H19V13h-2v-1.5h2V10h-2.025a4.979 4.979 0 00-1.167-2.74l1.76-1.76-1.061-1.06-1.834 1.834A4.977 4.977 0 0012 5.5c-1.062 0-2.046.33-2.855.895L7.19 4.44 6.13 5.5zm2.37 5v3a3.5 3.5 0 107 0v-3a3.5 3.5 0 10-7 0z",fillRule:"evenodd",clipRule:"evenodd"})}),kS=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{d:"M17.5 10h-1.7l-3.7 10.5h1.7l.9-2.6h3.9l.9 2.6h1.7L17.5 10zm-2.2 6.3 1.4-4 1.4 4h-2.8zm-4.8-3.8c1.6-1.8 2.9-3.6 3.7-5.7H16V5.2h-5.8V3H8.8v2.2H3v1.5h9.6c-.7 1.6-1.8 3.1-3.1 4.6C8.6 10.2 7.8 9 7.2 8H5.6c.6 1.4 1.7 2.9 2.9 4.4l-2.4 2.4c-.3.4-.7.8-1.1 1.2l1 1 1.2-1.2c.8-.8 1.6-1.5 2.3-2.3.8.9 1.7 1.7 2.5 2.5l.6-1.5c-.7-.6-1.4-1.3-2.1-2z"})}),xS=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(Q.Path,{fillRule:"evenodd",d:"M6.863 13.644L5 13.25h-.5a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5H5L18 6.5h2V16h-2l-3.854-.815.026.008a3.75 3.75 0 01-7.31-1.549zm1.477.313a2.251 2.251 0 004.356.921l-4.356-.921zm-2.84-3.28L18.157 8h.343v6.5h-.343L5.5 11.823v-1.146z",clipRule:"evenodd"})}),{HEADING:SS}=(0,We.getNamesOfBlocks)(),wS=({title:e,subtitle:t,icon:o})=>(0,g.jsxs)(h.Flex,{className:"text-ai-custom-label",direction:"column",gap:1.5,expanded:!0,children:[(0,g.jsxs)(h.Flex,{justify:"flex-start",children:[(0,g.jsx)(Ue,{icon:o,className:"text-ai-custom-label__icon"}),(0,g.jsx)("span",{className:"text-ai-custom-label__title",children:e})]}),(0,g.jsx)("span",{className:"text-ai-custom-label__subtitle",children:t})]}),CS=({dataHelper:e,onClose:t,anchor:o,isGenerating:n,setIsGenerating:i})=>{const[r,a]=(0,u.useState)(""),[{pageTitle:s,siteContext:l,pageContext:c}]=(0,S.useAIData)(),d=(0,u.useCallback)((async()=>{i(!0),t();try{const t=await(0,S.prompt)({pageTitle:s,siteContext:l,pageContext:c,prompt:r,originalContent:e.getAttribute("content",""),short:e.block.name===SS});e.setAttribute("content",t)}catch(e){}i(!1)}),[e,r,t,c,s,i,l]);return(0,g.jsx)(h.Popover,{className:"kubio-options-popover kubio-text-ai-popover",anchor:o,onClose:t,offset:15,children:(0,g.jsxs)(h.Flex,{direction:"column",align:"end",gap:3.75,children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)(ut.TextareaControl,{className:"kubio-ai-block-prompt-textarea",value:r,onChange:a,label:(0,g.jsx)(wS,{icon:He.TextAiRegenerate,title:(0,m.__)("Regenerate","kubio"),subtitle:(0,m.__)("Write a new prompt and let the AI generate the content for you","kubio")}),cols:60,rows:4})}),(0,g.jsx)(h.FlexItem,{children:(0,g.jsx)(h.Button,{className:"kubio-ai-button",onClick:d,isBusy:n,children:(0,m.__)("Regenerate","kubio")})})]})})},IS=({dataHelper:e,onClose:t,anchor:o,isGenerating:n,setIsGenerating:i})=>{const[r,a]=(0,u.useState)("natural"),[{pageTitle:s,siteContext:l,pageContext:c}]=(0,S.useAIData)(),d=(0,u.useMemo)((()=>(0,_.map)((0,S.getContentLanguageStyles)(),(({label:e,description:t},o)=>({label:e,description:t,value:o})))),[]),p=(0,u.useCallback)((async()=>{i(!0),t();try{const t=await(0,S.changeTextPrompt)({pageTitle:s,siteContext:l,pageContext:c,promptData:r,text:e.getAttribute("content",""),type:"tone"});e.setAttribute("content",t)}catch(e){}i(!1)}),[e,r,t,c,s,i,l]);return(0,g.jsx)(h.Popover,{className:"kubio-options-popover kubio-text-ai-popover",anchor:o,onClose:t,offset:15,children:(0,g.jsxs)(h.Flex,{direction:"column",gap:3.75,children:[(0,g.jsx)(h.FlexBlock,{children:(0,g.jsx)(ut.GutentagSelectControl,{label:(0,g.jsx)(wS,{icon:xS,title:(0,m.__)("Change tone","kubio"),subtitle:(0,m.__)("Select the tone you want to rewrite this text.","kubio")}),inlineLabel:!1,options:d,value:r,onChange:a,itemRenderer:e=>(0,g.jsxs)("div",{className:"kubio-ai-language-style-select-item",children:[(0,g.jsx)("span",{children:e.label}),(0,g.jsx)("span",{children:e.description})]})})}),(0,g.jsx)(h.Button,{className:"kubio-ai-button",onClick:p,isBusy:n,children:(0,m.__)("Rewrite","kubio")})]})})},jS=["en_US","es_ES","de_DE","fr_FR","en_GB","ja_JP"],TS=({dataHelper:e,onClose:t,anchor:o,isGenerating:n,setIsGenerating:i})=>{const[r,a]=(0,u.useState)("en_US"),[{pageTitle:s,siteContext:l,pageContext:c}]=(0,S.useAIData)(),d=(0,u.useMemo)((()=>{const e=(0,_.map)((0,S.getContentLanguages)(),((e,t)=>({label:e,value:t})));return[{items:e.filter((e=>jS.includes(e.value))).sort(((e,t)=>jS.indexOf(e.value)-jS.indexOf(t.value)))},{items:e.filter((e=>!jS.includes(e.value)))}]}),[]),p=(0,u.useCallback)((async()=>{i(!0),t();try{const t=await(0,S.changeTextPrompt)({pageTitle:s,siteContext:l,pageContext:c,promptData:r,text:e.getAttribute("content",""),type:"translate"});e.setAttribute("content",t)}catch(e){}i(!1)}),[e,r,t,c,s,i,l]);return(0,g.jsx)(h.Popover,{className:"kubio-options-popover kubio-text-ai-popover",anchor:o,onClose:t,offset:15,children:(0,g.jsxs)(h.Flex,{direction:"column",gap:3.75,children:[(0,g.jsx)(h.FlexBlock,{expanded:!0,children:(0,g.jsx)(ut.GutentagSelectControl,{label:(0,g.jsx)(wS,{icon:kS,title:(0,m.__)("Translate","kubio"),subtitle:(0,m.__)("In which language would you like to translate this text?","kubio")}),value:r,onChange:a,inlineLabel:!1,options:d})}),(0,g.jsx)(h.Button,{className:"kubio-ai-button",onClick:p,isBusy:n,children:(0,m.__)("Translate","kubio")})]})})},{HEADING:PS,TEXT:ES}=(0,We.getNamesOfBlocks)(),RS=[PS,ES],AS=[{icon:_S,title:(0,m.__)("Make shorter","kubio"),action:"shorten"},{icon:vS,title:(0,m.__)("Make longer","kubio"),action:"lengthen"},{icon:yS,title:(0,m.__)("Fix spelling & grammar","kubio"),action:"fix"},{icon:He.TextAiRegenerate,title:(0,m.__)("Regenerate","kubio"),action:"prompt"},{icon:kS,title:(0,m.__)("Translate","kubio"),action:"translate"},{icon:xS,title:(0,m.__)("Change tone","kubio"),action:"change-tone"}],OS=({BlockEdit:e,...t})=>{const{dataHelper:o}=(0,s.useKubioBlockContext)(),{name:n,clientId:i,isSelected:r}=t,[a,l]=y_(i),[{pageContext:c,siteContext:d,pageTitle:p}]=(0,S.useAIData)(),f=(0,u.useRef)(),b=n===ES?"p":`h${o.getProp("level",2)}`,[_,v]=(0,u.useState)(!1),[y,k]=(0,u.useState)(!1),[x,w]=(0,u.useState)(!1),[C,j,P]=Do(),E=(0,u.useCallback)((async e=>{const{action:t}=e;if(!a){switch(l(!0),t){case"shorten":case"lengthen":case"fix":try{const e=await(0,S.processContent)({pageContext:c,siteContext:d,pageTitle:p,content:o.getAttribute("content",""),action:t,extras:{tag:b}});o.setAttribute("content",e)}catch(e){Ko.Log.error(`process-text: ${t}`,e)}break;case"prompt":v(!0);break;case"translate":k(!0);break;case"change-tone":w(!0)}l(!1)}}),[o,a,c,p,l,d,b]),R=(0,u.useRef)(),[A,O]=(0,Ge.useProModal)();return(0,g.jsxs)(g.Fragment,{children:[C,(0,g.jsxs)(I.BlockControls,{group:"block",children:[P&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.ToolbarDropdownMenu,{ref:f,icon:He.KubioAI,className:"kubio-toolbar-text-ai",label:(0,m.__)("Kubio AI","kubio"),controls:AS.map((e=>({...e,onClick:()=>E(e)}))),popoverProps:{className:X()("kubio-toolbar-text-ai__popover",{"kubio-toolbar-text-ai__popover--hidden":T.AI_IN_PRO})},toggleProps:{ref:R,onClick:e=>{O(!0)}}}),T.AI_IN_PRO&&r&&(0,g.jsx)(A,{anchorRef:R.current,urlArgs:{source:"AI",content:"text-ai-toolbar"}})]}),!P&&(0,g.jsx)(Ge.ProItem,{isProItem:T.AI_IN_PRO,tag:h.ToolbarButton,ref:f,icon:He.KubioAI,className:"kubio-toolbar-text-ai kubio-ai-button",label:(0,m.__)("Kubio AI","kubio"),onClick:j})]}),_&&(0,g.jsx)(CS,{anchor:f.current,onClose:()=>v(!1),dataHelper:o,isGenerating:a,setIsGenerating:l}),y&&(0,g.jsx)(TS,{anchor:f.current,onClose:()=>k(!1),dataHelper:o,isGenerating:a,setIsGenerating:l}),x&&(0,g.jsx)(IS,{anchor:f.current,onClose:()=>w(!1),dataHelper:o,isGenerating:a,setIsGenerating:l}),(0,g.jsx)(e,{...t})]})},NS=(0,p.createHigherOrderComponent)((e=>t=>{const{name:o}=t;return(0,l.useSelect)((e=>e(y.STORE_KEY).isAICapabilityEnabled()),[])&&RS.includes(o)?(0,g.jsx)(OS,{BlockEdit:e,...t}):(0,g.jsx)(e,{...t})}),"withKubioAIToolbarControls");(0,d.addFilter)("editor.BlockEdit","kubio/ai/with-toolbar-controls",NS,4),(0,d.addFilter)("kubio.ai.generateSectionBlocks.afterBlockGenerated","contact-form",(e=>("kubio/contact"!==e.name||(0,T.getCanInstallContactForm)()&&v().set(e,"attributes.kubio.props.autoSelectFormAtMount",!0),e))),(0,d.addFilter)("kubio.ai.generateSectionBlocks.afterBlockGenerated","contact-form",(e=>("kubio/subscribe-form"!==e.name||(0,T.getCanInstallSubscribeForm)()&&v().set(e,"attributes.kubio.props.autoSelectFormAtMount",!0),e)));const BS={facebook:"font-awesome/facebook-square",twitter:"font-awesome/square-x-twitter",youtube:"font-awesome/youtube-square",instagram:"font-awesome/instagram",tiktok:"font-awesome/tiktok",pinterest:"font-awesome/pinterest-square",whatsapp:"font-awesome/whatsapp",linkedin:"font-awesome/linkedin-square"},DS={"font-awesome":[{type:"square",items:BS},{type:"noneSquare",items:{facebook:"font-awesome/facebook",twitter:"font-awesome/twitter-x",youtube:"font-awesome/youtube-play",instagram:"font-awesome/instagram",tiktok:"font-awesome/tiktok",pinterest:"font-awesome/pinterest",whatsapp:"font-awesome/whatsapp",linkedin:"font-awesome/linkedin"}}],ionicons:[{type:"filled",items:{facebook:"ionicons/social-facebook",twitter:"ionicons/social-twitter",youtube:"ionicons/social-youtube",instagram:"ionicons/social-instagram",pinterest:"ionicons/social-pinterest",whatsapp:"ionicons/social-whatsapp",linkedin:"ionicons/social-linkedin"}},{type:"outlined",items:{facebook:"ionicons/social-facebook-outline",twitter:"ionicons/social-twitter-outline",youtube:"ionicons/social-youtube-outline",instagram:"ionicons/social-instagram-outline",pinterest:"ionicons/social-pinterest-outline",whatsapp:"ionicons/social-whatsapp-outline",linkedin:"ionicons/social-linkedin-outline"}}],"icons8-line-awesome":[{type:"normal",items:{facebook:"icons8-line-awesome/facebook",twitter:"icons8-line-awesome/twitter",youtube:"icons8-line-awesome/youtube-play",instagram:"icons8-line-awesome/instagram",pinterest:"icons8-line-awesome/pinterest",whatsapp:"icons8-line-awesome/whatsapp",linkedin:"icons8-line-awesome/linkedin"}}],socicon:[{type:"normal",items:{facebook:"socicon/facebook",twitter:"socicon/twitter",youtube:"socicon/youtube",instagram:"socicon/instagram",pinterest:"socicon/pinterest",whatsapp:"socicon/whatsapp",linkedin:"socicon/linkedin"}}],"foundation-icons":[{type:"normal",items:{facebook:"foundation-icons/social-facebook",twitter:"foundation-icons/social-twitter",youtube:"foundation-icons/social-youtube",instagram:"foundation-icons/social-instagram",pinterest:"foundation-icons/social-pinterest",linkedin:"foundation-icons/social-linkedin"}}],"simple-line-icons":[{type:"normal",items:{facebook:"simple-line-icons/social-facebook",twitter:"simple-line-icons/social-twitter",youtube:"simple-line-icons/social-youtube"}}],typicons:[{type:"normal",items:{facebook:"typicons/social-facebook",twitter:"typicons/social-twitter",youtube:"typicons/social-youtube",instagram:"typicons/social-instagram",pinterest:"typicons/social-pinterest",linkedin:"typicons/social-linkedin"}}]},MS=(()=>{const e={};return v().each(DS,((t,o)=>{t.forEach((({items:t})=>{v().each(t,((o,n)=>{v().set(e,o,t)}))}))})),e})(),LS=BS,{SECTION:zS,SOCIAL_ICONS:FS}=(0,We.getNamesOfBlocks)(),GS=({block:e,siteContext:t})=>{const o=v().get(t,"contact.socials",[]),n=(0,_.filter)(o,(({url:e})=>!!e));if(!o||v().isEmpty(o)||!n.length)return e;const i="attributes.icon.name",r=o.filter((({url:e})=>e)),a=e.innerBlocks,s=a.filter((e=>{const t=v().get(e,i);return r.find((({type:e})=>t.includes(e)))})),l=[];let c=null;return r.forEach((({type:e,url:t})=>{const o=s.find((t=>v().get(t,i).includes(e)));o?(v().set(o,"attributes.link.value",t),c=v().get(o,"attributes.icon.name")):l.push({type:e,url:t})})),l.forEach((({type:e,url:t})=>{const o=a[a.length-1],n=(0,T.kubioCloneDeep)((0,lt.cloneBlock)(o));v().unset(n,"attributes.kubio.styleRef"),v().set(n,"attributes.link.value",t);const i=((e,t)=>{const o=v().get(MS,t),n=LS[e];return o?v().get(o,e,n):n})(e,c);v().set(n,"attributes.icon.name",i),s.push(n)})),e.innerBlocks=s,e};(0,d.addFilter)("kubio.ai.generateSectionBlocks.afterBlockGenerated","social-icons",((e,t,o,n)=>{if(e.name!==FS)return e;const i=Array.isArray(n)?n[0]:n;if(i.name===zS){const t=["contact","footer-section","footer"],o=v().get(i,"attributes.kubioAI.meta.category");if(!t.includes(o))return e}return GS({block:e,siteContext:t})})),(0,d.addFilter)("kubio.navigation.topBarBlockBeforeInsert","social-icons",((e,t)=>e.name!==FS?e:GS({block:e,siteContext:t})));const{ICON_LIST:HS}=(0,We.getNamesOfBlocks)(),US={phone:{desc:"phone",icons:["phone","call"]},email:{desc:"mail",icons:["mail","envelope"]},address:{desc:"address",icons:["map","pin","home","house"]}},WS=(e,t)=>e.innerBlocks.find((e=>{if(v().get(e,"attributes.kubioAI.desc","").toLowerCase().includes(US[t].desc))return!0;const o=v().get(e,"attributes.icon","").toLowerCase();for(const e of US[t].icons)if(o.includes(e))return!0;return!1})),VS=({block:e,siteContext:t})=>{const o=v().get(t,"contact"),n=v().get(o,"address","123, Main Street, City, Country");if(n){const t=WS(e,"address");t&&v().set(t,"attributes.text",n)}const i=v().get(o,"phone","+1 234 567 890");if(i){const t=WS(e,"phone");t&&v().set(t,"attributes.text",i)}const r=v().get(o,"email","email@example.com");if(r){const t=WS(e,"email");t&&v().set(t,"attributes.text",r)}return e};(0,d.addFilter)("kubio.ai.generateSectionBlocks.afterBlockGenerated","iconsList",((e,t,o,n)=>e.name!==HS?e:VS({block:e,siteContext:t}))),(0,d.addFilter)("kubio.navigation.topBarBlockBeforeInsert","iconsList",((e,t)=>e.name!==HS?e:VS({block:e,siteContext:t}))),(0,d.addFilter)("kubio.ai.generateSectionBlocks.afterBlockGenerated","kubio-map",((e,t)=>{if("kubio/map"!==e.name)return e;const o=(0,_.get)(t,["contact","address"]);return o&&(0,_.set)(e,"attributes.address",o),(0,_.set)(e,"attributes.zoom.value",15),e})),(0,d.addFilter)("kubio.ai.generateSectionBlocks.afterBlockGenerated","logo",((e,t)=>{if("kubio/logo"!==e.name)return e;const o=(0,l.select)("core").getEditedEntityRecord("root","site");return((null==o?void 0:o.site_logo)||(null==o?void 0:o.sitelogo)||v().get(t,["website_logo","id"]))&&v().set(e,"attributes.kubio.props.layoutType","image"),e})),(0,d.addFilter)("kubio.ai-filters","kubio-ai-filters",(()=>({useHandleInsert:Rk,useIsAISetupComplete:Do,GenerateSectionModal:Ek})));const KS=window.wp.privateApis;let $S,qS;if((0,T.wpVersionCompare)("6.7",">="))try{const{lock:e,unlock:t}=(0,KS.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/edit-site");$S=e,qS=t}catch(e){console.error(e)}const YS=window.wp.widgets,ZS=(0,g.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24",children:(0,g.jsx)(Q.Path,{d:"M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"})}),XS=function({icon:e}){if(!(0,l.useSelect)((e=>e(y.STORE_KEY).isFeatureActive("fullscreenMode")),[]))return null;const t=e||ZS;return(0,g.jsx)(h.Button,{className:"edit-site-fullscreen-mode-close",icon:t,iconSize:36,href:"index.php",label:(0,m.__)("Back","kubio")})};let JS;try{const{registerCoreBlockBindingsSources:e}=(null==qS?void 0:qS(q.privateApis))||{};JS=e}catch(e){console.error(e)}const QS=(0,T.wpVersionCompare)("6.7",">="),ew=(0,T.wpVersionCompare)("6.8",">=");function tw(e,t){var o,n;(0,s.registerTemplateStore)(),t.__experimentalFetchLinkSuggestions=s.fetchLinkSuggestions,t.__experimentalSpotlightEntityBlocks=["core/template-part"];const i=new URLSearchParams(window.location.search);t.isGutentagDebug=!!i.get("kubio-debug");const r=t.state;delete t.state,r.settings=t;const p=null===c.__experimentalGetCoreBlocks||void 0===c.__experimentalGetCoreBlocks||null===(o=(0,c.__experimentalGetCoreBlocks)())||void 0===o||null===(n=o.filter)||void 0===n?void 0:n.call(o,(({name:e})=>"core/freeform"!==e));var h;if(v().isEmpty(p)?null===c.registerCoreBlocks||void 0===c.registerCoreBlocks||(0,c.registerCoreBlocks)():null===c.registerCoreBlocks||void 0===c.registerCoreBlocks||(0,c.registerCoreBlocks)(p),QS&&(null===(h=JS)||void 0===h||h()),ew)try{(0,l.dispatch)("core/blocks").setFreeformFallbackBlockName("core/html"),(0,YS.registerLegacyWidgetBlock)({inserter:!1}),(0,YS.registerWidgetGroupBlock)({inserter:!1})}catch(e){console.error(e)}(0,a.initFirebaseData)(),(0,_.isFunction)(c.__experimentalRegisterExperimentalCoreBlocks)&&(0,c.__experimentalRegisterExperimentalCoreBlocks)({enableFSEBlocks:!0});const m=Fv;t.wpVersion&&document.body.classList.add("kubio-wp-"+t.wpVersion.replace(".","-")),jk(r),(0,s.reactRender)((0,g.jsx)(u.StrictMode,{children:(0,g.jsx)(m,{initialSettings:r.settings})}),document.getElementById(e)),window.kubioToggleDebug=e=>{wp.data.dispatch("kubio/edit-site").toggleGutentagDebug(e)},top.kubioStartTime=performance.now(),(0,d.addAction)("kubio.editor.page-changed","kubio/editor/page-changed/restart-performance-timer",(()=>{top.kubioStartTime=performance.now()}))}})(),(window.kubio=window.kubio||{}).editor=n})();