@imgly/plugin-ai-sticker-generation-web 0.2.10 → 0.2.12
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/CHANGELOG.md +15 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/fal-ai/index.mjs +5 -5
- package/dist/fal-ai/index.mjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/fal-ai/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ea=Object.create;var Si=Object.defineProperty;var ta=Object.getOwnPropertyDescriptor;var ia=Object.getOwnPropertyNames;var ra=Object.getPrototypeOf,na=Object.prototype.hasOwnProperty;var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var aa=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ia(e))!na.call(t,n)&&n!==i&&Si(t,n,{get:()=>e[n],enumerable:!(r=ta(e,n))||r.enumerable});return t};var oa=(t,e,i)=>(i=t!=null?ea(ra(t)):{},aa(e||!t||!t.__esModule?Si(i,"default",{value:t,enumerable:!0}):i,t));var qt=k(D=>{"use strict";var xd=D&&D.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(D,"__esModule",{value:!0});D.TARGET_URL_HEADER=void 0;D.withMiddleware=kd;D.withProxy=Sd;function kd(...t){let e=i=>typeof i=="function";return i=>xd(this,void 0,void 0,function*(){let r=Object.assign({},i);for(let n of t.filter(e))r=yield n(r);return r})}D.TARGET_URL_HEADER="x-fal-target-url";function Sd(t){let e=i=>Promise.resolve(i);return typeof window>"u"?e:i=>i.headers&&D.TARGET_URL_HEADER in i?e(i):Promise.resolve(Object.assign(Object.assign({},i),{url:t.targetUrl,headers:Object.assign(Object.assign({},i.headers||{}),{[D.TARGET_URL_HEADER]:i.url})}))}});var q=k(P=>{"use strict";var kr=P&&P.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.ValidationError=P.ApiError=void 0;P.defaultResponseHandler=Sr;P.resultResponseHandler=Id;var Ed="x-fal-request-id",he=class extends Error{constructor({message:e,status:i,body:r}){super(e),this.name="ApiError",this.status=i,this.body=r}};P.ApiError=he;var Xe=class extends he{constructor(e){super(e),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(i=>i.loc[i.loc.length-1]===e)}};P.ValidationError=Xe;function Sr(t){return kr(this,void 0,void 0,function*(){var e;let{status:i,statusText:r}=t,n=(e=t.headers.get("Content-Type"))!==null&&e!==void 0?e:"";if(!t.ok){if(n.includes("application/json")){let a=yield t.json(),o=i===422?Xe:he;throw new o({message:a.message||r,status:i,body:a})}throw new he({message:`HTTP ${i}: ${r}`,status:i})}return n.includes("application/json")?t.json():n.includes("text/html")?t.text():n.includes("application/octet-stream")?t.arrayBuffer():t.text()})}function Id(t){return kr(this,void 0,void 0,function*(){return{data:yield Sr(t),requestId:t.headers.get(Ed)||""}})}});var V=k($=>{"use strict";var Ad=$&&$.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty($,"__esModule",{value:!0});$.ensureEndpointIdFormat=Er;$.parseEndpointId=Td;$.isValidUrl=Md;$.throttle=Od;$.isReact=$d;$.isPlainObject=jd;$.sleep=Dd;function Er(t){if(t.split("/").length>1)return t;let[,i,r]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(t)||[];if(i&&r)return`${i}/${r}`;throw new Error(`Invalid app id: ${t}. Must be in the format <appOwner>/<appId>`)}var Cd=["workflows","comfy"];function Td(t){let i=Er(t).split("/");return Cd.includes(i[0])?{owner:i[1],alias:i[2],path:i.slice(3).join("/")||void 0,namespace:i[0]}:{owner:i[0],alias:i[1],path:i.slice(2).join("/")||void 0}}function Md(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function Od(t,e,i=!1){let r,n;return(...a)=>{!n&&i?(t(...a),n=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-n>=e&&(t(...a),n=Date.now())},e-(Date.now()-n)))}}var Vt;function $d(){if(Vt===void 0){let t=new Error().stack;Vt=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return Vt}function jd(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}function Dd(t){return Ad(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}});var De=k(T=>{"use strict";var Pd=T&&T.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(T,"__esModule",{value:!0});T.DEFAULT_RETRY_OPTIONS=T.DEFAULT_RETRYABLE_STATUS_CODES=void 0;T.isRetryableError=Ir;T.calculateBackoffDelay=Ar;T.executeWithRetry=Ld;var Ud=q(),Nd=V();T.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];T.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:T.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Ir(t,e){return t instanceof Ud.ApiError&&e.includes(t.status)}function Ar(t,e,i,r,n){let a=Math.min(e*Math.pow(r,t),i);if(n){let o=.25*a*(Math.random()*2-1);return Math.max(0,a+o)}return a}function Ld(t,e,i){return Pd(this,void 0,void 0,function*(){let r={totalAttempts:0,totalDelay:0},n;for(let a=0;a<=e.maxRetries;a++){r.totalAttempts++;try{return{result:yield t(),metrics:r}}catch(o){if(n=o,r.lastError=o,a===e.maxRetries||!Ir(o,e.retryableStatusCodes))throw o;let s=Ar(a,e.baseDelay,e.maxDelay,e.backoffMultiplier,e.enableJitter);r.totalDelay+=s,i&&i(a+1,o,s),yield(0,Nd.sleep)(s)}}throw n})}});var Cr=k((Jf,Fd)=>{Fd.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.6.2",license:"MIT",repository:{type:"git",url:"https://github.com/fal-ai/fal-js.git",directory:"libs/client"},keywords:["fal","client","ai","ml","typescript"],exports:{".":"./src/index.js","./endpoints":"./src/types/endpoints.js"},typesVersions:{"*":{endpoints:["src/types/endpoints.d.ts"]}},main:"./src/index.js",types:"./src/index.d.ts",dependencies:{"@msgpack/msgpack":"^3.0.0-beta2","eventsource-parser":"^1.1.2",robot3:"^0.4.1"},engines:{node:">=18.0.0"},type:"commonjs"}});var tt=k(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.isBrowser=zd;et.getUserAgent=Bd;function zd(){return typeof window<"u"&&typeof window.document<"u"}var Je=null;function Bd(){if(Je!==null)return Je;let t=Cr();return Je=`${t.name}/${t.version}`,Je}});var it=k(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.credentialsFromEnv=void 0;H.resolveDefaultFetch=Or;H.createConfig=Kd;H.getRestApiUrl=Yd;var Tr=qt(),Rd=q(),Mr=De(),qd=tt();function Or(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function Vd(){return typeof process<"u"&&process.env&&(typeof process.env.FAL_KEY<"u"||typeof process.env.FAL_KEY_ID<"u"&&typeof process.env.FAL_KEY_SECRET<"u")}var Hd=()=>{if(Vd())return typeof process.env.FAL_KEY<"u"?process.env.FAL_KEY:process.env.FAL_KEY_ID?`${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}`:void 0};H.credentialsFromEnv=Hd;var Gd={credentials:H.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:Rd.defaultResponseHandler,retry:Mr.DEFAULT_RETRY_OPTIONS};function Kd(t){var e;let i=Object.assign(Object.assign(Object.assign({},Gd),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:Or(),retry:Object.assign(Object.assign({},Mr.DEFAULT_RETRY_OPTIONS),t.retry||{})});t.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,Tr.withMiddleware)(i.requestMiddleware,(0,Tr.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,a=typeof r=="function"?r():r;return(0,qd.isBrowser)()&&a&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),i}function Yd(){return"https://rest.alpha.fal.ai"}});var me=k(G=>{"use strict";var $r=G&&G.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})},Wd=G&&G.__rest||function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]]);return i};Object.defineProperty(G,"__esModule",{value:!0});G.dispatchRequest=Zd;G.buildUrl=Xd;var jr=De(),Dr=tt(),Ht=V(),Qd=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Zd(t){return $r(this,void 0,void 0,function*(){var e;let{targetUrl:i,input:r,config:n,options:a={}}=t,{credentials:o,requestMiddleware:s,responseHandler:c,fetch:u}=n,l=Object.assign(Object.assign({},n.retry),a.retry||{}),d=()=>$r(this,void 0,void 0,function*(){var p,m,y;let w=(0,Dr.isBrowser)()?{}:{"User-Agent":(0,Dr.getUserAgent)()},g=typeof o=="function"?o():o,{method:f,url:v,headers:_}=yield s({method:((m=(p=t.method)!==null&&p!==void 0?p:a.method)!==null&&m!==void 0?m:"post").toUpperCase(),url:i,headers:t.headers}),C=g?{Authorization:`Key ${g}`}:{},xt=Object.assign(Object.assign(Object.assign(Object.assign({},C),{Accept:"application/json","Content-Type":"application/json"}),w),_??{}),{responseHandler:kt,retry:nf}=a,ki=Wd(a,["responseHandler","retry"]),Jn=yield u(v,Object.assign(Object.assign(Object.assign(Object.assign({},ki),{method:f,headers:Object.assign(Object.assign({},xt),(y=ki.headers)!==null&&y!==void 0?y:{})}),!Qd&&{mode:"cors"}),{signal:a.signal,body:f.toLowerCase()!=="get"&&r?JSON.stringify(r):void 0}));return yield(kt??c)(Jn)}),h;for(let p=0;p<=l.maxRetries;p++)try{return yield d()}catch(m){if(h=m,p===l.maxRetries||!(0,jr.isRetryableError)(m,l.retryableStatusCodes)||((e=a.signal)===null||e===void 0?void 0:e.aborted))throw m;let w=(0,jr.calculateBackoffDelay)(p,l.baseDelay,l.maxDelay,l.backoffMultiplier,l.enableJitter);yield(0,Ht.sleep)(w)}throw h})}function Xd(t,e={}){var i,r;let n=((i=e.method)!==null&&i!==void 0?i:"post").toLowerCase(),a=((r=e.path)!==null&&r!==void 0?r:"").replace(/^\//,"").replace(/\/{2,}/,"/"),o=e.input,s=Object.assign(Object.assign({},e.query||{}),n==="get"?o:{}),c=Object.keys(s).length>0?`?${new URLSearchParams(s).toString()}`:"";if((0,Ht.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${a}${c}`;let u=(0,Ht.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${a}`.replace(/\/$/,"")}${c}`}});var Ur=k(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});function Jd(t){let e,i,r,n,a,o,s;return c(),{feed:u,reset:c};function c(){e=!0,i="",r=0,n=-1,a=void 0,o=void 0,s=""}function u(d){i=i?i+d:d,e&&eg(i)&&(i=i.slice(Pr.length)),e=!1;let h=i.length,p=0,m=!1;for(;p<h;){m&&(i[p]===`
|
|
1
|
+
var eo=Object.create;var Si=Object.defineProperty;var to=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var ro=Object.getPrototypeOf,no=Object.prototype.hasOwnProperty;var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var oo=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of io(e))!no.call(t,n)&&n!==i&&Si(t,n,{get:()=>e[n],enumerable:!(r=to(e,n))||r.enumerable});return t};var ao=(t,e,i)=>(i=t!=null?eo(ro(t)):{},oo(e||!t||!t.__esModule?Si(i,"default",{value:t,enumerable:!0}):i,t));var qt=x(D=>{"use strict";var kd=D&&D.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(D,"__esModule",{value:!0});D.TARGET_URL_HEADER=void 0;D.withMiddleware=xd;D.withProxy=Sd;function xd(...t){let e=i=>typeof i=="function";return i=>kd(this,void 0,void 0,function*(){let r=Object.assign({},i);for(let n of t.filter(e))r=yield n(r);return r})}D.TARGET_URL_HEADER="x-fal-target-url";function Sd(t){let e=i=>Promise.resolve(i);return typeof window>"u"?e:i=>i.headers&&D.TARGET_URL_HEADER in i?e(i):Promise.resolve(Object.assign(Object.assign({},i),{url:t.targetUrl,headers:Object.assign(Object.assign({},i.headers||{}),{[D.TARGET_URL_HEADER]:i.url})}))}});var q=x(P=>{"use strict";var xr=P&&P.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.ValidationError=P.ApiError=void 0;P.defaultResponseHandler=Sr;P.resultResponseHandler=Id;var Ed="x-fal-request-id",he=class extends Error{constructor({message:e,status:i,body:r}){super(e),this.name="ApiError",this.status=i,this.body=r}};P.ApiError=he;var Xe=class extends he{constructor(e){super(e),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(i=>i.loc[i.loc.length-1]===e)}};P.ValidationError=Xe;function Sr(t){return xr(this,void 0,void 0,function*(){var e;let{status:i,statusText:r}=t,n=(e=t.headers.get("Content-Type"))!==null&&e!==void 0?e:"";if(!t.ok){if(n.includes("application/json")){let o=yield t.json(),a=i===422?Xe:he;throw new a({message:o.message||r,status:i,body:o})}throw new he({message:`HTTP ${i}: ${r}`,status:i})}return n.includes("application/json")?t.json():n.includes("text/html")?t.text():n.includes("application/octet-stream")?t.arrayBuffer():t.text()})}function Id(t){return xr(this,void 0,void 0,function*(){return{data:yield Sr(t),requestId:t.headers.get(Ed)||""}})}});var V=x(j=>{"use strict";var Ad=j&&j.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(j,"__esModule",{value:!0});j.ensureEndpointIdFormat=Er;j.parseEndpointId=Td;j.isValidUrl=Md;j.throttle=$d;j.isReact=jd;j.isPlainObject=Od;j.sleep=Dd;function Er(t){if(t.split("/").length>1)return t;let[,i,r]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(t)||[];if(i&&r)return`${i}/${r}`;throw new Error(`Invalid app id: ${t}. Must be in the format <appOwner>/<appId>`)}var Cd=["workflows","comfy"];function Td(t){let i=Er(t).split("/");return Cd.includes(i[0])?{owner:i[1],alias:i[2],path:i.slice(3).join("/")||void 0,namespace:i[0]}:{owner:i[0],alias:i[1],path:i.slice(2).join("/")||void 0}}function Md(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function $d(t,e,i=!1){let r,n;return(...o)=>{!n&&i?(t(...o),n=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-n>=e&&(t(...o),n=Date.now())},e-(Date.now()-n)))}}var Vt;function jd(){if(Vt===void 0){let t=new Error().stack;Vt=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return Vt}function Od(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}function Dd(t){return Ad(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}});var De=x(T=>{"use strict";var Pd=T&&T.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(T,"__esModule",{value:!0});T.DEFAULT_RETRY_OPTIONS=T.DEFAULT_RETRYABLE_STATUS_CODES=void 0;T.isRetryableError=Ir;T.calculateBackoffDelay=Ar;T.executeWithRetry=Ld;var Ud=q(),Nd=V();T.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];T.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:T.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Ir(t,e){return t instanceof Ud.ApiError&&e.includes(t.status)}function Ar(t,e,i,r,n){let o=Math.min(e*Math.pow(r,t),i);if(n){let a=.25*o*(Math.random()*2-1);return Math.max(0,o+a)}return o}function Ld(t,e,i){return Pd(this,void 0,void 0,function*(){let r={totalAttempts:0,totalDelay:0},n;for(let o=0;o<=e.maxRetries;o++){r.totalAttempts++;try{return{result:yield t(),metrics:r}}catch(a){if(n=a,r.lastError=a,o===e.maxRetries||!Ir(a,e.retryableStatusCodes))throw a;let s=Ar(o,e.baseDelay,e.maxDelay,e.backoffMultiplier,e.enableJitter);r.totalDelay+=s,i&&i(o+1,a,s),yield(0,Nd.sleep)(s)}}throw n})}});var Cr=x((Jf,Fd)=>{Fd.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.6.2",license:"MIT",repository:{type:"git",url:"https://github.com/fal-ai/fal-js.git",directory:"libs/client"},keywords:["fal","client","ai","ml","typescript"],exports:{".":"./src/index.js","./endpoints":"./src/types/endpoints.js"},typesVersions:{"*":{endpoints:["src/types/endpoints.d.ts"]}},main:"./src/index.js",types:"./src/index.d.ts",dependencies:{"@msgpack/msgpack":"^3.0.0-beta2","eventsource-parser":"^1.1.2",robot3:"^0.4.1"},engines:{node:">=18.0.0"},type:"commonjs"}});var tt=x(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.isBrowser=zd;et.getUserAgent=Bd;function zd(){return typeof window<"u"&&typeof window.document<"u"}var Je=null;function Bd(){if(Je!==null)return Je;let t=Cr();return Je=`${t.name}/${t.version}`,Je}});var it=x(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.credentialsFromEnv=void 0;H.resolveDefaultFetch=$r;H.createConfig=Kd;H.getRestApiUrl=Yd;var Tr=qt(),Rd=q(),Mr=De(),qd=tt();function $r(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function Vd(){return typeof process<"u"&&process.env&&(typeof process.env.FAL_KEY<"u"||typeof process.env.FAL_KEY_ID<"u"&&typeof process.env.FAL_KEY_SECRET<"u")}var Hd=()=>{if(Vd())return typeof process.env.FAL_KEY<"u"?process.env.FAL_KEY:process.env.FAL_KEY_ID?`${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}`:void 0};H.credentialsFromEnv=Hd;var Gd={credentials:H.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:Rd.defaultResponseHandler,retry:Mr.DEFAULT_RETRY_OPTIONS};function Kd(t){var e;let i=Object.assign(Object.assign(Object.assign({},Gd),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:$r(),retry:Object.assign(Object.assign({},Mr.DEFAULT_RETRY_OPTIONS),t.retry||{})});t.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,Tr.withMiddleware)(i.requestMiddleware,(0,Tr.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,qd.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),i}function Yd(){return"https://rest.alpha.fal.ai"}});var me=x(G=>{"use strict";var jr=G&&G.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})},Wd=G&&G.__rest||function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]]);return i};Object.defineProperty(G,"__esModule",{value:!0});G.dispatchRequest=Zd;G.buildUrl=Xd;var Or=De(),Dr=tt(),Ht=V(),Qd=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Zd(t){return jr(this,void 0,void 0,function*(){var e;let{targetUrl:i,input:r,config:n,options:o={}}=t,{credentials:a,requestMiddleware:s,responseHandler:c,fetch:u}=n,l=Object.assign(Object.assign({},n.retry),o.retry||{}),d=()=>jr(this,void 0,void 0,function*(){var p,m,y;let w=(0,Dr.isBrowser)()?{}:{"User-Agent":(0,Dr.getUserAgent)()},g=typeof a=="function"?a():a,{method:f,url:v,headers:_}=yield s({method:((m=(p=t.method)!==null&&p!==void 0?p:o.method)!==null&&m!==void 0?m:"post").toUpperCase(),url:i,headers:t.headers}),C=g?{Authorization:`Key ${g}`}:{},kt=Object.assign(Object.assign(Object.assign(Object.assign({},C),{Accept:"application/json","Content-Type":"application/json"}),w),_??{}),{responseHandler:xt,retry:nf}=o,xi=Wd(o,["responseHandler","retry"]),Jn=yield u(v,Object.assign(Object.assign(Object.assign(Object.assign({},xi),{method:f,headers:Object.assign(Object.assign({},kt),(y=xi.headers)!==null&&y!==void 0?y:{})}),!Qd&&{mode:"cors"}),{signal:o.signal,body:f.toLowerCase()!=="get"&&r?JSON.stringify(r):void 0}));return yield(xt??c)(Jn)}),h;for(let p=0;p<=l.maxRetries;p++)try{return yield d()}catch(m){if(h=m,p===l.maxRetries||!(0,Or.isRetryableError)(m,l.retryableStatusCodes)||((e=o.signal)===null||e===void 0?void 0:e.aborted))throw m;let w=(0,Or.calculateBackoffDelay)(p,l.baseDelay,l.maxDelay,l.backoffMultiplier,l.enableJitter);yield(0,Ht.sleep)(w)}throw h})}function Xd(t,e={}){var i,r;let n=((i=e.method)!==null&&i!==void 0?i:"post").toLowerCase(),o=((r=e.path)!==null&&r!==void 0?r:"").replace(/^\//,"").replace(/\/{2,}/,"/"),a=e.input,s=Object.assign(Object.assign({},e.query||{}),n==="get"?a:{}),c=Object.keys(s).length>0?`?${new URLSearchParams(s).toString()}`:"";if((0,Ht.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${o}${c}`;let u=(0,Ht.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var Ur=x(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});function Jd(t){let e,i,r,n,o,a,s;return c(),{feed:u,reset:c};function c(){e=!0,i="",r=0,n=-1,o=void 0,a=void 0,s=""}function u(d){i=i?i+d:d,e&&eg(i)&&(i=i.slice(Pr.length)),e=!1;let h=i.length,p=0,m=!1;for(;p<h;){m&&(i[p]===`
|
|
2
2
|
`&&++p,m=!1);let y=-1,w=n,g;for(let f=r;y<0&&f<h;++f)g=i[f],g===":"&&w<0?w=f-p:g==="\r"?(m=!0,y=f-p):g===`
|
|
3
|
-
`&&(y=f-p);if(y<0){r=h-p,n=w;break}else r=0,n=-1;l(i,p,w,y),p+=y+1}p===h?i="":p>0&&(i=i.slice(p))}function l(d,h,p,m){if(m===0){s.length>0&&(t({type:"event",id:
|
|
3
|
+
`&&(y=f-p);if(y<0){r=h-p,n=w;break}else r=0,n=-1;l(i,p,w,y),p+=y+1}p===h?i="":p>0&&(i=i.slice(p))}function l(d,h,p,m){if(m===0){s.length>0&&(t({type:"event",id:o,event:a||void 0,data:s.slice(0,-1)}),s="",o=void 0),a=void 0;return}let y=p<0,w=d.slice(h,h+(y?m:p)),g=0;y?g=m:d[h+p+1]===" "?g=p+2:g=p+1;let f=h+g,v=m-g,_=d.slice(f,f+v).toString();if(w==="data")s+=_?"".concat(_,`
|
|
4
4
|
`):`
|
|
5
|
-
`;else if(w==="event")o=_;else if(w==="id"&&!_.includes("\0"))a=_;else if(w==="retry"){let C=parseInt(_,10);Number.isNaN(C)||t({type:"reconnect-interval",value:C})}}}var Pr=[239,187,191];function eg(t){return Pr.every((e,i)=>t.charCodeAt(i)===e)}Gt.createParser=Jd});var Kt=k(K=>{"use strict";var tg=K&&K.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(K,"__esModule",{value:!0});K.TOKEN_EXPIRATION_SECONDS=void 0;K.getTemporaryAuthToken=ag;var ig=it(),rg=me(),ng=V();K.TOKEN_EXPIRATION_SECONDS=120;function ag(t,e){return tg(this,void 0,void 0,function*(){let i=(0,ng.parseEndpointId)(t),r=yield(0,rg.dispatchRequest)({method:"POST",targetUrl:`${(0,ig.getRestApiUrl)()}/tokens/`,config:e,input:{allowed_apps:[i.alias],token_expiration:K.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var Wt=k(j=>{"use strict";var be=j&&j.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})},Pe=j&&j.__await||function(t){return this instanceof Pe?(this.v=t,this):new Pe(t)},og=j&&j.__asyncGenerator||function(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(t,e||[]),n,a=[];return n={},s("next"),s("throw"),s("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(p){return function(m){return Promise.resolve(m).then(p,d)}}function s(p,m){r[p]&&(n[p]=function(y){return new Promise(function(w,g){a.push([p,y,w,g])>1||c(p,y)})},m&&(n[p]=m(n[p])))}function c(p,m){try{u(r[p](m))}catch(y){h(a[0][3],y)}}function u(p){p.value instanceof Pe?Promise.resolve(p.value.v).then(l,d):h(a[0][2],p)}function l(p){c("next",p)}function d(p){c("throw",p)}function h(p,m){p(m),a.shift(),a.length&&c(a[0][0],a[0][1])}};Object.defineProperty(j,"__esModule",{value:!0});j.FalStream=void 0;j.createStreamingClient=ug;var sg=Ur(),lg=Kt(),Nr=me(),ye=q(),Yt="text/event-stream",cg=15*1e3,rt=class{constructor(e,i,r){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this._requestId=null,this.abortController=new AbortController,this.start=()=>be(this,void 0,void 0,function*(){var a,o;let{endpointId:s,options:c}=this,{input:u,method:l="post",connectionMode:d="server"}=c;try{if(d==="client"){let h=yield(0,lg.getTemporaryAuthToken)(s,this.config),{fetch:p}=this.config,m=new URL(this.url);m.searchParams.set("fal_jwt_token",h);let y=yield p(m.toString(),{method:l.toUpperCase(),headers:{accept:(a=c.accept)!==null&&a!==void 0?a:Yt,"content-type":"application/json"},body:u&&l!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return this._requestId=y.headers.get("x-fal-request-id"),yield this.handleResponse(y)}return yield(0,Nr.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(o=c.accept)!==null&&o!==void 0?o:Yt},responseHandler:h=>be(this,void 0,void 0,function*(){return this._requestId=h.headers.get("x-fal-request-id"),yield this.handleResponse(h)}),signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=a=>be(this,void 0,void 0,function*(){var o,s;if(!a.ok){try{yield(0,ye.defaultResponseHandler)(a)}catch(y){this.emit("error",y)}return}let c=a.body;if(!c){this.emit("error",new ye.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((o=a.headers.get("content-type"))!==null&&o!==void 0?o:"").startsWith(Yt)){let y=c.getReader(),w=()=>{y.read().then(({done:g,value:f})=>{if(g){this.emit("done",this.currentData);return}this.currentData=f,this.emit("data",f),w()})};w();return}let l=new TextDecoder("utf-8"),d=a.body.getReader(),h=(0,sg.createParser)(y=>{if(y.type==="event"){let w=y.data;try{let g=JSON.parse(w);this.buffer.push(g),this.currentData=g,this.emit("data",g),this.emit("message",g)}catch(g){this.emit("error",g)}}}),p=(s=this.options.timeout)!==null&&s!==void 0?s:cg,m=()=>be(this,void 0,void 0,function*(){let{value:y,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(l.decode(y)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new ye.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):m().catch(this.handleError)});m().catch(this.handleError)}),this.handleError=a=>{var o;if(a.name==="AbortError"||this.signal.aborted)return;let s=a instanceof ye.ApiError?a:new ye.ApiError({message:(o=a.message)!==null&&o!==void 0?o:"An unknown error occurred",status:500});this.emit("error",s)},this.on=(a,o)=>{var s;this.listeners.has(a)||this.listeners.set(a,[]),(s=this.listeners.get(a))===null||s===void 0||s.push(o)},this.emit=(a,o)=>{let s=this.listeners.get(a)||[];for(let c of s)c(o)},this.done=()=>be(this,void 0,void 0,function*(){return this.donePromise}),this.abort=a=>{this.streamClosed||this.abortController.abort(a)},this.endpointId=e,this.config=i,this.url=(n=r.url)!==null&&n!==void 0?n:(0,Nr.buildUrl)(e,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((a,o)=>{this.streamClosed&&o(new ye.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var s;a((s=this.currentData)!==null&&s!==void 0?s:{})}),this.on("done",s=>{this.streamClosed=!0,a(s)}),this.on("error",s=>{this.streamClosed=!0,o(s)})}),r.signal&&r.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return og(this,arguments,function*(){let i=!0,r=()=>i=!1;for(this.on("error",r),this.on("done",r);i||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield Pe(n)),yield Pe(new Promise(a=>setTimeout(a,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};j.FalStream=rt;function ug({config:t,storage:e}){return{stream(i,r){return be(this,void 0,void 0,function*(){let n=r.input?yield e.transformInput(r.input):void 0;return new rt(i,t,Object.assign(Object.assign({},r),{input:n}))})}}}});var Br=k(Y=>{"use strict";var J=Y&&Y.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})},dg=Y&&Y.__rest||function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]]);return i};Object.defineProperty(Y,"__esModule",{value:!0});Y.createQueueClient=void 0;var F=me(),gg=q(),zr=De(),pg=Wt(),nt=V(),Lr=500,Fr={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:zr.DEFAULT_RETRYABLE_STATUS_CODES},fg={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...zr.DEFAULT_RETRYABLE_STATUS_CODES,500]},hg=({config:t,storage:e})=>{let i={submit(r,n){return J(this,void 0,void 0,function*(){let{webhookUrl:a,priority:o,hint:s}=n,c=dg(n,["webhookUrl","priority","hint"]),u=n.input?yield e.transformInput(n.input):void 0;return(0,F.dispatchRequest)({method:n.method,targetUrl:(0,F.buildUrl)(r,Object.assign(Object.assign({},c),{subdomain:"queue",query:a?{fal_webhook:a}:void 0})),headers:Object.assign({"x-fal-queue-priority":o??"normal"},s&&{"x-fal-runner-hint":s}),input:u,config:t,options:{signal:n.abortSignal,retry:Fr}})})},status(r,n){return J(this,arguments,void 0,function*(a,{requestId:o,logs:s=!1,abortSignal:c}){let u=(0,nt.parseEndpointId)(a),l=u.namespace?`${u.namespace}/`:"";return(0,F.dispatchRequest)({method:"get",targetUrl:(0,F.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:s?"1":"0"},path:`/requests/${o}/status`}),config:t,options:{signal:c,retry:fg}})})},streamStatus(r,n){return J(this,arguments,void 0,function*(a,{requestId:o,logs:s=!1,connectionMode:c}){let u=(0,nt.parseEndpointId)(a),l=u.namespace?`${u.namespace}/`:"",d={logs:s?"1":"0"},h=(0,F.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${o}/status/stream`,query:d});return new pg.FalStream(a,t,{url:h,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(r,n){return J(this,void 0,void 0,function*(){let a=n.requestId,o=n.timeout,s,c=()=>{};if(n.mode==="streaming"){let u=yield i.streamStatus(r,{requestId:a,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];o&&(s=setTimeout(()=>{throw u.abort(),i.cancel(r,{requestId:a}).catch(c),new Error(`Client timed out waiting for the request to complete after ${o}ms`)},o)),u.on("data",h=>{n.onQueueUpdate&&("logs"in h&&Array.isArray(h.logs)&&h.logs.length>0&&l.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:l}):h))});let d=yield u.done();return s&&clearTimeout(s),d}return new Promise((u,l)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:Lr,m=()=>{s&&clearTimeout(s),h&&clearTimeout(h)};o&&(s=setTimeout(()=>{m(),i.cancel(r,{requestId:a}).catch(c),l(new Error(`Client timed out waiting for the request to complete after ${o}ms`))},o));let y=()=>J(this,void 0,void 0,function*(){var w;try{let g=yield i.status(r,{requestId:a,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){m(),u(g);return}h=setTimeout(y,p)}catch(g){m(),l(g)}});y().catch(l)})})},result(r,n){return J(this,arguments,void 0,function*(a,{requestId:o,abortSignal:s}){let c=(0,nt.parseEndpointId)(a),u=c.namespace?`${c.namespace}/`:"";return(0,F.dispatchRequest)({method:"get",targetUrl:(0,F.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${o}`}),config:Object.assign(Object.assign({},t),{responseHandler:gg.resultResponseHandler}),options:{signal:s,retry:Fr}})})},cancel(r,n){return J(this,arguments,void 0,function*(a,{requestId:o,abortSignal:s}){let c=(0,nt.parseEndpointId)(a),u=c.namespace?`${c.namespace}/`:"";yield(0,F.dispatchRequest)({method:"put",targetUrl:(0,F.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${o}/cancel`}),config:t,options:{signal:s}})})}};return i};Y.createQueueClient=hg});var at=k(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.utf8Count=mg;z.utf8EncodeJs=Rr;z.utf8EncodeTE=qr;z.utf8Encode=_g;z.utf8DecodeJs=Vr;z.utf8DecodeTD=Hr;z.utf8Decode=kg;function mg(t){let e=t.length,i=0,r=0;for(;r<e;){let n=t.charCodeAt(r++);if(n&4294967168)if(!(n&4294965248))i+=2;else{if(n>=55296&&n<=56319&&r<e){let a=t.charCodeAt(r);(a&64512)===56320&&(++r,n=((n&1023)<<10)+(a&1023)+65536)}n&4294901760?i+=4:i+=3}else{i++;continue}}return i}function Rr(t,e,i){let r=t.length,n=i,a=0;for(;a<r;){let o=t.charCodeAt(a++);if(o&4294967168)if(!(o&4294965248))e[n++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&a<r){let s=t.charCodeAt(a);(s&64512)===56320&&(++a,o=((o&1023)<<10)+(s&1023)+65536)}o&4294901760?(e[n++]=o>>18&7|240,e[n++]=o>>12&63|128,e[n++]=o>>6&63|128):(e[n++]=o>>12&15|224,e[n++]=o>>6&63|128)}else{e[n++]=o;continue}e[n++]=o&63|128}}var yg=new TextEncoder,bg=50;function qr(t,e,i){yg.encodeInto(t,e.subarray(i))}function _g(t,e,i){t.length>bg?qr(t,e,i):Rr(t,e,i)}var vg=4096;function Vr(t,e,i){let r=e,n=r+i,a=[],o="";for(;r<n;){let s=t[r++];if(!(s&128))a.push(s);else if((s&224)===192){let c=t[r++]&63;a.push((s&31)<<6|c)}else if((s&240)===224){let c=t[r++]&63,u=t[r++]&63;a.push((s&31)<<12|c<<6|u)}else if((s&248)===240){let c=t[r++]&63,u=t[r++]&63,l=t[r++]&63,d=(s&7)<<18|c<<12|u<<6|l;d>65535&&(d-=65536,a.push(d>>>10&1023|55296),d=56320|d&1023),a.push(d)}else a.push(s);a.length>=vg&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var wg=new TextDecoder,xg=200;function Hr(t,e,i){let r=t.subarray(e,e+i);return wg.decode(r)}function kg(t,e,i){return i>xg?Hr(t,e,i):Vr(t,e,i)}});var Zt=k(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.ExtData=void 0;var Qt=class{constructor(e,i){this.type=e,this.data=i}};ot.ExtData=Qt});var lt=k(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.DecodeError=void 0;var Xt=class t extends Error{constructor(e){super(e);let i=Object.create(t.prototype);Object.setPrototypeOf(this,i),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};st.DecodeError=Xt});var ct=k(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.UINT32_MAX=void 0;W.setUint64=Sg;W.setInt64=Eg;W.getInt64=Ig;W.getUint64=Ag;W.UINT32_MAX=4294967295;function Sg(t,e,i){let r=i/4294967296,n=i;t.setUint32(e,r),t.setUint32(e+4,n)}function Eg(t,e,i){let r=Math.floor(i/4294967296),n=i;t.setUint32(e,r),t.setUint32(e+4,n)}function Ig(t,e){let i=t.getInt32(e),r=t.getUint32(e+4);return i*4294967296+r}function Ag(t,e){let i=t.getUint32(e),r=t.getUint32(e+4);return i*4294967296+r}});var Jt=k(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.timestampExtension=M.EXT_TIMESTAMP=void 0;M.encodeTimeSpecToTimestamp=Kr;M.encodeDateToTimeSpec=Yr;M.encodeTimestampExtension=Wr;M.decodeTimestampToTimeSpec=Qr;M.decodeTimestampExtension=Zr;var Cg=lt(),Gr=ct();M.EXT_TIMESTAMP=-1;var Tg=4294967296-1,Mg=17179869184-1;function Kr({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Mg)if(e===0&&t<=Tg){let i=new Uint8Array(4);return new DataView(i.buffer).setUint32(0,t),i}else{let i=t/4294967296,r=t&4294967295,n=new Uint8Array(8),a=new DataView(n.buffer);return a.setUint32(0,e<<2|i&3),a.setUint32(4,r),n}else{let i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,e),(0,Gr.setInt64)(r,4,t),i}}function Yr(t){let e=t.getTime(),i=Math.floor(e/1e3),r=(e-i*1e3)*1e6,n=Math.floor(r/1e9);return{sec:i+n,nsec:r-n*1e9}}function Wr(t){if(t instanceof Date){let e=Yr(t);return Kr(e)}else return null}function Qr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let i=e.getUint32(0),r=e.getUint32(4),n=(i&3)*4294967296+r,a=i>>>2;return{sec:n,nsec:a}}case 12:{let i=(0,Gr.getInt64)(e,4),r=e.getUint32(0);return{sec:i,nsec:r}}default:throw new Cg.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Zr(t){let e=Qr(t);return new Date(e.sec*1e3+e.nsec/1e6)}M.timestampExtension={type:M.EXT_TIMESTAMP,encode:Wr,decode:Zr}});var gt=k(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.ExtensionCodec=void 0;var ut=Zt(),Og=Jt(),Ue=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Og.timestampExtension)}register({type:e,encode:i,decode:r}){if(e>=0)this.encoders[e]=i,this.decoders[e]=r;else{let n=-1-e;this.builtInEncoders[n]=i,this.builtInDecoders[n]=r}}tryToEncode(e,i){for(let r=0;r<this.builtInEncoders.length;r++){let n=this.builtInEncoders[r];if(n!=null){let a=n(e,i);if(a!=null){let o=-1-r;return new ut.ExtData(o,a)}}}for(let r=0;r<this.encoders.length;r++){let n=this.encoders[r];if(n!=null){let a=n(e,i);if(a!=null){let o=r;return new ut.ExtData(o,a)}}}return e instanceof ut.ExtData?e:null}decode(e,i,r){let n=i<0?this.builtInDecoders[-1-i]:this.decoders[i];return n?n(e,i,r):new ut.ExtData(i,e)}};dt.ExtensionCodec=Ue;Ue.defaultCodec=new Ue});var ti=k(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.ensureUint8Array=jg;function $g(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function jg(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):$g(t)?new Uint8Array(t):Uint8Array.from(t)}});var ri=k(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.Encoder=U.DEFAULT_INITIAL_BUFFER_SIZE=U.DEFAULT_MAX_DEPTH=void 0;var Xr=at(),Dg=gt(),Jr=ct(),Pg=ti();U.DEFAULT_MAX_DEPTH=100;U.DEFAULT_INITIAL_BUFFER_SIZE=2048;var ii=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??Dg.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??U.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??U.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,i){if(i>this.maxDepth)throw new Error(`Too deep objects in depth ${i}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,i)}ensureBufferSizeToWrite(e){let i=this.pos+e;this.view.byteLength<i&&this.resizeBuffer(i*2)}resizeBuffer(e){let i=new ArrayBuffer(e),r=new Uint8Array(i),n=new DataView(i);r.set(this.bytes),this.view=n,this.bytes=r}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let r=(0,Xr.utf8Count)(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,Xr.utf8Encode)(e,this.bytes,this.pos),this.pos+=r}encodeObject(e,i){let r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,i);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,i);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let i=e.byteLength;if(i<256)this.writeU8(196),this.writeU8(i);else if(i<65536)this.writeU8(197),this.writeU16(i);else if(i<4294967296)this.writeU8(198),this.writeU32(i);else throw new Error(`Too large binary: ${i}`);let r=(0,Pg.ensureUint8Array)(e);this.writeU8a(r)}encodeArray(e,i){let r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let n of e)this.doEncode(n,i+1)}countWithoutUndefined(e,i){let r=0;for(let n of i)e[n]!==void 0&&r++;return r}encodeMap(e,i){let r=Object.keys(e);this.sortKeys&&r.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else if(n<4294967296)this.writeU8(223),this.writeU32(n);else throw new Error(`Too large map object: ${n}`);for(let a of r){let o=e[a];this.ignoreUndefined&&o===void 0||(this.encodeString(a),this.doEncode(o,i+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),n=r.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(r);return}let i=e.data.length;if(i===1)this.writeU8(212);else if(i===2)this.writeU8(213);else if(i===4)this.writeU8(214);else if(i===8)this.writeU8(215);else if(i===16)this.writeU8(216);else if(i<256)this.writeU8(199),this.writeU8(i);else if(i<65536)this.writeU8(200),this.writeU16(i);else if(i<4294967296)this.writeU8(201),this.writeU32(i);else throw new Error(`Too large extension object: ${i}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let i=e.length;this.ensureBufferSizeToWrite(i),this.bytes.set(e,this.pos),this.pos+=i}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Jr.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Jr.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};U.Encoder=ii});var en=k(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.encode=Ng;var Ug=ri();function Ng(t,e){return new Ug.Encoder(e).encodeSharedRef(t)}});var tn=k(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.prettyByte=Lg;function Lg(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var rn=k(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.CachedKeyDecoder=void 0;var Fg=at(),zg=16,Bg=16,oi=class{constructor(e=zg,i=Bg){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=i,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,i,r){let n=this.caches[r-1];e:for(let a of n){let o=a.bytes;for(let s=0;s<r;s++)if(o[s]!==e[i+s])continue e;return a.str}return null}store(e,i){let r=this.caches[e.length-1],n={bytes:e,str:i};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)}decode(e,i,r){let n=this.find(e,i,r);if(n!=null)return this.hit++,n;this.miss++;let a=(0,Fg.utf8DecodeJs)(e,i,r),o=Uint8Array.prototype.slice.call(e,i,i+r);return this.store(o,a),a}};pt.CachedKeyDecoder=oi});var ht=k(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.Decoder=void 0;var si=tn(),Rg=gt(),ee=ct(),qg=at(),nn=ti(),Vg=rn(),B=lt(),li="array",Le="map_key",on="map_value",Hg=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new B.DecodeError("The type of key must be string or number but "+typeof t)},ci=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let i=this.getUninitializedStateFromPool();i.type=li,i.position=0,i.size=e,i.array=new Array(e)}pushMapState(e){let i=this.getUninitializedStateFromPool();i.type=Le,i.readCount=0,i.size=e,i.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===li){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===Le||e.type===on){let r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Ne=-1,di=new DataView(new ArrayBuffer(0)),Gg=new Uint8Array(di.buffer);try{di.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var an=new RangeError("Insufficient data"),Kg=new Vg.CachedKeyDecoder,ui=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=di,this.bytes=Gg,this.headByte=Ne,this.stack=new ci,this.entered=!1,this.extensionCodec=e?.extensionCodec??Rg.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??ee.UINT32_MAX,this.maxBinLength=e?.maxBinLength??ee.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??ee.UINT32_MAX,this.maxMapLength=e?.maxMapLength??ee.UINT32_MAX,this.maxExtLength=e?.maxExtLength??ee.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Kg,this.mapKeyConverter=e?.mapKeyConverter??Hg}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ne,this.stack.reset()}setBuffer(e){let i=(0,nn.ensureUint8Array)(e);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Ne&&!this.hasRemaining(1))this.setBuffer(e);else{let i=this.bytes.subarray(this.pos),r=(0,nn.ensureUint8Array)(e),n=new Uint8Array(i.length+r.length);n.set(i),n.set(r,i.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:i,pos:r}=this;return new RangeError(`Extra ${i.byteLength-r} of ${i.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let i=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return i}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let i=!1,r;for await(let s of e){if(i)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(s);try{r=this.doDecodeSync(),i=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(i){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return r}let{headByte:n,pos:a,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${(0,si.prettyByte)(n)} at ${o} (${a} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,i){if(this.entered){yield*this.clone().decodeMultiAsync(e,i);return}try{this.entered=!0;let r=i,n=-1;for await(let a of e){if(i&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),r&&(n=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),i;if(e>=224)i=e-256;else if(e<192)if(e<128)i=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else{let n=e-160;i=this.decodeString(n,0)}else if(e===192)i=null;else if(e===194)i=!1;else if(e===195)i=!0;else if(e===202)i=this.readF32();else if(e===203)i=this.readF64();else if(e===204)i=this.readU8();else if(e===205)i=this.readU16();else if(e===206)i=this.readU32();else if(e===207)this.useBigInt64?i=this.readU64AsBigInt():i=this.readU64();else if(e===208)i=this.readI8();else if(e===209)i=this.readI16();else if(e===210)i=this.readI32();else if(e===211)this.useBigInt64?i=this.readI64AsBigInt():i=this.readI64();else if(e===217){let n=this.lookU8();i=this.decodeString(n,1)}else if(e===218){let n=this.lookU16();i=this.decodeString(n,2)}else if(e===219){let n=this.lookU32();i=this.decodeString(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(e===196){let n=this.lookU8();i=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();i=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();i=this.decodeBinary(n,4)}else if(e===212)i=this.decodeExtension(1,0);else if(e===213)i=this.decodeExtension(2,0);else if(e===214)i=this.decodeExtension(4,0);else if(e===215)i=this.decodeExtension(8,0);else if(e===216)i=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();i=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();i=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();i=this.decodeExtension(n,4)}else throw new B.DecodeError(`Unrecognized type byte: ${(0,si.prettyByte)(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===li)if(n.array[n.position]=i,n.position++,n.position===n.size)i=n.array,r.release(n);else continue e;else if(n.type===Le){if(i==="__proto__")throw new B.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=on;continue e}else if(n.map[n.key]=i,n.readCount++,n.readCount===n.size)i=n.map,r.release(n);else{n.key=null,n.type=Le;continue e}}return i}}readHeadByte(){return this.headByte===Ne&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ne}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new B.DecodeError(`Unrecognized array type byte: ${(0,si.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new B.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new B.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,i){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,i):this.decodeBinary(e,i)}decodeUtf8String(e,i){if(e>this.maxStrLength)throw new B.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+e)throw an;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,r,e):n=(0,qg.utf8Decode)(this.bytes,r,e),this.pos+=i+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Le:!1}decodeBinary(e,i){if(e>this.maxBinLength)throw new B.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+i))throw an;let r=this.pos+i,n=this.bytes.subarray(r,r+e);return this.pos+=i+e,n}decodeExtension(e,i){if(e>this.maxExtLength)throw new B.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+i),n=this.decodeBinary(e,i+1);return this.extensionCodec.decode(n,r,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,ee.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,ee.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};ft.Decoder=ui});var ln=k(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.decode=Yg;mt.decodeMulti=Wg;var sn=ht();function Yg(t,e){return new sn.Decoder(e).decode(t)}function Wg(t,e){return new sn.Decoder(e).decodeMulti(t)}});var dn=k(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.isAsyncIterable=cn;Fe.asyncIterableFromStream=un;Fe.ensureAsyncIterable=Qg;function cn(t){return t[Symbol.asyncIterator]!=null}async function*un(t){let e=t.getReader();try{for(;;){let{done:i,value:r}=await e.read();if(i)return;yield r}}finally{e.releaseLock()}}function Qg(t){return cn(t)?t:un(t)}});var gn=k(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.decodeAsync=Zg;ze.decodeArrayStream=Xg;ze.decodeMultiStream=Jg;var gi=ht(),pi=dn();async function Zg(t,e){let i=(0,pi.ensureAsyncIterable)(t);return new gi.Decoder(e).decodeAsync(i)}function Xg(t,e){let i=(0,pi.ensureAsyncIterable)(t);return new gi.Decoder(e).decodeArrayStream(i)}function Jg(t,e){let i=(0,pi.ensureAsyncIterable)(t);return new gi.Decoder(e).decodeStream(i)}});var fn=k(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.decodeTimestampExtension=x.encodeTimestampExtension=x.decodeTimestampToTimeSpec=x.encodeTimeSpecToTimestamp=x.encodeDateToTimeSpec=x.EXT_TIMESTAMP=x.ExtData=x.ExtensionCodec=x.Encoder=x.DecodeError=x.Decoder=x.decodeMultiStream=x.decodeArrayStream=x.decodeAsync=x.decodeMulti=x.decode=x.encode=void 0;var ep=en();Object.defineProperty(x,"encode",{enumerable:!0,get:function(){return ep.encode}});var pn=ln();Object.defineProperty(x,"decode",{enumerable:!0,get:function(){return pn.decode}});Object.defineProperty(x,"decodeMulti",{enumerable:!0,get:function(){return pn.decodeMulti}});var fi=gn();Object.defineProperty(x,"decodeAsync",{enumerable:!0,get:function(){return fi.decodeAsync}});Object.defineProperty(x,"decodeArrayStream",{enumerable:!0,get:function(){return fi.decodeArrayStream}});Object.defineProperty(x,"decodeMultiStream",{enumerable:!0,get:function(){return fi.decodeMultiStream}});var tp=ht();Object.defineProperty(x,"Decoder",{enumerable:!0,get:function(){return tp.Decoder}});var ip=lt();Object.defineProperty(x,"DecodeError",{enumerable:!0,get:function(){return ip.DecodeError}});var rp=ri();Object.defineProperty(x,"Encoder",{enumerable:!0,get:function(){return rp.Encoder}});var np=gt();Object.defineProperty(x,"ExtensionCodec",{enumerable:!0,get:function(){return np.ExtensionCodec}});var ap=Zt();Object.defineProperty(x,"ExtData",{enumerable:!0,get:function(){return ap.ExtData}});var _e=Jt();Object.defineProperty(x,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return _e.EXT_TIMESTAMP}});Object.defineProperty(x,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return _e.encodeDateToTimeSpec}});Object.defineProperty(x,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return _e.encodeTimeSpecToTimestamp}});Object.defineProperty(x,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return _e.decodeTimestampToTimeSpec}});Object.defineProperty(x,"encodeTimestampExtension",{enumerable:!0,get:function(){return _e.encodeTimestampExtension}});Object.defineProperty(x,"decodeTimestampExtension",{enumerable:!0,get:function(){return _e.decodeTimestampExtension}})});var Tn=k(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});function A(t){return{enumerable:!0,value:t}}function hn(t){return{enumerable:!0,writable:!0,value:t}}var te={},op=()=>!0,mn=()=>({}),bn=t=>t,sp=(t,e,i,r)=>t.apply(i,r)&&e.apply(i,r),lp=(t,e,i,[r,n])=>e.call(i,t.call(i,r,n),n),Q=(t,e)=>Object.freeze(Object.create(t,e));function yn(t,e,i){return t.reduce((r,n)=>function(...a){return i(r,n,this,a)},e)}function _n(t){return Q(this,{fn:A(t)})}var vn={},wn=_n.bind(vn),cp=t=>wn((e,i)=>!!~t(e,i)&&e),xn={},up=_n.bind(xn);function yt(t,e){return e.filter(i=>t.isPrototypeOf(i))}function kn(t,e,...i){let r=yn(yt(xn,i).map(a=>a.fn),op,sp),n=yn(yt(vn,i).map(a=>a.fn),bn,lp);return Q(this,{from:A(t),to:A(e),guards:A(r),reducers:A(n)})}var Sn={},En={},dp=kn.bind(Sn),gp=kn.bind(En,null);function pp(t,e,i){return mi(e,t,i,this.immediates)||t}function In(t){let e=new Map;for(let i of t)e.has(i.from)||e.set(i.from,[]),e.get(i.from).push(i);return e}var fp={enter:bn};function hp(...t){let e=yt(Sn,t),i=yt(En,t),r={final:A(t.length===0),transitions:A(In(e))};return i.length&&(r.immediates=A(i),r.enter=A(pp)),Q(fp,r)}var mp={enter(t,e,i){let r=this.fn.call(e,e.context,i);return hi.isPrototypeOf(r)?Q(An,{machine:A(r),transitions:A(this.transitions)}).enter(t,e,i):(r.then(n=>e.send({type:"done",data:n})).catch(n=>e.send({type:"error",error:n})),t)}},An={enter(t,e,i){if(e.child=Cn(this.machine,r=>{e.onChange(r),e.child==r&&r.machine.state.value.final&&(delete e.child,e.send({type:"done",data:r.context}))},e.context,i),e.child.machine.state.value.final){let r=e.child.context;return delete e.child,mi(e,t,{type:"done",data:r},this.transitions.get("done"))}return t}};function yp(t,...e){let i=A(In(e));return hi.isPrototypeOf(t)?Q(An,{machine:A(t),transitions:i}):Q(mp,{fn:A(t),transitions:i})}var hi={get state(){return{name:this.current,value:this.states[this.current]}}};function bp(t,e,i=mn){return typeof t!="string"&&(i=e||mn,e=t,t=Object.keys(e)[0]),te._create&&te._create(t,e),Q(hi,{context:A(i),current:A(t),states:A(e)})}function mi(t,e,i,r){let{context:n}=t;for(let{to:a,guards:o,reducers:s}of r)if(o(n,i)){t.context=s.call(t,n,i);let c=e.original||e,u=Q(c,{current:A(a),original:{value:c}});return te._onEnter&&te._onEnter(e,a,t.context,n,i),u.state.value.enter(u,t,i)}}function _p(t,e){let i=e.type||e,{machine:r}=t,{value:n,name:a}=r.state;return n.transitions.has(i)?mi(t,r,e,n.transitions.get(i))||r:(te._send&&te._send(i,a),r)}var vp={send(t){this.machine=_p(this,t),this.onChange(this)}};function Cn(t,e,i,r){let n=Object.create(vp,{machine:hn(t),context:hn(t.context(i,r)),onChange:A(e)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}O.action=cp;O.createMachine=bp;O.d=te;O.guard=up;O.immediate=gp;O.interpret=Cn;O.invoke=yp;O.reduce=wn;O.state=hp;O.transition=dp});var Dn=k(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.createRealtimeClient=Pp;var _t=fn(),b=Tn(),Mn=Kt(),yi=q(),On=tt(),vi=V(),wp=()=>({enqueuedMessage:void 0});function xp(t){return t.token!==void 0}function kp(t){return!xp(t)}function bt(t,e){return Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function R(t){return t.websocket&&t.websocket.readyState===WebSocket.OPEN&&t.websocket.close(),Object.assign(Object.assign({},t),{websocket:void 0})}function Sp(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,_t.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function bi(t){return Object.assign(Object.assign({},t),{token:void 0})}function Ep(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Ip(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var Ap=(0,b.createMachine)("idle",{idle:(0,b.state)((0,b.transition)("send","connecting",(0,b.reduce)(bt)),(0,b.transition)("expireToken","idle",(0,b.reduce)(bi)),(0,b.transition)("close","idle",(0,b.reduce)(R))),connecting:(0,b.state)((0,b.transition)("connecting","connecting"),(0,b.transition)("connected","active",(0,b.reduce)(Ip)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(R)),(0,b.transition)("send","connecting",(0,b.reduce)(bt)),(0,b.transition)("close","idle",(0,b.reduce)(R)),(0,b.immediate)("authRequired",(0,b.guard)(kp))),authRequired:(0,b.state)((0,b.transition)("initiateAuth","authInProgress"),(0,b.transition)("send","authRequired",(0,b.reduce)(bt)),(0,b.transition)("close","idle",(0,b.reduce)(R))),authInProgress:(0,b.state)((0,b.transition)("authenticated","connecting",(0,b.reduce)(Ep)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(bi),(0,b.reduce)(R)),(0,b.transition)("send","authInProgress",(0,b.reduce)(bt)),(0,b.transition)("close","idle",(0,b.reduce)(R))),active:(0,b.state)((0,b.transition)("send","active",(0,b.reduce)(Sp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(bi)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(R)),(0,b.transition)("close","idle",(0,b.reduce)(R))),failed:(0,b.state)((0,b.transition)("send","failed"),(0,b.transition)("close","idle",(0,b.reduce)(R)))},wp);function Cp(t,{token:e,maxBuffering:i}){if(i!==void 0&&(i<1||i>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let r=new URLSearchParams({fal_jwt_token:e});return i!==void 0&&r.set("max_buffering",i.toFixed(0)),`wss://fal.run/${(0,vi.ensureEndpointIdFormat)(t)}/realtime?${r.toString()}`}var Tp=128;function Mp(t){return t.status==="error"&&t.error==="Unauthorized"}var Op={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},_i=new Map,$n=new Map;function $p(t,e,i){if(!_i.has(t)){let r=(0,b.interpret)(Ap,i);_i.set(t,Object.assign(Object.assign({},r),{throttledSend:e>0?(0,vi.throttle)(r.send,e,!0):r.send}))}return _i.get(t)}var Be=()=>{},jp={send:Be,close:Be};function Dp(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!jn(t)}function jn(t){return t.type==="x-fal-error"}function Pp({config:t}){return{connect(e,i){let{clientOnly:r=(0,vi.isReact)()&&!(0,On.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:a,throttleInterval:o=Tp}=i;if(r&&!(0,On.isBrowser)())return jp;let s;$n.set(n,{onError:i.onError,onResult:i.onResult});let c=()=>$n.get(n),u=$p(n,o,({context:h,machine:p,send:m})=>{let{enqueuedMessage:y,token:w}=h;if(p.current==="active"&&y&&m({type:"send",message:y}),p.current==="authRequired"&&w===void 0&&s!==p.current&&(m({type:"initiateAuth"}),(0,Mn.getTemporaryAuthToken)(e,t).then(g=>{m({type:"authenticated",token:g});let f=Math.round(Mn.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{m({type:"expireToken"})},f)}).catch(g=>{m({type:"unauthorized",error:g})})),p.current==="connecting"&&s!==p.current&&w!==void 0){let g=new WebSocket(Cp(e,{token:w,maxBuffering:a}));g.onopen=()=>{m({type:"connected",websocket:g})},g.onclose=f=>{if(f.code!==Op.NORMAL_CLOSURE){let{onError:v=Be}=c();v(new yi.ApiError({message:`Error closing the connection: ${f.reason}`,status:f.code}))}m({type:"connectionClosed",code:f.code})},g.onerror=f=>{let{onError:v=Be}=c();v(new yi.ApiError({message:"Unknown error",status:500}))},g.onmessage=f=>{let{onResult:v}=c();if(f.data instanceof ArrayBuffer){let C=(0,_t.decode)(new Uint8Array(f.data));v(C);return}if(f.data instanceof Uint8Array){let C=(0,_t.decode)(f.data);v(C);return}if(f.data instanceof Blob){f.data.arrayBuffer().then(C=>{let xt=(0,_t.decode)(new Uint8Array(C));v(xt)});return}let _=JSON.parse(f.data);if(Mp(_)){m({type:"unauthorized",error:new Error("Unauthorized")});return}if(Dp(_)){v(_);return}if(jn(_)){if(_.error==="TIMEOUT")return;let{onError:C=Be}=c();C(new yi.ApiError({message:`${_.error}: ${_.reason}`,status:400,body:_}));return}}}s=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var Fn=k(Re=>{"use strict";var ie=Re&&Re.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(Re,"__esModule",{value:!0});Re.createStorageClient=zp;var Pn=it(),Un=me(),Up=V();function Nn(t){var e;let[i,r]=t.split("/");return(e=r.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function Np(t,e,i){return ie(this,void 0,void 0,function*(){let r=t.name||`${Date.now()}.${Nn(i)}`;return yield(0,Un.dispatchRequest)({method:"POST",targetUrl:`${(0,Pn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:e})})}function Lp(t,e,i){return ie(this,void 0,void 0,function*(){let r=t.name||`${Date.now()}.${Nn(i)}`;return yield(0,Un.dispatchRequest)({method:"POST",targetUrl:`${(0,Pn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:e})})}function Ln(t,e,i){return ie(this,arguments,void 0,function*(r,n,a,o=3){if(o===0)throw new Error("Part upload failed, retries exhausted");let{fetch:s,responseHandler:c}=a;try{let u=yield s(r,{method:"PUT",body:n});return yield c(u)}catch{return yield Ln(r,n,a,o-1)}})}function Fp(t,e){return ie(this,void 0,void 0,function*(){let{fetch:i,responseHandler:r}=e,n=t.type||"application/octet-stream",{upload_url:a,file_url:o}=yield Lp(t,e,n),s=10*1024*1024,c=Math.ceil(t.size/s),u=new URL(a),l=[];for(let p=0;p<c;p++){let m=p*s,y=Math.min(m+s,t.size),w=t.slice(m,y),g=p+1,f=`${u.origin}${u.pathname}/${g}${u.search}`;l.push(yield Ln(f,w,e))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield i(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield r(h),o})}function zp({config:t}){let e={upload:i=>ie(this,void 0,void 0,function*(){if(i.size>94371840)return yield Fp(i,t);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:a}=t,{upload_url:o,file_url:s}=yield Np(i,t,r),c=yield n(o,{method:"PUT",body:i,headers:{"Content-Type":i.type||"application/octet-stream"}});return yield a(c),s}),transformInput:i=>ie(this,void 0,void 0,function*(){if(Array.isArray(i))return Promise.all(i.map(r=>e.transformInput(r)));if(i instanceof Blob)return yield e.upload(i);if((0,Up.isPlainObject)(i)){let n=Object.entries(i).map(o=>ie(this,[o],void 0,function*([s,c]){return[s,yield e.transformInput(c)]})),a=yield Promise.all(n);return Object.fromEntries(a)}return i})};return e}});var xi=k(qe=>{"use strict";var zn=qe&&qe.__awaiter||function(t,e,i,r){function n(a){return a instanceof i?a:new i(function(o){o(a)})}return new(i||(i=Promise))(function(a,o){function s(l){try{u(r.next(l))}catch(d){o(d)}}function c(l){try{u(r.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(qe,"__esModule",{value:!0});qe.createFalClient=Kp;var Bp=it(),Rp=Br(),qp=Dn(),Bn=me(),Vp=q(),Hp=Fn(),Gp=Wt();function Kp(t={}){let e=(0,Bp.createConfig)(t),i=(0,Hp.createStorageClient)({config:e}),r=(0,Rp.createQueueClient)({config:e,storage:i}),n=(0,Gp.createStreamingClient)({config:e,storage:i}),a=(0,qp.createRealtimeClient)({config:e});return{queue:r,realtime:a,storage:i,streaming:n,stream:n.stream,run(o){return zn(this,arguments,void 0,function*(s,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,Bn.dispatchRequest)({method:c.method,targetUrl:(0,Bn.buildUrl)(s,c),input:u,config:Object.assign(Object.assign({},e),{responseHandler:Vp.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(o,s)=>zn(this,void 0,void 0,function*(){let{request_id:c}=yield r.submit(o,s);return s.onEnqueue&&s.onEnqueue(c),yield r.subscribeToStatus(o,Object.assign({requestId:c},s)),r.result(o,{requestId:c})})}}});var qn=k(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.isQueueStatus=Rn;vt.isCompletedQueueStatus=Yp;function Rn(t){return t&&t.status&&t.response_url}function Yp(t){return Rn(t)&&t.status==="COMPLETED"}});var Kn=k(I=>{"use strict";var Wp=I&&I.__createBinding||(Object.create?function(t,e,i,r){r===void 0&&(r=i);var n=Object.getOwnPropertyDescriptor(e,i);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,r,n)}:function(t,e,i,r){r===void 0&&(r=i),t[r]=e[i]}),Qp=I&&I.__exportStar||function(t,e){for(var i in t)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&Wp(e,t,i)};Object.defineProperty(I,"__esModule",{value:!0});I.fal=I.parseEndpointId=I.isRetryableError=I.ValidationError=I.ApiError=I.withProxy=I.withMiddleware=I.createFalClient=void 0;var Vn=xi(),Zp=xi();Object.defineProperty(I,"createFalClient",{enumerable:!0,get:function(){return Zp.createFalClient}});var Hn=qt();Object.defineProperty(I,"withMiddleware",{enumerable:!0,get:function(){return Hn.withMiddleware}});Object.defineProperty(I,"withProxy",{enumerable:!0,get:function(){return Hn.withProxy}});var Gn=q();Object.defineProperty(I,"ApiError",{enumerable:!0,get:function(){return Gn.ApiError}});Object.defineProperty(I,"ValidationError",{enumerable:!0,get:function(){return Gn.ValidationError}});var Xp=De();Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return Xp.isRetryableError}});Qp(qn(),I);var Jp=V();Object.defineProperty(I,"parseEndpointId",{enumerable:!0,get:function(){return Jp.parseEndpointId}});I.fal=function(){let e=(0,Vn.createFalClient)();return{config(i){e=(0,Vn.createFalClient)(i)},get queue(){return e.queue},get realtime(){return e.realtime},get storage(){return e.storage},get streaming(){return e.streaming},run(i,r){return e.run(i,r)},subscribe(i,r){return e.subscribe(i,r)},stream(i,r){return e.stream(i,r)}}}()});var sa=`
|
|
5
|
+
`;else if(w==="event")a=_;else if(w==="id"&&!_.includes("\0"))o=_;else if(w==="retry"){let C=parseInt(_,10);Number.isNaN(C)||t({type:"reconnect-interval",value:C})}}}var Pr=[239,187,191];function eg(t){return Pr.every((e,i)=>t.charCodeAt(i)===e)}Gt.createParser=Jd});var Kt=x(K=>{"use strict";var tg=K&&K.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(K,"__esModule",{value:!0});K.TOKEN_EXPIRATION_SECONDS=void 0;K.getTemporaryAuthToken=og;var ig=it(),rg=me(),ng=V();K.TOKEN_EXPIRATION_SECONDS=120;function og(t,e){return tg(this,void 0,void 0,function*(){let i=(0,ng.parseEndpointId)(t),r=yield(0,rg.dispatchRequest)({method:"POST",targetUrl:`${(0,ig.getRestApiUrl)()}/tokens/`,config:e,input:{allowed_apps:[i.alias],token_expiration:K.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var Wt=x(O=>{"use strict";var be=O&&O.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})},Pe=O&&O.__await||function(t){return this instanceof Pe?(this.v=t,this):new Pe(t)},ag=O&&O.__asyncGenerator||function(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(t,e||[]),n,o=[];return n={},s("next"),s("throw"),s("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(p){return function(m){return Promise.resolve(m).then(p,d)}}function s(p,m){r[p]&&(n[p]=function(y){return new Promise(function(w,g){o.push([p,y,w,g])>1||c(p,y)})},m&&(n[p]=m(n[p])))}function c(p,m){try{u(r[p](m))}catch(y){h(o[0][3],y)}}function u(p){p.value instanceof Pe?Promise.resolve(p.value.v).then(l,d):h(o[0][2],p)}function l(p){c("next",p)}function d(p){c("throw",p)}function h(p,m){p(m),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty(O,"__esModule",{value:!0});O.FalStream=void 0;O.createStreamingClient=ug;var sg=Ur(),lg=Kt(),Nr=me(),ye=q(),Yt="text/event-stream",cg=15*1e3,rt=class{constructor(e,i,r){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this._requestId=null,this.abortController=new AbortController,this.start=()=>be(this,void 0,void 0,function*(){var o,a;let{endpointId:s,options:c}=this,{input:u,method:l="post",connectionMode:d="server"}=c;try{if(d==="client"){let h=yield(0,lg.getTemporaryAuthToken)(s,this.config),{fetch:p}=this.config,m=new URL(this.url);m.searchParams.set("fal_jwt_token",h);let y=yield p(m.toString(),{method:l.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:Yt,"content-type":"application/json"},body:u&&l!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return this._requestId=y.headers.get("x-fal-request-id"),yield this.handleResponse(y)}return yield(0,Nr.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:Yt},responseHandler:h=>be(this,void 0,void 0,function*(){return this._requestId=h.headers.get("x-fal-request-id"),yield this.handleResponse(h)}),signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>be(this,void 0,void 0,function*(){var a,s;if(!o.ok){try{yield(0,ye.defaultResponseHandler)(o)}catch(y){this.emit("error",y)}return}let c=o.body;if(!c){this.emit("error",new ye.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((a=o.headers.get("content-type"))!==null&&a!==void 0?a:"").startsWith(Yt)){let y=c.getReader(),w=()=>{y.read().then(({done:g,value:f})=>{if(g){this.emit("done",this.currentData);return}this.currentData=f,this.emit("data",f),w()})};w();return}let l=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,sg.createParser)(y=>{if(y.type==="event"){let w=y.data;try{let g=JSON.parse(w);this.buffer.push(g),this.currentData=g,this.emit("data",g),this.emit("message",g)}catch(g){this.emit("error",g)}}}),p=(s=this.options.timeout)!==null&&s!==void 0?s:cg,m=()=>be(this,void 0,void 0,function*(){let{value:y,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(l.decode(y)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new ye.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):m().catch(this.handleError)});m().catch(this.handleError)}),this.handleError=o=>{var a;if(o.name==="AbortError"||this.signal.aborted)return;let s=o instanceof ye.ApiError?o:new ye.ApiError({message:(a=o.message)!==null&&a!==void 0?a:"An unknown error occurred",status:500});this.emit("error",s)},this.on=(o,a)=>{var s;this.listeners.has(o)||this.listeners.set(o,[]),(s=this.listeners.get(o))===null||s===void 0||s.push(a)},this.emit=(o,a)=>{let s=this.listeners.get(o)||[];for(let c of s)c(a)},this.done=()=>be(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=e,this.config=i,this.url=(n=r.url)!==null&&n!==void 0?n:(0,Nr.buildUrl)(e,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new ye.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var s;o((s=this.currentData)!==null&&s!==void 0?s:{})}),this.on("done",s=>{this.streamClosed=!0,o(s)}),this.on("error",s=>{this.streamClosed=!0,a(s)})}),r.signal&&r.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return ag(this,arguments,function*(){let i=!0,r=()=>i=!1;for(this.on("error",r),this.on("done",r);i||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield Pe(n)),yield Pe(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};O.FalStream=rt;function ug({config:t,storage:e}){return{stream(i,r){return be(this,void 0,void 0,function*(){let n=r.input?yield e.transformInput(r.input):void 0;return new rt(i,t,Object.assign(Object.assign({},r),{input:n}))})}}}});var Br=x(Y=>{"use strict";var J=Y&&Y.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})},dg=Y&&Y.__rest||function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]]);return i};Object.defineProperty(Y,"__esModule",{value:!0});Y.createQueueClient=void 0;var F=me(),gg=q(),zr=De(),pg=Wt(),nt=V(),Lr=500,Fr={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:zr.DEFAULT_RETRYABLE_STATUS_CODES},fg={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...zr.DEFAULT_RETRYABLE_STATUS_CODES,500]},hg=({config:t,storage:e})=>{let i={submit(r,n){return J(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a,hint:s}=n,c=dg(n,["webhookUrl","priority","hint"]),u=n.input?yield e.transformInput(n.input):void 0;return(0,F.dispatchRequest)({method:n.method,targetUrl:(0,F.buildUrl)(r,Object.assign(Object.assign({},c),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:Object.assign({"x-fal-queue-priority":a??"normal"},s&&{"x-fal-runner-hint":s}),input:u,config:t,options:{signal:n.abortSignal,retry:Fr}})})},status(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,logs:s=!1,abortSignal:c}){let u=(0,nt.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"";return(0,F.dispatchRequest)({method:"get",targetUrl:(0,F.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:s?"1":"0"},path:`/requests/${a}/status`}),config:t,options:{signal:c,retry:fg}})})},streamStatus(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,logs:s=!1,connectionMode:c}){let u=(0,nt.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"",d={logs:s?"1":"0"},h=(0,F.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new pg.FalStream(o,t,{url:h,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(r,n){return J(this,void 0,void 0,function*(){let o=n.requestId,a=n.timeout,s,c=()=>{};if(n.mode==="streaming"){let u=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];a&&(s=setTimeout(()=>{throw u.abort(),i.cancel(r,{requestId:o}).catch(c),new Error(`Client timed out waiting for the request to complete after ${a}ms`)},a)),u.on("data",h=>{n.onQueueUpdate&&("logs"in h&&Array.isArray(h.logs)&&h.logs.length>0&&l.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:l}):h))});let d=yield u.done();return s&&clearTimeout(s),d}return new Promise((u,l)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:Lr,m=()=>{s&&clearTimeout(s),h&&clearTimeout(h)};a&&(s=setTimeout(()=>{m(),i.cancel(r,{requestId:o}).catch(c),l(new Error(`Client timed out waiting for the request to complete after ${a}ms`))},a));let y=()=>J(this,void 0,void 0,function*(){var w;try{let g=yield i.status(r,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){m(),u(g);return}h=setTimeout(y,p)}catch(g){m(),l(g)}});y().catch(l)})})},result(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,nt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,F.dispatchRequest)({method:"get",targetUrl:(0,F.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},t),{responseHandler:gg.resultResponseHandler}),options:{signal:s,retry:Fr}})})},cancel(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,nt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,F.dispatchRequest)({method:"put",targetUrl:(0,F.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:t,options:{signal:s}})})}};return i};Y.createQueueClient=hg});var ot=x(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.utf8Count=mg;z.utf8EncodeJs=Rr;z.utf8EncodeTE=qr;z.utf8Encode=_g;z.utf8DecodeJs=Vr;z.utf8DecodeTD=Hr;z.utf8Decode=xg;function mg(t){let e=t.length,i=0,r=0;for(;r<e;){let n=t.charCodeAt(r++);if(n&4294967168)if(!(n&4294965248))i+=2;else{if(n>=55296&&n<=56319&&r<e){let o=t.charCodeAt(r);(o&64512)===56320&&(++r,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?i+=4:i+=3}else{i++;continue}}return i}function Rr(t,e,i){let r=t.length,n=i,o=0;for(;o<r;){let a=t.charCodeAt(o++);if(a&4294967168)if(!(a&4294965248))e[n++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&o<r){let s=t.charCodeAt(o);(s&64512)===56320&&(++o,a=((a&1023)<<10)+(s&1023)+65536)}a&4294901760?(e[n++]=a>>18&7|240,e[n++]=a>>12&63|128,e[n++]=a>>6&63|128):(e[n++]=a>>12&15|224,e[n++]=a>>6&63|128)}else{e[n++]=a;continue}e[n++]=a&63|128}}var yg=new TextEncoder,bg=50;function qr(t,e,i){yg.encodeInto(t,e.subarray(i))}function _g(t,e,i){t.length>bg?qr(t,e,i):Rr(t,e,i)}var vg=4096;function Vr(t,e,i){let r=e,n=r+i,o=[],a="";for(;r<n;){let s=t[r++];if(!(s&128))o.push(s);else if((s&224)===192){let c=t[r++]&63;o.push((s&31)<<6|c)}else if((s&240)===224){let c=t[r++]&63,u=t[r++]&63;o.push((s&31)<<12|c<<6|u)}else if((s&248)===240){let c=t[r++]&63,u=t[r++]&63,l=t[r++]&63,d=(s&7)<<18|c<<12|u<<6|l;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(s);o.length>=vg&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var wg=new TextDecoder,kg=200;function Hr(t,e,i){let r=t.subarray(e,e+i);return wg.decode(r)}function xg(t,e,i){return i>kg?Hr(t,e,i):Vr(t,e,i)}});var Zt=x(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.ExtData=void 0;var Qt=class{constructor(e,i){this.type=e,this.data=i}};at.ExtData=Qt});var lt=x(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.DecodeError=void 0;var Xt=class t extends Error{constructor(e){super(e);let i=Object.create(t.prototype);Object.setPrototypeOf(this,i),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};st.DecodeError=Xt});var ct=x(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.UINT32_MAX=void 0;W.setUint64=Sg;W.setInt64=Eg;W.getInt64=Ig;W.getUint64=Ag;W.UINT32_MAX=4294967295;function Sg(t,e,i){let r=i/4294967296,n=i;t.setUint32(e,r),t.setUint32(e+4,n)}function Eg(t,e,i){let r=Math.floor(i/4294967296),n=i;t.setUint32(e,r),t.setUint32(e+4,n)}function Ig(t,e){let i=t.getInt32(e),r=t.getUint32(e+4);return i*4294967296+r}function Ag(t,e){let i=t.getUint32(e),r=t.getUint32(e+4);return i*4294967296+r}});var Jt=x(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.timestampExtension=M.EXT_TIMESTAMP=void 0;M.encodeTimeSpecToTimestamp=Kr;M.encodeDateToTimeSpec=Yr;M.encodeTimestampExtension=Wr;M.decodeTimestampToTimeSpec=Qr;M.decodeTimestampExtension=Zr;var Cg=lt(),Gr=ct();M.EXT_TIMESTAMP=-1;var Tg=4294967296-1,Mg=17179869184-1;function Kr({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Mg)if(e===0&&t<=Tg){let i=new Uint8Array(4);return new DataView(i.buffer).setUint32(0,t),i}else{let i=t/4294967296,r=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,e<<2|i&3),o.setUint32(4,r),n}else{let i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,e),(0,Gr.setInt64)(r,4,t),i}}function Yr(t){let e=t.getTime(),i=Math.floor(e/1e3),r=(e-i*1e3)*1e6,n=Math.floor(r/1e9);return{sec:i+n,nsec:r-n*1e9}}function Wr(t){if(t instanceof Date){let e=Yr(t);return Kr(e)}else return null}function Qr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let i=e.getUint32(0),r=e.getUint32(4),n=(i&3)*4294967296+r,o=i>>>2;return{sec:n,nsec:o}}case 12:{let i=(0,Gr.getInt64)(e,4),r=e.getUint32(0);return{sec:i,nsec:r}}default:throw new Cg.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Zr(t){let e=Qr(t);return new Date(e.sec*1e3+e.nsec/1e6)}M.timestampExtension={type:M.EXT_TIMESTAMP,encode:Wr,decode:Zr}});var gt=x(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.ExtensionCodec=void 0;var ut=Zt(),$g=Jt(),Ue=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register($g.timestampExtension)}register({type:e,encode:i,decode:r}){if(e>=0)this.encoders[e]=i,this.decoders[e]=r;else{let n=-1-e;this.builtInEncoders[n]=i,this.builtInDecoders[n]=r}}tryToEncode(e,i){for(let r=0;r<this.builtInEncoders.length;r++){let n=this.builtInEncoders[r];if(n!=null){let o=n(e,i);if(o!=null){let a=-1-r;return new ut.ExtData(a,o)}}}for(let r=0;r<this.encoders.length;r++){let n=this.encoders[r];if(n!=null){let o=n(e,i);if(o!=null){let a=r;return new ut.ExtData(a,o)}}}return e instanceof ut.ExtData?e:null}decode(e,i,r){let n=i<0?this.builtInDecoders[-1-i]:this.decoders[i];return n?n(e,i,r):new ut.ExtData(i,e)}};dt.ExtensionCodec=Ue;Ue.defaultCodec=new Ue});var ti=x(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.ensureUint8Array=Og;function jg(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function Og(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):jg(t)?new Uint8Array(t):Uint8Array.from(t)}});var ri=x(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.Encoder=U.DEFAULT_INITIAL_BUFFER_SIZE=U.DEFAULT_MAX_DEPTH=void 0;var Xr=ot(),Dg=gt(),Jr=ct(),Pg=ti();U.DEFAULT_MAX_DEPTH=100;U.DEFAULT_INITIAL_BUFFER_SIZE=2048;var ii=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??Dg.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??U.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??U.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,i){if(i>this.maxDepth)throw new Error(`Too deep objects in depth ${i}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,i)}ensureBufferSizeToWrite(e){let i=this.pos+e;this.view.byteLength<i&&this.resizeBuffer(i*2)}resizeBuffer(e){let i=new ArrayBuffer(e),r=new Uint8Array(i),n=new DataView(i);r.set(this.bytes),this.view=n,this.bytes=r}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let r=(0,Xr.utf8Count)(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,Xr.utf8Encode)(e,this.bytes,this.pos),this.pos+=r}encodeObject(e,i){let r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,i);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,i);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let i=e.byteLength;if(i<256)this.writeU8(196),this.writeU8(i);else if(i<65536)this.writeU8(197),this.writeU16(i);else if(i<4294967296)this.writeU8(198),this.writeU32(i);else throw new Error(`Too large binary: ${i}`);let r=(0,Pg.ensureUint8Array)(e);this.writeU8a(r)}encodeArray(e,i){let r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let n of e)this.doEncode(n,i+1)}countWithoutUndefined(e,i){let r=0;for(let n of i)e[n]!==void 0&&r++;return r}encodeMap(e,i){let r=Object.keys(e);this.sortKeys&&r.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else if(n<4294967296)this.writeU8(223),this.writeU32(n);else throw new Error(`Too large map object: ${n}`);for(let o of r){let a=e[o];this.ignoreUndefined&&a===void 0||(this.encodeString(o),this.doEncode(a,i+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),n=r.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(r);return}let i=e.data.length;if(i===1)this.writeU8(212);else if(i===2)this.writeU8(213);else if(i===4)this.writeU8(214);else if(i===8)this.writeU8(215);else if(i===16)this.writeU8(216);else if(i<256)this.writeU8(199),this.writeU8(i);else if(i<65536)this.writeU8(200),this.writeU16(i);else if(i<4294967296)this.writeU8(201),this.writeU32(i);else throw new Error(`Too large extension object: ${i}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let i=e.length;this.ensureBufferSizeToWrite(i),this.bytes.set(e,this.pos),this.pos+=i}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Jr.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Jr.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};U.Encoder=ii});var en=x(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.encode=Ng;var Ug=ri();function Ng(t,e){return new Ug.Encoder(e).encodeSharedRef(t)}});var tn=x(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});oi.prettyByte=Lg;function Lg(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var rn=x(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.CachedKeyDecoder=void 0;var Fg=ot(),zg=16,Bg=16,ai=class{constructor(e=zg,i=Bg){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=i,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,i,r){let n=this.caches[r-1];e:for(let o of n){let a=o.bytes;for(let s=0;s<r;s++)if(a[s]!==e[i+s])continue e;return o.str}return null}store(e,i){let r=this.caches[e.length-1],n={bytes:e,str:i};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)}decode(e,i,r){let n=this.find(e,i,r);if(n!=null)return this.hit++,n;this.miss++;let o=(0,Fg.utf8DecodeJs)(e,i,r),a=Uint8Array.prototype.slice.call(e,i,i+r);return this.store(a,o),o}};pt.CachedKeyDecoder=ai});var ht=x(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.Decoder=void 0;var si=tn(),Rg=gt(),ee=ct(),qg=ot(),nn=ti(),Vg=rn(),B=lt(),li="array",Le="map_key",an="map_value",Hg=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new B.DecodeError("The type of key must be string or number but "+typeof t)},ci=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let i=this.getUninitializedStateFromPool();i.type=li,i.position=0,i.size=e,i.array=new Array(e)}pushMapState(e){let i=this.getUninitializedStateFromPool();i.type=Le,i.readCount=0,i.size=e,i.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===li){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===Le||e.type===an){let r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Ne=-1,di=new DataView(new ArrayBuffer(0)),Gg=new Uint8Array(di.buffer);try{di.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var on=new RangeError("Insufficient data"),Kg=new Vg.CachedKeyDecoder,ui=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=di,this.bytes=Gg,this.headByte=Ne,this.stack=new ci,this.entered=!1,this.extensionCodec=e?.extensionCodec??Rg.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??ee.UINT32_MAX,this.maxBinLength=e?.maxBinLength??ee.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??ee.UINT32_MAX,this.maxMapLength=e?.maxMapLength??ee.UINT32_MAX,this.maxExtLength=e?.maxExtLength??ee.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Kg,this.mapKeyConverter=e?.mapKeyConverter??Hg}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ne,this.stack.reset()}setBuffer(e){let i=(0,nn.ensureUint8Array)(e);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Ne&&!this.hasRemaining(1))this.setBuffer(e);else{let i=this.bytes.subarray(this.pos),r=(0,nn.ensureUint8Array)(e),n=new Uint8Array(i.length+r.length);n.set(i),n.set(r,i.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:i,pos:r}=this;return new RangeError(`Extra ${i.byteLength-r} of ${i.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let i=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return i}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let i=!1,r;for await(let s of e){if(i)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(s);try{r=this.doDecodeSync(),i=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(i){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return r}let{headByte:n,pos:o,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${(0,si.prettyByte)(n)} at ${a} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,i){if(this.entered){yield*this.clone().decodeMultiAsync(e,i);return}try{this.entered=!0;let r=i,n=-1;for await(let o of e){if(i&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),r&&(n=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),i;if(e>=224)i=e-256;else if(e<192)if(e<128)i=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else{let n=e-160;i=this.decodeString(n,0)}else if(e===192)i=null;else if(e===194)i=!1;else if(e===195)i=!0;else if(e===202)i=this.readF32();else if(e===203)i=this.readF64();else if(e===204)i=this.readU8();else if(e===205)i=this.readU16();else if(e===206)i=this.readU32();else if(e===207)this.useBigInt64?i=this.readU64AsBigInt():i=this.readU64();else if(e===208)i=this.readI8();else if(e===209)i=this.readI16();else if(e===210)i=this.readI32();else if(e===211)this.useBigInt64?i=this.readI64AsBigInt():i=this.readI64();else if(e===217){let n=this.lookU8();i=this.decodeString(n,1)}else if(e===218){let n=this.lookU16();i=this.decodeString(n,2)}else if(e===219){let n=this.lookU32();i=this.decodeString(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(e===196){let n=this.lookU8();i=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();i=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();i=this.decodeBinary(n,4)}else if(e===212)i=this.decodeExtension(1,0);else if(e===213)i=this.decodeExtension(2,0);else if(e===214)i=this.decodeExtension(4,0);else if(e===215)i=this.decodeExtension(8,0);else if(e===216)i=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();i=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();i=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();i=this.decodeExtension(n,4)}else throw new B.DecodeError(`Unrecognized type byte: ${(0,si.prettyByte)(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===li)if(n.array[n.position]=i,n.position++,n.position===n.size)i=n.array,r.release(n);else continue e;else if(n.type===Le){if(i==="__proto__")throw new B.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=an;continue e}else if(n.map[n.key]=i,n.readCount++,n.readCount===n.size)i=n.map,r.release(n);else{n.key=null,n.type=Le;continue e}}return i}}readHeadByte(){return this.headByte===Ne&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ne}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new B.DecodeError(`Unrecognized array type byte: ${(0,si.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new B.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new B.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,i){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,i):this.decodeBinary(e,i)}decodeUtf8String(e,i){if(e>this.maxStrLength)throw new B.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+e)throw on;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,r,e):n=(0,qg.utf8Decode)(this.bytes,r,e),this.pos+=i+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Le:!1}decodeBinary(e,i){if(e>this.maxBinLength)throw new B.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+i))throw on;let r=this.pos+i,n=this.bytes.subarray(r,r+e);return this.pos+=i+e,n}decodeExtension(e,i){if(e>this.maxExtLength)throw new B.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+i),n=this.decodeBinary(e,i+1);return this.extensionCodec.decode(n,r,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,ee.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,ee.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};ft.Decoder=ui});var ln=x(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.decode=Yg;mt.decodeMulti=Wg;var sn=ht();function Yg(t,e){return new sn.Decoder(e).decode(t)}function Wg(t,e){return new sn.Decoder(e).decodeMulti(t)}});var dn=x(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.isAsyncIterable=cn;Fe.asyncIterableFromStream=un;Fe.ensureAsyncIterable=Qg;function cn(t){return t[Symbol.asyncIterator]!=null}async function*un(t){let e=t.getReader();try{for(;;){let{done:i,value:r}=await e.read();if(i)return;yield r}}finally{e.releaseLock()}}function Qg(t){return cn(t)?t:un(t)}});var gn=x(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.decodeAsync=Zg;ze.decodeArrayStream=Xg;ze.decodeMultiStream=Jg;var gi=ht(),pi=dn();async function Zg(t,e){let i=(0,pi.ensureAsyncIterable)(t);return new gi.Decoder(e).decodeAsync(i)}function Xg(t,e){let i=(0,pi.ensureAsyncIterable)(t);return new gi.Decoder(e).decodeArrayStream(i)}function Jg(t,e){let i=(0,pi.ensureAsyncIterable)(t);return new gi.Decoder(e).decodeStream(i)}});var fn=x(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.decodeTimestampExtension=k.encodeTimestampExtension=k.decodeTimestampToTimeSpec=k.encodeTimeSpecToTimestamp=k.encodeDateToTimeSpec=k.EXT_TIMESTAMP=k.ExtData=k.ExtensionCodec=k.Encoder=k.DecodeError=k.Decoder=k.decodeMultiStream=k.decodeArrayStream=k.decodeAsync=k.decodeMulti=k.decode=k.encode=void 0;var ep=en();Object.defineProperty(k,"encode",{enumerable:!0,get:function(){return ep.encode}});var pn=ln();Object.defineProperty(k,"decode",{enumerable:!0,get:function(){return pn.decode}});Object.defineProperty(k,"decodeMulti",{enumerable:!0,get:function(){return pn.decodeMulti}});var fi=gn();Object.defineProperty(k,"decodeAsync",{enumerable:!0,get:function(){return fi.decodeAsync}});Object.defineProperty(k,"decodeArrayStream",{enumerable:!0,get:function(){return fi.decodeArrayStream}});Object.defineProperty(k,"decodeMultiStream",{enumerable:!0,get:function(){return fi.decodeMultiStream}});var tp=ht();Object.defineProperty(k,"Decoder",{enumerable:!0,get:function(){return tp.Decoder}});var ip=lt();Object.defineProperty(k,"DecodeError",{enumerable:!0,get:function(){return ip.DecodeError}});var rp=ri();Object.defineProperty(k,"Encoder",{enumerable:!0,get:function(){return rp.Encoder}});var np=gt();Object.defineProperty(k,"ExtensionCodec",{enumerable:!0,get:function(){return np.ExtensionCodec}});var op=Zt();Object.defineProperty(k,"ExtData",{enumerable:!0,get:function(){return op.ExtData}});var _e=Jt();Object.defineProperty(k,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return _e.EXT_TIMESTAMP}});Object.defineProperty(k,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return _e.encodeDateToTimeSpec}});Object.defineProperty(k,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return _e.encodeTimeSpecToTimestamp}});Object.defineProperty(k,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return _e.decodeTimestampToTimeSpec}});Object.defineProperty(k,"encodeTimestampExtension",{enumerable:!0,get:function(){return _e.encodeTimestampExtension}});Object.defineProperty(k,"decodeTimestampExtension",{enumerable:!0,get:function(){return _e.decodeTimestampExtension}})});var Tn=x($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});function A(t){return{enumerable:!0,value:t}}function hn(t){return{enumerable:!0,writable:!0,value:t}}var te={},ap=()=>!0,mn=()=>({}),bn=t=>t,sp=(t,e,i,r)=>t.apply(i,r)&&e.apply(i,r),lp=(t,e,i,[r,n])=>e.call(i,t.call(i,r,n),n),Q=(t,e)=>Object.freeze(Object.create(t,e));function yn(t,e,i){return t.reduce((r,n)=>function(...o){return i(r,n,this,o)},e)}function _n(t){return Q(this,{fn:A(t)})}var vn={},wn=_n.bind(vn),cp=t=>wn((e,i)=>!!~t(e,i)&&e),kn={},up=_n.bind(kn);function yt(t,e){return e.filter(i=>t.isPrototypeOf(i))}function xn(t,e,...i){let r=yn(yt(kn,i).map(o=>o.fn),ap,sp),n=yn(yt(vn,i).map(o=>o.fn),bn,lp);return Q(this,{from:A(t),to:A(e),guards:A(r),reducers:A(n)})}var Sn={},En={},dp=xn.bind(Sn),gp=xn.bind(En,null);function pp(t,e,i){return mi(e,t,i,this.immediates)||t}function In(t){let e=new Map;for(let i of t)e.has(i.from)||e.set(i.from,[]),e.get(i.from).push(i);return e}var fp={enter:bn};function hp(...t){let e=yt(Sn,t),i=yt(En,t),r={final:A(t.length===0),transitions:A(In(e))};return i.length&&(r.immediates=A(i),r.enter=A(pp)),Q(fp,r)}var mp={enter(t,e,i){let r=this.fn.call(e,e.context,i);return hi.isPrototypeOf(r)?Q(An,{machine:A(r),transitions:A(this.transitions)}).enter(t,e,i):(r.then(n=>e.send({type:"done",data:n})).catch(n=>e.send({type:"error",error:n})),t)}},An={enter(t,e,i){if(e.child=Cn(this.machine,r=>{e.onChange(r),e.child==r&&r.machine.state.value.final&&(delete e.child,e.send({type:"done",data:r.context}))},e.context,i),e.child.machine.state.value.final){let r=e.child.context;return delete e.child,mi(e,t,{type:"done",data:r},this.transitions.get("done"))}return t}};function yp(t,...e){let i=A(In(e));return hi.isPrototypeOf(t)?Q(An,{machine:A(t),transitions:i}):Q(mp,{fn:A(t),transitions:i})}var hi={get state(){return{name:this.current,value:this.states[this.current]}}};function bp(t,e,i=mn){return typeof t!="string"&&(i=e||mn,e=t,t=Object.keys(e)[0]),te._create&&te._create(t,e),Q(hi,{context:A(i),current:A(t),states:A(e)})}function mi(t,e,i,r){let{context:n}=t;for(let{to:o,guards:a,reducers:s}of r)if(a(n,i)){t.context=s.call(t,n,i);let c=e.original||e,u=Q(c,{current:A(o),original:{value:c}});return te._onEnter&&te._onEnter(e,o,t.context,n,i),u.state.value.enter(u,t,i)}}function _p(t,e){let i=e.type||e,{machine:r}=t,{value:n,name:o}=r.state;return n.transitions.has(i)?mi(t,r,e,n.transitions.get(i))||r:(te._send&&te._send(i,o),r)}var vp={send(t){this.machine=_p(this,t),this.onChange(this)}};function Cn(t,e,i,r){let n=Object.create(vp,{machine:hn(t),context:hn(t.context(i,r)),onChange:A(e)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}$.action=cp;$.createMachine=bp;$.d=te;$.guard=up;$.immediate=gp;$.interpret=Cn;$.invoke=yp;$.reduce=wn;$.state=hp;$.transition=dp});var Dn=x(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.createRealtimeClient=Pp;var _t=fn(),b=Tn(),Mn=Kt(),yi=q(),$n=tt(),vi=V(),wp=()=>({enqueuedMessage:void 0});function kp(t){return t.token!==void 0}function xp(t){return!kp(t)}function bt(t,e){return Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function R(t){return t.websocket&&t.websocket.readyState===WebSocket.OPEN&&t.websocket.close(),Object.assign(Object.assign({},t),{websocket:void 0})}function Sp(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,_t.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function bi(t){return Object.assign(Object.assign({},t),{token:void 0})}function Ep(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Ip(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var Ap=(0,b.createMachine)("idle",{idle:(0,b.state)((0,b.transition)("send","connecting",(0,b.reduce)(bt)),(0,b.transition)("expireToken","idle",(0,b.reduce)(bi)),(0,b.transition)("close","idle",(0,b.reduce)(R))),connecting:(0,b.state)((0,b.transition)("connecting","connecting"),(0,b.transition)("connected","active",(0,b.reduce)(Ip)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(R)),(0,b.transition)("send","connecting",(0,b.reduce)(bt)),(0,b.transition)("close","idle",(0,b.reduce)(R)),(0,b.immediate)("authRequired",(0,b.guard)(xp))),authRequired:(0,b.state)((0,b.transition)("initiateAuth","authInProgress"),(0,b.transition)("send","authRequired",(0,b.reduce)(bt)),(0,b.transition)("close","idle",(0,b.reduce)(R))),authInProgress:(0,b.state)((0,b.transition)("authenticated","connecting",(0,b.reduce)(Ep)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(bi),(0,b.reduce)(R)),(0,b.transition)("send","authInProgress",(0,b.reduce)(bt)),(0,b.transition)("close","idle",(0,b.reduce)(R))),active:(0,b.state)((0,b.transition)("send","active",(0,b.reduce)(Sp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(bi)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(R)),(0,b.transition)("close","idle",(0,b.reduce)(R))),failed:(0,b.state)((0,b.transition)("send","failed"),(0,b.transition)("close","idle",(0,b.reduce)(R)))},wp);function Cp(t,{token:e,maxBuffering:i}){if(i!==void 0&&(i<1||i>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let r=new URLSearchParams({fal_jwt_token:e});return i!==void 0&&r.set("max_buffering",i.toFixed(0)),`wss://fal.run/${(0,vi.ensureEndpointIdFormat)(t)}/realtime?${r.toString()}`}var Tp=128;function Mp(t){return t.status==="error"&&t.error==="Unauthorized"}var $p={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},_i=new Map,jn=new Map;function jp(t,e,i){if(!_i.has(t)){let r=(0,b.interpret)(Ap,i);_i.set(t,Object.assign(Object.assign({},r),{throttledSend:e>0?(0,vi.throttle)(r.send,e,!0):r.send}))}return _i.get(t)}var Be=()=>{},Op={send:Be,close:Be};function Dp(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!On(t)}function On(t){return t.type==="x-fal-error"}function Pp({config:t}){return{connect(e,i){let{clientOnly:r=(0,vi.isReact)()&&!(0,$n.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:a=Tp}=i;if(r&&!(0,$n.isBrowser)())return Op;let s;jn.set(n,{onError:i.onError,onResult:i.onResult});let c=()=>jn.get(n),u=jp(n,a,({context:h,machine:p,send:m})=>{let{enqueuedMessage:y,token:w}=h;if(p.current==="active"&&y&&m({type:"send",message:y}),p.current==="authRequired"&&w===void 0&&s!==p.current&&(m({type:"initiateAuth"}),(0,Mn.getTemporaryAuthToken)(e,t).then(g=>{m({type:"authenticated",token:g});let f=Math.round(Mn.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{m({type:"expireToken"})},f)}).catch(g=>{m({type:"unauthorized",error:g})})),p.current==="connecting"&&s!==p.current&&w!==void 0){let g=new WebSocket(Cp(e,{token:w,maxBuffering:o}));g.onopen=()=>{m({type:"connected",websocket:g})},g.onclose=f=>{if(f.code!==$p.NORMAL_CLOSURE){let{onError:v=Be}=c();v(new yi.ApiError({message:`Error closing the connection: ${f.reason}`,status:f.code}))}m({type:"connectionClosed",code:f.code})},g.onerror=f=>{let{onError:v=Be}=c();v(new yi.ApiError({message:"Unknown error",status:500}))},g.onmessage=f=>{let{onResult:v}=c();if(f.data instanceof ArrayBuffer){let C=(0,_t.decode)(new Uint8Array(f.data));v(C);return}if(f.data instanceof Uint8Array){let C=(0,_t.decode)(f.data);v(C);return}if(f.data instanceof Blob){f.data.arrayBuffer().then(C=>{let kt=(0,_t.decode)(new Uint8Array(C));v(kt)});return}let _=JSON.parse(f.data);if(Mp(_)){m({type:"unauthorized",error:new Error("Unauthorized")});return}if(Dp(_)){v(_);return}if(On(_)){if(_.error==="TIMEOUT")return;let{onError:C=Be}=c();C(new yi.ApiError({message:`${_.error}: ${_.reason}`,status:400,body:_}));return}}}s=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var Fn=x(Re=>{"use strict";var ie=Re&&Re.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(Re,"__esModule",{value:!0});Re.createStorageClient=zp;var Pn=it(),Un=me(),Up=V();function Nn(t){var e;let[i,r]=t.split("/");return(e=r.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function Np(t,e,i){return ie(this,void 0,void 0,function*(){let r=t.name||`${Date.now()}.${Nn(i)}`;return yield(0,Un.dispatchRequest)({method:"POST",targetUrl:`${(0,Pn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:e})})}function Lp(t,e,i){return ie(this,void 0,void 0,function*(){let r=t.name||`${Date.now()}.${Nn(i)}`;return yield(0,Un.dispatchRequest)({method:"POST",targetUrl:`${(0,Pn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:e})})}function Ln(t,e,i){return ie(this,arguments,void 0,function*(r,n,o,a=3){if(a===0)throw new Error("Part upload failed, retries exhausted");let{fetch:s,responseHandler:c}=o;try{let u=yield s(r,{method:"PUT",body:n});return yield c(u)}catch{return yield Ln(r,n,o,a-1)}})}function Fp(t,e){return ie(this,void 0,void 0,function*(){let{fetch:i,responseHandler:r}=e,n=t.type||"application/octet-stream",{upload_url:o,file_url:a}=yield Lp(t,e,n),s=10*1024*1024,c=Math.ceil(t.size/s),u=new URL(o),l=[];for(let p=0;p<c;p++){let m=p*s,y=Math.min(m+s,t.size),w=t.slice(m,y),g=p+1,f=`${u.origin}${u.pathname}/${g}${u.search}`;l.push(yield Ln(f,w,e))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield i(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield r(h),a})}function zp({config:t}){let e={upload:i=>ie(this,void 0,void 0,function*(){if(i.size>94371840)return yield Fp(i,t);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:o}=t,{upload_url:a,file_url:s}=yield Np(i,t,r),c=yield n(a,{method:"PUT",body:i,headers:{"Content-Type":i.type||"application/octet-stream"}});return yield o(c),s}),transformInput:i=>ie(this,void 0,void 0,function*(){if(Array.isArray(i))return Promise.all(i.map(r=>e.transformInput(r)));if(i instanceof Blob)return yield e.upload(i);if((0,Up.isPlainObject)(i)){let n=Object.entries(i).map(a=>ie(this,[a],void 0,function*([s,c]){return[s,yield e.transformInput(c)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return i})};return e}});var ki=x(qe=>{"use strict";var zn=qe&&qe.__awaiter||function(t,e,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(qe,"__esModule",{value:!0});qe.createFalClient=Kp;var Bp=it(),Rp=Br(),qp=Dn(),Bn=me(),Vp=q(),Hp=Fn(),Gp=Wt();function Kp(t={}){let e=(0,Bp.createConfig)(t),i=(0,Hp.createStorageClient)({config:e}),r=(0,Rp.createQueueClient)({config:e,storage:i}),n=(0,Gp.createStreamingClient)({config:e,storage:i}),o=(0,qp.createRealtimeClient)({config:e});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return zn(this,arguments,void 0,function*(s,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,Bn.dispatchRequest)({method:c.method,targetUrl:(0,Bn.buildUrl)(s,c),input:u,config:Object.assign(Object.assign({},e),{responseHandler:Vp.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(a,s)=>zn(this,void 0,void 0,function*(){let{request_id:c}=yield r.submit(a,s);return s.onEnqueue&&s.onEnqueue(c),yield r.subscribeToStatus(a,Object.assign({requestId:c},s)),r.result(a,{requestId:c})})}}});var qn=x(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.isQueueStatus=Rn;vt.isCompletedQueueStatus=Yp;function Rn(t){return t&&t.status&&t.response_url}function Yp(t){return Rn(t)&&t.status==="COMPLETED"}});var Kn=x(I=>{"use strict";var Wp=I&&I.__createBinding||(Object.create?function(t,e,i,r){r===void 0&&(r=i);var n=Object.getOwnPropertyDescriptor(e,i);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,r,n)}:function(t,e,i,r){r===void 0&&(r=i),t[r]=e[i]}),Qp=I&&I.__exportStar||function(t,e){for(var i in t)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&Wp(e,t,i)};Object.defineProperty(I,"__esModule",{value:!0});I.fal=I.parseEndpointId=I.isRetryableError=I.ValidationError=I.ApiError=I.withProxy=I.withMiddleware=I.createFalClient=void 0;var Vn=ki(),Zp=ki();Object.defineProperty(I,"createFalClient",{enumerable:!0,get:function(){return Zp.createFalClient}});var Hn=qt();Object.defineProperty(I,"withMiddleware",{enumerable:!0,get:function(){return Hn.withMiddleware}});Object.defineProperty(I,"withProxy",{enumerable:!0,get:function(){return Hn.withProxy}});var Gn=q();Object.defineProperty(I,"ApiError",{enumerable:!0,get:function(){return Gn.ApiError}});Object.defineProperty(I,"ValidationError",{enumerable:!0,get:function(){return Gn.ValidationError}});var Xp=De();Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return Xp.isRetryableError}});Qp(qn(),I);var Jp=V();Object.defineProperty(I,"parseEndpointId",{enumerable:!0,get:function(){return Jp.parseEndpointId}});I.fal=function(){let e=(0,Vn.createFalClient)();return{config(i){e=(0,Vn.createFalClient)(i)},get queue(){return e.queue},get realtime(){return e.realtime},get storage(){return e.storage},get streaming(){return e.streaming},run(i,r){return e.run(i,r)},subscribe(i,r){return e.subscribe(i,r)},stream(i,r){return e.stream(i,r)}}}()});var so=`
|
|
6
6
|
<svg>
|
|
7
7
|
<symbol
|
|
8
8
|
fill="none"
|
|
@@ -68,7 +68,7 @@ var ea=Object.create;var Si=Object.defineProperty;var ta=Object.getOwnPropertyDe
|
|
|
68
68
|
<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"/>
|
|
69
69
|
</symbol>
|
|
70
70
|
</svg>
|
|
71
|
-
`,Fi=class{constructor(t,e=[],i){this.id=t,this.translateLabel=i?.translateLabel,this.assets=e.map(r=>{if(typeof r.label=="string"&&!(r.label&&typeof r.label=="object")){let n=r;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return r}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(t){let{page:e,perPage:i,locale:r="en",sortActiveFirst:n,query:a,tags:o,groups:s,excludeGroups:c,sortingOrder:u,sortKey:l}=t,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(g=>g.groups&&s.some(f=>g.groups?.includes(f)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(f=>g.groups?.includes(f)))),a){let g=a.toLowerCase();d=d.filter(f=>{let v=f.label?.[r]?.toLowerCase(),_=f.tags?.[r]||[];return v&&v.includes(g)||_.some(C=>C.toLowerCase().includes(g))})}if(o&&o.length>0){let g=Array.isArray(o)?o:[o];d=d.filter(f=>{let v=f.tags?.[r]||[];return g.some(_=>v.includes(_))})}n&&d.sort((g,f)=>{let v=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(f.id);return v&&!_?-1:!v&&_?1:0}),l&&l!=="id"?d.sort((g,f)=>{let v=g.meta?.[l],_=f.meta?.[l];return v===void 0?1:_===void 0?-1:typeof v=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(v):v.localeCompare(_):typeof v=="number"&&typeof _=="number"?u==="Descending"?_-v:v-_:0}):l==="id"&&d.sort((g,f)=>u==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=d.length,p=e*i,m=p+i,y=d.slice(p,m).map(g=>{let f=g.label?.[r]||"",v=this.translateLabel?this.translateLabel(g.id,f,r):f;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:v,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),w=m<h?e+1:void 0;return{assets:y,currentPage:e,nextPage:w,total:h}}updateLabel(t,e,i){this.assets.forEach(r=>{r.id===t&&(r.label=r.label||{},r.label[i]=e)})}getAssetSelectValue(t){let e=this.assets.find(({id:i})=>i===t);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}getActiveSelectValue(){let t=this.getActiveAssetIds();if(t.length>0){let e=this.assets.find(({id:i})=>i===t[0]);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}}getTranslatedLabel(t){let e=this.assets.find(({id:i})=>i===t);if(e)return this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||""}getAsset(t){return this.assets.find(e=>e.id===t)}setAssetActive(t){this.activeAssetIds.add(t)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(t){t.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(t){this.activeAssetIds.delete(t)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(t){return this.activeAssetIds.has(t)}addAsset(t){let e=this.assets.findIndex(i=>i.id===t.id);e>=0?this.assets[e]=t:this.assets.push(t)}removeAsset(t){let e=this.assets.findIndex(i=>i.id===t);e!==-1&&(this.assets.splice(e,1),this.activeAssetIds.delete(t))}async getGroups(){let t=new Set;return this.assets.forEach(e=>{e.groups&&e.groups.forEach(i=>t.add(i))}),Array.from(t)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var la=typeof global=="object"&&global&&global.Object===Object&&global,zi=la,ca=typeof self=="object"&&self&&self.Object===Object&&self,ua=zi||ca||Function("return this")(),N=ua,da=N.Symbol,ne=da,Bi=Object.prototype,ga=Bi.hasOwnProperty,pa=Bi.toString,we=ne?ne.toStringTag:void 0;function fa(t){var e=ga.call(t,we),i=t[we];try{t[we]=void 0;var r=!0}catch{}var n=pa.call(t);return r&&(e?t[we]=i:delete t[we]),n}var ha=fa,ma=Object.prototype,ya=ma.toString;function ba(t){return ya.call(t)}var _a=ba,va="[object Null]",wa="[object Undefined]",Ei=ne?ne.toStringTag:void 0;function xa(t){return t==null?t===void 0?wa:va:Ei&&Ei in Object(t)?ha(t):_a(t)}var Ee=xa;function ka(t){return t!=null&&typeof t=="object"}var Ot=ka,sf=Array.isArray;function Sa(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Ri=Sa,Ea="[object AsyncFunction]",Ia="[object Function]",Aa="[object GeneratorFunction]",Ca="[object Proxy]";function Ta(t){if(!Ri(t))return!1;var e=Ee(t);return e==Ia||e==Aa||e==Ea||e==Ca}var Ma=Ta,Oa=N["__core-js_shared__"],St=Oa,Ii=function(){var t=/[^.]+$/.exec(St&&St.keys&&St.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function $a(t){return!!Ii&&Ii in t}var ja=$a,Da=Function.prototype,Pa=Da.toString;function Ua(t){if(t!=null){try{return Pa.call(t)}catch{}try{return t+""}catch{}}return""}var Z=Ua,Na=/[\\^$.*+?()[\]{}|]/g,La=/^\[object .+?Constructor\]$/,Fa=Function.prototype,za=Object.prototype,Ba=Fa.toString,Ra=za.hasOwnProperty,qa=RegExp("^"+Ba.call(Ra).replace(Na,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Va(t){if(!Ri(t)||ja(t))return!1;var e=Ma(t)?qa:La;return e.test(Z(t))}var Ha=Va;function Ga(t,e){return t?.[e]}var Ka=Ga;function Ya(t,e){var i=Ka(t,e);return Ha(i)?i:void 0}var ae=Ya,Wa=ae(N,"WeakMap"),It=Wa;function Qa(t,e){return t===e||t!==t&&e!==e}var Za=Qa,Xa=9007199254740991;function Ja(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Xa}var eo=Ja;var lf=Object.prototype;var to="[object Arguments]";function io(t){return Ot(t)&&Ee(t)==to}var Ai=io,qi=Object.prototype,ro=qi.hasOwnProperty,no=qi.propertyIsEnumerable,cf=Ai(function(){return arguments}())?Ai:function(t){return Ot(t)&&ro.call(t,"callee")&&!no.call(t,"callee")};var Vi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ci=Vi&&typeof module=="object"&&module&&!module.nodeType&&module,ao=Ci&&Ci.exports===Vi,Ti=ao?N.Buffer:void 0,uf=Ti?Ti.isBuffer:void 0;var oo="[object Arguments]",so="[object Array]",lo="[object Boolean]",co="[object Date]",uo="[object Error]",go="[object Function]",po="[object Map]",fo="[object Number]",ho="[object Object]",mo="[object RegExp]",yo="[object Set]",bo="[object String]",_o="[object WeakMap]",vo="[object ArrayBuffer]",wo="[object DataView]",xo="[object Float32Array]",ko="[object Float64Array]",So="[object Int8Array]",Eo="[object Int16Array]",Io="[object Int32Array]",Ao="[object Uint8Array]",Co="[object Uint8ClampedArray]",To="[object Uint16Array]",Mo="[object Uint32Array]",S={};S[xo]=S[ko]=S[So]=S[Eo]=S[Io]=S[Ao]=S[Co]=S[To]=S[Mo]=!0;S[oo]=S[so]=S[vo]=S[lo]=S[wo]=S[co]=S[uo]=S[go]=S[po]=S[fo]=S[ho]=S[mo]=S[yo]=S[bo]=S[_o]=!1;function Oo(t){return Ot(t)&&eo(t.length)&&!!S[Ee(t)]}var $o=Oo;function jo(t){return function(e){return t(e)}}var Do=jo,Hi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xe=Hi&&typeof module=="object"&&module&&!module.nodeType&&module,Po=xe&&xe.exports===Hi,Et=Po&&zi.process,Uo=function(){try{var t=xe&&xe.require&&xe.require("util").types;return t||Et&&Et.binding&&Et.binding("util")}catch{}}(),Mi=Uo,Oi=Mi&&Mi.isTypedArray,df=Oi?Do(Oi):$o;var No=Object.prototype,gf=No.hasOwnProperty;function Lo(t,e){return function(i){return t(e(i))}}var Fo=Lo,pf=Fo(Object.keys,Object);var zo=Object.prototype,ff=zo.hasOwnProperty;var Bo=ae(Object,"create"),ke=Bo;function Ro(){this.__data__=ke?ke(null):{},this.size=0}var qo=Ro;function Vo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ho=Vo,Go="__lodash_hash_undefined__",Ko=Object.prototype,Yo=Ko.hasOwnProperty;function Wo(t){var e=this.__data__;if(ke){var i=e[t];return i===Go?void 0:i}return Yo.call(e,t)?e[t]:void 0}var Qo=Wo,Zo=Object.prototype,Xo=Zo.hasOwnProperty;function Jo(t){var e=this.__data__;return ke?e[t]!==void 0:Xo.call(e,t)}var es=Jo,ts="__lodash_hash_undefined__";function is(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=ke&&e===void 0?ts:e,this}var rs=is;function oe(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}oe.prototype.clear=qo;oe.prototype.delete=Ho;oe.prototype.get=Qo;oe.prototype.has=es;oe.prototype.set=rs;var $i=oe;function ns(){this.__data__=[],this.size=0}var as=ns;function os(t,e){for(var i=t.length;i--;)if(Za(t[i][0],e))return i;return-1}var Ve=os,ss=Array.prototype,ls=ss.splice;function cs(t){var e=this.__data__,i=Ve(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():ls.call(e,i,1),--this.size,!0}var us=cs;function ds(t){var e=this.__data__,i=Ve(e,t);return i<0?void 0:e[i][1]}var gs=ds;function ps(t){return Ve(this.__data__,t)>-1}var fs=ps;function hs(t,e){var i=this.__data__,r=Ve(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}var ms=hs;function se(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}se.prototype.clear=as;se.prototype.delete=us;se.prototype.get=gs;se.prototype.has=fs;se.prototype.set=ms;var He=se,ys=ae(N,"Map"),Se=ys;function bs(){this.size=0,this.__data__={hash:new $i,map:new(Se||He),string:new $i}}var _s=bs;function vs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ws=vs;function xs(t,e){var i=t.__data__;return ws(e)?i[typeof e=="string"?"string":"hash"]:i.map}var Ge=xs;function ks(t){var e=Ge(this,t).delete(t);return this.size-=e?1:0,e}var Ss=ks;function Es(t){return Ge(this,t).get(t)}var Is=Es;function As(t){return Ge(this,t).has(t)}var Cs=As;function Ts(t,e){var i=Ge(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}var Ms=Ts;function le(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}le.prototype.clear=_s;le.prototype.delete=Ss;le.prototype.get=Is;le.prototype.has=Cs;le.prototype.set=Ms;var Gi=le;function Os(){this.__data__=new He,this.size=0}var $s=Os;function js(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}var Ds=js;function Ps(t){return this.__data__.get(t)}var Us=Ps;function Ns(t){return this.__data__.has(t)}var Ls=Ns,Fs=200;function zs(t,e){var i=this.__data__;if(i instanceof He){var r=i.__data__;if(!Se||r.length<Fs-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new Gi(r)}return i.set(t,e),this.size=i.size,this}var Bs=zs;function Ie(t){var e=this.__data__=new He(t);this.size=e.size}Ie.prototype.clear=$s;Ie.prototype.delete=Ds;Ie.prototype.get=Us;Ie.prototype.has=Ls;Ie.prototype.set=Bs;var Rs=Object.prototype,hf=Rs.propertyIsEnumerable;var qs=ae(N,"DataView"),At=qs,Vs=ae(N,"Promise"),Ct=Vs,Hs=ae(N,"Set"),Tt=Hs,ji="[object Map]",Gs="[object Object]",Di="[object Promise]",Pi="[object Set]",Ui="[object WeakMap]",Ni="[object DataView]",Ks=Z(At),Ys=Z(Se),Ws=Z(Ct),Qs=Z(Tt),Zs=Z(It),re=Ee;(At&&re(new At(new ArrayBuffer(1)))!=Ni||Se&&re(new Se)!=ji||Ct&&re(Ct.resolve())!=Di||Tt&&re(new Tt)!=Pi||It&&re(new It)!=Ui)&&(re=function(t){var e=Ee(t),i=e==Gs?t.constructor:void 0,r=i?Z(i):"";if(r)switch(r){case Ks:return Ni;case Ys:return ji;case Ws:return Di;case Qs:return Pi;case Zs:return Ui}return e});var mf=N.Uint8Array;var Xs="__lodash_hash_undefined__";function Js(t){return this.__data__.set(t,Xs),this}var el=Js;function tl(t){return this.__data__.has(t)}var il=tl;function Mt(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new Gi;++e<i;)this.add(t[e])}Mt.prototype.add=Mt.prototype.push=el;Mt.prototype.has=il;var Li=ne?ne.prototype:void 0,yf=Li?Li.valueOf:void 0;var rl=Object.prototype,bf=rl.hasOwnProperty;var nl=Object.prototype,_f=nl.hasOwnProperty;var vf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),wf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),xf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function $t(t){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[t]??"png"}var Ki={Formats:sa};function al(t,e){let{cesdk:i}=e,r=e.propertyKey??"image_url",n=Ut(t);return i.i18n.setTranslations({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."}}),ol(t,i),{[r]:(a,o)=>{let{builder:s,experimental:{global:c},payload:u}=a,l,d=a.providerConfig,h=a.config,p=d?.properties?.[o.id]??h?.properties?.[o.id];p?.default&&(typeof p.default=="function"?l=p.default({}):l=p.default);let m=l??u?.url??e.defaultUrl,y=c(`${t}.${o.id}`,m);return s.MediaPreview(o.id,{preview:{type:"image",uri:y.value},action:{label:"ly.img.ai.imageSelection.selectImage.label",onClick:()=>{i?.ui.openPanel(n,{payload:{onSelect:w=>{w.meta?.uri!=null&&y.setValue(w.meta?.uri)}}})}}}),()=>({id:o.id,type:"string",value:y.value})}}}function ol(t,e){e?.ui.registerPanel(Ut(t),({builder:i,payload:r})=>{i.Library(`${t}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let a=n?.meta?.uri;if(a==null)return;let o=await e.engine.editor.getMimeType(a);o==="image/svg+xml"?e.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.svg"}):o.startsWith("image/")?(r?.onSelect(n),e?.ui.closePanel(Ut(t))):e.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function Ut(t){return`ly.img.ai.${t}.imageSelection`}var sl=al,ll=class{constructor(t,e=[],i){this.id=t,this.translateLabel=i?.translateLabel,this.assets=e.map(r=>{if(typeof r.label=="string"&&!(r.label&&typeof r.label=="object")){let n=r;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return r}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(t){let{page:e,perPage:i,locale:r="en",sortActiveFirst:n,query:a,tags:o,groups:s,excludeGroups:c,sortingOrder:u,sortKey:l}=t,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(g=>g.groups&&s.some(f=>g.groups?.includes(f)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(f=>g.groups?.includes(f)))),a){let g=a.toLowerCase();d=d.filter(f=>{let v=f.label?.[r]?.toLowerCase(),_=f.tags?.[r]||[];return v&&v.includes(g)||_.some(C=>C.toLowerCase().includes(g))})}if(o&&o.length>0){let g=Array.isArray(o)?o:[o];d=d.filter(f=>{let v=f.tags?.[r]||[];return g.some(_=>v.includes(_))})}n&&d.sort((g,f)=>{let v=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(f.id);return v&&!_?-1:!v&&_?1:0}),l&&l!=="id"?d.sort((g,f)=>{let v=g.meta?.[l],_=f.meta?.[l];return v===void 0?1:_===void 0?-1:typeof v=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(v):v.localeCompare(_):typeof v=="number"&&typeof _=="number"?u==="Descending"?_-v:v-_:0}):l==="id"&&d.sort((g,f)=>u==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=d.length,p=e*i,m=p+i,y=d.slice(p,m).map(g=>{let f=g.label?.[r]||"",v=this.translateLabel?this.translateLabel(g.id,f,r):f;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:v,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),w=m<h?e+1:void 0;return{assets:y,currentPage:e,nextPage:w,total:h}}updateLabel(t,e,i){this.assets.forEach(r=>{r.id===t&&(r.label=r.label||{},r.label[i]=e)})}getAssetSelectValue(t){let e=this.assets.find(({id:i})=>i===t);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}getActiveSelectValue(){let t=this.getActiveAssetIds();if(t.length>0){let e=this.assets.find(({id:i})=>i===t[0]);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}}getTranslatedLabel(t){let e=this.assets.find(({id:i})=>i===t);if(e)return this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||""}getAsset(t){return this.assets.find(e=>e.id===t)}setAssetActive(t){this.activeAssetIds.add(t)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(t){t.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(t){this.activeAssetIds.delete(t)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(t){return this.activeAssetIds.has(t)}addAsset(t){let e=this.assets.findIndex(i=>i.id===t.id);e>=0?this.assets[e]=t:this.assets.push(t)}removeAsset(t){let e=this.assets.findIndex(i=>i.id===t);e!==-1&&(this.assets.splice(e,1),this.activeAssetIds.delete(t))}async getGroups(){let t=new Set;return this.assets.forEach(e=>{e.groups&&e.groups.forEach(i=>t.add(i))}),Array.from(t)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var cl=typeof global=="object"&&global&&global.Object===Object&&global,cr=cl,ul=typeof self=="object"&&self&&self.Object===Object&&self,dl=cr||ul||Function("return this")(),L=dl,gl=L.Symbol,ue=gl,ur=Object.prototype,pl=ur.hasOwnProperty,fl=ur.toString,Ae=ue?ue.toStringTag:void 0;function hl(t){var e=pl.call(t,Ae),i=t[Ae];try{t[Ae]=void 0;var r=!0}catch{}var n=fl.call(t);return r&&(e?t[Ae]=i:delete t[Ae]),n}var ml=hl,yl=Object.prototype,bl=yl.toString;function _l(t){return bl.call(t)}var vl=_l,wl="[object Null]",xl="[object Undefined]",Yi=ue?ue.toStringTag:void 0;function kl(t){return t==null?t===void 0?xl:wl:Yi&&Yi in Object(t)?ml(t):vl(t)}var Oe=kl;function Sl(t){return t!=null&&typeof t=="object"}var Rt=Sl,Ef=Array.isArray;function El(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var dr=El,Il="[object AsyncFunction]",Al="[object Function]",Cl="[object GeneratorFunction]",Tl="[object Proxy]";function Ml(t){if(!dr(t))return!1;var e=Oe(t);return e==Al||e==Cl||e==Il||e==Tl}var Ol=Ml,$l=L["__core-js_shared__"],jt=$l,Wi=function(){var t=/[^.]+$/.exec(jt&&jt.keys&&jt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function jl(t){return!!Wi&&Wi in t}var Dl=jl,Pl=Function.prototype,Ul=Pl.toString;function Nl(t){if(t!=null){try{return Ul.call(t)}catch{}try{return t+""}catch{}}return""}var X=Nl,Ll=/[\\^$.*+?()[\]{}|]/g,Fl=/^\[object .+?Constructor\]$/,zl=Function.prototype,Bl=Object.prototype,Rl=zl.toString,ql=Bl.hasOwnProperty,Vl=RegExp("^"+Rl.call(ql).replace(Ll,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hl(t){if(!dr(t)||Dl(t))return!1;var e=Ol(t)?Vl:Fl;return e.test(X(t))}var Gl=Hl;function Kl(t,e){return t?.[e]}var Yl=Kl;function Wl(t,e){var i=Yl(t,e);return Gl(i)?i:void 0}var de=Wl,Ql=de(L,"WeakMap"),Nt=Ql;function Zl(t,e){return t===e||t!==t&&e!==e}var Xl=Zl,Jl=9007199254740991;function ec(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Jl}var tc=ec,If=Object.prototype,ic="[object Arguments]";function rc(t){return Rt(t)&&Oe(t)==ic}var Qi=rc,gr=Object.prototype,nc=gr.hasOwnProperty,ac=gr.propertyIsEnumerable,Af=Qi(function(){return arguments}())?Qi:function(t){return Rt(t)&&nc.call(t,"callee")&&!ac.call(t,"callee")},pr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zi=pr&&typeof module=="object"&&module&&!module.nodeType&&module,oc=Zi&&Zi.exports===pr,Xi=oc?L.Buffer:void 0,Cf=Xi?Xi.isBuffer:void 0,sc="[object Arguments]",lc="[object Array]",cc="[object Boolean]",uc="[object Date]",dc="[object Error]",gc="[object Function]",pc="[object Map]",fc="[object Number]",hc="[object Object]",mc="[object RegExp]",yc="[object Set]",bc="[object String]",_c="[object WeakMap]",vc="[object ArrayBuffer]",wc="[object DataView]",xc="[object Float32Array]",kc="[object Float64Array]",Sc="[object Int8Array]",Ec="[object Int16Array]",Ic="[object Int32Array]",Ac="[object Uint8Array]",Cc="[object Uint8ClampedArray]",Tc="[object Uint16Array]",Mc="[object Uint32Array]",E={};E[xc]=E[kc]=E[Sc]=E[Ec]=E[Ic]=E[Ac]=E[Cc]=E[Tc]=E[Mc]=!0;E[sc]=E[lc]=E[vc]=E[cc]=E[wc]=E[uc]=E[dc]=E[gc]=E[pc]=E[fc]=E[hc]=E[mc]=E[yc]=E[bc]=E[_c]=!1;function Oc(t){return Rt(t)&&tc(t.length)&&!!E[Oe(t)]}var $c=Oc;function jc(t){return function(e){return t(e)}}var Dc=jc,fr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ce=fr&&typeof module=="object"&&module&&!module.nodeType&&module,Pc=Ce&&Ce.exports===fr,Dt=Pc&&cr.process,Uc=function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||Dt&&Dt.binding&&Dt.binding("util")}catch{}}(),Ji=Uc,er=Ji&&Ji.isTypedArray,Tf=er?Dc(er):$c,Nc=Object.prototype,Mf=Nc.hasOwnProperty;function Lc(t,e){return function(i){return t(e(i))}}var Fc=Lc,Of=Fc(Object.keys,Object),zc=Object.prototype,$f=zc.hasOwnProperty,Bc=de(Object,"create"),Te=Bc;function Rc(){this.__data__=Te?Te(null):{},this.size=0}var qc=Rc;function Vc(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Hc=Vc,Gc="__lodash_hash_undefined__",Kc=Object.prototype,Yc=Kc.hasOwnProperty;function Wc(t){var e=this.__data__;if(Te){var i=e[t];return i===Gc?void 0:i}return Yc.call(e,t)?e[t]:void 0}var Qc=Wc,Zc=Object.prototype,Xc=Zc.hasOwnProperty;function Jc(t){var e=this.__data__;return Te?e[t]!==void 0:Xc.call(e,t)}var eu=Jc,tu="__lodash_hash_undefined__";function iu(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Te&&e===void 0?tu:e,this}var ru=iu;function ge(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}ge.prototype.clear=qc;ge.prototype.delete=Hc;ge.prototype.get=Qc;ge.prototype.has=eu;ge.prototype.set=ru;var tr=ge;function nu(){this.__data__=[],this.size=0}var au=nu;function ou(t,e){for(var i=t.length;i--;)if(Xl(t[i][0],e))return i;return-1}var Ke=ou,su=Array.prototype,lu=su.splice;function cu(t){var e=this.__data__,i=Ke(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():lu.call(e,i,1),--this.size,!0}var uu=cu;function du(t){var e=this.__data__,i=Ke(e,t);return i<0?void 0:e[i][1]}var gu=du;function pu(t){return Ke(this.__data__,t)>-1}var fu=pu;function hu(t,e){var i=this.__data__,r=Ke(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}var mu=hu;function pe(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}pe.prototype.clear=au;pe.prototype.delete=uu;pe.prototype.get=gu;pe.prototype.has=fu;pe.prototype.set=mu;var Ye=pe,yu=de(L,"Map"),Me=yu;function bu(){this.size=0,this.__data__={hash:new tr,map:new(Me||Ye),string:new tr}}var _u=bu;function vu(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var wu=vu;function xu(t,e){var i=t.__data__;return wu(e)?i[typeof e=="string"?"string":"hash"]:i.map}var We=xu;function ku(t){var e=We(this,t).delete(t);return this.size-=e?1:0,e}var Su=ku;function Eu(t){return We(this,t).get(t)}var Iu=Eu;function Au(t){return We(this,t).has(t)}var Cu=Au;function Tu(t,e){var i=We(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}var Mu=Tu;function fe(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}fe.prototype.clear=_u;fe.prototype.delete=Su;fe.prototype.get=Iu;fe.prototype.has=Cu;fe.prototype.set=Mu;var hr=fe;function Ou(){this.__data__=new Ye,this.size=0}var $u=Ou;function ju(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}var Du=ju;function Pu(t){return this.__data__.get(t)}var Uu=Pu;function Nu(t){return this.__data__.has(t)}var Lu=Nu,Fu=200;function zu(t,e){var i=this.__data__;if(i instanceof Ye){var r=i.__data__;if(!Me||r.length<Fu-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new hr(r)}return i.set(t,e),this.size=i.size,this}var Bu=zu;function $e(t){var e=this.__data__=new Ye(t);this.size=e.size}$e.prototype.clear=$u;$e.prototype.delete=Du;$e.prototype.get=Uu;$e.prototype.has=Lu;$e.prototype.set=Bu;var Ru=Object.prototype,jf=Ru.propertyIsEnumerable,qu=de(L,"DataView"),Lt=qu,Vu=de(L,"Promise"),Ft=Vu,Hu=de(L,"Set"),zt=Hu,ir="[object Map]",Gu="[object Object]",rr="[object Promise]",nr="[object Set]",ar="[object WeakMap]",or="[object DataView]",Ku=X(Lt),Yu=X(Me),Wu=X(Ft),Qu=X(zt),Zu=X(Nt),ce=Oe;(Lt&&ce(new Lt(new ArrayBuffer(1)))!=or||Me&&ce(new Me)!=ir||Ft&&ce(Ft.resolve())!=rr||zt&&ce(new zt)!=nr||Nt&&ce(new Nt)!=ar)&&(ce=function(t){var e=Oe(t),i=e==Gu?t.constructor:void 0,r=i?X(i):"";if(r)switch(r){case Ku:return or;case Yu:return ir;case Wu:return rr;case Qu:return nr;case Zu:return ar}return e});var Df=L.Uint8Array,Xu="__lodash_hash_undefined__";function Ju(t){return this.__data__.set(t,Xu),this}var ed=Ju;function td(t){return this.__data__.has(t)}var id=td;function Bt(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new hr;++e<i;)this.add(t[e])}Bt.prototype.add=Bt.prototype.push=ed;Bt.prototype.has=id;var sr=ue?ue.prototype:void 0,Pf=sr?sr.valueOf:void 0,rd=Object.prototype,Uf=rd.hasOwnProperty,nd=Object.prototype,Nf=nd.hasOwnProperty,Lf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ff=new RegExp(/[A-Fa-f0-9]{1}/,"g"),zf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function ad(t){return t!==void 0}var od=ad;function mr(t){return t?.version?t.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof t.i18n?.translate=="function":!1}function yr(t){return typeof t?.translate=="function"}function lr(t,e,i){return t&&mr(t)&&yr(t.i18n)?t.i18n.translate(e):i}function sd(t,e){let{cesdk:i}=e;if(i==null)return{};let r=e.propertyKey??"style",n=cd(t);i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${t}.${r}`]:"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=dd({baseURL:e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0,cesdk:i}),o=a;e.styles!=null&&(Array.isArray(e.styles)?o=e.styles:typeof e.styles=="function"&&(o=e.styles(a)));let s=gd({cesdk:i,providerId:t,styles:o}),c=s.id;return pd(s,{cesdk:i}),ld({providerId:t,cesdk:i,panelId:n,entryId:c}),{[e.propertyKeyForPrompt??"prompt"]:(u,l)=>{let d=u.state("prompt","");return u.builder.TextArea(`${l.id}`,{inputLabel:e.i18n?.prompt?.inputLabel??e.propertyKeyForPrompt??"prompt",placeholder:e.i18n?.prompt?.placeholder,...d}),()=>{let[h]=s.getActiveAssetIds(),p=s.getAsset(h);return{id:l.id,type:"string",value:p?.meta?.prompt==null?d.value:`${d.value}; ${p.meta.prompt}`}}},[r]:(u,l)=>{let{builder:d,state:h}=u;if(o.length>0){let p=h("style",o[0]);return d.Button(`${l.id}`,{inputLabel:`${t}.${l.id}`,icon:"@imgly/Appearance",isDisabled:o.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async y=>{s.clearActiveAssets(),s.setAssetActive(y.id),p.setValue({id:y.id,label:y.label??y.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function ld(t){let{providerId:e,cesdk:i,panelId:r,entryId:n}=t;i?.ui.registerPanel(r,({builder:a,payload:o})=>{o?.onSelect==null&&a.Section(`${e}.error`,{children:()=>{a.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),a.Library(`${e}.library.image`,{entries:[n],onSelect:async s=>{o?.onSelect?.(s)}})})}function cd(t){return`ly.img.ai.${t}.styleSelection`}var ud=[{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 dd(t){return ud.map(e=>e.id==="none"?t.includeNone?{id:e.id,label:lr(t.cesdk,e.labelKey,e.labelKey),prompt:e.prompt,thumbUri:`${t.baseURL}/thumbnails/None.svg`}:void 0:{id:e.id,label:lr(t.cesdk,e.labelKey,e.labelKey),prompt:e.prompt,thumbUri:`${t.baseURL}/thumbnails/${e.id}.jpeg`}).filter(od)}var gd=t=>{let e=t.styles.map(o=>({...o,meta:{prompt:o.prompt}})),i=t.cesdk.engine.asset.findAllSources(),r=`${t.providerId}/styles`;for(;i.includes(r);)r+=`-${Math.random().toString(36).substring(2,5)}`;let n=new ll(r,e),a=t.styles[0];return n.setAssetActive(a.id),n},pd=(t,e)=>{e.cesdk.engine.asset.addSource(t),e.cesdk.ui.addAssetLibraryEntry({id:t.id,sourceIds:[t.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:i})=>i,cardLabelPosition:()=>"below"})},fd=sd;var hd="ly.img.ai";function je(t){return`${hd}.${t}`}function br(t,e){let i={...t};if(!e)return i;for(let[r,n]of Object.entries(e))n===!1||n===null||n===void 0?delete i[r]:n===!0?r in t||(i[r]=!0):i[r]=n;return i}var Pt="@imgly/plugin-ai-generation",Bf=`
|
|
71
|
+
`,Fi=class{constructor(t,e=[],i){this.id=t,this.translateLabel=i?.translateLabel,this.assets=e.map(r=>{if(typeof r.label=="string"&&!(r.label&&typeof r.label=="object")){let n=r;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return r}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(t){let{page:e,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:s,excludeGroups:c,sortingOrder:u,sortKey:l}=t,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(g=>g.groups&&s.some(f=>g.groups?.includes(f)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(f=>g.groups?.includes(f)))),o){let g=o.toLowerCase();d=d.filter(f=>{let v=f.label?.[r]?.toLowerCase(),_=f.tags?.[r]||[];return v&&v.includes(g)||_.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(f=>{let v=f.tags?.[r]||[];return g.some(_=>v.includes(_))})}n&&d.sort((g,f)=>{let v=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(f.id);return v&&!_?-1:!v&&_?1:0}),l&&l!=="id"?d.sort((g,f)=>{let v=g.meta?.[l],_=f.meta?.[l];return v===void 0?1:_===void 0?-1:typeof v=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(v):v.localeCompare(_):typeof v=="number"&&typeof _=="number"?u==="Descending"?_-v:v-_:0}):l==="id"&&d.sort((g,f)=>u==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=d.length,p=e*i,m=p+i,y=d.slice(p,m).map(g=>{let f=g.label?.[r]||"",v=this.translateLabel?this.translateLabel(g.id,f,r):f;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:v,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),w=m<h?e+1:void 0;return{assets:y,currentPage:e,nextPage:w,total:h}}updateLabel(t,e,i){this.assets.forEach(r=>{r.id===t&&(r.label=r.label||{},r.label[i]=e)})}getAssetSelectValue(t){let e=this.assets.find(({id:i})=>i===t);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}getActiveSelectValue(){let t=this.getActiveAssetIds();if(t.length>0){let e=this.assets.find(({id:i})=>i===t[0]);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}}getTranslatedLabel(t){let e=this.assets.find(({id:i})=>i===t);if(e)return this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||""}getAsset(t){return this.assets.find(e=>e.id===t)}setAssetActive(t){this.activeAssetIds.add(t)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(t){t.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(t){this.activeAssetIds.delete(t)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(t){return this.activeAssetIds.has(t)}addAsset(t){let e=this.assets.findIndex(i=>i.id===t.id);e>=0?this.assets[e]=t:this.assets.push(t)}removeAsset(t){let e=this.assets.findIndex(i=>i.id===t);e!==-1&&(this.assets.splice(e,1),this.activeAssetIds.delete(t))}async getGroups(){let t=new Set;return this.assets.forEach(e=>{e.groups&&e.groups.forEach(i=>t.add(i))}),Array.from(t)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var lo=typeof global=="object"&&global&&global.Object===Object&&global,zi=lo,co=typeof self=="object"&&self&&self.Object===Object&&self,uo=zi||co||Function("return this")(),N=uo,go=N.Symbol,ne=go,Bi=Object.prototype,po=Bi.hasOwnProperty,fo=Bi.toString,we=ne?ne.toStringTag:void 0;function ho(t){var e=po.call(t,we),i=t[we];try{t[we]=void 0;var r=!0}catch{}var n=fo.call(t);return r&&(e?t[we]=i:delete t[we]),n}var mo=ho,yo=Object.prototype,bo=yo.toString;function _o(t){return bo.call(t)}var vo=_o,wo="[object Null]",ko="[object Undefined]",Ei=ne?ne.toStringTag:void 0;function xo(t){return t==null?t===void 0?ko:wo:Ei&&Ei in Object(t)?mo(t):vo(t)}var Ee=xo;function So(t){return t!=null&&typeof t=="object"}var $t=So,sf=Array.isArray;function Eo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Ri=Eo,Io="[object AsyncFunction]",Ao="[object Function]",Co="[object GeneratorFunction]",To="[object Proxy]";function Mo(t){if(!Ri(t))return!1;var e=Ee(t);return e==Ao||e==Co||e==Io||e==To}var $o=Mo,jo=N["__core-js_shared__"],St=jo,Ii=function(){var t=/[^.]+$/.exec(St&&St.keys&&St.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Oo(t){return!!Ii&&Ii in t}var Do=Oo,Po=Function.prototype,Uo=Po.toString;function No(t){if(t!=null){try{return Uo.call(t)}catch{}try{return t+""}catch{}}return""}var Z=No,Lo=/[\\^$.*+?()[\]{}|]/g,Fo=/^\[object .+?Constructor\]$/,zo=Function.prototype,Bo=Object.prototype,Ro=zo.toString,qo=Bo.hasOwnProperty,Vo=RegExp("^"+Ro.call(qo).replace(Lo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ho(t){if(!Ri(t)||Do(t))return!1;var e=$o(t)?Vo:Fo;return e.test(Z(t))}var Go=Ho;function Ko(t,e){return t?.[e]}var Yo=Ko;function Wo(t,e){var i=Yo(t,e);return Go(i)?i:void 0}var oe=Wo,Qo=oe(N,"WeakMap"),It=Qo;function Zo(t,e){return t===e||t!==t&&e!==e}var Xo=Zo,Jo=9007199254740991;function ea(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Jo}var ta=ea;var lf=Object.prototype;var ia="[object Arguments]";function ra(t){return $t(t)&&Ee(t)==ia}var Ai=ra,qi=Object.prototype,na=qi.hasOwnProperty,oa=qi.propertyIsEnumerable,cf=Ai(function(){return arguments}())?Ai:function(t){return $t(t)&&na.call(t,"callee")&&!oa.call(t,"callee")};var Vi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ci=Vi&&typeof module=="object"&&module&&!module.nodeType&&module,aa=Ci&&Ci.exports===Vi,Ti=aa?N.Buffer:void 0,uf=Ti?Ti.isBuffer:void 0;var sa="[object Arguments]",la="[object Array]",ca="[object Boolean]",ua="[object Date]",da="[object Error]",ga="[object Function]",pa="[object Map]",fa="[object Number]",ha="[object Object]",ma="[object RegExp]",ya="[object Set]",ba="[object String]",_a="[object WeakMap]",va="[object ArrayBuffer]",wa="[object DataView]",ka="[object Float32Array]",xa="[object Float64Array]",Sa="[object Int8Array]",Ea="[object Int16Array]",Ia="[object Int32Array]",Aa="[object Uint8Array]",Ca="[object Uint8ClampedArray]",Ta="[object Uint16Array]",Ma="[object Uint32Array]",S={};S[ka]=S[xa]=S[Sa]=S[Ea]=S[Ia]=S[Aa]=S[Ca]=S[Ta]=S[Ma]=!0;S[sa]=S[la]=S[va]=S[ca]=S[wa]=S[ua]=S[da]=S[ga]=S[pa]=S[fa]=S[ha]=S[ma]=S[ya]=S[ba]=S[_a]=!1;function $a(t){return $t(t)&&ta(t.length)&&!!S[Ee(t)]}var ja=$a;function Oa(t){return function(e){return t(e)}}var Da=Oa,Hi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ke=Hi&&typeof module=="object"&&module&&!module.nodeType&&module,Pa=ke&&ke.exports===Hi,Et=Pa&&zi.process,Ua=function(){try{var t=ke&&ke.require&&ke.require("util").types;return t||Et&&Et.binding&&Et.binding("util")}catch{}}(),Mi=Ua,$i=Mi&&Mi.isTypedArray,df=$i?Da($i):ja;var Na=Object.prototype,gf=Na.hasOwnProperty;function La(t,e){return function(i){return t(e(i))}}var Fa=La,pf=Fa(Object.keys,Object);var za=Object.prototype,ff=za.hasOwnProperty;var Ba=oe(Object,"create"),xe=Ba;function Ra(){this.__data__=xe?xe(null):{},this.size=0}var qa=Ra;function Va(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ha=Va,Ga="__lodash_hash_undefined__",Ka=Object.prototype,Ya=Ka.hasOwnProperty;function Wa(t){var e=this.__data__;if(xe){var i=e[t];return i===Ga?void 0:i}return Ya.call(e,t)?e[t]:void 0}var Qa=Wa,Za=Object.prototype,Xa=Za.hasOwnProperty;function Ja(t){var e=this.__data__;return xe?e[t]!==void 0:Xa.call(e,t)}var es=Ja,ts="__lodash_hash_undefined__";function is(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=xe&&e===void 0?ts:e,this}var rs=is;function ae(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}ae.prototype.clear=qa;ae.prototype.delete=Ha;ae.prototype.get=Qa;ae.prototype.has=es;ae.prototype.set=rs;var ji=ae;function ns(){this.__data__=[],this.size=0}var os=ns;function as(t,e){for(var i=t.length;i--;)if(Xo(t[i][0],e))return i;return-1}var Ve=as,ss=Array.prototype,ls=ss.splice;function cs(t){var e=this.__data__,i=Ve(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():ls.call(e,i,1),--this.size,!0}var us=cs;function ds(t){var e=this.__data__,i=Ve(e,t);return i<0?void 0:e[i][1]}var gs=ds;function ps(t){return Ve(this.__data__,t)>-1}var fs=ps;function hs(t,e){var i=this.__data__,r=Ve(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}var ms=hs;function se(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}se.prototype.clear=os;se.prototype.delete=us;se.prototype.get=gs;se.prototype.has=fs;se.prototype.set=ms;var He=se,ys=oe(N,"Map"),Se=ys;function bs(){this.size=0,this.__data__={hash:new ji,map:new(Se||He),string:new ji}}var _s=bs;function vs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ws=vs;function ks(t,e){var i=t.__data__;return ws(e)?i[typeof e=="string"?"string":"hash"]:i.map}var Ge=ks;function xs(t){var e=Ge(this,t).delete(t);return this.size-=e?1:0,e}var Ss=xs;function Es(t){return Ge(this,t).get(t)}var Is=Es;function As(t){return Ge(this,t).has(t)}var Cs=As;function Ts(t,e){var i=Ge(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}var Ms=Ts;function le(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}le.prototype.clear=_s;le.prototype.delete=Ss;le.prototype.get=Is;le.prototype.has=Cs;le.prototype.set=Ms;var Gi=le;function $s(){this.__data__=new He,this.size=0}var js=$s;function Os(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}var Ds=Os;function Ps(t){return this.__data__.get(t)}var Us=Ps;function Ns(t){return this.__data__.has(t)}var Ls=Ns,Fs=200;function zs(t,e){var i=this.__data__;if(i instanceof He){var r=i.__data__;if(!Se||r.length<Fs-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new Gi(r)}return i.set(t,e),this.size=i.size,this}var Bs=zs;function Ie(t){var e=this.__data__=new He(t);this.size=e.size}Ie.prototype.clear=js;Ie.prototype.delete=Ds;Ie.prototype.get=Us;Ie.prototype.has=Ls;Ie.prototype.set=Bs;var Rs=Object.prototype,hf=Rs.propertyIsEnumerable;var qs=oe(N,"DataView"),At=qs,Vs=oe(N,"Promise"),Ct=Vs,Hs=oe(N,"Set"),Tt=Hs,Oi="[object Map]",Gs="[object Object]",Di="[object Promise]",Pi="[object Set]",Ui="[object WeakMap]",Ni="[object DataView]",Ks=Z(At),Ys=Z(Se),Ws=Z(Ct),Qs=Z(Tt),Zs=Z(It),re=Ee;(At&&re(new At(new ArrayBuffer(1)))!=Ni||Se&&re(new Se)!=Oi||Ct&&re(Ct.resolve())!=Di||Tt&&re(new Tt)!=Pi||It&&re(new It)!=Ui)&&(re=function(t){var e=Ee(t),i=e==Gs?t.constructor:void 0,r=i?Z(i):"";if(r)switch(r){case Ks:return Ni;case Ys:return Oi;case Ws:return Di;case Qs:return Pi;case Zs:return Ui}return e});var mf=N.Uint8Array;var Xs="__lodash_hash_undefined__";function Js(t){return this.__data__.set(t,Xs),this}var el=Js;function tl(t){return this.__data__.has(t)}var il=tl;function Mt(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new Gi;++e<i;)this.add(t[e])}Mt.prototype.add=Mt.prototype.push=el;Mt.prototype.has=il;var Li=ne?ne.prototype:void 0,yf=Li?Li.valueOf:void 0;var rl=Object.prototype,bf=rl.hasOwnProperty;var nl=Object.prototype,_f=nl.hasOwnProperty;var vf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),wf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),kf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function jt(t){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[t]??"png"}var Ki={Formats:so};function ol(t,e){let{cesdk:i}=e,r=e.propertyKey??"image_url",n=Ut(t);return i.i18n.setTranslations({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."}}),al(t,i),{[r]:(o,a)=>{let{builder:s,experimental:{global:c},payload:u}=o,l,d=o.providerConfig,h=o.config,p=d?.properties?.[a.id]??h?.properties?.[a.id];p?.default&&(typeof p.default=="function"?l=p.default({}):l=p.default);let m=l??u?.url??e.defaultUrl,y=c(`${t}.${a.id}`,m);return s.MediaPreview(a.id,{preview:{type:"image",uri:y.value},action:{label:"ly.img.ai.imageSelection.selectImage.label",onClick:()=>{i?.ui.openPanel(n,{payload:{onSelect:w=>{w.meta?.uri!=null&&y.setValue(w.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:y.value})}}}function al(t,e){e?.ui.registerPanel(Ut(t),({builder:i,payload:r})=>{i.Library(`${t}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let a=await e.engine.editor.getMimeType(o);a==="image/svg+xml"?e.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.svg"}):a.startsWith("image/")?(r?.onSelect(n),e?.ui.closePanel(Ut(t))):e.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function Ut(t){return`ly.img.ai.${t}.imageSelection`}var sl=ol,ll=class{constructor(t,e=[],i){this.id=t,this.translateLabel=i?.translateLabel,this.assets=e.map(r=>{if(typeof r.label=="string"&&!(r.label&&typeof r.label=="object")){let n=r;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return r}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(t){let{page:e,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:s,excludeGroups:c,sortingOrder:u,sortKey:l}=t,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(g=>g.groups&&s.some(f=>g.groups?.includes(f)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(f=>g.groups?.includes(f)))),o){let g=o.toLowerCase();d=d.filter(f=>{let v=f.label?.[r]?.toLowerCase(),_=f.tags?.[r]||[];return v&&v.includes(g)||_.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(f=>{let v=f.tags?.[r]||[];return g.some(_=>v.includes(_))})}n&&d.sort((g,f)=>{let v=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(f.id);return v&&!_?-1:!v&&_?1:0}),l&&l!=="id"?d.sort((g,f)=>{let v=g.meta?.[l],_=f.meta?.[l];return v===void 0?1:_===void 0?-1:typeof v=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(v):v.localeCompare(_):typeof v=="number"&&typeof _=="number"?u==="Descending"?_-v:v-_:0}):l==="id"&&d.sort((g,f)=>u==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=d.length,p=e*i,m=p+i,y=d.slice(p,m).map(g=>{let f=g.label?.[r]||"",v=this.translateLabel?this.translateLabel(g.id,f,r):f;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:v,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),w=m<h?e+1:void 0;return{assets:y,currentPage:e,nextPage:w,total:h}}updateLabel(t,e,i){this.assets.forEach(r=>{r.id===t&&(r.label=r.label||{},r.label[i]=e)})}getAssetSelectValue(t){let e=this.assets.find(({id:i})=>i===t);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}getActiveSelectValue(){let t=this.getActiveAssetIds();if(t.length>0){let e=this.assets.find(({id:i})=>i===t[0]);if(e){let i=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:i,thumbUri:e.meta?.thumbUri}}}}getTranslatedLabel(t){let e=this.assets.find(({id:i})=>i===t);if(e)return this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||""}getAsset(t){return this.assets.find(e=>e.id===t)}setAssetActive(t){this.activeAssetIds.add(t)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(t){t.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(t){this.activeAssetIds.delete(t)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(t){return this.activeAssetIds.has(t)}addAsset(t){let e=this.assets.findIndex(i=>i.id===t.id);e>=0?this.assets[e]=t:this.assets.push(t)}removeAsset(t){let e=this.assets.findIndex(i=>i.id===t);e!==-1&&(this.assets.splice(e,1),this.activeAssetIds.delete(t))}async getGroups(){let t=new Set;return this.assets.forEach(e=>{e.groups&&e.groups.forEach(i=>t.add(i))}),Array.from(t)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var cl=typeof global=="object"&&global&&global.Object===Object&&global,cr=cl,ul=typeof self=="object"&&self&&self.Object===Object&&self,dl=cr||ul||Function("return this")(),L=dl,gl=L.Symbol,ue=gl,ur=Object.prototype,pl=ur.hasOwnProperty,fl=ur.toString,Ae=ue?ue.toStringTag:void 0;function hl(t){var e=pl.call(t,Ae),i=t[Ae];try{t[Ae]=void 0;var r=!0}catch{}var n=fl.call(t);return r&&(e?t[Ae]=i:delete t[Ae]),n}var ml=hl,yl=Object.prototype,bl=yl.toString;function _l(t){return bl.call(t)}var vl=_l,wl="[object Null]",kl="[object Undefined]",Yi=ue?ue.toStringTag:void 0;function xl(t){return t==null?t===void 0?kl:wl:Yi&&Yi in Object(t)?ml(t):vl(t)}var $e=xl;function Sl(t){return t!=null&&typeof t=="object"}var Rt=Sl,Ef=Array.isArray;function El(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var dr=El,Il="[object AsyncFunction]",Al="[object Function]",Cl="[object GeneratorFunction]",Tl="[object Proxy]";function Ml(t){if(!dr(t))return!1;var e=$e(t);return e==Al||e==Cl||e==Il||e==Tl}var $l=Ml,jl=L["__core-js_shared__"],Ot=jl,Wi=function(){var t=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ol(t){return!!Wi&&Wi in t}var Dl=Ol,Pl=Function.prototype,Ul=Pl.toString;function Nl(t){if(t!=null){try{return Ul.call(t)}catch{}try{return t+""}catch{}}return""}var X=Nl,Ll=/[\\^$.*+?()[\]{}|]/g,Fl=/^\[object .+?Constructor\]$/,zl=Function.prototype,Bl=Object.prototype,Rl=zl.toString,ql=Bl.hasOwnProperty,Vl=RegExp("^"+Rl.call(ql).replace(Ll,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hl(t){if(!dr(t)||Dl(t))return!1;var e=$l(t)?Vl:Fl;return e.test(X(t))}var Gl=Hl;function Kl(t,e){return t?.[e]}var Yl=Kl;function Wl(t,e){var i=Yl(t,e);return Gl(i)?i:void 0}var de=Wl,Ql=de(L,"WeakMap"),Nt=Ql;function Zl(t,e){return t===e||t!==t&&e!==e}var Xl=Zl,Jl=9007199254740991;function ec(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Jl}var tc=ec,If=Object.prototype,ic="[object Arguments]";function rc(t){return Rt(t)&&$e(t)==ic}var Qi=rc,gr=Object.prototype,nc=gr.hasOwnProperty,oc=gr.propertyIsEnumerable,Af=Qi(function(){return arguments}())?Qi:function(t){return Rt(t)&&nc.call(t,"callee")&&!oc.call(t,"callee")},pr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zi=pr&&typeof module=="object"&&module&&!module.nodeType&&module,ac=Zi&&Zi.exports===pr,Xi=ac?L.Buffer:void 0,Cf=Xi?Xi.isBuffer:void 0,sc="[object Arguments]",lc="[object Array]",cc="[object Boolean]",uc="[object Date]",dc="[object Error]",gc="[object Function]",pc="[object Map]",fc="[object Number]",hc="[object Object]",mc="[object RegExp]",yc="[object Set]",bc="[object String]",_c="[object WeakMap]",vc="[object ArrayBuffer]",wc="[object DataView]",kc="[object Float32Array]",xc="[object Float64Array]",Sc="[object Int8Array]",Ec="[object Int16Array]",Ic="[object Int32Array]",Ac="[object Uint8Array]",Cc="[object Uint8ClampedArray]",Tc="[object Uint16Array]",Mc="[object Uint32Array]",E={};E[kc]=E[xc]=E[Sc]=E[Ec]=E[Ic]=E[Ac]=E[Cc]=E[Tc]=E[Mc]=!0;E[sc]=E[lc]=E[vc]=E[cc]=E[wc]=E[uc]=E[dc]=E[gc]=E[pc]=E[fc]=E[hc]=E[mc]=E[yc]=E[bc]=E[_c]=!1;function $c(t){return Rt(t)&&tc(t.length)&&!!E[$e(t)]}var jc=$c;function Oc(t){return function(e){return t(e)}}var Dc=Oc,fr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ce=fr&&typeof module=="object"&&module&&!module.nodeType&&module,Pc=Ce&&Ce.exports===fr,Dt=Pc&&cr.process,Uc=function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||Dt&&Dt.binding&&Dt.binding("util")}catch{}}(),Ji=Uc,er=Ji&&Ji.isTypedArray,Tf=er?Dc(er):jc,Nc=Object.prototype,Mf=Nc.hasOwnProperty;function Lc(t,e){return function(i){return t(e(i))}}var Fc=Lc,$f=Fc(Object.keys,Object),zc=Object.prototype,jf=zc.hasOwnProperty,Bc=de(Object,"create"),Te=Bc;function Rc(){this.__data__=Te?Te(null):{},this.size=0}var qc=Rc;function Vc(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Hc=Vc,Gc="__lodash_hash_undefined__",Kc=Object.prototype,Yc=Kc.hasOwnProperty;function Wc(t){var e=this.__data__;if(Te){var i=e[t];return i===Gc?void 0:i}return Yc.call(e,t)?e[t]:void 0}var Qc=Wc,Zc=Object.prototype,Xc=Zc.hasOwnProperty;function Jc(t){var e=this.__data__;return Te?e[t]!==void 0:Xc.call(e,t)}var eu=Jc,tu="__lodash_hash_undefined__";function iu(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Te&&e===void 0?tu:e,this}var ru=iu;function ge(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}ge.prototype.clear=qc;ge.prototype.delete=Hc;ge.prototype.get=Qc;ge.prototype.has=eu;ge.prototype.set=ru;var tr=ge;function nu(){this.__data__=[],this.size=0}var ou=nu;function au(t,e){for(var i=t.length;i--;)if(Xl(t[i][0],e))return i;return-1}var Ke=au,su=Array.prototype,lu=su.splice;function cu(t){var e=this.__data__,i=Ke(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():lu.call(e,i,1),--this.size,!0}var uu=cu;function du(t){var e=this.__data__,i=Ke(e,t);return i<0?void 0:e[i][1]}var gu=du;function pu(t){return Ke(this.__data__,t)>-1}var fu=pu;function hu(t,e){var i=this.__data__,r=Ke(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}var mu=hu;function pe(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}pe.prototype.clear=ou;pe.prototype.delete=uu;pe.prototype.get=gu;pe.prototype.has=fu;pe.prototype.set=mu;var Ye=pe,yu=de(L,"Map"),Me=yu;function bu(){this.size=0,this.__data__={hash:new tr,map:new(Me||Ye),string:new tr}}var _u=bu;function vu(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var wu=vu;function ku(t,e){var i=t.__data__;return wu(e)?i[typeof e=="string"?"string":"hash"]:i.map}var We=ku;function xu(t){var e=We(this,t).delete(t);return this.size-=e?1:0,e}var Su=xu;function Eu(t){return We(this,t).get(t)}var Iu=Eu;function Au(t){return We(this,t).has(t)}var Cu=Au;function Tu(t,e){var i=We(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}var Mu=Tu;function fe(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}fe.prototype.clear=_u;fe.prototype.delete=Su;fe.prototype.get=Iu;fe.prototype.has=Cu;fe.prototype.set=Mu;var hr=fe;function $u(){this.__data__=new Ye,this.size=0}var ju=$u;function Ou(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}var Du=Ou;function Pu(t){return this.__data__.get(t)}var Uu=Pu;function Nu(t){return this.__data__.has(t)}var Lu=Nu,Fu=200;function zu(t,e){var i=this.__data__;if(i instanceof Ye){var r=i.__data__;if(!Me||r.length<Fu-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new hr(r)}return i.set(t,e),this.size=i.size,this}var Bu=zu;function je(t){var e=this.__data__=new Ye(t);this.size=e.size}je.prototype.clear=ju;je.prototype.delete=Du;je.prototype.get=Uu;je.prototype.has=Lu;je.prototype.set=Bu;var Ru=Object.prototype,Of=Ru.propertyIsEnumerable,qu=de(L,"DataView"),Lt=qu,Vu=de(L,"Promise"),Ft=Vu,Hu=de(L,"Set"),zt=Hu,ir="[object Map]",Gu="[object Object]",rr="[object Promise]",nr="[object Set]",or="[object WeakMap]",ar="[object DataView]",Ku=X(Lt),Yu=X(Me),Wu=X(Ft),Qu=X(zt),Zu=X(Nt),ce=$e;(Lt&&ce(new Lt(new ArrayBuffer(1)))!=ar||Me&&ce(new Me)!=ir||Ft&&ce(Ft.resolve())!=rr||zt&&ce(new zt)!=nr||Nt&&ce(new Nt)!=or)&&(ce=function(t){var e=$e(t),i=e==Gu?t.constructor:void 0,r=i?X(i):"";if(r)switch(r){case Ku:return ar;case Yu:return ir;case Wu:return rr;case Qu:return nr;case Zu:return or}return e});var Df=L.Uint8Array,Xu="__lodash_hash_undefined__";function Ju(t){return this.__data__.set(t,Xu),this}var ed=Ju;function td(t){return this.__data__.has(t)}var id=td;function Bt(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new hr;++e<i;)this.add(t[e])}Bt.prototype.add=Bt.prototype.push=ed;Bt.prototype.has=id;var sr=ue?ue.prototype:void 0,Pf=sr?sr.valueOf:void 0,rd=Object.prototype,Uf=rd.hasOwnProperty,nd=Object.prototype,Nf=nd.hasOwnProperty,Lf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ff=new RegExp(/[A-Fa-f0-9]{1}/,"g"),zf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function od(t){return t!==void 0}var ad=od;function mr(t){return t?.version?t.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof t.i18n?.translate=="function":!1}function yr(t){return typeof t?.translate=="function"}function lr(t,e,i){return t&&mr(t)&&yr(t.i18n)?t.i18n.translate(e):i}function sd(t,e){let{cesdk:i}=e;if(i==null)return{};let r=e.propertyKey??"style",n=cd(t);i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${t}.${r}`]:"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 o=dd({baseURL:e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0,cesdk:i}),a=o;e.styles!=null&&(Array.isArray(e.styles)?a=e.styles:typeof e.styles=="function"&&(a=e.styles(o)));let s=gd({cesdk:i,providerId:t,styles:a}),c=s.id;return pd(s,{cesdk:i}),ld({providerId:t,cesdk:i,panelId:n,entryId:c}),{[e.propertyKeyForPrompt??"prompt"]:(u,l)=>{let d=u.state("prompt","");return u.builder.TextArea(`${l.id}`,{inputLabel:e.i18n?.prompt?.inputLabel??e.propertyKeyForPrompt??"prompt",placeholder:e.i18n?.prompt?.placeholder,...d}),()=>{let[h]=s.getActiveAssetIds(),p=s.getAsset(h);return{id:l.id,type:"string",value:p?.meta?.prompt==null?d.value:`${d.value}; ${p.meta.prompt}`}}},[r]:(u,l)=>{let{builder:d,state:h}=u;if(a.length>0){let p=h("style",a[0]);return d.Button(`${l.id}`,{inputLabel:`${t}.${l.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async y=>{s.clearActiveAssets(),s.setAssetActive(y.id),p.setValue({id:y.id,label:y.label??y.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function ld(t){let{providerId:e,cesdk:i,panelId:r,entryId:n}=t;i?.ui.registerPanel(r,({builder:o,payload:a})=>{a?.onSelect==null&&o.Section(`${e}.error`,{children:()=>{o.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),o.Library(`${e}.library.image`,{entries:[n],onSelect:async s=>{a?.onSelect?.(s)}})})}function cd(t){return`ly.img.ai.${t}.styleSelection`}var ud=[{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 dd(t){return ud.map(e=>e.id==="none"?t.includeNone?{id:e.id,label:lr(t.cesdk,e.labelKey,e.labelKey),prompt:e.prompt,thumbUri:`${t.baseURL}/thumbnails/None.svg`}:void 0:{id:e.id,label:lr(t.cesdk,e.labelKey,e.labelKey),prompt:e.prompt,thumbUri:`${t.baseURL}/thumbnails/${e.id}.jpeg`}).filter(ad)}var gd=t=>{let e=t.styles.map(a=>({...a,meta:{prompt:a.prompt}})),i=t.cesdk.engine.asset.findAllSources(),r=`${t.providerId}/styles`;for(;i.includes(r);)r+=`-${Math.random().toString(36).substring(2,5)}`;let n=new ll(r,e),o=t.styles[0];return n.setAssetActive(o.id),n},pd=(t,e)=>{e.cesdk.engine.asset.addSource(t),e.cesdk.ui.addAssetLibraryEntry({id:t.id,sourceIds:[t.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:i})=>i,cardLabelPosition:()=>"below"})},fd=sd;var hd="ly.img.ai";function Oe(t){return`${hd}.${t}`}function br(t,e){let i={...t};if(!e)return i;for(let[r,n]of Object.entries(e))n===!1||n===null||n===void 0?delete i[r]:n===!0?r in t||(i[r]=!0):i[r]=n;return i}var Pt="@imgly/plugin-ai-generation",Bf=`
|
|
72
72
|
<svg>
|
|
73
73
|
<symbol
|
|
74
74
|
fill="none"
|
|
@@ -129,7 +129,7 @@ var ea=Object.create;var Si=Object.defineProperty;var ta=Object.getOwnPropertyDe
|
|
|
129
129
|
|
|
130
130
|
</symbol>
|
|
131
131
|
</svg>
|
|
132
|
-
`;function _r(t,e,i="style",r="image"){return(n,a)=>{if(!mr(t))return a;let o=md(e,i,n,r);if(yr(t.i18n)){let s=t.i18n.translate(o);return s!==o[o.length-1]?s:a}return a}}function md(t,e,i,r="image"){return[`ly.img.plugin-ai-${r}-generation-web.${t}.property.${e}.${i}`,`ly.img.plugin-ai-generation-web.property.${e}.${i}`,`ly.img.plugin-ai-${r}-generation-web.${t}.defaults.property.${e}.${i}`,`ly.img.plugin-ai-generation-web.defaults.property.${e}.${i}`]}var vr={ImageUrl:sl,StyleTransfer:fd};var wr={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},Recraft20bInput:{title:"TextToImageInput",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},image_size:{anyOf:[{enum:["square_hd","square","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"],type:"string"},{$ref:"#/components/schemas/ImageSize"}],title:"Format",default:"square_hd","x-imgly-enum-labels":{ImageSize:"Custom",square_hd:"Square HD",square:"Square",portrait_4_3:"Portrait 4:3",portrait_16_9:"Portrait 16:9",landscape_4_3:"Landscape 4:3",landscape_16_9:"Landscape 16:9"},"x-imgly-enum-icons":{square:"@imgly/plugin/formats/ratio1by1",square_hd:"@imgly/plugin/formats/ratio1by1",portrait_4_3:"@imgly/plugin/formats/ratio3by4",portrait_16_9:"@imgly/plugin/formats/ratio9by16",landscape_4_3:"@imgly/plugin/formats/ratio4by3",landscape_16_9:"@imgly/plugin/formats/ratio16by9",ImageSize:"@imgly/plugin/formats/ratioFree"}},style:{enum:["any","realistic_image","digital_illustration","vector_illustration","realistic_image/b_and_w","realistic_image/hard_flash","realistic_image/hdr","realistic_image/natural_light","realistic_image/studio_portrait","realistic_image/enterprise","realistic_image/motion_blur","realistic_image/evening_light","realistic_image/faded_nostalgia","realistic_image/forest_life","realistic_image/mystic_naturalism","realistic_image/natural_tones","realistic_image/organic_calm","realistic_image/real_life_glow","realistic_image/retro_realism","realistic_image/retro_snapshot","realistic_image/urban_drama","realistic_image/village_realism","realistic_image/warm_folk","digital_illustration/pixel_art","digital_illustration/hand_drawn","digital_illustration/grain","digital_illustration/infantile_sketch","digital_illustration/2d_art_poster","digital_illustration/handmade_3d","digital_illustration/hand_drawn_outline","digital_illustration/engraving_color","digital_illustration/2d_art_poster_2","digital_illustration/antiquarian","digital_illustration/bold_fantasy","digital_illustration/child_book","digital_illustration/child_books","digital_illustration/cover","digital_illustration/crosshatch","digital_illustration/digital_engraving","digital_illustration/expressionism","digital_illustration/freehand_details","digital_illustration/grain_20","digital_illustration/graphic_intensity","digital_illustration/hard_comics","digital_illustration/long_shadow","digital_illustration/modern_folk","digital_illustration/multicolor","digital_illustration/neon_calm","digital_illustration/noir","digital_illustration/nostalgic_pastel","digital_illustration/outline_details","digital_illustration/pastel_gradient","digital_illustration/pastel_sketch","digital_illustration/pop_art","digital_illustration/pop_renaissance","digital_illustration/street_art","digital_illustration/tablet_sketch","digital_illustration/urban_glow","digital_illustration/urban_sketching","digital_illustration/vanilla_dreams","digital_illustration/young_adult_book","digital_illustration/young_adult_book_2","vector_illustration/bold_stroke","vector_illustration/chemistry","vector_illustration/colored_stencil","vector_illustration/contour_pop_art","vector_illustration/cosmics","vector_illustration/cutout","vector_illustration/depressive","vector_illustration/editorial","vector_illustration/emotional_flat","vector_illustration/infographical","vector_illustration/marker_outline","vector_illustration/mosaic","vector_illustration/naivector","vector_illustration/roundish_flat","vector_illustration/segmented_colors","vector_illustration/sharp_contrast","vector_illustration/thin","vector_illustration/vector_photo","vector_illustration/vivid_shapes","vector_illustration/engraving","vector_illustration/line_art","vector_illustration/line_circuit","vector_illustration/linocut","icon/broken_line","icon/colored_outline","icon/colored_shapes","icon/colored_shapes_gradient","icon/doodle_fill","icon/doodle_offset_fill","icon/offset_fill","icon/outline","icon/outline_gradient","icon/uneven_fill"],title:"Style",type:"string",description:"The style of the generated images. Vector images cost 2X as much.",default:"realistic_image"},colors:{title:"Colors",type:"array",description:"An array of preferable colors",items:{$ref:"#/components/schemas/RGBColor"},default:[]}},"x-fal-order-properties":["prompt","style","image_size"],required:["prompt"]},Recraft20bOutput:{title:"TextToImageOutput",type:"object",properties:{images:{title:"Images",type:"array",items:{$ref:"#/components/schemas/File"}}},"x-fal-order-properties":["images"],required:["images"]},ImageSize:{title:"ImageSize",type:"object",properties:{height:{maximum:14142,type:"integer",title:"Height",description:"The height of the generated image.",exclusiveMinimum:0,default:512},width:{maximum:14142,type:"integer",title:"Width",description:"The width of the generated image.",exclusiveMinimum:0,default:512}},"x-fal-order-properties":["width","height"]},RGBColor:{title:"RGBColor",type:"object",properties:{r:{minimum:0,maximum:255,type:"integer",title:"R",description:"Red color value",default:0},b:{minimum:0,maximum:255,type:"integer",title:"B",description:"Blue color value",default:0},g:{minimum:0,maximum:255,type:"integer",title:"G",description:"Green color value",default:0}},"x-fal-order-properties":["r","g","b"]},File:{title:"File",type:"object",properties:{file_size:{title:"File Size",type:"integer",description:"The size of the file in bytes."},file_name:{title:"File Name",type:"string",description:"The name of the file. It will be auto-generated if not provided."},content_type:{title:"Content Type",type:"string",description:"The mime type of the file."},url:{title:"Url",type:"string",description:"The URL where the file can be downloaded from."},file_data:{format:"binary",title:"File Data",type:"string",description:"File data"}},"x-fal-order-properties":["url","content_type","file_name","file_size","file_data"],required:["url"]}}},paths:{"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/status":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}},{name:"logs",in:"query",required:!1,schema:{type:"number",description:"Whether to include logs (`1`) in the response or not (`0`)."}}],responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/cancel":{put:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"The request was cancelled.",content:{"application/json":{schema:{type:"object",properties:{success:{type:"boolean",description:"Whether the request was cancelled successfully."}}}}}}}}},"/fal-ai/recraft/v2/text-to-image":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"Result of the request.",content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var bd={square_hd:{width:1024,height:1024},square:{width:512,height:512},portrait_4_3:{width:1024,height:1365},portrait_16_9:{width:1024,height:1820},landscape_4_3:{width:1365,height:1024},landscape_16_9:{width:1820,height:1024}};function Qe(t){return bd[t]}var _d=[{id:"realistic_image",label:"Realistic Image"},{id:"digital_illustration",label:"Digital Illustration"},{id:"realistic_image/b_and_w",label:"Black & White"},{id:"realistic_image/hard_flash",label:"Hard Flash"},{id:"realistic_image/hdr",label:"HDR"},{id:"realistic_image/natural_light",label:"Natural Light"},{id:"realistic_image/studio_portrait",label:"Studio Portrait"},{id:"realistic_image/enterprise",label:"Enterprise"},{id:"realistic_image/motion_blur",label:"Motion Blur"},{id:"realistic_image/evening_light",label:"Evening Light"},{id:"realistic_image/faded_nostalgia",label:"Faded Nostalgia"},{id:"realistic_image/forest_life",label:"Forest Life"},{id:"realistic_image/mystic_naturalism",label:"Mystic Naturalism"},{id:"realistic_image/natural_tones",label:"Natural Tones"},{id:"realistic_image/organic_calm",label:"Organic Calm"},{id:"realistic_image/real_life_glow",label:"Real Life Glow"},{id:"realistic_image/retro_realism",label:"Retro Realism"},{id:"realistic_image/retro_snapshot",label:"Retro Snapshot"},{id:"realistic_image/urban_drama",label:"Urban Drama"},{id:"realistic_image/village_realism",label:"Village Realism"},{id:"realistic_image/warm_folk",label:"Warm Folk"},{id:"digital_illustration/pixel_art",label:"Pixel Art"},{id:"digital_illustration/hand_drawn",label:"Hand Drawn"},{id:"digital_illustration/grain",label:"Grain"},{id:"digital_illustration/infantile_sketch",label:"Infantile Sketch"},{id:"digital_illustration/2d_art_poster",label:"2D Art Poster"},{id:"digital_illustration/handmade_3d",label:"Handmade 3D"},{id:"digital_illustration/hand_drawn_outline",label:"Hand Drawn Outline"},{id:"digital_illustration/engraving_color",label:"Engraving Color"},{id:"digital_illustration/2d_art_poster_2",label:"2D Art Poster 2"},{id:"digital_illustration/antiquarian",label:"Antiquarian"},{id:"digital_illustration/bold_fantasy",label:"Bold Fantasy"},{id:"digital_illustration/child_book",label:"Child Book"},{id:"digital_illustration/child_books",label:"Child Books"},{id:"digital_illustration/cover",label:"Cover"},{id:"digital_illustration/crosshatch",label:"Crosshatch"},{id:"digital_illustration/digital_engraving",label:"Digital Engraving"},{id:"digital_illustration/expressionism",label:"Expressionism"},{id:"digital_illustration/freehand_details",label:"Freehand Details"},{id:"digital_illustration/grain_20",label:"Grain 20"},{id:"digital_illustration/graphic_intensity",label:"Graphic Intensity"},{id:"digital_illustration/hard_comics",label:"Hard Comics"},{id:"digital_illustration/long_shadow",label:"Long Shadow"},{id:"digital_illustration/modern_folk",label:"Modern Folk"},{id:"digital_illustration/multicolor",label:"Multicolor"},{id:"digital_illustration/neon_calm",label:"Neon Calm"},{id:"digital_illustration/noir",label:"Noir"},{id:"digital_illustration/nostalgic_pastel",label:"Nostalgic Pastel"},{id:"digital_illustration/outline_details",label:"Outline Details"},{id:"digital_illustration/pastel_gradient",label:"Pastel Gradient"},{id:"digital_illustration/pastel_sketch",label:"Pastel Sketch"},{id:"digital_illustration/pop_art",label:"Pop Art"},{id:"digital_illustration/pop_renaissance",label:"Pop Renaissance"},{id:"digital_illustration/street_art",label:"Street Art"},{id:"digital_illustration/tablet_sketch",label:"Tablet Sketch"},{id:"digital_illustration/urban_glow",label:"Urban Glow"},{id:"digital_illustration/urban_sketching",label:"Urban Sketching"},{id:"digital_illustration/vanilla_dreams",label:"Vanilla Dreams"},{id:"digital_illustration/young_adult_book",label:"Young Adult Book"},{id:"digital_illustration/young_adult_book_2",label:"Young Adult Book 2"}],Hf=_d[0],vd=[{id:"vector_illustration",label:"Vector Illustration"},{id:"vector_illustration/bold_stroke",label:"Bold Stroke"},{id:"vector_illustration/chemistry",label:"Chemistry"},{id:"vector_illustration/colored_stencil",label:"Colored Stencil"},{id:"vector_illustration/contour_pop_art",label:"Contour Pop Art"},{id:"vector_illustration/cosmics",label:"Cosmics"},{id:"vector_illustration/cutout",label:"Cutout"},{id:"vector_illustration/depressive",label:"Depressive"},{id:"vector_illustration/editorial",label:"Editorial"},{id:"vector_illustration/emotional_flat",label:"Emotional Flat"},{id:"vector_illustration/infographical",label:"Infographical"},{id:"vector_illustration/marker_outline",label:"Marker Outline"},{id:"vector_illustration/mosaic",label:"Mosaic"},{id:"vector_illustration/naivector",label:"Naive Vector"},{id:"vector_illustration/roundish_flat",label:"Roundish Flat"},{id:"vector_illustration/segmented_colors",label:"Segmented Colors"},{id:"vector_illustration/sharp_contrast",label:"Sharp Contrast"},{id:"vector_illustration/thin",label:"Thin"},{id:"vector_illustration/vector_photo",label:"Vector Photo"},{id:"vector_illustration/vivid_shapes",label:"Vivid Shapes"},{id:"vector_illustration/engraving",label:"Engraving"},{id:"vector_illustration/line_art",label:"Line Art"},{id:"vector_illustration/line_circuit",label:"Line Circuit"},{id:"vector_illustration/linocut",label:"Linocut"}],Gf=vd[0],Ze=[{id:"icon/broken_line",label:"Broken Line"},{id:"icon/colored_outline",label:"Colored Outline"},{id:"icon/colored_shapes",label:"Colored Shapes"},{id:"icon/colored_shapes_gradient",label:"Colored Shapes Gradient"},{id:"icon/doodle_fill",label:"Doodle Fill"},{id:"icon/doodle_offset_fill",label:"Doodle Offset Fill"},{id:"icon/offset_fill",label:"Offset Fill"},{id:"icon/outline",label:"Outline"},{id:"icon/outline_gradient",label:"Outline Gradient"},{id:"icon/uneven_fill",label:"Uneven Fill"}],Kf=Ze[0],wd=t=>({realistic_image:`${t}/realistic_image.webp`,digital_illustration:`${t}/digital_illustration.webp`,"realistic_image/b_and_w":`${t}/realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${t}/realistic_image_hard_flash.webp`,"realistic_image/hdr":`${t}/realistic_image_hdr.webp`,"realistic_image/natural_light":`${t}/realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${t}/realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${t}/realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${t}/realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${t}/digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${t}/digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${t}/digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${t}/digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${t}/digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${t}/digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${t}/digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${t}/digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${t}/digital_illustration_2d_artposter_2.webp`,vector_illustration:`${t}/vector_illustration.svg`,"vector_illustration/bold_stroke":`${t}/vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${t}/vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${t}/vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${t}/vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${t}/vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${t}/vector_illustration_cutout.svg`,"vector_illustration/depressive":`${t}/vector_illustration_depressive.svg`,"vector_illustration/editorial":`${t}/vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${t}/vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${t}/vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${t}/vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${t}/vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${t}/vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${t}/vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${t}/vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${t}/vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${t}/vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${t}/vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${t}/vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${t}/vector_illustration_engraving.svg`,"vector_illustration/line_art":`${t}/vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${t}/vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${t}/vector_illustration_linocut.svg`,"realistic_image/evening_light":`${t}/realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${t}/realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${t}/realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${t}/realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${t}/realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${t}/realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${t}/realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${t}/realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${t}/realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${t}/realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${t}/realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${t}/realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${t}/digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${t}/digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${t}/digital_illustration_child_book.webp`,"digital_illustration/child_books":`${t}/digital_illustration_child_books.webp`,"digital_illustration/cover":`${t}/digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${t}/digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${t}/digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${t}/digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${t}/digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${t}/digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${t}/digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${t}/digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${t}/digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${t}/digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${t}/digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${t}/digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${t}/digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${t}/digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${t}/digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${t}/digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${t}/digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${t}/digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${t}/digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${t}/digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${t}/digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${t}/digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${t}/digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${t}/digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${t}/digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${t}/digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${t}/icon_broken_line.svg`,"icon/colored_outline":`${t}/icon_colored_outline.svg`,"icon/colored_shapes":`${t}/icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${t}/icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${t}/icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${t}/icon_doodle_offset_fill.svg`,"icon/offset_fill":`${t}/icon_offset_fill.svg`,"icon/outline":`${t}/icon_outline.svg`,"icon/outline_gradient":`${t}/icon_outline_gradient.svg`,"icon/uneven_fill":`${t}/icon_uneven_fill.svg`});function xr(t,e){return wd(`${e}thumbnails/`)[t]}var Yn=oa(Kn());function Wn(t,e){return(0,Yn.createFalClient)({proxyUrl:t,requestMiddleware:async r=>({...r,headers:{...r.headers,...e??{}}})})}function wt(t){return t!=null&&typeof t!="string"&&"width"in t&&"height"in t}async function Qn(t,e,i){if(e!=null){if(e.startsWith("blob:")){let r=i!=null?await i.engine.editor.getMimeType(e):"image/png",a=await(await fetch(e)).blob(),o=new File([a],`image.${$t(r)}`,{type:r});return t.storage.upload(o)}if(i!=null&&e.startsWith("buffer:")){let r=await i.engine.editor.getMimeType(e),n=i.engine.editor.getBufferLength(e),a=i.engine.editor.getBufferData(e,0,n),o=new Uint8Array(a),s=new File([o],`image.${$t(r)}`,{type:r});return t.storage.upload(s)}return e}}function ef(t,e){let i=t.middleware??e.middlewares??e.middleware??[],r=null,n={id:t.modelKey,kind:"sticker",name:t.name,initialize:async a=>{r=Wn(e.proxyUrl,t.headers),t.initialize?.(a)},input:{quickActions:{supported:br(t.supportedQuickActions??{},e.supportedQuickActions)},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?vr.ImageUrl(t.modelKey,{cesdk:t.cesdk}):{},...t.renderCustomProperty},getBlockInput:a=>{if(t.getBlockInput!=null)return t.getBlockInput(a);if(t.getStickerSize!=null){let{width:o,height:s}=t.getStickerSize(a);return Promise.resolve({sticker:{width:o,height:s}})}if(a.image_size!=null&&wt(a.image_size))return Promise.resolve({sticker:{width:a.image_size.width??512,height:a.image_size.height??512}});if(a.image_size!=null&&typeof a.image_size=="string"){let o=Qe(a.image_size);return Promise.resolve({sticker:o})}throw new Error("getBlockInput or getStickerSize must be provided")},userFlow:t.userFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:e.history??"@imgly/indexedDB",generate:async(a,{abortSignal:o})=>{if(!r)throw new Error("Provider not initialized");let s=await Qn(r,a.image_url,t.cesdk),c=await r.subscribe(t.falKey??t.modelKey,{abortSignal:o,input:s!=null?{...a,image_url:s}:a,logs:!0}),u=c?.data?.images;if(u!=null&&Array.isArray(u)){let d=u[0]?.url;if(d!=null)return{kind:"sticker",url:d}}else{let l=c?.data?.image;if(l!=null){let d=l?.url;if(d!=null)return{kind:"sticker",url:d}}}throw console.error("Cannot extract generated sticker from response:",c),new Error("Cannot find generated sticker")}}};return e.debug&&console.log("Created Provider:",n),n}var Zn=ef;var ve;function Xn(t){return async({cesdk:e})=>tf(e,t)}function tf(t,e){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,a=e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/";t.ui.addIconSet("@imgly/plugin/formats",Ki.Formats),ve=new Fi(n,Ze.map(({id:c,label:u})=>({id:c,label:u,thumbUri:xr(c,a)})),{translateLabel:_r(t,r,"style","sticker")});let o=ve.getActiveSelectValue();t.engine.asset.addSource(ve),t.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:c})=>c,cardLabelPosition:()=>"below"}),t.ui.registerPanel(`${je(r)}.styleSelection`,({builder:c,payload:u})=>{if(u==null)return null;c.Library(`${r}.library.style`,{entries:[n],onSelect:async l=>{u.onSelect(l)}})});let s={};return Ze.forEach(({id:c,label:u})=>{s[`ly.img.plugin-ai-sticker-generation-web.${r}.property.style.${c}`]=u}),t.i18n.setTranslations({en:{[`panel.${je("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",...s}}),Zn({falKey:i,modelKey:r,name:"Recraft 20b",schema:wr,inputReference:"#/components/schemas/Recraft20bInput",middleware:e.middlewares??e.middleware??[],headers:e.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:c,state:u},l)=>{let d=u("style/icon",o?o.id:"icon/broken_line");return c.Button(`${l.id}`,{inputLabel:[`ly.img.plugin-ai-sticker-generation-web.${r}.property.${l.id}`,`ly.img.plugin-ai-generation-web.property.${l.id}`,`ly.img.plugin-ai-sticker-generation-web.${r}.defaults.property.${l.id}`,`ly.img.plugin-ai-generation-web.defaults.property.${l.id}`],icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:ve.getTranslatedLabel(d.value||"icon/broken_line")||d.value||"icon/broken_line",labelAlignment:"left",onClick:()=>{let h={onSelect:async p=>{if(p.id==="back")return;let m=p.id;ve.clearActiveAssets(),ve.setAssetActive(p.id),d.setValue(m),t.ui.closePanel(`${je(r)}.styleSelection`)}};t.ui.openPanel(`${je(r)}.styleSelection`,{payload:h})}}),()=>({id:l.id,type:"string",value:d.value??"icon/broken_line"})}},getBlockInput:c=>{if(wt(c.image_size))return Promise.resolve({sticker:{width:c.image_size.width??512,height:c.image_size.height??512}});let u=Qe(c.image_size??"square_hd");return Promise.resolve({sticker:u})}},e)}var rf={Recraft20b:Xn},Wh=rf;export{Wh as default};
|
|
132
|
+
`;function _r(t,e,i="style",r="image"){return(n,o)=>{if(!mr(t))return o;let a=md(e,i,n,r);if(yr(t.i18n)){let s=t.i18n.translate(a);return s!==a[a.length-1]?s:o}return o}}function md(t,e,i,r="image"){return[`ly.img.plugin-ai-${r}-generation-web.${t}.property.${e}.${i}`,`ly.img.plugin-ai-generation-web.property.${e}.${i}`,`ly.img.plugin-ai-${r}-generation-web.${t}.defaults.property.${e}.${i}`,`ly.img.plugin-ai-generation-web.defaults.property.${e}.${i}`]}var vr={ImageUrl:sl,StyleTransfer:fd};var wr={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},Recraft20bInput:{title:"TextToImageInput",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},image_size:{anyOf:[{enum:["square_hd","square","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"],type:"string"},{$ref:"#/components/schemas/ImageSize"}],title:"Format",default:"square_hd","x-imgly-enum-labels":{ImageSize:"Custom",square_hd:"Square HD",square:"Square",portrait_4_3:"Portrait 4:3",portrait_16_9:"Portrait 16:9",landscape_4_3:"Landscape 4:3",landscape_16_9:"Landscape 16:9"},"x-imgly-enum-icons":{square:"@imgly/plugin/formats/ratio1by1",square_hd:"@imgly/plugin/formats/ratio1by1",portrait_4_3:"@imgly/plugin/formats/ratio3by4",portrait_16_9:"@imgly/plugin/formats/ratio9by16",landscape_4_3:"@imgly/plugin/formats/ratio4by3",landscape_16_9:"@imgly/plugin/formats/ratio16by9",ImageSize:"@imgly/plugin/formats/ratioFree"}},style:{enum:["any","realistic_image","digital_illustration","vector_illustration","realistic_image/b_and_w","realistic_image/hard_flash","realistic_image/hdr","realistic_image/natural_light","realistic_image/studio_portrait","realistic_image/enterprise","realistic_image/motion_blur","realistic_image/evening_light","realistic_image/faded_nostalgia","realistic_image/forest_life","realistic_image/mystic_naturalism","realistic_image/natural_tones","realistic_image/organic_calm","realistic_image/real_life_glow","realistic_image/retro_realism","realistic_image/retro_snapshot","realistic_image/urban_drama","realistic_image/village_realism","realistic_image/warm_folk","digital_illustration/pixel_art","digital_illustration/hand_drawn","digital_illustration/grain","digital_illustration/infantile_sketch","digital_illustration/2d_art_poster","digital_illustration/handmade_3d","digital_illustration/hand_drawn_outline","digital_illustration/engraving_color","digital_illustration/2d_art_poster_2","digital_illustration/antiquarian","digital_illustration/bold_fantasy","digital_illustration/child_book","digital_illustration/child_books","digital_illustration/cover","digital_illustration/crosshatch","digital_illustration/digital_engraving","digital_illustration/expressionism","digital_illustration/freehand_details","digital_illustration/grain_20","digital_illustration/graphic_intensity","digital_illustration/hard_comics","digital_illustration/long_shadow","digital_illustration/modern_folk","digital_illustration/multicolor","digital_illustration/neon_calm","digital_illustration/noir","digital_illustration/nostalgic_pastel","digital_illustration/outline_details","digital_illustration/pastel_gradient","digital_illustration/pastel_sketch","digital_illustration/pop_art","digital_illustration/pop_renaissance","digital_illustration/street_art","digital_illustration/tablet_sketch","digital_illustration/urban_glow","digital_illustration/urban_sketching","digital_illustration/vanilla_dreams","digital_illustration/young_adult_book","digital_illustration/young_adult_book_2","vector_illustration/bold_stroke","vector_illustration/chemistry","vector_illustration/colored_stencil","vector_illustration/contour_pop_art","vector_illustration/cosmics","vector_illustration/cutout","vector_illustration/depressive","vector_illustration/editorial","vector_illustration/emotional_flat","vector_illustration/infographical","vector_illustration/marker_outline","vector_illustration/mosaic","vector_illustration/naivector","vector_illustration/roundish_flat","vector_illustration/segmented_colors","vector_illustration/sharp_contrast","vector_illustration/thin","vector_illustration/vector_photo","vector_illustration/vivid_shapes","vector_illustration/engraving","vector_illustration/line_art","vector_illustration/line_circuit","vector_illustration/linocut","icon/broken_line","icon/colored_outline","icon/colored_shapes","icon/colored_shapes_gradient","icon/doodle_fill","icon/doodle_offset_fill","icon/offset_fill","icon/outline","icon/outline_gradient","icon/uneven_fill"],title:"Style",type:"string",description:"The style of the generated images. Vector images cost 2X as much.",default:"realistic_image"},colors:{title:"Colors",type:"array",description:"An array of preferable colors",items:{$ref:"#/components/schemas/RGBColor"},default:[]}},"x-fal-order-properties":["prompt","style","image_size"],required:["prompt"]},Recraft20bOutput:{title:"TextToImageOutput",type:"object",properties:{images:{title:"Images",type:"array",items:{$ref:"#/components/schemas/File"}}},"x-fal-order-properties":["images"],required:["images"]},ImageSize:{title:"ImageSize",type:"object",properties:{height:{maximum:14142,type:"integer",title:"Height",description:"The height of the generated image.",exclusiveMinimum:0,default:512},width:{maximum:14142,type:"integer",title:"Width",description:"The width of the generated image.",exclusiveMinimum:0,default:512}},"x-fal-order-properties":["width","height"]},RGBColor:{title:"RGBColor",type:"object",properties:{r:{minimum:0,maximum:255,type:"integer",title:"R",description:"Red color value",default:0},b:{minimum:0,maximum:255,type:"integer",title:"B",description:"Blue color value",default:0},g:{minimum:0,maximum:255,type:"integer",title:"G",description:"Green color value",default:0}},"x-fal-order-properties":["r","g","b"]},File:{title:"File",type:"object",properties:{file_size:{title:"File Size",type:"integer",description:"The size of the file in bytes."},file_name:{title:"File Name",type:"string",description:"The name of the file. It will be auto-generated if not provided."},content_type:{title:"Content Type",type:"string",description:"The mime type of the file."},url:{title:"Url",type:"string",description:"The URL where the file can be downloaded from."},file_data:{format:"binary",title:"File Data",type:"string",description:"File data"}},"x-fal-order-properties":["url","content_type","file_name","file_size","file_data"],required:["url"]}}},paths:{"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/status":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}},{name:"logs",in:"query",required:!1,schema:{type:"number",description:"Whether to include logs (`1`) in the response or not (`0`)."}}],responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/cancel":{put:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"The request was cancelled.",content:{"application/json":{schema:{type:"object",properties:{success:{type:"boolean",description:"Whether the request was cancelled successfully."}}}}}}}}},"/fal-ai/recraft/v2/text-to-image":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"Result of the request.",content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var bd={square_hd:{width:1024,height:1024},square:{width:512,height:512},portrait_4_3:{width:1024,height:1365},portrait_16_9:{width:1024,height:1820},landscape_4_3:{width:1365,height:1024},landscape_16_9:{width:1820,height:1024}};function Qe(t){return bd[t]}var _d=[{id:"realistic_image",label:"Realistic Image"},{id:"digital_illustration",label:"Digital Illustration"},{id:"realistic_image/b_and_w",label:"Black & White"},{id:"realistic_image/hard_flash",label:"Hard Flash"},{id:"realistic_image/hdr",label:"HDR"},{id:"realistic_image/natural_light",label:"Natural Light"},{id:"realistic_image/studio_portrait",label:"Studio Portrait"},{id:"realistic_image/enterprise",label:"Enterprise"},{id:"realistic_image/motion_blur",label:"Motion Blur"},{id:"realistic_image/evening_light",label:"Evening Light"},{id:"realistic_image/faded_nostalgia",label:"Faded Nostalgia"},{id:"realistic_image/forest_life",label:"Forest Life"},{id:"realistic_image/mystic_naturalism",label:"Mystic Naturalism"},{id:"realistic_image/natural_tones",label:"Natural Tones"},{id:"realistic_image/organic_calm",label:"Organic Calm"},{id:"realistic_image/real_life_glow",label:"Real Life Glow"},{id:"realistic_image/retro_realism",label:"Retro Realism"},{id:"realistic_image/retro_snapshot",label:"Retro Snapshot"},{id:"realistic_image/urban_drama",label:"Urban Drama"},{id:"realistic_image/village_realism",label:"Village Realism"},{id:"realistic_image/warm_folk",label:"Warm Folk"},{id:"digital_illustration/pixel_art",label:"Pixel Art"},{id:"digital_illustration/hand_drawn",label:"Hand Drawn"},{id:"digital_illustration/grain",label:"Grain"},{id:"digital_illustration/infantile_sketch",label:"Infantile Sketch"},{id:"digital_illustration/2d_art_poster",label:"2D Art Poster"},{id:"digital_illustration/handmade_3d",label:"Handmade 3D"},{id:"digital_illustration/hand_drawn_outline",label:"Hand Drawn Outline"},{id:"digital_illustration/engraving_color",label:"Engraving Color"},{id:"digital_illustration/2d_art_poster_2",label:"2D Art Poster 2"},{id:"digital_illustration/antiquarian",label:"Antiquarian"},{id:"digital_illustration/bold_fantasy",label:"Bold Fantasy"},{id:"digital_illustration/child_book",label:"Child Book"},{id:"digital_illustration/child_books",label:"Child Books"},{id:"digital_illustration/cover",label:"Cover"},{id:"digital_illustration/crosshatch",label:"Crosshatch"},{id:"digital_illustration/digital_engraving",label:"Digital Engraving"},{id:"digital_illustration/expressionism",label:"Expressionism"},{id:"digital_illustration/freehand_details",label:"Freehand Details"},{id:"digital_illustration/grain_20",label:"Grain 20"},{id:"digital_illustration/graphic_intensity",label:"Graphic Intensity"},{id:"digital_illustration/hard_comics",label:"Hard Comics"},{id:"digital_illustration/long_shadow",label:"Long Shadow"},{id:"digital_illustration/modern_folk",label:"Modern Folk"},{id:"digital_illustration/multicolor",label:"Multicolor"},{id:"digital_illustration/neon_calm",label:"Neon Calm"},{id:"digital_illustration/noir",label:"Noir"},{id:"digital_illustration/nostalgic_pastel",label:"Nostalgic Pastel"},{id:"digital_illustration/outline_details",label:"Outline Details"},{id:"digital_illustration/pastel_gradient",label:"Pastel Gradient"},{id:"digital_illustration/pastel_sketch",label:"Pastel Sketch"},{id:"digital_illustration/pop_art",label:"Pop Art"},{id:"digital_illustration/pop_renaissance",label:"Pop Renaissance"},{id:"digital_illustration/street_art",label:"Street Art"},{id:"digital_illustration/tablet_sketch",label:"Tablet Sketch"},{id:"digital_illustration/urban_glow",label:"Urban Glow"},{id:"digital_illustration/urban_sketching",label:"Urban Sketching"},{id:"digital_illustration/vanilla_dreams",label:"Vanilla Dreams"},{id:"digital_illustration/young_adult_book",label:"Young Adult Book"},{id:"digital_illustration/young_adult_book_2",label:"Young Adult Book 2"}],Hf=_d[0],vd=[{id:"vector_illustration",label:"Vector Illustration"},{id:"vector_illustration/bold_stroke",label:"Bold Stroke"},{id:"vector_illustration/chemistry",label:"Chemistry"},{id:"vector_illustration/colored_stencil",label:"Colored Stencil"},{id:"vector_illustration/contour_pop_art",label:"Contour Pop Art"},{id:"vector_illustration/cosmics",label:"Cosmics"},{id:"vector_illustration/cutout",label:"Cutout"},{id:"vector_illustration/depressive",label:"Depressive"},{id:"vector_illustration/editorial",label:"Editorial"},{id:"vector_illustration/emotional_flat",label:"Emotional Flat"},{id:"vector_illustration/infographical",label:"Infographical"},{id:"vector_illustration/marker_outline",label:"Marker Outline"},{id:"vector_illustration/mosaic",label:"Mosaic"},{id:"vector_illustration/naivector",label:"Naive Vector"},{id:"vector_illustration/roundish_flat",label:"Roundish Flat"},{id:"vector_illustration/segmented_colors",label:"Segmented Colors"},{id:"vector_illustration/sharp_contrast",label:"Sharp Contrast"},{id:"vector_illustration/thin",label:"Thin"},{id:"vector_illustration/vector_photo",label:"Vector Photo"},{id:"vector_illustration/vivid_shapes",label:"Vivid Shapes"},{id:"vector_illustration/engraving",label:"Engraving"},{id:"vector_illustration/line_art",label:"Line Art"},{id:"vector_illustration/line_circuit",label:"Line Circuit"},{id:"vector_illustration/linocut",label:"Linocut"}],Gf=vd[0],Ze=[{id:"icon/broken_line",label:"Broken Line"},{id:"icon/colored_outline",label:"Colored Outline"},{id:"icon/colored_shapes",label:"Colored Shapes"},{id:"icon/colored_shapes_gradient",label:"Colored Shapes Gradient"},{id:"icon/doodle_fill",label:"Doodle Fill"},{id:"icon/doodle_offset_fill",label:"Doodle Offset Fill"},{id:"icon/offset_fill",label:"Offset Fill"},{id:"icon/outline",label:"Outline"},{id:"icon/outline_gradient",label:"Outline Gradient"},{id:"icon/uneven_fill",label:"Uneven Fill"}],Kf=Ze[0],wd=t=>({realistic_image:`${t}/realistic_image.webp`,digital_illustration:`${t}/digital_illustration.webp`,"realistic_image/b_and_w":`${t}/realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${t}/realistic_image_hard_flash.webp`,"realistic_image/hdr":`${t}/realistic_image_hdr.webp`,"realistic_image/natural_light":`${t}/realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${t}/realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${t}/realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${t}/realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${t}/digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${t}/digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${t}/digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${t}/digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${t}/digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${t}/digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${t}/digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${t}/digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${t}/digital_illustration_2d_artposter_2.webp`,vector_illustration:`${t}/vector_illustration.svg`,"vector_illustration/bold_stroke":`${t}/vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${t}/vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${t}/vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${t}/vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${t}/vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${t}/vector_illustration_cutout.svg`,"vector_illustration/depressive":`${t}/vector_illustration_depressive.svg`,"vector_illustration/editorial":`${t}/vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${t}/vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${t}/vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${t}/vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${t}/vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${t}/vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${t}/vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${t}/vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${t}/vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${t}/vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${t}/vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${t}/vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${t}/vector_illustration_engraving.svg`,"vector_illustration/line_art":`${t}/vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${t}/vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${t}/vector_illustration_linocut.svg`,"realistic_image/evening_light":`${t}/realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${t}/realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${t}/realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${t}/realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${t}/realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${t}/realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${t}/realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${t}/realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${t}/realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${t}/realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${t}/realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${t}/realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${t}/digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${t}/digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${t}/digital_illustration_child_book.webp`,"digital_illustration/child_books":`${t}/digital_illustration_child_books.webp`,"digital_illustration/cover":`${t}/digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${t}/digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${t}/digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${t}/digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${t}/digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${t}/digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${t}/digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${t}/digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${t}/digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${t}/digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${t}/digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${t}/digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${t}/digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${t}/digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${t}/digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${t}/digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${t}/digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${t}/digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${t}/digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${t}/digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${t}/digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${t}/digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${t}/digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${t}/digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${t}/digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${t}/digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${t}/icon_broken_line.svg`,"icon/colored_outline":`${t}/icon_colored_outline.svg`,"icon/colored_shapes":`${t}/icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${t}/icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${t}/icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${t}/icon_doodle_offset_fill.svg`,"icon/offset_fill":`${t}/icon_offset_fill.svg`,"icon/outline":`${t}/icon_outline.svg`,"icon/outline_gradient":`${t}/icon_outline_gradient.svg`,"icon/uneven_fill":`${t}/icon_uneven_fill.svg`});function kr(t,e){return wd(`${e}thumbnails/`)[t]}var Yn=ao(Kn());function Wn(t,e){return(0,Yn.createFalClient)({proxyUrl:t,requestMiddleware:async r=>({...r,headers:{...r.headers,...e??{}}})})}function wt(t){return t!=null&&typeof t!="string"&&"width"in t&&"height"in t}async function Qn(t,e,i){if(e!=null){if(e.startsWith("blob:")){let r=i!=null?await i.engine.editor.getMimeType(e):"image/png",o=await(await fetch(e)).blob(),a=new File([o],`image.${jt(r)}`,{type:r});return t.storage.upload(a)}if(i!=null&&e.startsWith("buffer:")){let r=await i.engine.editor.getMimeType(e),n=i.engine.editor.getBufferLength(e),o=i.engine.editor.getBufferData(e,0,n),a=new Uint8Array(o),s=new File([a],`image.${jt(r)}`,{type:r});return t.storage.upload(s)}return e}}function ef(t,e){let i=t.middleware??e.middlewares??e.middleware??[],r=null,n={id:t.modelKey,kind:"sticker",name:t.name,initialize:async o=>{r=Wn(e.proxyUrl,t.headers),t.initialize?.(o)},input:{quickActions:{supported:br(t.supportedQuickActions??{},e.supportedQuickActions)},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?vr.ImageUrl(t.modelKey,{cesdk:t.cesdk}):{},...t.renderCustomProperty},getBlockInput:o=>{if(t.getBlockInput!=null)return t.getBlockInput(o);if(t.getStickerSize!=null){let{width:a,height:s}=t.getStickerSize(o);return Promise.resolve({sticker:{width:a,height:s}})}if(o.image_size!=null&&wt(o.image_size))return Promise.resolve({sticker:{width:o.image_size.width??512,height:o.image_size.height??512}});if(o.image_size!=null&&typeof o.image_size=="string"){let a=Qe(o.image_size);return Promise.resolve({sticker:a})}throw new Error("getBlockInput or getStickerSize must be provided")},userFlow:t.userFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:e.history??"@imgly/indexedDB",generate:async(o,{abortSignal:a})=>{if(!r)throw new Error("Provider not initialized");let s=await Qn(r,o.image_url,t.cesdk),c=await r.subscribe(t.falKey??t.modelKey,{abortSignal:a,input:s!=null?{...o,image_url:s}:o,logs:!0}),u=c?.data?.images;if(u!=null&&Array.isArray(u)){let d=u[0]?.url;if(d!=null)return{kind:"sticker",url:d}}else{let l=c?.data?.image;if(l!=null){let d=l?.url;if(d!=null)return{kind:"sticker",url:d}}}throw console.error("Cannot extract generated sticker from response:",c),new Error("Cannot find generated sticker")}}};return e.debug&&console.log("Created Provider:",n),n}var Zn=ef;var ve;function Xn(t){return async({cesdk:e})=>tf(e,t)}function tf(t,e){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/";t.ui.addIconSet("@imgly/plugin/formats",Ki.Formats),ve=new Fi(n,Ze.map(({id:c,label:u})=>({id:c,label:u,thumbUri:kr(c,o)})),{translateLabel:_r(t,r,"style","sticker")});let a=ve.getActiveSelectValue();t.engine.asset.addSource(ve),t.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:c})=>c,cardLabelPosition:()=>"below"}),t.ui.registerPanel(`${Oe(r)}.styleSelection`,({builder:c,payload:u})=>{if(u==null)return null;c.Library(`${r}.library.style`,{entries:[n],onSelect:async l=>{u.onSelect(l)}})});let s={};return Ze.forEach(({id:c,label:u})=>{s[`ly.img.plugin-ai-sticker-generation-web.${r}.property.style.${c}`]=u}),t.i18n.setTranslations({en:{[`panel.${Oe("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",...s}}),Zn({falKey:i,modelKey:r,name:"Recraft 20b",schema:wr,inputReference:"#/components/schemas/Recraft20bInput",middleware:e.middlewares??e.middleware??[],headers:e.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:c,state:u},l)=>{let d=u("style/icon",a?a.id:"icon/broken_line");return c.Button(`${l.id}`,{inputLabel:[`ly.img.plugin-ai-sticker-generation-web.${r}.property.${l.id}`,`ly.img.plugin-ai-generation-web.property.${l.id}`,`ly.img.plugin-ai-sticker-generation-web.${r}.defaults.property.${l.id}`,`ly.img.plugin-ai-generation-web.defaults.property.${l.id}`],icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:ve.getTranslatedLabel(d.value||"icon/broken_line")||d.value||"icon/broken_line",labelAlignment:"left",onClick:()=>{let h={onSelect:async p=>{if(p.id==="back")return;let m=p.id;ve.clearActiveAssets(),ve.setAssetActive(p.id),d.setValue(m),t.ui.closePanel(`${Oe(r)}.styleSelection`)}};t.ui.openPanel(`${Oe(r)}.styleSelection`,{payload:h})}}),()=>({id:l.id,type:"string",value:d.value??"icon/broken_line"})}},getBlockInput:c=>{if(wt(c.image_size))return Promise.resolve({sticker:{width:c.image_size.width??512,height:c.image_size.height??512}});let u=Qe(c.image_size??"square_hd");return Promise.resolve({sticker:u})}},e)}var rf={Recraft20b:Xn},Wh=rf;export{Wh as default};
|
|
133
133
|
/*! Bundled license information:
|
|
134
134
|
|
|
135
135
|
lodash-es/lodash.js:
|