@emailmaker/emailmaker 1.1.31 → 1.1.32
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.
- package/{emailmaker-core.25e2342b.js → emailmaker-core.8bdd92fb.js} +1 -1
- package/emailmaker-esm.js +5 -5
- package/emailmaker.d.ts +7 -2
- package/emailmaker.js +11 -11
- package/iframe/js/amp.DieSnBUu.js +1 -0
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.CNqvmp_P.js +1 -1
- package/package.json +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{1da27b3c.js → 0a752305.js} +1 -1
- package/static/core/{13ca3f502.js → 1369407e2.js} +1 -1
- package/static/core/{e37f6763.js → 2c12aa51.js} +2 -2
- package/static/core/{4686eabe.js → 34ed48da.js} +3 -3
- package/static/core/{df4b4fe2.js → 3d1e7c2e.js} +2 -2
- package/static/core/4698f05f.js +51 -0
- package/static/core/{bfefb58d.js → 7760eab7.js} +2 -2
- package/static/core/{25d26369.js → 7865066d.js} +2 -2
- package/static/core/{76f5295d.js → 7ae09748.js} +1 -1
- package/static/core/96583da0.js +3 -0
- package/static/core/{ca58f6cf.js → a73f6ffb.js} +1 -1
- package/static/core/b7b90cb5.js +78 -0
- package/static/core/{91634ef3.js → ba40f70e.js} +1 -1
- package/static/core/{cc38c423.js → d5670b2e.js} +2 -2
- package/static/core/{d06bc0bd.js → db185a82.js} +50 -50
- package/static/core/e1095f09.js +1 -0
- package/static/core/{558afaa1.js → ef4e808c.js} +1 -1
- package/static/core/{e4ba0190.js → fc5712ae.js} +1 -1
- package/static/esm/533d7587.js +1 -0
- package/two_step_headless_plugin.html +1 -1
- package/iframe/js/amp.BLBsfH3J.js +0 -1
- package/static/core/3c291097.js +0 -78
- package/static/core/62c48605.js +0 -3
- package/static/core/8a188b85.js +0 -51
- package/static/core/8aba252b.js +0 -1
- /package/iframe/{iframe-eblock.25e2342b.html → iframe-eblock.8bdd92fb.html} +0 -0
- /package/iframe/{iframe.25e2342b.html → iframe.8bdd92fb.html} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.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(--colorBorder);border-radius:6px;max-width:100%;max-height:500px}.blocks-app .image-editor-modal .ant-modal-container{flex-direction:column;min-height:100vh;display:flex;border-radius:0!important}.blocks-app .image-editor-modal .ant-modal-body{flex-grow:1;display:flex}.blocks-app .image-editor-modal .ant-modal-body #pixie-editor{flex-grow:1;height:calc(100vh - 70px);min-height:calc(100vh - 70px);overflow:hidden}.blocks-app .image-editor-modal .pi .text-on-primary{background:var(--colorPrimary);border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary:hover{background:var(--colorPrimaryHover);border-color:var(--colorPrimaryHover)}.blocks-app .image-editor-modal .pi .text-on-primary.rounded-full{border-radius:calc(var(--borderRadius) * 1px)}.blocks-app .image-editor-modal .pi .shadow-xl{box-shadow:none}.blocks-app .image-editor-modal .w-\\[4ch\\].text-sm.text-center{width:5ch}.blocks-app .image-editor-modal .pi .border-white{border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .bg-white\\/50{background-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary{color:var(--colorWhite)}.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(--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(--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(--borderWidth) * 1px);border-color:var(--colorFillSecondaryDarken);border-radius:calc(var(--borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--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(--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(--colorBorderSecondary);background:linear-gradient(180deg, var(--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(--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(--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(--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}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();__emailmaker__.define(`static/core/4686eabe.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/8a188b85.js`,`static/core/25d26369.js`,`static/core/13ca3f502.js`,`static/core/df4b4fe2.js`,`static/core/cc38c423.js`,`static/core/62c48605.js`,`react`,`prop-types`,`react-router-dom`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./8a188b85.js"),a=e("./62c48605.js"),o=e("./df4b4fe2.js"),s=e("./25d26369.js"),c=e("./13ca3f502.js"),l=e("./cc38c423.js"),u=e("react");u=r.l(u);let d=e("prop-types");d=r.l(d);let f=e("react-router-dom"),p=e("react/jsx-runtime");function m(e,t){return{[e]:{Filter:t(`Filter`),filter:t(`filter`),Resize:t(`Resize`),resize:t(`resize`),Crop:t(`Crop`),Width:t(`Width`),width:t(`width`),Height:t(`Height`),height:t(`height`),"Background color":t(`Background color`),Cancel:t(`Cancel`),Create:t(`Create`),Objects:t(`Objects`),Quality:t(`Quality`),Save:t(`Save`),"Loading Canvas":t(`Loading Canvas`),"Loading Image":t(`Loading Image`),"Loading State":t(`Loading State`),"Processing Image":t(`Processing Image`),Close:t(`Close`),Apply:t(`Apply`),Font:t(`Font`),Color:t(`Color`),Background:t(`Background`),Image:t(`Image`),Opacity:t(`Opacity`),Outline:t(`Outline`),Shadow:t(`Shadow`),Gradient:t(`Gradient`),Texture:t(`Texture`),"Replace Image":t(`Replace Image`),"Outline Color":t(`Outline Color`),"Shadow Color":t(`Shadow Color`),"Font Size":t(`Font Size`),Radius:t(`Radius`),"Brush Color":t(`Brush Color`),"Brush Type":t(`Brush Type`),"Brush Size":t(`Brush Size`),History:t(`History`),"Maintain aspect ratio":t(`Maintain aspect ratio`),"New Text":t(`New Text`),Size:t(`Size`),Draw:t(`Draw`),Text:t(`Text`),Stickers:t(`Stickers`),Frame:t(`Frame`),Shapes:t(`Shapes`),Corners:t(`Corners`),corners:t(`corners`),Done:t(`Done`),"Applied Filters":t(`Applied Filters`),"Resized Image":t(`Resized Image`),"Cropped Image":t(`Cropped Image`),"Added Drawing":t(`Added Drawing`),"Added Text":t(`Added Text`),"Added Shape":t(`Added Shape`),"Added Sticker":t(`Added Sticker`),"Added Frame":t(`Added Frame`),"Merged Objects":t(`Merged Objects`),"Rounded Corner":t(`Rounded Corner`),"Replaced Background Image":t(`Replaced Background Image`),"Added Image":t(`Added Image`),Initial:t(`Initial`),"Loaded State":t(`Loaded State`),"Changed Style":t(`Changed Style`),"Deleted object":t(`Deleted object`),Merge:t(`Merge`),Emoticons:t(`Emoticons`),Doodles:t(`Doodles`),Landmarks:t(`Landmarks`),Bubbles:t(`Bubbles`),Transportation:t(`Transportation`),Beach:t(`Beach`),PencilBrush:t(`PencilBrush`),SprayBrush:t(`SprayBrush`),CircleBrush:t(`CircleBrush`),DiamondBrush:t(`DiamondBrush`),VLineBrush:t(`VLineBrush`),HLineBrush:t(`HLineBrush`),SquareBrush:t(`SquareBrush`),Square:t(`Square`),square:t(`square`)}}}var h={text:{replaceDefault:!0,defaultCategory:`handwriting`,items:[{family:`Montserrat Light`,src:`customFonts/Montserrat-Light.woff2`},{family:`Montserrat Regular`,src:`customFonts/Montserrat-Regular.woff2`},{family:`Montserrat Bold`,src:`customFonts/Montserrat-Bold.woff2`},{family:`Montserrat Black`,src:`customFonts/Montserrat-Black.woff2`},{family:`Roboto Light`,src:`customFonts/Roboto-Light.woff2`},{family:`Roboto Regular`,src:`customFonts/Roboto-Regular.woff2`},{family:`Roboto Bold`,src:`customFonts/Roboto-Bold.woff2`},{family:`Roboto Black`,src:`customFonts/Roboto-Black.woff2`},{family:`Lato Light`,src:`customFonts/Lato-Light.woff2`},{family:`Lato Regular`,src:`customFonts/Lato-Regular.woff2`},{family:`Lato Bold`,src:`customFonts/Lato-Bold.woff2`},{family:`Lato Black`,src:`customFonts/Lato-Black.woff2`},{family:`Rubik Light`,src:`customFonts/Rubik-Light.woff2`},{family:`Rubik Regular`,src:`customFonts/Rubik-Regular.woff2`},{family:`Rubik Bold`,src:`customFonts/Rubik-Bold.woff2`},{family:`Rubik Black`,src:`customFonts/Rubik-Black.woff2`},{family:`Bebas Neue Light`,src:`customFonts/BebasNeueLight.woff2`},{family:`Bebas Neue Regular`,src:`customFonts/BebasNeueRegular.woff2`},{family:`Bebas Neue Book`,src:`customFonts/BebasNeueBook.woff2`},{family:`Bebas Neue Bold`,src:`customFonts/BebasNeueBold.woff2`},{family:`Arial`,src:`customFonts/ArialMT.woff2`},{family:`Arial Bold`,src:`customFonts/Arial-BoldMT.woff2`}]}},g=(e,t=`application/octet-stream`)=>fetch(`data:${t};base64,${e}`).then(e=>e.blob());function _(e,t){if(e===`json`)return new Blob([t],{type:`application/json`});if(e===`svg`)return new Blob([t],{type:`image/svg+xml`});let n=`image/${e}`;return t=t.replace(/data:image\/([a-z]*)?;base64,/,``),g(t,n)}var v=({currentImageLink:e,prefetchedBlobUrl:t,newLink:n,onSave:r,uploadImageResultIsLoading:d})=>{let f=l.h(),[g,v]=(0,u.useState)(),[y,b]=(0,u.useState)(),{__:x}=o.h(),S=i.Ei(),C=i.Di(),w=i.sn(),T=i.Ti(i.n),E=i.Ti(a.u),D=i.Ti(i.ct),O=(0,u.useMemo)(()=>{if(!w?.icons)return;let e={};for(let[t,n]of Object.entries(w.icons))typeof n==`string`&&(e[t]=c.h(n));return Object.keys(e).length>0?e:void 0},[w?.icons]),k=(0,u.useRef)(!1),[A,j]=(0,u.useState)(),M=i.q(i.xo.FILE_PROXY_EVENT_ID);(0,u.useEffect)(()=>{(async()=>{let n=e;if(!n&&!t)return;let r;if(t)try{let e=await fetch(t);e.ok&&(r=await e.blob())}catch{r=void 0}if(!r&&n)try{r=await(await fetch(n)).blob()}catch{if(r=await M.fire({url:n,project:D}).filter(e=>e instanceof Blob)[0],!r){let e=f.get(i.zi.em_token)||await i.bi.getInstance(C,a.D);r=await(await fetch(`https://app.emailmaker.ru/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(n)}`,{headers:{authorization:`Bearer ${e}`}})).blob()}}if(r){let e=new FileReader;e.onload=()=>{A?.tools.import.openBackgroundImage(g),e.result!==g&&(v(e.result),b(r.type))},e.readAsDataURL(r)}})().catch(e=>void 0)},[e,t,n,v,f,g,A,M,D,C]);let N=(0,u.useCallback)(()=>{v(null),b(null),S(a.n()),S(a.t(i.va.UPLOAD_IMAGE_MODAL))},[S]),P=(0,u.useRef)();P.current=async function(e,t,n){let i=await _(n,e);r&&r(new File([i],t,{lastModified:new Date().getTime(),type:i.type}))};let F=(0,u.useCallback)(e=>{if(e&&!(k.current&&A)){k.current=!0;let e=T.locale?T.locale.replace(`_`,`-`):`ru-RU`,t=T.theme===`system`?matchMedia(`(prefers-color-scheme: dark)`).matches?i.Yi:i.fa:T.theme;s.O.init({selector:`#pixie-editor`,baseUrl:o.t(`assets/pixie`),image:g,activeLanguage:e,languages:m(e,x),tools:h,ui:{menubar:{replaceDefaultItems:!0,items:[{type:`undoWidget`,align:`left`},{type:`zoomWidget`,align:`center`,desktopOnly:!0},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`HistoryOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:e=>{e.togglePanel(`history`)}},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`CloseOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:()=>N()}]},nav:{position:`top`},activeTheme:t,mode:`inline`,forceOverlayModeOnMobile:!1},onSave:async function(e,t,n){P.current(e,t,n)}}).then(e=>{j(e)}).catch(e=>void 0)}},[T.theme,g,A,j,T.locale,x,N,O]),I=(0,u.useCallback)(()=>{A?.tools.export.save(e?.split(`/`).pop().split(`.`)[0],y?.split(`/`)[1])},[A,e,y]);return(0,p.jsxs)(o.Y,{afterOpenChange:F,width:`100%`,style:{maxWidth:`100%`,minHeight:`100vh`},className:`image-editor-modal`,centered:!0,closable:!1,zIndex:1100,mask:!1,open:E,footer:[(0,p.jsx)(o.Rt,{className:`em-analytics__profile-cancel`,onClick:N,children:x(`Cancel`)},`Cancel`),(0,p.jsx)(o.Rt,{className:`em-analytics__profile-updapixiete`,id:`save`,type:`primary`,onClick:I,children:x(`Update`)},`Ok`)],children:[d&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),(0,p.jsx)(`div`,{id:`pixie-editor`})]})},y=({currentImageLink:e,newLink:t,previewDisplayUrl:n,resolvedPreviewObjectUrl:r,onSave:i,uploadImageResultIsLoading:a})=>{let s=n||r;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{children:(0,p.jsxs)(`div`,{className:`image-preview`,children:[a&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),s&&(0,p.jsx)(`img`,{alt:`uploadedImage`,src:s})]})}),(0,p.jsx)(v,{currentImageLink:e,prefetchedBlobUrl:r,newLink:t,onSave:i,uploadImageResultIsLoading:a})]})},b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},b(e,t)};function x(e,t){b(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},S.apply(this,arguments)};function C(e,t,n,r){var i,a=!1,o=0;function s(){i&&clearTimeout(i)}function c(){s(),a=!0}typeof t!=`boolean`&&(r=n,n=t,t=void 0);function l(){var c=this,l=Date.now()-o,u=arguments;if(a)return;function d(){o=Date.now(),n.apply(c,u)}function f(){i=void 0}r&&!i&&d(),s(),r===void 0&&l>e?d():t!==!0&&(i=setTimeout(r?f:d,r===void 0?e-l:e))}return l.cancel=c,l}var w={Pixel:`Pixel`,Percent:`Percent`},T={unit:w.Percent,value:.8};function E(e){return typeof e==`number`?{unit:w.Percent,value:e*100}:typeof e==`string`?e.match(/^(\d*(\.\d+)?)px$/)?{unit:w.Pixel,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:w.Percent,value:parseFloat(e)}:T:T}var D=function(e){x(t,e);function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:typeof n.props.scrollableTarget==`string`?document.getElementById(n.props.scrollableTarget):(n.props.scrollableTarget,null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange=`transform`,n._infScroll.style.transition=`transform 0.2s cubic-bezier(0,0,0.31,1)`))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),!(n.currentY<n.startY)&&(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),!(n.currentY-n.startY>n.maxPullDownDistance*1.5)&&n._infScroll&&(n._infScroll.style.overflow=`visible`,n._infScroll.style.transform=`translate3d(0px, `+(n.currentY-n.startY)+`px, 0px)`)))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow=`auto`,n._infScroll.style.transform=`none`,n._infScroll.style.willChange=`unset`)})},n.onScrollListener=function(e){typeof n.props.onScroll==`function`&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=C(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return t.prototype.componentDidMount=function(){if(this.props.dataLength===void 0)throw Error(`mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage`);if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener(`scroll`,this.throttledOnScrollListener),typeof this.props.initialScrollY==`number`&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener(`touchstart`,this.onStart),this.el.addEventListener(`touchmove`,this.onMove),this.el.addEventListener(`touchend`,this.onEnd),this.el.addEventListener(`mousedown`,this.onStart),this.el.addEventListener(`mousemove`,this.onMove),this.el.addEventListener(`mouseup`,this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),typeof this.props.refreshFunction!=`function`))throw Error(`Mandatory prop "refreshFunction" missing.
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.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(--colorBorder);border-radius:6px;max-width:100%;max-height:500px}.blocks-app .image-editor-modal .ant-modal-container{flex-direction:column;min-height:100vh;display:flex;border-radius:0!important}.blocks-app .image-editor-modal .ant-modal-body{flex-grow:1;display:flex}.blocks-app .image-editor-modal .ant-modal-body #pixie-editor{flex-grow:1;height:calc(100vh - 70px);min-height:calc(100vh - 70px);overflow:hidden}.blocks-app .image-editor-modal .pi .text-on-primary{background:var(--colorPrimary);border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary:hover{background:var(--colorPrimaryHover);border-color:var(--colorPrimaryHover)}.blocks-app .image-editor-modal .pi .text-on-primary.rounded-full{border-radius:calc(var(--borderRadius) * 1px)}.blocks-app .image-editor-modal .pi .shadow-xl{box-shadow:none}.blocks-app .image-editor-modal .w-\\[4ch\\].text-sm.text-center{width:5ch}.blocks-app .image-editor-modal .pi .border-white{border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .bg-white\\/50{background-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary{color:var(--colorWhite)}.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(--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(--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(--borderWidth) * 1px);border-color:var(--colorFillSecondaryDarken);border-radius:calc(var(--borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--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(--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(--colorBorderSecondary);background:linear-gradient(180deg, var(--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(--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(--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(--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}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();__emailmaker__.define(`static/core/34ed48da.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/4698f05f.js`,`static/core/7865066d.js`,`static/core/1369407e2.js`,`static/core/3d1e7c2e.js`,`static/core/d5670b2e.js`,`static/core/96583da0.js`,`react`,`prop-types`,`react-router-dom`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./4698f05f.js"),a=e("./96583da0.js"),o=e("./3d1e7c2e.js"),s=e("./7865066d.js"),c=e("./1369407e2.js"),l=e("./d5670b2e.js"),u=e("react");u=r.l(u);let d=e("prop-types");d=r.l(d);let f=e("react-router-dom"),p=e("react/jsx-runtime");function m(e,t){return{[e]:{Filter:t(`Filter`),filter:t(`filter`),Resize:t(`Resize`),resize:t(`resize`),Crop:t(`Crop`),Width:t(`Width`),width:t(`width`),Height:t(`Height`),height:t(`height`),"Background color":t(`Background color`),Cancel:t(`Cancel`),Create:t(`Create`),Objects:t(`Objects`),Quality:t(`Quality`),Save:t(`Save`),"Loading Canvas":t(`Loading Canvas`),"Loading Image":t(`Loading Image`),"Loading State":t(`Loading State`),"Processing Image":t(`Processing Image`),Close:t(`Close`),Apply:t(`Apply`),Font:t(`Font`),Color:t(`Color`),Background:t(`Background`),Image:t(`Image`),Opacity:t(`Opacity`),Outline:t(`Outline`),Shadow:t(`Shadow`),Gradient:t(`Gradient`),Texture:t(`Texture`),"Replace Image":t(`Replace Image`),"Outline Color":t(`Outline Color`),"Shadow Color":t(`Shadow Color`),"Font Size":t(`Font Size`),Radius:t(`Radius`),"Brush Color":t(`Brush Color`),"Brush Type":t(`Brush Type`),"Brush Size":t(`Brush Size`),History:t(`History`),"Maintain aspect ratio":t(`Maintain aspect ratio`),"New Text":t(`New Text`),Size:t(`Size`),Draw:t(`Draw`),Text:t(`Text`),Stickers:t(`Stickers`),Frame:t(`Frame`),Shapes:t(`Shapes`),Corners:t(`Corners`),corners:t(`corners`),Done:t(`Done`),"Applied Filters":t(`Applied Filters`),"Resized Image":t(`Resized Image`),"Cropped Image":t(`Cropped Image`),"Added Drawing":t(`Added Drawing`),"Added Text":t(`Added Text`),"Added Shape":t(`Added Shape`),"Added Sticker":t(`Added Sticker`),"Added Frame":t(`Added Frame`),"Merged Objects":t(`Merged Objects`),"Rounded Corner":t(`Rounded Corner`),"Replaced Background Image":t(`Replaced Background Image`),"Added Image":t(`Added Image`),Initial:t(`Initial`),"Loaded State":t(`Loaded State`),"Changed Style":t(`Changed Style`),"Deleted object":t(`Deleted object`),Merge:t(`Merge`),Emoticons:t(`Emoticons`),Doodles:t(`Doodles`),Landmarks:t(`Landmarks`),Bubbles:t(`Bubbles`),Transportation:t(`Transportation`),Beach:t(`Beach`),PencilBrush:t(`PencilBrush`),SprayBrush:t(`SprayBrush`),CircleBrush:t(`CircleBrush`),DiamondBrush:t(`DiamondBrush`),VLineBrush:t(`VLineBrush`),HLineBrush:t(`HLineBrush`),SquareBrush:t(`SquareBrush`),Square:t(`Square`),square:t(`square`)}}}var h={text:{replaceDefault:!0,defaultCategory:`handwriting`,items:[{family:`Montserrat Light`,src:`customFonts/Montserrat-Light.woff2`},{family:`Montserrat Regular`,src:`customFonts/Montserrat-Regular.woff2`},{family:`Montserrat Bold`,src:`customFonts/Montserrat-Bold.woff2`},{family:`Montserrat Black`,src:`customFonts/Montserrat-Black.woff2`},{family:`Roboto Light`,src:`customFonts/Roboto-Light.woff2`},{family:`Roboto Regular`,src:`customFonts/Roboto-Regular.woff2`},{family:`Roboto Bold`,src:`customFonts/Roboto-Bold.woff2`},{family:`Roboto Black`,src:`customFonts/Roboto-Black.woff2`},{family:`Lato Light`,src:`customFonts/Lato-Light.woff2`},{family:`Lato Regular`,src:`customFonts/Lato-Regular.woff2`},{family:`Lato Bold`,src:`customFonts/Lato-Bold.woff2`},{family:`Lato Black`,src:`customFonts/Lato-Black.woff2`},{family:`Rubik Light`,src:`customFonts/Rubik-Light.woff2`},{family:`Rubik Regular`,src:`customFonts/Rubik-Regular.woff2`},{family:`Rubik Bold`,src:`customFonts/Rubik-Bold.woff2`},{family:`Rubik Black`,src:`customFonts/Rubik-Black.woff2`},{family:`Bebas Neue Light`,src:`customFonts/BebasNeueLight.woff2`},{family:`Bebas Neue Regular`,src:`customFonts/BebasNeueRegular.woff2`},{family:`Bebas Neue Book`,src:`customFonts/BebasNeueBook.woff2`},{family:`Bebas Neue Bold`,src:`customFonts/BebasNeueBold.woff2`},{family:`Arial`,src:`customFonts/ArialMT.woff2`},{family:`Arial Bold`,src:`customFonts/Arial-BoldMT.woff2`}]}},g=(e,t=`application/octet-stream`)=>fetch(`data:${t};base64,${e}`).then(e=>e.blob());function _(e,t){if(e===`json`)return new Blob([t],{type:`application/json`});if(e===`svg`)return new Blob([t],{type:`image/svg+xml`});let n=`image/${e}`;return t=t.replace(/data:image\/([a-z]*)?;base64,/,``),g(t,n)}var v=({currentImageLink:e,prefetchedBlobUrl:t,newLink:n,onSave:r,uploadImageResultIsLoading:d})=>{let f=l.h(),[g,v]=(0,u.useState)(),[y,b]=(0,u.useState)(),{__:x}=o.h(),S=i.Oi(),C=i.ki(),w=i.sn(),T=i.Di(i.n),E=i.Di(a.u),D=i.Di(i.ct),O=(0,u.useMemo)(()=>{if(!w?.icons)return;let e={};for(let[t,n]of Object.entries(w.icons))typeof n==`string`&&(e[t]=c.h(n));return Object.keys(e).length>0?e:void 0},[w?.icons]),k=(0,u.useRef)(!1),[A,j]=(0,u.useState)(),M=i.q(i.Co.FILE_PROXY_EVENT_ID);(0,u.useEffect)(()=>{(async()=>{let n=e;if(!n&&!t)return;let r;if(t)try{let e=await fetch(t);e.ok&&(r=await e.blob())}catch{r=void 0}if(!r&&n)try{r=await(await fetch(n)).blob()}catch{if(r=await M.fire({url:n,project:D}).filter(e=>e instanceof Blob)[0],!r){let e=f.get(i.Vi.em_token)||await i.Si.getInstance(C,a.E);r=await(await fetch(`https://app.emailmaker.ru/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(n)}`,{headers:{authorization:`Bearer ${e}`}})).blob()}}if(r){let e=new FileReader;e.onload=()=>{A?.tools.import.openBackgroundImage(g),e.result!==g&&(v(e.result),b(r.type))},e.readAsDataURL(r)}})().catch(e=>void 0)},[e,t,n,v,f,g,A,M,D,C]);let N=(0,u.useCallback)(()=>{v(null),b(null),S(a.n()),S(a.t(i.ba.UPLOAD_IMAGE_MODAL))},[S]),P=(0,u.useRef)();P.current=async function(e,t,n){let i=await _(n,e);r&&r(new File([i],t,{lastModified:new Date().getTime(),type:i.type}))};let F=(0,u.useCallback)(e=>{if(e&&!(k.current&&A)){k.current=!0;let e=T.locale?T.locale.replace(`_`,`-`):`ru-RU`,t=T.theme===`system`?matchMedia(`(prefers-color-scheme: dark)`).matches?i.Zi:i.ma:T.theme;s.O.init({selector:`#pixie-editor`,baseUrl:o.t(`assets/pixie`),image:g,activeLanguage:e,languages:m(e,x),tools:h,ui:{menubar:{replaceDefaultItems:!0,items:[{type:`undoWidget`,align:`left`},{type:`zoomWidget`,align:`center`,desktopOnly:!0},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`HistoryOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:e=>{e.togglePanel(`history`)}},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`CloseOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:()=>N()}]},nav:{position:`top`},activeTheme:t,mode:`inline`,forceOverlayModeOnMobile:!1},onSave:async function(e,t,n){P.current(e,t,n)}}).then(e=>{j(e)}).catch(e=>void 0)}},[T.theme,g,A,j,T.locale,x,N,O]),I=(0,u.useCallback)(()=>{A?.tools.export.save(e?.split(`/`).pop().split(`.`)[0],y?.split(`/`)[1])},[A,e,y]);return(0,p.jsxs)(o.Y,{afterOpenChange:F,width:`100%`,style:{maxWidth:`100%`,minHeight:`100vh`},className:`image-editor-modal`,centered:!0,closable:!1,zIndex:1100,mask:!1,open:E,footer:[(0,p.jsx)(o.Rt,{className:`em-analytics__profile-cancel`,onClick:N,children:x(`Cancel`)},`Cancel`),(0,p.jsx)(o.Rt,{className:`em-analytics__profile-updapixiete`,id:`save`,type:`primary`,onClick:I,children:x(`Update`)},`Ok`)],children:[d&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),(0,p.jsx)(`div`,{id:`pixie-editor`})]})},y=({currentImageLink:e,newLink:t,previewDisplayUrl:n,resolvedPreviewObjectUrl:r,onSave:i,uploadImageResultIsLoading:a})=>{let s=n||r;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{children:(0,p.jsxs)(`div`,{className:`image-preview`,children:[a&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),s&&(0,p.jsx)(`img`,{alt:`uploadedImage`,src:s})]})}),(0,p.jsx)(v,{currentImageLink:e,prefetchedBlobUrl:r,newLink:t,onSave:i,uploadImageResultIsLoading:a})]})},b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},b(e,t)};function x(e,t){b(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},S.apply(this,arguments)};function C(e,t,n,r){var i,a=!1,o=0;function s(){i&&clearTimeout(i)}function c(){s(),a=!0}typeof t!=`boolean`&&(r=n,n=t,t=void 0);function l(){var c=this,l=Date.now()-o,u=arguments;if(a)return;function d(){o=Date.now(),n.apply(c,u)}function f(){i=void 0}r&&!i&&d(),s(),r===void 0&&l>e?d():t!==!0&&(i=setTimeout(r?f:d,r===void 0?e-l:e))}return l.cancel=c,l}var w={Pixel:`Pixel`,Percent:`Percent`},T={unit:w.Percent,value:.8};function E(e){return typeof e==`number`?{unit:w.Percent,value:e*100}:typeof e==`string`?e.match(/^(\d*(\.\d+)?)px$/)?{unit:w.Pixel,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:w.Percent,value:parseFloat(e)}:T:T}var D=function(e){x(t,e);function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:typeof n.props.scrollableTarget==`string`?document.getElementById(n.props.scrollableTarget):(n.props.scrollableTarget,null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange=`transform`,n._infScroll.style.transition=`transform 0.2s cubic-bezier(0,0,0.31,1)`))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),!(n.currentY<n.startY)&&(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),!(n.currentY-n.startY>n.maxPullDownDistance*1.5)&&n._infScroll&&(n._infScroll.style.overflow=`visible`,n._infScroll.style.transform=`translate3d(0px, `+(n.currentY-n.startY)+`px, 0px)`)))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow=`auto`,n._infScroll.style.transform=`none`,n._infScroll.style.willChange=`unset`)})},n.onScrollListener=function(e){typeof n.props.onScroll==`function`&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=C(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return t.prototype.componentDidMount=function(){if(this.props.dataLength===void 0)throw Error(`mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage`);if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener(`scroll`,this.throttledOnScrollListener),typeof this.props.initialScrollY==`number`&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener(`touchstart`,this.onStart),this.el.addEventListener(`touchmove`,this.onMove),this.el.addEventListener(`touchend`,this.onEnd),this.el.addEventListener(`mousedown`,this.onStart),this.el.addEventListener(`mousemove`,this.onMove),this.el.addEventListener(`mouseup`,this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),typeof this.props.refreshFunction!=`function`))throw Error(`Mandatory prop "refreshFunction" missing.
|
|
2
2
|
Pull Down To Refresh functionality will not work
|
|
3
|
-
as expected. Check README.md for usage'`)},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener(`scroll`,this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener(`touchstart`,this.onStart),this.el.removeEventListener(`touchmove`,this.onMove),this.el.removeEventListener(`touchend`,this.onEnd),this.el.removeEventListener(`mousedown`,this.onStart),this.el.removeEventListener(`mousemove`,this.onMove),this.el.removeEventListener(`mouseup`,this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength===t.prevDataLength?null:S(S({},t),{prevDataLength:e.dataLength})},t.prototype.isElementAtTop=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=S({height:this.props.height||`auto`,overflow:`auto`,WebkitOverflowScrolling:`touch`},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:`auto`}:{};return u.default.createElement(`div`,{style:r,className:`infinite-scroll-component__outerdiv`},u.default.createElement(`div`,{className:`infinite-scroll-component `+(this.props.className||``),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&u.default.createElement(`div`,{style:{position:`relative`},ref:function(t){return e._pullDown=t}},u.default.createElement(`div`,{style:{position:`absolute`,left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(u.Component);function O(e,t){if(e==null)return{};var n=k(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function k(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function A(){return A=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A.apply(this,arguments)}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?j(Object(n),!0).forEach(function(t){N(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0},F=2,I=class extends u.default.Component{constructor(e){super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this);let t;t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||F,this.state={columnCount:t}}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(){let e=window&&window.innerWidth||1/0,t=this.props.breakpointCols;typeof t!=`object`&&(t={default:parseInt(t)||F});let n=1/0,r=t.default||F;for(let i in t){let a=parseInt(i);a>0&&e<=a&&a<n&&(n=a,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){let e=this.state.columnCount,t=Array(e),n=u.default.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){let i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){let{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),i=`${100/r.length}%`,a=n;a&&typeof a!=`string`&&(this.logDeprecated(`The property "columnClassName" requires a string`),a===void 0&&(a=`my-masonry-grid_column`));let o=M(M(M({},e),t),{},{style:M(M({},t.style),{},{width:i}),className:a});return r.map((e,t)=>u.default.createElement(`div`,A({},o,{key:t}),e))}logDeprecated(e){}render(){let e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:i,column:a,className:o}=e,s=O(e,[`children`,`breakpointCols`,`columnClassName`,`columnAttrs`,`column`,`className`]),c=o;return typeof o!=`string`&&(this.logDeprecated(`The property "className" requires a string`),o===void 0&&(c=`my-masonry-grid`)),u.default.createElement(`div`,A({},s,{className:c}),this.renderColumns())}};I.defaultProps=P;function L(e,t){return e?e.exhausted?{...e,src:null}:{...e,src:e.src||t||null}:null}function R({items:e,getItemId:t,getRequestUrl:n,createController:r}){let[i,a]=(0,u.useState)({}),o=(0,u.useRef)(new Map),s=(0,u.useCallback)(e=>{let i=t(e),a=n(e),s=`${i}:${a}`;if(o.current.has(s))return{itemId:i,requestUrl:a,cacheKey:s,controller:o.current.get(s)};let c=r(a);return o.current.set(s,c),{itemId:i,requestUrl:a,cacheKey:s,controller:c}},[r,t,n]);return(0,u.useEffect)(()=>{let t=new Set,n={},r=e.map(e=>{let{itemId:r,cacheKey:i,controller:o}=s(e);t.add(i),n[r]=o.src;let c=L(o.handleChangeSrc?.(),o.src);return c?.changed&&c.src&&(n[r]=c.src),o.subscribeToSrcChange?.(e=>{let t=L(e,o.src);!t?.changed||!t.src||a(e=>e[r]===t.src?e:{...e,[r]:t.src})})}).filter(Boolean);return o.current.forEach((e,n)=>{t.has(n)||o.current.delete(n)}),a(n),()=>{r.forEach(e=>e?.())}},[s,e]),{getDisplaySrc:(0,u.useCallback)(e=>{let{itemId:t,requestUrl:n,controller:r}=s(e);return i[t]||r.src||n},[i,s]),handleLoad:(0,u.useCallback)(e=>{s(e).controller.handleSuccess()},[s]),handleError:(0,u.useCallback)(e=>{let{itemId:t,controller:n}=s(e),r=L(n.handleError(),n.src);r?.changed&&r.src&&a(e=>({...e,[t]:r.src}))},[s])}}var z=`blocks`,B=({setCurrentImageLink:e,setModalHeight:t,setModalWidth:n,setImageStockList:r,imageStockList:s,currentReq:l,setCurrentReq:d,inputRef:f,setStockLink:m,customRequest:h})=>{let g=i.sn(),_=c.t(),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(2),{__:S}=o.h(),C=o.o(),[w]=a.S(),[T]=a.x(),E=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:S(`Failed to load stock images through the configured proxy chain.`),[S]),O=(0,u.useCallback)(e=>{C.error({id:`STOCK_IMAGES_SEARCH_FAILED`,title:S(`Failed to load stock images`),description:E(e)})},[S,E,C]),k=async()=>{v||(y(!0),T({query:l,page:b}).then(e=>{if(e?.error){O(e.error),y(!1);return}let t=e?.data?.results||[];r(e=>[...e,...t]),y(!1),x(e=>e+1)}).catch(()=>{y(!1)}))};(0,u.useEffect)(()=>{l.keywords!==``&&A()},[l.color,l.orientation]);let A=async()=>{let e=await T({query:l,page:1});if(e?.error){O(e.error),r([]);return}let i=e?.data?.results||[];i.length>0?(r(i),setTimeout(()=>{n(1060),t(`84vh`)},0)):r([])},[j,M]=(0,u.useState)(null),N=(0,u.useCallback)((e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}w=${t}&q=${n}`,[]),P=(0,u.useCallback)(e=>i.eo(e,{config:g,standalone:_,resourceType:`stockImages`,intent:`display`}),[g,_]),{getDisplaySrc:F,handleLoad:L,handleError:B}=R({items:s,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>N(e.urls.raw,644,96),[N]),createController:P}),V=e=>t=>{L(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)},te=(t,n,r)=>{w(n.download_location),M(r),setTimeout(()=>M(null),2e3),m(`${t.raw}&w=1200&q=96`),e(`${t.raw}&w=1200&q=96`),h(`${t.raw}&w=1200&q=96`)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:A,className:s.length>0?`serach-results`:``,children:[(0,p.jsxs)(o.Ot,{gutter:24,children:[(0,p.jsx)(o.Dt,{span:s.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:A,allowClear:!0,size:s.length>0?`medium`:`large`,placeholder:S(`Search image`),value:l.keywords,onChange:e=>d(t=>({...t,keywords:e.target.value})),ref:f,spellCheck:`false`,enterButton:!1})})}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Dt,{children:(0,p.jsxs)(o._t.Group,{defaultValue:``,onChange:e=>d(t=>({...t,orientation:e.target.value})),children:[(0,p.jsx)(o.U,{title:S(`All`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:``,children:(0,p.jsx)(c.m,{icon:`MixedView`})})}),(0,p.jsx)(o.U,{title:S(`Landscape`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`landscape`,children:(0,p.jsx)(c.m,{icon:`LandscapeView`})})}),(0,p.jsx)(o.U,{title:S(`Portrait`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`portrait`,children:(0,p.jsx)(c.m,{icon:`PortraitView`})})}),(0,p.jsx)(o.U,{title:S(`Squarish`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`squarish`,children:(0,p.jsx)(c.m,{icon:`SquareView`})})})]})}),(0,p.jsx)(o.Dt,{children:(0,p.jsx)(o.A,{defaultValue:``,onChange:e=>d(t=>({...t,color:e.target.value})),options:[{value:``,colorClass:`all-colors`,label:S(`All`)},{value:`black`,colorClass:`black-color`,label:S(`Black`)},{value:`black_and_white`,colorClass:`bw-color`,label:S(`Black and White`)},{value:`white`,colorClass:`white-color`,label:S(`White`)},{value:`orange`,colorClass:`orange-color`,label:S(`Orange`)},{value:`red`,colorClass:`red-color`,label:S(`Red`)},{value:`purple`,colorClass:`purple-color`,label:S(`Purple`)},{value:`magenta`,colorClass:`magenta-color`,label:S(`Magenta`)},{value:`green`,colorClass:`green-color`,label:S(`Green`)},{value:`teal`,colorClass:`teal-color`,label:S(`Teal`)},{value:`blue`,colorClass:`blue-color`,label:S(`Blue`)}],tooltipPlacement:`top`})})]})]}),s.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:s.length>0&&(0,p.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,p.jsx)(D,{dataLength:s&&s.length,next:k,hasMore:s,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[S("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:null,children:(0,p.jsx)(I,{breakpointCols:{default:3},className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:s.map(e=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>te(e.urls,e.links,e.id),children:[(0,p.jsx)(`img`,{className:j===e.id?`loaded-image`:``,width:`322px`,src:F(e),alt:e.description,onLoad:V(e),onError:ee(e)}),(0,p.jsxs)(`p`,{className:`creator-info`,onClick:e=>e.stopPropagation(),children:[`Photo by`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`${e.user.links.html}?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:e.user.name}),` `,`on`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`https://unsplash.com/?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:`Unsplash`})]}),j===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id))})})})})]})},V=({images:e,transitionDuration:t=1e3})=>{let[n,r]=(0,u.useState)([]);return(0,u.useEffect)(()=>{if(e.length>0){let t=e[e.length-1];r(e=>[...e,{src:t,opacity:0}]),setTimeout(()=>{r(e=>e.map((t,n)=>n===e.length-1?{...t,opacity:1}:t))},1e3)}},[e]),(0,p.jsx)(`div`,{className:`slideshow-container`,children:n.map((e,n)=>(0,p.jsx)(`img`,{src:`data:image/jpeg;base64, ${e.src}`,alt:`Slide ${n+1}`,className:`slideshow-image`,style:{opacity:e.opacity,transition:`opacity ${t}ms linear`}},n))})};function ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:s,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,onPluginAiImageLimitExceeded:g,onImageGenerateLimitExceeded:_}){let{__:v}=o.h(),y=i.sn(),b=o.o(),x=i.wt(),{emailId:S,blockId:C,projectId:w}=(0,f.useParams)(),[T]=a.C(),[E,{data:D=[]}]=a.v(),[O]=a.g(),k=y?.sendAIImageRequest||T,A=y?.trigger||E,j=y?.handleLimitUsageEmitter||i.q(i.xo.ON_LIMIT_ID),[M,N]=(0,u.useState)(0),[P,F]=(0,u.useState)(null),[I,L]=(0,u.useState)(!1),[R,z]=(0,u.useState)(v(`Evaluating the task`)),[B,V]=(0,u.useState)(!1),ee=S||C,{limits:te}=y?.limits?y:{limits:{ai_img_limit:0}},{ai_img_limit:H}=te,U=H>0&&M>=H,W=!!(y.limits&&y.counters)&&i.Ca.isPlugin,G=(0,u.useCallback)(()=>{j.fire({name:`AiImgCount`,count:M+1})},[j,M]),K=(0,u.useMemo)(()=>!U&&(!W||H===0||M<H),[U,W,M,H]),ne=(0,u.useCallback)(async()=>{z(v(`Evaluating the task`)),l!==``&&!m&&(h(!0),V(!0),p([]),x({event:`submit_form`,action:`ai_image_generation`,entity_id:S,project_id:w}),k({body:{project_id:w,request:`create-image`,connection:`midjourney`,message:l}}).then(({data:e,error:t})=>{if(t)throw t;if(e.data.status===401)throw Error(i.sa);e?.data.status===200?(e?.data.task.id&&(z(e.data.task.message),F(e.data.task.id)),e.message&&b.success({id:`AI_IMAGE_SEND_SUCCESS`,title:e.message,placement:`bottomRight`,data:l}),A({task_id:e?.data.task.id,entity_id:ee})):(h(!1),V(!1),b.error({id:`AI_IMAGE_SEND_ERROR`,title:e?.message||v(`Something went wrong, please try again`),placement:`bottomRight`,data:l,innerException:e}))}).catch(e=>{h(!1),V(!1),(e?.error||e?.data)&&b.fromError(`AI_IMAGE_SEND_ERROR`,l,e.error||e)}))},[l,m,h,V,p,x,S,w,k,b,A,ee,v]),re=(0,u.useCallback)(async()=>{if(K){if(!W){let e=c.l(`image_generate`,(await O(`image_generate`)).data?.stats);if(e){_?.(e);return}}W&&(N(e=>e+1),G()),ne()}else W&&(g?g():b.error({title:v(`The usage limit has been exceeded`),description:v(`The maximum number of requests for the current subscription period has been reached.
|
|
4
|
-
Select the appropriate plan to fulfil more requests`),placement:`bottomRight`}))},[K,W,O,_,N,G,ne,b,v,g]);(0,u.useEffect)(()=>{W&&N(y?.counters?.ai_img_counter||0)},[y,W]);let ie=(0,u.useCallback)(e=>{if(!r){s(!0);let n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;let r=n[1],i=n[2],a=atob(i),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let c=new Uint8Array(o),l=new Blob([c],{type:`image/${r}`});t({file:new File([l],`image.jpeg`,{type:l.type})})}},[r,s,t]),ae=(0,u.useCallback)(e=>{e.status!==`error`&&e.status!==`Canceled`?e.images?(z(e.status),e.progress===100&&(p(e.images),z(v(`Evaluating the task`)),F(null),V(!1))):(p([e.data]),h(!1)):(h(!1),V(!1),b.error({id:`AI_IMAGE_GET_ERROR`,title:v(`Something went wrong, please try again`),placement:`bottomRight`,data:P}))},[p,z,v,h,e,P,b,V]);return(0,u.useEffect)(()=>{D.length>1&&ae(D[D.length-1])},[D,ae]),(0,u.useEffect)(()=>{(m||d.length>0)&&setTimeout(()=>{let t=550;n.current&&(t=n.current.offsetHeight+68),e(t)},0)},[n,D,d.length,m,e]),{aiImageCounter:M,setAiImageCounter:N,currentAiImgLimits:H,isFieldsDisabled:U,canGenerateImage:K,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,loadingDuringGeneration:B,setLoadingDuringGeneration:V,requestStatus:R,setRequestStatus:z,handleGenerate:re,handleLimitAiImgCount:G,convertBase64ToFile:ie,isShiftPressed:I,setIsShiftPressed:L,currentReqId:P,setCurrentReqId:F,limitsInPlugin:W}}var te=({setModalHeight:e,customRequest:t,aiTabRef:n,inputAiRef:r,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,setAiImageRequest:h,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y})=>{let b=(0,f.useNavigate)(),x=i.Ei(),{__:S,_n:C}=o.h(),w=i.sn(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),{aiImageCounter:k,currentAiImgLimits:A,loadingDuringGeneration:j,requestStatus:M,handleGenerate:N,convertBase64ToFile:P,isShiftPressed:F,setIsShiftPressed:I,limitsInPlugin:L}=ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y,onPluginAiImageLimitExceeded:()=>E(!0),onImageGenerateLimitExceeded:O}),R=T&&A>0?l.p(A):null,z=R?c.u(R.presetId):null,B=D?c.u(D.presetId):null,[te,H]=(0,u.useState)(!1),U=(0,u.useCallback)(()=>H(!0),[]),W=(0,u.useCallback)(()=>H(!1),[]),G=(0,u.useCallback)(e=>h(e.target.value),[h]),K=(0,u.useCallback)(e=>{e.key===`Shift`?I(!0):e.key===`Enter`&&!F&&(e.preventDefault(),N())},[F,N,I]),ne=(0,u.useCallback)(e=>{e.key===`Shift`&&I(!1)},[I]),re=g[g.length-1];return(0,p.jsxs)(`div`,{className:`image-ai`,children:[z&&R?(0,p.jsx)(c.f,{open:!0,onClose:()=>E(!1),title:S(z.titleKey),subtitle:S(z.subtitleKey),usageResource:z.usageResource,previousDisplay:c.d(R.previousLimit),nextDisplay:c.d(R.nextLimit),onChangePlan:()=>{E(!1),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.va.SWITCH_TO_PLAN_MODAL))}}):null,B&&D?(0,p.jsx)(c.f,{open:!0,onClose:()=>O(null),title:S(B.titleKey),subtitle:S(B.subtitleKey),usageResource:B.usageResource,previousDisplay:c.d(D.previousLimit),nextDisplay:c.d(D.nextLimit),onChangePlan:()=>{O(null),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.va.SWITCH_TO_PLAN_MODAL))}}):null,L&&(0,p.jsx)(o.P,{text:`${k} ${S(`of`)} ${A>0?A:`∞`} images ${C(`was used`,`were used`,k)}`,exceeded:A>0&&k>=A,style:{marginTop:-25},extra:(0,p.jsx)(`span`,{style:{textDecoration:`underline`,cursor:`pointer`},onClick:()=>b(w.billingPageUrl||i.Bi.billing),children:S(`Need more?`)})}),(0,p.jsx)(o.Ot,{gutter:24,className:`image-ai__row`,children:(0,p.jsx)(o.Dt,{span:24,children:(0,p.jsx)(o.Ft.Item,{style:{margin:0},children:(0,p.jsxs)(`span`,{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg image-ai__input-affix-wrapper${te?` ant-input-affix-wrapper-focused`:``}`,children:[(0,p.jsx)(o.xt,{ref:r,onKeyDown:K,onKeyUp:ne,onFocus:U,onBlur:W,autoSize:!0,allowClear:!0,className:`text-area-input-hybrid image-ai__textarea`,placeholder:S(`Generate image`),value:m,onChange:G,spellCheck:`false`}),(0,p.jsx)(`span`,{className:`ant-input-suffix image-ai__input-suffix`,children:v||j?(0,p.jsx)(c.m,{icon:`LoadingOutlined`,className:`input-icon image-ai__input-icon`,spin:!0}):(0,p.jsx)(c.m,{icon:`AI`,className:`input-icon image-ai__input-icon`,onClick:N})})]})})})}),(v||g.length>0)&&(0,p.jsxs)(`div`,{className:`image-ai__preview`,children:[v&&g.length===0&&(0,p.jsx)(`div`,{className:`image-ai__loading`,children:(0,p.jsxs)(`div`,{className:`spin`,children:[(0,p.jsx)(c.m,{icon:`LoadingOutlined`,style:{fontSize:48},spin:!0}),(0,p.jsx)(`p`,{className:`status`,children:M})]})}),g.length>0&&(0,p.jsxs)(`div`,{className:`image-ai__image-item`,children:[(0,p.jsx)(V,{images:g}),(0,p.jsx)(`div`,{className:`buttons`,children:(0,p.jsx)(o.Rt,{onClick:()=>P(`data:image/jpeg;base64, ${re}`),icon:(0,p.jsx)(c.m,{icon:`CheckOutlined`}),children:S(`Use this one`)})})]})]})]})},H=({setNewLink:e,setCurrentImageLink:t,setModalHeight:n,setModalWidth:r,setImageGifList:s,imageGifList:l,currentReqGif:d,setCurrentReqGif:f,inputRef:m,setStockLink:h,customRequest:g})=>{let{__:_}=o.h(),v=i.sn(),y=c.t(),b=o.o(),[x,S]=(0,u.useState)(null),[C,w]=(0,u.useState)(!1),[T,E]=(0,u.useState)(25),[O]=a.b(),k=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:_(`Failed to load GIFs through the configured proxy chain.`),[_]),A=(0,u.useCallback)(e=>{b.error({id:`STOCK_GIFS_SEARCH_FAILED`,title:_(`Failed to load GIFs`),description:k(e)})},[_,k,b]),j=async()=>{C||(w(!0),O({query:d,page:T}).then(e=>{if(e?.error){A(e.error),w(!1);return}s(t=>[...t,...e.data.data]),w(!1),E(e=>e+25)}).catch(()=>{w(!1)}))},M=async()=>{let e=await O({query:d,page:0});if(e?.error){A(e.error),s([]);return}e?.data?.data?.length>0&&(s(e.data.data),setTimeout(()=>{n(`84vh`),r(1060)},0))},N=(e,n)=>{S(n),setTimeout(()=>{S(null)},2e3),h(`${e}`),t(`${e}`),g(`${e}`)},P={default:3},F=(0,u.useCallback)(e=>i.eo(e,{config:v,standalone:y,resourceType:`generic`,intent:`display`}),[v,y]),{getDisplaySrc:L,handleLoad:z,handleError:B}=R({items:l,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>e.images.downsized.url,[]),createController:F}),V=e=>t=>{z(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:M,className:l.length>0?`serach-results`:``,children:[(0,p.jsx)(o.Ot,{gutter:24,children:(0,p.jsx)(o.Dt,{span:l.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:M,allowClear:!0,size:l.length>0?`medium`:`large`,placeholder:_(`Search GIFs`),value:d.keywords,onChange:e=>f(t=>({...t,keywords:e.target.value})),ref:m,spellCheck:`false`,enterButton:!1})})})}),l.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:l.length>0&&(0,p.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,p.jsx)(D,{dataLength:l&&l.length,next:j,hasMore:l,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[_("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:(0,p.jsx)(o.K,{size:`small`}),children:(0,p.jsx)(I,{breakpointCols:P,className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:l.map((e,t)=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>N(e.images.downsized.url,e.id),children:[(0,p.jsx)(`img`,{className:x===e.id?`loaded-image`:``,width:`322px`,src:L(e),alt:e.title,onLoad:V(e),onError:ee(e)}),(0,p.jsx)(`a`,{rel:`noreferrer`,href:`https://giphy.com/`,target:`_blank`,onClick:e=>e.stopPropagation(),children:(0,p.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=)`}})}),x===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id+t))})})})})]})};function U(e){if(!(e==null||e===``))return e}async function W(e,t){if(e){if(e.url)return e.url;if(typeof t.getFileById==`function`&&e.id){let n=await t.getFileById(e.id);if(n?.url)return n.url;if(n?.thumbnailUrl)return n.thumbnailUrl;if(n?.thumbnail)return n.thumbnail}if(typeof t.getFileUrl==`function`&&e.folderId!==void 0&&e.name){let n=await t.getFileUrl(e.folderId||``,e.name);if(n)return n}if(typeof t.getUrl==`function`&&e.name){let n=await t.getUrl(e);if(n)return n}return e.thumbnail||e.thumbnailUrl}}function G(e){if(!(!e?.success||!Array.isArray(e.detailed)))return e.detailed.find(e=>e?.success&&e.data)?.data}function K(e,t,n){if(e)return{id:e.id,name:e.name||t.name,size:e.size??t.size,type:e.type||t.type,folderId:e.folderId??n??``,url:e.url,thumbnail:e.thumbnail,thumbnailUrl:e.thumbnailUrl,date:e.date,dimensions:e.dimensions,aspectRatio:e.aspectRatio,extension:e.extension,selected:e.selected,isFolder:e.isFolder,lastEdited:e.lastEdited,childrenCount:e.childrenCount}}async function ne(e,t,n){if(!t)return;let r=U(n??t.rootId),i;typeof t.uploadFiles==`function`?i=G(await t.uploadFiles({folderId:r,items:[{name:e.name,size:e.size,type:e.type,folderId:r,data:e}]})):typeof t.uploadFile==`function`&&(i=K(await t.uploadFile({name:e.name,size:e.size,type:e.type,folderId:r,data:e}),e,r));let a=await W(i,t);return a?{item:i,url:a}:void 0}var re=`IMG`,ie=`BACKGROUND`,ae=`GALLERY`,oe=`EDITOR`,q=`UPLOAD`,se=`STOCK`,ce=`GIF`,le=`AI`,{Dragger:ue}=o.gt,de=(e,t=`image`)=>{try{let n=new URL(e).pathname.split(`/`).pop();return n&&decodeURIComponent(n)||t}catch{return t}},fe=l.f,pe=(e,t)=>{let n=fe(t);return!n||e.includes(`.`)?e:`${e}.${n}`},me=(e,t)=>new File([e],pe(de(t),e.type),{type:e.type||`application/octet-stream`}),he=({dataProvider:e})=>{let t=i.sn(),n=c.t(),{__:r}=o.h(),s=i.Ei(),{projectId:d}=(0,f.useParams)(),[m]=a.y(),{modal:h}=o.Wt.useApp(),g=o.o(),_=i.Ti(i.r),v=i.Ti(i.n),b=i.Ti(a.s),{request:x,resolveImagePicker:S}=c.r(),[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``),[k,A]=(0,u.useState)(``),[j,M]=(0,u.useState)(q),[N,P]=(0,u.useState)({width:``,height:``,size:``,format:``}),[F,I]=(0,u.useState)(`success`),[L,R]=(0,u.useState)(!1),z=u.default.useRef(null),V=u.default.useRef(null),ee=u.default.useRef(null),U=u.default.useRef(null),W=u.default.useRef(null),G=u.default.useRef(null),K=u.default.useRef(null),de=u.default.useRef(null),pe=u.default.useRef(null),[he,J]=(0,u.useState)(`auto`),[ge,Y]=(0,u.useState)(572),[_e,ve]=(0,u.useState)(!1),[ye,be]=(0,u.useState)({keywords:``,color:``,orientation:``}),[xe,Se]=(0,u.useState)({keywords:``}),[Ce,we]=(0,u.useState)([]),[Te,Ee]=(0,u.useState)([]),[De,Oe]=(0,u.useState)([]),[ke,Ae]=(0,u.useState)(!1),[je,Me]=(0,u.useState)(``),[Ne,Pe]=(0,u.useState)(!1),[Fe,Ie]=(0,u.useState)(0),Le=i.Ti(i.ct),Re=Le?.id===void 0?d||``:String(Le.id),ze=i.q(i.xo.UPLOAD_EVENT_ID),Be=u.default.useRef(l.u()),Ve=u.default.useRef(``),He=u.default.useRef(0),X=u.default.useRef(``),[Ue,We]=(0,u.useState)(``),[Ge,Ke]=(0,u.useState)(``),Z=(0,u.useCallback)(()=>{X.current&&=(URL.revokeObjectURL(X.current),``),We(``)},[]),Q=(0,u.useCallback)(()=>{Ke(``)},[]),$=!(_||v.id?.toString()!==Le?.members?.owner.ID),qe=e=>{E(e.target.value)},Je=(0,u.useCallback)((e,t,n=r(`The image could not be uploaded.`))=>{let i=t instanceof Error?t.message:n;g.error({id:`IMAGE_UPLOAD_ERROR`,data:e,title:r(`Upload failed`),description:i})},[r,g]),Ye=(0,u.useCallback)(async e=>c.o(await ze.fire({file:e,project:Re})),[Re,ze]),Xe=l.t(),Ze=async e=>{if(e)try{let t=await $e(e);t&&it(t)?await at({file:t}):t||Je({url:e},null,r(`Failed to download image from URL.`))}catch(t){Je({url:e},t,r(`Failed to process image URL.`))}},Qe=u.default.useRef(Ze);Qe.current=Ze,u.default.useEffect(()=>{if(j!==q||!k)return;let e=T.trim();if(!e||!e.toLowerCase().startsWith(`http`))return;let t=setTimeout(()=>{Qe.current(e)},1e3);return()=>{clearTimeout(t)}},[T,j,k]);let $e=async e=>{try{let t=l.l(e);return me(await Be.current.resolve(t,void 0,Xe),t)}catch{}};document.onpaste=function(e){let n=e.clipboardData?.items?.[0];if(j===q&&k){if(n?.type?.indexOf(`image`)===0&&t.imageCenterLocalUploadEnabled!==!1){let e=n.getAsFile();it(e);let t={file:e};E(``),at(t);return}let r=e.clipboardData?.getData(`text/plain`);if(r&&r.trim().toLowerCase().startsWith(`http`)){e.preventDefault(),e.stopPropagation(),E(r.trim());return}n?.type?.indexOf(`text`)===0&&n.getAsString(e=>{if(e.trim().toLowerCase().startsWith(`http`))E(e.trim());else if(e.toString().slice(1,5)===`meta`){let t=e.toString().split(`"`)[1];t&&E(t)}})}},(0,u.useEffect)(()=>{let e=e=>{let t=null;x?.kind===`background`?(t=ie,A(ie)):x?.kind===`img`&&(A(re),t=re),x?.currentUrl&&t&&(w(x.currentUrl),M(e))};b===i.va.UPLOAD_IMAGE_MODAL||b===i.va.UPLOAD_BACKGROUND_MODAL?e(oe):b===i.va.UPLOAD_IMAGE_MODAL_AI||b===i.va.UPLOAD_BACKGROUND_MODAL_AI?($?(Pe(!0),Ie(2)):e(le),setTimeout(()=>pe.current?.focus({cursor:`start`}),100)):b===i.va.UPLOAD_IMAGE_MODAL_UPLOAD||b===i.va.UPLOAD_BACKGROUND_MODAL_UPLOAD?(e(q),setTimeout(()=>G.current?.focus({cursor:`start`}),100)):b===i.va.UPLOAD_IMAGE_MODAL_STOCK||b===i.va.UPLOAD_BACKGROUND_MODAL_STOCK?($?(Pe(!0),Ie(3)):e(se),setTimeout(()=>de.current?.focus({cursor:`start`}),100)):b===i.va.UPLOAD_IMAGE_MODAL_GIF||b===i.va.UPLOAD_BACKGROUND_MODAL_GIF?($?(Pe(!0),Ie(3)):e(ce),setTimeout(()=>K.current?.focus({cursor:`start`}),100)):b===i.va.UPLOAD_IMAGE_MODAL_EDIT||b===i.va.UPLOAD_BACKGROUND_MODAL_EDIT?($?(Pe(!0),Ie(5)):e(oe),s(a.i(i.va.IMAGE_EDITOR_MODAL))):A(``)},[b,s,$,x]);let et=(0,u.useCallback)(({url:e=C||``})=>{w(e),S({url:e,meta:{mode:`select`}}),setTimeout(()=>{Q(),Z(),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),Ee([]),we([]),A(``),Me(``),Ae(!1),O(``),E(``),M(q)},200),s(a.t()),s(a.n())},[C,Q,s,S,Z]),tt=(0,u.useCallback)((e,t)=>(J(`auto`),R(!1),et({url:e}),g.success({id:`IMAGE_UPLOAD_SUCCESS`,data:t,title:r(`The image was successfully uploaded.`)}),e),[r,et,g]);(0,u.useEffect)(()=>{let t=T||D,r=l.l(t);if(!t||!r){I(``),Ve.current=``,Q(),Z(),Be.current.invalidateAll();return}let i=Ve.current;i&&i!==r&&(Be.current.abandonKey(i),Q(),Z()),Ve.current=r;let a=new AbortController,o=T?800:0,s=++He.current,c=setTimeout(async()=>{try{let i=async()=>{let e=await Be.current.resolve(r,a.signal,Xe);if(s!==He.current)return;let{width:t,height:n}=await l.d(e);if(s!==He.current)return;P({width:t,height:n,size:(e.size/1024).toFixed(2),format:fe(e.type)}),Q(),X.current&&URL.revokeObjectURL(X.current);let i=URL.createObjectURL(e);X.current=i,We(i)};if(n)await i();else{let t=await l.n(e,r);if(t?.previewUrl&&s===He.current){Ke(t.previewUrl),Z();try{let{data:e}=await m(r);if(s!==He.current)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await i()}catch{await i()}}else await i()}if(s!==He.current)return;I(`success`),w(t),Y(572),setTimeout(()=>{let e=0;V.current&&(e=V.current.offsetHeight+62),J(e)},0)}catch(e){if(e?.name===`AbortError`||a.signal.aborted||s!==He.current)return;Q(),Z(),I(`error`)}},o);return()=>{clearTimeout(c),a.abort()}},[T,D,n,Q,Xe,m,Z,e]),(0,u.useEffect)(()=>{if(!C||T||D)return;let t=l.l(C),r=new AbortController,i=!1,a=async()=>{let e=await Be.current.resolve(t,r.signal,Xe);if(i)return;let{width:n,height:a}=await l.d(e);if(i)return;Q(),X.current&&URL.revokeObjectURL(X.current);let o=URL.createObjectURL(e);X.current=o,We(o),P({width:n,height:a,size:(e.size/1024).toFixed(2),format:fe(e.type)})};return(async()=>{try{if(!n){let n=await l.n(e,t);if(n?.previewUrl&&!i){Ke(n.previewUrl),Z();try{let{data:e}=await m(t);if(i)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await a();return}catch{await a()}}}await a()}catch{i||Q()}})(),()=>{i=!0,r.abort()}},[n,Q,C,Xe,m,e,T,D]);let nt=()=>{s(a.t()),setTimeout(()=>{Q(),Z(),w(``),E(``),Ee([]),Ee([]),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),J(`auto`),!ke&&Me(``),Y(572),M(q)},200)},rt=e=>{e===ae?h.success({mask:{closable:!0},centered:!0,title:r(`Coming soon`),content:r(`The feature is under development.`),okText:r(`Ok. I'll be waiting`),onOk:()=>{}}):e===oe&&C===``?h.warning({mask:{closable:!0},centered:!0,title:r(``),content:r(`To preview and edit the uploaded image`),okText:r(`Upload Image`),onOk:()=>{M(q)}}):(setTimeout(()=>{let t=0,n=0;e===q&&z.current?(ye.keywords===``&&G.current?.focus({cursor:`start`}),t=300,n=572):e===oe&&V.current?(t=V.current.offsetHeight+62,n=572):e===se&&ee.current?(ye.keywords===``&&de.current?.focus({cursor:`start`}),t=130,n=572,Te.length>0&&(n=1060,t=`84vh`)):e===ce&&U.current?(ye.keywords===``&&K.current?.focus({cursor:`start`}),t=130,n=572,Ce.length>0&&(n=1060,t=`84vh`)):e===le&&W.current&&(je===``&&De.length===0?(pe.current?.focus({cursor:`start`}),t=130):t=W.current.offsetHeight+82,n=572),J(t),Y(n)},0),M(e))};(0,u.useEffect)(()=>{ye.keywords===``&&(G?.current?.focus({cursor:`start`}),Ee([]),setTimeout(()=>{J(`auto`),Y(572)},0))},[ye,Ee,J,Y]);let it=e=>{let t=e.type===`image/jpeg`||e.type===`image/png`||e.type===`image/jpg`||e.type===`image/webp`||e.type===`image/gif`||e.type===`image/svg+xml`;return t||g.error({id:`IMAGE_UPLOAD_WRONG_FORMAT`,data:e,title:`Upload`,description:`You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!`}),t},at=async({file:n})=>{try{ve(!0);let r=await l.i(n,t),i=await Ye(r);if(i)return tt(i,r),i;let a=await ne(r,e);if(a?.url)return tt(a.url,r),a.url;Je(r,null);return}catch(e){Je(n,e);return}finally{ve(!1)}},ot=e=>at({file:e}),st=[{label:r(`Upload`),key:q,children:(0,p.jsxs)(`div`,{ref:z,style:{paddingBottom:24},children:[t.imageCenterLocalUploadEnabled!==!1&&(0,p.jsxs)(ue,{showUploadList:!1,name:`Image`,beforeUpload:it,customRequest:at,style:{marginBottom:10},multiple:!1,accept:`image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml`,children:[(0,p.jsx)(`p`,{className:`ant-upload-drag-icon`,children:(0,p.jsx)(c.m,{icon:`InboxOutlined`})}),(0,p.jsx)(`p`,{className:`ant-upload-text`,children:r(`Click to select, paste from the clipboard, or drag and drop`)}),(0,p.jsx)(`p`,{className:`ant-upload-hint`,children:r(`Accepted formats: PNG, JPG, WEBP, SVG or GIF.`)})]}),(0,p.jsx)(o.Ft,{style:{padding:`0 2px 0 2px`},children:(0,p.jsx)(o.Ft.Item,{validateStatus:F,children:(0,p.jsx)(o.kt,{ref:G,allowClear:!0,size:`large`,placeholder:r(`Paste image URL here`),value:T,onChange:qe,spellCheck:`false`})})})]})}];return t.imageCenterStockEnabled&&!$&&st.push({label:r(`Stock`),key:se,children:(0,p.jsx)(`div`,{ref:ee,style:{paddingBottom:24},children:(0,p.jsx)(B,{currentReq:ye,setCurrentReq:be,imageStockList:Te,setImageStockList:Ee,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:de,customRequest:Ze})})}),t.imageCenterGifEnabled&&!$&&st.push({label:r(`GIF`),key:ce,children:(0,p.jsx)(`div`,{ref:U,style:{paddingBottom:24},children:(0,p.jsx)(H,{currentReqGif:xe,setCurrentReqGif:Se,imageGifList:Ce,setImageGifList:we,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:K,customRequest:Ze})})}),t.elementAIimageEnabled&&!$&&st.push({label:r(`AI`),key:le,children:(0,p.jsx)(`div`,{ref:W,style:{paddingBottom:24},children:(0,p.jsx)(te,{setModalHeight:J,customRequest:at,aiImageRequest:je,setAiImageRequest:Me,imageAiList:De,setImageAiList:Oe,isLoadingAi:ke,setIsLoadingAi:Ae,aiTabRef:W,inputAiRef:pe,isImageUploaded:L,setIsImageUploaded:R})})}),t.imageCenterEditorEnabled&&st.push({label:``,key:oe,children:(0,p.jsx)(`div`,{ref:V,children:(0,p.jsx)(y,{currentImageLink:C,newLink:T,previewDisplayUrl:Ge,resolvedPreviewObjectUrl:Ue,imageSize:N,onSave:ot,uploadImageResultIsLoading:_e||!1})})}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Y,{width:ge,className:`image-center`,title:r(`Image Center`),style:{minHeight:390},open:!!k,onOk:et,onCancel:nt,footer:j===oe?(0,p.jsx)(p.Fragment,{}):null,children:(0,p.jsx)(o.K,{spinning:_e,children:(0,p.jsx)(o.Z,{activeKey:j,onChange:rt,items:st,className:`modal-tabs`,style:{height:he,minHeight:130}})})}),(0,p.jsx)(c.g,{open:Ne,onCancel:()=>Pe(!1),initialSlide:Fe})]})};he.propTypes={dataProvider:d.default.object},t.default=he});
|
|
3
|
+
as expected. Check README.md for usage'`)},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener(`scroll`,this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener(`touchstart`,this.onStart),this.el.removeEventListener(`touchmove`,this.onMove),this.el.removeEventListener(`touchend`,this.onEnd),this.el.removeEventListener(`mousedown`,this.onStart),this.el.removeEventListener(`mousemove`,this.onMove),this.el.removeEventListener(`mouseup`,this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength===t.prevDataLength?null:S(S({},t),{prevDataLength:e.dataLength})},t.prototype.isElementAtTop=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=S({height:this.props.height||`auto`,overflow:`auto`,WebkitOverflowScrolling:`touch`},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:`auto`}:{};return u.default.createElement(`div`,{style:r,className:`infinite-scroll-component__outerdiv`},u.default.createElement(`div`,{className:`infinite-scroll-component `+(this.props.className||``),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&u.default.createElement(`div`,{style:{position:`relative`},ref:function(t){return e._pullDown=t}},u.default.createElement(`div`,{style:{position:`absolute`,left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(u.Component);function O(e,t){if(e==null)return{};var n=k(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function k(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function A(){return A=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A.apply(this,arguments)}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?j(Object(n),!0).forEach(function(t){N(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0},F=2,I=class extends u.default.Component{constructor(e){super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this);let t;t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||F,this.state={columnCount:t}}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(){let e=window&&window.innerWidth||1/0,t=this.props.breakpointCols;typeof t!=`object`&&(t={default:parseInt(t)||F});let n=1/0,r=t.default||F;for(let i in t){let a=parseInt(i);a>0&&e<=a&&a<n&&(n=a,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){let e=this.state.columnCount,t=Array(e),n=u.default.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){let i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){let{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),i=`${100/r.length}%`,a=n;a&&typeof a!=`string`&&(this.logDeprecated(`The property "columnClassName" requires a string`),a===void 0&&(a=`my-masonry-grid_column`));let o=M(M(M({},e),t),{},{style:M(M({},t.style),{},{width:i}),className:a});return r.map((e,t)=>u.default.createElement(`div`,A({},o,{key:t}),e))}logDeprecated(e){}render(){let e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:i,column:a,className:o}=e,s=O(e,[`children`,`breakpointCols`,`columnClassName`,`columnAttrs`,`column`,`className`]),c=o;return typeof o!=`string`&&(this.logDeprecated(`The property "className" requires a string`),o===void 0&&(c=`my-masonry-grid`)),u.default.createElement(`div`,A({},s,{className:c}),this.renderColumns())}};I.defaultProps=P;function L(e,t){return e?e.exhausted?{...e,src:null}:{...e,src:e.src||t||null}:null}function R({items:e,getItemId:t,getRequestUrl:n,createController:r}){let[i,a]=(0,u.useState)({}),o=(0,u.useRef)(new Map),s=(0,u.useCallback)(e=>{let i=t(e),a=n(e),s=`${i}:${a}`;if(o.current.has(s))return{itemId:i,requestUrl:a,cacheKey:s,controller:o.current.get(s)};let c=r(a);return o.current.set(s,c),{itemId:i,requestUrl:a,cacheKey:s,controller:c}},[r,t,n]);return(0,u.useEffect)(()=>{let t=new Set,n={},r=e.map(e=>{let{itemId:r,cacheKey:i,controller:o}=s(e);t.add(i),n[r]=o.src;let c=L(o.handleChangeSrc?.(),o.src);return c?.changed&&c.src&&(n[r]=c.src),o.subscribeToSrcChange?.(e=>{let t=L(e,o.src);!t?.changed||!t.src||a(e=>e[r]===t.src?e:{...e,[r]:t.src})})}).filter(Boolean);return o.current.forEach((e,n)=>{t.has(n)||o.current.delete(n)}),a(n),()=>{r.forEach(e=>e?.())}},[s,e]),{getDisplaySrc:(0,u.useCallback)(e=>{let{itemId:t,requestUrl:n,controller:r}=s(e);return i[t]||r.src||n},[i,s]),handleLoad:(0,u.useCallback)(e=>{s(e).controller.handleSuccess()},[s]),handleError:(0,u.useCallback)(e=>{let{itemId:t,controller:n}=s(e),r=L(n.handleError(),n.src);r?.changed&&r.src&&a(e=>({...e,[t]:r.src}))},[s])}}var z=`blocks`,B=({setCurrentImageLink:e,setModalHeight:t,setModalWidth:n,setImageStockList:r,imageStockList:s,currentReq:l,setCurrentReq:d,inputRef:f,setStockLink:m,customRequest:h})=>{let g=i.sn(),_=c.t(),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(2),{__:S}=o.h(),C=o.o(),[w]=a.S(),[T]=a.x(),E=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:S(`Failed to load stock images through the configured proxy chain.`),[S]),O=(0,u.useCallback)(e=>{C.error({id:`STOCK_IMAGES_SEARCH_FAILED`,title:S(`Failed to load stock images`),description:E(e)})},[S,E,C]),k=async()=>{v||(y(!0),T({query:l,page:b}).then(e=>{if(e?.error){O(e.error),y(!1);return}let t=e?.data?.results||[];r(e=>[...e,...t]),y(!1),x(e=>e+1)}).catch(()=>{y(!1)}))};(0,u.useEffect)(()=>{l.keywords!==``&&A()},[l.color,l.orientation]);let A=async()=>{let e=await T({query:l,page:1});if(e?.error){O(e.error),r([]);return}let i=e?.data?.results||[];i.length>0?(r(i),setTimeout(()=>{n(1060),t(`84vh`)},0)):r([])},[j,M]=(0,u.useState)(null),N=(0,u.useCallback)((e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}w=${t}&q=${n}`,[]),P=(0,u.useCallback)(e=>i.no(e,{config:g,standalone:_,resourceType:`stockImages`,intent:`display`}),[g,_]),{getDisplaySrc:F,handleLoad:L,handleError:B}=R({items:s,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>N(e.urls.raw,644,96),[N]),createController:P}),V=e=>t=>{L(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)},te=(t,n,r)=>{w(n.download_location),M(r),setTimeout(()=>M(null),2e3),m(`${t.raw}&w=1200&q=96`),e(`${t.raw}&w=1200&q=96`),h(`${t.raw}&w=1200&q=96`)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:A,className:s.length>0?`serach-results`:``,children:[(0,p.jsxs)(o.Ot,{gutter:24,children:[(0,p.jsx)(o.Dt,{span:s.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:A,allowClear:!0,size:s.length>0?`medium`:`large`,placeholder:S(`Search image`),value:l.keywords,onChange:e=>d(t=>({...t,keywords:e.target.value})),ref:f,spellCheck:`false`,enterButton:!1})})}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Dt,{children:(0,p.jsxs)(o._t.Group,{defaultValue:``,onChange:e=>d(t=>({...t,orientation:e.target.value})),children:[(0,p.jsx)(o.U,{title:S(`All`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:``,children:(0,p.jsx)(c.m,{icon:`MixedView`})})}),(0,p.jsx)(o.U,{title:S(`Landscape`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`landscape`,children:(0,p.jsx)(c.m,{icon:`LandscapeView`})})}),(0,p.jsx)(o.U,{title:S(`Portrait`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`portrait`,children:(0,p.jsx)(c.m,{icon:`PortraitView`})})}),(0,p.jsx)(o.U,{title:S(`Squarish`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`squarish`,children:(0,p.jsx)(c.m,{icon:`SquareView`})})})]})}),(0,p.jsx)(o.Dt,{children:(0,p.jsx)(o.A,{defaultValue:``,onChange:e=>d(t=>({...t,color:e.target.value})),options:[{value:``,colorClass:`all-colors`,label:S(`All`)},{value:`black`,colorClass:`black-color`,label:S(`Black`)},{value:`black_and_white`,colorClass:`bw-color`,label:S(`Black and White`)},{value:`white`,colorClass:`white-color`,label:S(`White`)},{value:`orange`,colorClass:`orange-color`,label:S(`Orange`)},{value:`red`,colorClass:`red-color`,label:S(`Red`)},{value:`purple`,colorClass:`purple-color`,label:S(`Purple`)},{value:`magenta`,colorClass:`magenta-color`,label:S(`Magenta`)},{value:`green`,colorClass:`green-color`,label:S(`Green`)},{value:`teal`,colorClass:`teal-color`,label:S(`Teal`)},{value:`blue`,colorClass:`blue-color`,label:S(`Blue`)}],tooltipPlacement:`top`})})]})]}),s.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:s.length>0&&(0,p.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,p.jsx)(D,{dataLength:s&&s.length,next:k,hasMore:s,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[S("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:null,children:(0,p.jsx)(I,{breakpointCols:{default:3},className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:s.map(e=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>te(e.urls,e.links,e.id),children:[(0,p.jsx)(`img`,{className:j===e.id?`loaded-image`:``,width:`322px`,src:F(e),alt:e.description,onLoad:V(e),onError:ee(e)}),(0,p.jsxs)(`p`,{className:`creator-info`,onClick:e=>e.stopPropagation(),children:[`Photo by`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`${e.user.links.html}?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:e.user.name}),` `,`on`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`https://unsplash.com/?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:`Unsplash`})]}),j===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id))})})})})]})},V=({images:e,transitionDuration:t=1e3})=>{let[n,r]=(0,u.useState)([]);return(0,u.useEffect)(()=>{if(e.length>0){let t=e[e.length-1];r(e=>[...e,{src:t,opacity:0}]),setTimeout(()=>{r(e=>e.map((t,n)=>n===e.length-1?{...t,opacity:1}:t))},1e3)}},[e]),(0,p.jsx)(`div`,{className:`slideshow-container`,children:n.map((e,n)=>(0,p.jsx)(`img`,{src:`data:image/jpeg;base64, ${e.src}`,alt:`Slide ${n+1}`,className:`slideshow-image`,style:{opacity:e.opacity,transition:`opacity ${t}ms linear`}},n))})};function ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:s,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,onPluginAiImageLimitExceeded:g,onImageGenerateLimitExceeded:_}){let{__:v}=o.h(),y=i.sn(),b=o.o(),x=i.wt(),{emailId:S,blockId:C,projectId:w}=(0,f.useParams)(),[T]=a.C(),[E,{data:D=[]}]=a.v(),[O]=a.g(),k=y?.sendAIImageRequest||T,A=y?.trigger||E,j=y?.handleLimitUsageEmitter||i.q(i.Co.ON_LIMIT_ID),[M,N]=(0,u.useState)(0),[P,F]=(0,u.useState)(null),[I,L]=(0,u.useState)(!1),[R,z]=(0,u.useState)(v(`Evaluating the task`)),[B,V]=(0,u.useState)(!1),ee=S||C,{limits:te}=y?.limits?y:{limits:{ai_img_limit:0}},{ai_img_limit:H}=te,U=H>0&&M>=H,W=!!(y.limits&&y.counters)&&i.Ta.isPlugin,G=(0,u.useCallback)(()=>{j.fire({name:`AiImgCount`,count:M+1})},[j,M]),K=(0,u.useMemo)(()=>!U&&(!W||H===0||M<H),[U,W,M,H]),ne=(0,u.useCallback)(async()=>{z(v(`Evaluating the task`)),l!==``&&!m&&(h(!0),V(!0),p([]),x({event:`submit_form`,action:`ai_image_generation`,entity_id:S,project_id:w}),k({body:{project_id:w,request:`create-image`,connection:`midjourney`,message:l}}).then(({data:e,error:t})=>{if(t)throw t;if(e.data.status===401)throw Error(i.la);e?.data.status===200?(e?.data.task.id&&(z(e.data.task.message),F(e.data.task.id)),e.message&&b.success({id:`AI_IMAGE_SEND_SUCCESS`,title:e.message,placement:`bottomRight`,data:l}),A({task_id:e?.data.task.id,entity_id:ee})):(h(!1),V(!1),b.error({id:`AI_IMAGE_SEND_ERROR`,title:e?.message||v(`Something went wrong, please try again`),placement:`bottomRight`,data:l,innerException:e}))}).catch(e=>{h(!1),V(!1),(e?.error||e?.data)&&b.fromError(`AI_IMAGE_SEND_ERROR`,l,e.error||e)}))},[l,m,h,V,p,x,S,w,k,b,A,ee,v]),re=(0,u.useCallback)(async()=>{if(K){if(!W){let e=c.l(`image_generate`,(await O(`image_generate`)).data?.stats);if(e){_?.(e);return}}W&&(N(e=>e+1),G()),ne()}else W&&(g?g():b.error({title:v(`The usage limit has been exceeded`),description:v(`The maximum number of requests for the current subscription period has been reached.
|
|
4
|
+
Select the appropriate plan to fulfil more requests`),placement:`bottomRight`}))},[K,W,O,_,N,G,ne,b,v,g]);(0,u.useEffect)(()=>{W&&N(y?.counters?.ai_img_counter||0)},[y,W]);let ie=(0,u.useCallback)(e=>{if(!r){s(!0);let n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;let r=n[1],i=n[2],a=atob(i),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let c=new Uint8Array(o),l=new Blob([c],{type:`image/${r}`});t({file:new File([l],`image.jpeg`,{type:l.type})})}},[r,s,t]),ae=(0,u.useCallback)(e=>{e.status!==`error`&&e.status!==`Canceled`?e.images?(z(e.status),e.progress===100&&(p(e.images),z(v(`Evaluating the task`)),F(null),V(!1))):(p([e.data]),h(!1)):(h(!1),V(!1),b.error({id:`AI_IMAGE_GET_ERROR`,title:v(`Something went wrong, please try again`),placement:`bottomRight`,data:P}))},[p,z,v,h,e,P,b,V]);return(0,u.useEffect)(()=>{D.length>1&&ae(D[D.length-1])},[D,ae]),(0,u.useEffect)(()=>{(m||d.length>0)&&setTimeout(()=>{let t=550;n.current&&(t=n.current.offsetHeight+68),e(t)},0)},[n,D,d.length,m,e]),{aiImageCounter:M,setAiImageCounter:N,currentAiImgLimits:H,isFieldsDisabled:U,canGenerateImage:K,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,loadingDuringGeneration:B,setLoadingDuringGeneration:V,requestStatus:R,setRequestStatus:z,handleGenerate:re,handleLimitAiImgCount:G,convertBase64ToFile:ie,isShiftPressed:I,setIsShiftPressed:L,currentReqId:P,setCurrentReqId:F,limitsInPlugin:W}}var te=({setModalHeight:e,customRequest:t,aiTabRef:n,inputAiRef:r,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,setAiImageRequest:h,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y})=>{let b=(0,f.useNavigate)(),x=i.Oi(),{__:S,_n:C}=o.h(),w=i.sn(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),{aiImageCounter:k,currentAiImgLimits:A,loadingDuringGeneration:j,requestStatus:M,handleGenerate:N,convertBase64ToFile:P,isShiftPressed:F,setIsShiftPressed:I,limitsInPlugin:L}=ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y,onPluginAiImageLimitExceeded:()=>E(!0),onImageGenerateLimitExceeded:O}),R=T&&A>0?l.p(A):null,z=R?c.u(R.presetId):null,B=D?c.u(D.presetId):null,[te,H]=(0,u.useState)(!1),U=(0,u.useCallback)(()=>H(!0),[]),W=(0,u.useCallback)(()=>H(!1),[]),G=(0,u.useCallback)(e=>h(e.target.value),[h]),K=(0,u.useCallback)(e=>{e.key===`Shift`?I(!0):e.key===`Enter`&&!F&&(e.preventDefault(),N())},[F,N,I]),ne=(0,u.useCallback)(e=>{e.key===`Shift`&&I(!1)},[I]),re=g[g.length-1];return(0,p.jsxs)(`div`,{className:`image-ai`,children:[z&&R?(0,p.jsx)(c.f,{open:!0,onClose:()=>E(!1),title:S(z.titleKey),subtitle:S(z.subtitleKey),usageResource:z.usageResource,previousDisplay:c.d(R.previousLimit),nextDisplay:c.d(R.nextLimit),onChangePlan:()=>{E(!1),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.ba.SWITCH_TO_PLAN_MODAL))}}):null,B&&D?(0,p.jsx)(c.f,{open:!0,onClose:()=>O(null),title:S(B.titleKey),subtitle:S(B.subtitleKey),usageResource:B.usageResource,previousDisplay:c.d(D.previousLimit),nextDisplay:c.d(D.nextLimit),onChangePlan:()=>{O(null),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.ba.SWITCH_TO_PLAN_MODAL))}}):null,L&&(0,p.jsx)(o.P,{text:`${k} ${S(`of`)} ${A>0?A:`∞`} images ${C(`was used`,`were used`,k)}`,exceeded:A>0&&k>=A,style:{marginTop:-25},extra:(0,p.jsx)(`span`,{style:{textDecoration:`underline`,cursor:`pointer`},onClick:()=>b(w.billingPageUrl||i.Hi.billing),children:S(`Need more?`)})}),(0,p.jsx)(o.Ot,{gutter:24,className:`image-ai__row`,children:(0,p.jsx)(o.Dt,{span:24,children:(0,p.jsx)(o.Ft.Item,{style:{margin:0},children:(0,p.jsxs)(`span`,{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg image-ai__input-affix-wrapper${te?` ant-input-affix-wrapper-focused`:``}`,children:[(0,p.jsx)(o.xt,{ref:r,onKeyDown:K,onKeyUp:ne,onFocus:U,onBlur:W,autoSize:!0,allowClear:!0,className:`text-area-input-hybrid image-ai__textarea`,placeholder:S(`Generate image`),value:m,onChange:G,spellCheck:`false`}),(0,p.jsx)(`span`,{className:`ant-input-suffix image-ai__input-suffix`,children:v||j?(0,p.jsx)(c.m,{icon:`LoadingOutlined`,className:`input-icon image-ai__input-icon`,spin:!0}):(0,p.jsx)(c.m,{icon:`AI`,className:`input-icon image-ai__input-icon`,onClick:N})})]})})})}),(v||g.length>0)&&(0,p.jsxs)(`div`,{className:`image-ai__preview`,children:[v&&g.length===0&&(0,p.jsx)(`div`,{className:`image-ai__loading`,children:(0,p.jsxs)(`div`,{className:`spin`,children:[(0,p.jsx)(c.m,{icon:`LoadingOutlined`,style:{fontSize:48},spin:!0}),(0,p.jsx)(`p`,{className:`status`,children:M})]})}),g.length>0&&(0,p.jsxs)(`div`,{className:`image-ai__image-item`,children:[(0,p.jsx)(V,{images:g}),(0,p.jsx)(`div`,{className:`buttons`,children:(0,p.jsx)(o.Rt,{onClick:()=>P(`data:image/jpeg;base64, ${re}`),icon:(0,p.jsx)(c.m,{icon:`CheckOutlined`}),children:S(`Use this one`)})})]})]})]})},H=({setNewLink:e,setCurrentImageLink:t,setModalHeight:n,setModalWidth:r,setImageGifList:s,imageGifList:l,currentReqGif:d,setCurrentReqGif:f,inputRef:m,setStockLink:h,customRequest:g})=>{let{__:_}=o.h(),v=i.sn(),y=c.t(),b=o.o(),[x,S]=(0,u.useState)(null),[C,w]=(0,u.useState)(!1),[T,E]=(0,u.useState)(25),[O]=a.b(),k=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:_(`Failed to load GIFs through the configured proxy chain.`),[_]),A=(0,u.useCallback)(e=>{b.error({id:`STOCK_GIFS_SEARCH_FAILED`,title:_(`Failed to load GIFs`),description:k(e)})},[_,k,b]),j=async()=>{C||(w(!0),O({query:d,page:T}).then(e=>{if(e?.error){A(e.error),w(!1);return}s(t=>[...t,...e.data.data]),w(!1),E(e=>e+25)}).catch(()=>{w(!1)}))},M=async()=>{let e=await O({query:d,page:0});if(e?.error){A(e.error),s([]);return}e?.data?.data?.length>0&&(s(e.data.data),setTimeout(()=>{n(`84vh`),r(1060)},0))},N=(e,n)=>{S(n),setTimeout(()=>{S(null)},2e3),h(`${e}`),t(`${e}`),g(`${e}`)},P={default:3},F=(0,u.useCallback)(e=>i.no(e,{config:v,standalone:y,resourceType:`generic`,intent:`display`}),[v,y]),{getDisplaySrc:L,handleLoad:z,handleError:B}=R({items:l,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>e.images.downsized.url,[]),createController:F}),V=e=>t=>{z(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:M,className:l.length>0?`serach-results`:``,children:[(0,p.jsx)(o.Ot,{gutter:24,children:(0,p.jsx)(o.Dt,{span:l.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:M,allowClear:!0,size:l.length>0?`medium`:`large`,placeholder:_(`Search GIFs`),value:d.keywords,onChange:e=>f(t=>({...t,keywords:e.target.value})),ref:m,spellCheck:`false`,enterButton:!1})})})}),l.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:l.length>0&&(0,p.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,p.jsx)(D,{dataLength:l&&l.length,next:j,hasMore:l,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[_("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:(0,p.jsx)(o.K,{size:`small`}),children:(0,p.jsx)(I,{breakpointCols:P,className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:l.map((e,t)=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>N(e.images.downsized.url,e.id),children:[(0,p.jsx)(`img`,{className:x===e.id?`loaded-image`:``,width:`322px`,src:L(e),alt:e.title,onLoad:V(e),onError:ee(e)}),(0,p.jsx)(`a`,{rel:`noreferrer`,href:`https://giphy.com/`,target:`_blank`,onClick:e=>e.stopPropagation(),children:(0,p.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=)`}})}),x===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id+t))})})})})]})};function U(e){if(!(e==null||e===``))return e}async function W(e,t){if(e){if(e.url)return e.url;if(typeof t.getFileById==`function`&&e.id){let n=await t.getFileById(e.id);if(n?.url)return n.url;if(n?.thumbnailUrl)return n.thumbnailUrl;if(n?.thumbnail)return n.thumbnail}if(typeof t.getFileUrl==`function`&&e.folderId!==void 0&&e.name){let n=await t.getFileUrl(e.folderId||``,e.name);if(n)return n}if(typeof t.getUrl==`function`&&e.name){let n=await t.getUrl(e);if(n)return n}return e.thumbnail||e.thumbnailUrl}}function G(e){if(!(!e?.success||!Array.isArray(e.detailed)))return e.detailed.find(e=>e?.success&&e.data)?.data}function K(e,t,n){if(e)return{id:e.id,name:e.name||t.name,size:e.size??t.size,type:e.type||t.type,folderId:e.folderId??n??``,url:e.url,thumbnail:e.thumbnail,thumbnailUrl:e.thumbnailUrl,date:e.date,dimensions:e.dimensions,aspectRatio:e.aspectRatio,extension:e.extension,selected:e.selected,isFolder:e.isFolder,lastEdited:e.lastEdited,childrenCount:e.childrenCount}}async function ne(e,t,n){if(!t)return;let r=U(n??t.rootId),i;typeof t.uploadFiles==`function`?i=G(await t.uploadFiles({folderId:r,items:[{name:e.name,size:e.size,type:e.type,folderId:r,data:e}]})):typeof t.uploadFile==`function`&&(i=K(await t.uploadFile({name:e.name,size:e.size,type:e.type,folderId:r,data:e}),e,r));let a=await W(i,t);return a?{item:i,url:a}:void 0}var re=`IMG`,ie=`BACKGROUND`,ae=`GALLERY`,oe=`EDITOR`,q=`UPLOAD`,se=`STOCK`,ce=`GIF`,le=`AI`,{Dragger:ue}=o.gt,de=(e,t=`image`)=>{try{let n=new URL(e).pathname.split(`/`).pop();return n&&decodeURIComponent(n)||t}catch{return t}},fe=l.f,pe=(e,t)=>{let n=fe(t);return!n||e.includes(`.`)?e:`${e}.${n}`},me=(e,t)=>new File([e],pe(de(t),e.type),{type:e.type||`application/octet-stream`}),he=({dataProvider:e})=>{let t=i.sn(),n=c.t(),{__:r}=o.h(),s=i.Oi(),{projectId:d}=(0,f.useParams)(),[m]=a.y(),{modal:h}=o.Wt.useApp(),g=o.o(),_=i.Di(i.r),v=i.Di(i.n),b=i.Di(a.s),{request:x,resolveImagePicker:S}=c.r(),[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``),[k,A]=(0,u.useState)(``),[j,M]=(0,u.useState)(q),[N,P]=(0,u.useState)({width:``,height:``,size:``,format:``}),[F,I]=(0,u.useState)(`success`),[L,R]=(0,u.useState)(!1),z=u.default.useRef(null),V=u.default.useRef(null),ee=u.default.useRef(null),U=u.default.useRef(null),W=u.default.useRef(null),G=u.default.useRef(null),K=u.default.useRef(null),de=u.default.useRef(null),pe=u.default.useRef(null),[he,J]=(0,u.useState)(`auto`),[ge,Y]=(0,u.useState)(572),[_e,ve]=(0,u.useState)(!1),[ye,be]=(0,u.useState)({keywords:``,color:``,orientation:``}),[xe,Se]=(0,u.useState)({keywords:``}),[Ce,we]=(0,u.useState)([]),[Te,Ee]=(0,u.useState)([]),[De,Oe]=(0,u.useState)([]),[ke,Ae]=(0,u.useState)(!1),[je,Me]=(0,u.useState)(``),[Ne,Pe]=(0,u.useState)(!1),[Fe,Ie]=(0,u.useState)(0),Le=i.Di(i.ct),Re=Le?.id===void 0?d||``:String(Le.id),ze=i.q(i.Co.UPLOAD_EVENT_ID),Be=u.default.useRef(l.u()),Ve=u.default.useRef(``),He=u.default.useRef(0),X=u.default.useRef(``),[Ue,We]=(0,u.useState)(``),[Ge,Ke]=(0,u.useState)(``),Z=(0,u.useCallback)(()=>{X.current&&=(URL.revokeObjectURL(X.current),``),We(``)},[]),Q=(0,u.useCallback)(()=>{Ke(``)},[]),$=!(_||v.id?.toString()!==Le?.members?.owner.ID),qe=e=>{E(e.target.value)},Je=(0,u.useCallback)((e,t,n=r(`The image could not be uploaded.`))=>{let i=t instanceof Error?t.message:n;g.error({id:`IMAGE_UPLOAD_ERROR`,data:e,title:r(`Upload failed`),description:i})},[r,g]),Ye=(0,u.useCallback)(async e=>c.o(await ze.fire({file:e,project:Re})),[Re,ze]),Xe=l.t(),Ze=async e=>{if(e)try{let t=await $e(e);t&&it(t)?await at({file:t}):t||Je({url:e},null,r(`Failed to download image from URL.`))}catch(t){Je({url:e},t,r(`Failed to process image URL.`))}},Qe=u.default.useRef(Ze);Qe.current=Ze,u.default.useEffect(()=>{if(j!==q||!k)return;let e=T.trim();if(!e||!e.toLowerCase().startsWith(`http`))return;let t=setTimeout(()=>{Qe.current(e)},1e3);return()=>{clearTimeout(t)}},[T,j,k]);let $e=async e=>{try{let t=l.l(e);return me(await Be.current.resolve(t,void 0,Xe),t)}catch{}};document.onpaste=function(e){let n=e.clipboardData?.items?.[0];if(j===q&&k){if(n?.type?.indexOf(`image`)===0&&t.imageCenterLocalUploadEnabled!==!1){let e=n.getAsFile();it(e);let t={file:e};E(``),at(t);return}let r=e.clipboardData?.getData(`text/plain`);if(r&&r.trim().toLowerCase().startsWith(`http`)){e.preventDefault(),e.stopPropagation(),E(r.trim());return}n?.type?.indexOf(`text`)===0&&n.getAsString(e=>{if(e.trim().toLowerCase().startsWith(`http`))E(e.trim());else if(e.toString().slice(1,5)===`meta`){let t=e.toString().split(`"`)[1];t&&E(t)}})}},(0,u.useEffect)(()=>{let e=e=>{let t=null;x?.kind===`background`?(t=ie,A(ie)):x?.kind===`img`&&(A(re),t=re),x?.currentUrl&&t&&(w(x.currentUrl),M(e))};b===i.ba.UPLOAD_IMAGE_MODAL||b===i.ba.UPLOAD_BACKGROUND_MODAL?e(oe):b===i.ba.UPLOAD_IMAGE_MODAL_AI||b===i.ba.UPLOAD_BACKGROUND_MODAL_AI?($?(Pe(!0),Ie(2)):e(le),setTimeout(()=>pe.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_UPLOAD||b===i.ba.UPLOAD_BACKGROUND_MODAL_UPLOAD?(e(q),setTimeout(()=>G.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_STOCK||b===i.ba.UPLOAD_BACKGROUND_MODAL_STOCK?($?(Pe(!0),Ie(3)):e(se),setTimeout(()=>de.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_GIF||b===i.ba.UPLOAD_BACKGROUND_MODAL_GIF?($?(Pe(!0),Ie(3)):e(ce),setTimeout(()=>K.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_EDIT||b===i.ba.UPLOAD_BACKGROUND_MODAL_EDIT?($?(Pe(!0),Ie(5)):e(oe),s(a.i(i.ba.IMAGE_EDITOR_MODAL))):A(``)},[b,s,$,x]);let et=(0,u.useCallback)(({url:e=C||``})=>{w(e),S({url:e,meta:{mode:`select`}}),setTimeout(()=>{Q(),Z(),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),Ee([]),we([]),A(``),Me(``),Ae(!1),O(``),E(``),M(q)},200),s(a.t()),s(a.n())},[C,Q,s,S,Z]),tt=(0,u.useCallback)((e,t)=>(J(`auto`),R(!1),et({url:e}),g.success({id:`IMAGE_UPLOAD_SUCCESS`,data:t,title:r(`The image was successfully uploaded.`)}),e),[r,et,g]);(0,u.useEffect)(()=>{let t=T||D,r=l.l(t);if(!t||!r){I(``),Ve.current=``,Q(),Z(),Be.current.invalidateAll();return}let i=Ve.current;i&&i!==r&&(Be.current.abandonKey(i),Q(),Z()),Ve.current=r;let a=new AbortController,o=T?800:0,s=++He.current,c=setTimeout(async()=>{try{let i=async()=>{let e=await Be.current.resolve(r,a.signal,Xe);if(s!==He.current)return;let{width:t,height:n}=await l.d(e);if(s!==He.current)return;P({width:t,height:n,size:(e.size/1024).toFixed(2),format:fe(e.type)}),Q(),X.current&&URL.revokeObjectURL(X.current);let i=URL.createObjectURL(e);X.current=i,We(i)};if(n)await i();else{let t=await l.n(e,r);if(t?.previewUrl&&s===He.current){Ke(t.previewUrl),Z();try{let{data:e}=await m(r);if(s!==He.current)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await i()}catch{await i()}}else await i()}if(s!==He.current)return;I(`success`),w(t),Y(572),setTimeout(()=>{let e=0;V.current&&(e=V.current.offsetHeight+62),J(e)},0)}catch(e){if(e?.name===`AbortError`||a.signal.aborted||s!==He.current)return;Q(),Z(),I(`error`)}},o);return()=>{clearTimeout(c),a.abort()}},[T,D,n,Q,Xe,m,Z,e]),(0,u.useEffect)(()=>{if(!C||T||D)return;let t=l.l(C),r=new AbortController,i=!1,a=async()=>{let e=await Be.current.resolve(t,r.signal,Xe);if(i)return;let{width:n,height:a}=await l.d(e);if(i)return;Q(),X.current&&URL.revokeObjectURL(X.current);let o=URL.createObjectURL(e);X.current=o,We(o),P({width:n,height:a,size:(e.size/1024).toFixed(2),format:fe(e.type)})};return(async()=>{try{if(!n){let n=await l.n(e,t);if(n?.previewUrl&&!i){Ke(n.previewUrl),Z();try{let{data:e}=await m(t);if(i)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await a();return}catch{await a()}}}await a()}catch{i||Q()}})(),()=>{i=!0,r.abort()}},[n,Q,C,Xe,m,e,T,D]);let nt=()=>{s(a.t()),setTimeout(()=>{Q(),Z(),w(``),E(``),Ee([]),Ee([]),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),J(`auto`),!ke&&Me(``),Y(572),M(q)},200)},rt=e=>{e===ae?h.success({mask:{closable:!0},centered:!0,title:r(`Coming soon`),content:r(`The feature is under development.`),okText:r(`Ok. I'll be waiting`),onOk:()=>{}}):e===oe&&C===``?h.warning({mask:{closable:!0},centered:!0,title:r(``),content:r(`To preview and edit the uploaded image`),okText:r(`Upload Image`),onOk:()=>{M(q)}}):(setTimeout(()=>{let t=0,n=0;e===q&&z.current?(ye.keywords===``&&G.current?.focus({cursor:`start`}),t=300,n=572):e===oe&&V.current?(t=V.current.offsetHeight+62,n=572):e===se&&ee.current?(ye.keywords===``&&de.current?.focus({cursor:`start`}),t=130,n=572,Te.length>0&&(n=1060,t=`84vh`)):e===ce&&U.current?(ye.keywords===``&&K.current?.focus({cursor:`start`}),t=130,n=572,Ce.length>0&&(n=1060,t=`84vh`)):e===le&&W.current&&(je===``&&De.length===0?(pe.current?.focus({cursor:`start`}),t=130):t=W.current.offsetHeight+82,n=572),J(t),Y(n)},0),M(e))};(0,u.useEffect)(()=>{ye.keywords===``&&(G?.current?.focus({cursor:`start`}),Ee([]),setTimeout(()=>{J(`auto`),Y(572)},0))},[ye,Ee,J,Y]);let it=e=>{let t=e.type===`image/jpeg`||e.type===`image/png`||e.type===`image/jpg`||e.type===`image/webp`||e.type===`image/gif`||e.type===`image/svg+xml`;return t||g.error({id:`IMAGE_UPLOAD_WRONG_FORMAT`,data:e,title:`Upload`,description:`You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!`}),t},at=async({file:n})=>{try{ve(!0);let r=await l.i(n,t),i=await Ye(r);if(i)return tt(i,r),i;let a=await ne(r,e);if(a?.url)return tt(a.url,r),a.url;Je(r,null);return}catch(e){Je(n,e);return}finally{ve(!1)}},ot=e=>at({file:e}),st=[{label:r(`Upload`),key:q,children:(0,p.jsxs)(`div`,{ref:z,style:{paddingBottom:24},children:[t.imageCenterLocalUploadEnabled!==!1&&(0,p.jsxs)(ue,{showUploadList:!1,name:`Image`,beforeUpload:it,customRequest:at,style:{marginBottom:10},multiple:!1,accept:`image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml`,children:[(0,p.jsx)(`p`,{className:`ant-upload-drag-icon`,children:(0,p.jsx)(c.m,{icon:`InboxOutlined`})}),(0,p.jsx)(`p`,{className:`ant-upload-text`,children:r(`Click to select, paste from the clipboard, or drag and drop`)}),(0,p.jsx)(`p`,{className:`ant-upload-hint`,children:r(`Accepted formats: PNG, JPG, WEBP, SVG or GIF.`)})]}),(0,p.jsx)(o.Ft,{style:{padding:`0 2px 0 2px`},children:(0,p.jsx)(o.Ft.Item,{validateStatus:F,children:(0,p.jsx)(o.kt,{ref:G,allowClear:!0,size:`large`,placeholder:r(`Paste image URL here`),value:T,onChange:qe,spellCheck:`false`})})})]})}];return t.imageCenterStockEnabled&&!$&&st.push({label:r(`Stock`),key:se,children:(0,p.jsx)(`div`,{ref:ee,style:{paddingBottom:24},children:(0,p.jsx)(B,{currentReq:ye,setCurrentReq:be,imageStockList:Te,setImageStockList:Ee,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:de,customRequest:Ze})})}),t.imageCenterGifEnabled&&!$&&st.push({label:r(`GIF`),key:ce,children:(0,p.jsx)(`div`,{ref:U,style:{paddingBottom:24},children:(0,p.jsx)(H,{currentReqGif:xe,setCurrentReqGif:Se,imageGifList:Ce,setImageGifList:we,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:K,customRequest:Ze})})}),t.elementAIimageEnabled&&!$&&st.push({label:r(`AI`),key:le,children:(0,p.jsx)(`div`,{ref:W,style:{paddingBottom:24},children:(0,p.jsx)(te,{setModalHeight:J,customRequest:at,aiImageRequest:je,setAiImageRequest:Me,imageAiList:De,setImageAiList:Oe,isLoadingAi:ke,setIsLoadingAi:Ae,aiTabRef:W,inputAiRef:pe,isImageUploaded:L,setIsImageUploaded:R})})}),t.imageCenterEditorEnabled&&st.push({label:``,key:oe,children:(0,p.jsx)(`div`,{ref:V,children:(0,p.jsx)(y,{currentImageLink:C,newLink:T,previewDisplayUrl:Ge,resolvedPreviewObjectUrl:Ue,imageSize:N,onSave:ot,uploadImageResultIsLoading:_e||!1})})}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Y,{width:ge,className:`image-center`,title:r(`Image Center`),style:{minHeight:390},open:!!k,onOk:et,onCancel:nt,footer:j===oe?(0,p.jsx)(p.Fragment,{}):null,children:(0,p.jsx)(o.K,{spinning:_e,children:(0,p.jsx)(o.Z,{activeKey:j,onChange:rt,items:st,className:`modal-tabs`,style:{height:he,minHeight:130}})})}),(0,p.jsx)(c.g,{open:Ne,onCancel:()=>Pe(!1),initialSlide:Fe})]})};he.propTypes={dataProvider:d.default.object},t.default=he});
|