UNPKG

@imgly/plugin-ai-video-generation-web

Version:

AI video generation plugin for the CE.SDK editor

128 lines (124 loc) 55.3 kB
var _t=class{constructor(e,t=[],r){this.id=e,this.translateLabel=r?.translateLabel,this.assets=t.map(i=>{if(typeof i.label=="string"&&!(i.label&&typeof i.label=="object")){let n=i;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return i}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(e){let{page:t,perPage:r,locale:i="en",sortActiveFirst:n,query:a,tags:s,groups:f,excludeGroups:c,sortingOrder:u,sortKey:l}=e,o=[...this.assets];if(f&&f.length>0&&(o=o.filter(p=>p.groups&&f.some(y=>p.groups?.includes(y)))),c&&c.length>0&&(o=o.filter(p=>!p.groups||!c.some(y=>p.groups?.includes(y)))),a){let p=a.toLowerCase();o=o.filter(y=>{let b=y.label?.[i]?.toLowerCase(),v=y.tags?.[i]||[];return b&&b.includes(p)||v.some(jt=>jt.toLowerCase().includes(p))})}if(s&&s.length>0){let p=Array.isArray(s)?s:[s];o=o.filter(y=>{let b=y.tags?.[i]||[];return p.some(v=>b.includes(v))})}n&&o.sort((p,y)=>{let b=this.activeAssetIds.has(p.id),v=this.activeAssetIds.has(y.id);return b&&!v?-1:!b&&v?1:0}),l&&l!=="id"?o.sort((p,y)=>{let b=p.meta?.[l],v=y.meta?.[l];return b===void 0?1:v===void 0?-1:typeof b=="string"&&typeof v=="string"?u==="Descending"?v.localeCompare(b):b.localeCompare(v):typeof b=="number"&&typeof v=="number"?u==="Descending"?v-b:b-v:0}):l==="id"&&o.sort((p,y)=>u==="Descending"?y.id.localeCompare(p.id):p.id.localeCompare(y.id));let d=o.length,h=t*r,I=h+r,w=o.slice(h,I).map(p=>{let y=p.label?.[i]||"",b=this.translateLabel?this.translateLabel(p.id,y,i):y;return{id:p.id,groups:p.groups,meta:p.meta,payload:p.payload,locale:i,label:b,tags:p.tags?.[i],active:this.activeAssetIds.has(p.id)}}),ee=I<d?t+1:void 0;return{assets:w,currentPage:t,nextPage:ee,total:d}}updateLabel(e,t,r){this.assets.forEach(i=>{i.id===e&&(i.label=i.label||{},i.label[r]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:r})=>r===e);if(t){let r=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:r,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:r})=>r===e[0]);if(t){let r=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:r,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:r})=>r===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||""}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(r=>r.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(r=>r.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(r=>e.add(r))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var Ot=typeof global=="object"&&global&&global.Object===Object&&global,Qe=Ot,$t=typeof self=="object"&&self&&self.Object===Object&&self,Vt=Qe||$t||Function("return this")(),x=Vt,Dt=x.Symbol,M=Dt,Ye=Object.prototype,Nt=Ye.hasOwnProperty,Rt=Ye.toString,U=M?M.toStringTag:void 0;function zt(e){var t=Nt.call(e,U),r=e[U];try{e[U]=void 0;var i=!0}catch{}var n=Rt.call(e);return i&&(t?e[U]=r:delete e[U]),n}var Ft=zt,Ut=Object.prototype,Bt=Ut.toString;function Kt(e){return Bt.call(e)}var Gt=Kt,qt="[object Null]",Ht="[object Undefined]",Oe=M?M.toStringTag:void 0;function Zt(e){return e==null?e===void 0?Ht:qt:Oe&&Oe in Object(e)?Ft(e):Gt(e)}var q=Zt;function Qt(e){return e!=null&&typeof e=="object"}var ve=Qt,el=Array.isArray;function Yt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var We=Yt,Wt="[object AsyncFunction]",Jt="[object Function]",Xt="[object GeneratorFunction]",er="[object Proxy]";function tr(e){if(!We(e))return!1;var t=q(e);return t==Jt||t==Xt||t==Wt||t==er}var rr=tr,ir=x["__core-js_shared__"],ce=ir,$e=function(){var e=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function nr(e){return!!$e&&$e in e}var or=nr,ar=Function.prototype,sr=ar.toString;function lr(e){if(e!=null){try{return sr.call(e)}catch{}try{return e+""}catch{}}return""}var E=lr,ur=/[\\^$.*+?()[\]{}|]/g,cr=/^\[object .+?Constructor\]$/,dr=Function.prototype,pr=Object.prototype,gr=dr.toString,mr=pr.hasOwnProperty,fr=RegExp("^"+gr.call(mr).replace(ur,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hr(e){if(!We(e)||or(e))return!1;var t=rr(e)?fr:cr;return t.test(E(e))}var yr=hr;function br(e,t){return e?.[t]}var vr=br;function wr(e,t){var r=vr(e,t);return yr(r)?r:void 0}var L=wr,kr=L(x,"WeakMap"),ge=kr;function Ir(e,t){return e===t||e!==e&&t!==t}var xr=Ir,Ar=9007199254740991;function Sr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Ar}var Cr=Sr,tl=Object.prototype,Er="[object Arguments]";function Tr(e){return ve(e)&&q(e)==Er}var Ve=Tr,Je=Object.prototype,Pr=Je.hasOwnProperty,Mr=Je.propertyIsEnumerable,rl=Ve(function(){return arguments}())?Ve:function(e){return ve(e)&&Pr.call(e,"callee")&&!Mr.call(e,"callee")},Xe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,De=Xe&&typeof module=="object"&&module&&!module.nodeType&&module,Lr=De&&De.exports===Xe,Ne=Lr?x.Buffer:void 0,il=Ne?Ne.isBuffer:void 0,jr="[object Arguments]",_r="[object Array]",Or="[object Boolean]",$r="[object Date]",Vr="[object Error]",Dr="[object Function]",Nr="[object Map]",Rr="[object Number]",zr="[object Object]",Fr="[object RegExp]",Ur="[object Set]",Br="[object String]",Kr="[object WeakMap]",Gr="[object ArrayBuffer]",qr="[object DataView]",Hr="[object Float32Array]",Zr="[object Float64Array]",Qr="[object Int8Array]",Yr="[object Int16Array]",Wr="[object Int32Array]",Jr="[object Uint8Array]",Xr="[object Uint8ClampedArray]",ei="[object Uint16Array]",ti="[object Uint32Array]",g={};g[Hr]=g[Zr]=g[Qr]=g[Yr]=g[Wr]=g[Jr]=g[Xr]=g[ei]=g[ti]=!0;g[jr]=g[_r]=g[Gr]=g[Or]=g[qr]=g[$r]=g[Vr]=g[Dr]=g[Nr]=g[Rr]=g[zr]=g[Fr]=g[Ur]=g[Br]=g[Kr]=!1;function ri(e){return ve(e)&&Cr(e.length)&&!!g[q(e)]}var ii=ri;function ni(e){return function(t){return e(t)}}var oi=ni,et=typeof exports=="object"&&exports&&!exports.nodeType&&exports,B=et&&typeof module=="object"&&module&&!module.nodeType&&module,ai=B&&B.exports===et,de=ai&&Qe.process,si=function(){try{var e=B&&B.require&&B.require("util").types;return e||de&&de.binding&&de.binding("util")}catch{}}(),Re=si,ze=Re&&Re.isTypedArray,nl=ze?oi(ze):ii,li=Object.prototype,ol=li.hasOwnProperty;function ui(e,t){return function(r){return e(t(r))}}var ci=ui,al=ci(Object.keys,Object),di=Object.prototype,sl=di.hasOwnProperty,pi=L(Object,"create"),K=pi;function gi(){this.__data__=K?K(null):{},this.size=0}var mi=gi;function fi(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var hi=fi,yi="__lodash_hash_undefined__",bi=Object.prototype,vi=bi.hasOwnProperty;function wi(e){var t=this.__data__;if(K){var r=t[e];return r===yi?void 0:r}return vi.call(t,e)?t[e]:void 0}var ki=wi,Ii=Object.prototype,xi=Ii.hasOwnProperty;function Ai(e){var t=this.__data__;return K?t[e]!==void 0:xi.call(t,e)}var Si=Ai,Ci="__lodash_hash_undefined__";function Ei(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=K&&t===void 0?Ci:t,this}var Ti=Ei;function j(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}j.prototype.clear=mi;j.prototype.delete=hi;j.prototype.get=ki;j.prototype.has=Si;j.prototype.set=Ti;var Fe=j;function Pi(){this.__data__=[],this.size=0}var Mi=Pi;function Li(e,t){for(var r=e.length;r--;)if(xr(e[r][0],t))return r;return-1}var te=Li,ji=Array.prototype,_i=ji.splice;function Oi(e){var t=this.__data__,r=te(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():_i.call(t,r,1),--this.size,!0}var $i=Oi;function Vi(e){var t=this.__data__,r=te(t,e);return r<0?void 0:t[r][1]}var Di=Vi;function Ni(e){return te(this.__data__,e)>-1}var Ri=Ni;function zi(e,t){var r=this.__data__,i=te(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var Fi=zi;function _(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}_.prototype.clear=Mi;_.prototype.delete=$i;_.prototype.get=Di;_.prototype.has=Ri;_.prototype.set=Fi;var re=_,Ui=L(x,"Map"),G=Ui;function Bi(){this.size=0,this.__data__={hash:new Fe,map:new(G||re),string:new Fe}}var Ki=Bi;function Gi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var qi=Gi;function Hi(e,t){var r=e.__data__;return qi(t)?r[typeof t=="string"?"string":"hash"]:r.map}var ie=Hi;function Zi(e){var t=ie(this,e).delete(e);return this.size-=t?1:0,t}var Qi=Zi;function Yi(e){return ie(this,e).get(e)}var Wi=Yi;function Ji(e){return ie(this,e).has(e)}var Xi=Ji;function en(e,t){var r=ie(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var tn=en;function O(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}O.prototype.clear=Ki;O.prototype.delete=Qi;O.prototype.get=Wi;O.prototype.has=Xi;O.prototype.set=tn;var tt=O;function rn(){this.__data__=new re,this.size=0}var nn=rn;function on(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var an=on;function sn(e){return this.__data__.get(e)}var ln=sn;function un(e){return this.__data__.has(e)}var cn=un,dn=200;function pn(e,t){var r=this.__data__;if(r instanceof re){var i=r.__data__;if(!G||i.length<dn-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new tt(i)}return r.set(e,t),this.size=r.size,this}var gn=pn;function H(e){var t=this.__data__=new re(e);this.size=t.size}H.prototype.clear=nn;H.prototype.delete=an;H.prototype.get=ln;H.prototype.has=cn;H.prototype.set=gn;var mn=Object.prototype,ll=mn.propertyIsEnumerable,fn=L(x,"DataView"),me=fn,hn=L(x,"Promise"),fe=hn,yn=L(x,"Set"),he=yn,Ue="[object Map]",bn="[object Object]",Be="[object Promise]",Ke="[object Set]",Ge="[object WeakMap]",qe="[object DataView]",vn=E(me),wn=E(G),kn=E(fe),In=E(he),xn=E(ge),P=q;(me&&P(new me(new ArrayBuffer(1)))!=qe||G&&P(new G)!=Ue||fe&&P(fe.resolve())!=Be||he&&P(new he)!=Ke||ge&&P(new ge)!=Ge)&&(P=function(e){var t=q(e),r=t==bn?e.constructor:void 0,i=r?E(r):"";if(i)switch(i){case vn:return qe;case wn:return Ue;case kn:return Be;case In:return Ke;case xn:return Ge}return t});var ul=x.Uint8Array,An="__lodash_hash_undefined__";function Sn(e){return this.__data__.set(e,An),this}var Cn=Sn;function En(e){return this.__data__.has(e)}var Tn=En;function ye(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new tt;++t<r;)this.add(e[t])}ye.prototype.add=ye.prototype.push=Cn;ye.prototype.has=Tn;var He=M?M.prototype:void 0,cl=He?He.valueOf:void 0,Pn=Object.prototype,dl=Pn.hasOwnProperty,Mn=Object.prototype,pl=Mn.hasOwnProperty,gl=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),ml=new RegExp(/[A-Fa-f0-9]{1}/,"g"),fl=new RegExp(/[A-Fa-f0-9]{2}/,"g");function Ln(e){return e!==void 0}var jn=Ln;function _n(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function On(e){return typeof e?.translate=="function"}function Ze(e,t,r){return e&&_n(e)&&On(e.i18n)?e.i18n.translate(t):r}function C(e,t){if(typeof e.i18n?.getTranslations!="function"){e.i18n.setTranslations(t);return}let r=Object.keys(t),i=e.i18n.getTranslations(r),n={};for(let a of r){let s=t[a];if(!s)continue;let f=i[a]??{},c={};for(let[u,l]of Object.entries(s))!(u in f)&&l!==void 0&&(c[u]=l);Object.keys(c).length>0&&(n[a]=c)}Object.keys(n).length>0&&e.i18n.setTranslations(n)}function $n(e,t){let{cesdk:r}=t,i=t.propertyKey??"image_url",n=be(e);return C(r,{en:{[`panel.${n}`]:"Select Image To Change","ly.img.ai.imageSelection.selectImage.label":"Select Image","ly.img.ai.imageSelection.error.svg":"SVG images are not supported. Please choose a different image.","ly.img.ai.imageSelection.error.invalidType":"Only images are supported. Found '{mimeType}'. Please choose a different image."}}),Vn(e,r),{[i]:(a,s)=>{let{builder:f,experimental:{global:c},payload:u}=a,l,o=a.providerConfig,d=a.config,h=o?.properties?.[s.id]??d?.properties?.[s.id];h?.default&&(typeof h.default=="function"?l=h.default({}):l=h.default);let I=l??u?.url??t.defaultUrl,w=c(`${e}.${s.id}`,I);return f.MediaPreview(s.id,{preview:{type:"image",uri:w.value},action:{label:"ly.img.ai.imageSelection.selectImage.label",onClick:()=>{r?.ui.openPanel(n,{payload:{onSelect:ee=>{ee.meta?.uri!=null&&w.setValue(ee.meta?.uri)}}})}}}),()=>({id:s.id,type:"string",value:w.value})}}}function Vn(e,t){t?.ui.registerPanel(be(e),({builder:r,payload:i})=>{r.Library(`${e}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let a=n?.meta?.uri;if(a==null)return;let s=await t.engine.editor.getMimeType(a);s==="image/svg+xml"?t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.svg"}):s.startsWith("image/")?(i?.onSelect(n),t?.ui.closePanel(be(e))):t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function be(e){return`ly.img.ai.${e}.imageSelection`}var Dn=$n;function Nn(e,t){let{cesdk:r}=t;if(r==null)return{};let i=t.propertyKey??"style",n=zn(e);C(r,{en:{[`panel.${n}`]:"Select Style",[`${e}.${i}`]:"Style","ly.img.ai.styleTransfer.none":"None","ly.img.ai.styleTransfer.anime":"Anime","ly.img.ai.styleTransfer.cyberpunk":"Cyberpunk","ly.img.ai.styleTransfer.kodak400":"Kodak 400","ly.img.ai.styleTransfer.watercolor":"Watercolor","ly.img.ai.styleTransfer.darkFantasy":"Dark Fantasy","ly.img.ai.styleTransfer.vaporwave":"Vaporwave","ly.img.ai.styleTransfer.vectorFlat":"Vector Flat","ly.img.ai.styleTransfer.3dAnimation":"3D Animation","ly.img.ai.styleTransfer.ukiyoe":"Ukiyo\u2011e","ly.img.ai.styleTransfer.surreal":"Surreal","ly.img.ai.styleTransfer.steampunk":"Steampunk","ly.img.ai.styleTransfer.nightBokeh":"Night Bokeh","ly.img.ai.styleTransfer.popArt":"Pop Art"}});let a=Un({baseURL:t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0,cesdk:r}),s=a;t.styles!=null&&(Array.isArray(t.styles)?s=t.styles:typeof t.styles=="function"&&(s=t.styles(a)));let f=Bn({cesdk:r,providerId:e,styles:s}),c=f.id;return Kn(f,{cesdk:r}),Rn({providerId:e,cesdk:r,panelId:n,entryId:c}),{[t.propertyKeyForPrompt??"prompt"]:(u,l)=>{let o=u.state("prompt","");return u.builder.TextArea(`${l.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??"prompt",placeholder:t.i18n?.prompt?.placeholder,...o}),()=>{let[d]=f.getActiveAssetIds(),h=f.getAsset(d);return{id:l.id,type:"string",value:h?.meta?.prompt==null?o.value:`${o.value}; ${h.meta.prompt}`}}},[i]:(u,l)=>{let{builder:o,state:d}=u;if(s.length>0){let h=d("style",s[0]);return o.Button(`${l.id}`,{inputLabel:`${e}.${l.id}`,icon:"@imgly/Appearance",isDisabled:s.length===0,trailingIcon:"@imgly/ChevronRight",label:h.value.label,labelAlignment:"left",onClick:()=>{let I={onSelect:async w=>{f.clearActiveAssets(),f.setAssetActive(w.id),h.setValue({id:w.id,label:w.label??w.id}),r.ui.closePanel(n)}};r.ui.openPanel(n,{payload:I})}}),()=>({id:l.id,type:"string",value:h.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function Rn(e){let{providerId:t,cesdk:r,panelId:i,entryId:n}=e;r?.ui.registerPanel(i,({builder:a,payload:s})=>{s?.onSelect==null&&a.Section(`${t}.error`,{children:()=>{a.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),a.Library(`${t}.library.image`,{entries:[n],onSelect:async f=>{s?.onSelect?.(f)}})})}function zn(e){return`ly.img.ai.${e}.styleSelection`}var Fn=[{id:"none",labelKey:"ly.img.ai.styleTransfer.none",prompt:""},{id:"anime-celshaded",labelKey:"ly.img.ai.styleTransfer.anime",prompt:"anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art "},{id:"cyberpunk-neon",labelKey:"ly.img.ai.styleTransfer.cyberpunk",prompt:"cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere"},{id:"kodak-portra-400",labelKey:"ly.img.ai.styleTransfer.kodak400",prompt:"shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo"},{id:"watercolor-storybook",labelKey:"ly.img.ai.styleTransfer.watercolor",prompt:"loose watercolor washes, gentle gradients, dreamy storybook feel"},{id:"dark-fantasy-realism",labelKey:"ly.img.ai.styleTransfer.darkFantasy",prompt:"dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures"},{id:"vaporwave-retrofuturism",labelKey:"ly.img.ai.styleTransfer.vaporwave",prompt:"retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines"},{id:"minimal-vector-flat",labelKey:"ly.img.ai.styleTransfer.vectorFlat",prompt:"minimalist flat vector illustration, bold geometry, two\u2011tone palette"},{id:"pixarstyle-3d-render",labelKey:"ly.img.ai.styleTransfer.3dAnimation",prompt:"Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting"},{id:"ukiyoe-woodblock",labelKey:"ly.img.ai.styleTransfer.ukiyoe",prompt:"ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink"},{id:"surreal-dreamscape",labelKey:"ly.img.ai.styleTransfer.surreal",prompt:"surreal dreamscape, floating objects, impossible architecture, vivid clouds"},{id:"steampunk-victorian",labelKey:"ly.img.ai.styleTransfer.steampunk",prompt:"Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog"},{id:"nightstreet-photo-bokeh",labelKey:"ly.img.ai.styleTransfer.nightBokeh",prompt:"night\u2011time street shot, large aperture bokeh lights, candid urban mood"},{id:"comicbook-pop-art",labelKey:"ly.img.ai.styleTransfer.popArt",prompt:"classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors"}];function Un(e){return Fn.map(t=>t.id==="none"?e.includeNone?{id:t.id,label:Ze(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}/thumbnails/None.svg`}:void 0:{id:t.id,label:Ze(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}/thumbnails/${t.id}.jpeg`}).filter(jn)}var Bn=e=>{let t=e.styles.map(s=>({...s,meta:{prompt:s.prompt}})),r=e.cesdk.engine.asset.findAllSources(),i=`${e.providerId}/styles`;for(;r.includes(i);)i+=`-${Math.random().toString(36).substring(2,5)}`;let n=new _t(i,t),a=e.styles[0];return n.setAssetActive(a.id),n},Kn=(e,t)=>{t.cesdk.engine.asset.addSource(e),t.cesdk.ui.addAssetLibraryEntry({id:e.id,sourceIds:[e.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:r})=>r,cardLabelPosition:()=>"below"})},Gn=Nn;var qn="ly.img.ai";function A(e){return`${qn}.${e}`}function ne(e,t,r){let i=`${t}.iconSetAdded`;e.ui.experimental.hasGlobalStateValue(i)||(e.ui.addIconSet(t,r),e.ui.experimental.setGlobalStateValue(i,!0))}function rt(e,t){let r={...e};if(!t)return r;for(let[i,n]of Object.entries(t))n===!1||n===null||n===void 0?delete r[i]:n===!0?i in e||(r[i]=!0):r[i]=n;return r}var pe="@imgly/plugin-ai-generation",hl=` <svg> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/Sparkle" > <path d="M5.35545 2.06745C5.24149 1.72556 4.7579 1.72556 4.64394 2.06745L4.05898 3.82232C4.02166 3.93429 3.9338 4.02215 3.82184 4.05948L2.06694 4.64459C1.72506 4.75858 1.72509 5.24217 2.06699 5.3561L3.82179 5.9409C3.93378 5.97822 4.02166 6.06609 4.05899 6.17808L4.64394 7.93291C4.7579 8.2748 5.24149 8.2748 5.35545 7.93291L5.9404 6.17806C5.97773 6.06608 6.06559 5.97821 6.17757 5.94089L7.93242 5.35594C8.27431 5.24198 8.27431 4.75839 7.93242 4.64442L6.17757 4.05947C6.06559 4.02215 5.97773 3.93428 5.9404 3.8223L5.35545 2.06745Z" fill="currentColor"/> <path d="M17.9632 3.23614C17.8026 2.80788 17.1968 2.80788 17.0362 3.23614L16.0787 5.78951C16.0285 5.92337 15.9229 6.02899 15.789 6.07918L13.2356 7.0367C12.8074 7.19729 12.8074 7.80307 13.2356 7.96366L15.789 8.92118C15.9229 8.97138 16.0285 9.077 16.0787 9.21085L17.0362 11.7642C17.1968 12.1925 17.8026 12.1925 17.9632 11.7642L18.9207 9.21086C18.9709 9.077 19.0765 8.97138 19.2104 8.92118L21.7637 7.96366C22.192 7.80307 22.192 7.1973 21.7637 7.0367L19.2104 6.07918C19.0765 6.02899 18.9709 5.92337 18.9207 5.78951L17.9632 3.23614Z" fill="currentColor"/> <path d="M9.30058 7.82012C9.54712 7.1791 10.454 7.1791 10.7006 7.82012L12.3809 12.189C12.4571 12.3871 12.6136 12.5436 12.8117 12.6198L17.1806 14.3001C17.8216 14.5466 17.8216 15.4536 17.1806 15.7001L12.8117 17.3804C12.6136 17.4566 12.4571 17.6131 12.3809 17.8112L10.7006 22.1801C10.454 22.8211 9.54712 22.8211 9.30058 22.1801L7.62024 17.8112C7.54406 17.6131 7.38754 17.4566 7.18947 17.3804L2.82061 15.7001C2.17959 15.4536 2.17959 14.5466 2.82061 14.3001L7.18947 12.6198C7.38754 12.5436 7.54406 12.3871 7.62024 12.189L9.30058 7.82012Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="${pe}/image" > <path d="M3 16.5V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V6C21 4.34315 19.6569 3 18 3L17.999 5C18.5513 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V16.5H3Z" fill="currentColor"/> <path d="M13.0982 0.884877C12.9734 0.568323 12.5254 0.568322 12.4005 0.884876L11.7485 2.53819C11.7104 2.63483 11.6339 2.71134 11.5372 2.74945L9.8839 3.40151C9.56735 3.52636 9.56734 3.97436 9.8839 4.09921L11.5372 4.75126C11.6339 4.78938 11.7104 4.86588 11.7485 4.96253L12.4005 6.61584C12.5254 6.93239 12.9734 6.9324 13.0982 6.61584L13.7503 4.96253C13.7884 4.86588 13.8649 4.78938 13.9616 4.75126L15.6149 4.09921C15.9314 3.97436 15.9314 3.52636 15.6149 3.40151L13.9616 2.74945C13.8649 2.71134 13.7884 2.63483 13.7503 2.53819L13.0982 0.884877Z" fill="currentColor"/> <path d="M6.40053 5.38488C6.52538 5.06832 6.97338 5.06832 7.09823 5.38488L8.17455 8.11392C8.21267 8.21057 8.28917 8.28707 8.38582 8.32519L11.1149 9.40151C11.4314 9.52636 11.4314 9.97436 11.1149 10.0992L8.38582 11.1755C8.28917 11.2136 8.21267 11.2901 8.17455 11.3868L7.09823 14.1158C6.97338 14.4324 6.52538 14.4324 6.40053 14.1158L5.32421 11.3868C5.2861 11.2901 5.20959 11.2136 5.11295 11.1755L2.3839 10.0992C2.06735 9.97436 2.06735 9.52636 2.3839 9.40151L5.11295 8.32519C5.20959 8.28707 5.2861 8.21057 5.32421 8.11392L6.40053 5.38488Z" fill="currentColor"/> <path d="M18.9994 16.5008V18.0004C18.9994 18.5526 18.5517 19.0004 17.9994 19.0004H9.33302L14.3753 11.4369C14.6722 10.9916 15.3266 10.9916 15.6234 11.4369L18.9994 16.5008Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="${pe}/video" > <path d="M6 3C4.34315 3 3 4.34315 3 6V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V16.5H19V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5V3Z" fill="currentColor"/> <path d="M10.9025 0.8839C11.0273 0.567345 11.4753 0.567346 11.6002 0.883901L12.2522 2.53721C12.2904 2.63386 12.3669 2.71036 12.4635 2.74848L14.1168 3.40053C14.4334 3.52538 14.4334 3.97338 14.1168 4.09823L12.4635 4.75029C12.3669 4.7884 12.2904 4.86491 12.2522 4.96155L11.6002 6.61486C11.4753 6.93142 11.0273 6.93142 10.9025 6.61486L10.2504 4.96155C10.2123 4.86491 10.1358 4.7884 10.0392 4.75029L8.38585 4.09823C8.0693 3.97338 8.0693 3.52538 8.38585 3.40053L10.0392 2.74848C10.1358 2.71036 10.2123 2.63386 10.2504 2.53721L10.9025 0.8839Z" fill="currentColor"/> <path d="M18.9019 3.3845C19.0267 3.06795 19.4747 3.06795 19.5996 3.3845L20.6759 6.11355C20.714 6.2102 20.7905 6.2867 20.8872 6.32482L23.6162 7.40114C23.9328 7.52598 23.9328 7.97399 23.6162 8.09883L20.8872 9.17515C20.7905 9.21327 20.714 9.28977 20.6759 9.38642L19.5996 12.1155C19.4747 12.432 19.0267 12.432 18.9019 12.1155L17.8255 9.38642C17.7874 9.28977 17.7109 9.21327 17.6143 9.17515L14.8852 8.09883C14.5687 7.97399 14.5687 7.52598 14.8852 7.40114L17.6143 6.32482C17.7109 6.2867 17.7874 6.2102 17.8255 6.11355L18.9019 3.3845Z" fill="currentColor"/> <path d="M14.9994 13.2862C15.5089 12.8859 15.5089 12.1141 14.9995 11.7137L10.618 8.27047C9.96188 7.75485 9.00011 8.22225 9.00011 9.05673L9.00011 15.9429C9.00011 16.7773 9.96185 17.2448 10.618 16.7292L14.9994 13.2862Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="${pe}/audio" > <path d="M6 3.80273C4.2066 4.84016 3 6.77919 3 9.00004V12.8153C3 15.931 5.39501 18.4873 8.44444 18.7436V20.9645C8.44444 22.2198 9.89427 22.9198 10.8773 22.1392L15.1265 18.7647H15.5C17.8285 18.7647 19.8472 17.4384 20.8417 15.5H18.4187C17.6889 16.2784 16.6512 16.7647 15.5 16.7647H14.9522C14.6134 16.7647 14.2846 16.8794 14.0193 17.0901L10.4444 19.929V18.2597C10.4444 17.4341 9.77513 16.7647 8.9495 16.7647C7.80494 16.7647 6.77409 16.2779 6.05276 15.5H6V15.4419C5.37798 14.7439 5 13.8237 5 12.8153V9.00004C5 7.98559 5.37764 7.05935 6 6.35422V3.80273Z" fill="currentColor"/> <path d="M11.6002 1.8839C11.4753 1.56735 11.0273 1.56735 10.9025 1.8839L10.2504 3.53721C10.2123 3.63386 10.1358 3.71036 10.0392 3.74848L8.38585 4.40053C8.0693 4.52538 8.0693 4.97338 8.38585 5.09823L10.0392 5.75029C10.1358 5.7884 10.2123 5.86491 10.2504 5.96155L10.9025 7.61486C11.0273 7.93142 11.4753 7.93142 11.6002 7.61486L12.2522 5.96155C12.2904 5.86491 12.3669 5.7884 12.4635 5.75029L14.1168 5.09823C14.4334 4.97338 14.4334 4.52538 14.1168 4.40053L12.4635 3.74848C12.3669 3.71036 12.2904 3.63386 12.2522 3.53721L11.6002 1.8839Z" fill="currentColor"/> <path d="M19.5996 4.3845C19.4747 4.06795 19.0267 4.06795 18.9019 4.3845L17.8255 7.11355C17.7874 7.2102 17.7109 7.2867 17.6143 7.32482L14.8852 8.40114C14.5687 8.52598 14.5687 8.97399 14.8852 9.09883L17.6143 10.1752C17.7109 10.2133 17.7874 10.2898 17.8255 10.3864L18.9019 13.1155C19.0267 13.432 19.4747 13.432 19.5996 13.1155L20.6759 10.3864C20.714 10.2898 20.7905 10.2133 20.8872 10.1752L23.6162 9.09883C23.9328 8.97399 23.9328 8.52598 23.6162 8.40114L20.8872 7.32482C20.7905 7.2867 20.714 7.2102 20.6759 7.11355L19.5996 4.3845Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/MixingPlate" > <path d="M9.75 9C10.5784 9 11.25 8.32843 11.25 7.5C11.25 6.67157 10.5784 6 9.75 6C8.92157 6 8.25 6.67157 8.25 7.5C8.25 8.32843 8.92157 9 9.75 9Z" fill="currentColor"/> <path d="M7 13C7.82843 13 8.5 12.3284 8.5 11.5C8.5 10.6716 7.82843 10 7 10C6.17157 10 5.5 10.6716 5.5 11.5C5.5 12.3284 6.17157 13 7 13Z" fill="currentColor"/> <path d="M15.75 7.5C15.75 8.32843 15.0784 9 14.25 9C13.4216 9 12.75 8.32843 12.75 7.5C12.75 6.67157 13.4216 6 14.25 6C15.0784 6 15.75 6.67157 15.75 7.5Z" fill="currentColor"/> <path d="M17 13C17.8284 13 18.5 12.3284 18.5 11.5C18.5 10.6716 17.8284 10 17 10C16.1716 10 15.5 10.6716 15.5 11.5C15.5 12.3284 16.1716 13 17 13Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.26309 2.77709C10.6681 1.77921 13.4829 1.7322 15.9209 2.64297C18.1572 3.47923 20.0876 5.09285 21.1766 7.28598C22.3395 9.62772 22.4889 13.1077 20.3864 15.2982C19.2693 16.4621 17.7657 16.9982 16.0026 16.9997C15.7897 16.9997 15.5555 16.9864 15.3497 16.9745C15.309 16.9722 15.2694 16.9699 15.2313 16.9679C14.9817 16.9542 14.761 16.9455 14.5569 16.9539C14.124 16.9718 13.9598 17.0612 13.89 17.1324C13.718 17.3081 13.6946 17.6672 13.8854 17.8895C14.2899 18.3608 14.5016 18.9277 14.5016 19.5497C14.5016 20.2206 14.3086 20.9011 13.7542 21.3896C13.2471 21.837 12.6082 21.9997 11.9635 21.9997C10.6049 21.9997 9.31155 21.7367 8.0934 21.2067C6.89058 20.6831 5.84501 19.9687 4.94363 19.0666C4.04281 18.1651 3.31836 17.107 2.79369 15.8978C1.72761 13.4409 1.72662 10.5261 2.81247 8.07034C3.88024 5.65548 5.84206 3.78161 8.26309 2.77709ZM15.2207 4.51639C13.2556 3.78239 10.9651 3.82132 9.02956 4.62439C7.06888 5.43791 5.49559 6.94785 4.64163 8.87914C3.78373 10.8194 3.78253 13.1522 4.62841 15.1017C5.05312 16.0805 5.63511 16.9291 6.35838 17.6529C7.08102 18.3761 7.91671 18.9484 8.89123 19.3728C9.8492 19.7895 10.87 19.9997 11.9635 19.9997C12.2815 19.9997 12.394 19.9225 12.431 19.8899L12.4319 19.8891C12.4367 19.8849 12.4487 19.8743 12.4631 19.8359C12.4799 19.7911 12.5016 19.7024 12.5016 19.5497C12.5016 19.4091 12.4633 19.3034 12.3677 19.192C11.5353 18.222 11.5272 16.6868 12.4611 15.7331C13.0741 15.1071 13.8844 14.98 14.4745 14.9556C14.7819 14.943 15.085 14.9568 15.3409 14.9709C15.3906 14.9736 15.4379 14.9763 15.4832 14.9788C15.6876 14.9904 15.8508 14.9997 16.0009 14.9997C17.3405 14.9986 18.2792 14.6054 18.9435 13.9133C20.2633 12.5382 20.3186 10.055 19.3853 8.1755C18.5436 6.48051 17.0293 5.19281 15.2207 4.51639Z" fill="currentColor"/> </symbol> </svg> `;var it={ImageUrl:Dn,StyleTransfer:Gn};var Hn=` <svg> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/plugin/formats/ratioFree" > <path d="M7 6C6.44772 6 6 6.44772 6 7V9.22222H4V7C4 5.34315 5.34315 4 7 4H9.22222V6H7Z" fill="currentColor"/> <path d="M17 6H14.7778V4H17C18.6569 4 20 5.34315 20 7V9.22222H18V7C18 6.44772 17.5523 6 17 6Z" fill="currentColor"/> <path d="M6 14.7778V17C6 17.5523 6.44772 18 7 18H9.22222V20H7C5.34315 20 4 18.6569 4 17V14.7778H6Z" fill="currentColor"/> <path d="M18 17V14.7778H20V17C20 18.6569 18.6569 20 17 20H14.7778V18H17C17.5523 18 18 17.5523 18 17Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/plugin/formats/ratio4by3" > <path d="M6.5 13H8V15H10V16.5H6.5V13Z" fill="currentColor"/> <path d="M14 9V7.5H17.5V11H16V9H14Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M6 4C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6ZM5 7C5 6.44772 5.44772 6 6 6H18C18.5523 6 19 6.44772 19 7V17C19 17.5523 18.5523 18 18 18H6C5.44772 18 5 17.5523 5 17V7Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/plugin/formats/ratio16by9" > <path d="M4.5 13H6V15H8V16.5H4.5V13Z" fill="currentColor"/> <path d="M16 9V7.5H19.5V11H18V9H16Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M4 4C2.34315 4 1 5.34315 1 7V17C1 18.6569 2.34315 20 4 20H20C21.6569 20 23 18.6569 23 17V7C23 5.34315 21.6569 4 20 4H4ZM3 7C3 6.44772 3.44772 6 4 6H20C20.5523 6 21 6.44772 21 7V17C21 17.5523 20.5523 18 20 18H4C3.44772 18 3 17.5523 3 17V7Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/plugin/formats/ratio9by16" > <path d="M7.5 16H9V18H11V19.5H7.5V16Z" fill="currentColor"/> <path d="M13 6V4.5H16.5V8H15V6H13Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M4 20C4 21.6569 5.34315 23 7 23H17C18.6569 23 20 21.6569 20 20V4C20 2.34315 18.6569 1 17 1H7C5.34315 1 4 2.34315 4 4V20ZM7 21C6.44772 21 6 20.5523 6 20V4C6 3.44772 6.44772 3 7 3H17C17.5523 3 18 3.44772 18 4V20C18 20.5523 17.5523 21 17 21H7Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/plugin/formats/ratio3by4" > <path d="M11 17.5V16H9V14H7.5V17.5H11Z" fill="currentColor"/> <path d="M15 10H16.5V6.5H13V8H15V10Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M20 18C20 19.6569 18.6569 21 17 21H7C5.34315 21 4 19.6569 4 18V6C4 4.34315 5.34315 3 7 3H17C18.6569 3 20 4.34315 20 6V18ZM17 19C17.5523 19 18 18.5523 18 18V6C18 5.44772 17.5523 5 17 5H7C6.44771 5 6 5.44771 6 6V18C6 18.5523 6.44772 19 7 19H17Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/plugin/formats/ratio1by1" > <path d="M17.4142 8.00009L16 6.58587L14.2929 8.29298L15.7071 9.70719L17.4142 8.00009Z" fill="currentColor"/> <path d="M13.0404 12.3739L15.0404 10.3739L13.6262 8.95965L11.6262 10.9596L13.0404 12.3739Z" fill="currentColor"/> <path d="M10.3737 15.0405L12.3737 13.0405L10.9595 11.6263L8.95953 13.6263L10.3737 15.0405Z" fill="currentColor"/> <path d="M9.70708 15.7072L8.29286 14.293L6.58576 16.0001L7.99997 17.4143L9.70708 15.7072Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z" fill="currentColor"/> </symbol> </svg> `;var Zn=typeof global=="object"&&global&&global.Object===Object&&global,bt=Zn,Qn=typeof self=="object"&&self&&self.Object===Object&&self,Yn=bt||Qn||Function("return this")(),S=Yn,Wn=S.Symbol,V=Wn,vt=Object.prototype,Jn=vt.hasOwnProperty,Xn=vt.toString,Z=V?V.toStringTag:void 0;function eo(e){var t=Jn.call(e,Z),r=e[Z];try{e[Z]=void 0;var i=!0}catch{}var n=Xn.call(e);return i&&(t?e[Z]=r:delete e[Z]),n}var to=eo,ro=Object.prototype,io=ro.toString;function no(e){return io.call(e)}var oo=no,ao="[object Null]",so="[object Undefined]",nt=V?V.toStringTag:void 0;function lo(e){return e==null?e===void 0?so:ao:nt&&nt in Object(e)?to(e):oo(e)}var J=lo;function uo(e){return e!=null&&typeof e=="object"}var Ee=uo,vl=Array.isArray;function co(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var wt=co,po="[object AsyncFunction]",go="[object Function]",mo="[object GeneratorFunction]",fo="[object Proxy]";function ho(e){if(!wt(e))return!1;var t=J(e);return t==go||t==mo||t==po||t==fo}var yo=ho,bo=S["__core-js_shared__"],we=bo,ot=function(){var e=/[^.]+$/.exec(we&&we.keys&&we.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function vo(e){return!!ot&&ot in e}var wo=vo,ko=Function.prototype,Io=ko.toString;function xo(e){if(e!=null){try{return Io.call(e)}catch{}try{return e+""}catch{}}return""}var T=xo,Ao=/[\\^$.*+?()[\]{}|]/g,So=/^\[object .+?Constructor\]$/,Co=Function.prototype,Eo=Object.prototype,To=Co.toString,Po=Eo.hasOwnProperty,Mo=RegExp("^"+To.call(Po).replace(Ao,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Lo(e){if(!wt(e)||wo(e))return!1;var t=yo(e)?Mo:So;return t.test(T(e))}var jo=Lo;function _o(e,t){return e?.[t]}var Oo=_o;function $o(e,t){var r=Oo(e,t);return jo(r)?r:void 0}var D=$o,Vo=D(S,"WeakMap"),Ie=Vo;function Do(e,t){return e===t||e!==e&&t!==t}var No=Do,Ro=9007199254740991;function zo(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Ro}var Fo=zo;var wl=Object.prototype;var Uo="[object Arguments]";function Bo(e){return Ee(e)&&J(e)==Uo}var at=Bo,kt=Object.prototype,Ko=kt.hasOwnProperty,Go=kt.propertyIsEnumerable,kl=at(function(){return arguments}())?at:function(e){return Ee(e)&&Ko.call(e,"callee")&&!Go.call(e,"callee")};var It=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=It&&typeof module=="object"&&module&&!module.nodeType&&module,qo=st&&st.exports===It,lt=qo?S.Buffer:void 0,Il=lt?lt.isBuffer:void 0;var Ho="[object Arguments]",Zo="[object Array]",Qo="[object Boolean]",Yo="[object Date]",Wo="[object Error]",Jo="[object Function]",Xo="[object Map]",ea="[object Number]",ta="[object Object]",ra="[object RegExp]",ia="[object Set]",na="[object String]",oa="[object WeakMap]",aa="[object ArrayBuffer]",sa="[object DataView]",la="[object Float32Array]",ua="[object Float64Array]",ca="[object Int8Array]",da="[object Int16Array]",pa="[object Int32Array]",ga="[object Uint8Array]",ma="[object Uint8ClampedArray]",fa="[object Uint16Array]",ha="[object Uint32Array]",m={};m[la]=m[ua]=m[ca]=m[da]=m[pa]=m[ga]=m[ma]=m[fa]=m[ha]=!0;m[Ho]=m[Zo]=m[aa]=m[Qo]=m[sa]=m[Yo]=m[Wo]=m[Jo]=m[Xo]=m[ea]=m[ta]=m[ra]=m[ia]=m[na]=m[oa]=!1;function ya(e){return Ee(e)&&Fo(e.length)&&!!m[J(e)]}var ba=ya;function va(e){return function(t){return e(t)}}var wa=va,xt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Q=xt&&typeof module=="object"&&module&&!module.nodeType&&module,ka=Q&&Q.exports===xt,ke=ka&&bt.process,Ia=function(){try{var e=Q&&Q.require&&Q.require("util").types;return e||ke&&ke.binding&&ke.binding("util")}catch{}}(),ut=Ia,ct=ut&&ut.isTypedArray,xl=ct?wa(ct):ba;var xa=Object.prototype,Al=xa.hasOwnProperty;function Aa(e,t){return function(r){return e(t(r))}}var Sa=Aa,Sl=Sa(Object.keys,Object);var Ca=Object.prototype,Cl=Ca.hasOwnProperty;var Ea=D(Object,"create"),Y=Ea;function Ta(){this.__data__=Y?Y(null):{},this.size=0}var Pa=Ta;function Ma(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var La=Ma,ja="__lodash_hash_undefined__",_a=Object.prototype,Oa=_a.hasOwnProperty;function $a(e){var t=this.__data__;if(Y){var r=t[e];return r===ja?void 0:r}return Oa.call(t,e)?t[e]:void 0}var Va=$a,Da=Object.prototype,Na=Da.hasOwnProperty;function Ra(e){var t=this.__data__;return Y?t[e]!==void 0:Na.call(t,e)}var za=Ra,Fa="__lodash_hash_undefined__";function Ua(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Y&&t===void 0?Fa:t,this}var Ba=Ua;function N(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}N.prototype.clear=Pa;N.prototype.delete=La;N.prototype.get=Va;N.prototype.has=za;N.prototype.set=Ba;var dt=N;function Ka(){this.__data__=[],this.size=0}var Ga=Ka;function qa(e,t){for(var r=e.length;r--;)if(No(e[r][0],t))return r;return-1}var oe=qa,Ha=Array.prototype,Za=Ha.splice;function Qa(e){var t=this.__data__,r=oe(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Za.call(t,r,1),--this.size,!0}var Ya=Qa;function Wa(e){var t=this.__data__,r=oe(t,e);return r<0?void 0:t[r][1]}var Ja=Wa;function Xa(e){return oe(this.__data__,e)>-1}var es=Xa;function ts(e,t){var r=this.__data__,i=oe(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var rs=ts;function R(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}R.prototype.clear=Ga;R.prototype.delete=Ya;R.prototype.get=Ja;R.prototype.has=es;R.prototype.set=rs;var ae=R,is=D(S,"Map"),W=is;function ns(){this.size=0,this.__data__={hash:new dt,map:new(W||ae),string:new dt}}var os=ns;function as(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ss=as;function ls(e,t){var r=e.__data__;return ss(t)?r[typeof t=="string"?"string":"hash"]:r.map}var se=ls;function us(e){var t=se(this,e).delete(e);return this.size-=t?1:0,t}var cs=us;function ds(e){return se(this,e).get(e)}var ps=ds;function gs(e){return se(this,e).has(e)}var ms=gs;function fs(e,t){var r=se(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var hs=fs;function z(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}z.prototype.clear=os;z.prototype.delete=cs;z.prototype.get=ps;z.prototype.has=ms;z.prototype.set=hs;var At=z;function ys(){this.__data__=new ae,this.size=0}var bs=ys;function vs(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var ws=vs;function ks(e){return this.__data__.get(e)}var Is=ks;function xs(e){return this.__data__.has(e)}var As=xs,Ss=200;function Cs(e,t){var r=this.__data__;if(r instanceof ae){var i=r.__data__;if(!W||i.length<Ss-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new At(i)}return r.set(e,t),this.size=r.size,this}var Es=Cs;function X(e){var t=this.__data__=new ae(e);this.size=t.size}X.prototype.clear=bs;X.prototype.delete=ws;X.prototype.get=Is;X.prototype.has=As;X.prototype.set=Es;var Ts=Object.prototype,El=Ts.propertyIsEnumerable;var Ps=D(S,"DataView"),xe=Ps,Ms=D(S,"Promise"),Ae=Ms,Ls=D(S,"Set"),Se=Ls,pt="[object Map]",js="[object Object]",gt="[object Promise]",mt="[object Set]",ft="[object WeakMap]",ht="[object DataView]",_s=T(xe),Os=T(W),$s=T(Ae),Vs=T(Se),Ds=T(Ie),$=J;(xe&&$(new xe(new ArrayBuffer(1)))!=ht||W&&$(new W)!=pt||Ae&&$(Ae.resolve())!=gt||Se&&$(new Se)!=mt||Ie&&$(new Ie)!=ft)&&($=function(e){var t=J(e),r=t==js?e.constructor:void 0,i=r?T(r):"";if(i)switch(i){case _s:return ht;case Os:return pt;case $s:return gt;case Vs:return mt;case Ds:return ft}return t});var Tl=S.Uint8Array;var Ns="__lodash_hash_undefined__";function Rs(e){return this.__data__.set(e,Ns),this}var zs=Rs;function Fs(e){return this.__data__.has(e)}var Us=Fs;function Ce(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new At;++t<r;)this.add(e[t])}Ce.prototype.add=Ce.prototype.push=zs;Ce.prototype.has=Us;var yt=V?V.prototype:void 0,Pl=yt?yt.valueOf:void 0;var Bs=Object.prototype,Ml=Bs.hasOwnProperty;var Ks=Object.prototype,Ll=Ks.hasOwnProperty;var jl=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),_l=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Ol=new RegExp(/[A-Fa-f0-9]{2}/,"g");function Te(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}async function Gs(e,t){if(e.startsWith("buffer:")){let r=await t.editor.getMimeType(e),i=t.editor.getBufferLength(e),n=t.editor.getBufferData(e,0,i),a=new Uint8Array(n),s=new Blob([a],{type:r});return URL.createObjectURL(s)}else return e}async function F(e,t){let r=await Gs(e,t);return new Promise((i,n)=>{let a=new Image;a.onload=()=>{i({width:a.width,height:a.height})},a.onerror=n,a.src=r})}var le={Formats:Hn};var St={openapi:"3.0.0",info:{title:"EachLabs Kling v2.6 Pro Text to Video API",version:"1.0.0",description:"Kling v2.6 Pro text-to-video generation via EachLabs"},components:{schemas:{KlingV26ProTextToVideoInput:{title:"KlingV26ProTextToVideoInput",type:"object",properties:{prompt:{title:"Prompt",type:"string",description:"User's video generation instruction",minLength:1,"x-imgly-builder":{component:"TextArea"}},duration:{title:"Duration",type:"string",enum:["5","10"],default:"10",description:"The duration of the generated video in seconds","x-imgly-enum-labels":{"5":"5 seconds","10":"10 seconds"}},aspect_ratio:{title:"Aspect Ratio",type:"string",enum:["16:9","9:16","1:1"],default:"16:9",description:"The aspect ratio of the generated video frame","x-imgly-enum-labels":{"16:9":"Landscape (16:9)","9:16":"Portrait (9:16)","1:1":"Square (1:1)"},"x-imgly-enum-icons":{"16:9":"@imgly/plugin/formats/ratio16by9","9:16":"@imgly/plugin/formats/ratio9by16","1:1":"@imgly/plugin/formats/ratio1by1"}}},"x-fal-order-properties":["prompt","duration","aspect_ratio"],required:["prompt"]}}},paths:{}};function Ct(e,t){let r={"Content-Type":"application/json",...t};async function i(c,u){let l=await fetch(`${e}/v1/prediction`,{method:"POST",headers:r,body:JSON.stringify({model:c.model,version:c.version,input:c.input}),signal:u});if(!l.ok){let d=await l.text().catch(()=>"Unknown error");throw new Error(`EachLabs API error: ${l.status} - ${d}`)}let o=await l.json();if(!o.predictionID)throw new Error("EachLabs API did not return a prediction ID");return o.predictionID}async function n(c,u){let l=await fetch(`${e}/v1/prediction/${c}`,{method:"GET",headers:r,signal:u});if(!l.ok){let o=await l.text().catch(()=>"Unknown error");throw new Error(`EachLabs API error: ${l.status} - ${o}`)}return l.json()}async function a(c,u){let l=0;for(;l<200;){if(u?.aborted)throw new Error("Request aborted");let o=await n(c,u);if(o.status==="success")return o;if(o.status==="failed")throw new Error(o.error??"Prediction failed");if(o.status==="cancelled")throw new Error("Prediction was cancelled");if(o.status==="error"){let d=o.error??(typeof o.output=="string"?o.output:null)??"Prediction error";throw new Error(d)}await new Promise(d=>{setTimeout(d,3e3)}),l++}throw new Error("Prediction timed out")}function s(c){if(!c)return[];if(typeof c=="string")return c.startsWith("http")?[c]:[];if(Array.isArray(c))return c.filter(o=>typeof o=="string"&&o.startsWith("http"));let u=c;if(typeof u.video=="string"&&u.video.startsWith("http"))return[u.video];if(Array.isArray(u.videos)&&u.videos.length>0)return u.videos.filter(o=>typeof o=="string"&&o.startsWith("http"));let l=["url","video_url","result","output"];for(let o of l){let d=u[o];if(typeof d=="string"&&d.startsWith("http"))return[d];if(Array.isArray(d)){let h=d.filter(I=>typeof I=="string"&&I.startsWith("http"));if(h.length>0)return h}}return[]}async function f(c){let u=new FormData;u.append("file",c);let l=`${e}/api/v1/upload`,o=await fetch(l,{method:"POST",headers:{...Object.fromEntries(Object.entries(r).filter(([h])=>h.toLowerCase()!=="content-type"))},body:u});if(!o.ok){let h=await o.text().catch(()=>"Unknown error");throw new Error(`EachLabs storage upload error: ${o.status} - ${h}`)}let d=await o.json();if(!d.url)throw new Error("EachLabs storage did not return a URL");return d.url}return{storage:{upload:f},videoInference:async(c,u)=>{let l=await i(c,u),o=await a(l,u),d=s(o.output);if(d.length===0)throw console.error("EachLabs response:",o),new Error("No videos found in EachLabs response");return d.map(h=>({videoURL:h}))}}}async function Et(e,t,r){if(t!=null){if(t.startsWith("blob:")){let i=r!=null?await r.engine.editor.getMimeType(t):"image/png",a=await(await fetch(t)).blob(),s=new File([a],`image.${Te(i)}`,{type:i});return e.storage.upload(s)}if(r!=null&&t.startsWith("buffer:")){let i=await r.engine.editor.getMimeType(t),n=r.engine.editor.getBufferLength(t),a=r.engine.editor.getBufferData(t,0,n),s=new Uint8Array(a),f=new File([s],`image.${Te(i)}`,{type:i});return e.storage.upload(f)}return t}}function Hs(e,t){let r=e.middleware??t.middlewares??[],i=null,n={id:e.providerId,kind:"video",name:e.name,configuration:t,initialize:async a=>{i=Ct(t.proxyUrl,e.headers),e.initialize?.(a)},input:{quickActions:{supported:rt(e.supportedQuickActions??{},t.supportedQuickActions)},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?it.ImageUrl(e.providerId,{cesdk:e.cesdk}):{},...e.renderCustomProperty},getBlockInput:e.getBlockInput,userFlow:e.useFlow??"placeholder"}},output:{abortable:!0,middleware:r,history:t.history??"@imgly/indexedDB",generate:async(a,{abortSignal:s})=>{if(!i)throw new Error("Provider not initialized");let f=a;if(a.image_url!=null){let l=await Et(i,a.image_url,e.cesdk);f={...a,image_url:l}}let c=e.mapInput(f),u=await i.videoInference({model:e.modelSlug,version:e.modelVersion,input:c},s);if(u!=null&&Array.isArray(u)&&u.length>0){let o=u[0]?.videoURL;if(o!=null)return{kind:"video",url:o}}throw console.error("Cannot extract generated video from response:",u),new Error("Cannot find generated video")},generationHintText:"ly.img.ai.video.generation.hint"}};return t.debug&&console.log("Created EachLabs Video Provider:",n),n}var k=Hs;var Zs={"16:9":{width:1280,height:720},"9:16":{width:720,height:1280},"1:1":{width:1024,height:1024},"4:3":{width:1024,height:768},"3:4":{width:768,height:1024},"21:9":{width:1344,height:576},"9:21":{width:576,height:1344}};function ue(e){return Zs[e]??{width:1280,height:720}}function Pe(e){return async({cesdk:t})=>(ne(t,"@imgly/plugin/formats",le.Formats),k({modelSlug:"kling-v2-6-pro-text-to-video",modelVersion:"0.0.1",providerId:"eachlabs/kling-v2-6-pro-text-to-video",name:"Kling v2.6 Pro",schema:St,inputReference:"#/components/schemas/KlingV26ProTextToVideoInput",cesdk:t,getBlockInput:r=>{let i=r.aspect_ratio??"16:9",{width:n,height:a}=ue(i),s=r.duration!=null?parseInt(r.duration,10):10;return Promise.resolve({video:{width:n,height:a,duration:s}})},mapInput:r=>({prompt:r.prompt,duration:r.duration??"10",aspect_ratio:r.aspect_ratio??"16:9",generate_audio:!0,negative_prompt:"blur, distort, and low quality",cfg_scale:.5})},e))}var Tt={openapi:"3.0.0",info:{title:"EachLabs Kling v2.6 Pro Image to Video API",version:"1.0.0",description:"Kling v2.6 Pro image-to-video generation via EachLabs"},components:{schemas:{KlingV26ProImageToVideoInput:{title:"KlingV26ProImageToVideoInput",type:"object",properties:{image_url:{title:"Input Image",type:"string",format:"uri",description:"URL of the image to be used for the video","x-imgly-builder":{component:"ImageUrl"}},prompt:{title:"Prompt",type:"string",description:"Motion/action description for video generation","x-imgly-builder":{component:"TextArea"}},duration:{title:"Duration",type:"string",enum:["5","10"],default:"5",description:"The duration of the generated video in seconds","x-imgly-enum-labels":{"5":"5 seconds","10":"10 seconds"}}},"x-fal-order-properties":["image_url","prompt","duration"],required:["image_url","prompt"]}}},paths:{}};function Me(e){return async({cesdk:t})=>{let r="eachlabs/kling-v2-6-pro-image-to-video";return C(t,{en:{[`panel.${A(r)}.imageSelection`]:"Select Image To Animate",[`libraries.${A(r)}.history.label`]:"Generated From Image"}}),k({modelSlug:"kling-v2-6-pro-image-to-video",modelVersion:"0.0.1",providerId:r,name:"Kling v2.6 Pro",schema:Tt,inputReference:"#/components/schemas/KlingV26ProImageToVideoInput",cesdk:t,supportedQuickActions:{"ly.img.createVideo":{mapInput:i=>({image_url:i.uri,prompt:""})}},getBlockInput:async i=>{let{width:n,height:a}=await F(i.image_url,t.engine),s=i.duration!=null?parseInt(i.duration,10):5;return{video:{width:n,height:a,duration:s}}},mapInput:i=>({image_url:i.image_url,prompt:i.prompt,duration:i.duration??"5",generate_audio:!0,negative_prompt:"blur, distort, and low quality"})},e)}}var Pt={openapi:"3.0.0",info:{title:"EachLabs Kling O1 Image to Video API",version:"1.0.0",description:"Kling O1 image-to-video generation via EachLabs"},components:{schemas:{KlingO1ImageToVideoInput:{title:"KlingO1ImageToVideoInput",type:"object",properties:{image_url:{title:"Input Image",type:"string",format:"uri",description:"URL of the image to be used as the start frame","x-imgly-builder":{component:"ImageUrl"}},prompt:{title:"Prompt",type:"string",description:"Motion/action description for video generation","x-imgly-builder":{component:"TextArea"}},duration:{title:"Duration",type:"string",enum:["5","10"],default:"5",de