useblocks 1.2.0 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +4 -0
  3. package/iframe/.vite/manifest.json +4 -4
  4. package/iframe/{iframe-eblock.71aea198.html → iframe-eblock.ad7a9d1f.html} +2 -2
  5. package/iframe/{iframe.71aea198.html → iframe.ad7a9d1f.html} +2 -2
  6. package/iframe/js/elMarkupHelper.vJSCLUyq.js +278 -0
  7. package/iframe/js/iframe-eblock.body.ad7a9d1f.js +9 -0
  8. package/iframe/js/iframe-eblock.js +2 -2
  9. package/iframe/js/iframe.body.ad7a9d1f.js +129 -0
  10. package/iframe/js/iframe.js +2 -2
  11. package/iframe/js/sanitize-html/sanitize-html.js +46 -21756
  12. package/package.json +1 -1
  13. package/runtime/react/index.js +1 -1
  14. package/static/core/{12f773c1.js → 220aeb6e.js} +1 -1
  15. package/static/core/{cea06bde.js → 25e324a7.js} +1 -1
  16. package/static/core/{1516d48e.js → 2d7469b5.js} +10 -10
  17. package/static/core/{1d170e32.js → 35aeebd4.js} +1 -1
  18. package/static/core/35b68c2d.js +7 -0
  19. package/static/core/{1dc51b93.js → 46b89e4e.js} +1 -1
  20. package/static/core/{f9749132.js → 50843a12.js} +1 -1
  21. package/static/core/{bfb25e63.js → 51c86df3.js} +1 -1
  22. package/static/core/55135cf2.js +1 -0
  23. package/static/core/{3d3eb29f.js → 581a610a.js} +1 -1
  24. package/static/core/{5278dff9.js → 67bd2b51.js} +1 -1
  25. package/static/core/{cf548c07.js → 719c3c6f.js} +1 -1
  26. package/static/core/{1594df08.js → 76d7fc00.js} +1 -1
  27. package/static/core/861ad8b1.js +28 -0
  28. package/static/core/{e460bb13.js → 8dc1398d.js} +1 -1
  29. package/static/core/{9f4f4873.js → 8ddf51c0.js} +1 -1
  30. package/static/core/{29e211b1.js → 91a70e6b.js} +2 -2
  31. package/static/core/98e0618f.js +2 -0
  32. package/static/core/{6dcb28a1.js → 9ec744ee.js} +1 -1
  33. package/static/core/{5b586fcb.js → ac4fee3c.js} +1 -1
  34. package/static/core/{f0c51560.js → be3fdb1c.js} +1 -1
  35. package/static/core/{a34a72bf.js → bf98b554.js} +2 -2
  36. package/static/core/{def48fbd.js → c5066b60.js} +1 -1
  37. package/static/core/d24bb113.js +4 -0
  38. package/static/core/{c8fe849c.js → d7c1e1d9.js} +1 -1
  39. package/static/core/{6f7a2152.js → e22d6382.js} +1 -1
  40. package/static/core/{d6929171.js → e33e9a92.js} +1 -1
  41. package/static/core/{6bc1c806.js → fb52c612.js} +10 -10
  42. package/static/esm/88c4c0b7.js +1 -0
  43. package/static/umd-runtime/{runtime.DxsFr3F4.js → runtime.CVHhHBC5.js} +1 -1
  44. package/useblocks-core.ad7a9d1f.js +859 -0
  45. package/useblocks-esm.js +11 -11
  46. package/{useblocks-po.71aea198.js → useblocks-po.ad7a9d1f.js} +1 -1
  47. package/useblocks.d.ts +34 -2
  48. package/useblocks.js +12 -12
  49. package/vendor/useblocks-ui-kit/package.json +1 -1
  50. package/iframe/js/elMarkupHelper.D_gxM3uK.js +0 -279
  51. package/iframe/js/iframe-eblock.body.71aea198.js +0 -9
  52. package/iframe/js/iframe.body.71aea198.js +0 -129
  53. package/iframe/js/sanitize-html/sanitize-html.min.js +0 -16923
  54. package/static/core/28d63741.js +0 -2
  55. package/static/core/3f80e59d.js +0 -28
  56. package/static/core/57fee71e.js +0 -4
  57. package/static/core/69789892.js +0 -1
  58. package/static/core/91f77c2d.js +0 -7
  59. package/static/esm/f97f84b4.js +0 -1
  60. package/useblocks-core.71aea198.js +0 -859
@@ -1,7 +0,0 @@
1
- __useblocks__.define("static/core/a73da823.js",["require","exports","module"],function(d,a,u){function s(c,l="application/octet-stream"){let t=c.trim(),i=l?.trim()||"application/octet-stream";const o=t.indexOf(",");if(t.startsWith("data:")&&o>=0){const e=t.slice(5,o).split(";")[0]?.trim();e&&(i=e),t=t.slice(o+1)}const m=t.replace(/\s/g,""),r=atob(m),n=new Uint8Array(r.length);for(let e=0;e<r.length;e++)n[e]=r.charCodeAt(e);return new Blob([n],{type:i})}Object.defineProperty(a,"base64ToBlob",{enumerable:!0,get:function(){return s}})});
2
-
3
- (function(){try{if(typeof document<"u"){var t=".blocks-app .image-preview{text-align:center;min-height:100px;position:relative}.blocks-app .image-preview .image-editor-modal{border:1px solid red}.blocks-app .image-preview__edit-button{position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-preview img{border:1px solid var(--ub-colorBorder);border-radius:6px;max-width:100%;max-height:500px}.blocks-app .serach-results .ant-row{align-items:center}.blocks-app .serach-results .blocks-search__divider-wrapper{margin-top:12px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{border-top:1px solid var(--ub-colorBorderSecondary);background:0 0;width:100%;height:1px;min-height:0;margin:0;position:static}.blocks-app .slideshow-container{width:524px;height:350px;margin:auto;position:relative;overflow:hidden}.blocks-app .slideshow-image{opacity:0;width:100%;height:100%;position:absolute;top:0;left:0}.blocks-app .image-ai .slideshow-image{width:auto;height:auto}.blocks-app .image-ai__image-item{text-align:center;border-radius:6px;justify-content:center;align-items:center;min-height:100px;display:flex;position:relative}.blocks-app .image-ai__image-item .buttons{justify-content:space-between;display:flex;position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-ai .text-area-input-hybrid{border:none;outline:none;min-height:0;padding:0 0 0 1px}.blocks-app .image-ai .text-area-input-hybrid textarea{height:32px;min-height:32px;padding:3px 11px;line-height:26px}.blocks-app .image-ai__loading{justify-content:center;align-items:center;min-height:150px;display:flex}.blocks-app .image-ai__loading .spin{flex-direction:column;justify-content:center;align-items:center;height:150px;display:flex}.blocks-app .image-ai__loading .status{margin:3px 0 0}.blocks-app .image-ai__preview{border-radius:6px;margin-top:24px;overflow:hidden}.blocks-app .image-ai__preview .image-ai__image-item img{border-radius:calc(var(--ub-borderRadius) * 1px);object-fit:contain;max-height:100%;transition:height 1s;top:50%;left:50%;overflow:hidden;transform:translate(-50%,-50%)}.blocks-app .image-ai .small{width:302px;height:202px}.blocks-app .image-ai .large{width:524px;height:350px}.blocks-app .image-ai .image-ai__row{padding:0 2px}.blocks-app .image-ai .image-ai__input-affix-wrapper{border-style:solid;border-width:calc(var(--ub-borderWidth) * 1px);border-color:var(--ub-colorFillSecondaryDarken);border-radius:calc(var(--ub-borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--ub-borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--ub-colorPrimaryBorder)}.blocks-app .image-ai .image-ai__textarea{font-size:16px}.blocks-app .image-ai .image-ai__input-icon{font-size:16px;top:0;right:0}.dark .blocks-app .image-ai .image-ai__preview .image-ai__image-item img{background:#2b2b2b;border:1px solid #434343}.dark .blocks-app .image-ai .ant-btn{background:#1f1f1f}.dark .blocks-app .image-ai .ant-btn:hover{color:var(--ub-colorPrimary)}.blocks-app .stock-tab img{border-radius:0;max-width:none;max-height:none}.blocks-app .stock-tab .stock-search-input{padding:0 2px}.blocks-app .stock-tab .my-masonry-grid{text-align:center;width:auto;display:flex}.blocks-app .stock-tab .my-masonry-grid_column{background-clip:padding-box}.blocks-app .stock-tab .list-item{cursor:pointer;background:#f0f2f5;border:1px solid #f0f2f5;border-radius:6px;min-height:100px;max-height:100px;margin-bottom:20px;transition:all .3s;display:inline-block;position:relative;overflow:hidden}.blocks-app .stock-tab .list-item .overlay-image{opacity:0;background-size:cover;width:110px;height:40px;transition:opacity .5s;position:absolute;bottom:10px;right:10px}.blocks-app .stock-tab .list-item .ant-spin{color:#f0f2f5;font-size:20px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.blocks-app .stock-tab .list-item img{object-fit:cover;opacity:0;border-radius:6px;height:auto;transition:opacity .5s ease-in-out;display:block}.blocks-app .stock-tab .list-item.loaded{border:1px solid #d9d9d9;max-height:1000px}.blocks-app .stock-tab .list-item.loaded img{opacity:1;height:100%}.blocks-app .stock-tab .list-item.loaded .loaded-image{opacity:.5}.blocks-app .stock-tab .list-item:hover{box-shadow:0 1px 2px -2px #00000029,0 3px 6px #0000001f,0 5px 12px 4px #00000017}.blocks-app .stock-tab .list-item:hover p.creator-info,.blocks-app .stock-tab .list-item:hover .overlay-image{opacity:1}.blocks-app .stock-tab .list-item p.creator-info{color:#fff;opacity:0;background-color:#00000080;border-radius:0 0 6px;margin:0;padding:5px;font-size:10px;line-height:1.2;position:absolute;bottom:0;right:0}.blocks-app .stock-tab .list-item p.creator-info:hover a{color:#fff;text-decoration:underline}.blocks-app .stock-tab .list-item p.creator-info a{color:#fff;text-decoration:none}.blocks-app .stock-color-filter{display:flex}.blocks-app .stock-color-filter label{border-width:1px;width:24px;height:24px;margin:4px;padding:0;font-size:0;border-radius:6px!important}.blocks-app .stock-color-filter label.all-colors{background-image:linear-gradient(135deg,red,#ff7f00,#ff0,#0f0,#00f,#8b00ff)}.blocks-app .stock-color-filter label.black-color{background:#222}.blocks-app .stock-color-filter label.bw-color{background-image:linear-gradient(135deg,#222 50%,#fff 50%)}.blocks-app .stock-color-filter label.white-color{background:#fff}.blocks-app .stock-color-filter label.orange-color{background:#fa8c16}.blocks-app .stock-color-filter label.red-color{background:#f5222d}.blocks-app .stock-color-filter label.purple-color{background:#722ed1}.blocks-app .stock-color-filter label.magenta-color{background:#eb2f96}.blocks-app .stock-color-filter label.green-color{background:#52c41a}.blocks-app .stock-color-filter label.teal-color{background:#43c3c3}.blocks-app .stock-color-filter label.blue-color{background:#1677ff}.blocks-app .stock-color-filter .ant-radio-button-wrapper:not(:first-child):before{display:none}.blocks-app .serach-results{padding-top:6px}.blocks-app .serach-results .stock-search-input{width:322px;padding:0 2px}.blocks-app .serach-results .blocks-search__divider-wrapper{width:calc(100% + 48px);margin-top:12px;margin-left:-24px;margin-right:-24px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{pointer-events:none;border-top:1px solid var(--ub-colorBorderSecondary);background:linear-gradient(180deg, var(--ub-colorBgContainerDisabled), transparent 40%);border-bottom:none;width:100%;height:20px;min-height:20px;margin:0;position:relative;bottom:auto;left:auto;right:auto}.dark .blocks-app .image-center .stock-tab .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{background:linear-gradient(180deg, var(--ub-colorBgBase), transparent 40%)}.dark .blocks-app .stock-tab .list-item{background:#2b2b2b;border:1px solid #2b2b2b}.dark .blocks-app .stock-tab .list-item.loaded{border:1px solid #434343}.blocks-app .image-center .image-center-image-preview{justify-content:center;align-items:center;display:flex}.blocks-app .image-center .ant-divider-horizontal{pointer-events:none;z-index:1;background:linear-gradient(180deg, var(--ub-colorBgContainerDisabled), transparent 40%);width:calc(100% + 48px);height:20px;margin:24px -24px 0;position:absolute;bottom:-19px}.dark .blocks-app .image-center .ant-divider-horizontal{background:linear-gradient(180deg, var(--ub-colorBgBase), transparent 40%)}.blocks-app .image-center .ant-divider-horizontal.ant-divider-with-text{background:0 0;width:calc(100% + 38px);margin:0 -24px 20px;position:relative;top:0}.blocks-app .image-center img{border-radius:4px;max-width:524px;max-height:352px}.blocks-app .image-center .image-size{justify-content:center;margin-top:6px;font-size:14px;line-height:22px;display:flex}.blocks-app .image-center .ant-upload.ant-upload-drag{border-radius:6px}.blocks-app .image-center .ant-modal-body .stock-search-input{margin-bottom:0}.blocks-app .image-center .ant-modal-body .serach-results .stock-search-input{margin-bottom:10px}.blocks-app .image-center .ant-modal-body .ant-form:not(.serach-results) .ant-form-item:last-child{margin-bottom:0}.blocks-app .image-center .ant-modal-body .ant-tabs{transition:all .7s cubic-bezier(.075,.82,.165,1)}.blocks-app .image-center .ant-modal-body .ant-tabs .ant-tabs-content-holder{overflow-y:clip}.blocks-app .ant-modal{transition:width .7s ease-in-out}",e=window.__useblocks_styles__||(window.__useblocks_styles__={sheets:{},order:[]}),r=t;if(!e.sheets[r]){var o=null;try{typeof CSSStyleSheet=="function"&&"replaceSync"in CSSStyleSheet.prototype&&(o=new CSSStyleSheet,o.replaceSync(t))}catch{o=null}if(o){if(!e.host||!e.host.isConnected||!e.host.sheet){var a=document.createElement("style");a.setAttribute("data-useblocks","true"),document.head.appendChild(a),e.host=a}for(var l=e.host.sheet,p=0;p<o.cssRules.length;p++)try{l.insertRule(o.cssRules[p].cssText,l.cssRules.length)}catch{}(e.texts||(e.texts=[])).push(t),(e.listeners||[]).forEach(function(i){try{i(t)}catch{}})}else{var a=document.createElement("style");a.setAttribute("data-useblocks","true"),a.appendChild(document.createTextNode(t)),document.head.appendChild(a)}e.sheets[r]=!0,e.order.push(r)}}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
4
- __useblocks__.define("static/core/91f77c2d.js",["require","exports","module","static/core/2ff39ddf.js","static/core/1ad5ec50.js","static/core/a73793d3.js","static/core/3f80e59d.js","static/core/a73da823.js","react","react/jsx-runtime","__delivery__/libs","vite/preload-helper"],function(ie,kt,fn){const Xe=ie("./2ff39ddf.js"),be=ie("./1ad5ec50.js"),s=ie("./a73793d3.js"),ne=ie("./3f80e59d.js"),It=ie("./a73da823.js");let e=ie("react");e=Xe.__toESM(e);let t=ie("react/jsx-runtime"),m=ie("__delivery__/libs"),xt=ie("vite/preload-helper");var _t=Xe.__toESM(s.require_prop_types()),Et=s.lazyRoute(()=>(0,xt.__vitePreload)(()=>Promise.resolve().then(()=>ie("./def48fbd.js")),void 0,{}.url));function St(r){return s.useSelector(s.selectSecondModal)?(0,t.jsx)(e.Suspense,{fallback:null,children:(0,t.jsx)(Et,{...r})}):null}var jt=({currentImageLink:r,newLink:o,previewDisplayUrl:i,resolvedPreviewObjectUrl:l,resolvedPreviewBlob:u,resolveImageBlob:c,onSave:f,uploadImageResultIsLoading:p})=>{const g=i||l;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:"image-preview",children:[p&&(0,t.jsx)("div",{style:{position:"absolute",height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:s.emCssVar("colorBgLayout"),zIndex:10,opacity:.7},children:(0,t.jsx)(m.ui_kit$Spin,{size:"large"})}),g&&(0,t.jsx)("img",{alt:"uploadedImage",src:g})]})}),(0,t.jsx)(St,{currentImageLink:r,prefetchedBlob:u,resolveImageBlob:c,newLink:o,onSave:f,uploadImageResultIsLoading:p})]})},_e={Pixel:"Pixel",Percent:"Percent"},et={unit:_e.Percent,value:80};function Rt(r){return typeof r=="number"?{unit:_e.Percent,value:r*100}:typeof r=="string"?/^(\d*(\.\d+)?)px$/.exec(r)?{unit:_e.Pixel,value:parseFloat(r)}:/^(\d*(\.\d+)?)%$/.exec(r)?{unit:_e.Percent,value:parseFloat(r)}:et:et}function Lt(r,o){const i=Rt(r);let l;return i.unit===_e.Pixel?l=`${i.value}px`:l=`${100-i.value}%`,o?`${l} 0px 0px 0px`:`0px 0px ${l} 0px`}function tt({next:r,hasMore:o,children:i,loader:l,scrollThreshold:u=.8,endMessage:c,style:f,height:p,scrollableTarget:g,hasChildren:w,inverse:I=!1,pullDownToRefresh:y=!1,pullDownToRefreshContent:h,releaseToRefreshContent:x,pullDownToRefreshThreshold:k=100,refreshFunction:L,onScroll:b,dataLength:S,initialScrollY:R,className:F="",role:Q,tabIndex:D,id:G,...z}){const[W,H]=(0,e.useState)(!1),[T,q]=(0,e.useState)(!1),[V,re]=(0,e.useState)(0),_=(0,e.useRef)(null),Y=(0,e.useRef)(null),N=(0,e.useRef)(null),B=(0,e.useRef)(r);B.current=r;const ee=(0,e.useRef)(L);ee.current=L;const P=(0,e.useRef)(k);P.current=k;const n=(0,e.useRef)(!1),A=(0,e.useRef)(!1),j=(0,e.useRef)(0),$=(0,e.useRef)(0),le=(0,e.useRef)(0),E=(0,e.useCallback)(()=>g instanceof HTMLElement?g:typeof g=="string"?document.getElementById(g):null,[g]);(0,e.useEffect)(()=>{if(typeof S>"u")throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(y&&typeof L!="function")throw new Error(`Mandatory prop "refreshFunction" missing.
5
- Pull Down To Refresh functionality will not work
6
- as expected. Check README.md for usage'`);if(typeof R=="number"){const U=p?_.current:E();U&&U.scrollHeight>R&&U.scrollTo(0,R)}},[]),(0,e.useEffect)(()=>{n.current=!1,H(!1)},[S]),(0,e.useEffect)(()=>{if(!o||typeof IntersectionObserver>"u")return;const U=Y.current;if(!U)return;const Z=p?_.current:E(),O=new IntersectionObserver(([te])=>{!te.isIntersecting||n.current||(n.current=!0,H(!0),B.current())},{root:Z,rootMargin:Lt(u,I),threshold:0});return O.observe(U),()=>O.disconnect()},[o,u,I,p,E]),(0,e.useEffect)(()=>{var U;if(!b)return;const Z=(U=p?_.current:E())!==null&&U!==void 0?U:typeof window<"u"?window:null;if(!Z)return;const O=te=>{setTimeout(()=>b(te),0)};return Z.addEventListener("scroll",O),()=>Z.removeEventListener("scroll",O)},[b,p,E]),(0,e.useEffect)(()=>{var U,Z;if(!y)return;const O=(U=p?_.current:E())!==null&&U!==void 0?U:typeof window<"u"?window:null;if(!O)return;if(!((Z=N.current)===null||Z===void 0)&&Z.firstChild){const K=N.current.firstChild.getBoundingClientRect().height;le.current=K,re(K)}const te=K=>{(O instanceof HTMLElement?O.scrollTop:document.documentElement.scrollTop)>0||(A.current=!0,K instanceof MouseEvent?j.current=K.pageY:K instanceof TouchEvent&&(j.current=K.touches[0].pageY),$.current=j.current,_.current&&(_.current.style.willChange="transform",_.current.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},v=K=>{if(!A.current||(K instanceof MouseEvent?$.current=K.pageY:K instanceof TouchEvent&&($.current=K.touches[0].pageY),$.current<j.current))return;const se=$.current-j.current;se>=P.current&&q(!0),!(se>le.current*1.5)&&_.current&&(_.current.style.overflow="visible",_.current.style.transform=`translate3d(0px, ${se}px, 0px)`)},J=()=>{j.current=0,$.current=0,A.current=!1,q(K=>{var se;return K&&((se=ee.current)===null||se===void 0||se.call(ee)),!1}),requestAnimationFrame(()=>{_.current&&(_.current.style.overflow="auto",_.current.style.transform="none",_.current.style.willChange="unset")})};return O.addEventListener("touchstart",te),O.addEventListener("touchmove",v),O.addEventListener("touchend",J),O.addEventListener("mousedown",te),O.addEventListener("mousemove",v),O.addEventListener("mouseup",J),()=>{O.removeEventListener("touchstart",te),O.removeEventListener("touchmove",v),O.removeEventListener("touchend",J),O.removeEventListener("mousedown",te),O.removeEventListener("mousemove",v),O.removeEventListener("mouseup",J)}},[y,p,E]);const ve={height:p??"auto",overflow:"auto",WebkitOverflowScrolling:"touch",...f},ae=w||!!(i&&i instanceof Array&&i.length),pe=y&&p?{overflow:"auto"}:{},Ce=o?(0,t.jsx)("div",{ref:Y,style:{height:1}}):null;return(0,t.jsx)("div",{style:pe,className:"infinite-scroll-component__outerdiv",children:(0,t.jsxs)("div",{...z,role:Q,tabIndex:D,id:G,className:["infinite-scroll-component",F].filter(Boolean).join(" "),ref:_,style:ve,children:[y&&(0,t.jsx)("div",{style:{position:"relative"},ref:N,children:(0,t.jsx)("div",{style:{position:"absolute",left:0,right:0,top:-1*V},children:T?x:h})}),i,!W&&!ae&&o&&l,W&&o&&l,Ce,!o&&c]})})}function Ot(r,o){if(r==null)return{};var i=Pt(r,o),l,u;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(u=0;u<c.length;u++)l=c[u],!(o.indexOf(l)>=0)&&Object.prototype.propertyIsEnumerable.call(r,l)&&(i[l]=r[l])}return i}function Pt(r,o){if(r==null)return{};for(var i={},l=Object.keys(r),u,c=0;c<l.length;c++)u=l[c],!(o.indexOf(u)>=0)&&(i[u]=r[u]);return i}function Pe(){return Pe=Object.assign||function(r){for(var o=1;o<arguments.length;o++){var i=arguments[o];for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(r[l]=i[l])}return r},Pe.apply(this,arguments)}function nt(r,o){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);o&&(l=l.filter(function(u){return Object.getOwnPropertyDescriptor(r,u).enumerable})),i.push.apply(i,l)}return i}function Ee(r){for(var o=1;o<arguments.length;o++){var i=arguments[o]!=null?arguments[o]:{};o%2?nt(Object(i),!0).forEach(function(l){Ut(r,l,i[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):nt(Object(i)).forEach(function(l){Object.defineProperty(r,l,Object.getOwnPropertyDescriptor(i,l))})}return r}function Ut(r,o,i){return o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,r}var Dt={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0},Te=2,Ne=class extends e.default.Component{constructor(r){super(r),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this);let o;this.props.breakpointCols&&this.props.breakpointCols.default?o=this.props.breakpointCols.default:o=parseInt(this.props.breakpointCols)||Te,this.state={columnCount:o}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener("resize",this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener("resize",this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){if(!window||!window.requestAnimationFrame){this.reCalculateColumnCount();return}window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})}reCalculateColumnCount(){const r=window&&window.innerWidth||1/0;let o=this.props.breakpointCols;typeof o!="object"&&(o={default:parseInt(o)||Te});let i=1/0,l=o.default||Te;for(let u in o){const c=parseInt(u);c>0&&r<=c&&c<i&&(i=c,l=o[u])}l=Math.max(1,parseInt(l)||1),this.state.columnCount!==l&&this.setState({columnCount:l})}itemsInColumns(){const r=this.state.columnCount,o=new Array(r),i=e.default.Children.toArray(this.props.children);for(let l=0;l<i.length;l++){const u=l%r;o[u]||(o[u]=[]),o[u].push(i[l])}return o}renderColumns(){const{column:r,columnAttrs:o={},columnClassName:i}=this.props,l=this.itemsInColumns(),u=`${100/l.length}%`;let c=i;c&&typeof c!="string"&&(this.logDeprecated('The property "columnClassName" requires a string'),typeof c>"u"&&(c="my-masonry-grid_column"));const f=Ee(Ee(Ee({},r),o),{},{style:Ee(Ee({},o.style),{},{width:u}),className:c});return l.map((p,g)=>e.default.createElement("div",Pe({},f,{key:g}),p))}logDeprecated(r){}render(){const r=this.props,{children:o,breakpointCols:i,columnClassName:l,columnAttrs:u,column:c,className:f}=r,p=Ot(r,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let g=f;return typeof f!="string"&&(this.logDeprecated('The property "className" requires a string'),typeof f>"u"&&(g="my-masonry-grid")),e.default.createElement("div",Pe({},p,{className:g}),this.renderColumns())}};Ne.defaultProps=Dt;function Be(r,o){return r?r.exhausted?{...r,src:null}:{...r,src:r.src||o||null}:null}function st({items:r,getItemId:o,getRequestUrl:i,createController:l}){const[u,c]=(0,e.useState)({}),f=(0,e.useRef)(new Map),p=(0,e.useCallback)(g=>{const w=o(g),I=i(g),y=`${w}:${I}`;if(f.current.has(y))return{itemId:w,requestUrl:I,cacheKey:y,controller:f.current.get(y)};const h=l(I);return f.current.set(y,h),{itemId:w,requestUrl:I,cacheKey:y,controller:h}},[l,o,i]);return(0,e.useEffect)(()=>{const g=new Set,w={},I=r.map(y=>{const{itemId:h,cacheKey:x,controller:k}=p(y);g.add(x),w[h]=k.src;const L=Be(k.handleChangeSrc?.(),k.src);return L?.changed&&L.src&&(w[h]=L.src),k.subscribeToSrcChange?.(b=>{const S=Be(b,k.src);!S?.changed||!S.src||c(R=>R[h]===S.src?R:{...R,[h]:S.src})})}).filter(Boolean);return f.current.forEach((y,h)=>{g.has(h)||f.current.delete(h)}),c(w),()=>{I.forEach(y=>y?.())}},[p,r]),{getDisplaySrc:(0,e.useCallback)(g=>{const{itemId:w,requestUrl:I,controller:y}=p(g);return u[w]||y.src||I},[u,p]),handleLoad:(0,e.useCallback)(g=>{p(g).controller.handleSuccess()},[p]),handleError:(0,e.useCallback)(g=>{const{itemId:w,controller:I}=p(g),y=Be(I.handleError(),I.src);y?.changed&&y.src&&c(h=>({...h,[w]:y.src}))},[p])}}var rt="blocks",Mt=({setCurrentImageLink:r,setModalHeight:o,setModalWidth:i,setImageStockList:l,imageStockList:u,currentReq:c,setCurrentReq:f,inputRef:p,setStockLink:g,customRequest:w})=>{const I=s.useAppConfig(),y=s.useIsStandalone(),[h,x]=(0,e.useState)(!1),[k,L]=(0,e.useState)(2),{__:b}=s.useI18n(),S=s.useNotification(),[R]=s.useLazyGetUnsplashImageQuery(),[F]=s.useLazyGetSearchImageQuery(),Q=(0,e.useCallback)(n=>n instanceof Error||typeof n?.message=="string"&&n.message?n.message:typeof n?.error?.message=="string"&&n.error.message?n.error.message:b("Failed to load stock images through the configured proxy chain."),[b]),D=(0,e.useCallback)(n=>{S.error({id:"STOCK_IMAGES_SEARCH_FAILED",title:b("Failed to load stock images"),description:Q(n)})},[b,Q,S]),G=async()=>{h||(x(!0),F({query:c,page:k}).then(n=>{if(n?.error){D(n.error),x(!1);return}const A=n?.data?.results||[];l(j=>[...j,...A]),x(!1),L(j=>j+1)}).catch(()=>{x(!1)}))};(0,e.useEffect)(()=>{c.keywords!==""&&z()},[c.color,c.orientation]);const z=async()=>{const n=await F({query:c,page:1});if(n?.error){D(n.error),l([]);return}const A=n?.data?.results||[];A.length>0?(l(A),setTimeout(()=>{i(1060),o("84vh")},0)):l([])},[W,H]=(0,e.useState)(null),T=(0,e.useCallback)((n,A,j)=>`${n}${n.includes("?")?"&":"?"}w=${A}&q=${j}`,[]),q=(0,e.useCallback)(n=>be.getProxiedUrl(n,{config:I,standalone:y,resourceType:"stockImages",intent:"display"}),[I,y]),V=(0,e.useCallback)(n=>n.id,[]),re=(0,e.useCallback)(n=>T(n.urls.raw,644,96),[T]),{getDisplaySrc:_,handleLoad:Y,handleError:N}=st({items:u,getItemId:V,getRequestUrl:re,createController:q}),B=n=>A=>{Y(n),A.target.parentNode.classList.add("loaded")},ee=n=>()=>{N(n)},P=(n,A,j)=>{R(A.download_location),H(j),setTimeout(()=>H(null),2e3),g(`${n.raw}&w=1200&q=96`),r(`${n.raw}&w=1200&q=96`),w(`${n.raw}&w=1200&q=96`)};return(0,t.jsxs)("div",{className:"stock-tab",children:[(0,t.jsxs)(m.ui_kit$Form,{onValuesChange:z,className:u.length>0?"serach-results":"",children:[(0,t.jsxs)(m.ui_kit$Row,{gutter:24,children:[(0,t.jsx)(m.ui_kit$Col,{span:u.length>0?"":24,children:(0,t.jsx)(m.ui_kit$Form.Item,{className:"stock-search-input",children:(0,t.jsx)(m.ui_kit$SearchInput,{onSearch:z,allowClear:!0,size:u.length>0?"medium":"large",placeholder:b("Search image"),value:c.keywords,onChange:n=>f(A=>({...A,keywords:n.target.value})),ref:p,spellCheck:"false",enterButton:!1})})}),u.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.ui_kit$Col,{children:(0,t.jsxs)(m.ui_kit$Radio.Group,{defaultValue:"",onChange:n=>f(A=>({...A,orientation:n.target.value})),children:[(0,t.jsx)(m.ui_kit$Tooltip,{title:b("All"),placement:"top",children:(0,t.jsx)(m.ui_kit$Radio.Button,{value:"",children:(0,t.jsx)(s.EmIcons,{icon:"MixedView",component:m.icons$MixedView})})}),(0,t.jsx)(m.ui_kit$Tooltip,{title:b("Landscape"),placement:"top",children:(0,t.jsx)(m.ui_kit$Radio.Button,{value:"landscape",children:(0,t.jsx)(s.EmIcons,{icon:"LandscapeView",component:m.icons$LandscapeView})})}),(0,t.jsx)(m.ui_kit$Tooltip,{title:b("Portrait"),placement:"top",children:(0,t.jsx)(m.ui_kit$Radio.Button,{value:"portrait",children:(0,t.jsx)(s.EmIcons,{icon:"PortraitView",component:m.icons$PortraitView})})}),(0,t.jsx)(m.ui_kit$Tooltip,{title:b("Squarish"),placement:"top",children:(0,t.jsx)(m.ui_kit$Radio.Button,{value:"squarish",children:(0,t.jsx)(s.EmIcons,{icon:"SquareView",component:m.icons$SquareView})})})]})}),(0,t.jsx)(m.ui_kit$Col,{children:(0,t.jsx)(m.ui_kit$RadioColorFilter,{defaultValue:"",onChange:n=>f(A=>({...A,color:n.target.value})),options:[{value:"",colorClass:"all-colors",label:b("All")},{value:"black",colorClass:"black-color",label:b("Black")},{value:"black_and_white",colorClass:"bw-color",label:b("Black and White")},{value:"white",colorClass:"white-color",label:b("White")},{value:"orange",colorClass:"orange-color",label:b("Orange")},{value:"red",colorClass:"red-color",label:b("Red")},{value:"purple",colorClass:"purple-color",label:b("Purple")},{value:"magenta",colorClass:"magenta-color",label:b("Magenta")},{value:"green",colorClass:"green-color",label:b("Green")},{value:"teal",colorClass:"teal-color",label:b("Teal")},{value:"blue",colorClass:"blue-color",label:b("Blue")}],tooltipPlacement:"top"})})]})]}),u.length>0&&(0,t.jsx)("div",{className:"blocks-search__divider-wrapper",children:(0,t.jsx)("div",{className:"ant-divider ant-divider-horizontal",role:"separator"})})]}),(0,t.jsx)("div",{className:"serach-output-wrapper",style:{marginRight:-10},children:u.length>0&&(0,t.jsx)("div",{id:"scrollableDiv",style:{width:"100%",height:"calc(84vh - 148px)",overflow:"auto",paddingTop:24,paddingRight:14,paddingLeft:24,marginLeft:-24,lineHeight:"0",boxSizing:"unset"},children:(0,t.jsx)(tt,{dataLength:u&&u.length,next:G,hasMore:u,endMessage:(0,t.jsxs)(m.ui_kit$Divider,{plain:!0,children:[b("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:null,children:(0,t.jsx)(Ne,{breakpointCols:{default:3},className:"my-masonry-grid",columnClassName:"my-masonry-grid_column",children:u.map(n=>(0,t.jsxs)("div",{className:"list-item",onClick:()=>P(n.urls,n.links,n.id),children:[(0,t.jsx)("img",{className:W===n.id?"loaded-image":"",width:"322px",src:_(n),alt:n.description,onLoad:B(n),onError:ee(n)}),(0,t.jsxs)("p",{className:"creator-info",onClick:A=>A.stopPropagation(),children:["Photo by"," ",(0,t.jsx)("a",{target:"_blank",href:`${n.user.links.html}?utm_source=${rt}&utm_medium=referral`,rel:"noreferrer",children:n.user.name})," ","on"," ",(0,t.jsx)("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${rt}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),W===n.id&&(0,t.jsx)(m.ui_kit$Spin,{className:"ant-spin",size:"small"})]},n.id))})})})})]})};function at(r){return/^(https?:)?\/\//i.test(r.trim())}function Gt(r){const o=r.trim();return at(o)||/^data:/i.test(o)?o:`data:image/jpeg;base64, ${r}`}var Tt=({images:r,transitionDuration:o=1e3})=>{const[i,l]=(0,e.useState)([]);return(0,e.useEffect)(()=>{if(r.length>0){const u=r[r.length-1];l(c=>[...c,{src:u,opacity:0}]),setTimeout(()=>{l(c=>c.map((f,p)=>p===c.length-1?{...f,opacity:1}:f))},1e3)}},[r]),(0,t.jsx)("div",{className:"slideshow-container",children:i.map((u,c)=>(0,t.jsx)("img",{src:Gt(u.src),alt:`Slide ${c+1}`,className:"slideshow-image",style:{opacity:u.opacity,transition:`opacity ${o}ms linear`}},c))})};function Nt({setModalHeight:r,customRequest:o,aiTabRef:i,isImageUploaded:l,setIsImageUploaded:u,aiImageRequest:c,imageAiList:f,setImageAiList:p,isLoadingAi:g,setIsLoadingAi:w,onPluginAiImageLimitExceeded:I,onImageGenerateLimitExceeded:y}){const{__:h}=s.useI18n(),x=s.useAppConfig(),k=s.useNotification(),L=s.usePushToDataLayer(),{blockId:b}=s.useRouteParams(),S=s.useEditorProjectId(),R=s.useRouteEmailId(),[F]=s.useLazySendAiImageRequestQuery(),[Q,{data:D=[]}]=s.useLazyGetAiImageSSEQuery(),G=s.useProjectPlanLimitPreflight(),z=x?.sendAIImageRequest||F,W=x?.trigger||Q,H=x?.handleLimitUsageEmitter||s.useEventEmitter(be.events.ON_LIMIT_ID),[T,q]=(0,e.useState)(0),[V,re]=(0,e.useState)(null),[_,Y]=(0,e.useState)(!1),[N,B]=(0,e.useState)(h("Evaluating the task")),[ee,P]=(0,e.useState)(!1),n=R||b,{limits:A}=x?.limits?x:{limits:{ai_img_limit:0}},{ai_img_limit:j}=A,$=!!(x.limits&&x.counters)&&!0,le=s.useEventEmitter(be.events.AI_IMAGE_REQUEST_ID).hasListeners(),E=ne.shouldCountAiUsage({limitsInPlugin:$,hostedAiActive:le}),ve=!le&&j>0&&T>=j,ae=(0,e.useCallback)(()=>{H.fire({name:"AiImgCount",count:T+1})},[H,T]),pe=(0,e.useMemo)(()=>!ve&&(!E||j===0||T<j),[ve,E,T,j]),Ce=(0,e.useCallback)(async()=>{B(h("Evaluating the task")),c!==""&&!g&&(w(!0),P(!0),p([]),L({event:"submit_form",action:"ai_image_generation",entity_id:R,project_id:S}),z({body:{project_id:S,request:"create-image",connection:"midjourney",message:c}}).then(({data:v,error:J})=>{if(J)throw J;if(v.data.status===401)throw new Error(s.ERROR);if(v?.data?._eventResult){p(v.data.task.images),w(!1),P(!1),B(h("Evaluating the task"));return}v?.data.status===200?(v?.data.task.id&&(B(v.data.task.message),re(v.data.task.id)),v.message&&k.success({id:"AI_IMAGE_SEND_SUCCESS",title:v.message,placement:"bottomRight",data:c}),W({task_id:v?.data.task.id,entity_id:n})):(w(!1),P(!1),k.error({id:"AI_IMAGE_SEND_ERROR",title:v?.message||h("Something went wrong, please try again"),placement:"bottomRight",data:c,innerException:v}))}).catch(v=>{w(!1),P(!1),(v?.error||v?.data)&&k.fromError("AI_IMAGE_SEND_ERROR",c,v.error||v)}))},[c,g,w,P,p,L,R,S,z,k,W,n,h]),U=(0,e.useCallback)(async()=>{pe?(E&&(q(v=>v+1),ae()),Ce()):$&&(I?I():k.error({title:h("The usage limit has been exceeded"),description:h(`The maximum number of requests for the current subscription period has been reached.
7
- Select the appropriate plan to fulfil more requests`),placement:"bottomRight"}))},[pe,$,le,E,G,y,q,ae,Ce,k,h,I]);(0,e.useEffect)(()=>{$&&q(x?.counters?.ai_img_counter||0)},[x,$]);const Z=s.useEventEmitter(be.events.AI_IMAGE_PROGRESS_ID);(0,e.useEffect)(()=>{const v=Z.event(({progress:J,status:K})=>{B(K||`${Math.round(J)}%`)});return()=>v.dispose()},[Z]);const O=(0,e.useCallback)(async v=>{if(!l){u(!0);try{const J=at(v)?await(await fetch(v)).blob():It.base64ToBlob(v);o({file:new File([J],"image.jpeg",{type:J.type||"image/jpeg"})})}catch{u(!1)}}},[l,u,o]),te=(0,e.useCallback)(v=>{v.status!=="error"&&v.status!=="Canceled"?v.images?(B(v.status),v.progress===100&&(p(v.images),B(h("Evaluating the task")),re(null),P(!1))):(p([v.data]),w(!1)):(w(!1),P(!1),k.error({id:"AI_IMAGE_GET_ERROR",title:h("Something went wrong, please try again"),placement:"bottomRight",data:V}))},[p,B,h,w,r,V,k,P]);return(0,e.useEffect)(()=>{D.length>1&&te(D[D.length-1])},[D,te]),(0,e.useEffect)(()=>{(g||f.length>0)&&setTimeout(()=>{let v=550;i.current&&(v=i.current.offsetHeight+68),r(v)},0)},[i,D,f.length,g,r]),{aiImageCounter:T,setAiImageCounter:q,currentAiImgLimits:j,isFieldsDisabled:ve,canGenerateImage:pe,aiImageRequest:c,imageAiList:f,setImageAiList:p,isLoadingAi:g,setIsLoadingAi:w,loadingDuringGeneration:ee,setLoadingDuringGeneration:P,requestStatus:N,setRequestStatus:B,handleGenerate:U,handleLimitAiImgCount:ae,convertBase64ToFile:O,isShiftPressed:_,setIsShiftPressed:Y,currentReqId:V,setCurrentReqId:re,limitsInPlugin:$}}var Bt=({setModalHeight:r,customRequest:o,aiTabRef:i,inputAiRef:l,isImageUploaded:u,setIsImageUploaded:c,aiImageRequest:f,setAiImageRequest:p,imageAiList:g,setImageAiList:w,isLoadingAi:I,setIsLoadingAi:y})=>{const h=s.useAppNavigate();s.useDispatch();const x=s.useOpenPlanCatalog(),{__:k,_n:L}=s.useI18n(),b=s.useAppConfig(),[S,R]=(0,e.useState)(!1),[F,Q]=(0,e.useState)(null),{aiImageCounter:D,currentAiImgLimits:G,loadingDuringGeneration:z,requestStatus:W,handleGenerate:H,convertBase64ToFile:T,isShiftPressed:q,setIsShiftPressed:V,limitsInPlugin:re}=Nt({setModalHeight:r,customRequest:o,aiTabRef:i,isImageUploaded:u,setIsImageUploaded:c,aiImageRequest:f,imageAiList:g,setImageAiList:w,isLoadingAi:I,setIsLoadingAi:y,onPluginAiImageLimitExceeded:()=>R(!0),onImageGenerateLimitExceeded:Q}),_=S&&G>0?s.getAiTariffUpgradeStep(G):null,Y=_?s.getLimitUpgradePresetDefinition(_.presetId):null,N=F?s.getLimitUpgradePresetDefinition(F.presetId):null,[B,ee]=(0,e.useState)(!1),P=(0,e.useCallback)(()=>ee(!0),[]),n=(0,e.useCallback)(()=>ee(!1),[]),A=(0,e.useCallback)(E=>p(E.target.value),[p]),j=(0,e.useCallback)(E=>{E.key==="Shift"?V(!0):E.key==="Enter"&&!q&&(E.preventDefault(),H())},[q,H,V]),$=(0,e.useCallback)(E=>{E.key==="Shift"&&V(!1)},[V]),le=g[g.length-1];return(0,t.jsxs)("div",{className:"image-ai",children:[Y&&_?(0,t.jsx)(ne.LimitUpgradeModal$1,{open:!0,onClose:()=>R(!1),title:k(Y.titleKey),subtitle:k(Y.subtitleKey),usageResource:Y.usageResource,previousDisplay:s.presetLimitDisplay(_.previousLimit),nextDisplay:s.presetLimitDisplay(_.nextLimit),onChangePlan:()=>{R(!1),x()}}):null,N&&F?(0,t.jsx)(ne.LimitUpgradeModal$1,{open:!0,onClose:()=>Q(null),title:k(N.titleKey),subtitle:k(N.subtitleKey),usageResource:N.usageResource,previousDisplay:s.presetLimitDisplay(F.previousLimit),nextDisplay:s.presetLimitDisplay(F.nextLimit),onChangePlan:()=>{Q(null),x()}}):null,re&&(0,t.jsx)(m.ui_kit$LimitsCounter,{text:`${D} ${k("of")} ${G>0?G:"∞"} images ${L("was used","were used",D)}`,exceeded:G>0&&D>=G,style:{marginTop:-25},extra:(0,t.jsx)("span",{style:{textDecoration:"underline",cursor:"pointer"},onClick:()=>h(b.billingPageUrl||s.APP_ROUTES.billing),children:k("Need more?")})}),(0,t.jsx)(m.ui_kit$Row,{gutter:24,className:"image-ai__row",children:(0,t.jsx)(m.ui_kit$Col,{span:24,children:(0,t.jsx)(m.ui_kit$Form.Item,{style:{margin:0},children:(0,t.jsxs)("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg image-ai__input-affix-wrapper${B?" ant-input-affix-wrapper-focused":""}`,children:[(0,t.jsx)(m.ui_kit$TextArea,{ref:l,onKeyDown:j,onKeyUp:$,onFocus:P,onBlur:n,autoSize:!0,allowClear:!0,className:"text-area-input-hybrid image-ai__textarea",placeholder:k("Generate image"),value:f,onChange:A,spellCheck:"false"}),(0,t.jsx)("span",{className:"ant-input-suffix image-ai__input-suffix",children:I||z?(0,t.jsx)(s.EmIcons,{icon:"LoadingOutlined",component:m.icons$LoadingOutlined,className:"input-icon image-ai__input-icon",spin:!0}):(0,t.jsx)(s.EmIcons,{icon:"AI",component:m.icons$AI,className:"input-icon image-ai__input-icon",onClick:H})})]})})})}),(I||g.length>0)&&(0,t.jsxs)("div",{className:"image-ai__preview",children:[I&&g.length===0&&(0,t.jsx)("div",{className:"image-ai__loading",children:(0,t.jsxs)("div",{className:"spin",children:[(0,t.jsx)(s.EmIcons,{icon:"LoadingOutlined",component:m.icons$LoadingOutlined,style:{fontSize:48},spin:!0}),(0,t.jsx)("p",{className:"status",children:W})]})}),g.length>0&&(0,t.jsxs)("div",{className:"image-ai__image-item",children:[(0,t.jsx)(Tt,{images:g}),(0,t.jsx)("div",{className:"buttons",children:(0,t.jsx)(m.ui_kit$Button,{onClick:()=>T(le),icon:(0,t.jsx)(s.EmIcons,{icon:"CheckOutlined",component:m.icons$CheckOutlined}),children:k("Use this one")})})]})]})]})},mn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAkCAYAAAB/up84AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABSBJREFUeNrsWjFv2zoQVoMW8BZ18xaN3qLRW9QtW9OtW92to98vaPoP3K1b1S1b3c2jvWlUNm3lw1s8Mpu3PAo4Iocr70jKlp0COuCQlpKPx/t43x1pv3h8fEwGeT5yNoTgeclLZvza6NgxXoNaGRktjE6MpjC2NVqh92bwt4HxBI1ro0s0dgN2tvD5a8a/9vkq0M+xYKdG81A7Gp6pyBjZddrnO6N36Hkbqyn8u4L3vYC0hjLHeAbPVhC4TwAK/ewNvLsEhyxgFXLK2l/D4tvnOVrUiPEh1k/JjvLYyWENdeTcKazBBr6AdY4AqBTmbkIzhO4gvMumYLxAYKzgPTvhBBajYNwCksHYhOyYiow1KONaKYlfO8bPEWyGEfi5Iu+Vjizg7EzB3xvwWTMxWkHG4mDnMF6BnSnYncLzHWGG4BqiwZkKQMC7I0cOVTCJhvRUKNgNCmCOxhNmrBEWzwGi0Y6rIihbsnOH/JgE2hshKrLZv4Px9yhj1twafRlid/UIGWvlFdlVLirIkIM12nETGLeO2tTPECBUZuT/a7JBMpSxUybYLjulUCN2iEpHQoyuGWZJUCa8R/VGSZvGB0iOdjAO9n8EtC2zUxICSIoW0ICTmA53DCDKQzWZg89XAXZ2B2iMavBnjDKpBX6B1tnAM5aqQgGhnU2D6GmHuqw7AkaOPmP/bsHpFC1kTLqVhglS6fFNgX1MCXUHO1zR1h5AFOoSc1jjmKx/An/1PoBQasBSoZZ3hpyaOrg0IW2sRkG8JsU8CaCaLckAhfi6AG0cmeuzkyMQMtL+SiySkY3oA/EgGeICK0UOZYQKVsQpDAjm2BpsaAGQLMKnMdok3yLtpKS70yT7OUBcm7UTHb5grk5y1Csrj40MqUbUpgW7NXo+RunckODkQvdXM37iwm7b1VA7lAaVB4jUUZOUIzNxfOougAwy3GUN0qWG2IJJ09V2NcvIFE8c54nQelEHFM6C6chUhI+WZjjffDQkrenPhqmlrAC9Naof/aLhXZeNNfMZOk+MtPOVRjNmTpfcCut0+biGZ3PBj1ywWTOfqV3v+yjLFuDPRs8Ddu05vLtmsuHQ0s73wehvR0t7aGkPevfCM5fcGr0MbOW9NSSFwF52cP5KcLIv+X4EUGbCemcOqpoz73/haE4CZNkRjAR20vwENXHRc2bWEMyQuUuGVe4hc6K6rBmg7pKN0XdGX7dts9E3Rr8afUATFl1PqgLAG6T3AoX1nSVtMP9l5r5FVyiu+D14/YssRHOheGVQYNMeinrhsMcV2WVPRR1rIRT4QmiA5r4G6oxp0y6ZzFh4LvhmB84MHz1xta9vWQMrcFR/3iF+7DmEu2YoyTshRbuMvGE9hnwGPQR1tdR04aCueKrqAIgiu/AqcCf1JXPhfuoYosGHn4Hgqa6AnCK4IfSkCa1eCJRxLGnn+mX0rfDOJok4AsQAUpwQlND2++HIgNiOVO1LVRIgtXDPs0bpunEU08vktHLMpoJS1/d9qEo6h6gAzq7RRaPV+QmBeICzUUh2fIHzk0s3HedXwkEy2ReQmjn4XDzDjqkN4D/J04/y/np5KbSrrtbwAyx+kTxdf9tfpvSZIW9O3FScHJAF8PEFc5F2lQzSi5wJheoG3U/t0xYOcgBAcOHuAkr7mY9ditoAiCz2q8uvEcD8gJpSDuGNl5hfnaTJ0/fpheMUr4CitHCO6fqdesj359xh1tWiqggfdUCmcz9ZivZ7+BnQM5P/BRgABx8sJWqTxoYAAAAASUVORK5CYII=",Ft=({setNewLink:r,setCurrentImageLink:o,setModalHeight:i,setModalWidth:l,setImageGifList:u,imageGifList:c,currentReqGif:f,setCurrentReqGif:p,inputRef:g,setStockLink:w,customRequest:I})=>{const{__:y}=s.useI18n(),h=s.useAppConfig(),x=s.useIsStandalone(),k=s.useNotification(),[L,b]=(0,e.useState)(null),[S,R]=(0,e.useState)(!1),[F,Q]=(0,e.useState)(25),[D]=s.useLazyGetSearchGifQuery(),G=(0,e.useCallback)(n=>n instanceof Error||typeof n?.message=="string"&&n.message?n.message:typeof n?.error?.message=="string"&&n.error.message?n.error.message:y("Failed to load GIFs through the configured proxy chain."),[y]),z=(0,e.useCallback)(n=>{k.error({id:"STOCK_GIFS_SEARCH_FAILED",title:y("Failed to load GIFs"),description:G(n)})},[y,G,k]),W=async()=>{S||(R(!0),D({query:f,page:F}).then(n=>{if(n?.error){z(n.error),R(!1);return}u(A=>[...A,...n.data.data]),R(!1),Q(A=>A+25)}).catch(()=>{R(!1)}))},H=async()=>{const n=await D({query:f,page:0});if(n?.error){z(n.error),u([]);return}n?.data?.data?.length>0&&(u(n.data.data),setTimeout(()=>{i("84vh"),l(1060)},0))},T=(n,A)=>{b(A),setTimeout(()=>{b(null)},2e3),w(`${n}`),o(`${n}`),I(`${n}`)},q={default:3},V=(0,e.useCallback)(n=>be.getProxiedUrl(n,{config:h,standalone:x,resourceType:"generic",intent:"display"}),[h,x]),re=(0,e.useCallback)(n=>n.id,[]),_=(0,e.useCallback)(n=>n.images.downsized.url,[]),{getDisplaySrc:Y,handleLoad:N,handleError:B}=st({items:c,getItemId:re,getRequestUrl:_,createController:V}),ee=n=>A=>{N(n),A.target.parentNode.classList.add("loaded")},P=n=>()=>{B(n)};return(0,t.jsxs)("div",{className:"stock-tab",children:[(0,t.jsxs)(m.ui_kit$Form,{onValuesChange:H,className:c.length>0?"serach-results":"",children:[(0,t.jsx)(m.ui_kit$Row,{gutter:24,children:(0,t.jsx)(m.ui_kit$Col,{span:c.length>0?"":24,children:(0,t.jsx)(m.ui_kit$Form.Item,{className:"stock-search-input",children:(0,t.jsx)(m.ui_kit$SearchInput,{onSearch:H,allowClear:!0,size:c.length>0?"medium":"large",placeholder:y("Search GIFs"),value:f.keywords,onChange:n=>p(A=>({...A,keywords:n.target.value})),ref:g,spellCheck:"false",enterButton:!1})})})}),c.length>0&&(0,t.jsx)("div",{className:"blocks-search__divider-wrapper",children:(0,t.jsx)("div",{className:"ant-divider ant-divider-horizontal",role:"separator"})})]}),(0,t.jsx)("div",{className:"serach-output-wrapper",style:{marginRight:-10},children:c.length>0&&(0,t.jsx)("div",{id:"scrollableDiv",style:{width:"100%",height:"calc(84vh - 148px)",overflow:"auto",paddingTop:24,paddingRight:14,paddingLeft:24,marginLeft:-24,lineHeight:"0",boxSizing:"unset"},children:(0,t.jsx)(tt,{dataLength:c&&c.length,next:W,hasMore:c,endMessage:(0,t.jsxs)(m.ui_kit$Divider,{plain:!0,children:[y("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:(0,t.jsx)(m.ui_kit$Spin,{size:"small"}),children:(0,t.jsx)(Ne,{breakpointCols:q,className:"my-masonry-grid",columnClassName:"my-masonry-grid_column",children:c.map((n,A)=>(0,t.jsxs)("div",{className:"list-item",onClick:()=>T(n.images.downsized.url,n.id),children:[(0,t.jsx)("img",{className:L===n.id?"loaded-image":"",width:"322px",src:Y(n),alt:n.title,onLoad:ee(n),onError:P(n)}),(0,t.jsx)("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:j=>j.stopPropagation(),children:(0,t.jsx)("div",{className:"overlay-image",style:{backgroundImage:"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAkCAYAAAB/up84AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABSBJREFUeNrsWjFv2zoQVoMW8BZ18xaN3qLRW9QtW9OtW92to98vaPoP3K1b1S1b3c2jvWlUNm3lw1s8Mpu3PAo4Iocr70jKlp0COuCQlpKPx/t43x1pv3h8fEwGeT5yNoTgeclLZvza6NgxXoNaGRktjE6MpjC2NVqh92bwt4HxBI1ro0s0dgN2tvD5a8a/9vkq0M+xYKdG81A7Gp6pyBjZddrnO6N36Hkbqyn8u4L3vYC0hjLHeAbPVhC4TwAK/ewNvLsEhyxgFXLK2l/D4tvnOVrUiPEh1k/JjvLYyWENdeTcKazBBr6AdY4AqBTmbkIzhO4gvMumYLxAYKzgPTvhBBajYNwCksHYhOyYiow1KONaKYlfO8bPEWyGEfi5Iu+Vjizg7EzB3xvwWTMxWkHG4mDnMF6BnSnYncLzHWGG4BqiwZkKQMC7I0cOVTCJhvRUKNgNCmCOxhNmrBEWzwGi0Y6rIihbsnOH/JgE2hshKrLZv4Px9yhj1twafRlid/UIGWvlFdlVLirIkIM12nETGLeO2tTPECBUZuT/a7JBMpSxUybYLjulUCN2iEpHQoyuGWZJUCa8R/VGSZvGB0iOdjAO9n8EtC2zUxICSIoW0ICTmA53DCDKQzWZg89XAXZ2B2iMavBnjDKpBX6B1tnAM5aqQgGhnU2D6GmHuqw7AkaOPmP/bsHpFC1kTLqVhglS6fFNgX1MCXUHO1zR1h5AFOoSc1jjmKx/An/1PoBQasBSoZZ3hpyaOrg0IW2sRkG8JsU8CaCaLckAhfi6AG0cmeuzkyMQMtL+SiySkY3oA/EgGeICK0UOZYQKVsQpDAjm2BpsaAGQLMKnMdok3yLtpKS70yT7OUBcm7UTHb5grk5y1Csrj40MqUbUpgW7NXo+RunckODkQvdXM37iwm7b1VA7lAaVB4jUUZOUIzNxfOougAwy3GUN0qWG2IJJ09V2NcvIFE8c54nQelEHFM6C6chUhI+WZjjffDQkrenPhqmlrAC9Naof/aLhXZeNNfMZOk+MtPOVRjNmTpfcCut0+biGZ3PBj1ywWTOfqV3v+yjLFuDPRs8Ddu05vLtmsuHQ0s73wehvR0t7aGkPevfCM5fcGr0MbOW9NSSFwF52cP5KcLIv+X4EUGbCemcOqpoz73/haE4CZNkRjAR20vwENXHRc2bWEMyQuUuGVe4hc6K6rBmg7pKN0XdGX7dts9E3Rr8afUATFl1PqgLAG6T3AoX1nSVtMP9l5r5FVyiu+D14/YssRHOheGVQYNMeinrhsMcV2WVPRR1rIRT4QmiA5r4G6oxp0y6ZzFh4LvhmB84MHz1xta9vWQMrcFR/3iF+7DmEu2YoyTshRbuMvGE9hnwGPQR1tdR04aCueKrqAIgiu/AqcCf1JXPhfuoYosGHn4Hgqa6AnCK4IfSkCa1eCJRxLGnn+mX0rfDOJok4AsQAUpwQlND2++HIgNiOVO1LVRIgtXDPs0bpunEU08vktHLMpoJS1/d9qEo6h6gAzq7RRaPV+QmBeICzUUh2fIHzk0s3HedXwkEy2ReQmjn4XDzDjqkN4D/J04/y/np5KbSrrtbwAyx+kTxdf9tfpvSZIW9O3FScHJAF8PEFc5F2lQzSi5wJheoG3U/t0xYOcgBAcOHuAkr7mY9ditoAiCz2q8uvEcD8gJpSDuGNl5hfnaTJ0/fpheMUr4CitHCO6fqdesj359xh1tWiqggfdUCmcz9ZivZ7+BnQM5P/BRgABx8sJWqTxoYAAAAASUVORK5CYII=)"}})}),L===n.id&&(0,t.jsx)(m.ui_kit$Spin,{className:"ant-spin",size:"small"})]},n.id+A))})})})})]})},ot="IMG",it="BACKGROUND",zt="GALLERY",we="EDITOR",de="UPLOAD",Fe="STOCK",ze="GIF",$e="AI",$t={mode:"select"},Kt={mode:"save"},{Dragger:Wt}=m.ui_kit$Upload,Vt=(r,o="image")=>s.decodeFileNameFromUrl(r)??o,Se=ne.normalizeImageFormatForDisplay,Ht=(r,o)=>{const i=Se(o);return!i||r.includes(".")?r:`${r}.${i}`},Qt=(r,o)=>new File([r],Ht(Vt(o),r.type),{type:r.type||"application/octet-stream"}),lt=({dataProvider:r,usesBuiltInStorage:o})=>{const i=s.useAppConfig(),l=s.useIntegratorConfigValue("compressMaxSize"),u=s.useIsStandalone(),c=s.shouldInsertUploadLinkAsIs(i),{__:f}=s.useI18n(),p=s.useDispatch(),g=s.useEditorProjectId(),[w]=s.useLazyGetImageInfoQuery(),{modal:I}=m.ui_kit$App.useApp(),y=s.useNotification(),h=s.useSelector(s.selectActiveModal$1),{request:x,resolveImagePicker:k}=s.useImagePicker(),[L,b]=(0,e.useState)(""),[S,R]=(0,e.useState)(""),[F,Q]=(0,e.useState)(""),[D,G]=(0,e.useState)(""),[z,W]=(0,e.useState)(de),[H,T]=(0,e.useState)({width:"",height:"",size:"",format:""}),[q,V]=(0,e.useState)("success"),[re,_]=(0,e.useState)(!1),Y=e.default.useRef(null),N=e.default.useRef(null),B=e.default.useRef(null),ee=e.default.useRef(null),P=e.default.useRef(null),n=e.default.useRef(null),A=e.default.useRef(null),j=e.default.useRef(null),$=e.default.useRef(null),[le,E]=(0,e.useState)("auto"),[ve,ae]=(0,e.useState)(572),[pe,Ce]=(0,e.useState)(!1),[U,Z]=(0,e.useState)({keywords:"",color:"",orientation:""}),[O,te]=(0,e.useState)({keywords:""}),[v,J]=(0,e.useState)([]),[K,se]=(0,e.useState)([]),[ct,qt]=(0,e.useState)([]),[ut,dt]=(0,e.useState)(!1),[ft,Ke]=(0,e.useState)(""),[Yt,je]=(0,e.useState)(!1),[Zt,Ue]=(0,e.useState)(0),mt=s.useProjectData(),pt=mt?.id!==void 0?String(mt.id):g||"",ht=s.useEventEmitter(be.events.UPLOAD_EVENT_ID),fe=ne.useImageBlobResolver(),Re=e.default.useRef(""),ye=e.default.useRef(0),ke=e.default.useRef(""),[Jt,gt]=(0,e.useState)(""),[Xt,vt]=(0,e.useState)(null),[en,We]=(0,e.useState)(""),De=(0,e.useCallback)(a=>{if(!(a instanceof Blob))return;ke.current&&URL.revokeObjectURL(ke.current);const d=URL.createObjectURL(a);ke.current=d,gt(d),vt(a)},[]),me=(0,e.useCallback)(()=>{ke.current&&(URL.revokeObjectURL(ke.current),ke.current=""),gt(""),vt(null)},[]),oe=(0,e.useCallback)(()=>{We("")},[]),Ve=s.usePlanFeatureGate("element_ai_image"),He=s.usePlanFeatureGate("stock_photo"),Qe=s.usePlanFeatureGate("stock_gif"),Ct=s.usePlanFeatureGate("image_editor"),Me=(0,e.useRef)(!1),qe=a=>{Me.current=!0,R(a)},tn=a=>{Me.current=!1,R(a.target.value)},Le=(0,e.useCallback)((a,d,C=f("The image could not be uploaded."))=>{const M=d instanceof Error?d.message:C;y.error({id:"IMAGE_UPLOAD_ERROR",data:a,title:f("Upload failed"),description:M})},[f,y]),nn=(0,e.useCallback)(a=>s.fireUploadImageEvent(ht,{file:a,project:pt}),[pt,ht]),Ae=ne.useImageBlobFetch(),sn=(0,e.useCallback)(a=>fe.resolve(ne.canonicalImageUrlKey(a),void 0,Ae),[Ae,fe]),Ye=async a=>{if(a)try{const d=await an(a);d&&Je(d)?await Ie({file:d}):d||Le({url:a},null,f("Failed to download image from URL."))}catch(d){Le({url:a},d,f("Failed to process image URL."))}},yt=(a,d)=>{const C=s.resolveUploadLinkAction(c,d,Me.current);C==="insertAsIs"?(Me.current=!1,Ge({url:a})):C==="upload"&&Ye(a)},Ze=e.default.useRef(yt);Ze.current=yt;const rn=(0,e.useCallback)(()=>{const a=S.trim();a.toLowerCase().startsWith("http")&&Ze.current(a,"enter")},[S]);e.default.useEffect(()=>{if(z!==de||!D)return;const a=S.trim();if(!a||!a.toLowerCase().startsWith("http"))return;const d=setTimeout(()=>{Ze.current(a,"timer")},1e3);return()=>{clearTimeout(d)}},[S,z,D]);const an=async a=>{try{const d=ne.canonicalImageUrlKey(a),C=await fe.resolve(d,void 0,Ae);return Qt(C,d)}catch{}};document.onpaste=function(a){const d=a.clipboardData?.items?.[0];if(z===de&&D){if(d?.type?.indexOf("image")===0&&i.imageCenterLocalUploadEnabled!==!1){const M=d.getAsFile();Je(M);const X={file:M};R(""),Ie(X);return}const C=a.clipboardData?.getData("text/plain");if(C&&C.trim().toLowerCase().startsWith("http")){a.preventDefault(),a.stopPropagation(),qe(C.trim());return}d?.type?.indexOf("text")===0&&d.getAsString(M=>{if(M.trim().toLowerCase().startsWith("http"))qe(M.trim());else if(M.toString().slice(1,5)==="meta"){const X=M.toString().split('"')[1];X&&qe(X)}})}},(0,e.useEffect)(()=>{const a=d=>{let C=null;x?.kind==="background"?(C=it,G(it)):x?.kind==="img"&&(G(ot),C=ot),x?.currentUrl&&C&&(b(x.currentUrl),W(d))};h===s.MODALS.UPLOAD_IMAGE_MODAL||h===s.MODALS.UPLOAD_BACKGROUND_MODAL?a(we):h===s.MODALS.UPLOAD_IMAGE_MODAL_AI||h===s.MODALS.UPLOAD_BACKGROUND_MODAL_AI?(Ve.isLocked?(je(!0),Ue(s.FEATURE_UPSELL_SLIDE.element_ai_image)):a($e),setTimeout(()=>$.current?.focus({cursor:"start"}),100)):h===s.MODALS.UPLOAD_IMAGE_MODAL_UPLOAD||h===s.MODALS.UPLOAD_BACKGROUND_MODAL_UPLOAD?(a(de),setTimeout(()=>n.current?.focus({cursor:"start"}),100)):h===s.MODALS.UPLOAD_IMAGE_MODAL_STOCK||h===s.MODALS.UPLOAD_BACKGROUND_MODAL_STOCK?(He.isLocked?(je(!0),Ue(s.FEATURE_UPSELL_SLIDE.stock_photo)):a(Fe),setTimeout(()=>j.current?.focus({cursor:"start"}),100)):h===s.MODALS.UPLOAD_IMAGE_MODAL_GIF||h===s.MODALS.UPLOAD_BACKGROUND_MODAL_GIF?(Qe.isLocked?(je(!0),Ue(s.FEATURE_UPSELL_SLIDE.stock_gif)):a(ze),setTimeout(()=>A.current?.focus({cursor:"start"}),100)):h===s.MODALS.UPLOAD_IMAGE_MODAL_EDIT||h===s.MODALS.UPLOAD_BACKGROUND_MODAL_EDIT?(Ct.isLocked?(je(!0),Ue(s.FEATURE_UPSELL_SLIDE.image_editor)):a(we),p(s.openSecondModal(s.MODALS.IMAGE_EDITOR_MODAL))):G("")},[h,p,Ve.isLocked,He.isLocked,Qe.isLocked,Ct.isLocked,x]);const Ge=(0,e.useCallback)(({url:a=L||"",meta:d=$t})=>{b(a),k({url:a,meta:d}),setTimeout(()=>{oe(),me(),Z({keywords:"",color:"",orientation:""}),te({keywords:""}),se([]),J([]),G(""),Ke(""),dt(!1),Q(""),R(""),W(de)},200),p(s.closeModal$1()),p(s.closeSecondModal())},[L,oe,p,k,me]),At=(0,e.useCallback)((a,d)=>(E("auto"),_(!1),Ge({url:a,meta:Kt}),y.success({id:"IMAGE_UPLOAD_SUCCESS",data:d,title:f("The image was successfully uploaded.")}),a),[f,Ge,y]);(0,e.useEffect)(()=>{const a=c?"":S,d=a||F,C=ne.canonicalImageUrlKey(d);if(!d||!C){V(""),Re.current&&fe.abandonKey(Re.current),Re.current="",oe(),me();return}const M=Re.current;M&&M!==C&&(fe.abandonKey(M),oe(),me()),Re.current=C;const X=new AbortController,ce=a?800:0,he=++ye.current,un=setTimeout(async()=>{try{const xe=async()=>{const ue=await fe.resolve(C,X.signal,Ae);if(he!==ye.current)return;const{width:ge,height:dn}=await ne.getImageDimensionsFromBlob(ue);he===ye.current&&(T({width:ge,height:dn,size:(ue.size/1024).toFixed(2),format:Se(ue.type)}),oe(),De(ue))};if(u)await xe();else{const ue=await ne.resolveDataProviderPreview(r,C);if(ue?.previewUrl&&he===ye.current){We(ue.previewUrl),me();try{const{data:ge}=await w(C);if(he!==ye.current)return;ge?T({width:ge?.width,height:ge?.height,size:ge?.fileSize!=null?(ge.fileSize/1024).toFixed(2):"",format:Se(ge?.format)}):await xe()}catch{await xe()}}else await xe()}if(he!==ye.current)return;V("success"),b(d),ae(572),setTimeout(()=>{let ue=0;N.current&&(ue=N.current.offsetHeight+62),E(ue)},0)}catch(xe){if(xe?.name==="AbortError"||X.signal.aborted||he!==ye.current)return;oe(),me(),V("error")}},ce);return()=>{clearTimeout(un),X.abort()}},[S,F,c,u,oe,Ae,w,fe,me,r,De]),(0,e.useEffect)(()=>{if(!L||S||F||!h)return;const a=ne.canonicalImageUrlKey(L),d=new AbortController;let C=!1;const M=async()=>{const X=await fe.resolve(a,d.signal,Ae);if(C)return;const{width:ce,height:he}=await ne.getImageDimensionsFromBlob(X);C||(oe(),De(X),T({width:ce,height:he,size:(X.size/1024).toFixed(2),format:Se(X.type)}))};return(async()=>{try{if(!u){const X=await ne.resolveDataProviderPreview(r,a);if(X?.previewUrl&&!C){We(X.previewUrl),me();try{const{data:ce}=await w(a);if(C)return;ce?T({width:ce?.width,height:ce?.height,size:ce?.fileSize!=null?(ce.fileSize/1024).toFixed(2):"",format:Se(ce?.format)}):await M();return}catch{await M()}}}await M()}catch{C||oe()}})(),()=>{C=!0,d.abort()}},[u,h,oe,L,Ae,w,fe,r,S,F,De]);const on=()=>{p(s.closeModal$1()),setTimeout(()=>{oe(),me(),b(""),R(""),se([]),se([]),Z({keywords:"",color:"",orientation:""}),te({keywords:""}),E("auto"),!ut&&Ke(""),ae(572),W(de)},200)},ln=a=>{a===zt?I.success({mask:{closable:!0},centered:!0,title:f("Coming soon"),content:f("The feature is under development."),okText:f("Ok. I'll be waiting"),onOk:()=>{}}):a===we&&L===""?I.warning({mask:{closable:!0},centered:!0,title:f(""),content:f("To preview and edit the uploaded image"),okText:f("Upload Image"),onOk:()=>{W(de)}}):(setTimeout(()=>{let d=0,C=0;a===de&&Y.current?(U.keywords===""&&n.current?.focus({cursor:"start"}),d=300,C=572):a===we&&N.current?(d=N.current.offsetHeight+62,C=572):a===Fe&&B.current?(U.keywords===""&&j.current?.focus({cursor:"start"}),d=130,C=572,K.length>0&&(C=1060,d="84vh")):a===ze&&ee.current?(U.keywords===""&&A.current?.focus({cursor:"start"}),d=130,C=572,v.length>0&&(C=1060,d="84vh")):a===$e&&P.current&&(ft===""&&ct.length===0?($.current?.focus({cursor:"start"}),d=130):d=P.current.offsetHeight+82,C=572),E(d),ae(C)},0),W(a))};(0,e.useEffect)(()=>{U.keywords===""&&(n?.current?.focus({cursor:"start"}),se([]),setTimeout(()=>{E("auto"),ae(572)},0))},[U,se,E,ae]);const Je=a=>{const d=a.type==="image/jpeg"||a.type==="image/png"||a.type==="image/jpg"||a.type==="image/webp"||a.type==="image/gif"||a.type==="image/svg+xml";return d||y.error({id:"IMAGE_UPLOAD_WRONG_FORMAT",data:a,title:"Upload",description:"You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!"}),d},bt=(0,e.useRef)(null),Ie=async({file:a})=>{try{Ce(!0);const d=a===bt.current?await s.prepareImageForEditorResult(a,i,void 0,{compressBySize:l!==void 0}):await s.prepareImageForEditorUpload(a,i),C=await nn(d);if(C.url)return At(C.url,d),C.url;if(!s.shouldFallbackToBuiltInUpload(C,{isStandalone:u,targetIsOurBackend:!!o})){Le(d,s.toUploadImageError(C));return}const M=await s.uploadFileViaDataProvider(d,r);if(M?.url)return At(M.url,d),M.url;Le(d,null);return}catch(d){Le(a,d);return}finally{Ce(!1)}},wt=(0,e.useRef)(Ie);wt.current=Ie;const cn=(0,e.useCallback)(a=>(bt.current=a,wt.current({file:a})),[]);let Oe=[{label:f("Upload"),key:de,children:(0,t.jsxs)("div",{ref:Y,style:{paddingBottom:24},children:[i.imageCenterLocalUploadEnabled!==!1&&(0,t.jsxs)(Wt,{showUploadList:!1,name:"Image",beforeUpload:Je,customRequest:Ie,style:{marginBottom:10},multiple:!1,accept:"image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml",children:[(0,t.jsx)("p",{className:"ant-upload-drag-icon",children:(0,t.jsx)(s.EmIcons,{icon:"InboxOutlined",component:m.icons$InboxOutlined})}),(0,t.jsx)("p",{className:"ant-upload-text",children:f("Click to select, paste from the clipboard, or drag and drop")}),(0,t.jsx)("p",{className:"ant-upload-hint",children:f("Accepted formats: PNG, JPG, WEBP, SVG or GIF.")})]}),(0,t.jsx)(m.ui_kit$Form,{style:{padding:"0 2px 0 2px"},children:(0,t.jsx)(m.ui_kit$Form.Item,{validateStatus:q,children:(0,t.jsx)(m.ui_kit$Input,{ref:n,allowClear:!0,size:"large",placeholder:f("Paste image URL here"),value:S,onChange:tn,onPressEnter:rn,spellCheck:"false"})})})]})}];return i.imageCenterStockEnabled&&!He.isLocked&&Oe.push({label:f("Stock"),key:Fe,children:(0,t.jsx)("div",{ref:B,style:{paddingBottom:24},children:(0,t.jsx)(Mt,{currentReq:U,setCurrentReq:Z,imageStockList:K,setImageStockList:se,setModalWidth:ae,setModalHeight:E,setStockLink:Q,setCurrentImageLink:b,inputRef:j,customRequest:Ye})})}),i.imageCenterGifEnabled&&!Qe.isLocked&&Oe.push({label:f("GIF"),key:ze,children:(0,t.jsx)("div",{ref:ee,style:{paddingBottom:24},children:(0,t.jsx)(Ft,{currentReqGif:O,setCurrentReqGif:te,imageGifList:v,setImageGifList:J,setModalWidth:ae,setModalHeight:E,setStockLink:Q,setCurrentImageLink:b,inputRef:A,customRequest:Ye})})}),i.elementAIimageEnabled&&!Ve.isLocked&&Oe.push({label:f("AI"),key:$e,children:(0,t.jsx)("div",{ref:P,style:{paddingBottom:24},children:(0,t.jsx)(Bt,{setModalHeight:E,customRequest:Ie,aiImageRequest:ft,setAiImageRequest:Ke,imageAiList:ct,setImageAiList:qt,isLoadingAi:ut,setIsLoadingAi:dt,aiTabRef:P,inputAiRef:$,isImageUploaded:re,setIsImageUploaded:_})})}),i.imageCenterEditorEnabled&&Oe.push({label:"",key:we,children:(0,t.jsx)("div",{ref:N,children:(0,t.jsx)(jt,{currentImageLink:L,newLink:S,previewDisplayUrl:en,resolvedPreviewObjectUrl:Jt,resolvedPreviewBlob:Xt,resolveImageBlob:sn,imageSize:H,onSave:cn,uploadImageResultIsLoading:pe||!1})})}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.ui_kit$Modal,{width:ve,className:"image-center",title:f("Image Center"),style:{minHeight:390},open:!!D,onOk:Ge,onCancel:on,footer:z===we?(0,t.jsx)(t.Fragment,{}):null,children:(0,t.jsx)(m.ui_kit$Spin,{spinning:pe,children:(0,t.jsx)(m.ui_kit$Tabs,{activeKey:z,onChange:ln,items:Oe,className:"modal-tabs",style:{height:le,minHeight:130}})})}),(0,t.jsx)(s.PlanUpgradePrompt,{open:Yt,onCancel:()=>je(!1),initialSlide:Zt})]})};lt.propTypes={dataProvider:_t.default.object},kt.default=lt});
@@ -1 +0,0 @@
1
- var m=class Ae{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof Ae&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const n=this._inner.indexOf(t);n>=0&&this._inner.splice(n,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function F(e){return`service_container_${e}`}var N=new Set,W;function qe(){if(!W)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,Ie.prototype.getInstanceAsync),e.stack}function U(e){N.delete(e)&&W?.end(e)}var Ie=class G extends m{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){[...this._injectCallbacks].forEach(n=>n(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(n=>this._runCallbacks(n)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const n=this._injectCallbacks.indexOf(t);n>=0&&this._injectCallbacks.splice(n,1)}});inject(t,n){this._injections[t]=()=>n,this._runCallbacks(t)}injectFactory(t,n,r){const s=this._injections[t];let o=typeof s=="function"?s():s;const i=this._injections[t]=()=>(o=n(this,o),o);r&&i(),this._runCallbacks(t)}_find(t,n=!0){return this._injections[t]||n&&this._parent?._find(t)}_onInject(t,n,r=new m){return r.addDisposable(this.onInject(s=>{t===s&&!r.isDisposed()&&(r.dispose(),n(this.getInstance(s)))})),this._parent&&r.addDisposable(this._parent._onInject(t,n,r)),this.addDisposable(r),r}getInstance(t,n=!0){const r=this._find(t,n);if(typeof r=="function")return r()}getOrCreateInstance(t,n){const r=this._find(t);if(typeof r=="function")return r();const s=n(this);return this.inject(t,s),s}getInstanceAsync(t){const n=this._find(t);if(typeof n=="function")return Promise.resolve(n());const r=qe();return new Promise((s,o)=>{const i={id:String(t),startedAt:Date.now(),origin:r,container:this,reject:o};N.add(i),W?.start(i),this._onInject(t,()=>{U(i),s(this.getInstance(t))})})}failPendingWaits(t){for(const n of Array.from(N))n.container===this&&(U(n),n.reject(t))}pendingWaits(){return[...N].filter(t=>t.container===this)}addService(t,n){const r=F(t);this.injectFactory(r,(o,i=[])=>i.indexOf(n)<0?[...i,n]:i);const s=new m;return s.addDispose(()=>{this.injectFactory(r,(o,i=[])=>i.filter(a=>a!==n))}),s}addServiceFactory(t,n,r){const s=F(t);let o;this.injectFactory(s,(a,c=[])=>(o=n(a,o),o===void 0?c:c.indexOf(o)<0?[...c,o]:c),r);const i=new m;return i.addDispose(()=>{this.injectFactory(s,(a,c=[])=>o===void 0?c:c.filter(_=>_!==o))}),i}getServices(t){const n=F(t);return[...this.getInstance(n,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new G(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const n=this._parent?.getOrCreateIsolatedContainer(t);return new G(n)})}remove(t){const n=this._injections;delete n[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(N))t.container===this&&U(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function H(e){return e.startsWith("__")?e:`__${e}__`}function ze(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=H(e),n=globalThis;return n[t]??={}}function Je(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function Ye(e){if(e)return H(e);const t="useblocks".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return H(t)}function Oe(e){const t=Ye(e),n=ze(t);if(Je(n.container))return n.container;const r=new Ie(null);return n.container=r,r}function Tn(e){return Oe(e)}function Qe(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),(n==="x"?r:r&3|8).toString(16)})}function Ze(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Qe()}function d(e=Ze()){return e}function ge(){return"esm".trim()||"unknown"}function et(e){if(typeof globalThis>"u")return;const t=ge(),n=globalThis[e]??{};globalThis[e]=n;const r=n.__diagnostics??={},s=r.diModuleEval??={evalCount:0,records:[]};s.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),s.evalCount+=1}function tt(){const e="useblocks".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function nt(e,t){if(et(t),typeof globalThis>"u")return e;const n=ge(),r=globalThis,s=r[t]=r[t]||{},o=s.__diagnostics=s.__diagnostics||{},i=o.dependencyResolver=o.dependencyResolver||{entries:[]},a={container:e,source:"packages/runtime-core/di/index.ts",buildSource:n,timestamp:Date.now(),stack:new Error().stack};return i.entries.push(a),e}var w;function rt(){if(w)return w;const e=tt();return w=nt(Oe(e),e),w}var te=new Proxy({},{get(e,t,n){const r=rt(),s=Reflect.get(r,t,n);return typeof s=="function"?s.bind(r):s}});function Sn(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function y(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function Dn(e){return e instanceof DOMException&&e.name==="AbortError"}function me(e){if(e?.aborted)throw y(e.reason)}function Nn(e,t){return t?(t.aborted&&e.catch(()=>{}),me(t),new Promise((n,r)=>{const s=()=>{o(),r(y(t.reason))},o=()=>{t.removeEventListener("abort",s)};t.addEventListener("abort",s),e.then(i=>{o(),n(i)},i=>{o(),r(i)})})):e}var Te=class extends m{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,n){if(this.isDisposed())return{dispose:()=>{}};const r=this._listeners,s=this._options;n&&typeof e=="function"&&(e=e.bind(n));const o=r.findIndex(([,a])=>a<t),i=[e,t];return r.splice(o>=0?o:r.length,0,i),r.length===1&&s.onFirstListenerAdd&&s.onFirstListenerAdd(),{dispose:()=>{const a=r.indexOf(i);a>=0&&(r.splice(a,1),!r.length&&s.onLastListenerRemove&&s.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,n)=>{const r=this._addListener((...s)=>(r?.dispose(),n?e.call(n,...s):e(...s)),t);return r};un=e=>{const t=this._listeners.findIndex(([n])=>n===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},L=class extends Te{execute(e,t){for(const n of t)try{n(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},Cn=class extends L{execute([e],t){for(const n of t)try{n(e)}catch{}}},vn=class extends L{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const n of t)try{n(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},K=class extends L{async execute([e],t){const n=[];for(const r of t)try{n.push(await r(e))}catch{}return n}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const n of this.getListeners([e]))try{t.results.push(await n(e))}catch(r){t.errors.push(r)}return t}};function yn(e,t=0){const n=new Te,r=e(n,t);return r&&n.addDisposable(r),n.event}function Ln(e,t,n=0){const r=new L,s=e((...o)=>{if(t(...o))return r.fire(...o)},n);return s&&r.addDisposable(s),r.event}function Pn(e,t=0,n=0){const r=new L;let s,o;const i=e((...a)=>{o=a,s||(s=setTimeout(()=>{o&&r.fire(...o),s=void 0},t))},n);return i&&r.addDisposable(i),r.event}function bn(e,t){return e.getOrCreateInstance(t,()=>new K)}function l(e){return d(e)}var ne;(function(e){e.BEFORE_SAVE_EMAIL=l("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=l("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=l("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=l("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=l("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=l("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=l("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=l("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=l("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=l("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=l("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=l("events.ON_EMAIL_CHANGED_ID"),e.ON_HEADER_APPLIED_ID=l("events.ON_HEADER_APPLIED_ID"),e.ON_BLOCK_CHANGED_ID=l("events.ON_BLOCK_CHANGED_ID"),e.ON_BLOCK_OPEN_ID=l("events.ON_BLOCK_OPEN_ID"),e.ON_BLOCK_CLOSE_ID=l("events.ON_BLOCK_CLOSE_ID"),e.OPEN_BLOCK_REQUEST_ID=l("events.OPEN_BLOCK_REQUEST_ID"),e.ON_BLOCK_SAVEBUTTON_CLICK_ID=l("events.ON_BLOCK_SAVEBUTTON_CLICK_ID"),e.ON_BLOCK_CLONE_ID=l("events.ON_BLOCK_CLONE_ID"),e.ON_CHUNKS_LOADED=l("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=l("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=l("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=l("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=l("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=l("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=l("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_ANALYTICS_EVENT=l("events.ON_ANALYTICS_EVENT"),e.ON_NOTIFICATION=l("events.ON_NOTIFICATION"),e.READ_LOCALE=l("events.READ_LOCALE"),e.ON_TRANSLATE_ID=l("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=l("events.ON_CODE_VALIDATE_ID"),e.ON_IMPORT_VALIDATE_ID=l("events.ON_IMPORT_VALIDATE_ID"),e.UPLOAD_EVENT_ID=l("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=l("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=l("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=l("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=l("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=l("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=l("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=l("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=l("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=l("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=l("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=l("events.AI_TEXT_STREAM_ID")})(ne||(ne={}));function Rn(e,t){return e.getOrCreateInstance(t,()=>new K).event}function xn(e,t){return e.getOrCreateInstance(t,()=>new K)}var wn=d("plugin.app"),Mn=d("plugin.disposable"),Bn=d("InitPipelineContext"),kn=d("plugin.instance"),Fn=d("plugin.lateSurfaceListeners"),st=d("plugin.optionsSource"),Un=d("plugin.store"),ot=d("ConfigSource"),jn=d("plugin.standalone.project"),it=d("plugin.standalone.bootstrapToken"),Gn=d("plugin.element"),at=d("plugin.securityModule"),Hn=d("plugin.standalone.activated"),Xn=d("plugin.standalone.fileProxyRegistered"),X=d("plugin.jwt.token"),C=d("plugin.jwt.error"),Vn=d("PluginCollection"),$n=l("APP_LOAD_EVENT"),Wn=l("CONFIG_CHANGED_EVENT");function ct(e,t=window){return{peer:e,send(n){e.postMessage(n,"*")},subscribe(n){const r=s=>{n({data:s.data,source:s.source,ports:s.ports})};return t.addEventListener("message",r),{dispose:()=>t.removeEventListener("message",r)}},close(){}}}function _t(e){let t=!1;return{peer:e,send(n){e.postMessage(n)},subscribe(n){const r=s=>{n({data:s.data,source:e})};return e.addEventListener("message",r),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",r)}},close(){e.close()}}}function Kn(e){return e}function ut(e){return e&&typeof e=="object"}function re(e,t){return e&&typeof e=="object"&&e.operationId===t}var g="INIT_MESSAGE",lt="em:port-ready",dt="em:window-drained",j="";function se(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var ft=class extends m{_listeners=Object.create(null);addListenerAsync=(e,t,n=0,r)=>{const s=this._listeners[e]||(this._listeners[e]=[]);r&&typeof t=="function"&&(t=t.bind(r));const o=s.findIndex(([a,c])=>n<=c),i=[t,n];return this.isDisposed()||s.splice(o>=0?o:s.length,0,i),{dispose(){const a=s.indexOf(i);a>=0&&s.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const n=this._listeners[e]||(this._listeners[e]=[]);let r;for(let s=0;s<n.length;s++){const o=n[s][0],i=r;r=a=>o(a,i)}if(r)return r(t)}};addListener=(e,t,n=0)=>this.addListenerAsync(e,(r,s)=>{try{t(r)}catch{}return s&&s(r)},n)},qn=class extends m{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new ft);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=ct({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(g,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(g))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,n=t.data,r=t.source,s=n?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&r&&n?.operationId==="em:window-drained"){this._ports.has(r)&&this._drained.add(r);return}if(o&&r&&this._drained.has(r))return;if(r&&r!==this._target&&this._greeted.has(r)&&re(n,g)){this._greeted.delete(r),this._handshaken.add(r),this._postMessage(r,{operationId:g,data:{}}),s&&this.usePort(s,!0,r);return}const i=t.source===this.target||this._isCurrentPort(t.source);if(i||this._notifyOffTarget(n?.operationId,t.source),ut(n)&&i||this._singleton&&re(n,g)){if(s&&i){const u=this._target;Promise.resolve().then(()=>this.usePort(s,!0,u))}const a=this._emitter.fireAsync(n.operationId||j,n.operationId===void 0?t:n.data),c=n.result,_=n.error;c&&_&&Promise.resolve(a).then(u=>this._sendMessage(c,u),u=>this._sendMessage(_,u))}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(g,void 0);return}this._inited=!1,this._postMessage(e,{operationId:g,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:g,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const n of Array.from(this._outgoingObservers))try{n(e,t)}catch{}}addOffTargetListener(e,t){let n=this._offTargetListeners.get(e);return n||(n=new Set,this._offTargetListeners.set(e,n)),n.add(t),{dispose:()=>{n.delete(t)}}}_notifyOffTarget(e,t){const n=typeof e=="string"?this._offTargetListeners.get(e):void 0,r=n?.size?this._knownPeer(t):void 0;if(!(!n||!r))for(const s of Array.from(n))try{s(r)}catch{}}_knownPeer(e){for(const[n,r]of this._ports)if(r.transport.peer===e)return n;const t=e;return typeof e=="object"&&e!==null&&(this._handshaken.has(t)||this._greeted.has(t))?t:void 0}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:g,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,n=this._target){if(!n||this._ports.has(n))return;const r=_t(e),s=r.subscribe(this._onTransportMessage);this._ports.set(n,{transport:r,subscription:s}),t&&(r.send({operationId:lt,data:{}}),this.drainWindow(n))}holdPort(e=this._target){!e||!this._ports.has(e)||(this._portSendHeld.add(e),this._drained.delete(e))}resumePort(e=this._target){e&&this._portSendHeld.delete(e)}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)&&!this._portSendHeld.has(this._target)}hasPort(e,t){const n=this._ports.get(e);return n!==void 0&&(t===void 0||n.transport.peer===t)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e),this._portSendHeld.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:dt,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,n){let r=t;this._outgoingFilter&&!n?.length&&(r="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const s=this._ports.get(e);if(s&&!this._portSendHeld.has(e)){s.transport.send(r);return}if(n?.length){e.postMessage(r,"*",n);return}e.postMessage(r,"*")}catch(s){if(s?.name==="DataCloneError"){const o=typeof r?.data=="object"&&r?.data!==null?r.data:void 0}throw s}}_sendMessage(e,t,n=!0){if(!n&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const r=this.addDisposable(this.onInit(s=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(s,{...o})}finally{r.dispose()}}))}send(e,t,n){return typeof e=="string"?this._sendMessage(e,t,n):this._sendMessage(j,e,t)}sendAsync(e,t,n=!0){if(!n&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const r=se(),s=se();return new Promise((o,i)=>{const a=this.addDisposable(new m);a.addDisposable(this.onInit(c=>{try{this._postMessage(c,{operationId:e,data:t,result:r,error:s})}catch(_){a.dispose(),i(_);return}a.addDisposable(this._onMessage(r,_=>{o(_),a.dispose()})),a.addDisposable(this._onMessage(s,_=>{i(_),a.dispose()}))}))})}_onMessage(e,t,n=0){return this._emitter.addListener(e,t,n)}addListener(e,t,n){return t?this._onMessage(e,t,n):this._onMessage(j,e)}addListenerAsyncPipe(e,t,n=0){return this._emitter.addListenerAsync(e,t,n)}addListenerAsync(e,t,n=0){return this._emitter.addListenerAsync(e,async(r,s)=>{const o=await t(r);return s?s(r):o},n)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,n=0){const r=this.addDisposable(new m);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?r.addDisposable(this.onInit(e,t,n)):e(this._target)}):r.addDisposable(this._onMessage(g,()=>{e(this._target)},n)),r}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function P(e){return d(e)}var zn=d("extensions.atomsHandlers"),Jn=P("HANDLE_ATOM_INSERT"),Yn=d("HeadlessMode"),Qn=d("extensions.sandboxExtensions"),Zn="SANDBOX_EXTENSION_SCRIPT_STATUS",er=d("MESSAGE_SERVICE"),tr=P("SETTINGS_PANEL_EVENT"),nr="advanced",rr=P("MODAL_SHOW_EVENT"),sr=P("MODAL_CLOSE_EVENT"),or=P("MODAL_UPDATE_EVENT"),ir=d("client"),ar=d("v2_client"),cr=d("ai_client"),_r=d("app.cookieManager"),ur=d("app.storageProvider"),lr=d("image-blob-resolver"),dr=d("template-directives"),fr=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),pt=class{baseUrl="https://api.emailmaker.ru/wp-json";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};async request({body:e,secure:t,path:n,type:r,query:s,format:o,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:_,...u}){const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(u,f);c&&(s=s?{...s,...c}:c);const p=s&&this.toQueryString(s),I=this.contentFormatters[r||"application/json"],E=o||h.format,R=`${i||this.baseUrl||""}${n}${p?`?${p}`:""}`,We=_?_(R,{body:e,secure:t,path:n,type:r,query:s,format:o,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:_,...u}):R,Z=new Request(We,{...h,headers:{...h.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):h.signal)||null,body:typeof e>"u"||e===null?null:I(e)});return this.customFetch(Z).then(async ee=>{const O=ee;O.data=null,O.error=null,O.meta={request:Z,response:O};const Ke=E?await ee[E]().then(x=>(O.ok?O.data=x:O.error={data:x},O)).catch(x=>(O.error=x,O)):O;return a&&this.abortControllers.delete(a),Ke})}},ht=d("prewarm.networkActivity");function Et(){let e=0;const t=new Set,n=()=>{t.forEach(r=>r())};return{begin(){e+=1,n();let r=!1;return()=>{r||(r=!0,e-=1,n())}},inFlight:()=>e,watch(r){return t.add(r),()=>t.delete(r)}}}function At(e){return e.getOrCreateInstance(ht,()=>Et())}var It=Symbol("rest.publicRequest"),q=d("rest.requestHandler"),Ot=d("rest.responseHandler"),Se=d("rest.customFetch"),gt=(e,t)=>fetch(e,t),De=d("rest_transport"),mt=e=>{e.inject(Se,{execute:async(t,n={})=>{const r=e.getServices(q),s={public:n[It]===!0},o=At(e).begin();try{let i=t instanceof Request?t:new Request(t,n);for(const _ of r){const u=await _.execute(i,s);u instanceof Request&&(i=u)}let a=await fetch(i);const c=e.getServices(Ot);for(const _ of c)a=await _.execute(a,i);return a}finally{o()}}})};function pr(e,t){const n=e.getInstance(De);if(!n)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(r=>new r(n)))}var Tt="INJECTION";function St(e){return e.getState}function hr(e){if(!St(e)){e.dispose();return}const t=e.getState()[Tt];t&&(te.getInstance(t)?.dispose(),te.remove(t))}function Er(e,t){for(const n of e)if(n&&t in n)return n[t]}function Dt(e){return Object.assign({},...e)}var Ne=["generic","stockImages","emFiles","cdn"];function z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function oe(e){return!z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Ne.includes(t))}function Ce(e){return e.length===0?[]:e.length===1?e[0]:e}function ve(e){let t=!1,n=[];for(const r of e)if(r!==void 0){if(t=!0,Array.isArray(r)){n=[...r,...n];continue}n=[r,...n]}if(t)return Ce(n)}function Nt(e){return z(e)&&("value"in e||"replace"in e)}function ie(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Ct(e){let t=!1,n=[],r=!1;for(const o of e)if(o!==void 0){if(Nt(o)){t=!0,o.replace&&(n=[],r=!0),o.value!==void 0&&(n=ie(n,o.value),r=!0);continue}n=ie(n,o),r=!0}const s=r?Ce(n):void 0;if(!t)return s;if(s!==void 0)return{value:s}}function Ar(e){const t=e.filter(r=>r!==void 0);if(t.length===0)return;if(!t.some(r=>oe(r)))return ve(t);const n={};for(const r of Ne){const s=Ct(e.map(o=>{if(o!==void 0)return oe(o)?o[r]:r==="generic"?o:void 0}));s!==void 0&&(n[r]=s)}return Object.keys(n).length>0?n:void 0}function Ir(e){return ve(e)}function vt(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(z(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function yt(e,t){const n=[...e],r=new Set(n.map(s=>s.toLowerCase()));for(const s of t){const o=s.trim().replace(/:\d+$/,"");if(!o)continue;const i=o.toLowerCase();r.has(i)||(r.add(i),n.push(o))}return n}function Lt(e){let t=[],n=!1;for(const r of e){const s=vt(r);s&&(n=!0,s.replace&&(t=[]),t=yt(t,s.hosts))}return n?t:void 0}function Or(e){const t=e.filter(s=>s!==void 0);if(t.length===0)return;const n=Dt(t.map(({directHosts:s,...o})=>o)),r=Lt(t.map(s=>s?.directHosts));return r!==void 0&&(n.directHosts=r),n}function J(e){return e?.backendProxy}function v(e){return e.replace(/\/$/,"")}function ye(e){return/^https?:\/\//i.test(e)}function Le(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Pt(e){const t=new Set;return e.filter(n=>!n.url||t.has(n.url)?!1:(t.add(n.url),!0))}function bt(e){const t=J(e);return t?[t]:[]}function Rt(e){return{proxyEmFiles:!0,proxyAi:!1}}function xt(e,t){const n=Rt(t),r=t?.backendProxyPolicy;switch(e){case"emFiles":return r?.proxyEmFiles??n.proxyEmFiles;case"ai":return r?.proxyAi??n.proxyAi;default:return!0}}var wt={url:".+",url_encoded:".+",origin:"https?:\\/\\/[^\\/?#]+",origin_encoded:".+",proxy_url:"https?:\\/\\/[^\\/?#]+",proxy_url_encoded:".+",path:"[^?#]*",pathname:"[^?#]*",path_with_slash:"\\/[^?#]*",pathname_with_slash:"\\/[^?#]*",query:"[^#]*",search:"\\?[^#]*",hash:"#.*",fragment:".*",pathname_after_wp_json:"[^?#]*",pathname_after_wp_json_with_slash:"\\/[^?#]*",rest_namespace:"[^/?#]*",rest_version:"[^/?#]*",rest_route:"[^?#]*",rest_route_with_slash:"\\/[^?#]*"};function Mt(e){const t=[],n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(r,s)=>(t.push(s),`(${wt[s]||".+"})`));return{regex:new RegExp(`^${n}$`,"i"),tokens:t}}function Bt(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function kt(e,t){if(Bt(t))return e;try{const n=new URL(e);return`${n.origin}${n.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Ft(e,t,n){if(n.endsWith("_encoded"))return!0;const r=e.slice(0,t),s=r.lastIndexOf("#"),o=r.lastIndexOf("?"),i=r.lastIndexOf("&"),a=r.lastIndexOf("=");return a>Math.max(o,i)&&a>s}function Ut(e){try{const t=new URL(e),n=t.pathname.replace(/^\/+/,""),r=t.search.replace(/^\?/,""),s=t.hash.replace(/^#/,""),o=n.replace(/^wp-json\/?/i,""),i=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),c=a?.[1]||"",_=a?.[2]||"",u=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:n,pathname:n,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:r,search:t.search,hash:t.hash,fragment:s,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:i,rest_namespace:c,rest_version:_,rest_route:u,rest_route_with_slash:u?`/${u}`:"/"}}catch{return}}function Y(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const c=Y(a,t);if(c!==void 0)return c}return}if(e==="*")return{};const n=kt(t,e),{regex:r,tokens:s}=Mt(e),o=r.exec(n);if(!o)return;const i={};return s.forEach((a,c)=>{i[`matched_${a}`]=o[c+1]||""}),i}function M(e,t,n={}){const r=Ut(t);if(!r)return t;const s={...r,...n};let o="",i=0;const a=/\{([a-z_]+)\}/gi;let c;for(;c=a.exec(e);){o+=e.slice(i,c.index);const _=s[c[1]]??"",u=Ft(e,c.index,c[1])?encodeURIComponent(_):_;o+=u,i=c.index+c[0].length}o+=e.slice(i);try{const _=new URL(o),u=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&u.search&&u.searchParams.forEach((f,h)=>{_.searchParams.has(h)||_.searchParams.append(h,f)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&u.hash&&!_.hash&&(_.hash=u.hash),_.toString()}catch{return o}}function ae(e,t){try{const n=new URL(t);return`${v(e)}/${n.pathname.replace(/^\//,"")}${n.search}${n.hash}`}catch{return t}}function ce(e,t){const n=v(e);return t?ye(t)?t:t.startsWith("?")||t.startsWith("#")?`${n}${t}`:`${n}${t.startsWith("/")?"":"/"}${t}`:n}function Pe(e,t,n,r){const s=e.match;return s?Array.isArray(s)?s.some(o=>Pe({...e,match:o},t,n,r)):typeof s=="function"?!!s({url:t,method:r,requestType:n}):s==="*"?!0:Y(s,t)!==void 0:!0}function jt(e,t,n,r="generic"){if(e==null)return[];const s=Array.isArray(e)?e:[e],o=[];return s.forEach((i,a)=>{if(!i)return;if(typeof i=="string"){const f=i.includes("{")&&i.includes("}")?M(i,t):ae(i,t);o.push({key:`backend:${a}`,url:f,source:"resource"});return}if(!Le(i)||!("rewrite"in i))return;const c=i;if(!Pe(c,t,r,n))return;const _=typeof c.match=="string"||Array.isArray(c.match)?Y(c.match,t)||{}:{},u=typeof c.proxyBase=="string"&&c.proxyBase.trim()?c.proxyBase.trim():void 0;(Array.isArray(c.rewrite)?c.rewrite:[c.rewrite]).filter(Boolean).forEach((f,h)=>{const p=typeof f=="function"?(()=>{const I=f({url:t,proxyBase:u,method:n,requestType:r,..._}),E=u&&!ye(I)?ce(u,I):I;return E.includes("{")&&E.includes("}")?M(E,t,_):E})():u?M(ce(u,f),t,_):f.includes("{")&&f.includes("}")?M(f,t,_):ae(f,t);o.push({key:`backend:${c.id||"rule"}:${a}:${h}`,url:p,source:"resource"})})}),Pt(o)}function Gt(e){try{const t=new URL(e);return/(?:^|\/)wp-json\/em-files\/v\d+(?:\/|$)/i.test(t.pathname)?"emFiles":/(?:^|\/)wp-json\/ai-generator\/v\d+(?:\/|$)/i.test(t.pathname)?"ai":"generic"}catch{return"generic"}}function Ht(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(n=>{if(n){if(typeof n=="string"){const r=n.split("{")[0]?.trim();r&&t.push(v(r));return}!Le(n)||!("rewrite"in n)||(typeof n.proxyBase=="string"&&n.proxyBase.trim()&&t.push(v(n.proxyBase.trim())),(Array.isArray(n.rewrite)?n.rewrite:[n.rewrite]).forEach(r=>{if(typeof r!="string")return;const s=r.split("{")[0]?.trim();s&&t.push(v(s))}))}}),t}function Xt(e,t){return bt(t).flatMap(n=>Ht(n)).filter(Boolean).some(n=>n&&e.startsWith(n))}function Vt(e,t){return!!J(t)&&xt(e,t)}function $t(e,t={}){const n=t.requestType||Gt(e);return Vt(n,t.config)?jt(J(t.config),e,t.method,n):[]}function Wt(e,t={}){return Xt(e,t.config)?[e]:$t(e,t).map(n=>n.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Kt(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const n=t.find(o=>o.aborted);if(n)return n;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const r=new AbortController,s=o=>{r.signal.aborted||r.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>s(o),{once:!0});return r.signal}var _e=3e5,ue=15e3,A=null,le=!1;function qt(){return!0}function zt(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return _e;const t=Number(e);return Number.isFinite(t)&&t>0?t:_e}function Jt(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return ue;const t=Number(e);return Number.isFinite(t)&&t>0?t:ue}function Yt(){const e="https://app.useblocks.io/api".trim();return e?D(e):void 0}function Qt(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("expected JSON array");return n.map(r=>String(r).trim()).filter(Boolean)}catch{return le||(le=!0),[]}return t.split(",").map(n=>n.trim()).filter(Boolean)}function Zt(e){const t=new Set,n=[];for(const r of e){const s=D(r);t.has(s)||(t.add(s),n.push(s))}return n}function be(e){const t=String(e||"").trim();return t?D(t):Yt()}function Re(e,t=[]){return e?Zt([e,...t]).slice(0,3):[]}function xe(){return Qt(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function en(e=Date.now()){return A?e-A.switchedAt>=zt():!0}function we(e=Date.now()){A&&en(e)&&(A=null)}function S(e){if(!qt())return!1;const t=be(e);if(!t)return!1;const n=xe();return n.length===0?!1:Re(t,n).length>1}function b(e){const t=be(e);if(!t)return[];const n=xe();return n.length===0?[t]:Re(t,n)}function Q(e){const t=b(e);if(t.length===0)return"";if(we(),A){const n=t.indexOf(A.activeUrl);if(n>=0)return t[n]}return t[0]}function Me(e){const t=b(e);if(t.length<=1||(we(),!A||!t.includes(A.activeUrl)))return t;const n=A.activeUrl;return[n,...t.filter(r=>r!==n)]}function tn(e){return Q(e)||void 0}function Be(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const n=Jt(),r=new AbortController;let s;const o=setTimeout(()=>{s=nn(n),r.abort(s)},n);return{signal:Kt(t,r.signal),timeoutError:()=>s,done:()=>clearTimeout(o)}}function nn(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const n=new Error(t);return n.name="TimeoutError",n}function ke(e){return e===502||e===503||e===504}function Fe(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var Ue;function gr(e){Ue=e}function B(e,t){if(!S(t))return;const n=b(t);if(n.length<=1)return;const r=n.indexOf(D(e));if(r<0)return;const s=r+1;if(s>=n.length)return;const o=n[s],i=A?.activeUrl;A={activeUrl:o,switchedAt:Date.now()},i!==o&&Ue?.()}function je(e,t){if(!S(t))return;const n=D(e),r=b(t);if(r.includes(n)){if(n===r[0]){A=null;return}A?.activeUrl!==n&&(A={activeUrl:n,switchedAt:Date.now()})}}function Ge(){A=null}var rn=e=>{const t=new FormData,n=(r,s,o)=>{if(s!=null){if(s instanceof Blob){r.append(o,s);return}if(Array.isArray(s)){s.forEach((i,a)=>{const c=o?`${o}[${a}]`:`${a}`;n(r,i,c)});return}if(typeof s=="object"){Object.keys(s).forEach(i=>{const a=s[i],c=o?`${o}[${i}]`:i;n(r,a,c)});return}r.append(o,String(s))}};return n(t,e),t},sn={baseUrl:D("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},T=new Map;function on(e){const t=e?.getInstance(ot);return t?t.get()??t.bootstrap():void 0}var an=class extends pt{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:n,extraQuery:r}=e;let{query:s}=e;r&&(s=s?{...s,...r}:r);const o=s&&this.toQueryString(s);return`${n||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const n=on(this.container),r=this.container?.getInstance(at)!==void 0,s=Wt(e,{config:n,method:t,standalone:r}),o=s.length>0?s:[e],i=this.buildRequestKey(e,t),a=T.get(i);return!a||!o.includes(a)?o:[a,...o.filter(c=>c!==a)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,n=!1){const r={...e,baseUrl:t},s=this.buildRequestUrl(r),o=r.method||"GET",i=this.buildRequestKey(s,o),a=this.getBackendProxyCandidates(s,o);let c,_;for(const u of a){const f=p=>p===s?u:p,h=n?Be(e.signal):void 0;try{const p=await super.request({...r,proxyHandler:f,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&u!==a[a.length-1]){_=p,T.get(i)===u&&T.delete(i);continue}return T.set(i,u),p}catch(p){T.get(i)===u&&T.delete(i);const I=h?.timeoutError();if(I)throw I;if(c=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{h?.done()}}if(_)return _;throw c instanceof Error?c:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const n=this.resolveFailoverBaseUrl(),r=S(n),s=e.failoverAttemptTimeout??r,o=r?Me(n):n?[Q(n)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let i,a;for(let c=0;c<o.length;c++){const _=o[c],u=c===o.length-1;try{const f=await this.requestOnOrigin(e,_,s);if(!f.ok&&ke(f.status)){if(a=f,!u){B(_,n);continue}break}return f.ok&&je(_,n),f}catch(f){if(!Fe(f))throw f;i=f,u||B(_,n)}}if(r&&Ge(),a)return a;throw i instanceof Error?i:new Error("API origin failover chain failed")}};function cn(e={},t){const n=new an({...sn,...e},t);return n.contentFormatters["multipart/form-data"]=rn,n}var _n=d("rest.clientFactory"),mr=e=>{mt(e);const t=cn({customFetch:e.getInstance(Se)?.execute??gt},e);e.inject(De,t)},de;(function(e){const t="https://racs.rest/v3";function n(s,o){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${s}&dataset=${document.location.hostname}`,i)}e.post=n;async function r(s,o=0){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${s}&dataset=${document.location.hostname}`,i)).json()}e.getAll=r})(de||(de={}));function k(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e),r=Array.isArray(t);if(n){if(!r)return!1;const a=e.length;if(t.length!==a)return!1;for(let c=0;c<a;c++)if(!k(e[c],t[c]))return!1}else if(r)return!1;const s=Object.keys(e),o=Object.keys(t),i=s.length;if(i!==o.length)return!1;for(let a=0;a<i;a++){const c=s[a];if(!t.hasOwnProperty(c)||!k(e[c],t[c]))return!1}}return!0}function un(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),n=atob(t),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return new TextDecoder().decode(r)}function ln(e){const[t,n,r]=e.split("."),s=JSON.parse(un(n));return{exp:s.exp,createdAt:s.iat,data:s}}var V=d("plugin.auth.token"),fe=new WeakMap,dn=3e4;function fn(e){let t;try{t=ln(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+dn}function pn(e,t,n,r){const s=fe.get(e);s&&(s.stale=!0);const o={stale:!1};fe.set(e,o),e.injectFactory(V,async(i,a)=>{if(o.stale)return"";try{let c=await a||void 0;if(!c){const _=e.getInstance(it);_&&(c=await _)}return t?!c||fn(c)?await t(n,r,c):c:""}catch{return""}},!0)}var pe=d("auth.oauthProvided"),he=new WeakMap;function He(e,t){const n=he.get(e)??{applied:!1};(!n.applied||n.getAuthToken!==t.getAuthToken||!k(n.user,t.user)||n.project!==t.project)&&(he.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),pn(e,t.getAuthToken,t.user,t.project))}function hn(e){if(e.getInstance(pe))return;e.inject(pe,!0);let t;e.getInstance(st)?.watch(n=>{t=n}),e.addService(q,{execute:async(n,r)=>{if(r?.public||!t?.getAuthToken)return;e.getInstance(V)===void 0&&He(e,t);const s=await e.getInstanceAsync(V);s&&n.headers.set("authorization",`Bearer ${s}`)}})}var Tr={theme:"canvas_fact_theme",flags:"canvas_fact_flags",commonStyles:"canvas_fact_common_styles",lockEditor:"canvas_fact_lock_editor",codeMode:"canvas_fact_code_mode",appName:"canvas_fact_app_name",previewPage:"canvas_fact_preview_page",viewport:"canvas_fact_viewport"},Sr={text:{fontFamily:["Google Fonts","Sans Serif","Mulish","Regular"],fontSize:16,fontSizeDim:"px",lineHeight:24,lineHeightDim:"px",color:"#595959",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Google Fonts","Sans Serif","Mulish","Bold"],fontSize:28,fontSizeDim:"px",lineHeight:34,lineHeightDim:"px",color:"#000000",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},links:{color:"#1890ff",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Google Fonts","Sans Serif","Mulish","Medium"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1890ff",bold:!1,italic:!1,backgroundColor:"#1890ff",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:6,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1890ff",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1890ff",contrastTextColor:"#ffffff",baseBackgroundColor:"#f8f8f8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},Xe="ERROR",Dr="useblocks",Nr={em_token:"em_access_token",em_refresh_token:"em_refresh_token",em_admin_token:"em_admin_access_token",em_admin_refresh_token:"em_admin_refresh_token",em_impersonation:"em_impersonation",em_elements_view:"em_elements_view",em_new_block:"em_new_block",em_new_email:"em_new_email",em_id:"em_id",em_name:"em_name",em_email:"em_email",em_locale:"em_locale",em_carrotquest_hash:"em_carrotquest_hash",em_ducalis_hash:"em_ducalis_hash",em_email_subscription_consent:"em_email_subscription_consent",em_folder:"em_folder",promocode:"promocode",em_active_tab:"em_active_tab"},Cr={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},vr="light",yr="dark",Lr="system",Pr="(prefers-color-scheme: dark)",br={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_SYNC_DRIFT:"application_sync_drift",APPLICATION_UPDATE_ENTITY:"application_update_entity",APPLICATION_IFRAME_DRAG_EVENT:"application_iframe_drag_event",APPLICATION_HAS_AMP:"application_has_amp",APPLICATION_CANVAS_IMAGE_GET:"application_canvas_image_get",APPLICATION_PREVIEW_ALERT_SHOW:"application_preview_alert_show",APPLICATION_ATOM_INSERTED:"application_atom_inserted",APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW:"application_template_not_em_alert_show",SANDBOX_IFRAME_SETSIZE:"sandbox_iframe-setsize",SANDBOX_BLOCK_INSERT:"sandbox_block-insert",SANDBOX_ATOM_INSERT:"sandbox_atom-insert",SANDBOX_DRAG_CANCEL:"sandbox_drag-cancel",UPDATE_EDITOR_POSITION_FROM_EDITOR:"update_position_from_editor",UPDATE_EDITOR_POSITION_FROM_IFRAME:"update_position_from_iframe",SANDBOX_CHANGE_PREVIEW:"sandbox_change_preview",APPLICATION_CHANGE_PREVIEW:"application_change_preview",SANDBOX_LOCK_EDIT:"sandbox_lock_edit",SANDBOX_FLOATBLOCK_ADD:"sandbox_floatBlock_add",SANDBOX_FLOATBLOCK_REMOVE:"sandbox_floatBlock_remove",SANDBOX_FLOATBLOCK_COPY:"sandbox_floatBlock_copy",SANDBOX_FLOATBLOCK_SWAP:"sandbox_floatBlock_swap",EDITOR_CHANGE_FOCUS:"editor_change_focus",SANDBOX_RESIZED:"sandbox_resized",SANDBOX_LOCK_DISCUSS:"sandbox_lock_discuss",SANDBOX_DISCUSS_SET_TARGET:"sandbox_discuss_set_target",SANDBOX_DISCUSS_REMOVE_TARGET:"sandbox_discuss_remove_target",SANDBOX_DISCUSS_RESET:"sandbox_discuss_reset",SANDBOX_DISCUSS_GET_TARGET:"sandbox_discuss_get_target",SANDBOX_READY:"SANDBOX_READY",SANDBOX_FLOATBLOCK_WRAP:"sandbox_floatblock_wrap",SANDBOX_FLOATBLOCK_DIR:"sandbox_floatblock_dir",SANDBOX_SUBJECT_UPDATE:"sandbox_subject_update",SANDBOX_PREHEADER_UPDATE:"sandbox_preheader_update",SANDBOX_DRAG_EVENT:"sandbox_drag_event",SANDBOX_WHEEL:"sandbox_wheel",SANDBOX_TRANSLATIONS:"sandbox_send_translations",SANDBOX_SET_THEME_VARIABLES:"sandbox_send_theme_variables",SANDBOX_SET_PROJECT_FONTS:"sandbox_set_project_fonts",SANDBOX_CANVAS_IMAGE_CACHE_SETUP:"sandbox_canvas_image_cache_setup",SANDBOX_SET_ENTITY:"sandbox_set_entity",SANDBOX_INIT_START:"sandbox_init_start",SANDBOX_INITED:"sandbox_inited",SANDBOX_UPDATE_ENTITY:"sandbox_update_entity",RELOAD:"reload",SANDBOX_ADD_EXTENSIONS:"sandbox_add_extensions",SANDBOX_REMOVE_EXTENSIONS:"sandbox_remove_extensions",SANDBOX_ADD_SCRIPT:"sandbox_add_script",SANDBOX_IS_EMAIL_EMPTY:"sandbox_is_email_empty",SANDBOX_SWITCH_THEME:"sandbox_switch_theme",SANDBOX_CANVAS_HEALTH:"sandbox_canvas_health"},Rr={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},En=e=>{const t={current:Promise.resolve(),state:e,decorate:(n,r)=>(r&&(n=n.bind(r)),function(...s){const o=t.current.then(()=>n(...s));return t.current=o.then(i=>{t.state=i},i=>{}),o})};return t};function Ve(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function xr(e){return t=>{const n={},r=[];for(const i of e)r.push(i(t));for(const i of r)Object.assign(n,i.instance);return{instance:n,setOptions:async i=>{for(const a of r)await a.setOptions(i)},dispose:()=>{for(const i of r)i.dispose()}}}}function An(e=Xe){const t=new Error(e);return t.name="AuthPipelineError",t}async function In(e,t,n,r){const s=r?.attemptTimeout??S(n),o=S(n)?Me(n):b(n).length>0?[Q(n)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const i=e.startsWith("/")?e:`/${e}`;let a,c;for(let _=0;_<o.length;_++){const u=o[_],f=_===o.length-1,h=s?Be(t.signal):void 0;try{const p=await fetch(`${u}${i}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&ke(p.status)){if(a=p,!f){B(u,n);continue}break}return p.ok&&je(u,n),p}catch(p){const I=h?.timeoutError();if(!I&&!Fe(p))throw p;c=I||p,f||B(u,n)}finally{h?.done()}}if(S(n)&&Ge(),a)return a;throw c instanceof Error?c:new Error("[apiOriginFailover] fetch chain failed")}function Ee(e){e.inject(C,void 0),e.inject(X,void 0)}var wr=Ve(e=>{let t,n;const r=En();return e.addService(q,{execute:r.decorate(async(s,o)=>{if(o?.public||!t)return;const i=String(e.getInstance(X)||"").trim();if(i){s.headers.append("authorization",`Bearer ${i}`);return}if(!e.getInstance(C))try{const a=e.getInstance(_n),c=String(a?.getOptions()?.baseUrl||"").trim(),_=tn(n||c||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const u=await In("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!u.ok)throw new Error(`JWT auth failed: ${u.status}`);const f=await u.json(),h=String(f.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(C,void 0),e.inject(X,h),s.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(C,Xe),An()}})}),{setOptions(s){const o=s.jwtAuth,i=String(s.baseUrl||"").trim()||void 0,a=!k(o,t),c=i!==n;if(t=o,n=i,!o){Ee(e);return}a||c?Ee(e):e.inject(C,void 0)}}}),Mr=Ve(e=>(hn(e),{setOptions(t){He(e,t)}}));function On(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function $(e,t=document){try{const r=t.querySelector(e);if(r)return r}catch{return null}const n=t.querySelectorAll("*");for(let r=0;r<n.length;r++){const s=n[r]?.shadowRoot;if(!s)continue;const o=$(e,s);if(o)return o}return null}function $e(e,t=[]){const n=e.querySelectorAll("*");for(let r=0;r<n.length;r++){const s=n[r]?.shadowRoot;s&&(t.push(s),$e(s,t))}return t}function gn(e,t,n){if(e.isConnected)return e;const r=e.id?.trim();return r?mn(`#${On(r)}`,t,n):Promise.reject(y("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function mn(e,t,n){if(me(n),typeof e<"u"){if(typeof e=="string"){const r=e,s=$(r);if(s)return s;const o=t.addDisposable(new m);return new Promise((i,a)=>{const c=E=>{o.dispose(),E()},_=()=>{c(()=>a(y(n?.reason)))};if(n?.aborted){_();return}n?.addEventListener("abort",_),o.addDispose(()=>n?.removeEventListener("abort",_));const u=document.body??document.documentElement;if(!u){c(()=>a(y("Document is not ready to observe mount element")));return}const f=new Set,h=new MutationObserver(()=>{const E=$(r);if(E){c(()=>i(E));return}I()}),p=E=>{f.has(E)||(f.add(E),h.observe(E,{attributes:!0,childList:!0,subtree:!0}))},I=()=>{const E=document.documentElement;if(E)for(const R of $e(E))p(R)};p(u),I(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?gn(e,t,n):e}return e}var Br=new Map;export{tr as $,Ar as A,y as At,fr as B,m as Bt,_n as C,K as Ct,gr as D,Pn as Dt,tn as E,vn as Et,Se as F,te as Ft,Jn as G,dr as H,It as I,d as It,sr as J,Yn as K,q as L,Ze as Lt,Dt as M,Nn as Mt,Er as N,me as Nt,Kt as O,Ln as Ot,hr as P,Sn as Pt,Zn as Q,De as R,Tn as Rt,k as S,bn as St,Q as T,Cn as Tt,nr as U,_r as V,zn as W,or as X,rr as Y,Qn as Z,Dr as _,jn as _t,In as a,Wn as at,hn as b,xn as bt,En as c,Bn as ct,br as d,st as dt,qn as et,vr as f,Vn as ft,Lr as g,Xn as gt,Pr as h,it as ht,wr as i,$n as it,Or as j,Dn as jt,Ir as k,yn as kt,Nr as l,kn as lt,Rr as m,Hn as mt,mn as n,Kn as nt,xr as o,ot,Cr as p,at as pt,er as q,Mr as r,wn as rt,Ve as s,Mn as st,Br as t,lt as tt,yr as u,Fn as ut,Sr as v,Un as vt,mr as w,L as wt,ln as x,Rn as xt,Tr as y,ne as yt,pr as z,F as zt};