@imgly/plugin-ai-sticker-generation-web 0.2.17 → 1.69.0-nightly.20260130

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.
@@ -1,8 +1,8 @@
1
- var io=Object.create;var Ei=Object.defineProperty;var ro=Object.getOwnPropertyDescriptor;var no=Object.getOwnPropertyNames;var oo=Object.getPrototypeOf,ao=Object.prototype.hasOwnProperty;var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var so=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of no(e))!ao.call(t,n)&&n!==i&&Ei(t,n,{get:()=>e[n],enumerable:!(r=ro(e,n))||r.enumerable});return t};var lo=(t,e,i)=>(i=t!=null?io(oo(t)):{},so(e||!t||!t.__esModule?Ei(i,"default",{value:t,enumerable:!0}):i,t));var Vt=k(D=>{"use strict";var Sd=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(D,"__esModule",{value:!0});D.TARGET_URL_HEADER=void 0;D.withMiddleware=Ed;D.withProxy=Id;function Ed(...t){let e=i=>typeof i=="function";return i=>Sd(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 Id(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 Er=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.ValidationError=P.ApiError=void 0;P.defaultResponseHandler=Ir;P.resultResponseHandler=Cd;var Ad="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 Je=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=Je;function Ir(t){return Er(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?Je: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 Cd(t){return Er(this,void 0,void 0,function*(){return{data:yield Ir(t),requestId:t.headers.get(Ad)||""}})}});var V=k($=>{"use strict";var Td=$&&$.__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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty($,"__esModule",{value:!0});$.ensureEndpointIdFormat=Ar;$.parseEndpointId=Od;$.isValidUrl=$d;$.throttle=jd;$.isReact=Dd;$.isPlainObject=Pd;$.sleep=Ud;function Ar(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 Md=["workflows","comfy"];function Od(t){let i=Ar(t).split("/");return Md.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 $d(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function jd(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 Ht;function Dd(){if(Ht===void 0){let t=new Error().stack;Ht=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return Ht}function Pd(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}function Ud(t){return Td(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}});var De=k(T=>{"use strict";var Nd=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,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=Cr;T.calculateBackoffDelay=Tr;T.executeWithRetry=zd;var Ld=q(),Fd=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 Cr(t,e){return t instanceof Ld.ApiError&&e.includes(t.status)}function Tr(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 zd(t,e,i){return Nd(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||!Cr(a,e.retryableStatusCodes))throw a;let l=Tr(o,e.baseDelay,e.maxDelay,e.backoffMultiplier,e.enableJitter);r.totalDelay+=l,i&&i(o+1,a,l),yield(0,Fd.sleep)(l)}}throw n})}});var Mr=k((th,Bd)=>{Bd.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 it=k(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.isBrowser=Rd;tt.getUserAgent=qd;function Rd(){return typeof window<"u"&&typeof window.document<"u"}var et=null;function qd(){if(et!==null)return et;let t=Mr();return et=`${t.name}/${t.version}`,et}});var rt=k(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.credentialsFromEnv=void 0;H.resolveDefaultFetch=jr;H.createConfig=Wd;H.getRestApiUrl=Qd;var Or=Vt(),Vd=q(),$r=De(),Hd=it();function jr(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function Gd(){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 Kd=()=>{if(Gd())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=Kd;var Yd={credentials:H.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:Vd.defaultResponseHandler,retry:$r.DEFAULT_RETRY_OPTIONS};function Wd(t){var e;let i=Object.assign(Object.assign(Object.assign({},Yd),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:jr(),retry:Object.assign(Object.assign({},$r.DEFAULT_RETRY_OPTIONS),t.retry||{})});t.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,Or.withMiddleware)(i.requestMiddleware,(0,Or.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,Hd.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 Qd(){return"https://rest.alpha.fal.ai"}});var me=k(G=>{"use strict";var Dr=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})},Zd=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=Jd;G.buildUrl=eg;var Pr=De(),Ur=it(),Gt=V(),Xd=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Jd(t){return Dr(this,void 0,void 0,function*(){var e;let{targetUrl:i,input:r,config:n,options:o={}}=t,{credentials:a,requestMiddleware:l,responseHandler:c,fetch:u}=n,s=Object.assign(Object.assign({},n.retry),o.retry||{}),d=()=>Dr(this,void 0,void 0,function*(){var p,m,y;let w=(0,Ur.isBrowser)()?{}:{"User-Agent":(0,Ur.getUserAgent)()},g=typeof a=="function"?a():a,{method:f,url:v,headers:_}=yield l({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:St,retry:af}=o,Si=Zd(o,["responseHandler","retry"]),to=yield u(v,Object.assign(Object.assign(Object.assign(Object.assign({},Si),{method:f,headers:Object.assign(Object.assign({},kt),(y=Si.headers)!==null&&y!==void 0?y:{})}),!Xd&&{mode:"cors"}),{signal:o.signal,body:f.toLowerCase()!=="get"&&r?JSON.stringify(r):void 0}));return yield(St??c)(to)}),h;for(let p=0;p<=s.maxRetries;p++)try{return yield d()}catch(m){if(h=m,p===s.maxRetries||!(0,Pr.isRetryableError)(m,s.retryableStatusCodes)||((e=o.signal)===null||e===void 0?void 0:e.aborted))throw m;let w=(0,Pr.calculateBackoffDelay)(p,s.baseDelay,s.maxDelay,s.backoffMultiplier,s.enableJitter);yield(0,Gt.sleep)(w)}throw h})}function eg(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,l=Object.assign(Object.assign({},e.query||{}),n==="get"?a:{}),c=Object.keys(l).length>0?`?${new URLSearchParams(l).toString()}`:"";if((0,Gt.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${o}${c}`;let u=(0,Gt.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var Lr=k(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});function tg(t){let e,i,r,n,o,a,l;return c(),{feed:u,reset:c};function c(){e=!0,i="",r=0,n=-1,o=void 0,a=void 0,l=""}function u(d){i=i?i+d:d,e&&ig(i)&&(i=i.slice(Nr.length)),e=!1;let h=i.length,p=0,m=!1;for(;p<h;){m&&(i[p]===`
1
+ var co=Object.create;var Mi=Object.defineProperty;var uo=Object.getOwnPropertyDescriptor;var go=Object.getOwnPropertyNames;var po=Object.getPrototypeOf,fo=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ho=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of go(t))!fo.call(e,n)&&n!==i&&Mi(e,n,{get:()=>t[n],enumerable:!(r=uo(t,n))||r.enumerable});return e};var mo=(e,t,i)=>(i=e!=null?co(po(e)):{},ho(t||!e||!e.__esModule?Mi(i,"default",{value:e,enumerable:!0}):i,e));var Wt=k(L=>{"use strict";var Od=L&&L.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(L,"__esModule",{value:!0});L.TARGET_URL_HEADER=void 0;L.withMiddleware=$d;L.withProxy=jd;function $d(...e){let t=i=>typeof i=="function";return i=>Od(this,void 0,void 0,function*(){let r=Object.assign({},i);for(let n of e.filter(t))r=yield n(r);return r})}L.TARGET_URL_HEADER="x-fal-target-url";function jd(e){let t=i=>Promise.resolve(i);return typeof window>"u"?t:i=>i.headers&&L.TARGET_URL_HEADER in i?t(i):Promise.resolve(Object.assign(Object.assign({},i),{url:e.targetUrl,headers:Object.assign(Object.assign({},i.headers||{}),{[L.TARGET_URL_HEADER]:i.url})}))}});var K=k(N=>{"use strict";var Mr=N&&N.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(N,"__esModule",{value:!0});N.ValidationError=N.ApiError=void 0;N.defaultResponseHandler=$r;N.resultResponseHandler=Dd;var Or="x-fal-request-id",ve=class extends Error{constructor({message:t,status:i,body:r,requestId:n}){super(t),this.name="ApiError",this.status=i,this.body=r,this.requestId=n||""}};N.ApiError=ve;var at=class extends ve{constructor(t){super(t),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(t){return this.fieldErrors.filter(i=>i.loc[i.loc.length-1]===t)}};N.ValidationError=at;function $r(e){return Mr(this,void 0,void 0,function*(){var t;let{status:i,statusText:r}=e,n=(t=e.headers.get("Content-Type"))!==null&&t!==void 0?t:"",o=e.headers.get(Or)||void 0;if(!e.ok){if(n.includes("application/json")){let a=yield e.json(),l=i===422?at:ve;throw new l({message:a.message||r,status:i,body:a,requestId:o})}throw new ve({message:`HTTP ${i}: ${r}`,status:i,requestId:o})}return n.includes("application/json")?e.json():n.includes("text/html")?e.text():n.includes("application/octet-stream")?e.arrayBuffer():e.text()})}function Dd(e){return Mr(this,void 0,void 0,function*(){return{data:yield $r(e),requestId:e.headers.get(Or)||""}})}});var Y=k(P=>{"use strict";var Pd=P&&P.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.ensureEndpointIdFormat=jr;P.parseEndpointId=Ld;P.isValidUrl=Nd;P.throttle=Fd;P.isReact=Rd;P.isPlainObject=Bd;P.sleep=zd;function jr(e){if(e.split("/").length>1)return e;let[,i,r]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(e)||[];if(i&&r)return`${i}/${r}`;throw new Error(`Invalid app id: ${e}. Must be in the format <appOwner>/<appId>`)}var Ud=["workflows","comfy"];function Ld(e){let i=jr(e).split("/");return Ud.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 Nd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function Fd(e,t,i=!1){let r,n;return(...o)=>{!n&&i?(e(...o),n=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-n>=t&&(e(...o),n=Date.now())},t-(Date.now()-n)))}}var Qt;function Rd(){if(Qt===void 0){let e=new Error().stack;Qt=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return Qt}function Bd(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function zd(e){return Pd(this,void 0,void 0,function*(){return new Promise(t=>setTimeout(t,e))})}});var Be=k(M=>{"use strict";var qd=M&&M.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(M,"__esModule",{value:!0});M.DEFAULT_RETRY_OPTIONS=M.DEFAULT_RETRYABLE_STATUS_CODES=void 0;M.isRetryableError=Dr;M.calculateBackoffDelay=Pr;M.executeWithRetry=Gd;var Vd=K(),Hd=Y();M.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];M.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:M.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Dr(e,t){return e instanceof Vd.ApiError&&t.includes(e.status)}function Pr(e,t,i,r,n){let o=Math.min(t*Math.pow(r,e),i);if(n){let a=.25*o*(Math.random()*2-1);return Math.max(0,o+a)}return o}function Gd(e,t,i){return qd(this,void 0,void 0,function*(){let r={totalAttempts:0,totalDelay:0},n;for(let o=0;o<=t.maxRetries;o++){r.totalAttempts++;try{return{result:yield e(),metrics:r}}catch(a){if(n=a,r.lastError=a,o===t.maxRetries||!Dr(a,t.retryableStatusCodes))throw a;let l=Pr(o,t.baseDelay,t.maxDelay,t.backoffMultiplier,t.enableJitter);r.totalDelay+=l,i&&i(o+1,a,l),yield(0,Hd.sleep)(l)}}throw n})}});var Ur=k((gh,Kd)=>{Kd.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.8.3",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:">=22.0.0"},type:"commonjs"}});var ct=k(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.isBrowser=Yd;lt.getUserAgent=Wd;function Yd(){return typeof window<"u"&&typeof window.document<"u"}var st=null;function Wd(){if(st!==null)return st;let e=Ur();return st=`${e.name}/${e.version}`,st}});var ut=k(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.credentialsFromEnv=void 0;W.resolveDefaultFetch=Fr;W.createConfig=tg;W.getRestApiUrl=ig;var Lr=Wt(),Qd=K(),Nr=Be(),Zd=ct();function Fr(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function Xd(){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 Jd=()=>{if(Xd())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};W.credentialsFromEnv=Jd;var eg={credentials:W.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:Qd.defaultResponseHandler,retry:Nr.DEFAULT_RETRY_OPTIONS};function tg(e){var t;let i=Object.assign(Object.assign(Object.assign({},eg),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:Fr(),retry:Object.assign(Object.assign({},Nr.DEFAULT_RETRY_OPTIONS),e.retry||{})});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,Lr.withMiddleware)(i.requestMiddleware,(0,Lr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,Zd.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 ig(){return"https://rest.alpha.fal.ai"}});var we=k(Q=>{"use strict";var Rr=Q&&Q.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})},rg=Q&&Q.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]]);return i};Object.defineProperty(Q,"__esModule",{value:!0});Q.dispatchRequest=og;Q.buildUrl=ag;var Br=Be(),zr=ct(),Zt=Y(),ng=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function og(e){return Rr(this,void 0,void 0,function*(){var t;let{targetUrl:i,input:r,config:n,options:o={}}=e,{credentials:a,requestMiddleware:l,responseHandler:c,fetch:u}=n,s=Object.assign(Object.assign({},n.retry),o.retry||{}),d=()=>Rr(this,void 0,void 0,function*(){var p,m,y;let w=(0,zr.isBrowser)()?{}:{"User-Agent":(0,zr.getUserAgent)()},g=typeof a=="function"?a():a,{method:f,url:v,headers:_}=yield l({method:((m=(p=e.method)!==null&&p!==void 0?p:o.method)!==null&&m!==void 0?m:"post").toUpperCase(),url:i,headers:e.headers}),T=g?{Authorization:`Key ${g}`}:{},Ee=Object.assign(Object.assign(Object.assign(Object.assign({},T),{Accept:"application/json","Content-Type":"application/json"}),w),_??{}),{responseHandler:te,retry:j}=o,C=rg(o,["responseHandler","retry"]),D=yield u(v,Object.assign(Object.assign(Object.assign(Object.assign({},C),{method:f,headers:Object.assign(Object.assign({},Ee),(y=C.headers)!==null&&y!==void 0?y:{})}),!ng&&{mode:"cors"}),{signal:o.signal,body:f.toLowerCase()!=="get"&&r?JSON.stringify(r):void 0}));return yield(te??c)(D)}),h;for(let p=0;p<=s.maxRetries;p++)try{return yield d()}catch(m){if(h=m,p===s.maxRetries||!(0,Br.isRetryableError)(m,s.retryableStatusCodes)||((t=o.signal)===null||t===void 0?void 0:t.aborted))throw m;let w=(0,Br.calculateBackoffDelay)(p,s.baseDelay,s.maxDelay,s.backoffMultiplier,s.enableJitter);yield(0,Zt.sleep)(w)}throw h})}function ag(e,t={}){var i,r;let n=((i=t.method)!==null&&i!==void 0?i:"post").toLowerCase(),o=((r=t.path)!==null&&r!==void 0?r:"").replace(/^\//,"").replace(/\/{2,}/,"/"),a=t.input,l=Object.assign(Object.assign({},t.query||{}),n==="get"?a:{}),c=Object.keys(l).length>0?`?${new URLSearchParams(l).toString()}`:"";if((0,Zt.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${c}`;let u=(0,Zt.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var Jt=k(F=>{"use strict";var ne=F&&F.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(F,"__esModule",{value:!0});F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER=void 0;F.getExpirationDurationSeconds=Xt;F.buildObjectLifecycleHeaders=cg;F.createStorageClient=pg;var qr=ut(),Vr=we(),sg=Y();F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER="x-fal-object-lifecycle-preference";var lg={never:31536e5,immediate:void 0,"1h":3600,"1d":86400,"7d":604800,"30d":2592e3,"1y":31536e3};function Xt(e){let{expiresIn:t}=e;return typeof t=="number"?t:lg[t]}function cg(e){if(!e)return{};let t=Xt(e);return t===void 0?{}:{[F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER]:JSON.stringify({expiration_duration_seconds:t})}}function Hr(e){var t;let[,i]=e.split("/");return(t=i.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function ug(e,t,i,r){return ne(this,void 0,void 0,function*(){let n=e.name||`${Date.now()}.${Hr(i)}`,o={};if(r){let a={expiration_duration_seconds:Xt(r),allow_io_storage:r.expiresIn!=="immediate"};o["X-Fal-Object-Lifecycle"]=JSON.stringify(a)}return yield(0,Vr.dispatchRequest)({method:"POST",targetUrl:`${(0,qr.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:n},config:t,headers:o})})}function dg(e,t,i,r){return ne(this,void 0,void 0,function*(){let n=e.name||`${Date.now()}.${Hr(i)}`,o={};return r&&(o["X-Fal-Object-Lifecycle"]=JSON.stringify(r)),yield(0,Vr.dispatchRequest)({method:"POST",targetUrl:`${(0,qr.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:n},config:t,headers:o})})}function Gr(e,t,i){return ne(this,arguments,void 0,function*(r,n,o,a=3){if(a===0)throw new Error("Part upload failed, retries exhausted");let{fetch:l,responseHandler:c}=o;try{let u=yield l(r,{method:"PUT",body:n});return yield c(u)}catch{return yield Gr(r,n,o,a-1)}})}function gg(e,t,i){return ne(this,void 0,void 0,function*(){let{fetch:r,responseHandler:n}=t,o=e.type||"application/octet-stream",{upload_url:a,file_url:l}=yield dg(e,t,o,i),c=10*1024*1024,u=Math.ceil(e.size/c),s=new URL(a),d=[];for(let m=0;m<u;m++){let y=m*c,w=Math.min(y+c,e.size),g=e.slice(y,w),f=m+1,v=`${s.origin}${s.pathname}/${f}${s.search}`;d.push(yield Gr(v,g,t))}let h=`${s.origin}${s.pathname}/complete${s.search}`,p=yield r(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:d.map(m=>({partNumber:m.partNumber,etag:m.etag}))})});return yield n(p),l})}function pg({config:e}){let t={upload:(i,r)=>ne(this,void 0,void 0,function*(){let n=r?.lifecycle;if(i.size>94371840)return yield gg(i,e,n);let o=i.type||"application/octet-stream",{fetch:a,responseHandler:l}=e,{upload_url:c,file_url:u}=yield ug(i,e,o,n),s=yield a(c,{method:"PUT",body:i,headers:{"Content-Type":i.type||"application/octet-stream"}});return yield l(s),u}),transformInput:i=>ne(this,void 0,void 0,function*(){if(Array.isArray(i))return Promise.all(i.map(r=>t.transformInput(r)));if(i instanceof Blob)return yield t.upload(i);if((0,sg.isPlainObject)(i)){let n=Object.entries(i).map(a=>ne(this,[a],void 0,function*([l,c]){return[l,yield t.transformInput(c)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return i})};return t}});var Yr=k(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});function fg(e){let t,i,r,n,o,a,l;return c(),{feed:u,reset:c};function c(){t=!0,i="",r=0,n=-1,o=void 0,a=void 0,l=""}function u(d){i=i?i+d:d,t&&hg(i)&&(i=i.slice(Kr.length)),t=!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;s(i,p,w,y),p+=y+1}p===h?i="":p>0&&(i=i.slice(p))}function s(d,h,p,m){if(m===0){l.length>0&&(t({type:"event",id:o,event:a||void 0,data:l.slice(0,-1)}),l="",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")l+=_?"".concat(_,`
3
+ `&&(y=f-p);if(y<0){r=h-p,n=w;break}else r=0,n=-1;s(i,p,w,y),p+=y+1}p===h?i="":p>0&&(i=i.slice(p))}function s(d,h,p,m){if(m===0){l.length>0&&(e({type:"event",id:o,event:a||void 0,data:l.slice(0,-1)}),l="",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")l+=_?"".concat(_,`
4
4
  `):`
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 Nr=[239,187,191];function ig(t){return Nr.every((e,i)=>t.charCodeAt(i)===e)}Kt.createParser=tg});var Yt=k(K=>{"use strict";var rg=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(K,"__esModule",{value:!0});K.TOKEN_EXPIRATION_SECONDS=void 0;K.getTemporaryAuthToken=sg;var ng=rt(),og=me(),ag=V();K.TOKEN_EXPIRATION_SECONDS=120;function sg(t,e){return rg(this,void 0,void 0,function*(){let i=(0,ag.parseEndpointId)(t),r=yield(0,og.dispatchRequest)({method:"POST",targetUrl:`${(0,ng.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 Qt=k(j=>{"use strict";var be=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,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)},lg=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,o=[];return n={},l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(p){return function(m){return Promise.resolve(m).then(p,d)}}function l(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(s,d):h(o[0][2],p)}function s(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(j,"__esModule",{value:!0});j.FalStream=void 0;j.createStreamingClient=gg;var cg=Lr(),ug=Yt(),Fr=me(),ye=q(),Wt="text/event-stream",dg=15*1e3,nt=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:l,options:c}=this,{input:u,method:s="post",connectionMode:d="server"}=c;try{if(d==="client"){let h=yield(0,ug.getTemporaryAuthToken)(l,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:s.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:Wt,"content-type":"application/json"},body:u&&s!=="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,Fr.dispatchRequest)({method:s.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:Wt},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,l;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(Wt)){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 s=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,cg.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=(l=this.options.timeout)!==null&&l!==void 0?l:dg,m=()=>be(this,void 0,void 0,function*(){let{value:y,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(s.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 l=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",l)},this.on=(o,a)=>{var l;this.listeners.has(o)||this.listeners.set(o,[]),(l=this.listeners.get(o))===null||l===void 0||l.push(a)},this.emit=(o,a)=>{let l=this.listeners.get(o)||[];for(let c of l)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,Fr.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 l;o((l=this.currentData)!==null&&l!==void 0?l:{})}),this.on("done",l=>{this.streamClosed=!0,o(l)}),this.on("error",l=>{this.streamClosed=!0,a(l)})}),r.signal&&r.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return lg(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}};j.FalStream=nt;function gg({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 nt(i,t,Object.assign(Object.assign({},r),{input:n}))})}}}});var qr=k(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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})},pg=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(),fg=q(),Rr=De(),hg=Qt(),ot=V(),zr=500,Br={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:Rr.DEFAULT_RETRYABLE_STATUS_CODES},mg={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...Rr.DEFAULT_RETRYABLE_STATUS_CODES,500]},yg=({config:t,storage:e})=>{let i={submit(r,n){return J(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a,hint:l}=n,c=pg(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"},l&&{"x-fal-runner-hint":l}),input:u,config:t,options:{signal:n.abortSignal,retry:Br}})})},status(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,abortSignal:c}){let u=(0,ot.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"";return(0,F.dispatchRequest)({method:"get",targetUrl:(0,F.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:l?"1":"0"},path:`/requests/${a}/status`}),config:t,options:{signal:c,retry:mg}})})},streamStatus(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,connectionMode:c}){let u=(0,ot.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"",d={logs:l?"1":"0"},h=(0,F.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new hg.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,l,c=()=>{};if(n.mode==="streaming"){let u=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),s=[];a&&(l=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&&s.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:s}):h))});let d=yield u.done();return l&&clearTimeout(l),d}return new Promise((u,s)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:zr,m=()=>{l&&clearTimeout(l),h&&clearTimeout(h)};a&&(l=setTimeout(()=>{m(),i.cancel(r,{requestId:o}).catch(c),s(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(),s(g)}});y().catch(s)})})},result(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,ot.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:fg.resultResponseHandler}),options:{signal:l,retry:Br}})})},cancel(r,n){return J(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,ot.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:l}})})}};return i};Y.createQueueClient=yg});var at=k(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.utf8Count=bg;z.utf8EncodeJs=Vr;z.utf8EncodeTE=Hr;z.utf8Encode=wg;z.utf8DecodeJs=Gr;z.utf8DecodeTD=Kr;z.utf8Decode=Eg;function bg(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 Vr(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 l=t.charCodeAt(o);(l&64512)===56320&&(++o,a=((a&1023)<<10)+(l&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 _g=new TextEncoder,vg=50;function Hr(t,e,i){_g.encodeInto(t,e.subarray(i))}function wg(t,e,i){t.length>vg?Hr(t,e,i):Vr(t,e,i)}var xg=4096;function Gr(t,e,i){let r=e,n=r+i,o=[],a="";for(;r<n;){let l=t[r++];if(!(l&128))o.push(l);else if((l&224)===192){let c=t[r++]&63;o.push((l&31)<<6|c)}else if((l&240)===224){let c=t[r++]&63,u=t[r++]&63;o.push((l&31)<<12|c<<6|u)}else if((l&248)===240){let c=t[r++]&63,u=t[r++]&63,s=t[r++]&63,d=(l&7)<<18|c<<12|u<<6|s;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(l);o.length>=xg&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var kg=new TextDecoder,Sg=200;function Kr(t,e,i){let r=t.subarray(e,e+i);return kg.decode(r)}function Eg(t,e,i){return i>Sg?Kr(t,e,i):Gr(t,e,i)}});var Xt=k(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.ExtData=void 0;var Zt=class{constructor(e,i){this.type=e,this.data=i}};st.ExtData=Zt});var ct=k(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.DecodeError=void 0;var Jt=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})}};lt.DecodeError=Jt});var ut=k(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.UINT32_MAX=void 0;W.setUint64=Ig;W.setInt64=Ag;W.getInt64=Cg;W.getUint64=Tg;W.UINT32_MAX=4294967295;function Ig(t,e,i){let r=i/4294967296,n=i;t.setUint32(e,r),t.setUint32(e+4,n)}function Ag(t,e,i){let r=Math.floor(i/4294967296),n=i;t.setUint32(e,r),t.setUint32(e+4,n)}function Cg(t,e){let i=t.getInt32(e),r=t.getUint32(e+4);return i*4294967296+r}function Tg(t,e){let i=t.getUint32(e),r=t.getUint32(e+4);return i*4294967296+r}});var ei=k(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.timestampExtension=M.EXT_TIMESTAMP=void 0;M.encodeTimeSpecToTimestamp=Wr;M.encodeDateToTimeSpec=Qr;M.encodeTimestampExtension=Zr;M.decodeTimestampToTimeSpec=Xr;M.decodeTimestampExtension=Jr;var Mg=ct(),Yr=ut();M.EXT_TIMESTAMP=-1;var Og=4294967296-1,$g=17179869184-1;function Wr({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=$g)if(e===0&&t<=Og){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,Yr.setInt64)(r,4,t),i}}function Qr(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 Zr(t){if(t instanceof Date){let e=Qr(t);return Wr(e)}else return null}function Xr(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,Yr.getInt64)(e,4),r=e.getUint32(0);return{sec:i,nsec:r}}default:throw new Mg.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Jr(t){let e=Xr(t);return new Date(e.sec*1e3+e.nsec/1e6)}M.timestampExtension={type:M.EXT_TIMESTAMP,encode:Zr,decode:Jr}});var pt=k(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.ExtensionCodec=void 0;var dt=Xt(),jg=ei(),Ue=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(jg.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 dt.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 dt.ExtData(a,o)}}}return e instanceof dt.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 dt.ExtData(i,e)}};gt.ExtensionCodec=Ue;Ue.defaultCodec=new Ue});var ii=k(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});ti.ensureUint8Array=Pg;function Dg(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function Pg(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Dg(t)?new Uint8Array(t):Uint8Array.from(t)}});var ni=k(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.Encoder=U.DEFAULT_INITIAL_BUFFER_SIZE=U.DEFAULT_MAX_DEPTH=void 0;var en=at(),Ug=pt(),tn=ut(),Ng=ii();U.DEFAULT_MAX_DEPTH=100;U.DEFAULT_INITIAL_BUFFER_SIZE=2048;var ri=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??Ug.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,en.utf8Count)(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,en.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,Ng.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,tn.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,tn.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=ri});var rn=k(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});oi.encode=Fg;var Lg=ni();function Fg(t,e){return new Lg.Encoder(e).encodeSharedRef(t)}});var nn=k(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.prettyByte=zg;function zg(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var on=k(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.CachedKeyDecoder=void 0;var Bg=at(),Rg=16,qg=16,si=class{constructor(e=Rg,i=qg){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 l=0;l<r;l++)if(a[l]!==e[i+l])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,Bg.utf8DecodeJs)(e,i,r),a=Uint8Array.prototype.slice.call(e,i,i+r);return this.store(a,o),o}};ft.CachedKeyDecoder=si});var mt=k(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.Decoder=void 0;var li=nn(),Vg=pt(),ee=ut(),Hg=at(),an=ii(),Gg=on(),B=ct(),ci="array",Le="map_key",ln="map_value",Kg=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)},ui=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=ci,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===ci){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===Le||e.type===ln){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,gi=new DataView(new ArrayBuffer(0)),Yg=new Uint8Array(gi.buffer);try{gi.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 sn=new RangeError("Insufficient data"),Wg=new Gg.CachedKeyDecoder,di=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=gi,this.bytes=Yg,this.headByte=Ne,this.stack=new ui,this.entered=!1,this.extensionCodec=e?.extensionCodec??Vg.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:Wg,this.mapKeyConverter=e?.mapKeyConverter??Kg}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,an.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,an.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 l of e){if(i)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(l);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,li.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,li.prettyByte)(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===ci)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=ln;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,li.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 sn;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,r,e):n=(0,Hg.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 sn;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}};ht.Decoder=di});var un=k(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.decode=Qg;yt.decodeMulti=Zg;var cn=mt();function Qg(t,e){return new cn.Decoder(e).decode(t)}function Zg(t,e){return new cn.Decoder(e).decodeMulti(t)}});var pn=k(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.isAsyncIterable=dn;Fe.asyncIterableFromStream=gn;Fe.ensureAsyncIterable=Xg;function dn(t){return t[Symbol.asyncIterator]!=null}async function*gn(t){let e=t.getReader();try{for(;;){let{done:i,value:r}=await e.read();if(i)return;yield r}}finally{e.releaseLock()}}function Xg(t){return dn(t)?t:gn(t)}});var fn=k(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.decodeAsync=Jg;ze.decodeArrayStream=ep;ze.decodeMultiStream=tp;var pi=mt(),fi=pn();async function Jg(t,e){let i=(0,fi.ensureAsyncIterable)(t);return new pi.Decoder(e).decodeAsync(i)}function ep(t,e){let i=(0,fi.ensureAsyncIterable)(t);return new pi.Decoder(e).decodeArrayStream(i)}function tp(t,e){let i=(0,fi.ensureAsyncIterable)(t);return new pi.Decoder(e).decodeStream(i)}});var mn=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 ip=rn();Object.defineProperty(x,"encode",{enumerable:!0,get:function(){return ip.encode}});var hn=un();Object.defineProperty(x,"decode",{enumerable:!0,get:function(){return hn.decode}});Object.defineProperty(x,"decodeMulti",{enumerable:!0,get:function(){return hn.decodeMulti}});var hi=fn();Object.defineProperty(x,"decodeAsync",{enumerable:!0,get:function(){return hi.decodeAsync}});Object.defineProperty(x,"decodeArrayStream",{enumerable:!0,get:function(){return hi.decodeArrayStream}});Object.defineProperty(x,"decodeMultiStream",{enumerable:!0,get:function(){return hi.decodeMultiStream}});var rp=mt();Object.defineProperty(x,"Decoder",{enumerable:!0,get:function(){return rp.Decoder}});var np=ct();Object.defineProperty(x,"DecodeError",{enumerable:!0,get:function(){return np.DecodeError}});var op=ni();Object.defineProperty(x,"Encoder",{enumerable:!0,get:function(){return op.Encoder}});var ap=pt();Object.defineProperty(x,"ExtensionCodec",{enumerable:!0,get:function(){return ap.ExtensionCodec}});var sp=Xt();Object.defineProperty(x,"ExtData",{enumerable:!0,get:function(){return sp.ExtData}});var _e=ei();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 On=k(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});function A(t){return{enumerable:!0,value:t}}function yn(t){return{enumerable:!0,writable:!0,value:t}}var te={},lp=()=>!0,bn=()=>({}),vn=t=>t,cp=(t,e,i,r)=>t.apply(i,r)&&e.apply(i,r),up=(t,e,i,[r,n])=>e.call(i,t.call(i,r,n),n),Q=(t,e)=>Object.freeze(Object.create(t,e));function _n(t,e,i){return t.reduce((r,n)=>function(...o){return i(r,n,this,o)},e)}function wn(t){return Q(this,{fn:A(t)})}var xn={},kn=wn.bind(xn),dp=t=>kn((e,i)=>!!~t(e,i)&&e),Sn={},gp=wn.bind(Sn);function bt(t,e){return e.filter(i=>t.isPrototypeOf(i))}function En(t,e,...i){let r=_n(bt(Sn,i).map(o=>o.fn),lp,cp),n=_n(bt(xn,i).map(o=>o.fn),vn,up);return Q(this,{from:A(t),to:A(e),guards:A(r),reducers:A(n)})}var In={},An={},pp=En.bind(In),fp=En.bind(An,null);function hp(t,e,i){return yi(e,t,i,this.immediates)||t}function Cn(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 mp={enter:vn};function yp(...t){let e=bt(In,t),i=bt(An,t),r={final:A(t.length===0),transitions:A(Cn(e))};return i.length&&(r.immediates=A(i),r.enter=A(hp)),Q(mp,r)}var bp={enter(t,e,i){let r=this.fn.call(e,e.context,i);return mi.isPrototypeOf(r)?Q(Tn,{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)}},Tn={enter(t,e,i){if(e.child=Mn(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,yi(e,t,{type:"done",data:r},this.transitions.get("done"))}return t}};function _p(t,...e){let i=A(Cn(e));return mi.isPrototypeOf(t)?Q(Tn,{machine:A(t),transitions:i}):Q(bp,{fn:A(t),transitions:i})}var mi={get state(){return{name:this.current,value:this.states[this.current]}}};function vp(t,e,i=bn){return typeof t!="string"&&(i=e||bn,e=t,t=Object.keys(e)[0]),te._create&&te._create(t,e),Q(mi,{context:A(i),current:A(t),states:A(e)})}function yi(t,e,i,r){let{context:n}=t;for(let{to:o,guards:a,reducers:l}of r)if(a(n,i)){t.context=l.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 wp(t,e){let i=e.type||e,{machine:r}=t,{value:n,name:o}=r.state;return n.transitions.has(i)?yi(t,r,e,n.transitions.get(i))||r:(te._send&&te._send(i,o),r)}var xp={send(t){this.machine=wp(this,t),this.onChange(this)}};function Mn(t,e,i,r){let n=Object.create(xp,{machine:yn(t),context:yn(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=dp;O.createMachine=vp;O.d=te;O.guard=gp;O.immediate=fp;O.interpret=Mn;O.invoke=_p;O.reduce=kn;O.state=yp;O.transition=pp});var Un=k(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.createRealtimeClient=Np;var vt=mn(),b=On(),$n=Yt(),bi=q(),jn=it(),wi=V(),kp=()=>({enqueuedMessage:void 0});function Sp(t){return t.token!==void 0}function Ep(t){return!Sp(t)}function _t(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 Ip(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,vt.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function _i(t){return Object.assign(Object.assign({},t),{token:void 0})}function Ap(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Cp(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var Tp=(0,b.createMachine)("idle",{idle:(0,b.state)((0,b.transition)("send","connecting",(0,b.reduce)(_t)),(0,b.transition)("expireToken","idle",(0,b.reduce)(_i)),(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)(Cp)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(R)),(0,b.transition)("send","connecting",(0,b.reduce)(_t)),(0,b.transition)("close","idle",(0,b.reduce)(R)),(0,b.immediate)("authRequired",(0,b.guard)(Ep))),authRequired:(0,b.state)((0,b.transition)("initiateAuth","authInProgress"),(0,b.transition)("send","authRequired",(0,b.reduce)(_t)),(0,b.transition)("close","idle",(0,b.reduce)(R))),authInProgress:(0,b.state)((0,b.transition)("authenticated","connecting",(0,b.reduce)(Ap)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(_i),(0,b.reduce)(R)),(0,b.transition)("send","authInProgress",(0,b.reduce)(_t)),(0,b.transition)("close","idle",(0,b.reduce)(R))),active:(0,b.state)((0,b.transition)("send","active",(0,b.reduce)(Ip)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(_i)),(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)))},kp);function Mp(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,wi.ensureEndpointIdFormat)(t)}/realtime?${r.toString()}`}var Op=128;function $p(t){return t.status==="error"&&t.error==="Unauthorized"}var jp={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},vi=new Map,Dn=new Map;function Dp(t,e,i){if(!vi.has(t)){let r=(0,b.interpret)(Tp,i);vi.set(t,Object.assign(Object.assign({},r),{throttledSend:e>0?(0,wi.throttle)(r.send,e,!0):r.send}))}return vi.get(t)}var Be=()=>{},Pp={send:Be,close:Be};function Up(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!Pn(t)}function Pn(t){return t.type==="x-fal-error"}function Np({config:t}){return{connect(e,i){let{clientOnly:r=(0,wi.isReact)()&&!(0,jn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:a=Op}=i;if(r&&!(0,jn.isBrowser)())return Pp;let l;Dn.set(n,{onError:i.onError,onResult:i.onResult});let c=()=>Dn.get(n),u=Dp(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&&l!==p.current&&(m({type:"initiateAuth"}),(0,$n.getTemporaryAuthToken)(e,t).then(g=>{m({type:"authenticated",token:g});let f=Math.round($n.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{m({type:"expireToken"})},f)}).catch(g=>{m({type:"unauthorized",error:g})})),p.current==="connecting"&&l!==p.current&&w!==void 0){let g=new WebSocket(Mp(e,{token:w,maxBuffering:o}));g.onopen=()=>{m({type:"connected",websocket:g})},g.onclose=f=>{if(f.code!==jp.NORMAL_CLOSURE){let{onError:v=Be}=c();v(new bi.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 bi.ApiError({message:"Unknown error",status:500}))},g.onmessage=f=>{let{onResult:v}=c();if(f.data instanceof ArrayBuffer){let C=(0,vt.decode)(new Uint8Array(f.data));v(C);return}if(f.data instanceof Uint8Array){let C=(0,vt.decode)(f.data);v(C);return}if(f.data instanceof Blob){f.data.arrayBuffer().then(C=>{let kt=(0,vt.decode)(new Uint8Array(C));v(kt)});return}let _=JSON.parse(f.data);if($p(_)){m({type:"unauthorized",error:new Error("Unauthorized")});return}if(Up(_)){v(_);return}if(Pn(_)){if(_.error==="TIMEOUT")return;let{onError:C=Be}=c();C(new bi.ApiError({message:`${_.error}: ${_.reason}`,status:400,body:_}));return}}}l=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var Bn=k(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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(Re,"__esModule",{value:!0});Re.createStorageClient=Rp;var Nn=rt(),Ln=me(),Lp=V();function Fn(t){var e;let[i,r]=t.split("/");return(e=r.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function Fp(t,e,i){return ie(this,void 0,void 0,function*(){let r=t.name||`${Date.now()}.${Fn(i)}`;return yield(0,Ln.dispatchRequest)({method:"POST",targetUrl:`${(0,Nn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:e})})}function zp(t,e,i){return ie(this,void 0,void 0,function*(){let r=t.name||`${Date.now()}.${Fn(i)}`;return yield(0,Ln.dispatchRequest)({method:"POST",targetUrl:`${(0,Nn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:e})})}function zn(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:l,responseHandler:c}=o;try{let u=yield l(r,{method:"PUT",body:n});return yield c(u)}catch{return yield zn(r,n,o,a-1)}})}function Bp(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 zp(t,e,n),l=10*1024*1024,c=Math.ceil(t.size/l),u=new URL(o),s=[];for(let p=0;p<c;p++){let m=p*l,y=Math.min(m+l,t.size),w=t.slice(m,y),g=p+1,f=`${u.origin}${u.pathname}/${g}${u.search}`;s.push(yield zn(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:s.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield r(h),a})}function Rp({config:t}){let e={upload:i=>ie(this,void 0,void 0,function*(){if(i.size>94371840)return yield Bp(i,t);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:o}=t,{upload_url:a,file_url:l}=yield Fp(i,t,r),c=yield n(a,{method:"PUT",body:i,headers:{"Content-Type":i.type||"application/octet-stream"}});return yield o(c),l}),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,Lp.isPlainObject)(i)){let n=Object.entries(i).map(a=>ie(this,[a],void 0,function*([l,c]){return[l,yield e.transformInput(c)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return i})};return e}});var ki=k(qe=>{"use strict";var Rn=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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(t,e||[])).next())})};Object.defineProperty(qe,"__esModule",{value:!0});qe.createFalClient=Wp;var qp=rt(),Vp=qr(),Hp=Un(),qn=me(),Gp=q(),Kp=Bn(),Yp=Qt();function Wp(t={}){let e=(0,qp.createConfig)(t),i=(0,Kp.createStorageClient)({config:e}),r=(0,Vp.createQueueClient)({config:e,storage:i}),n=(0,Yp.createStreamingClient)({config:e,storage:i}),o=(0,Hp.createRealtimeClient)({config:e});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return Rn(this,arguments,void 0,function*(l,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,qn.dispatchRequest)({method:c.method,targetUrl:(0,qn.buildUrl)(l,c),input:u,config:Object.assign(Object.assign({},e),{responseHandler:Gp.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(a,l)=>Rn(this,void 0,void 0,function*(){let{request_id:c}=yield r.submit(a,l);return l.onEnqueue&&l.onEnqueue(c),yield r.subscribeToStatus(a,Object.assign({requestId:c},l)),r.result(a,{requestId:c})})}}});var Hn=k(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.isQueueStatus=Vn;wt.isCompletedQueueStatus=Qp;function Vn(t){return t&&t.status&&t.response_url}function Qp(t){return Vn(t)&&t.status==="COMPLETED"}});var Wn=k(I=>{"use strict";var Zp=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]}),Xp=I&&I.__exportStar||function(t,e){for(var i in t)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&Zp(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 Gn=ki(),Jp=ki();Object.defineProperty(I,"createFalClient",{enumerable:!0,get:function(){return Jp.createFalClient}});var Kn=Vt();Object.defineProperty(I,"withMiddleware",{enumerable:!0,get:function(){return Kn.withMiddleware}});Object.defineProperty(I,"withProxy",{enumerable:!0,get:function(){return Kn.withProxy}});var Yn=q();Object.defineProperty(I,"ApiError",{enumerable:!0,get:function(){return Yn.ApiError}});Object.defineProperty(I,"ValidationError",{enumerable:!0,get:function(){return Yn.ValidationError}});var ef=De();Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return ef.isRetryableError}});Xp(Hn(),I);var tf=V();Object.defineProperty(I,"parseEndpointId",{enumerable:!0,get:function(){return tf.parseEndpointId}});I.fal=function(){let e=(0,Gn.createFalClient)();return{config(i){e=(0,Gn.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 co=`
5
+ `;else if(w==="event")a=_;else if(w==="id"&&!_.includes("\0"))o=_;else if(w==="retry"){let T=parseInt(_,10);Number.isNaN(T)||e({type:"reconnect-interval",value:T})}}}var Kr=[239,187,191];function hg(e){return Kr.every((t,i)=>e.charCodeAt(i)===t)}ei.createParser=fg});var ti=k(Z=>{"use strict";var mg=Z&&Z.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(Z,"__esModule",{value:!0});Z.TOKEN_EXPIRATION_SECONDS=void 0;Z.getTemporaryAuthToken=vg;var yg=ut(),bg=we(),_g=Y();Z.TOKEN_EXPIRATION_SECONDS=120;function vg(e,t){return mg(this,void 0,void 0,function*(){let i=(0,_g.parseEndpointId)(e),r=yield(0,bg.dispatchRequest)({method:"POST",targetUrl:`${(0,yg.getRestApiUrl)()}/tokens/`,config:t,input:{allowed_apps:[i.alias],token_expiration:Z.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var ri=k(U=>{"use strict";var ke=U&&U.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})},ze=U&&U.__await||function(e){return this instanceof ze?(this.v=e,this):new ze(e)},wg=U&&U.__asyncGenerator||function(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(e,t||[]),n,o=[];return n={},l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(p){return function(m){return Promise.resolve(m).then(p,d)}}function l(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 ze?Promise.resolve(p.value.v).then(s,d):h(o[0][2],p)}function s(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(U,"__esModule",{value:!0});U.FalStream=void 0;U.createStreamingClient=Ig;var xg=Yr(),kg=ti(),Wr=we(),xe=K(),ii="text/event-stream",Sg=15*1e3,dt=class{constructor(t,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=()=>ke(this,void 0,void 0,function*(){var o,a;let{endpointId:l,options:c}=this,{input:u,method:s="post",connectionMode:d="server"}=c;try{if(d==="client"){let h=yield(0,kg.getTemporaryAuthToken)(l,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:s.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:ii,"content-type":"application/json"},body:u&&s!=="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,Wr.dispatchRequest)({method:s.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:ii},responseHandler:h=>ke(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=>ke(this,void 0,void 0,function*(){var a,l;if(!o.ok){try{yield(0,xe.defaultResponseHandler)(o)}catch(y){this.emit("error",y)}return}let c=o.body;if(!c){this.emit("error",new xe.ApiError({message:"Response body is empty.",status:400,body:void 0,requestId:this._requestId||void 0}));return}if(!((a=o.headers.get("content-type"))!==null&&a!==void 0?a:"").startsWith(ii)){let y=c.getReader(),w=()=>{y.read().then(({done:g,value:f})=>{if(g){this.emit("done",this.currentData);return}this.buffer.push(f),this.currentData=f,this.emit("data",f),w()})};w();return}let s=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,xg.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=(l=this.options.timeout)!==null&&l!==void 0?l:Sg,m=()=>ke(this,void 0,void 0,function*(){let{value:y,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(s.decode(y)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new xe.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408,requestId:this._requestId||void 0})),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 l=o instanceof xe.ApiError?o:new xe.ApiError({message:(a=o.message)!==null&&a!==void 0?a:"An unknown error occurred",status:500,requestId:this._requestId||void 0});this.emit("error",l)},this.on=(o,a)=>{var l;this.listeners.has(o)||this.listeners.set(o,[]),(l=this.listeners.get(o))===null||l===void 0||l.push(a)},this.emit=(o,a)=>{let l=this.listeners.get(o)||[];for(let c of l)c(a)},this.done=()=>ke(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=t,this.config=i,this.url=(n=r.url)!==null&&n!==void 0?n:(0,Wr.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new xe.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0,requestId:this._requestId||void 0})),this.signal.addEventListener("abort",()=>{var l;o((l=this.currentData)!==null&&l!==void 0?l:{})}),this.on("done",l=>{this.streamClosed=!0,o(l)}),this.on("error",l=>{this.streamClosed=!0,a(l)})}),r.signal&&r.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return wg(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 ze(n)),yield ze(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};U.FalStream=dt;function Ig({config:e,storage:t}){return{stream(i,r){return ke(this,void 0,void 0,function*(){let n=r.input?yield t.transformInput(r.input):void 0;return new dt(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var Jr=k(X=>{"use strict";var oe=X&&X.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})},Eg=X&&X.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]]);return i};Object.defineProperty(X,"__esModule",{value:!0});X.createQueueClient=void 0;var q=we(),Ag=K(),Xr=Be(),Cg=Jt(),Tg=ri(),gt=Y(),Qr=500,Mg="x-fal-queue-priority",Og="x-fal-runner-hint",Zr={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:Xr.DEFAULT_RETRYABLE_STATUS_CODES},$g={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...Xr.DEFAULT_RETRYABLE_STATUS_CODES,500]},jg=({config:e,storage:t})=>{let i={submit(r,n){return oe(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a,hint:l,headers:c,storageSettings:u}=n,s=Eg(n,["webhookUrl","priority","hint","headers","storageSettings"]),d=n.input?yield t.transformInput(n.input):void 0,h=Object.fromEntries(Object.entries(c??{}).map(([p,m])=>[p.toLowerCase(),m]));return(0,q.dispatchRequest)({method:n.method,targetUrl:(0,q.buildUrl)(r,Object.assign(Object.assign({},s),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:Object.assign(Object.assign(Object.assign(Object.assign({},h),(0,Cg.buildObjectLifecycleHeaders)(u)),{[Mg]:a??"normal"}),l&&{[Og]:l}),input:d,config:e,options:{signal:n.abortSignal,retry:Zr}})})},status(r,n){return oe(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,abortSignal:c}){let u=(0,gt.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"";return(0,q.dispatchRequest)({method:"get",targetUrl:(0,q.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:l?"1":"0"},path:`/requests/${a}/status`}),config:e,options:{signal:c,retry:$g}})})},streamStatus(r,n){return oe(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,connectionMode:c}){let u=(0,gt.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"",d={logs:l?"1":"0"},h=(0,q.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new Tg.FalStream(o,e,{url:h,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(r,n){return oe(this,void 0,void 0,function*(){let o=n.requestId,a=n.timeout,l,c=()=>{};if(n.mode==="streaming"){let u=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),s=[];a&&(l=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&&s.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:s}):h))});let d=yield u.done();return l&&clearTimeout(l),d}return new Promise((u,s)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:Qr,m=()=>{l&&clearTimeout(l),h&&clearTimeout(h)};a&&(l=setTimeout(()=>{m(),i.cancel(r,{requestId:o}).catch(c),s(new Error(`Client timed out waiting for the request to complete after ${a}ms`))},a));let y=()=>oe(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(),s(g)}});y().catch(s)})})},result(r,n){return oe(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,gt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,q.dispatchRequest)({method:"get",targetUrl:(0,q.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:Ag.resultResponseHandler}),options:{signal:l,retry:Zr}})})},cancel(r,n){return oe(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,gt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,q.dispatchRequest)({method:"put",targetUrl:(0,q.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:l}})})}};return i};X.createQueueClient=jg});var pt=k(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.utf8Count=Dg;V.utf8EncodeJs=en;V.utf8EncodeTE=tn;V.utf8Encode=Lg;V.utf8DecodeJs=rn;V.utf8DecodeTD=nn;V.utf8Decode=Bg;function Dg(e){let t=e.length,i=0,r=0;for(;r<t;){let n=e.charCodeAt(r++);if(n&4294967168)if(!(n&4294965248))i+=2;else{if(n>=55296&&n<=56319&&r<t){let o=e.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 en(e,t,i){let r=e.length,n=i,o=0;for(;o<r;){let a=e.charCodeAt(o++);if(a&4294967168)if(!(a&4294965248))t[n++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&o<r){let l=e.charCodeAt(o);(l&64512)===56320&&(++o,a=((a&1023)<<10)+(l&1023)+65536)}a&4294901760?(t[n++]=a>>18&7|240,t[n++]=a>>12&63|128,t[n++]=a>>6&63|128):(t[n++]=a>>12&15|224,t[n++]=a>>6&63|128)}else{t[n++]=a;continue}t[n++]=a&63|128}}var Pg=new TextEncoder,Ug=50;function tn(e,t,i){Pg.encodeInto(e,t.subarray(i))}function Lg(e,t,i){e.length>Ug?tn(e,t,i):en(e,t,i)}var Ng=4096;function rn(e,t,i){let r=t,n=r+i,o=[],a="";for(;r<n;){let l=e[r++];if(!(l&128))o.push(l);else if((l&224)===192){let c=e[r++]&63;o.push((l&31)<<6|c)}else if((l&240)===224){let c=e[r++]&63,u=e[r++]&63;o.push((l&31)<<12|c<<6|u)}else if((l&248)===240){let c=e[r++]&63,u=e[r++]&63,s=e[r++]&63,d=(l&7)<<18|c<<12|u<<6|s;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(l);o.length>=Ng&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var Fg=new TextDecoder,Rg=200;function nn(e,t,i){let r=e.subarray(t,t+i);return Fg.decode(r)}function Bg(e,t,i){return i>Rg?nn(e,t,i):rn(e,t,i)}});var oi=k(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.ExtData=void 0;var ni=class{type;data;constructor(t,i){this.type=t,this.data=i}};ft.ExtData=ni});var mt=k(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.DecodeError=void 0;var ai=class e extends Error{constructor(t){super(t);let i=Object.create(e.prototype);Object.setPrototypeOf(this,i),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};ht.DecodeError=ai});var yt=k(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.UINT32_MAX=void 0;J.setUint64=zg;J.setInt64=qg;J.getInt64=Vg;J.getUint64=Hg;J.UINT32_MAX=4294967295;function zg(e,t,i){let r=i/4294967296,n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function qg(e,t,i){let r=Math.floor(i/4294967296),n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function Vg(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function Hg(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var si=k(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.timestampExtension=O.EXT_TIMESTAMP=void 0;O.encodeTimeSpecToTimestamp=an;O.encodeDateToTimeSpec=sn;O.encodeTimestampExtension=ln;O.decodeTimestampToTimeSpec=cn;O.decodeTimestampExtension=un;var Gg=mt(),on=yt();O.EXT_TIMESTAMP=-1;var Kg=4294967296-1,Yg=17179869184-1;function an({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=Yg)if(t===0&&e<=Kg){let i=new Uint8Array(4);return new DataView(i.buffer).setUint32(0,e),i}else{let i=e/4294967296,r=e&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,t<<2|i&3),o.setUint32(4,r),n}else{let i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,t),(0,on.setInt64)(r,4,e),i}}function sn(e){let t=e.getTime(),i=Math.floor(t/1e3),r=(t-i*1e3)*1e6,n=Math.floor(r/1e9);return{sec:i+n,nsec:r-n*1e9}}function ln(e){if(e instanceof Date){let t=sn(e);return an(t)}else return null}function cn(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let i=t.getUint32(0),r=t.getUint32(4),n=(i&3)*4294967296+r,o=i>>>2;return{sec:n,nsec:o}}case 12:{let i=(0,on.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new Gg.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function un(e){let t=cn(e);return new Date(t.sec*1e3+t.nsec/1e6)}O.timestampExtension={type:O.EXT_TIMESTAMP,encode:ln,decode:un}});var vt=k(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.ExtensionCodec=void 0;var bt=oi(),Wg=si(),li=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(Wg.timestampExtension)}register({type:t,encode:i,decode:r}){if(t>=0)this.encoders[t]=i,this.decoders[t]=r;else{let n=-1-t;this.builtInEncoders[n]=i,this.builtInDecoders[n]=r}}tryToEncode(t,i){for(let r=0;r<this.builtInEncoders.length;r++){let n=this.builtInEncoders[r];if(n!=null){let o=n(t,i);if(o!=null){let a=-1-r;return new bt.ExtData(a,o)}}}for(let r=0;r<this.encoders.length;r++){let n=this.encoders[r];if(n!=null){let o=n(t,i);if(o!=null){let a=r;return new bt.ExtData(a,o)}}}return t instanceof bt.ExtData?t:null}decode(t,i,r){let n=i<0?this.builtInDecoders[-1-i]:this.decoders[i];return n?n(t,i,r):new bt.ExtData(i,t)}};_t.ExtensionCodec=li});var ui=k(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.ensureUint8Array=Zg;function Qg(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function Zg(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Qg(e)?new Uint8Array(e):Uint8Array.from(e)}});var gi=k(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.Encoder=R.DEFAULT_INITIAL_BUFFER_SIZE=R.DEFAULT_MAX_DEPTH=void 0;var dn=pt(),Xg=vt(),gn=yt(),Jg=ui();R.DEFAULT_MAX_DEPTH=100;R.DEFAULT_INITIAL_BUFFER_SIZE=2048;var di=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(t){this.extensionCodec=t?.extensionCodec??Xg.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.maxDepth=t?.maxDepth??R.DEFAULT_MAX_DEPTH,this.initialBufferSize=t?.initialBufferSize??R.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=t?.sortKeys??!1,this.forceFloat32=t?.forceFloat32??!1,this.ignoreUndefined=t?.ignoreUndefined??!1,this.forceIntegerToFloat=t?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({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(t){if(this.entered)return this.clone().encodeSharedRef(t);try{return this.entered=!0,this.reinitializeState(),this.doEncode(t,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(t){if(this.entered)return this.clone().encode(t);try{return this.entered=!0,this.reinitializeState(),this.doEncode(t,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(t,i){if(i>this.maxDepth)throw new Error(`Too deep objects in depth ${i}`);t==null?this.encodeNil():typeof t=="boolean"?this.encodeBoolean(t):typeof t=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(t):this.encodeNumber(t):typeof t=="string"?this.encodeString(t):this.useBigInt64&&typeof t=="bigint"?this.encodeBigInt64(t):this.encodeObject(t,i)}ensureBufferSizeToWrite(t){let i=this.pos+t;this.view.byteLength<i&&this.resizeBuffer(i*2)}resizeBuffer(t){let i=new ArrayBuffer(t),r=new Uint8Array(i),n=new DataView(i);r.set(this.bytes),this.view=n,this.bytes=r}encodeNil(){this.writeU8(192)}encodeBoolean(t){t===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(t){!this.forceIntegerToFloat&&Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):this.useBigInt64?this.encodeNumberAsFloat(t):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):this.useBigInt64?this.encodeNumberAsFloat(t):(this.writeU8(211),this.writeI64(t)):this.encodeNumberAsFloat(t)}encodeNumberAsFloat(t){this.forceFloat32?(this.writeU8(202),this.writeF32(t)):(this.writeU8(203),this.writeF64(t))}encodeBigInt64(t){t>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(t)):(this.writeU8(211),this.writeBigInt64(t))}writeStringHeader(t){if(t<32)this.writeU8(160+t);else if(t<256)this.writeU8(217),this.writeU8(t);else if(t<65536)this.writeU8(218),this.writeU16(t);else if(t<4294967296)this.writeU8(219),this.writeU32(t);else throw new Error(`Too long string: ${t} bytes in UTF-8`)}encodeString(t){let r=(0,dn.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,dn.utf8Encode)(t,this.bytes,this.pos),this.pos+=r}encodeObject(t,i){let r=this.extensionCodec.tryToEncode(t,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(t))this.encodeArray(t,i);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if(typeof t=="object")this.encodeMap(t,i);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(t)}`)}encodeBinary(t){let i=t.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,Jg.ensureUint8Array)(t);this.writeU8a(r)}encodeArray(t,i){let r=t.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 t)this.doEncode(n,i+1)}countWithoutUndefined(t,i){let r=0;for(let n of i)t[n]!==void 0&&r++;return r}encodeMap(t,i){let r=Object.keys(t);this.sortKeys&&r.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(t,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=t[o];this.ignoreUndefined&&a===void 0||(this.encodeString(o),this.doEncode(a,i+1))}}encodeExtension(t){if(typeof t.data=="function"){let r=t.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(t.type),this.writeU8a(r);return}let i=t.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(t.type),this.writeU8a(t.data)}writeU8(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++}writeU8a(t){let i=t.length;this.ensureBufferSizeToWrite(i),this.bytes.set(t,this.pos),this.pos+=i}writeI8(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++}writeU16(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2}writeI16(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2}writeU32(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4}writeI32(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4}writeF32(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4}writeF64(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8}writeU64(t){this.ensureBufferSizeToWrite(8),(0,gn.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,gn.setInt64)(this.view,this.pos,t),this.pos+=8}writeBigUint64(t){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,t),this.pos+=8}writeBigInt64(t){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,t),this.pos+=8}};R.Encoder=di});var pn=k(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.encode=tp;var ep=gi();function tp(e,t){return new ep.Encoder(t).encodeSharedRef(e)}});var fn=k(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.prettyByte=ip;function ip(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var hn=k(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.CachedKeyDecoder=void 0;var rp=pt(),np=16,op=16,hi=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(t=np,i=op){this.maxKeyLength=t,this.maxLengthPerKey=i,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(t){return t>0&&t<=this.maxKeyLength}find(t,i,r){let n=this.caches[r-1];e:for(let o of n){let a=o.bytes;for(let l=0;l<r;l++)if(a[l]!==t[i+l])continue e;return o.str}return null}store(t,i){let r=this.caches[t.length-1],n={bytes:t,str:i};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)}decode(t,i,r){let n=this.find(t,i,r);if(n!=null)return this.hit++,n;this.miss++;let o=(0,rp.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};wt.CachedKeyDecoder=hi});var kt=k(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.Decoder=void 0;var mi=fn(),ap=vt(),ae=yt(),sp=pt(),mn=ui(),lp=hn(),H=mt(),yi="array",Ve="map_key",bn="map_value",cp=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new H.DecodeError("The type of key must be string or number but "+typeof e)},bi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(t){let i=this.getUninitializedStateFromPool();i.type=yi,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=Ve,i.readCount=0,i.size=t,i.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let t={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(t)}return this.stack[this.stackHeadPosition]}release(t){if(this.stack[this.stackHeadPosition]!==t)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(t.type===yi){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===Ve||t.type===bn){let r=t;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},qe=-1,vi=new DataView(new ArrayBuffer(0)),up=new Uint8Array(vi.buffer);try{vi.getInt8(0)}catch(e){if(!(e 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 yn=new RangeError("Insufficient data"),dp=new lp.CachedKeyDecoder,_i=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=vi;bytes=up;headByte=qe;stack=new bi;entered=!1;constructor(t){this.extensionCodec=t?.extensionCodec??ap.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.rawStrings=t?.rawStrings??!1,this.maxStrLength=t?.maxStrLength??ae.UINT32_MAX,this.maxBinLength=t?.maxBinLength??ae.UINT32_MAX,this.maxArrayLength=t?.maxArrayLength??ae.UINT32_MAX,this.maxMapLength=t?.maxMapLength??ae.UINT32_MAX,this.maxExtLength=t?.maxExtLength??ae.UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:dp,this.mapKeyConverter=t?.mapKeyConverter??cp}clone(){return new e({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=qe,this.stack.reset()}setBuffer(t){let i=(0,mn.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===qe&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,mn.ensureUint8Array)(t),n=new Uint8Array(i.length+r.length);n.set(i),n.set(r,i.length),this.setBuffer(n)}}hasRemaining(t){return this.view.byteLength-this.pos>=t}createExtraByteError(t){let{view:i,pos:r}=this;return new RangeError(`Extra ${i.byteLength-r} of ${i.byteLength} byte(s) found at buffer[${t}]`)}decode(t){if(this.entered)return this.clone().decode(t);try{this.entered=!0,this.reinitializeState(),this.setBuffer(t);let i=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return i}finally{this.entered=!1}}*decodeMulti(t){if(this.entered){yield*this.clone().decodeMulti(t);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(t);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(t){if(this.entered)return this.clone().decodeAsync(t);try{this.entered=!0;let i=!1,r;for await(let l of t){if(i)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(l);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,mi.prettyByte)(n)} at ${a} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(t){return this.decodeMultiAsync(t,!0)}decodeStream(t){return this.decodeMultiAsync(t,!1)}async*decodeMultiAsync(t,i){if(this.entered){yield*this.clone().decodeMultiAsync(t,i);return}try{this.entered=!0;let r=i,n=-1;for await(let o of t){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 t=this.readHeadByte(),i;if(t>=224)i=t-256;else if(t<192)if(t<128)i=t;else if(t<144){let n=t-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t<160){let n=t-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else{let n=t-160;i=this.decodeString(n,0)}else if(t===192)i=null;else if(t===194)i=!1;else if(t===195)i=!0;else if(t===202)i=this.readF32();else if(t===203)i=this.readF64();else if(t===204)i=this.readU8();else if(t===205)i=this.readU16();else if(t===206)i=this.readU32();else if(t===207)this.useBigInt64?i=this.readU64AsBigInt():i=this.readU64();else if(t===208)i=this.readI8();else if(t===209)i=this.readI16();else if(t===210)i=this.readI32();else if(t===211)this.useBigInt64?i=this.readI64AsBigInt():i=this.readI64();else if(t===217){let n=this.lookU8();i=this.decodeString(n,1)}else if(t===218){let n=this.lookU16();i=this.decodeString(n,2)}else if(t===219){let n=this.lookU32();i=this.decodeString(n,4)}else if(t===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(t===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(t===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t===196){let n=this.lookU8();i=this.decodeBinary(n,1)}else if(t===197){let n=this.lookU16();i=this.decodeBinary(n,2)}else if(t===198){let n=this.lookU32();i=this.decodeBinary(n,4)}else if(t===212)i=this.decodeExtension(1,0);else if(t===213)i=this.decodeExtension(2,0);else if(t===214)i=this.decodeExtension(4,0);else if(t===215)i=this.decodeExtension(8,0);else if(t===216)i=this.decodeExtension(16,0);else if(t===199){let n=this.lookU8();i=this.decodeExtension(n,1)}else if(t===200){let n=this.lookU16();i=this.decodeExtension(n,2)}else if(t===201){let n=this.lookU32();i=this.decodeExtension(n,4)}else throw new H.DecodeError(`Unrecognized type byte: ${(0,mi.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===yi)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===Ve){if(i==="__proto__")throw new H.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=bn;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=Ve;continue e}}return i}}readHeadByte(){return this.headByte===qe&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=qe}readArraySize(){let t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new H.DecodeError(`Unrecognized array type byte: ${(0,mi.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new H.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new H.DecodeError(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(t)}decodeString(t,i){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(t,i):this.decodeBinary(t,i)}decodeUtf8String(t,i){if(t>this.maxStrLength)throw new H.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw yn;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,sp.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ve:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new H.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw yn;let r=this.pos+i,n=this.bytes.subarray(r,r+t);return this.pos+=i+t,n}decodeExtension(t,i){if(t>this.maxExtLength)throw new H.DecodeError(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+i),n=this.decodeBinary(t,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 t=this.view.getUint8(this.pos);return this.pos++,t}readI8(){let t=this.view.getInt8(this.pos);return this.pos++,t}readU16(){let t=this.view.getUint16(this.pos);return this.pos+=2,t}readI16(){let t=this.view.getInt16(this.pos);return this.pos+=2,t}readU32(){let t=this.view.getUint32(this.pos);return this.pos+=4,t}readI32(){let t=this.view.getInt32(this.pos);return this.pos+=4,t}readU64(){let t=(0,ae.getUint64)(this.view,this.pos);return this.pos+=8,t}readI64(){let t=(0,ae.getInt64)(this.view,this.pos);return this.pos+=8,t}readU64AsBigInt(){let t=this.view.getBigUint64(this.pos);return this.pos+=8,t}readI64AsBigInt(){let t=this.view.getBigInt64(this.pos);return this.pos+=8,t}readF32(){let t=this.view.getFloat32(this.pos);return this.pos+=4,t}readF64(){let t=this.view.getFloat64(this.pos);return this.pos+=8,t}};xt.Decoder=_i});var vn=k(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.decode=gp;St.decodeMulti=pp;var _n=kt();function gp(e,t){return new _n.Decoder(t).decode(e)}function pp(e,t){return new _n.Decoder(t).decodeMulti(e)}});var kn=k(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.isAsyncIterable=wn;He.asyncIterableFromStream=xn;He.ensureAsyncIterable=fp;function wn(e){return e[Symbol.asyncIterator]!=null}async function*xn(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function fp(e){return wn(e)?e:xn(e)}});var Sn=k(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.decodeAsync=hp;Ge.decodeArrayStream=mp;Ge.decodeMultiStream=yp;var wi=kt(),xi=kn();async function hp(e,t){let i=(0,xi.ensureAsyncIterable)(e);return new wi.Decoder(t).decodeAsync(i)}function mp(e,t){let i=(0,xi.ensureAsyncIterable)(e);return new wi.Decoder(t).decodeArrayStream(i)}function yp(e,t){let i=(0,xi.ensureAsyncIterable)(e);return new wi.Decoder(t).decodeStream(i)}});var En=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 bp=pn();Object.defineProperty(x,"encode",{enumerable:!0,get:function(){return bp.encode}});var In=vn();Object.defineProperty(x,"decode",{enumerable:!0,get:function(){return In.decode}});Object.defineProperty(x,"decodeMulti",{enumerable:!0,get:function(){return In.decodeMulti}});var ki=Sn();Object.defineProperty(x,"decodeAsync",{enumerable:!0,get:function(){return ki.decodeAsync}});Object.defineProperty(x,"decodeArrayStream",{enumerable:!0,get:function(){return ki.decodeArrayStream}});Object.defineProperty(x,"decodeMultiStream",{enumerable:!0,get:function(){return ki.decodeMultiStream}});var _p=kt();Object.defineProperty(x,"Decoder",{enumerable:!0,get:function(){return _p.Decoder}});var vp=mt();Object.defineProperty(x,"DecodeError",{enumerable:!0,get:function(){return vp.DecodeError}});var wp=gi();Object.defineProperty(x,"Encoder",{enumerable:!0,get:function(){return wp.Encoder}});var xp=vt();Object.defineProperty(x,"ExtensionCodec",{enumerable:!0,get:function(){return xp.ExtensionCodec}});var kp=oi();Object.defineProperty(x,"ExtData",{enumerable:!0,get:function(){return kp.ExtData}});var Se=si();Object.defineProperty(x,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return Se.EXT_TIMESTAMP}});Object.defineProperty(x,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return Se.encodeDateToTimeSpec}});Object.defineProperty(x,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return Se.encodeTimeSpecToTimestamp}});Object.defineProperty(x,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return Se.decodeTimestampToTimeSpec}});Object.defineProperty(x,"encodeTimestampExtension",{enumerable:!0,get:function(){return Se.encodeTimestampExtension}});Object.defineProperty(x,"decodeTimestampExtension",{enumerable:!0,get:function(){return Se.decodeTimestampExtension}})});var Bn=k($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});function A(e){return{enumerable:!0,value:e}}function An(e){return{enumerable:!0,writable:!0,value:e}}var se={},Sp=()=>!0,Cn=()=>({}),Mn=e=>e,Ip=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),Ep=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),ee=(e,t)=>Object.freeze(Object.create(e,t));function Tn(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function On(e){return ee(this,{fn:A(e)})}var $n={},jn=On.bind($n),Ap=e=>jn((t,i)=>!!~e(t,i)&&t),Dn={},Cp=On.bind(Dn);function It(e,t){return t.filter(i=>e.isPrototypeOf(i))}function Pn(e,t,...i){let r=Tn(It(Dn,i).map(o=>o.fn),Sp,Ip),n=Tn(It($n,i).map(o=>o.fn),Mn,Ep);return ee(this,{from:A(e),to:A(t),guards:A(r),reducers:A(n)})}var Un={},Ln={},Tp=Pn.bind(Un),Mp=Pn.bind(Ln,null);function Op(e,t,i){return Ii(t,e,i,this.immediates)||e}function Nn(e){let t=new Map;for(let i of e)t.has(i.from)||t.set(i.from,[]),t.get(i.from).push(i);return t}var $p={enter:Mn};function jp(...e){let t=It(Un,e),i=It(Ln,e),r={final:A(e.length===0),transitions:A(Nn(t))};return i.length&&(r.immediates=A(i),r.enter=A(Op)),ee($p,r)}var Dp={enter(e,t,i){let r=this.fn.call(t,t.context,i);return Si.isPrototypeOf(r)?ee(Fn,{machine:A(r),transitions:A(this.transitions)}).enter(e,t,i):(r.then(n=>t.send({type:"done",data:n})).catch(n=>t.send({type:"error",error:n})),e)}},Fn={enter(e,t,i){if(t.child=Rn(this.machine,r=>{t.onChange(r),t.child==r&&r.machine.state.value.final&&(delete t.child,t.send({type:"done",data:r.context}))},t.context,i),t.child.machine.state.value.final){let r=t.child.context;return delete t.child,Ii(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function Pp(e,...t){let i=A(Nn(t));return Si.isPrototypeOf(e)?ee(Fn,{machine:A(e),transitions:i}):ee(Dp,{fn:A(e),transitions:i})}var Si={get state(){return{name:this.current,value:this.states[this.current]}}};function Up(e,t,i=Cn){return typeof e!="string"&&(i=t||Cn,t=e,e=Object.keys(t)[0]),se._create&&se._create(e,t),ee(Si,{context:A(i),current:A(e),states:A(t)})}function Ii(e,t,i,r){let{context:n}=e;for(let{to:o,guards:a,reducers:l}of r)if(a(n,i)){e.context=l.call(e,n,i);let c=t.original||t,u=ee(c,{current:A(o),original:{value:c}});return se._onEnter&&se._onEnter(t,o,e.context,n,i),u.state.value.enter(u,e,i)}}function Lp(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?Ii(e,r,t,n.transitions.get(i))||r:(se._send&&se._send(i,o),r)}var Np={send(e){this.machine=Lp(this,e),this.onChange(this)}};function Rn(e,t,i,r){let n=Object.create(Np,{machine:An(e),context:An(e.context(i,r)),onChange:A(t)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}$.action=Ap;$.createMachine=Up;$.d=se;$.guard=Cp;$.immediate=Mp;$.interpret=Rn;$.invoke=Pp;$.reduce=jn;$.state=jp;$.transition=Tp});var Kn=k(We=>{"use strict";var zn=We&&We.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(We,"__esModule",{value:!0});We.createRealtimeClient=rf;var Ye=En(),b=Bn(),qn=ti(),At=K(),Vn=ct(),Ci=Y(),Fp=()=>({enqueuedMessage:void 0});function Rp(e){return e.token!==void 0}function Bp(e){return!Rp(e)}function Et(e,t){return Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function G(e){return e.websocket&&e.websocket.readyState===WebSocket.OPEN&&e.websocket.close(),Object.assign(Object.assign({},e),{websocket:void 0})}function zp(e,t){return e.websocket&&e.websocket.readyState===WebSocket.OPEN?(t.message instanceof Uint8Array||typeof t.message=="string"?e.websocket.send(t.message):e.websocket.send((0,Ye.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function Ei(e){return Object.assign(Object.assign({},e),{token:void 0})}function qp(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function Vp(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var Hp=(0,b.createMachine)("idle",{idle:(0,b.state)((0,b.transition)("send","connecting",(0,b.reduce)(Et)),(0,b.transition)("expireToken","idle",(0,b.reduce)(Ei)),(0,b.transition)("close","idle",(0,b.reduce)(G))),connecting:(0,b.state)((0,b.transition)("connecting","connecting"),(0,b.transition)("connected","active",(0,b.reduce)(Vp)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(G)),(0,b.transition)("send","connecting",(0,b.reduce)(Et)),(0,b.transition)("close","idle",(0,b.reduce)(G)),(0,b.immediate)("authRequired",(0,b.guard)(Bp))),authRequired:(0,b.state)((0,b.transition)("initiateAuth","authInProgress"),(0,b.transition)("send","authRequired",(0,b.reduce)(Et)),(0,b.transition)("close","idle",(0,b.reduce)(G))),authInProgress:(0,b.state)((0,b.transition)("authenticated","connecting",(0,b.reduce)(qp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(Ei),(0,b.reduce)(G)),(0,b.transition)("send","authInProgress",(0,b.reduce)(Et)),(0,b.transition)("close","idle",(0,b.reduce)(G))),active:(0,b.state)((0,b.transition)("send","active",(0,b.reduce)(zp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)(Ei)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(G)),(0,b.transition)("close","idle",(0,b.reduce)(G))),failed:(0,b.state)((0,b.transition)("send","failed"),(0,b.transition)("close","idle",(0,b.reduce)(G)))},Fp);function Gp(e,{token:t,maxBuffering:i,path:r}){if(i!==void 0&&(i<1||i>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let n=new URLSearchParams({fal_jwt_token:t});i!==void 0&&n.set("max_buffering",i.toFixed(0));let o=(0,Ci.ensureEndpointIdFormat)(e),a=r?`/${r.replace(/^\/+/,"")}`:"/realtime";return`wss://fal.run/${o}${a}?${n.toString()}`}var Kp=128;function Yp(e){return e.status==="error"&&e.error==="Unauthorized"}var Wp={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Ai=new Map,Hn=new Map;function Qp(e,t,i){if(!Ai.has(e)){let r=(0,b.interpret)(Hp,i);Ai.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,Ci.throttle)(r.send,t,!0):r.send}))}return Ai.get(e)}var Ke=()=>{},Zp={send:Ke,close:Ke};function Xp(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!Gn(e)}function Gn(e){return e.type==="x-fal-error"}function Jp(e){return zn(this,void 0,void 0,function*(){if(typeof e=="string")return JSON.parse(e);let t=i=>zn(this,void 0,void 0,function*(){return i instanceof Uint8Array?i:i instanceof Blob?new Uint8Array(yield i.arrayBuffer()):new Uint8Array(i)});return e instanceof ArrayBuffer||e instanceof Uint8Array?(0,Ye.decode)(yield t(e)):e instanceof Blob?(0,Ye.decode)(yield t(e)):e})}function ef(e){return e instanceof Uint8Array?e:(0,Ye.encode)(e)}function tf({data:e,decodeMessage:t,onResult:i,onError:r,send:n}){let o=a=>{if(Yp(a)){n({type:"unauthorized",error:new Error("Unauthorized")});return}if(Xp(a)){i(a);return}if(Gn(a)){if(a.error==="TIMEOUT")return;r(new At.ApiError({message:`${a.error}: ${a.reason}`,status:400,body:a}));return}};Promise.resolve(t(e)).then(o).catch(a=>{var l;r(new At.ApiError({message:(l=a?.message)!==null&&l!==void 0?l:"Failed to decode realtime message",status:400}))})}function rf({config:e}){return{connect(t,i){let{clientOnly:r=(0,Ci.isReact)()&&!(0,Vn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,path:a,throttleInterval:l=Kp,encodeMessage:c,decodeMessage:u}=i;if(r&&!(0,Vn.isBrowser)())return Zp;let s=c??(f=>ef(f)),d=u??(f=>Jp(f)),h,p;Hn.set(n,{decodeMessage:d,onError:i.onError,onResult:i.onResult});let m=()=>Hn.get(n),y=Qp(n,l,({context:f,machine:v,send:_})=>{let{enqueuedMessage:T,token:Ee,websocket:te}=f;if(p=T,v.current==="active"&&T&&te?.readyState===WebSocket.OPEN&&_({type:"send",message:T}),v.current==="authRequired"&&Ee===void 0&&h!==v.current&&(_({type:"initiateAuth"}),(0,qn.getTemporaryAuthToken)(t,e).then(j=>{_({type:"authenticated",token:j});let C=Math.round(qn.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{_({type:"expireToken"})},C)}).catch(j=>{_({type:"unauthorized",error:j})})),v.current==="connecting"&&h!==v.current&&Ee!==void 0){let j=new WebSocket(Gp(t,{token:Ee,maxBuffering:o,path:a}));j.onopen=()=>{var C,D;_({type:"connected",websocket:j});let Ae=(D=(C=y.context)===null||C===void 0?void 0:C.enqueuedMessage)!==null&&D!==void 0?D:p;Ae&&(j.send(s(Ae)),y.context=Object.assign(Object.assign({},y.context),{enqueuedMessage:void 0}))},j.onclose=C=>{if(C.code!==Wp.NORMAL_CLOSURE){let{onError:D=Ke}=m();D(new At.ApiError({message:`Error closing the connection: ${C.reason}`,status:C.code}))}_({type:"connectionClosed",code:C.code})},j.onerror=C=>{let{onError:D=Ke}=m();D(new At.ApiError({message:"Unknown error",status:500}))},j.onmessage=C=>{let{decodeMessage:D=d,onResult:Ae,onError:lo=Ke}=m();tf({data:C.data,decodeMessage:D,onResult:Ae,onError:lo,send:_})}}h=v.current});return{send:f=>{y.throttledSend({type:"send",message:s(f)})},close:()=>{y.send({type:"close"})}}}}}});var Ti=k(Qe=>{"use strict";var Yn=Qe&&Qe.__awaiter||function(e,t,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 l(s){try{u(r.next(s))}catch(d){a(d)}}function c(s){try{u(r.throw(s))}catch(d){a(d)}}function u(s){s.done?o(s.value):n(s.value).then(l,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.createFalClient=cf;var nf=ut(),of=Jr(),af=Kn(),Wn=we(),sf=K(),Qn=Jt(),lf=ri();function cf(e={}){let t=(0,nf.createConfig)(e),i=(0,Qn.createStorageClient)({config:t}),r=(0,of.createQueueClient)({config:t,storage:i}),n=(0,lf.createStreamingClient)({config:t,storage:i}),o=(0,af.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return Yn(this,arguments,void 0,function*(l,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,Wn.dispatchRequest)({method:c.method,targetUrl:(0,Wn.buildUrl)(l,c),input:u,headers:(0,Qn.buildObjectLifecycleHeaders)(c.storageSettings),config:Object.assign(Object.assign({},t),{responseHandler:sf.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(a,l)=>Yn(this,void 0,void 0,function*(){let{request_id:c}=yield r.submit(a,l);return l.onEnqueue&&l.onEnqueue(c),yield r.subscribeToStatus(a,Object.assign({requestId:c},l)),r.result(a,{requestId:c})})}}});var Xn=k(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.isQueueStatus=Zn;Ct.isCompletedQueueStatus=uf;function Zn(e){return e&&e.status&&e.response_url}function uf(e){return Zn(e)&&e.status==="COMPLETED"}});var io=k(E=>{"use strict";var df=E&&E.__createBinding||(Object.create?function(e,t,i,r){r===void 0&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){r===void 0&&(r=i),e[r]=t[i]}),gf=E&&E.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&df(t,e,i)};Object.defineProperty(E,"__esModule",{value:!0});E.fal=E.parseEndpointId=E.isRetryableError=E.ValidationError=E.ApiError=E.withProxy=E.withMiddleware=E.createFalClient=void 0;var Jn=Ti(),pf=Ti();Object.defineProperty(E,"createFalClient",{enumerable:!0,get:function(){return pf.createFalClient}});var eo=Wt();Object.defineProperty(E,"withMiddleware",{enumerable:!0,get:function(){return eo.withMiddleware}});Object.defineProperty(E,"withProxy",{enumerable:!0,get:function(){return eo.withProxy}});var to=K();Object.defineProperty(E,"ApiError",{enumerable:!0,get:function(){return to.ApiError}});Object.defineProperty(E,"ValidationError",{enumerable:!0,get:function(){return to.ValidationError}});var ff=Be();Object.defineProperty(E,"isRetryableError",{enumerable:!0,get:function(){return ff.isRetryableError}});gf(Xn(),E);var hf=Y();Object.defineProperty(E,"parseEndpointId",{enumerable:!0,get:function(){return hf.parseEndpointId}});E.fal=function(){let t=(0,Jn.createFalClient)();return{config(i){t=(0,Jn.createFalClient)(i)},get queue(){return t.queue},get realtime(){return t.realtime},get storage(){return t.storage},get streaming(){return t.streaming},run(i,r){return t.run(i,r)},subscribe(i,r){return t.subscribe(i,r)},stream(i,r){return t.stream(i,r)}}}()});var yo=`
6
6
  <svg>
7
7
  <symbol
8
8
  fill="none"
@@ -68,7 +68,7 @@ var io=Object.create;var Ei=Object.defineProperty;var ro=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
- `,zi=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:l,excludeGroups:c,sortingOrder:u,sortKey:s}=t,d=[...this.assets];if(l&&l.length>0&&(d=d.filter(g=>g.groups&&l.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}),s&&s!=="id"?d.sort((g,f)=>{let v=g.meta?.[s],_=f.meta?.[s];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}):s==="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 uo=typeof global=="object"&&global&&global.Object===Object&&global,Bi=uo,go=typeof self=="object"&&self&&self.Object===Object&&self,po=Bi||go||Function("return this")(),N=po,fo=N.Symbol,ne=fo,Ri=Object.prototype,ho=Ri.hasOwnProperty,mo=Ri.toString,we=ne?ne.toStringTag:void 0;function yo(t){var e=ho.call(t,we),i=t[we];try{t[we]=void 0;var r=!0}catch{}var n=mo.call(t);return r&&(e?t[we]=i:delete t[we]),n}var bo=yo,_o=Object.prototype,vo=_o.toString;function wo(t){return vo.call(t)}var xo=wo,ko="[object Null]",So="[object Undefined]",Ii=ne?ne.toStringTag:void 0;function Eo(t){return t==null?t===void 0?So:ko:Ii&&Ii in Object(t)?bo(t):xo(t)}var Ee=Eo;function Io(t){return t!=null&&typeof t=="object"}var $t=Io,cf=Array.isArray;function Ao(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var qi=Ao,Co="[object AsyncFunction]",To="[object Function]",Mo="[object GeneratorFunction]",Oo="[object Proxy]";function $o(t){if(!qi(t))return!1;var e=Ee(t);return e==To||e==Mo||e==Co||e==Oo}var jo=$o,Do=N["__core-js_shared__"],Et=Do,Ai=function(){var t=/[^.]+$/.exec(Et&&Et.keys&&Et.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Po(t){return!!Ai&&Ai in t}var Uo=Po,No=Function.prototype,Lo=No.toString;function Fo(t){if(t!=null){try{return Lo.call(t)}catch{}try{return t+""}catch{}}return""}var Z=Fo,zo=/[\\^$.*+?()[\]{}|]/g,Bo=/^\[object .+?Constructor\]$/,Ro=Function.prototype,qo=Object.prototype,Vo=Ro.toString,Ho=qo.hasOwnProperty,Go=RegExp("^"+Vo.call(Ho).replace(zo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ko(t){if(!qi(t)||Uo(t))return!1;var e=jo(t)?Go:Bo;return e.test(Z(t))}var Yo=Ko;function Wo(t,e){return t?.[e]}var Qo=Wo;function Zo(t,e){var i=Qo(t,e);return Yo(i)?i:void 0}var oe=Zo,Xo=oe(N,"WeakMap"),At=Xo;function Jo(t,e){return t===e||t!==t&&e!==e}var ea=Jo,ta=9007199254740991;function ia(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ta}var ra=ia;var uf=Object.prototype;var na="[object Arguments]";function oa(t){return $t(t)&&Ee(t)==na}var Ci=oa,Vi=Object.prototype,aa=Vi.hasOwnProperty,sa=Vi.propertyIsEnumerable,df=Ci(function(){return arguments}())?Ci:function(t){return $t(t)&&aa.call(t,"callee")&&!sa.call(t,"callee")};var Hi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ti=Hi&&typeof module=="object"&&module&&!module.nodeType&&module,la=Ti&&Ti.exports===Hi,Mi=la?N.Buffer:void 0,gf=Mi?Mi.isBuffer:void 0;var ca="[object Arguments]",ua="[object Array]",da="[object Boolean]",ga="[object Date]",pa="[object Error]",fa="[object Function]",ha="[object Map]",ma="[object Number]",ya="[object Object]",ba="[object RegExp]",_a="[object Set]",va="[object String]",wa="[object WeakMap]",xa="[object ArrayBuffer]",ka="[object DataView]",Sa="[object Float32Array]",Ea="[object Float64Array]",Ia="[object Int8Array]",Aa="[object Int16Array]",Ca="[object Int32Array]",Ta="[object Uint8Array]",Ma="[object Uint8ClampedArray]",Oa="[object Uint16Array]",$a="[object Uint32Array]",S={};S[Sa]=S[Ea]=S[Ia]=S[Aa]=S[Ca]=S[Ta]=S[Ma]=S[Oa]=S[$a]=!0;S[ca]=S[ua]=S[xa]=S[da]=S[ka]=S[ga]=S[pa]=S[fa]=S[ha]=S[ma]=S[ya]=S[ba]=S[_a]=S[va]=S[wa]=!1;function ja(t){return $t(t)&&ra(t.length)&&!!S[Ee(t)]}var Da=ja;function Pa(t){return function(e){return t(e)}}var Ua=Pa,Gi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xe=Gi&&typeof module=="object"&&module&&!module.nodeType&&module,Na=xe&&xe.exports===Gi,It=Na&&Bi.process,La=function(){try{var t=xe&&xe.require&&xe.require("util").types;return t||It&&It.binding&&It.binding("util")}catch{}}(),Oi=La,$i=Oi&&Oi.isTypedArray,pf=$i?Ua($i):Da;var Fa=Object.prototype,ff=Fa.hasOwnProperty;function za(t,e){return function(i){return t(e(i))}}var Ba=za,hf=Ba(Object.keys,Object);var Ra=Object.prototype,mf=Ra.hasOwnProperty;var qa=oe(Object,"create"),ke=qa;function Va(){this.__data__=ke?ke(null):{},this.size=0}var Ha=Va;function Ga(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ka=Ga,Ya="__lodash_hash_undefined__",Wa=Object.prototype,Qa=Wa.hasOwnProperty;function Za(t){var e=this.__data__;if(ke){var i=e[t];return i===Ya?void 0:i}return Qa.call(e,t)?e[t]:void 0}var Xa=Za,Ja=Object.prototype,es=Ja.hasOwnProperty;function ts(t){var e=this.__data__;return ke?e[t]!==void 0:es.call(e,t)}var is=ts,rs="__lodash_hash_undefined__";function ns(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=ke&&e===void 0?rs:e,this}var os=ns;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=Ha;ae.prototype.delete=Ka;ae.prototype.get=Xa;ae.prototype.has=is;ae.prototype.set=os;var ji=ae;function as(){this.__data__=[],this.size=0}var ss=as;function ls(t,e){for(var i=t.length;i--;)if(ea(t[i][0],e))return i;return-1}var Ve=ls,cs=Array.prototype,us=cs.splice;function ds(t){var e=this.__data__,i=Ve(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():us.call(e,i,1),--this.size,!0}var gs=ds;function ps(t){var e=this.__data__,i=Ve(e,t);return i<0?void 0:e[i][1]}var fs=ps;function hs(t){return Ve(this.__data__,t)>-1}var ms=hs;function ys(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 bs=ys;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=ss;se.prototype.delete=gs;se.prototype.get=fs;se.prototype.has=ms;se.prototype.set=bs;var He=se,_s=oe(N,"Map"),Se=_s;function vs(){this.size=0,this.__data__={hash:new ji,map:new(Se||He),string:new ji}}var ws=vs;function xs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ks=xs;function Ss(t,e){var i=t.__data__;return ks(e)?i[typeof e=="string"?"string":"hash"]:i.map}var Ge=Ss;function Es(t){var e=Ge(this,t).delete(t);return this.size-=e?1:0,e}var Is=Es;function As(t){return Ge(this,t).get(t)}var Cs=As;function Ts(t){return Ge(this,t).has(t)}var Ms=Ts;function Os(t,e){var i=Ge(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}var $s=Os;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=ws;le.prototype.delete=Is;le.prototype.get=Cs;le.prototype.has=Ms;le.prototype.set=$s;var Ki=le;function js(){this.__data__=new He,this.size=0}var Ds=js;function Ps(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}var Us=Ps;function Ns(t){return this.__data__.get(t)}var Ls=Ns;function Fs(t){return this.__data__.has(t)}var zs=Fs,Bs=200;function Rs(t,e){var i=this.__data__;if(i instanceof He){var r=i.__data__;if(!Se||r.length<Bs-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new Ki(r)}return i.set(t,e),this.size=i.size,this}var qs=Rs;function Ie(t){var e=this.__data__=new He(t);this.size=e.size}Ie.prototype.clear=Ds;Ie.prototype.delete=Us;Ie.prototype.get=Ls;Ie.prototype.has=zs;Ie.prototype.set=qs;var Vs=Object.prototype,yf=Vs.propertyIsEnumerable;var Hs=oe(N,"DataView"),Ct=Hs,Gs=oe(N,"Promise"),Tt=Gs,Ks=oe(N,"Set"),Mt=Ks,Di="[object Map]",Ys="[object Object]",Pi="[object Promise]",Ui="[object Set]",Ni="[object WeakMap]",Li="[object DataView]",Ws=Z(Ct),Qs=Z(Se),Zs=Z(Tt),Xs=Z(Mt),Js=Z(At),re=Ee;(Ct&&re(new Ct(new ArrayBuffer(1)))!=Li||Se&&re(new Se)!=Di||Tt&&re(Tt.resolve())!=Pi||Mt&&re(new Mt)!=Ui||At&&re(new At)!=Ni)&&(re=function(t){var e=Ee(t),i=e==Ys?t.constructor:void 0,r=i?Z(i):"";if(r)switch(r){case Ws:return Li;case Qs:return Di;case Zs:return Pi;case Xs:return Ui;case Js:return Ni}return e});var bf=N.Uint8Array;var el="__lodash_hash_undefined__";function tl(t){return this.__data__.set(t,el),this}var il=tl;function rl(t){return this.__data__.has(t)}var nl=rl;function Ot(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new Ki;++e<i;)this.add(t[e])}Ot.prototype.add=Ot.prototype.push=il;Ot.prototype.has=nl;var Fi=ne?ne.prototype:void 0,_f=Fi?Fi.valueOf:void 0;var ol=Object.prototype,vf=ol.hasOwnProperty;var al=Object.prototype,wf=al.hasOwnProperty;var xf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),kf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Sf=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 Yi={Formats:co};var sl=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:l,excludeGroups:c,sortingOrder:u,sortKey:s}=t,d=[...this.assets];if(l&&l.length>0&&(d=d.filter(g=>g.groups&&l.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}),s&&s!=="id"?d.sort((g,f)=>{let v=g.meta?.[s],_=f.meta?.[s];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}):s==="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 ll=typeof global=="object"&&global&&global.Object===Object&&global,ur=ll,cl=typeof self=="object"&&self&&self.Object===Object&&self,ul=ur||cl||Function("return this")(),L=ul,dl=L.Symbol,ue=dl,dr=Object.prototype,gl=dr.hasOwnProperty,pl=dr.toString,Ae=ue?ue.toStringTag:void 0;function fl(t){var e=gl.call(t,Ae),i=t[Ae];try{t[Ae]=void 0;var r=!0}catch{}var n=pl.call(t);return r&&(e?t[Ae]=i:delete t[Ae]),n}var hl=fl,ml=Object.prototype,yl=ml.toString;function bl(t){return yl.call(t)}var _l=bl,vl="[object Null]",wl="[object Undefined]",Wi=ue?ue.toStringTag:void 0;function xl(t){return t==null?t===void 0?wl:vl:Wi&&Wi in Object(t)?hl(t):_l(t)}var Oe=xl;function kl(t){return t!=null&&typeof t=="object"}var qt=kl,Af=Array.isArray;function Sl(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var gr=Sl,El="[object AsyncFunction]",Il="[object Function]",Al="[object GeneratorFunction]",Cl="[object Proxy]";function Tl(t){if(!gr(t))return!1;var e=Oe(t);return e==Il||e==Al||e==El||e==Cl}var Ml=Tl,Ol=L["__core-js_shared__"],Dt=Ol,Qi=function(){var t=/[^.]+$/.exec(Dt&&Dt.keys&&Dt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function $l(t){return!!Qi&&Qi in t}var jl=$l,Dl=Function.prototype,Pl=Dl.toString;function Ul(t){if(t!=null){try{return Pl.call(t)}catch{}try{return t+""}catch{}}return""}var X=Ul,Nl=/[\\^$.*+?()[\]{}|]/g,Ll=/^\[object .+?Constructor\]$/,Fl=Function.prototype,zl=Object.prototype,Bl=Fl.toString,Rl=zl.hasOwnProperty,ql=RegExp("^"+Bl.call(Rl).replace(Nl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vl(t){if(!gr(t)||jl(t))return!1;var e=Ml(t)?ql:Ll;return e.test(X(t))}var Hl=Vl;function Gl(t,e){return t?.[e]}var Kl=Gl;function Yl(t,e){var i=Kl(t,e);return Hl(i)?i:void 0}var de=Yl,Wl=de(L,"WeakMap"),Nt=Wl;function Ql(t,e){return t===e||t!==t&&e!==e}var Zl=Ql,Xl=9007199254740991;function Jl(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Xl}var ec=Jl,Cf=Object.prototype,tc="[object Arguments]";function ic(t){return qt(t)&&Oe(t)==tc}var Zi=ic,pr=Object.prototype,rc=pr.hasOwnProperty,nc=pr.propertyIsEnumerable,Tf=Zi(function(){return arguments}())?Zi:function(t){return qt(t)&&rc.call(t,"callee")&&!nc.call(t,"callee")},fr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xi=fr&&typeof module=="object"&&module&&!module.nodeType&&module,oc=Xi&&Xi.exports===fr,Ji=oc?L.Buffer:void 0,Mf=Ji?Ji.isBuffer:void 0,ac="[object Arguments]",sc="[object Array]",lc="[object Boolean]",cc="[object Date]",uc="[object Error]",dc="[object Function]",gc="[object Map]",pc="[object Number]",fc="[object Object]",hc="[object RegExp]",mc="[object Set]",yc="[object String]",bc="[object WeakMap]",_c="[object ArrayBuffer]",vc="[object DataView]",wc="[object Float32Array]",xc="[object Float64Array]",kc="[object Int8Array]",Sc="[object Int16Array]",Ec="[object Int32Array]",Ic="[object Uint8Array]",Ac="[object Uint8ClampedArray]",Cc="[object Uint16Array]",Tc="[object Uint32Array]",E={};E[wc]=E[xc]=E[kc]=E[Sc]=E[Ec]=E[Ic]=E[Ac]=E[Cc]=E[Tc]=!0;E[ac]=E[sc]=E[_c]=E[lc]=E[vc]=E[cc]=E[uc]=E[dc]=E[gc]=E[pc]=E[fc]=E[hc]=E[mc]=E[yc]=E[bc]=!1;function Mc(t){return qt(t)&&ec(t.length)&&!!E[Oe(t)]}var Oc=Mc;function $c(t){return function(e){return t(e)}}var jc=$c,hr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ce=hr&&typeof module=="object"&&module&&!module.nodeType&&module,Dc=Ce&&Ce.exports===hr,Pt=Dc&&ur.process,Pc=function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||Pt&&Pt.binding&&Pt.binding("util")}catch{}}(),er=Pc,tr=er&&er.isTypedArray,Of=tr?jc(tr):Oc,Uc=Object.prototype,$f=Uc.hasOwnProperty;function Nc(t,e){return function(i){return t(e(i))}}var Lc=Nc,jf=Lc(Object.keys,Object),Fc=Object.prototype,Df=Fc.hasOwnProperty,zc=de(Object,"create"),Te=zc;function Bc(){this.__data__=Te?Te(null):{},this.size=0}var Rc=Bc;function qc(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Vc=qc,Hc="__lodash_hash_undefined__",Gc=Object.prototype,Kc=Gc.hasOwnProperty;function Yc(t){var e=this.__data__;if(Te){var i=e[t];return i===Hc?void 0:i}return Kc.call(e,t)?e[t]:void 0}var Wc=Yc,Qc=Object.prototype,Zc=Qc.hasOwnProperty;function Xc(t){var e=this.__data__;return Te?e[t]!==void 0:Zc.call(e,t)}var Jc=Xc,eu="__lodash_hash_undefined__";function tu(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Te&&e===void 0?eu:e,this}var iu=tu;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=Rc;ge.prototype.delete=Vc;ge.prototype.get=Wc;ge.prototype.has=Jc;ge.prototype.set=iu;var ir=ge;function ru(){this.__data__=[],this.size=0}var nu=ru;function ou(t,e){for(var i=t.length;i--;)if(Zl(t[i][0],e))return i;return-1}var Ke=ou,au=Array.prototype,su=au.splice;function lu(t){var e=this.__data__,i=Ke(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():su.call(e,i,1),--this.size,!0}var cu=lu;function uu(t){var e=this.__data__,i=Ke(e,t);return i<0?void 0:e[i][1]}var du=uu;function gu(t){return Ke(this.__data__,t)>-1}var pu=gu;function fu(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 hu=fu;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=nu;pe.prototype.delete=cu;pe.prototype.get=du;pe.prototype.has=pu;pe.prototype.set=hu;var Ye=pe,mu=de(L,"Map"),Me=mu;function yu(){this.size=0,this.__data__={hash:new ir,map:new(Me||Ye),string:new ir}}var bu=yu;function _u(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var vu=_u;function wu(t,e){var i=t.__data__;return vu(e)?i[typeof e=="string"?"string":"hash"]:i.map}var We=wu;function xu(t){var e=We(this,t).delete(t);return this.size-=e?1:0,e}var ku=xu;function Su(t){return We(this,t).get(t)}var Eu=Su;function Iu(t){return We(this,t).has(t)}var Au=Iu;function Cu(t,e){var i=We(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}var Tu=Cu;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=bu;fe.prototype.delete=ku;fe.prototype.get=Eu;fe.prototype.has=Au;fe.prototype.set=Tu;var mr=fe;function Mu(){this.__data__=new Ye,this.size=0}var Ou=Mu;function $u(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}var ju=$u;function Du(t){return this.__data__.get(t)}var Pu=Du;function Uu(t){return this.__data__.has(t)}var Nu=Uu,Lu=200;function Fu(t,e){var i=this.__data__;if(i instanceof Ye){var r=i.__data__;if(!Me||r.length<Lu-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new mr(r)}return i.set(t,e),this.size=i.size,this}var zu=Fu;function $e(t){var e=this.__data__=new Ye(t);this.size=e.size}$e.prototype.clear=Ou;$e.prototype.delete=ju;$e.prototype.get=Pu;$e.prototype.has=Nu;$e.prototype.set=zu;var Bu=Object.prototype,Pf=Bu.propertyIsEnumerable,Ru=de(L,"DataView"),Lt=Ru,qu=de(L,"Promise"),Ft=qu,Vu=de(L,"Set"),zt=Vu,rr="[object Map]",Hu="[object Object]",nr="[object Promise]",or="[object Set]",ar="[object WeakMap]",sr="[object DataView]",Gu=X(Lt),Ku=X(Me),Yu=X(Ft),Wu=X(zt),Qu=X(Nt),ce=Oe;(Lt&&ce(new Lt(new ArrayBuffer(1)))!=sr||Me&&ce(new Me)!=rr||Ft&&ce(Ft.resolve())!=nr||zt&&ce(new zt)!=or||Nt&&ce(new Nt)!=ar)&&(ce=function(t){var e=Oe(t),i=e==Hu?t.constructor:void 0,r=i?X(i):"";if(r)switch(r){case Gu:return sr;case Ku:return rr;case Yu:return nr;case Wu:return or;case Qu:return ar}return e});var Uf=L.Uint8Array,Zu="__lodash_hash_undefined__";function Xu(t){return this.__data__.set(t,Zu),this}var Ju=Xu;function ed(t){return this.__data__.has(t)}var td=ed;function Bt(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new mr;++e<i;)this.add(t[e])}Bt.prototype.add=Bt.prototype.push=Ju;Bt.prototype.has=td;var lr=ue?ue.prototype:void 0,Nf=lr?lr.valueOf:void 0,id=Object.prototype,Lf=id.hasOwnProperty,rd=Object.prototype,Ff=rd.hasOwnProperty,zf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Bf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Rf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function nd(t){return t!==void 0}var od=nd;function yr(t){return t?.version?t.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof t.i18n?.translate=="function":!1}function br(t){return typeof t?.translate=="function"}function cr(t,e,i){return t&&yr(t)&&br(t.i18n)?t.i18n.translate(e):i}function Qe(t,e){if(typeof t.i18n?.getTranslations!="function"){t.i18n.setTranslations(e);return}let i=Object.keys(e),r=t.i18n.getTranslations(i),n={};for(let o of i){let a=e[o];if(!a)continue;let l=r[o]??{},c={};for(let[u,s]of Object.entries(a))!(u in l)&&s!==void 0&&(c[u]=s);Object.keys(c).length>0&&(n[o]=c)}Object.keys(n).length>0&&t.i18n.setTranslations(n)}function _r(t,e,i="style",r="image"){return(n,o)=>{if(!yr(t))return o;let a=ad(e,i,n,r);if(br(t.i18n)){let l=t.i18n.translate(a);return l!==a[a.length-1]?l:o}return o}}function ad(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}`]}function sd(t,e){let{cesdk:i}=e,r=e.propertyKey??"image_url",n=Rt(t);return Qe(i,{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."}}),ld(t,i),{[r]:(o,a)=>{let{builder:l,experimental:{global:c},payload:u}=o,s,d=o.providerConfig,h=o.config,p=d?.properties?.[a.id]??h?.properties?.[a.id];p?.default&&(typeof p.default=="function"?s=p.default({}):s=p.default);let m=s??u?.url??e.defaultUrl,y=c(`${t}.${a.id}`,m);return l.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 ld(t,e){e?.ui.registerPanel(Rt(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(Rt(t))):e.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function Rt(t){return`ly.img.ai.${t}.imageSelection`}var cd=sd;function ud(t,e){let{cesdk:i}=e;if(i==null)return{};let r=e.propertyKey??"style",n=gd(t);Qe(i,{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=fd({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 l=hd({cesdk:i,providerId:t,styles:a}),c=l.id;return md(l,{cesdk:i}),dd({providerId:t,cesdk:i,panelId:n,entryId:c}),{[e.propertyKeyForPrompt??"prompt"]:(u,s)=>{let d=u.state("prompt","");return u.builder.TextArea(`${s.id}`,{inputLabel:e.i18n?.prompt?.inputLabel??e.propertyKeyForPrompt??"prompt",placeholder:e.i18n?.prompt?.placeholder,...d}),()=>{let[h]=l.getActiveAssetIds(),p=l.getAsset(h);return{id:s.id,type:"string",value:p?.meta?.prompt==null?d.value:`${d.value}; ${p.meta.prompt}`}}},[r]:(u,s)=>{let{builder:d,state:h}=u;if(a.length>0){let p=h("style",a[0]);return d.Button(`${s.id}`,{inputLabel:`${t}.${s.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async y=>{l.clearActiveAssets(),l.setAssetActive(y.id),p.setValue({id:y.id,label:y.label??y.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:s.id,type:"string",value:p.value.id})}return()=>({id:s.id,type:"string",value:"none"})}}}function dd(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 l=>{a?.onSelect?.(l)}})})}function gd(t){return`ly.img.ai.${t}.styleSelection`}var pd=[{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 fd(t){return pd.map(e=>e.id==="none"?t.includeNone?{id:e.id,label:cr(t.cesdk,e.labelKey,e.labelKey),prompt:e.prompt,thumbUri:`${t.baseURL}/thumbnails/None.svg`}:void 0:{id:e.id,label:cr(t.cesdk,e.labelKey,e.labelKey),prompt:e.prompt,thumbUri:`${t.baseURL}/thumbnails/${e.id}.jpeg`}).filter(od)}var hd=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 sl(r,e),o=t.styles[0];return n.setAssetActive(o.id),n},md=(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"})},yd=ud;var bd="ly.img.ai";function je(t){return`${bd}.${t}`}function vr(t){return`${t.replace(/\/+$/,"")}/`}function wr(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 Ut="@imgly/plugin-ai-generation",qf=`
71
+ `,Hi=class{constructor(e,t=[],i){this.id=e,this.translateLabel=i?.translateLabel,this.assets=t.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(e){let{page:t,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:l,excludeGroups:c,sortingOrder:u,sortKey:s}=e,d=[...this.assets];if(l&&l.length>0&&(d=d.filter(g=>g.groups&&l.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(T=>T.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}),s&&s!=="id"?d.sort((g,f)=>{let v=g.meta?.[s],_=f.meta?.[s];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}):s==="id"&&d.sort((g,f)=>u==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=d.length,p=t*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?t+1:void 0;return{assets:y,currentPage:t,nextPage:w,total:h}}updateLabel(e,t,i){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[i]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:i})=>i===e);if(t){let i=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:i,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:i})=>i===e[0]);if(t){let i=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:i,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:i})=>i===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||""}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(i=>i.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(i=>i.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(i=>e.add(i))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var bo=typeof global=="object"&&global&&global.Object===Object&&global,Gi=bo,_o=typeof self=="object"&&self&&self.Object===Object&&self,vo=Gi||_o||Function("return this")(),B=vo,wo=B.Symbol,ce=wo,Ki=Object.prototype,xo=Ki.hasOwnProperty,ko=Ki.toString,Ce=ce?ce.toStringTag:void 0;function So(e){var t=xo.call(e,Ce),i=e[Ce];try{e[Ce]=void 0;var r=!0}catch{}var n=ko.call(e);return r&&(t?e[Ce]=i:delete e[Ce]),n}var Io=So,Eo=Object.prototype,Ao=Eo.toString;function Co(e){return Ao.call(e)}var To=Co,Mo="[object Null]",Oo="[object Undefined]",Oi=ce?ce.toStringTag:void 0;function $o(e){return e==null?e===void 0?Oo:Mo:Oi&&Oi in Object(e)?Io(e):To(e)}var $e=$o;function jo(e){return e!=null&&typeof e=="object"}var Lt=jo,vf=Array.isArray;function Do(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Yi=Do,Po="[object AsyncFunction]",Uo="[object Function]",Lo="[object GeneratorFunction]",No="[object Proxy]";function Fo(e){if(!Yi(e))return!1;var t=$e(e);return t==Uo||t==Lo||t==Po||t==No}var Ro=Fo,Bo=B["__core-js_shared__"],Mt=Bo,$i=function(){var e=/[^.]+$/.exec(Mt&&Mt.keys&&Mt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function zo(e){return!!$i&&$i in e}var qo=zo,Vo=Function.prototype,Ho=Vo.toString;function Go(e){if(e!=null){try{return Ho.call(e)}catch{}try{return e+""}catch{}}return""}var ie=Go,Ko=/[\\^$.*+?()[\]{}|]/g,Yo=/^\[object .+?Constructor\]$/,Wo=Function.prototype,Qo=Object.prototype,Zo=Wo.toString,Xo=Qo.hasOwnProperty,Jo=RegExp("^"+Zo.call(Xo).replace(Ko,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ea(e){if(!Yi(e)||qo(e))return!1;var t=Ro(e)?Jo:Yo;return t.test(ie(e))}var ta=ea;function ia(e,t){return e?.[t]}var ra=ia;function na(e,t){var i=ra(e,t);return ta(i)?i:void 0}var ue=na,oa=ue(B,"WeakMap"),$t=oa;function aa(e,t){return e===t||e!==e&&t!==t}var sa=aa,la=9007199254740991;function ca(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=la}var ua=ca;var wf=Object.prototype;var da="[object Arguments]";function ga(e){return Lt(e)&&$e(e)==da}var ji=ga,Wi=Object.prototype,pa=Wi.hasOwnProperty,fa=Wi.propertyIsEnumerable,xf=ji(function(){return arguments}())?ji:function(e){return Lt(e)&&pa.call(e,"callee")&&!fa.call(e,"callee")};var Qi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Di=Qi&&typeof module=="object"&&module&&!module.nodeType&&module,ha=Di&&Di.exports===Qi,Pi=ha?B.Buffer:void 0,kf=Pi?Pi.isBuffer:void 0;var ma="[object Arguments]",ya="[object Array]",ba="[object Boolean]",_a="[object Date]",va="[object Error]",wa="[object Function]",xa="[object Map]",ka="[object Number]",Sa="[object Object]",Ia="[object RegExp]",Ea="[object Set]",Aa="[object String]",Ca="[object WeakMap]",Ta="[object ArrayBuffer]",Ma="[object DataView]",Oa="[object Float32Array]",$a="[object Float64Array]",ja="[object Int8Array]",Da="[object Int16Array]",Pa="[object Int32Array]",Ua="[object Uint8Array]",La="[object Uint8ClampedArray]",Na="[object Uint16Array]",Fa="[object Uint32Array]",S={};S[Oa]=S[$a]=S[ja]=S[Da]=S[Pa]=S[Ua]=S[La]=S[Na]=S[Fa]=!0;S[ma]=S[ya]=S[Ta]=S[ba]=S[Ma]=S[_a]=S[va]=S[wa]=S[xa]=S[ka]=S[Sa]=S[Ia]=S[Ea]=S[Aa]=S[Ca]=!1;function Ra(e){return Lt(e)&&ua(e.length)&&!!S[$e(e)]}var Ba=Ra;function za(e){return function(t){return e(t)}}var qa=za,Zi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=Zi&&typeof module=="object"&&module&&!module.nodeType&&module,Va=Te&&Te.exports===Zi,Ot=Va&&Gi.process,Ha=function(){try{var e=Te&&Te.require&&Te.require("util").types;return e||Ot&&Ot.binding&&Ot.binding("util")}catch{}}(),Ui=Ha,Li=Ui&&Ui.isTypedArray,Sf=Li?qa(Li):Ba;var Ga=Object.prototype,If=Ga.hasOwnProperty;function Ka(e,t){return function(i){return e(t(i))}}var Ya=Ka,Ef=Ya(Object.keys,Object);var Wa=Object.prototype,Af=Wa.hasOwnProperty;var Qa=ue(Object,"create"),Me=Qa;function Za(){this.__data__=Me?Me(null):{},this.size=0}var Xa=Za;function Ja(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var es=Ja,ts="__lodash_hash_undefined__",is=Object.prototype,rs=is.hasOwnProperty;function ns(e){var t=this.__data__;if(Me){var i=t[e];return i===ts?void 0:i}return rs.call(t,e)?t[e]:void 0}var os=ns,as=Object.prototype,ss=as.hasOwnProperty;function ls(e){var t=this.__data__;return Me?t[e]!==void 0:ss.call(t,e)}var cs=ls,us="__lodash_hash_undefined__";function ds(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Me&&t===void 0?us:t,this}var gs=ds;function de(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}de.prototype.clear=Xa;de.prototype.delete=es;de.prototype.get=os;de.prototype.has=cs;de.prototype.set=gs;var Ni=de;function ps(){this.__data__=[],this.size=0}var fs=ps;function hs(e,t){for(var i=e.length;i--;)if(sa(e[i][0],t))return i;return-1}var Ze=hs,ms=Array.prototype,ys=ms.splice;function bs(e){var t=this.__data__,i=Ze(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():ys.call(t,i,1),--this.size,!0}var _s=bs;function vs(e){var t=this.__data__,i=Ze(t,e);return i<0?void 0:t[i][1]}var ws=vs;function xs(e){return Ze(this.__data__,e)>-1}var ks=xs;function Ss(e,t){var i=this.__data__,r=Ze(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var Is=Ss;function ge(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ge.prototype.clear=fs;ge.prototype.delete=_s;ge.prototype.get=ws;ge.prototype.has=ks;ge.prototype.set=Is;var Xe=ge,Es=ue(B,"Map"),Oe=Es;function As(){this.size=0,this.__data__={hash:new Ni,map:new(Oe||Xe),string:new Ni}}var Cs=As;function Ts(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Ms=Ts;function Os(e,t){var i=e.__data__;return Ms(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Je=Os;function $s(e){var t=Je(this,e).delete(e);return this.size-=t?1:0,t}var js=$s;function Ds(e){return Je(this,e).get(e)}var Ps=Ds;function Us(e){return Je(this,e).has(e)}var Ls=Us;function Ns(e,t){var i=Je(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Fs=Ns;function pe(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}pe.prototype.clear=Cs;pe.prototype.delete=js;pe.prototype.get=Ps;pe.prototype.has=Ls;pe.prototype.set=Fs;var Xi=pe;function Rs(){this.__data__=new Xe,this.size=0}var Bs=Rs;function zs(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var qs=zs;function Vs(e){return this.__data__.get(e)}var Hs=Vs;function Gs(e){return this.__data__.has(e)}var Ks=Gs,Ys=200;function Ws(e,t){var i=this.__data__;if(i instanceof Xe){var r=i.__data__;if(!Oe||r.length<Ys-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Xi(r)}return i.set(e,t),this.size=i.size,this}var Qs=Ws;function je(e){var t=this.__data__=new Xe(e);this.size=t.size}je.prototype.clear=Bs;je.prototype.delete=qs;je.prototype.get=Hs;je.prototype.has=Ks;je.prototype.set=Qs;var Zs=Object.prototype,Cf=Zs.propertyIsEnumerable;var Xs=ue(B,"DataView"),jt=Xs,Js=ue(B,"Promise"),Dt=Js,el=ue(B,"Set"),Pt=el,Fi="[object Map]",tl="[object Object]",Ri="[object Promise]",Bi="[object Set]",zi="[object WeakMap]",qi="[object DataView]",il=ie(jt),rl=ie(Oe),nl=ie(Dt),ol=ie(Pt),al=ie($t),le=$e;(jt&&le(new jt(new ArrayBuffer(1)))!=qi||Oe&&le(new Oe)!=Fi||Dt&&le(Dt.resolve())!=Ri||Pt&&le(new Pt)!=Bi||$t&&le(new $t)!=zi)&&(le=function(e){var t=$e(e),i=t==tl?e.constructor:void 0,r=i?ie(i):"";if(r)switch(r){case il:return qi;case rl:return Fi;case nl:return Ri;case ol:return Bi;case al:return zi}return t});var Tf=B.Uint8Array;var sl="__lodash_hash_undefined__";function ll(e){return this.__data__.set(e,sl),this}var cl=ll;function ul(e){return this.__data__.has(e)}var dl=ul;function Ut(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Xi;++t<i;)this.add(e[t])}Ut.prototype.add=Ut.prototype.push=cl;Ut.prototype.has=dl;var Vi=ce?ce.prototype:void 0,Mf=Vi?Vi.valueOf:void 0;var gl=Object.prototype,Of=gl.hasOwnProperty;var pl=Object.prototype,$f=pl.hasOwnProperty;var jf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Df=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Pf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function Nt(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}var Ji={Formats:yo};var fl=class{constructor(e,t=[],i){this.id=e,this.translateLabel=i?.translateLabel,this.assets=t.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(e){let{page:t,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:l,excludeGroups:c,sortingOrder:u,sortKey:s}=e,d=[...this.assets];if(l&&l.length>0&&(d=d.filter(g=>g.groups&&l.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(T=>T.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}),s&&s!=="id"?d.sort((g,f)=>{let v=g.meta?.[s],_=f.meta?.[s];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}):s==="id"&&d.sort((g,f)=>u==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=d.length,p=t*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?t+1:void 0;return{assets:y,currentPage:t,nextPage:w,total:h}}updateLabel(e,t,i){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[i]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:i})=>i===e);if(t){let i=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:i,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:i})=>i===e[0]);if(t){let i=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:i,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:i})=>i===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||""}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(i=>i.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(i=>i.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(i=>e.add(i))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var hl=typeof global=="object"&&global&&global.Object===Object&&global,hr=hl,ml=typeof self=="object"&&self&&self.Object===Object&&self,yl=hr||ml||Function("return this")(),z=yl,bl=z.Symbol,he=bl,mr=Object.prototype,_l=mr.hasOwnProperty,vl=mr.toString,De=he?he.toStringTag:void 0;function wl(e){var t=_l.call(e,De),i=e[De];try{e[De]=void 0;var r=!0}catch{}var n=vl.call(e);return r&&(t?e[De]=i:delete e[De]),n}var xl=wl,kl=Object.prototype,Sl=kl.toString;function Il(e){return Sl.call(e)}var El=Il,Al="[object Null]",Cl="[object Undefined]",er=he?he.toStringTag:void 0;function Tl(e){return e==null?e===void 0?Cl:Al:er&&er in Object(e)?xl(e):El(e)}var Ne=Tl;function Ml(e){return e!=null&&typeof e=="object"}var Yt=Ml,Nf=Array.isArray;function Ol(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var yr=Ol,$l="[object AsyncFunction]",jl="[object Function]",Dl="[object GeneratorFunction]",Pl="[object Proxy]";function Ul(e){if(!yr(e))return!1;var t=Ne(e);return t==jl||t==Dl||t==$l||t==Pl}var Ll=Ul,Nl=z["__core-js_shared__"],Ft=Nl,tr=function(){var e=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Fl(e){return!!tr&&tr in e}var Rl=Fl,Bl=Function.prototype,zl=Bl.toString;function ql(e){if(e!=null){try{return zl.call(e)}catch{}try{return e+""}catch{}}return""}var re=ql,Vl=/[\\^$.*+?()[\]{}|]/g,Hl=/^\[object .+?Constructor\]$/,Gl=Function.prototype,Kl=Object.prototype,Yl=Gl.toString,Wl=Kl.hasOwnProperty,Ql=RegExp("^"+Yl.call(Wl).replace(Vl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zl(e){if(!yr(e)||Rl(e))return!1;var t=Ll(e)?Ql:Hl;return t.test(re(e))}var Xl=Zl;function Jl(e,t){return e?.[t]}var ec=Jl;function tc(e,t){var i=ec(e,t);return Xl(i)?i:void 0}var me=tc,ic=me(z,"WeakMap"),zt=ic;function rc(e,t){return e===t||e!==e&&t!==t}var nc=rc,oc=9007199254740991;function ac(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=oc}var sc=ac,Ff=Object.prototype,lc="[object Arguments]";function cc(e){return Yt(e)&&Ne(e)==lc}var ir=cc,br=Object.prototype,uc=br.hasOwnProperty,dc=br.propertyIsEnumerable,Rf=ir(function(){return arguments}())?ir:function(e){return Yt(e)&&uc.call(e,"callee")&&!dc.call(e,"callee")},_r=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rr=_r&&typeof module=="object"&&module&&!module.nodeType&&module,gc=rr&&rr.exports===_r,nr=gc?z.Buffer:void 0,Bf=nr?nr.isBuffer:void 0,pc="[object Arguments]",fc="[object Array]",hc="[object Boolean]",mc="[object Date]",yc="[object Error]",bc="[object Function]",_c="[object Map]",vc="[object Number]",wc="[object Object]",xc="[object RegExp]",kc="[object Set]",Sc="[object String]",Ic="[object WeakMap]",Ec="[object ArrayBuffer]",Ac="[object DataView]",Cc="[object Float32Array]",Tc="[object Float64Array]",Mc="[object Int8Array]",Oc="[object Int16Array]",$c="[object Int32Array]",jc="[object Uint8Array]",Dc="[object Uint8ClampedArray]",Pc="[object Uint16Array]",Uc="[object Uint32Array]",I={};I[Cc]=I[Tc]=I[Mc]=I[Oc]=I[$c]=I[jc]=I[Dc]=I[Pc]=I[Uc]=!0;I[pc]=I[fc]=I[Ec]=I[hc]=I[Ac]=I[mc]=I[yc]=I[bc]=I[_c]=I[vc]=I[wc]=I[xc]=I[kc]=I[Sc]=I[Ic]=!1;function Lc(e){return Yt(e)&&sc(e.length)&&!!I[Ne(e)]}var Nc=Lc;function Fc(e){return function(t){return e(t)}}var Rc=Fc,vr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pe=vr&&typeof module=="object"&&module&&!module.nodeType&&module,Bc=Pe&&Pe.exports===vr,Rt=Bc&&hr.process,zc=function(){try{var e=Pe&&Pe.require&&Pe.require("util").types;return e||Rt&&Rt.binding&&Rt.binding("util")}catch{}}(),or=zc,ar=or&&or.isTypedArray,zf=ar?Rc(ar):Nc,qc=Object.prototype,qf=qc.hasOwnProperty;function Vc(e,t){return function(i){return e(t(i))}}var Hc=Vc,Vf=Hc(Object.keys,Object),Gc=Object.prototype,Hf=Gc.hasOwnProperty,Kc=me(Object,"create"),Ue=Kc;function Yc(){this.__data__=Ue?Ue(null):{},this.size=0}var Wc=Yc;function Qc(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Zc=Qc,Xc="__lodash_hash_undefined__",Jc=Object.prototype,eu=Jc.hasOwnProperty;function tu(e){var t=this.__data__;if(Ue){var i=t[e];return i===Xc?void 0:i}return eu.call(t,e)?t[e]:void 0}var iu=tu,ru=Object.prototype,nu=ru.hasOwnProperty;function ou(e){var t=this.__data__;return Ue?t[e]!==void 0:nu.call(t,e)}var au=ou,su="__lodash_hash_undefined__";function lu(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ue&&t===void 0?su:t,this}var cu=lu;function ye(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ye.prototype.clear=Wc;ye.prototype.delete=Zc;ye.prototype.get=iu;ye.prototype.has=au;ye.prototype.set=cu;var sr=ye;function uu(){this.__data__=[],this.size=0}var du=uu;function gu(e,t){for(var i=e.length;i--;)if(nc(e[i][0],t))return i;return-1}var et=gu,pu=Array.prototype,fu=pu.splice;function hu(e){var t=this.__data__,i=et(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():fu.call(t,i,1),--this.size,!0}var mu=hu;function yu(e){var t=this.__data__,i=et(t,e);return i<0?void 0:t[i][1]}var bu=yu;function _u(e){return et(this.__data__,e)>-1}var vu=_u;function wu(e,t){var i=this.__data__,r=et(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var xu=wu;function be(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}be.prototype.clear=du;be.prototype.delete=mu;be.prototype.get=bu;be.prototype.has=vu;be.prototype.set=xu;var tt=be,ku=me(z,"Map"),Le=ku;function Su(){this.size=0,this.__data__={hash:new sr,map:new(Le||tt),string:new sr}}var Iu=Su;function Eu(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Au=Eu;function Cu(e,t){var i=e.__data__;return Au(t)?i[typeof t=="string"?"string":"hash"]:i.map}var it=Cu;function Tu(e){var t=it(this,e).delete(e);return this.size-=t?1:0,t}var Mu=Tu;function Ou(e){return it(this,e).get(e)}var $u=Ou;function ju(e){return it(this,e).has(e)}var Du=ju;function Pu(e,t){var i=it(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Uu=Pu;function _e(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}_e.prototype.clear=Iu;_e.prototype.delete=Mu;_e.prototype.get=$u;_e.prototype.has=Du;_e.prototype.set=Uu;var wr=_e;function Lu(){this.__data__=new tt,this.size=0}var Nu=Lu;function Fu(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Ru=Fu;function Bu(e){return this.__data__.get(e)}var zu=Bu;function qu(e){return this.__data__.has(e)}var Vu=qu,Hu=200;function Gu(e,t){var i=this.__data__;if(i instanceof tt){var r=i.__data__;if(!Le||r.length<Hu-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new wr(r)}return i.set(e,t),this.size=i.size,this}var Ku=Gu;function Fe(e){var t=this.__data__=new tt(e);this.size=t.size}Fe.prototype.clear=Nu;Fe.prototype.delete=Ru;Fe.prototype.get=zu;Fe.prototype.has=Vu;Fe.prototype.set=Ku;var Yu=Object.prototype,Gf=Yu.propertyIsEnumerable,Wu=me(z,"DataView"),qt=Wu,Qu=me(z,"Promise"),Vt=Qu,Zu=me(z,"Set"),Ht=Zu,lr="[object Map]",Xu="[object Object]",cr="[object Promise]",ur="[object Set]",dr="[object WeakMap]",gr="[object DataView]",Ju=re(qt),ed=re(Le),td=re(Vt),id=re(Ht),rd=re(zt),fe=Ne;(qt&&fe(new qt(new ArrayBuffer(1)))!=gr||Le&&fe(new Le)!=lr||Vt&&fe(Vt.resolve())!=cr||Ht&&fe(new Ht)!=ur||zt&&fe(new zt)!=dr)&&(fe=function(e){var t=Ne(e),i=t==Xu?e.constructor:void 0,r=i?re(i):"";if(r)switch(r){case Ju:return gr;case ed:return lr;case td:return cr;case id:return ur;case rd:return dr}return t});var Kf=z.Uint8Array,nd="__lodash_hash_undefined__";function od(e){return this.__data__.set(e,nd),this}var ad=od;function sd(e){return this.__data__.has(e)}var ld=sd;function Gt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new wr;++t<i;)this.add(e[t])}Gt.prototype.add=Gt.prototype.push=ad;Gt.prototype.has=ld;var pr=he?he.prototype:void 0,Yf=pr?pr.valueOf:void 0,cd=Object.prototype,Wf=cd.hasOwnProperty,ud=Object.prototype,Qf=ud.hasOwnProperty,Zf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Xf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Jf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function dd(e){return e!==void 0}var gd=dd;function xr(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function kr(e){return typeof e?.translate=="function"}function fr(e,t,i){return e&&xr(e)&&kr(e.i18n)?e.i18n.translate(t):i}function rt(e,t){if(typeof e.i18n?.getTranslations!="function"){e.i18n.setTranslations(t);return}let i=Object.keys(t),r=e.i18n.getTranslations(i),n={};for(let o of i){let a=t[o];if(!a)continue;let l=r[o]??{},c={};for(let[u,s]of Object.entries(a))!(u in l)&&s!==void 0&&(c[u]=s);Object.keys(c).length>0&&(n[o]=c)}Object.keys(n).length>0&&e.i18n.setTranslations(n)}function Sr(e,t,i="style",r="image"){return(n,o)=>{if(!xr(e))return o;let a=pd(t,i,n,r);if(kr(e.i18n)){let l=e.i18n.translate(a);return l!==a[a.length-1]?l:o}return o}}function pd(e,t,i,r="image"){return[`ly.img.plugin-ai-${r}-generation-web.${e}.property.${t}.${i}`,`ly.img.plugin-ai-generation-web.property.${t}.${i}`,`ly.img.plugin-ai-${r}-generation-web.${e}.defaults.property.${t}.${i}`,`ly.img.plugin-ai-generation-web.defaults.property.${t}.${i}`]}function fd(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=Kt(e);return rt(i,{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."}}),hd(e,i),{[r]:(o,a)=>{let{builder:l,experimental:{global:c},payload:u}=o,s,d=o.providerConfig,h=o.config,p=d?.properties?.[a.id]??h?.properties?.[a.id];p?.default&&(typeof p.default=="function"?s=p.default({}):s=p.default);let m=s??u?.url??t.defaultUrl,y=c(`${e}.${a.id}`,m);return l.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 hd(e,t){t?.ui.registerPanel(Kt(e),({builder:i,payload:r})=>{i.Library(`${e}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let a=await t.engine.editor.getMimeType(o);a==="image/svg+xml"?t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.svg"}):a.startsWith("image/")?(r?.onSelect(n),t?.ui.closePanel(Kt(e))):t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function Kt(e){return`ly.img.ai.${e}.imageSelection`}var md=fd;function yd(e,t){let{cesdk:i}=t;if(i==null)return{};let r=t.propertyKey??"style",n=_d(e);rt(i,{en:{[`panel.${n}`]:"Select Style",[`${e}.${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=wd({baseURL:t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0,cesdk:i}),a=o;t.styles!=null&&(Array.isArray(t.styles)?a=t.styles:typeof t.styles=="function"&&(a=t.styles(o)));let l=xd({cesdk:i,providerId:e,styles:a}),c=l.id;return kd(l,{cesdk:i}),bd({providerId:e,cesdk:i,panelId:n,entryId:c}),{[t.propertyKeyForPrompt??"prompt"]:(u,s)=>{let d=u.state("prompt","");return u.builder.TextArea(`${s.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??"prompt",placeholder:t.i18n?.prompt?.placeholder,...d}),()=>{let[h]=l.getActiveAssetIds(),p=l.getAsset(h);return{id:s.id,type:"string",value:p?.meta?.prompt==null?d.value:`${d.value}; ${p.meta.prompt}`}}},[r]:(u,s)=>{let{builder:d,state:h}=u;if(a.length>0){let p=h("style",a[0]);return d.Button(`${s.id}`,{inputLabel:`${e}.${s.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async y=>{l.clearActiveAssets(),l.setAssetActive(y.id),p.setValue({id:y.id,label:y.label??y.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:s.id,type:"string",value:p.value.id})}return()=>({id:s.id,type:"string",value:"none"})}}}function bd(e){let{providerId:t,cesdk:i,panelId:r,entryId:n}=e;i?.ui.registerPanel(r,({builder:o,payload:a})=>{a?.onSelect==null&&o.Section(`${t}.error`,{children:()=>{o.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),o.Library(`${t}.library.image`,{entries:[n],onSelect:async l=>{a?.onSelect?.(l)}})})}function _d(e){return`ly.img.ai.${e}.styleSelection`}var vd=[{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 wd(e){return vd.map(t=>t.id==="none"?e.includeNone?{id:t.id,label:fr(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/None.svg`}:void 0:{id:t.id,label:fr(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/${t.id}.jpeg`}).filter(gd)}var xd=e=>{let t=e.styles.map(a=>({...a,meta:{prompt:a.prompt}})),i=e.cesdk.engine.asset.findAllSources(),r=`${e.providerId}/styles`;for(;i.includes(r);)r+=`-${Math.random().toString(36).substring(2,5)}`;let n=new fl(r,t),o=e.styles[0];return n.setAssetActive(o.id),n},kd=(e,t)=>{t.cesdk.engine.asset.addSource(e),t.cesdk.ui.addAssetLibraryEntry({id:e.id,sourceIds:[e.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:i})=>i,cardLabelPosition:()=>"below"})},Sd=yd;var Id="ly.img.ai";function Re(e){return`${Id}.${e}`}function Ir(e){return`${e.replace(/\/+$/,"")}/`}function Er(e,t){let i={...e};if(!t)return i;for(let[r,n]of Object.entries(t))n===!1||n===null||n===void 0?delete i[r]:n===!0?r in e||(i[r]=!0):i[r]=n;return i}var Bt="@imgly/plugin-ai-generation",eh=`
72
72
  <svg>
73
73
  <symbol
74
74
  fill="none"
@@ -86,7 +86,7 @@ var io=Object.create;var Ei=Object.defineProperty;var ro=Object.getOwnPropertyDe
86
86
  fill="none"
87
87
  xmlns="http://www.w3.org/2000/svg"
88
88
  viewBox="0 0 24 24"
89
- id="${Ut}/image"
89
+ id="${Bt}/image"
90
90
  >
91
91
  <path d="M3 16.5V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V6C21 4.34315 19.6569 3 18 3L17.999 5C18.5513 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V16.5H3Z" fill="currentColor"/>
92
92
  <path d="M13.0982 0.884877C12.9734 0.568323 12.5254 0.568322 12.4005 0.884876L11.7485 2.53819C11.7104 2.63483 11.6339 2.71134 11.5372 2.74945L9.8839 3.40151C9.56735 3.52636 9.56734 3.97436 9.8839 4.09921L11.5372 4.75126C11.6339 4.78938 11.7104 4.86588 11.7485 4.96253L12.4005 6.61584C12.5254 6.93239 12.9734 6.9324 13.0982 6.61584L13.7503 4.96253C13.7884 4.86588 13.8649 4.78938 13.9616 4.75126L15.6149 4.09921C15.9314 3.97436 15.9314 3.52636 15.6149 3.40151L13.9616 2.74945C13.8649 2.71134 13.7884 2.63483 13.7503 2.53819L13.0982 0.884877Z" fill="currentColor"/>
@@ -98,7 +98,7 @@ var io=Object.create;var Ei=Object.defineProperty;var ro=Object.getOwnPropertyDe
98
98
  fill="none"
99
99
  xmlns="http://www.w3.org/2000/svg"
100
100
  viewBox="0 0 24 24"
101
- id="${Ut}/video"
101
+ id="${Bt}/video"
102
102
  >
103
103
  <path d="M6 3C4.34315 3 3 4.34315 3 6V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V16.5H19V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5V3Z" fill="currentColor"/>
104
104
  <path d="M10.9025 0.8839C11.0273 0.567345 11.4753 0.567346 11.6002 0.883901L12.2522 2.53721C12.2904 2.63386 12.3669 2.71036 12.4635 2.74848L14.1168 3.40053C14.4334 3.52538 14.4334 3.97338 14.1168 4.09823L12.4635 4.75029C12.3669 4.7884 12.2904 4.86491 12.2522 4.96155L11.6002 6.61486C11.4753 6.93142 11.0273 6.93142 10.9025 6.61486L10.2504 4.96155C10.2123 4.86491 10.1358 4.7884 10.0392 4.75029L8.38585 4.09823C8.0693 3.97338 8.0693 3.52538 8.38585 3.40053L10.0392 2.74848C10.1358 2.71036 10.2123 2.63386 10.2504 2.53721L10.9025 0.8839Z" fill="currentColor"/>
@@ -109,7 +109,7 @@ var io=Object.create;var Ei=Object.defineProperty;var ro=Object.getOwnPropertyDe
109
109
  fill="none"
110
110
  xmlns="http://www.w3.org/2000/svg"
111
111
  viewBox="0 0 24 24"
112
- id="${Ut}/audio"
112
+ id="${Bt}/audio"
113
113
  >
114
114
  <path d="M6 3.80273C4.2066 4.84016 3 6.77919 3 9.00004V12.8153C3 15.931 5.39501 18.4873 8.44444 18.7436V20.9645C8.44444 22.2198 9.89427 22.9198 10.8773 22.1392L15.1265 18.7647H15.5C17.8285 18.7647 19.8472 17.4384 20.8417 15.5H18.4187C17.6889 16.2784 16.6512 16.7647 15.5 16.7647H14.9522C14.6134 16.7647 14.2846 16.8794 14.0193 17.0901L10.4444 19.929V18.2597C10.4444 17.4341 9.77513 16.7647 8.9495 16.7647C7.80494 16.7647 6.77409 16.2779 6.05276 15.5H6V15.4419C5.37798 14.7439 5 13.8237 5 12.8153V9.00004C5 7.98559 5.37764 7.05935 6 6.35422V3.80273Z" fill="currentColor"/>
115
115
  <path d="M11.6002 1.8839C11.4753 1.56735 11.0273 1.56735 10.9025 1.8839L10.2504 3.53721C10.2123 3.63386 10.1358 3.71036 10.0392 3.74848L8.38585 4.40053C8.0693 4.52538 8.0693 4.97338 8.38585 5.09823L10.0392 5.75029C10.1358 5.7884 10.2123 5.86491 10.2504 5.96155L10.9025 7.61486C11.0273 7.93142 11.4753 7.93142 11.6002 7.61486L12.2522 5.96155C12.2904 5.86491 12.3669 5.7884 12.4635 5.75029L14.1168 5.09823C14.4334 4.97338 14.4334 4.52538 14.1168 4.40053L12.4635 3.74848C12.3669 3.71036 12.2904 3.63386 12.2522 3.53721L11.6002 1.8839Z" fill="currentColor"/>
@@ -129,7 +129,7 @@ var io=Object.create;var Ei=Object.defineProperty;var ro=Object.getOwnPropertyDe
129
129
 
130
130
  </symbol>
131
131
  </svg>
132
- `;var xr={ImageUrl:cd,StyleTransfer:yd};var kr={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 vd={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 Ze(t){return vd[t]}var wd=[{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"}],Kf=wd[0],xd=[{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"}],Yf=xd[0],Xe=[{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"}],Wf=Xe[0],kd=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 Sr(t,e){return kd(`${e}thumbnails/`)[t]}var Qn=lo(Wn());function Zn(t,e){return(0,Qn.createFalClient)({proxyUrl:t,requestMiddleware:async r=>({...r,headers:{...r.headers,...e??{}}})})}function xt(t){return t!=null&&typeof t!="string"&&"width"in t&&"height"in t}async function Xn(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),l=new File([a],`image.${jt(r)}`,{type:r});return t.storage.upload(l)}return e}}function rf(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=Zn(e.proxyUrl,t.headers),t.initialize?.(o)},input:{quickActions:{supported:wr(t.supportedQuickActions??{},e.supportedQuickActions)},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?xr.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:l}=t.getStickerSize(o);return Promise.resolve({sticker:{width:a,height:l}})}if(o.image_size!=null&&xt(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=Ze(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 l=await Xn(r,o.image_url,t.cesdk),c=await r.subscribe(t.falKey??t.modelKey,{abortSignal:a,input:l!=null?{...o,image_url:l}: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 s=c?.data?.image;if(s!=null){let d=s?.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 Jn=rf;var ve;function eo(t){return async({cesdk:e})=>nf(e,t)}function nf(t,e){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=vr(e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/");t.ui.addIconSet("@imgly/plugin/formats",Yi.Formats),ve=new zi(n,Xe.map(({id:c,label:u})=>({id:c,label:u,thumbUri:Sr(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(`${je(r)}.styleSelection`,({builder:c,payload:u})=>{if(u==null)return null;c.Library(`${r}.library.style`,{entries:[n],onSelect:async s=>{u.onSelect(s)}})});let l={};return Xe.forEach(({id:c,label:u})=>{l[`ly.img.plugin-ai-sticker-generation-web.${r}.property.style.${c}`]=u}),Qe(t,{en:{[`panel.${je("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",...l}}),Jn({falKey:i,modelKey:r,name:"Recraft 20b",schema:kr,inputReference:"#/components/schemas/Recraft20bInput",middleware:e.middlewares??e.middleware??[],headers:e.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:c,state:u},s)=>{let d=u("style/icon",a?a.id:"icon/broken_line");return c.Button(`${s.id}`,{inputLabel:[`ly.img.plugin-ai-sticker-generation-web.${r}.property.${s.id}`,`ly.img.plugin-ai-generation-web.property.${s.id}`,`ly.img.plugin-ai-sticker-generation-web.${r}.defaults.property.${s.id}`,`ly.img.plugin-ai-generation-web.defaults.property.${s.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:s.id,type:"string",value:d.value??"icon/broken_line"})}},getBlockInput:c=>{if(xt(c.image_size))return Promise.resolve({sticker:{width:c.image_size.width??512,height:c.image_size.height??512}});let u=Ze(c.image_size??"square_hd");return Promise.resolve({sticker:u})}},e)}var of={Recraft20b:eo},Zh=of;export{Zh as default};
132
+ `;var Ar={ImageUrl:md,StyleTransfer:Sd};var Cr={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 Ad={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 nt(e){return Ad[e]}var Cd=[{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"}],nh=Cd[0],Td=[{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"}],oh=Td[0],ot=[{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"}],ah=ot[0],Md=e=>({realistic_image:`${e}realistic_image.webp`,digital_illustration:`${e}digital_illustration.webp`,"realistic_image/b_and_w":`${e}realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${e}realistic_image_hard_flash.webp`,"realistic_image/hdr":`${e}realistic_image_hdr.webp`,"realistic_image/natural_light":`${e}realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${e}realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${e}realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${e}realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${e}digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${e}digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${e}digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${e}digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${e}digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${e}digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${e}digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${e}digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${e}digital_illustration_2d_artposter_2.webp`,vector_illustration:`${e}vector_illustration.svg`,"vector_illustration/bold_stroke":`${e}vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${e}vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${e}vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${e}vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${e}vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${e}vector_illustration_cutout.svg`,"vector_illustration/depressive":`${e}vector_illustration_depressive.svg`,"vector_illustration/editorial":`${e}vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${e}vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${e}vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${e}vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${e}vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${e}vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${e}vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${e}vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${e}vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${e}vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${e}vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${e}vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${e}vector_illustration_engraving.svg`,"vector_illustration/line_art":`${e}vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${e}vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${e}vector_illustration_linocut.svg`,"realistic_image/evening_light":`${e}realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${e}realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${e}realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${e}realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${e}realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${e}realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${e}realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${e}realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${e}realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${e}realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${e}realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${e}realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${e}digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${e}digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${e}digital_illustration_child_book.webp`,"digital_illustration/child_books":`${e}digital_illustration_child_books.webp`,"digital_illustration/cover":`${e}digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${e}digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${e}digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${e}digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${e}digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${e}digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${e}digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${e}digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${e}digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${e}digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${e}digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${e}digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${e}digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${e}digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${e}digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${e}digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${e}digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${e}digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${e}digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${e}digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${e}digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${e}digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${e}digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${e}digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${e}digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${e}digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${e}icon_broken_line.svg`,"icon/colored_outline":`${e}icon_colored_outline.svg`,"icon/colored_shapes":`${e}icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${e}icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${e}icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${e}icon_doodle_offset_fill.svg`,"icon/offset_fill":`${e}icon_offset_fill.svg`,"icon/outline":`${e}icon_outline.svg`,"icon/outline_gradient":`${e}icon_outline_gradient.svg`,"icon/uneven_fill":`${e}icon_uneven_fill.svg`});function Tr(e,t){return Md(`${t}thumbnails/`)[e]}var ro=mo(io());function no(e,t){return(0,ro.createFalClient)({proxyUrl:e,requestMiddleware:async r=>({...r,headers:{...r.headers,...t??{}}})})}function Tt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function oo(e,t,i){if(t!=null){if(t.startsWith("blob:")){let r=i!=null?await i.engine.editor.getMimeType(t):"image/png",o=await(await fetch(t)).blob(),a=new File([o],`image.${Nt(r)}`,{type:r});return e.storage.upload(a)}if(i!=null&&t.startsWith("buffer:")){let r=await i.engine.editor.getMimeType(t),n=i.engine.editor.getBufferLength(t),o=i.engine.editor.getBufferData(t,0,n),a=new Uint8Array(o),l=new File([a],`image.${Nt(r)}`,{type:r});return e.storage.upload(l)}return t}}function mf(e,t){let i=e.middleware??t.middlewares??t.middleware??[],r=null,n={id:e.modelKey,kind:"sticker",name:e.name,initialize:async o=>{r=no(t.proxyUrl,e.headers),e.initialize?.(o)},input:{quickActions:{supported:Er(e.supportedQuickActions??{},t.supportedQuickActions)},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?Ar.ImageUrl(e.modelKey,{cesdk:e.cesdk}):{},...e.renderCustomProperty},getBlockInput:o=>{if(e.getBlockInput!=null)return e.getBlockInput(o);if(e.getStickerSize!=null){let{width:a,height:l}=e.getStickerSize(o);return Promise.resolve({sticker:{width:a,height:l}})}if(o.image_size!=null&&Tt(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=nt(o.image_size);return Promise.resolve({sticker:a})}throw new Error("getBlockInput or getStickerSize must be provided")},userFlow:e.userFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:t.history??"@imgly/indexedDB",generate:async(o,{abortSignal:a})=>{if(!r)throw new Error("Provider not initialized");let l=await oo(r,o.image_url,e.cesdk),c=await r.subscribe(e.falKey??e.modelKey,{abortSignal:a,input:l!=null?{...o,image_url:l}: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 s=c?.data?.image;if(s!=null){let d=s?.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 t.debug&&console.log("Created Provider:",n),n}var ao=mf;var Ie;function so(e){return async({cesdk:t})=>yf(t,e)}function yf(e,t){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=Ir(t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/");e.ui.addIconSet("@imgly/plugin/formats",Ji.Formats),Ie=new Hi(n,ot.map(({id:c,label:u})=>({id:c,label:u,thumbUri:Tr(c,o)})),{translateLabel:Sr(e,r,"style","sticker")});let a=Ie.getActiveSelectValue();e.engine.asset.addSource(Ie),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:c})=>c,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${Re(r)}.styleSelection`,({builder:c,payload:u})=>{if(u==null)return null;c.Library(`${r}.library.style`,{entries:[n],onSelect:async s=>{u.onSelect(s)}})});let l={};return ot.forEach(({id:c,label:u})=>{l[`ly.img.plugin-ai-sticker-generation-web.${r}.property.style.${c}`]=u}),rt(e,{en:{[`panel.${Re("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",...l}}),ao({falKey:i,modelKey:r,name:"Recraft 20b",schema:Cr,inputReference:"#/components/schemas/Recraft20bInput",middleware:t.middlewares??t.middleware??[],headers:t.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:c,state:u},s)=>{let d=u("style/icon",a?a.id:"icon/broken_line");return c.Button(`${s.id}`,{inputLabel:[`ly.img.plugin-ai-sticker-generation-web.${r}.property.${s.id}`,`ly.img.plugin-ai-generation-web.property.${s.id}`,`ly.img.plugin-ai-sticker-generation-web.${r}.defaults.property.${s.id}`,`ly.img.plugin-ai-generation-web.defaults.property.${s.id}`],icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:Ie.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;Ie.clearActiveAssets(),Ie.setAssetActive(p.id),d.setValue(m),e.ui.closePanel(`${Re(r)}.styleSelection`)}};e.ui.openPanel(`${Re(r)}.styleSelection`,{payload:h})}}),()=>({id:s.id,type:"string",value:d.value??"icon/broken_line"})}},getBlockInput:c=>{if(Tt(c.image_size))return Promise.resolve({sticker:{width:c.image_size.width??512,height:c.image_size.height??512}});let u=nt(c.image_size??"square_hd");return Promise.resolve({sticker:u})}},t)}var bf={Recraft20b:so},lm=bf;export{lm as default};
133
133
  /*! Bundled license information:
134
134
 
135
135
  lodash-es/lodash.js: