@imgly/plugin-ai-audio-generation-web 1.81.0 → 1.81.1-rc.0

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/dist/index.mjs CHANGED
@@ -63,7 +63,7 @@ Consider updating all AI plugins to the same version for optimal compatibility.`
63
63
  </symbol>
64
64
  </svg>
65
65
  `,fo=go;function mo(e){return async(t,r,i)=>e.enable?(console.log(`[DRY RUN]: Requesting dummy AI generation for kind '${e.kind}' with inputs: `,JSON.stringify(t,void 0,2)),await Gt(2e3),await yo(t,e,r)):i(t,r)}async function yo(e,t,r){switch(t.kind){case"image":return ho(e,t,r);case"video":return bo(e,t,r);case"text":return vo(e,t,r);case"audio":return ko(e,t,r);default:throw new Error(`Unsupported output kind for creating dry run output: ${t.kind}`)}}async function ho(e,t,{engine:r}){let i,n,o=e!=null&&typeof e=="object"&&"prompt"in e&&typeof e.prompt=="string"?e.prompt:"AI Generated Image",a=o.match(/(\d+)x(\d+)/);if(a!=null)i=parseInt(a[1],10),n=parseInt(a[2],10);else if(t.blockInputs!=null&&(i=t.blockInputs.image.width,n=t.blockInputs.image.height),t.blockIds!=null&&Array.isArray(t.blockIds)&&t.blockIds.length>0){let[l]=t.blockIds,c=await ga(l,r),s=await pa(c,r);i=s.width,n=s.height}else i=512,n=512;return{kind:"image",url:`https://placehold.co/${i}x${n}/000000/FFF?text=${o.replace(" ","+").replace(`
66
- `,"+")}`}}async function bo(e,t,r){return Promise.resolve({kind:"video",url:"https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4"})}async function vo(e,t,r){let i="";if(t.blockIds&&t.blockIds.length>0){let[a]=t.blockIds;r.engine.block.isValid(a)&&(i=r.engine.block.getString(a,"text/text"))}if(!i&&e!=null&&typeof e=="object"&&"prompt"in e&&typeof e.prompt=="string"){let a=e.prompt,l=a.match(/text:\s*"([^"]+)"/i)||a.match(/content:\s*"([^"]+)"/i)||a.match(/"([^"]+)"/);l&&l[1]&&(i=l[1])}let n=i.length||50,o="";if(e!=null&&typeof e=="object")if("language"in e&&typeof e.language=="string")o=ee(n,"translation");else if("type"in e&&typeof e.type=="string"){let a=e.type;o=ee(n,a)}else"customPrompt"in e?o=ee(n,"custom"):o=ee(n,"improved");else o=ee(n,"generated");return wo(o,r.abortSignal)}async function*wo(e,t){let r=Math.max(1,Math.ceil(e.length/20)),i=0;for(;i<e.length;){if(t?.aborted)return;let n=Math.min(i+r,e.length);yield{kind:"text",text:e.substring(0,n)},i=n,i<e.length&&await Gt(100)}return{kind:"text",text:e}}function ee(e,t){let r="[DRY RUN - Dummy Text] ",i=r.length;if(e<=i)return r.substring(0,e);let n=e-i,o={translation:"Ceci est un texte fictif traduit qui maintient la longueur approximative.",professional:"Enhanced professional content with improved clarity and structure.",casual:"Relaxed, friendly text that keeps things simple and approachable.",formal:"Refined formal documentation that preserves original structure.",humorous:"Amusing content that brings lighthearted fun to the text.",improved:"Enhanced text that demonstrates better clarity and readability.",custom:"Customized content reflecting the requested modifications.",generated:"AI-generated content maintaining original length and structure."},a=o[t]||o.generated,l="";if(n<=a.length)l=a.substring(0,n);else{l=a;let c=[" Additional content continues with similar phrasing."," Further elaboration maintains the established tone."," Extended content preserves the original style."," Continued text follows the same pattern."],s=0;for(;l.length<n;){let u=c[s%c.length];if(l.length+u.length<=n)l+=u;else{l+=u.substring(0,n-l.length);break}s++}}return r+l}async function ko(e,t,r){let i=3;if(e!=null&&typeof e=="object"){if("duration"in e&&typeof e.duration=="number")i=e.duration;else if("prompt"in e&&typeof e.prompt=="string"){let n=e.prompt.match(/(\d+)\s*(?:seconds?|secs?|s)\b/i);n&&(i=parseInt(n[1],10))}}return t.blockInputs?.audio?.duration&&(i=t.blockInputs.audio.duration),{kind:"audio",url:Io(220,i),duration:i,thumbnailUrl:void 0}}function Io(e,t){let r=Math.floor(44100*t),i=new Float32Array(r);for(let n=0;n<r;n++)i[n]=Math.sin(2*Math.PI*e*n/44100);return So(i,44100)}function So(e,t){let r=e.length,i=2,n=1,o=n*i,a=t*o,l=r*i,c=44+l,s=new ArrayBuffer(c),u=new DataView(s),d=(f,y)=>{for(let h=0;h<y.length;h++)u.setUint8(f+h,y.charCodeAt(h))};d(0,"RIFF"),u.setUint32(4,c-8,!0),d(8,"WAVE"),d(12,"fmt "),u.setUint32(16,16,!0),u.setUint16(20,1,!0),u.setUint16(22,n,!0),u.setUint32(24,t,!0),u.setUint32(28,a,!0),u.setUint16(32,o,!0),u.setUint16(34,16,!0),d(36,"data"),u.setUint32(40,l,!0);let g=44;for(let f=0;f<r;f++){let y=Math.max(-1,Math.min(1,e[f])),h=Math.round(y*32767);u.setInt16(g,h,!0),g+=2}let p=new Uint8Array(s),m="";for(let f=0;f<p.length;f++)m+=String.fromCharCode(p[f]);return`data:audio/wav;base64,${btoa(m)}`}async function Gt(e){return new Promise(t=>{setTimeout(t,e)})}var Ao=mo,xo="USER_CANCEL";function Co(e){return async(t,r)=>{if(r?.abortSignal?.aborted)return{status:"aborted"};let i=ha([...e.provider.output.middleware??[],...r?.middlewares??[],va({enable:r?.debug}),Ao({enable:r?.dryRun,kind:e.provider.kind})]),n={prevented:!1},o={blockIds:r?.blockIds,abortSignal:r?.abortSignal,engine:e.engine,cesdk:e.cesdk,preventDefault:()=>{n.prevented=!0},defaultPrevented:()=>n.prevented};try{let{result:a}=await i(e.provider.output.generate)(t,o);return r?.abortSignal?.aborted?{status:"aborted",middlewareOptions:o}:a instanceof Error?{status:"error",message:a.message,error:a,middlewareOptions:o}:a==null?{status:"error",message:"No output generated",middlewareOptions:o}:Sa(a)?{status:"success",type:"async",output:a,middlewareOptions:o}:{status:"success",type:"sync",output:a,middlewareOptions:o}}catch(a){return Ue(a)?{status:"aborted",message:a.message,middlewareOptions:o}:a===xo?{status:"aborted",message:a,middlewareOptions:o}:{status:"error",message:a instanceof Error?a.message:String(a),error:a,middlewareOptions:o}}}}var Eo=Co;async function Mo(e,t,r,i){let n={...i,provider:t},o={provider:t,panelInput:t.input?.panel,options:{cesdk:r.cesdk,engine:r.cesdk.engine},config:n,providerConfig:t.configuration};if(await t.initialize?.({...r,engine:r.cesdk.engine}),t.input?.quickActions?.supported){let d=t.kind,g=Fe.get();Object.keys(t.input.quickActions.supported).forEach(p=>{if(!g.getBy({id:p,type:"quick"})[0]){let m=`ly.img.plugin-ai-${d}-generation-web.quickAction.${p}`;r.cesdk.feature.enable(m,!0)}})}let a=uo(o),l=po(o,a);o.options.historyAssetSourceId=a,o.options.historyAssetLibraryEntryId=l;let c=Eo({provider:t,cesdk:r.cesdk,engine:r.cesdk.engine}),s=await so(o,c);Aa(r.cesdk,"@imgly/plugin-ai-generation",fo);let u={provider:t,panel:{builderRenderFunction:s},history:{assetSourceId:a,assetLibraryEntryId:l},generate:c};return ya.get().register(u),u}var $e=Mo;function jo(e){let{kind:t,cesdk:r,historAssetSourceIds:i}=e,n=`ly.img.ai.${t}-generation.history`;if(r.engine.asset.findAllSources().includes(n))return n;let o=new fr(n,r,i);return r.engine.asset.addSource(o),o.id}var _o=jo;function re(e,t){return[`ly.img.plugin-ai-${e}-generation-web.${t}`,`ly.img.plugin-ai-generation-web.${t}`,`ly.img.plugin-ai-generation-web.defaults.${t}`]}async function $o(e,t,r,i){let{cesdk:n}=r;ke(n,{en:{"ly.img.plugin-ai-generation-web.generate":"Generate","ly.img.plugin-ai-generation-web.defaults.fromType.label":"Input","ly.img.plugin-ai-generation-web.defaults.providerSelect.label":"Provider","ly.img.plugin-ai-generation-web.defaults.fromText.label":"Text","ly.img.plugin-ai-generation-web.defaults.fromImage.label":"Image","ly.img.plugin-ai-generation-web.schema.loading.label":"Loading\u2026","ly.img.plugin-ai-generation-web.schema.error.title":"Failed to load schema","ly.img.plugin-ai-generation-web.schema.error.retry":"Retry","common.ai-generation.failed":"We couldn't generate the asset. Please try again.","ly.img.ai.error.insufficientCredits":"You've run out of AI credits. Generation is unavailable until more credits are available.","ly.img.ai.error.unauthorized":"AI generation isn't authorized. Please sign in again or contact support.","ly.img.ai.error.notAvailable":"This AI model isn't available on your current plan.","ly.img.ai.error.invalidRequest":"This request couldn't be processed. Please adjust your input and try again.","ly.img.ai.error.serviceUnavailable":"The AI service is temporarily unavailable. Please try again shortly.","ly.img.ai.error.network":"We couldn't reach the AI service. Please check your connection and try again."}});let o,a=[];if(i.debug&&console.groupCollapsed(`Initializing ${e} generation providers`),Array.isArray(t)){let s=await Promise.all(t.map(u=>$e(e,u,r,i)));a.push(...s),o=To({kind:e,prefix:e,providerInitializationResults:a,cesdk:n})}else{let s=await Promise.all(t.fromText.map(d=>$e(e,d,r,i)));a.push(...s);let u=await Promise.all(t.fromImage.map(d=>$e(e,d,r,i)));a.push(...u),o=Lo({kind:e,prefix:`ly.img.ai.${e}-generation`,initializedFromTextProviders:s,initializedFromImageProviders:u,cesdk:n})}i.debug&&console.groupEnd();let l=_o({kind:e,cesdk:r.cesdk,historAssetSourceIds:a.map(s=>s.history?.assetSourceId).filter(ma)}),c;return l!=null&&(c=l,r.cesdk.ui.addAssetLibraryEntry({id:c,sourceIds:[l],sortBy:{sortKey:"insertedAt",sortingOrder:"Descending"},canRemove:!0,gridItemHeight:"square",gridBackgroundType:"cover"})),{panel:{builderRenderFunction:o},history:{assetSourceId:l,assetLibraryEntryId:c},providerInitializationResults:a}}function Lo({kind:e,prefix:t,initializedFromTextProviders:r,initializedFromImageProviders:i,cesdk:n}){let o=r.length>0&&i.length>0;return a=>{let{builder:l,experimental:c,engine:s}=a,u=`ly.img.plugin-ai-${e}-generation-web.fromText`,d=n.feature.isEnabled(u,{engine:s}),g=`ly.img.plugin-ai-${e}-generation-web.fromImage`,p=n.feature.isEnabled(g,{engine:s}),m;d&&r.length>0&&(!p||i.length===0)?m="fromText":p&&i.length>0&&(!d||r.length===0)?m="fromImage":d&&p&&o&&(m="fromText");let f=c.global(`${t}.fromType`,m),y=[];f.value==="fromText"?y.push(...r):f.value==="fromImage"?y.push(...i):y.push(...r,...i);let h=r.map(({provider:A,panel:C})=>({id:A.id,label:De(A),builderRenderFunction:C?.builderRenderFunction})),I=i.map(({provider:A,panel:C})=>({id:A.id,label:De(A),builderRenderFunction:C?.builderRenderFunction})),S=a.experimental.global(`${t}.selectedProvider.fromText`,h[0]?.id),x=a.experimental.global(`${t}.selectedProvider.fromImage`,I[0]?.id),v=h.find(A=>A.id===S.value)??h[0],E=I.find(A=>A.id===x.value)??I[0],ye=f.value==="fromText"?S:f.value==="fromImage"?x:void 0,O=f.value==="fromText"?v:f.value==="fromImage"?E:void 0,he=`ly.img.plugin-ai-${e}-generation-web.providerSelect`,xe=n.feature.isEnabled(he,{engine:s});if(!d&&!p){l.Section(`${t}.noInputWarning.section`,{children:()=>{l.Text(`${t}.noInputWarning.text`,{content:"No input types are enabled. Please enable at least one input type (text or image) via the Feature API."})}});return}let L=d&&p&&r.length>0&&i.length>0,b=o&&L,j=y.length>1&&xe;if((b||j)&&l.Section(`${t}.providerSelection.section`,{children:()=>{if(b&&l.ButtonGroup(`${t}.fromType.buttonGroup`,{inputLabel:re(e,"fromType.label"),children:()=>{d&&r.length>0&&l.Button(`${t}.fromType.buttonGroup.fromText`,{label:re(e,"fromText.label"),icon:f.value!=="fromText"&&It(r,a)?"@imgly/LoadingSpinner":void 0,isActive:f.value==="fromText",onClick:()=>{f.setValue("fromText")}}),p&&i.length>0&&l.Button(`${t}.fromType.buttonGroup.fromImage`,{label:re(e,"fromImage.label"),icon:f.value!=="fromImage"&&It(i,a)?"@imgly/LoadingSpinner":void 0,isActive:f.value==="fromImage",onClick:()=>{f.setValue("fromImage")}})}}),j){let A=f.value==="fromText"?h:f.value==="fromImage"?I:[...h,...I];ye!=null&&O!=null&&l.Select(`${t}.providerSelect.select`,{inputLabel:re(e,"providerSelect.label"),values:A,value:O,setValue:C=>{ye.setValue(C.id)}})}}}),y.length>1)O?.builderRenderFunction?.(a);else{let A=y[0];A&&A.panel?.builderRenderFunction?.(a)}}}function To({kind:e,prefix:t,providerInitializationResults:r,cesdk:i}){return n=>{let{builder:o,engine:a}=n;if(r.length===0)return;let l=`ly.img.plugin-ai-${e}-generation-web.providerSelect`;e==="audio"&&t&&(t.includes("speech")?l="ly.img.plugin-ai-audio-generation-web.speech.providerSelect":t.includes("sound")&&(l="ly.img.plugin-ai-audio-generation-web.sound.providerSelect"));let c=i.feature.isEnabled(l,{engine:a}),s=r.map(({provider:g,panel:p})=>({id:g.id,label:De(g),builderRenderFunction:p?.builderRenderFunction})),u=n.state(`${t}.selectedProvider`,s[0]?.id),d=s.find(g=>g.id===u.value)??s[0];r.length>1&&c&&u!=null&&d!=null&&o.Section(`${t}.providerSelection.section`,{children:()=>{o.Select(`${t}.providerSelect.select`,{inputLabel:re(e,"providerSelect.label"),values:s,value:d,setValue:g=>{u.setValue(g.id)}})}}),d?.builderRenderFunction?.(n)}}function It(e,t){return e.length===0?!1:e.some(({provider:r})=>r.id==null?!1:t.experimental.global(Ge(r.id),!1).value)}var qe=$o;var Ju=5*60*1e3;var Po=typeof global=="object"&&global&&global.Object===Object&&global,ar=Po,Oo=typeof self=="object"&&self&&self.Object===Object&&self,No=ar||Oo||Function("return this")(),$=No,Do=$.Symbol,K=Do,or=Object.prototype,zo=or.hasOwnProperty,Ro=or.toString,ce=K?K.toStringTag:void 0;function Fo(e){var t=zo.call(e,ce),r=e[ce];try{e[ce]=void 0;var i=!0}catch{}var n=Ro.call(e);return i&&(t?e[ce]=r:delete e[ce]),n}var Uo=Fo,Vo=Object.prototype,Bo=Vo.toString;function Go(e){return Bo.call(e)}var qo=Go,Ho="[object Null]",Zo="[object Undefined]",qt=K?K.toStringTag:void 0;function Ko(e){return e==null?e===void 0?Zo:Ho:qt&&qt in Object(e)?Uo(e):qo(e)}var fe=Ko;function Yo(e){return e!=null&&typeof e=="object"}var Xe=Yo,rc=Array.isArray;function Qo(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var sr=Qo,Wo="[object AsyncFunction]",Jo="[object Function]",Xo="[object GeneratorFunction]",es="[object Proxy]";function ts(e){if(!sr(e))return!1;var t=fe(e);return t==Jo||t==Xo||t==Wo||t==es}var rs=ts,is=$["__core-js_shared__"],He=is,Ht=function(){var e=/[^.]+$/.exec(He&&He.keys&&He.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ns(e){return!!Ht&&Ht in e}var as=ns,os=Function.prototype,ss=os.toString;function ls(e){if(e!=null){try{return ss.call(e)}catch{}try{return e+""}catch{}}return""}var D=ls,us=/[\\^$.*+?()[\]{}|]/g,cs=/^\[object .+?Constructor\]$/,ds=Function.prototype,ps=Object.prototype,gs=ds.toString,fs=ps.hasOwnProperty,ms=RegExp("^"+gs.call(fs).replace(us,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ys(e){if(!sr(e)||as(e))return!1;var t=rs(e)?ms:cs;return t.test(D(e))}var hs=ys;function bs(e,t){return e?.[t]}var vs=bs;function ws(e,t){var r=vs(e,t);return hs(r)?r:void 0}var Y=ws,ks=Y($,"WeakMap"),Ke=ks;function Is(e,t){return e===t||e!==e&&t!==t}var Ss=Is,As=9007199254740991;function xs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=As}var Cs=xs;var ic=Object.prototype;var Es="[object Arguments]";function Ms(e){return Xe(e)&&fe(e)==Es}var Zt=Ms,lr=Object.prototype,js=lr.hasOwnProperty,_s=lr.propertyIsEnumerable,nc=Zt(function(){return arguments}())?Zt:function(e){return Xe(e)&&js.call(e,"callee")&&!_s.call(e,"callee")};var ur=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Kt=ur&&typeof module=="object"&&module&&!module.nodeType&&module,$s=Kt&&Kt.exports===ur,Yt=$s?$.Buffer:void 0,ac=Yt?Yt.isBuffer:void 0;var Ls="[object Arguments]",Ts="[object Array]",Ps="[object Boolean]",Os="[object Date]",Ns="[object Error]",Ds="[object Function]",zs="[object Map]",Rs="[object Number]",Fs="[object Object]",Us="[object RegExp]",Vs="[object Set]",Bs="[object String]",Gs="[object WeakMap]",qs="[object ArrayBuffer]",Hs="[object DataView]",Zs="[object Float32Array]",Ks="[object Float64Array]",Ys="[object Int8Array]",Qs="[object Int16Array]",Ws="[object Int32Array]",Js="[object Uint8Array]",Xs="[object Uint8ClampedArray]",el="[object Uint16Array]",tl="[object Uint32Array]",k={};k[Zs]=k[Ks]=k[Ys]=k[Qs]=k[Ws]=k[Js]=k[Xs]=k[el]=k[tl]=!0;k[Ls]=k[Ts]=k[qs]=k[Ps]=k[Hs]=k[Os]=k[Ns]=k[Ds]=k[zs]=k[Rs]=k[Fs]=k[Us]=k[Vs]=k[Bs]=k[Gs]=!1;function rl(e){return Xe(e)&&Cs(e.length)&&!!k[fe(e)]}var il=rl;function nl(e){return function(t){return e(t)}}var al=nl,cr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,de=cr&&typeof module=="object"&&module&&!module.nodeType&&module,ol=de&&de.exports===cr,Ze=ol&&ar.process,sl=function(){try{var e=de&&de.require&&de.require("util").types;return e||Ze&&Ze.binding&&Ze.binding("util")}catch{}}(),Qt=sl,Wt=Qt&&Qt.isTypedArray,oc=Wt?al(Wt):il;var ll=Object.prototype,sc=ll.hasOwnProperty;function ul(e,t){return function(r){return e(t(r))}}var cl=ul,lc=cl(Object.keys,Object);var dl=Object.prototype,uc=dl.hasOwnProperty;var pl=Y(Object,"create"),pe=pl;function gl(){this.__data__=pe?pe(null):{},this.size=0}var fl=gl;function ml(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var yl=ml,hl="__lodash_hash_undefined__",bl=Object.prototype,vl=bl.hasOwnProperty;function wl(e){var t=this.__data__;if(pe){var r=t[e];return r===hl?void 0:r}return vl.call(t,e)?t[e]:void 0}var kl=wl,Il=Object.prototype,Sl=Il.hasOwnProperty;function Al(e){var t=this.__data__;return pe?t[e]!==void 0:Sl.call(t,e)}var xl=Al,Cl="__lodash_hash_undefined__";function El(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=pe&&t===void 0?Cl:t,this}var Ml=El;function Q(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])}}Q.prototype.clear=fl;Q.prototype.delete=yl;Q.prototype.get=kl;Q.prototype.has=xl;Q.prototype.set=Ml;var Jt=Q;function jl(){this.__data__=[],this.size=0}var _l=jl;function $l(e,t){for(var r=e.length;r--;)if(Ss(e[r][0],t))return r;return-1}var Ie=$l,Ll=Array.prototype,Tl=Ll.splice;function Pl(e){var t=this.__data__,r=Ie(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Tl.call(t,r,1),--this.size,!0}var Ol=Pl;function Nl(e){var t=this.__data__,r=Ie(t,e);return r<0?void 0:t[r][1]}var Dl=Nl;function zl(e){return Ie(this.__data__,e)>-1}var Rl=zl;function Fl(e,t){var r=this.__data__,i=Ie(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var Ul=Fl;function W(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])}}W.prototype.clear=_l;W.prototype.delete=Ol;W.prototype.get=Dl;W.prototype.has=Rl;W.prototype.set=Ul;var Se=W,Vl=Y($,"Map"),ge=Vl;function Bl(){this.size=0,this.__data__={hash:new Jt,map:new(ge||Se),string:new Jt}}var Gl=Bl;function ql(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Hl=ql;function Zl(e,t){var r=e.__data__;return Hl(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Ae=Zl;function Kl(e){var t=Ae(this,e).delete(e);return this.size-=t?1:0,t}var Yl=Kl;function Ql(e){return Ae(this,e).get(e)}var Wl=Ql;function Jl(e){return Ae(this,e).has(e)}var Xl=Jl;function eu(e,t){var r=Ae(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var tu=eu;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=Gl;J.prototype.delete=Yl;J.prototype.get=Wl;J.prototype.has=Xl;J.prototype.set=tu;var dr=J;function ru(){this.__data__=new Se,this.size=0}var iu=ru;function nu(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var au=nu;function ou(e){return this.__data__.get(e)}var su=ou;function lu(e){return this.__data__.has(e)}var uu=lu,cu=200;function du(e,t){var r=this.__data__;if(r instanceof Se){var i=r.__data__;if(!ge||i.length<cu-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new dr(i)}return r.set(e,t),this.size=r.size,this}var pu=du;function me(e){var t=this.__data__=new Se(e);this.size=t.size}me.prototype.clear=iu;me.prototype.delete=au;me.prototype.get=su;me.prototype.has=uu;me.prototype.set=pu;var gu=Object.prototype,cc=gu.propertyIsEnumerable;var fu=Y($,"DataView"),Ye=fu,mu=Y($,"Promise"),Qe=mu,yu=Y($,"Set"),We=yu,Xt="[object Map]",hu="[object Object]",er="[object Promise]",tr="[object Set]",rr="[object WeakMap]",ir="[object DataView]",bu=D(Ye),vu=D(ge),wu=D(Qe),ku=D(We),Iu=D(Ke),Z=fe;(Ye&&Z(new Ye(new ArrayBuffer(1)))!=ir||ge&&Z(new ge)!=Xt||Qe&&Z(Qe.resolve())!=er||We&&Z(new We)!=tr||Ke&&Z(new Ke)!=rr)&&(Z=function(e){var t=fe(e),r=t==hu?e.constructor:void 0,i=r?D(r):"";if(i)switch(i){case bu:return ir;case vu:return Xt;case wu:return er;case ku:return tr;case Iu:return rr}return t});var dc=$.Uint8Array;var Su="__lodash_hash_undefined__";function Au(e){return this.__data__.set(e,Su),this}var xu=Au;function Cu(e){return this.__data__.has(e)}var Eu=Cu;function Je(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new dr;++t<r;)this.add(e[t])}Je.prototype.add=Je.prototype.push=xu;Je.prototype.has=Eu;var nr=K?K.prototype:void 0,pc=nr?nr.valueOf:void 0;var Mu=Object.prototype,gc=Mu.hasOwnProperty;var ju=Object.prototype,fc=ju.hasOwnProperty;var mc=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),yc=new RegExp(/[A-Fa-f0-9]{1}/,"g"),hc=new RegExp(/[A-Fa-f0-9]{2}/,"g");function _u(e){return e==null?[]:Array.isArray(e)?e:[e]}var et=_u;function $u(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function Lu(e){return typeof e?.translate=="function"}function tt(e,t,r){return e&&$u(e)&&Lu(e.i18n)?e.i18n.translate(t):r}var M="@imgly/plugin-ai-audio-generation-web";var z="ly.img.ai.audio-generation.speech",R="ly.img.ai.audio-generation.sound";function Tu(e){return{async initialize({cesdk:t}){if(t==null)return;Pt(t,M,"1.81.0"),t.feature.enable("ly.img.plugin-ai-audio-generation-web.speech.providerSelect",!0),t.feature.enable("ly.img.plugin-ai-audio-generation-web.sound.providerSelect",!0);let r=`${M}.sound.action.label`,i=`${M}.speech.action.label`;ke(t,{en:{[`panel.${z}`]:"AI Voice",[`panel.${R}`]:"Sound Generation",[r]:"Generate Sound",[i]:"AI Voice"}}),Pu(e);let n=Fe.get(),o=n.register({type:"plugin",sceneMode:"Video",id:`${M}/sound`,pluginId:M,label:tt(t,r,"Generate Sound"),labelKey:r,meta:{panelId:R},execute:()=>{t.ui.isPanelOpen(R)?t.ui.closePanel(R):t.ui.openPanel(R)}}),a=n.register({type:"plugin",sceneMode:"Video",id:`${M}/speech`,pluginId:M,label:tt(t,i,"AI Voice"),labelKey:i,meta:{panelId:z},execute:()=>{t.ui.isPanelOpen(z)?t.ui.closePanel(z):t.ui.openPanel(z)}}),l=e.providers?.text2speech??e.text2speech,c=e.providers?.text2sound??e.text2sound,s=await Promise.all(et(l).map(f=>f({cesdk:t}))),u=await Promise.all(et(c).map(f=>f({cesdk:t}))),d=s.length>0,g=u.length>0;if(!d&&!g){o(),a();return}g||o(),d||a();let p=await qe("audio",s,{cesdk:t},e),m=await qe("audio",u,{cesdk:t},e);m.panel.builderRenderFunction!=null?(t.ui.registerPanel(R,m.panel.builderRenderFunction),Ve({cesdk:t,panelId:R})):o(),p.panel.builderRenderFunction!=null?(t.ui.registerPanel(z,p.panel.builderRenderFunction),Ve({cesdk:t,panelId:z})):a()}}}function Pu(e){e.debug&&(e.providers?.text2speech!=null&&e.text2speech!=null&&console.warn("[AudioGeneration]: Both `providers.text2speech` and `text2speech` configuration is provided. Since `text2speech` is deprecated, only `providers.text2speech` will be used."),e.providers?.text2sound!=null&&e.text2sound!=null&&console.warn("[AudioGeneration]: Both `providers.text2sound` and `text2sound` configuration is provided. Since `text2sound` is deprecated, only `providers.text2sound` will be used."))}var pr=Tu;var Ou=e=>({name:M,version:"1.81.0",...pr(e)}),Ec=Ou;export{Ec as default};
66
+ `,"+")}`}}async function bo(e,t,r){return Promise.resolve({kind:"video",url:"https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4"})}async function vo(e,t,r){let i="";if(t.blockIds&&t.blockIds.length>0){let[a]=t.blockIds;r.engine.block.isValid(a)&&(i=r.engine.block.getString(a,"text/text"))}if(!i&&e!=null&&typeof e=="object"&&"prompt"in e&&typeof e.prompt=="string"){let a=e.prompt,l=a.match(/text:\s*"([^"]+)"/i)||a.match(/content:\s*"([^"]+)"/i)||a.match(/"([^"]+)"/);l&&l[1]&&(i=l[1])}let n=i.length||50,o="";if(e!=null&&typeof e=="object")if("language"in e&&typeof e.language=="string")o=ee(n,"translation");else if("type"in e&&typeof e.type=="string"){let a=e.type;o=ee(n,a)}else"customPrompt"in e?o=ee(n,"custom"):o=ee(n,"improved");else o=ee(n,"generated");return wo(o,r.abortSignal)}async function*wo(e,t){let r=Math.max(1,Math.ceil(e.length/20)),i=0;for(;i<e.length;){if(t?.aborted)return;let n=Math.min(i+r,e.length);yield{kind:"text",text:e.substring(0,n)},i=n,i<e.length&&await Gt(100)}return{kind:"text",text:e}}function ee(e,t){let r="[DRY RUN - Dummy Text] ",i=r.length;if(e<=i)return r.substring(0,e);let n=e-i,o={translation:"Ceci est un texte fictif traduit qui maintient la longueur approximative.",professional:"Enhanced professional content with improved clarity and structure.",casual:"Relaxed, friendly text that keeps things simple and approachable.",formal:"Refined formal documentation that preserves original structure.",humorous:"Amusing content that brings lighthearted fun to the text.",improved:"Enhanced text that demonstrates better clarity and readability.",custom:"Customized content reflecting the requested modifications.",generated:"AI-generated content maintaining original length and structure."},a=o[t]||o.generated,l="";if(n<=a.length)l=a.substring(0,n);else{l=a;let c=[" Additional content continues with similar phrasing."," Further elaboration maintains the established tone."," Extended content preserves the original style."," Continued text follows the same pattern."],s=0;for(;l.length<n;){let u=c[s%c.length];if(l.length+u.length<=n)l+=u;else{l+=u.substring(0,n-l.length);break}s++}}return r+l}async function ko(e,t,r){let i=3;if(e!=null&&typeof e=="object"){if("duration"in e&&typeof e.duration=="number")i=e.duration;else if("prompt"in e&&typeof e.prompt=="string"){let n=e.prompt.match(/(\d+)\s*(?:seconds?|secs?|s)\b/i);n&&(i=parseInt(n[1],10))}}return t.blockInputs?.audio?.duration&&(i=t.blockInputs.audio.duration),{kind:"audio",url:Io(220,i),duration:i,thumbnailUrl:void 0}}function Io(e,t){let r=Math.floor(44100*t),i=new Float32Array(r);for(let n=0;n<r;n++)i[n]=Math.sin(2*Math.PI*e*n/44100);return So(i,44100)}function So(e,t){let r=e.length,i=2,n=1,o=n*i,a=t*o,l=r*i,c=44+l,s=new ArrayBuffer(c),u=new DataView(s),d=(f,y)=>{for(let h=0;h<y.length;h++)u.setUint8(f+h,y.charCodeAt(h))};d(0,"RIFF"),u.setUint32(4,c-8,!0),d(8,"WAVE"),d(12,"fmt "),u.setUint32(16,16,!0),u.setUint16(20,1,!0),u.setUint16(22,n,!0),u.setUint32(24,t,!0),u.setUint32(28,a,!0),u.setUint16(32,o,!0),u.setUint16(34,16,!0),d(36,"data"),u.setUint32(40,l,!0);let g=44;for(let f=0;f<r;f++){let y=Math.max(-1,Math.min(1,e[f])),h=Math.round(y*32767);u.setInt16(g,h,!0),g+=2}let p=new Uint8Array(s),m="";for(let f=0;f<p.length;f++)m+=String.fromCharCode(p[f]);return`data:audio/wav;base64,${btoa(m)}`}async function Gt(e){return new Promise(t=>{setTimeout(t,e)})}var Ao=mo,xo="USER_CANCEL";function Co(e){return async(t,r)=>{if(r?.abortSignal?.aborted)return{status:"aborted"};let i=ha([...e.provider.output.middleware??[],...r?.middlewares??[],va({enable:r?.debug}),Ao({enable:r?.dryRun,kind:e.provider.kind})]),n={prevented:!1},o={blockIds:r?.blockIds,abortSignal:r?.abortSignal,engine:e.engine,cesdk:e.cesdk,preventDefault:()=>{n.prevented=!0},defaultPrevented:()=>n.prevented};try{let{result:a}=await i(e.provider.output.generate)(t,o);return r?.abortSignal?.aborted?{status:"aborted",middlewareOptions:o}:a instanceof Error?{status:"error",message:a.message,error:a,middlewareOptions:o}:a==null?{status:"error",message:"No output generated",middlewareOptions:o}:Sa(a)?{status:"success",type:"async",output:a,middlewareOptions:o}:{status:"success",type:"sync",output:a,middlewareOptions:o}}catch(a){return Ue(a)?{status:"aborted",message:a.message,middlewareOptions:o}:a===xo?{status:"aborted",message:a,middlewareOptions:o}:{status:"error",message:a instanceof Error?a.message:String(a),error:a,middlewareOptions:o}}}}var Eo=Co;async function Mo(e,t,r,i){let n={...i,provider:t},o={provider:t,panelInput:t.input?.panel,options:{cesdk:r.cesdk,engine:r.cesdk.engine},config:n,providerConfig:t.configuration};if(await t.initialize?.({...r,engine:r.cesdk.engine}),t.input?.quickActions?.supported){let d=t.kind,g=Fe.get();Object.keys(t.input.quickActions.supported).forEach(p=>{if(!g.getBy({id:p,type:"quick"})[0]){let m=`ly.img.plugin-ai-${d}-generation-web.quickAction.${p}`;r.cesdk.feature.enable(m,!0)}})}let a=uo(o),l=po(o,a);o.options.historyAssetSourceId=a,o.options.historyAssetLibraryEntryId=l;let c=Eo({provider:t,cesdk:r.cesdk,engine:r.cesdk.engine}),s=await so(o,c);Aa(r.cesdk,"@imgly/plugin-ai-generation",fo);let u={provider:t,panel:{builderRenderFunction:s},history:{assetSourceId:a,assetLibraryEntryId:l},generate:c};return ya.get().register(u),u}var $e=Mo;function jo(e){let{kind:t,cesdk:r,historAssetSourceIds:i}=e,n=`ly.img.ai.${t}-generation.history`;if(r.engine.asset.findAllSources().includes(n))return n;let o=new fr(n,r,i);return r.engine.asset.addSource(o),o.id}var _o=jo;function re(e,t){return[`ly.img.plugin-ai-${e}-generation-web.${t}`,`ly.img.plugin-ai-generation-web.${t}`,`ly.img.plugin-ai-generation-web.defaults.${t}`]}async function $o(e,t,r,i){let{cesdk:n}=r;ke(n,{en:{"ly.img.plugin-ai-generation-web.generate":"Generate","ly.img.plugin-ai-generation-web.defaults.fromType.label":"Input","ly.img.plugin-ai-generation-web.defaults.providerSelect.label":"Provider","ly.img.plugin-ai-generation-web.defaults.fromText.label":"Text","ly.img.plugin-ai-generation-web.defaults.fromImage.label":"Image","ly.img.plugin-ai-generation-web.schema.loading.label":"Loading\u2026","ly.img.plugin-ai-generation-web.schema.error.title":"Failed to load schema","ly.img.plugin-ai-generation-web.schema.error.retry":"Retry","common.ai-generation.failed":"We couldn't generate the asset. Please try again.","ly.img.ai.error.insufficientCredits":"You've run out of AI credits. Generation is unavailable until more credits are available.","ly.img.ai.error.unauthorized":"AI generation isn't authorized. Please sign in again or contact support.","ly.img.ai.error.notAvailable":"This AI model isn't available on your current plan.","ly.img.ai.error.invalidRequest":"This request couldn't be processed. Please adjust your input and try again.","ly.img.ai.error.serviceUnavailable":"The AI service is temporarily unavailable. Please try again shortly.","ly.img.ai.error.network":"We couldn't reach the AI service. Please check your connection and try again."}});let o,a=[];if(i.debug&&console.groupCollapsed(`Initializing ${e} generation providers`),Array.isArray(t)){let s=await Promise.all(t.map(u=>$e(e,u,r,i)));a.push(...s),o=To({kind:e,prefix:e,providerInitializationResults:a,cesdk:n})}else{let s=await Promise.all(t.fromText.map(d=>$e(e,d,r,i)));a.push(...s);let u=await Promise.all(t.fromImage.map(d=>$e(e,d,r,i)));a.push(...u),o=Lo({kind:e,prefix:`ly.img.ai.${e}-generation`,initializedFromTextProviders:s,initializedFromImageProviders:u,cesdk:n})}i.debug&&console.groupEnd();let l=_o({kind:e,cesdk:r.cesdk,historAssetSourceIds:a.map(s=>s.history?.assetSourceId).filter(ma)}),c;return l!=null&&(c=l,r.cesdk.ui.addAssetLibraryEntry({id:c,sourceIds:[l],sortBy:{sortKey:"insertedAt",sortingOrder:"Descending"},canRemove:!0,gridItemHeight:"square",gridBackgroundType:"cover"})),{panel:{builderRenderFunction:o},history:{assetSourceId:l,assetLibraryEntryId:c},providerInitializationResults:a}}function Lo({kind:e,prefix:t,initializedFromTextProviders:r,initializedFromImageProviders:i,cesdk:n}){let o=r.length>0&&i.length>0;return a=>{let{builder:l,experimental:c,engine:s}=a,u=`ly.img.plugin-ai-${e}-generation-web.fromText`,d=n.feature.isEnabled(u,{engine:s}),g=`ly.img.plugin-ai-${e}-generation-web.fromImage`,p=n.feature.isEnabled(g,{engine:s}),m;d&&r.length>0&&(!p||i.length===0)?m="fromText":p&&i.length>0&&(!d||r.length===0)?m="fromImage":d&&p&&o&&(m="fromText");let f=c.global(`${t}.fromType`,m),y=[];f.value==="fromText"?y.push(...r):f.value==="fromImage"?y.push(...i):y.push(...r,...i);let h=r.map(({provider:A,panel:C})=>({id:A.id,label:De(A),builderRenderFunction:C?.builderRenderFunction})),I=i.map(({provider:A,panel:C})=>({id:A.id,label:De(A),builderRenderFunction:C?.builderRenderFunction})),S=a.experimental.global(`${t}.selectedProvider.fromText`,h[0]?.id),x=a.experimental.global(`${t}.selectedProvider.fromImage`,I[0]?.id),v=h.find(A=>A.id===S.value)??h[0],E=I.find(A=>A.id===x.value)??I[0],ye=f.value==="fromText"?S:f.value==="fromImage"?x:void 0,O=f.value==="fromText"?v:f.value==="fromImage"?E:void 0,he=`ly.img.plugin-ai-${e}-generation-web.providerSelect`,xe=n.feature.isEnabled(he,{engine:s});if(!d&&!p){l.Section(`${t}.noInputWarning.section`,{children:()=>{l.Text(`${t}.noInputWarning.text`,{content:"No input types are enabled. Please enable at least one input type (text or image) via the Feature API."})}});return}let L=d&&p&&r.length>0&&i.length>0,b=o&&L,j=y.length>1&&xe;if((b||j)&&l.Section(`${t}.providerSelection.section`,{children:()=>{if(b&&l.ButtonGroup(`${t}.fromType.buttonGroup`,{inputLabel:re(e,"fromType.label"),children:()=>{d&&r.length>0&&l.Button(`${t}.fromType.buttonGroup.fromText`,{label:re(e,"fromText.label"),icon:f.value!=="fromText"&&It(r,a)?"@imgly/LoadingSpinner":void 0,isActive:f.value==="fromText",onClick:()=>{f.setValue("fromText")}}),p&&i.length>0&&l.Button(`${t}.fromType.buttonGroup.fromImage`,{label:re(e,"fromImage.label"),icon:f.value!=="fromImage"&&It(i,a)?"@imgly/LoadingSpinner":void 0,isActive:f.value==="fromImage",onClick:()=>{f.setValue("fromImage")}})}}),j){let A=f.value==="fromText"?h:f.value==="fromImage"?I:[...h,...I];ye!=null&&O!=null&&l.Select(`${t}.providerSelect.select`,{inputLabel:re(e,"providerSelect.label"),values:A,value:O,setValue:C=>{ye.setValue(C.id)}})}}}),y.length>1)O?.builderRenderFunction?.(a);else{let A=y[0];A&&A.panel?.builderRenderFunction?.(a)}}}function To({kind:e,prefix:t,providerInitializationResults:r,cesdk:i}){return n=>{let{builder:o,engine:a}=n;if(r.length===0)return;let l=`ly.img.plugin-ai-${e}-generation-web.providerSelect`;e==="audio"&&t&&(t.includes("speech")?l="ly.img.plugin-ai-audio-generation-web.speech.providerSelect":t.includes("sound")&&(l="ly.img.plugin-ai-audio-generation-web.sound.providerSelect"));let c=i.feature.isEnabled(l,{engine:a}),s=r.map(({provider:g,panel:p})=>({id:g.id,label:De(g),builderRenderFunction:p?.builderRenderFunction})),u=n.state(`${t}.selectedProvider`,s[0]?.id),d=s.find(g=>g.id===u.value)??s[0];r.length>1&&c&&u!=null&&d!=null&&o.Section(`${t}.providerSelection.section`,{children:()=>{o.Select(`${t}.providerSelect.select`,{inputLabel:re(e,"providerSelect.label"),values:s,value:d,setValue:g=>{u.setValue(g.id)}})}}),d?.builderRenderFunction?.(n)}}function It(e,t){return e.length===0?!1:e.some(({provider:r})=>r.id==null?!1:t.experimental.global(Ge(r.id),!1).value)}var qe=$o;var Ju=5*60*1e3;var Po=typeof global=="object"&&global&&global.Object===Object&&global,ar=Po,Oo=typeof self=="object"&&self&&self.Object===Object&&self,No=ar||Oo||Function("return this")(),$=No,Do=$.Symbol,K=Do,or=Object.prototype,zo=or.hasOwnProperty,Ro=or.toString,ce=K?K.toStringTag:void 0;function Fo(e){var t=zo.call(e,ce),r=e[ce];try{e[ce]=void 0;var i=!0}catch{}var n=Ro.call(e);return i&&(t?e[ce]=r:delete e[ce]),n}var Uo=Fo,Vo=Object.prototype,Bo=Vo.toString;function Go(e){return Bo.call(e)}var qo=Go,Ho="[object Null]",Zo="[object Undefined]",qt=K?K.toStringTag:void 0;function Ko(e){return e==null?e===void 0?Zo:Ho:qt&&qt in Object(e)?Uo(e):qo(e)}var fe=Ko;function Yo(e){return e!=null&&typeof e=="object"}var Xe=Yo,rc=Array.isArray;function Qo(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var sr=Qo,Wo="[object AsyncFunction]",Jo="[object Function]",Xo="[object GeneratorFunction]",es="[object Proxy]";function ts(e){if(!sr(e))return!1;var t=fe(e);return t==Jo||t==Xo||t==Wo||t==es}var rs=ts,is=$["__core-js_shared__"],He=is,Ht=function(){var e=/[^.]+$/.exec(He&&He.keys&&He.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ns(e){return!!Ht&&Ht in e}var as=ns,os=Function.prototype,ss=os.toString;function ls(e){if(e!=null){try{return ss.call(e)}catch{}try{return e+""}catch{}}return""}var D=ls,us=/[\\^$.*+?()[\]{}|]/g,cs=/^\[object .+?Constructor\]$/,ds=Function.prototype,ps=Object.prototype,gs=ds.toString,fs=ps.hasOwnProperty,ms=RegExp("^"+gs.call(fs).replace(us,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ys(e){if(!sr(e)||as(e))return!1;var t=rs(e)?ms:cs;return t.test(D(e))}var hs=ys;function bs(e,t){return e?.[t]}var vs=bs;function ws(e,t){var r=vs(e,t);return hs(r)?r:void 0}var Y=ws,ks=Y($,"WeakMap"),Ke=ks;function Is(e,t){return e===t||e!==e&&t!==t}var Ss=Is,As=9007199254740991;function xs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=As}var Cs=xs;var ic=Object.prototype;var Es="[object Arguments]";function Ms(e){return Xe(e)&&fe(e)==Es}var Zt=Ms,lr=Object.prototype,js=lr.hasOwnProperty,_s=lr.propertyIsEnumerable,nc=Zt(function(){return arguments}())?Zt:function(e){return Xe(e)&&js.call(e,"callee")&&!_s.call(e,"callee")};var ur=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Kt=ur&&typeof module=="object"&&module&&!module.nodeType&&module,$s=Kt&&Kt.exports===ur,Yt=$s?$.Buffer:void 0,ac=Yt?Yt.isBuffer:void 0;var Ls="[object Arguments]",Ts="[object Array]",Ps="[object Boolean]",Os="[object Date]",Ns="[object Error]",Ds="[object Function]",zs="[object Map]",Rs="[object Number]",Fs="[object Object]",Us="[object RegExp]",Vs="[object Set]",Bs="[object String]",Gs="[object WeakMap]",qs="[object ArrayBuffer]",Hs="[object DataView]",Zs="[object Float32Array]",Ks="[object Float64Array]",Ys="[object Int8Array]",Qs="[object Int16Array]",Ws="[object Int32Array]",Js="[object Uint8Array]",Xs="[object Uint8ClampedArray]",el="[object Uint16Array]",tl="[object Uint32Array]",k={};k[Zs]=k[Ks]=k[Ys]=k[Qs]=k[Ws]=k[Js]=k[Xs]=k[el]=k[tl]=!0;k[Ls]=k[Ts]=k[qs]=k[Ps]=k[Hs]=k[Os]=k[Ns]=k[Ds]=k[zs]=k[Rs]=k[Fs]=k[Us]=k[Vs]=k[Bs]=k[Gs]=!1;function rl(e){return Xe(e)&&Cs(e.length)&&!!k[fe(e)]}var il=rl;function nl(e){return function(t){return e(t)}}var al=nl,cr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,de=cr&&typeof module=="object"&&module&&!module.nodeType&&module,ol=de&&de.exports===cr,Ze=ol&&ar.process,sl=function(){try{var e=de&&de.require&&de.require("util").types;return e||Ze&&Ze.binding&&Ze.binding("util")}catch{}}(),Qt=sl,Wt=Qt&&Qt.isTypedArray,oc=Wt?al(Wt):il;var ll=Object.prototype,sc=ll.hasOwnProperty;function ul(e,t){return function(r){return e(t(r))}}var cl=ul,lc=cl(Object.keys,Object);var dl=Object.prototype,uc=dl.hasOwnProperty;var pl=Y(Object,"create"),pe=pl;function gl(){this.__data__=pe?pe(null):{},this.size=0}var fl=gl;function ml(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var yl=ml,hl="__lodash_hash_undefined__",bl=Object.prototype,vl=bl.hasOwnProperty;function wl(e){var t=this.__data__;if(pe){var r=t[e];return r===hl?void 0:r}return vl.call(t,e)?t[e]:void 0}var kl=wl,Il=Object.prototype,Sl=Il.hasOwnProperty;function Al(e){var t=this.__data__;return pe?t[e]!==void 0:Sl.call(t,e)}var xl=Al,Cl="__lodash_hash_undefined__";function El(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=pe&&t===void 0?Cl:t,this}var Ml=El;function Q(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])}}Q.prototype.clear=fl;Q.prototype.delete=yl;Q.prototype.get=kl;Q.prototype.has=xl;Q.prototype.set=Ml;var Jt=Q;function jl(){this.__data__=[],this.size=0}var _l=jl;function $l(e,t){for(var r=e.length;r--;)if(Ss(e[r][0],t))return r;return-1}var Ie=$l,Ll=Array.prototype,Tl=Ll.splice;function Pl(e){var t=this.__data__,r=Ie(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Tl.call(t,r,1),--this.size,!0}var Ol=Pl;function Nl(e){var t=this.__data__,r=Ie(t,e);return r<0?void 0:t[r][1]}var Dl=Nl;function zl(e){return Ie(this.__data__,e)>-1}var Rl=zl;function Fl(e,t){var r=this.__data__,i=Ie(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var Ul=Fl;function W(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])}}W.prototype.clear=_l;W.prototype.delete=Ol;W.prototype.get=Dl;W.prototype.has=Rl;W.prototype.set=Ul;var Se=W,Vl=Y($,"Map"),ge=Vl;function Bl(){this.size=0,this.__data__={hash:new Jt,map:new(ge||Se),string:new Jt}}var Gl=Bl;function ql(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Hl=ql;function Zl(e,t){var r=e.__data__;return Hl(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Ae=Zl;function Kl(e){var t=Ae(this,e).delete(e);return this.size-=t?1:0,t}var Yl=Kl;function Ql(e){return Ae(this,e).get(e)}var Wl=Ql;function Jl(e){return Ae(this,e).has(e)}var Xl=Jl;function eu(e,t){var r=Ae(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var tu=eu;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=Gl;J.prototype.delete=Yl;J.prototype.get=Wl;J.prototype.has=Xl;J.prototype.set=tu;var dr=J;function ru(){this.__data__=new Se,this.size=0}var iu=ru;function nu(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var au=nu;function ou(e){return this.__data__.get(e)}var su=ou;function lu(e){return this.__data__.has(e)}var uu=lu,cu=200;function du(e,t){var r=this.__data__;if(r instanceof Se){var i=r.__data__;if(!ge||i.length<cu-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new dr(i)}return r.set(e,t),this.size=r.size,this}var pu=du;function me(e){var t=this.__data__=new Se(e);this.size=t.size}me.prototype.clear=iu;me.prototype.delete=au;me.prototype.get=su;me.prototype.has=uu;me.prototype.set=pu;var gu=Object.prototype,cc=gu.propertyIsEnumerable;var fu=Y($,"DataView"),Ye=fu,mu=Y($,"Promise"),Qe=mu,yu=Y($,"Set"),We=yu,Xt="[object Map]",hu="[object Object]",er="[object Promise]",tr="[object Set]",rr="[object WeakMap]",ir="[object DataView]",bu=D(Ye),vu=D(ge),wu=D(Qe),ku=D(We),Iu=D(Ke),Z=fe;(Ye&&Z(new Ye(new ArrayBuffer(1)))!=ir||ge&&Z(new ge)!=Xt||Qe&&Z(Qe.resolve())!=er||We&&Z(new We)!=tr||Ke&&Z(new Ke)!=rr)&&(Z=function(e){var t=fe(e),r=t==hu?e.constructor:void 0,i=r?D(r):"";if(i)switch(i){case bu:return ir;case vu:return Xt;case wu:return er;case ku:return tr;case Iu:return rr}return t});var dc=$.Uint8Array;var Su="__lodash_hash_undefined__";function Au(e){return this.__data__.set(e,Su),this}var xu=Au;function Cu(e){return this.__data__.has(e)}var Eu=Cu;function Je(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new dr;++t<r;)this.add(e[t])}Je.prototype.add=Je.prototype.push=xu;Je.prototype.has=Eu;var nr=K?K.prototype:void 0,pc=nr?nr.valueOf:void 0;var Mu=Object.prototype,gc=Mu.hasOwnProperty;var ju=Object.prototype,fc=ju.hasOwnProperty;var mc=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),yc=new RegExp(/[A-Fa-f0-9]{1}/,"g"),hc=new RegExp(/[A-Fa-f0-9]{2}/,"g");function _u(e){return e==null?[]:Array.isArray(e)?e:[e]}var et=_u;function $u(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function Lu(e){return typeof e?.translate=="function"}function tt(e,t,r){return e&&$u(e)&&Lu(e.i18n)?e.i18n.translate(t):r}var M="@imgly/plugin-ai-audio-generation-web";var z="ly.img.ai.audio-generation.speech",R="ly.img.ai.audio-generation.sound";function Tu(e){return{async initialize({cesdk:t}){if(t==null)return;Pt(t,M,"1.81.1-rc.0"),t.feature.enable("ly.img.plugin-ai-audio-generation-web.speech.providerSelect",!0),t.feature.enable("ly.img.plugin-ai-audio-generation-web.sound.providerSelect",!0);let r=`${M}.sound.action.label`,i=`${M}.speech.action.label`;ke(t,{en:{[`panel.${z}`]:"AI Voice",[`panel.${R}`]:"Sound Generation",[r]:"Generate Sound",[i]:"AI Voice"}}),Pu(e);let n=Fe.get(),o=n.register({type:"plugin",sceneMode:"Video",id:`${M}/sound`,pluginId:M,label:tt(t,r,"Generate Sound"),labelKey:r,meta:{panelId:R},execute:()=>{t.ui.isPanelOpen(R)?t.ui.closePanel(R):t.ui.openPanel(R)}}),a=n.register({type:"plugin",sceneMode:"Video",id:`${M}/speech`,pluginId:M,label:tt(t,i,"AI Voice"),labelKey:i,meta:{panelId:z},execute:()=>{t.ui.isPanelOpen(z)?t.ui.closePanel(z):t.ui.openPanel(z)}}),l=e.providers?.text2speech??e.text2speech,c=e.providers?.text2sound??e.text2sound,s=await Promise.all(et(l).map(f=>f({cesdk:t}))),u=await Promise.all(et(c).map(f=>f({cesdk:t}))),d=s.length>0,g=u.length>0;if(!d&&!g){o(),a();return}g||o(),d||a();let p=await qe("audio",s,{cesdk:t},e),m=await qe("audio",u,{cesdk:t},e);m.panel.builderRenderFunction!=null?(t.ui.registerPanel(R,m.panel.builderRenderFunction),Ve({cesdk:t,panelId:R})):o(),p.panel.builderRenderFunction!=null?(t.ui.registerPanel(z,p.panel.builderRenderFunction),Ve({cesdk:t,panelId:z})):a()}}}function Pu(e){e.debug&&(e.providers?.text2speech!=null&&e.text2speech!=null&&console.warn("[AudioGeneration]: Both `providers.text2speech` and `text2speech` configuration is provided. Since `text2speech` is deprecated, only `providers.text2speech` will be used."),e.providers?.text2sound!=null&&e.text2sound!=null&&console.warn("[AudioGeneration]: Both `providers.text2sound` and `text2sound` configuration is provided. Since `text2sound` is deprecated, only `providers.text2sound` will be used."))}var pr=Tu;var Ou=e=>({name:M,version:"1.81.1-rc.0",...pr(e)}),Ec=Ou;export{Ec as default};
67
67
  /*! Bundled license information:
68
68
 
69
69
  lodash-es/lodash.js: