@imgly/plugin-ai-sticker-generation-web 1.78.0-rc.0 → 1.79.0-nightly.20260708
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/fal-ai/index.mjs +4 -4
- package/dist/fal-ai/index.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +2 -2
- package/package.json +3 -3
package/dist/fal-ai/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var mo=Object.create;var Pi=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var _o=Object.getPrototypeOf,vo=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var wo=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of bo(t))!vo.call(e,n)&&n!==i&&Pi(e,n,{get:()=>t[n],enumerable:!(r=yo(t,n))||r.enumerable});return e};var Eo=(e,t,i)=>(i=e!=null?mo(_o(e)):{},wo(t||!e||!e.__esModule?Pi(i,"default",{value:e,enumerable:!0}):i,e));var Xt=k(L=>{"use strict";var Nd=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=Ld;L.withProxy=Rd;function Ld(...e){let t=i=>typeof i=="function";return i=>Nd(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 Rd(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 ct=k(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.RUNNER_HINT_HEADER=T.QUEUE_PRIORITY_HEADER=T.REQUEST_TIMEOUT_TYPE_HEADER=T.REQUEST_TIMEOUT_HEADER=T.MIN_REQUEST_TIMEOUT_SECONDS=void 0;T.validateTimeoutHeader=Pr;T.buildTimeoutHeaders=Fd;T.MIN_REQUEST_TIMEOUT_SECONDS=1;T.REQUEST_TIMEOUT_HEADER="x-fal-request-timeout";T.REQUEST_TIMEOUT_TYPE_HEADER="x-fal-request-timeout-type";T.QUEUE_PRIORITY_HEADER="x-fal-queue-priority";T.RUNNER_HINT_HEADER="x-fal-runner-hint";function Pr(e){if(typeof e!="number"||isNaN(e))throw new Error(`Timeout must be a number, got ${e}`);if(e<=T.MIN_REQUEST_TIMEOUT_SECONDS)throw new Error(`Timeout must be greater than ${T.MIN_REQUEST_TIMEOUT_SECONDS} seconds`);return e.toString()}function Fd(e){return e===void 0?{}:{[T.REQUEST_TIMEOUT_HEADER]:Pr(e)}}});var Q=k(R=>{"use strict";var Ur=R&&R.__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(R,"__esModule",{value:!0});R.ValidationError=R.ApiError=void 0;R.defaultResponseHandler=Lr;R.resultResponseHandler=zd;var Bd=ct(),Nr="x-fal-request-id",Se=class extends Error{constructor({message:t,status:i,body:r,requestId:n,timeoutType:o}){super(t),this.name="ApiError",this.status=i,this.body=r,this.requestId=n||"",this.timeoutType=o}get isUserTimeout(){return this.status===504&&this.timeoutType==="user"}};R.ApiError=Se;var ut=class extends Se{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)}};R.ValidationError=ut;function Lr(e){return Ur(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(Nr)||void 0,a=e.headers.get(Bd.REQUEST_TIMEOUT_TYPE_HEADER)||void 0;if(!e.ok){if(n.includes("application/json")){let l=yield e.json(),c=i===422?ut:Se;throw new c({message:l.message||r,status:i,body:l,requestId:o,timeoutType:a})}throw new Se({message:`HTTP ${i}: ${r}`,status:i,requestId:o,timeoutType:a})}return n.includes("application/json")?e.json():n.includes("text/html")?e.text():n.includes("application/octet-stream")?e.arrayBuffer():e.text()})}function zd(e){return Ur(this,void 0,void 0,function*(){return{data:yield Lr(e),requestId:e.headers.get(Nr)||""}})}});var W=k(P=>{"use strict";var qd=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=Rr;P.parseEndpointId=Hd;P.isValidUrl=Gd;P.throttle=Kd;P.isReact=Yd;P.isPlainObject=Qd;P.sleep=Wd;function Rr(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 Vd=["workflows","comfy"];function Hd(e){let i=Rr(e).split("/");return Vd.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 Gd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function Kd(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 ei;function Yd(){if(ei===void 0){let e=new Error().stack;ei=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return ei}function Qd(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function Wd(e){return qd(this,void 0,void 0,function*(){return new Promise(t=>setTimeout(t,e))})}});var qe=k(O=>{"use strict";var Zd=O&&O.__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(O,"__esModule",{value:!0});O.DEFAULT_RETRY_OPTIONS=O.DEFAULT_RETRYABLE_STATUS_CODES=void 0;O.isRetryableError=Fr;O.calculateBackoffDelay=Br;O.executeWithRetry=eg;var Jd=Q(),Xd=W();O.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];O.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:O.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Fr(e,t){return!(e instanceof Jd.ApiError)||e.isUserTimeout?!1:t.includes(e.status)}function Br(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 eg(e,t,i){return Zd(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||!Fr(a,t.retryableStatusCodes))throw a;let l=Br(o,t.baseDelay,t.maxDelay,t.backoffMultiplier,t.enableJitter);r.totalDelay+=l,i&&i(o+1,a,l),yield(0,Xd.sleep)(l)}}throw n})}});var zr=k((vh,tg)=>{tg.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.9.0",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 pt=k(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.isBrowser=ig;gt.getUserAgent=rg;function ig(){return typeof window<"u"&&typeof window.document<"u"}var dt=null;function rg(){if(dt!==null)return dt;let e=zr();return dt=`${e.name}/${e.version}`,dt}});var ft=k(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.credentialsFromEnv=void 0;Z.resolveDefaultFetch=Hr;Z.createConfig=cg;Z.getRestApiUrl=ug;var qr=Xt(),ng=Q(),Vr=qe(),og=pt();function Hr(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function ag(){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 sg=()=>{if(ag())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};Z.credentialsFromEnv=sg;var lg={credentials:Z.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:ng.defaultResponseHandler,retry:Vr.DEFAULT_RETRY_OPTIONS};function cg(e){var t;let i=Object.assign(Object.assign(Object.assign({},lg),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:Hr(),retry:Object.assign(Object.assign({},Vr.DEFAULT_RETRY_OPTIONS),e.retry||{})});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,qr.withMiddleware)(i.requestMiddleware,(0,qr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,og.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 ug(){return"https://rest.alpha.fal.ai"}});var xe=k(J=>{"use strict";var Gr=J&&J.__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())})},dg=J&&J.__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(J,"__esModule",{value:!0});J.dispatchRequest=pg;J.buildUrl=fg;var Kr=qe(),Yr=pt(),ti=W(),gg=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function pg(e){return Gr(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=()=>Gr(this,void 0,void 0,function*(){var p,f,y;let v=(0,Yr.isBrowser)()?{}:{"User-Agent":(0,Yr.getUserAgent)()},g=typeof a=="function"?a():a,{method:h,url:w,headers:_}=yield l({method:((f=(p=e.method)!==null&&p!==void 0?p:o.method)!==null&&f!==void 0?f:"post").toUpperCase(),url:i,headers:e.headers}),M=g?{Authorization:`Key ${g}`}:{},N=Object.assign(Object.assign(Object.assign(Object.assign({},M),{Accept:"application/json","Content-Type":"application/json"}),v),_??{}),{responseHandler:re,retry:Xe}=o,ue=dg(o,["responseHandler","retry"]),z=yield u(w,Object.assign(Object.assign(Object.assign(Object.assign({},ue),{method:h,headers:Object.assign(Object.assign({},N),(y=ue.headers)!==null&&y!==void 0?y:{})}),!gg&&{mode:"cors"}),{signal:o.signal,body:h.toLowerCase()!=="get"&&r?JSON.stringify(r):void 0}));return yield(re??c)(z)}),m;for(let p=0;p<=s.maxRetries;p++)try{return yield d()}catch(f){if(m=f,p===s.maxRetries||!(0,Kr.isRetryableError)(f,s.retryableStatusCodes)||((t=o.signal)===null||t===void 0?void 0:t.aborted))throw f;let v=(0,Kr.calculateBackoffDelay)(p,s.baseDelay,s.maxDelay,s.backoffMultiplier,s.enableJitter);yield(0,ti.sleep)(v)}throw m})}function fg(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,ti.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${c}`;let u=(0,ti.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var ri=k(F=>{"use strict";var ae=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=ii;F.buildObjectLifecycleHeaders=yg;F.createStorageClient=wg;var Qr=ft(),Wr=xe(),hg=W();F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER="x-fal-object-lifecycle-preference";var mg={never:31536e5,immediate:void 0,"1h":3600,"1d":86400,"7d":604800,"30d":2592e3,"1y":31536e3};function ii(e){let{expiresIn:t}=e;return typeof t=="number"?t:mg[t]}function yg(e){if(!e)return{};let t=ii(e);return t===void 0?{}:{[F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER]:JSON.stringify({expiration_duration_seconds:t})}}function Zr(e){var t;let[,i]=e.split("/");return(t=i.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function bg(e,t,i,r){return ae(this,void 0,void 0,function*(){let n=e.name||`${Date.now()}.${Zr(i)}`,o={};if(r){let a={expiration_duration_seconds:ii(r),allow_io_storage:r.expiresIn!=="immediate"};o["X-Fal-Object-Lifecycle"]=JSON.stringify(a)}return yield(0,Wr.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 _g(e,t,i,r){return ae(this,void 0,void 0,function*(){let n=e.name||`${Date.now()}.${Zr(i)}`,o={};return r&&(o["X-Fal-Object-Lifecycle"]=JSON.stringify(r)),yield(0,Wr.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 Jr(e,t,i){return ae(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 Jr(r,n,o,a-1)}})}function vg(e,t,i){return ae(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 _g(e,t,o,i),c=10*1024*1024,u=Math.ceil(e.size/c),s=new URL(a),d=[];for(let f=0;f<u;f++){let y=f*c,v=Math.min(y+c,e.size),g=e.slice(y,v),h=f+1,w=`${s.origin}${s.pathname}/${h}${s.search}`;d.push(yield Jr(w,g,t))}let m=`${s.origin}${s.pathname}/complete${s.search}`,p=yield r(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:d.map(f=>({partNumber:f.partNumber,etag:f.etag}))})});return yield n(p),l})}function wg({config:e}){let t={upload:(i,r)=>ae(this,void 0,void 0,function*(){let n=r?.lifecycle;if(i.size>94371840)return yield vg(i,e,n);let o=i.type||"application/octet-stream",{fetch:a,responseHandler:l}=e,{upload_url:c,file_url:u}=yield bg(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=>ae(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,hg.isPlainObject)(i)){let n=Object.entries(i).map(a=>ae(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 en=k(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});function Eg(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&&kg(i)&&(i=i.slice(Xr.length)),t=!1;let m=i.length,p=0,f=!1;for(;p<m;){f&&(i[p]===`
|
|
1
|
+
var mo=Object.create;var Pi=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var _o=Object.getPrototypeOf,vo=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var wo=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of bo(t))!vo.call(e,n)&&n!==i&&Pi(e,n,{get:()=>t[n],enumerable:!(r=yo(t,n))||r.enumerable});return e};var Eo=(e,t,i)=>(i=e!=null?mo(_o(e)):{},wo(t||!e||!e.__esModule?Pi(i,"default",{value:e,enumerable:!0}):i,e));var Xt=k(L=>{"use strict";var Nd=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=Ld;L.withProxy=Rd;function Ld(...e){let t=i=>typeof i=="function";return i=>Nd(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 Rd(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 ct=k(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.RUNNER_HINT_HEADER=T.QUEUE_PRIORITY_HEADER=T.REQUEST_TIMEOUT_TYPE_HEADER=T.REQUEST_TIMEOUT_HEADER=T.MIN_REQUEST_TIMEOUT_SECONDS=void 0;T.validateTimeoutHeader=Pr;T.buildTimeoutHeaders=Fd;T.MIN_REQUEST_TIMEOUT_SECONDS=1;T.REQUEST_TIMEOUT_HEADER="x-fal-request-timeout";T.REQUEST_TIMEOUT_TYPE_HEADER="x-fal-request-timeout-type";T.QUEUE_PRIORITY_HEADER="x-fal-queue-priority";T.RUNNER_HINT_HEADER="x-fal-runner-hint";function Pr(e){if(typeof e!="number"||isNaN(e))throw new Error(`Timeout must be a number, got ${e}`);if(e<=T.MIN_REQUEST_TIMEOUT_SECONDS)throw new Error(`Timeout must be greater than ${T.MIN_REQUEST_TIMEOUT_SECONDS} seconds`);return e.toString()}function Fd(e){return e===void 0?{}:{[T.REQUEST_TIMEOUT_HEADER]:Pr(e)}}});var Q=k(R=>{"use strict";var Ur=R&&R.__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(R,"__esModule",{value:!0});R.ValidationError=R.ApiError=void 0;R.defaultResponseHandler=Lr;R.resultResponseHandler=zd;var Bd=ct(),Nr="x-fal-request-id",xe=class extends Error{constructor({message:t,status:i,body:r,requestId:n,timeoutType:o}){super(t),this.name="ApiError",this.status=i,this.body=r,this.requestId=n||"",this.timeoutType=o}get isUserTimeout(){return this.status===504&&this.timeoutType==="user"}};R.ApiError=xe;var ut=class extends xe{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)}};R.ValidationError=ut;function Lr(e){return Ur(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(Nr)||void 0,a=e.headers.get(Bd.REQUEST_TIMEOUT_TYPE_HEADER)||void 0;if(!e.ok){if(n.includes("application/json")){let l=yield e.json(),c=i===422?ut:xe;throw new c({message:l.message||r,status:i,body:l,requestId:o,timeoutType:a})}throw new xe({message:`HTTP ${i}: ${r}`,status:i,requestId:o,timeoutType:a})}return n.includes("application/json")?e.json():n.includes("text/html")?e.text():n.includes("application/octet-stream")?e.arrayBuffer():e.text()})}function zd(e){return Ur(this,void 0,void 0,function*(){return{data:yield Lr(e),requestId:e.headers.get(Nr)||""}})}});var W=k(P=>{"use strict";var qd=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=Rr;P.parseEndpointId=Hd;P.isValidUrl=Gd;P.throttle=Kd;P.isReact=Yd;P.isPlainObject=Qd;P.sleep=Wd;function Rr(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 Vd=["workflows","comfy"];function Hd(e){let i=Rr(e).split("/");return Vd.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 Gd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function Kd(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 ei;function Yd(){if(ei===void 0){let e=new Error().stack;ei=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return ei}function Qd(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function Wd(e){return qd(this,void 0,void 0,function*(){return new Promise(t=>setTimeout(t,e))})}});var qe=k(O=>{"use strict";var Zd=O&&O.__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(O,"__esModule",{value:!0});O.DEFAULT_RETRY_OPTIONS=O.DEFAULT_RETRYABLE_STATUS_CODES=void 0;O.isRetryableError=Fr;O.calculateBackoffDelay=Br;O.executeWithRetry=eg;var Jd=Q(),Xd=W();O.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];O.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:O.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Fr(e,t){return!(e instanceof Jd.ApiError)||e.isUserTimeout?!1:t.includes(e.status)}function Br(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 eg(e,t,i){return Zd(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||!Fr(a,t.retryableStatusCodes))throw a;let l=Br(o,t.baseDelay,t.maxDelay,t.backoffMultiplier,t.enableJitter);r.totalDelay+=l,i&&i(o+1,a,l),yield(0,Xd.sleep)(l)}}throw n})}});var zr=k((vh,tg)=>{tg.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.9.0",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 pt=k(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.isBrowser=ig;gt.getUserAgent=rg;function ig(){return typeof window<"u"&&typeof window.document<"u"}var dt=null;function rg(){if(dt!==null)return dt;let e=zr();return dt=`${e.name}/${e.version}`,dt}});var ft=k(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.credentialsFromEnv=void 0;Z.resolveDefaultFetch=Hr;Z.createConfig=cg;Z.getRestApiUrl=ug;var qr=Xt(),ng=Q(),Vr=qe(),og=pt();function Hr(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function ag(){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 sg=()=>{if(ag())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};Z.credentialsFromEnv=sg;var lg={credentials:Z.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:ng.defaultResponseHandler,retry:Vr.DEFAULT_RETRY_OPTIONS};function cg(e){var t;let i=Object.assign(Object.assign(Object.assign({},lg),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:Hr(),retry:Object.assign(Object.assign({},Vr.DEFAULT_RETRY_OPTIONS),e.retry||{})});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,qr.withMiddleware)(i.requestMiddleware,(0,qr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,og.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 ug(){return"https://rest.alpha.fal.ai"}});var Se=k(J=>{"use strict";var Gr=J&&J.__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())})},dg=J&&J.__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(J,"__esModule",{value:!0});J.dispatchRequest=pg;J.buildUrl=fg;var Kr=qe(),Yr=pt(),ti=W(),gg=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function pg(e){return Gr(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=()=>Gr(this,void 0,void 0,function*(){var p,f,y;let v=(0,Yr.isBrowser)()?{}:{"User-Agent":(0,Yr.getUserAgent)()},g=typeof a=="function"?a():a,{method:h,url:w,headers:_}=yield l({method:((f=(p=e.method)!==null&&p!==void 0?p:o.method)!==null&&f!==void 0?f:"post").toUpperCase(),url:i,headers:e.headers}),M=g?{Authorization:`Key ${g}`}:{},N=Object.assign(Object.assign(Object.assign(Object.assign({},M),{Accept:"application/json","Content-Type":"application/json"}),v),_??{}),{responseHandler:re,retry:Xe}=o,ue=dg(o,["responseHandler","retry"]),z=yield u(w,Object.assign(Object.assign(Object.assign(Object.assign({},ue),{method:h,headers:Object.assign(Object.assign({},N),(y=ue.headers)!==null&&y!==void 0?y:{})}),!gg&&{mode:"cors"}),{signal:o.signal,body:h.toLowerCase()!=="get"&&r?JSON.stringify(r):void 0}));return yield(re??c)(z)}),m;for(let p=0;p<=s.maxRetries;p++)try{return yield d()}catch(f){if(m=f,p===s.maxRetries||!(0,Kr.isRetryableError)(f,s.retryableStatusCodes)||((t=o.signal)===null||t===void 0?void 0:t.aborted))throw f;let v=(0,Kr.calculateBackoffDelay)(p,s.baseDelay,s.maxDelay,s.backoffMultiplier,s.enableJitter);yield(0,ti.sleep)(v)}throw m})}function fg(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,ti.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${c}`;let u=(0,ti.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var ri=k(F=>{"use strict";var ae=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=ii;F.buildObjectLifecycleHeaders=yg;F.createStorageClient=wg;var Qr=ft(),Wr=Se(),hg=W();F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER="x-fal-object-lifecycle-preference";var mg={never:31536e5,immediate:void 0,"1h":3600,"1d":86400,"7d":604800,"30d":2592e3,"1y":31536e3};function ii(e){let{expiresIn:t}=e;return typeof t=="number"?t:mg[t]}function yg(e){if(!e)return{};let t=ii(e);return t===void 0?{}:{[F.OBJECT_LIFECYCYLE_PREFERENCE_HEADER]:JSON.stringify({expiration_duration_seconds:t})}}function Zr(e){var t;let[,i]=e.split("/");return(t=i.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function bg(e,t,i,r){return ae(this,void 0,void 0,function*(){let n=e.name||`${Date.now()}.${Zr(i)}`,o={};if(r){let a={expiration_duration_seconds:ii(r),allow_io_storage:r.expiresIn!=="immediate"};o["X-Fal-Object-Lifecycle"]=JSON.stringify(a)}return yield(0,Wr.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 _g(e,t,i,r){return ae(this,void 0,void 0,function*(){let n=e.name||`${Date.now()}.${Zr(i)}`,o={};return r&&(o["X-Fal-Object-Lifecycle"]=JSON.stringify(r)),yield(0,Wr.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 Jr(e,t,i){return ae(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 Jr(r,n,o,a-1)}})}function vg(e,t,i){return ae(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 _g(e,t,o,i),c=10*1024*1024,u=Math.ceil(e.size/c),s=new URL(a),d=[];for(let f=0;f<u;f++){let y=f*c,v=Math.min(y+c,e.size),g=e.slice(y,v),h=f+1,w=`${s.origin}${s.pathname}/${h}${s.search}`;d.push(yield Jr(w,g,t))}let m=`${s.origin}${s.pathname}/complete${s.search}`,p=yield r(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:d.map(f=>({partNumber:f.partNumber,etag:f.etag}))})});return yield n(p),l})}function wg({config:e}){let t={upload:(i,r)=>ae(this,void 0,void 0,function*(){let n=r?.lifecycle;if(i.size>94371840)return yield vg(i,e,n);let o=i.type||"application/octet-stream",{fetch:a,responseHandler:l}=e,{upload_url:c,file_url:u}=yield bg(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=>ae(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,hg.isPlainObject)(i)){let n=Object.entries(i).map(a=>ae(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 en=k(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});function Eg(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&&kg(i)&&(i=i.slice(Xr.length)),t=!1;let m=i.length,p=0,f=!1;for(;p<m;){f&&(i[p]===`
|
|
2
2
|
`&&++p,f=!1);let y=-1,v=n,g;for(let h=r;y<0&&h<m;++h)g=i[h],g===":"&&v<0?v=h-p:g==="\r"?(f=!0,y=h-p):g===`
|
|
3
3
|
`&&(y=h-p);if(y<0){r=m-p,n=v;break}else r=0,n=-1;s(i,p,v,y),p+=y+1}p===m?i="":p>0&&(i=i.slice(p))}function s(d,m,p,f){if(f===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,v=d.slice(m,m+(y?f:p)),g=0;y?g=f:d[m+p+1]===" "?g=p+2:g=p+1;let h=m+g,w=f-g,_=d.slice(h,h+w).toString();if(v==="data")l+=_?"".concat(_,`
|
|
4
4
|
`):`
|
|
5
|
-
`;else if(v==="event")a=_;else if(v==="id"&&!_.includes("\0"))o=_;else if(v==="retry"){let M=parseInt(_,10);Number.isNaN(M)||e({type:"reconnect-interval",value:M})}}}var Xr=[239,187,191];function kg(e){return Xr.every((t,i)=>e.charCodeAt(i)===t)}ni.createParser=Eg});var oi=k(X=>{"use strict";var Sg=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())})};Object.defineProperty(X,"__esModule",{value:!0});X.TOKEN_EXPIRATION_SECONDS=void 0;X.getTemporaryAuthToken=Tg;var xg=ft(),Ig=xe(),Ag=W();X.TOKEN_EXPIRATION_SECONDS=120;function Tg(e,t){return Sg(this,void 0,void 0,function*(){let i=(0,Ag.parseEndpointId)(e),r=yield(0,Ig.dispatchRequest)({method:"POST",targetUrl:`${(0,xg.getRestApiUrl)()}/tokens/`,config:t,input:{allowed_apps:[i.alias],token_expiration:X.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var si=k(U=>{"use strict";var Ae=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())})},Ve=U&&U.__await||function(e){return this instanceof Ve?(this.v=e,this):new Ve(e)},Cg=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(f){return Promise.resolve(f).then(p,d)}}function l(p,f){r[p]&&(n[p]=function(y){return new Promise(function(v,g){o.push([p,y,v,g])>1||c(p,y)})},f&&(n[p]=f(n[p])))}function c(p,f){try{u(r[p](f))}catch(y){m(o[0][3],y)}}function u(p){p.value instanceof Ve?Promise.resolve(p.value.v).then(s,d):m(o[0][2],p)}function s(p){c("next",p)}function d(p){c("throw",p)}function m(p,f){p(f),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty(U,"__esModule",{value:!0});U.FalStream=void 0;U.createStreamingClient=jg;var Mg=en(),$g=oi(),tn=xe(),Ie=Q(),ai="text/event-stream",Og=15*1e3,ht=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=()=>Ae(this,void 0,void 0,function*(){var o,a;let{endpointId:l,options:c}=this,{input:u,method:s="post",connectionMode:d="server",tokenProvider:m}=c;try{if(d==="client"){let f=yield(m?()=>m(l):()=>(console.warn('[fal.stream] Using the default token provider is deprecated. Please provide a `tokenProvider` function when using `connectionMode: "client"`. See https://docs.fal.ai/fal-client/authentication for more information.'),(0,$g.getTemporaryAuthToken)(l,this.config)))(),{fetch:y}=this.config,v=new URL(this.url);v.searchParams.set("fal_jwt_token",f);let g=yield y(v.toString(),{method:s.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:ai,"content-type":"application/json"},body:u&&s!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return this._requestId=g.headers.get("x-fal-request-id"),yield this.handleResponse(g)}return yield(0,tn.dispatchRequest)({method:s.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:ai},responseHandler:p=>Ae(this,void 0,void 0,function*(){return this._requestId=p.headers.get("x-fal-request-id"),yield this.handleResponse(p)}),signal:this.abortController.signal}})}catch(p){this.handleError(p)}}),this.handleResponse=o=>Ae(this,void 0,void 0,function*(){var a,l;if(!o.ok){try{yield(0,Ie.defaultResponseHandler)(o)}catch(y){this.emit("error",y)}return}let c=o.body;if(!c){this.emit("error",new Ie.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(ai)){let y=c.getReader(),v=()=>{y.read().then(({done:g,value:h})=>{if(g){this.emit("done",this.currentData);return}this.buffer.push(h),this.currentData=h,this.emit("data",h),v()})};v();return}let s=new TextDecoder("utf-8"),d=o.body.getReader(),m=(0,Mg.createParser)(y=>{if(y.type==="event"){let v=y.data;try{let g=JSON.parse(v);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:Og,f=()=>Ae(this,void 0,void 0,function*(){let{value:y,done:v}=yield d.read();this.lastEventTimestamp=Date.now(),m.feed(s.decode(y)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new Ie.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408,requestId:this._requestId||void 0})),v?this.emit("done",this.currentData):f().catch(this.handleError)});f().catch(this.handleError)}),this.handleError=o=>{var a;if(o.name==="AbortError"||this.signal.aborted)return;let l=o instanceof Ie.ApiError?o:new Ie.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=()=>Ae(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,tn.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new Ie.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 Cg(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 Ve(n)),yield Ve(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};U.FalStream=ht;function jg({config:e,storage:t}){return{stream(i,r){return Ae(this,void 0,void 0,function*(){let n=r.input?yield t.transformInput(r.input):void 0;return new ht(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var an=k(ee=>{"use strict";var se=ee&&ee.__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())})},Dg=ee&&ee.__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(ee,"__esModule",{value:!0});ee.createQueueClient=void 0;var li=ct(),H=xe(),Pg=Q(),on=qe(),Ug=ri(),Ng=si(),mt=W(),rn=500,nn={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:on.DEFAULT_RETRYABLE_STATUS_CODES},Lg={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...on.DEFAULT_RETRYABLE_STATUS_CODES,500]},Rg=({config:e,storage:t})=>{let i={submit(r,n){return se(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a,hint:l,startTimeout:c,headers:u,storageSettings:s}=n,d=Dg(n,["webhookUrl","priority","hint","startTimeout","headers","storageSettings"]),m=n.input?yield t.transformInput(n.input):void 0,p=Object.fromEntries(Object.entries(u??{}).map(([f,y])=>[f.toLowerCase(),y]));return(0,H.dispatchRequest)({method:n.method,targetUrl:(0,H.buildUrl)(r,Object.assign(Object.assign({},d),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},p),(0,Ug.buildObjectLifecycleHeaders)(s)),{[li.QUEUE_PRIORITY_HEADER]:a??"normal"}),l&&{[li.RUNNER_HINT_HEADER]:l}),(0,li.buildTimeoutHeaders)(c)),input:m,config:e,options:{signal:n.abortSignal,retry:nn}})})},status(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,abortSignal:c}){let u=(0,mt.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"";return(0,H.dispatchRequest)({method:"get",targetUrl:(0,H.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:l?"1":"0"},path:`/requests/${a}/status`}),config:e,options:{signal:c,retry:Lg}})})},streamStatus(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,connectionMode:c}){let u=(0,mt.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"",d={logs:l?"1":"0"},m=(0,H.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new Ng.FalStream(o,e,{url:m,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(r,n){return se(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",m=>{n.onQueueUpdate&&("logs"in m&&Array.isArray(m.logs)&&m.logs.length>0&&s.push(...m.logs),n.onQueueUpdate("logs"in m?Object.assign(Object.assign({},m),{logs:s}):m))});let d=yield u.done();return l&&clearTimeout(l),d}return new Promise((u,s)=>{var d;let m,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:rn,f=()=>{l&&clearTimeout(l),m&&clearTimeout(m)};a&&(l=setTimeout(()=>{f(),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=()=>se(this,void 0,void 0,function*(){var v;try{let g=yield i.status(r,{requestId:o,logs:(v=n.logs)!==null&&v!==void 0?v:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){f(),u(g);return}m=setTimeout(y,p)}catch(g){f(),s(g)}});y().catch(s)})})},result(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,mt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,H.dispatchRequest)({method:"get",targetUrl:(0,H.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:Pg.resultResponseHandler}),options:{signal:l,retry:nn}})})},cancel(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,mt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,H.dispatchRequest)({method:"put",targetUrl:(0,H.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:l}})})}};return i};ee.createQueueClient=Rg});var yt=k(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.utf8Count=Fg;G.utf8EncodeJs=sn;G.utf8EncodeTE=ln;G.utf8Encode=qg;G.utf8DecodeJs=cn;G.utf8DecodeTD=un;G.utf8Decode=Kg;function Fg(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 sn(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 Bg=new TextEncoder,zg=50;function ln(e,t,i){Bg.encodeInto(e,t.subarray(i))}function qg(e,t,i){e.length>zg?ln(e,t,i):sn(e,t,i)}var Vg=4096;function cn(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>=Vg&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var Hg=new TextDecoder,Gg=200;function un(e,t,i){let r=e.subarray(t,t+i);return Hg.decode(r)}function Kg(e,t,i){return i>Gg?un(e,t,i):cn(e,t,i)}});var ui=k(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.ExtData=void 0;var ci=class{type;data;constructor(t,i){this.type=t,this.data=i}};bt.ExtData=ci});var vt=k(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.DecodeError=void 0;var di=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})}};_t.DecodeError=di});var wt=k(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.UINT32_MAX=void 0;te.setUint64=Yg;te.setInt64=Qg;te.getInt64=Wg;te.getUint64=Zg;te.UINT32_MAX=4294967295;function Yg(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 Wg(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function Zg(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var gi=k(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.timestampExtension=j.EXT_TIMESTAMP=void 0;j.encodeTimeSpecToTimestamp=gn;j.encodeDateToTimeSpec=pn;j.encodeTimestampExtension=fn;j.decodeTimestampToTimeSpec=hn;j.decodeTimestampExtension=mn;var Jg=vt(),dn=wt();j.EXT_TIMESTAMP=-1;var Xg=4294967296-1,ep=17179869184-1;function gn({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=ep)if(t===0&&e<=Xg){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,dn.setInt64)(r,4,e),i}}function pn(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 fn(e){if(e instanceof Date){let t=pn(e);return gn(t)}else return null}function hn(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,dn.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new Jg.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function mn(e){let t=hn(e);return new Date(t.sec*1e3+t.nsec/1e6)}j.timestampExtension={type:j.EXT_TIMESTAMP,encode:fn,decode:mn}});var St=k(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.ExtensionCodec=void 0;var Et=ui(),tp=gi(),pi=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(tp.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 Et.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 Et.ExtData(a,o)}}}return t instanceof Et.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 Et.ExtData(i,t)}};kt.ExtensionCodec=pi});var hi=k(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.ensureUint8Array=rp;function ip(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function rp(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):ip(e)?new Uint8Array(e):Uint8Array.from(e)}});var yi=k(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.Encoder=B.DEFAULT_INITIAL_BUFFER_SIZE=B.DEFAULT_MAX_DEPTH=void 0;var yn=yt(),np=St(),bn=wt(),op=hi();B.DEFAULT_MAX_DEPTH=100;B.DEFAULT_INITIAL_BUFFER_SIZE=2048;var mi=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(t){this.extensionCodec=t?.extensionCodec??np.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.maxDepth=t?.maxDepth??B.DEFAULT_MAX_DEPTH,this.initialBufferSize=t?.initialBufferSize??B.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,yn.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,yn.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,op.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,bn.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,bn.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}};B.Encoder=mi});var _n=k(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.encode=sp;var ap=yi();function sp(e,t){return new ap.Encoder(t).encodeSharedRef(e)}});var vn=k(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.prettyByte=lp;function lp(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var wn=k(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.CachedKeyDecoder=void 0;var cp=yt(),up=16,dp=16,vi=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(t=up,i=dp){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,cp.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};xt.CachedKeyDecoder=vi});var At=k(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.Decoder=void 0;var wi=vn(),gp=St(),le=wt(),pp=yt(),En=hi(),fp=wn(),K=vt(),Ei="array",Ge="map_key",Sn="map_value",hp=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new K.DecodeError("The type of key must be string or number but "+typeof e)},ki=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(t){let i=this.getUninitializedStateFromPool();i.type=Ei,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=Ge,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===Ei){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===Ge||t.type===Sn){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}},He=-1,xi=new DataView(new ArrayBuffer(0)),mp=new Uint8Array(xi.buffer);try{xi.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 kn=new RangeError("Insufficient data"),yp=new fp.CachedKeyDecoder,Si=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=xi;bytes=mp;headByte=He;stack=new ki;entered=!1;constructor(t){this.extensionCodec=t?.extensionCodec??gp.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.rawStrings=t?.rawStrings??!1,this.maxStrLength=t?.maxStrLength??le.UINT32_MAX,this.maxBinLength=t?.maxBinLength??le.UINT32_MAX,this.maxArrayLength=t?.maxArrayLength??le.UINT32_MAX,this.maxMapLength=t?.maxMapLength??le.UINT32_MAX,this.maxExtLength=t?.maxExtLength??le.UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:yp,this.mapKeyConverter=t?.mapKeyConverter??hp}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=He,this.stack.reset()}setBuffer(t){let i=(0,En.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===He&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,En.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,wi.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 K.DecodeError(`Unrecognized type byte: ${(0,wi.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===Ei)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===Ge){if(i==="__proto__")throw new K.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=Sn;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=Ge;continue e}}return i}}readHeadByte(){return this.headByte===He&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=He}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 K.DecodeError(`Unrecognized array type byte: ${(0,wi.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new K.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new K.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 K.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw kn;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,pp.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ge:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new K.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw kn;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 K.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,le.getUint64)(this.view,this.pos);return this.pos+=8,t}readI64(){let t=(0,le.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}};It.Decoder=Si});var In=k(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.decode=bp;Tt.decodeMulti=_p;var xn=At();function bp(e,t){return new xn.Decoder(t).decode(e)}function _p(e,t){return new xn.Decoder(t).decodeMulti(e)}});var Cn=k(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.isAsyncIterable=An;Ke.asyncIterableFromStream=Tn;Ke.ensureAsyncIterable=vp;function An(e){return e[Symbol.asyncIterator]!=null}async function*Tn(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function vp(e){return An(e)?e:Tn(e)}});var Mn=k(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.decodeAsync=wp;Ye.decodeArrayStream=Ep;Ye.decodeMultiStream=kp;var Ii=At(),Ai=Cn();async function wp(e,t){let i=(0,Ai.ensureAsyncIterable)(e);return new Ii.Decoder(t).decodeAsync(i)}function Ep(e,t){let i=(0,Ai.ensureAsyncIterable)(e);return new Ii.Decoder(t).decodeArrayStream(i)}function kp(e,t){let i=(0,Ai.ensureAsyncIterable)(e);return new Ii.Decoder(t).decodeStream(i)}});var On=k(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.decodeTimestampExtension=E.encodeTimestampExtension=E.decodeTimestampToTimeSpec=E.encodeTimeSpecToTimestamp=E.encodeDateToTimeSpec=E.EXT_TIMESTAMP=E.ExtData=E.ExtensionCodec=E.Encoder=E.DecodeError=E.Decoder=E.decodeMultiStream=E.decodeArrayStream=E.decodeAsync=E.decodeMulti=E.decode=E.encode=void 0;var Sp=_n();Object.defineProperty(E,"encode",{enumerable:!0,get:function(){return Sp.encode}});var $n=In();Object.defineProperty(E,"decode",{enumerable:!0,get:function(){return $n.decode}});Object.defineProperty(E,"decodeMulti",{enumerable:!0,get:function(){return $n.decodeMulti}});var Ti=Mn();Object.defineProperty(E,"decodeAsync",{enumerable:!0,get:function(){return Ti.decodeAsync}});Object.defineProperty(E,"decodeArrayStream",{enumerable:!0,get:function(){return Ti.decodeArrayStream}});Object.defineProperty(E,"decodeMultiStream",{enumerable:!0,get:function(){return Ti.decodeMultiStream}});var xp=At();Object.defineProperty(E,"Decoder",{enumerable:!0,get:function(){return xp.Decoder}});var Ip=vt();Object.defineProperty(E,"DecodeError",{enumerable:!0,get:function(){return Ip.DecodeError}});var Ap=yi();Object.defineProperty(E,"Encoder",{enumerable:!0,get:function(){return Ap.Encoder}});var Tp=St();Object.defineProperty(E,"ExtensionCodec",{enumerable:!0,get:function(){return Tp.ExtensionCodec}});var Cp=ui();Object.defineProperty(E,"ExtData",{enumerable:!0,get:function(){return Cp.ExtData}});var Te=gi();Object.defineProperty(E,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return Te.EXT_TIMESTAMP}});Object.defineProperty(E,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return Te.encodeDateToTimeSpec}});Object.defineProperty(E,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return Te.encodeTimeSpecToTimestamp}});Object.defineProperty(E,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return Te.decodeTimestampToTimeSpec}});Object.defineProperty(E,"encodeTimestampExtension",{enumerable:!0,get:function(){return Te.encodeTimestampExtension}});Object.defineProperty(E,"decodeTimestampExtension",{enumerable:!0,get:function(){return Te.decodeTimestampExtension}})});var Kn=k(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});function A(e){return{enumerable:!0,value:e}}function jn(e){return{enumerable:!0,writable:!0,value:e}}var ce={},Mp=()=>!0,Dn=()=>({}),Un=e=>e,$p=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),Op=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),ie=(e,t)=>Object.freeze(Object.create(e,t));function Pn(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function Nn(e){return ie(this,{fn:A(e)})}var Ln={},Rn=Nn.bind(Ln),jp=e=>Rn((t,i)=>!!~e(t,i)&&t),Fn={},Dp=Nn.bind(Fn);function Ct(e,t){return t.filter(i=>e.isPrototypeOf(i))}function Bn(e,t,...i){let r=Pn(Ct(Fn,i).map(o=>o.fn),Mp,$p),n=Pn(Ct(Ln,i).map(o=>o.fn),Un,Op);return ie(this,{from:A(e),to:A(t),guards:A(r),reducers:A(n)})}var zn={},qn={},Pp=Bn.bind(zn),Up=Bn.bind(qn,null);function Np(e,t,i){return Mi(t,e,i,this.immediates)||e}function Vn(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 Lp={enter:Un};function Rp(...e){let t=Ct(zn,e),i=Ct(qn,e),r={final:A(e.length===0),transitions:A(Vn(t))};return i.length&&(r.immediates=A(i),r.enter=A(Np)),ie(Lp,r)}var Fp={enter(e,t,i){let r=this.fn.call(t,t.context,i);return Ci.isPrototypeOf(r)?ie(Hn,{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)}},Hn={enter(e,t,i){if(t.child=Gn(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,Mi(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function Bp(e,...t){let i=A(Vn(t));return Ci.isPrototypeOf(e)?ie(Hn,{machine:A(e),transitions:i}):ie(Fp,{fn:A(e),transitions:i})}var Ci={get state(){return{name:this.current,value:this.states[this.current]}}};function zp(e,t,i=Dn){return typeof e!="string"&&(i=t||Dn,t=e,e=Object.keys(t)[0]),ce._create&&ce._create(e,t),ie(Ci,{context:A(i),current:A(e),states:A(t)})}function Mi(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=ie(c,{current:A(o),original:{value:c}});return ce._onEnter&&ce._onEnter(t,o,e.context,n,i),u.state.value.enter(u,e,i)}}function qp(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?Mi(e,r,t,n.transitions.get(i))||r:(ce._send&&ce._send(i,o),r)}var Vp={send(e){this.machine=qp(this,e),this.onChange(this)}};function Gn(e,t,i,r){let n=Object.create(Vp,{machine:jn(e),context:jn(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}D.action=jp;D.createMachine=zp;D.d=ce;D.guard=Dp;D.immediate=Up;D.interpret=Gn;D.invoke=Bp;D.reduce=Rn;D.state=Rp;D.transition=Pp});var Xn=k(Ze=>{"use strict";var Yn=Ze&&Ze.__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(Ze,"__esModule",{value:!0});Ze.createRealtimeClient=cf;var We=On(),b=Kn(),Qn=oi(),$t=Q(),Wn=pt(),ji=W(),Hp=()=>({enqueuedMessage:void 0});function Gp(e){return e.token!==void 0}function Kp(e){return!Gp(e)}function Mt(e,t){return Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function Y(e){return e.websocket&&e.websocket.readyState===WebSocket.OPEN&&e.websocket.close(),Object.assign(Object.assign({},e),{websocket:void 0})}function Yp(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,We.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function $i(e){return Object.assign(Object.assign({},e),{token:void 0})}function Qp(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function Wp(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var Zp=(0,b.createMachine)("idle",{idle:(0,b.state)((0,b.transition)("send","connecting",(0,b.reduce)(Mt)),(0,b.transition)("expireToken","idle",(0,b.reduce)($i)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),connecting:(0,b.state)((0,b.transition)("connecting","connecting"),(0,b.transition)("connected","active",(0,b.reduce)(Wp)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(Y)),(0,b.transition)("send","connecting",(0,b.reduce)(Mt)),(0,b.transition)("close","idle",(0,b.reduce)(Y)),(0,b.immediate)("authRequired",(0,b.guard)(Kp))),authRequired:(0,b.state)((0,b.transition)("initiateAuth","authInProgress"),(0,b.transition)("send","authRequired",(0,b.reduce)(Mt)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),authInProgress:(0,b.state)((0,b.transition)("authenticated","connecting",(0,b.reduce)(Qp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)($i),(0,b.reduce)(Y)),(0,b.transition)("send","authInProgress",(0,b.reduce)(Mt)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),active:(0,b.state)((0,b.transition)("send","active",(0,b.reduce)(Yp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)($i)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(Y)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),failed:(0,b.state)((0,b.transition)("send","failed"),(0,b.transition)("close","idle",(0,b.reduce)(Y)))},Hp);function Jp(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,ji.ensureEndpointIdFormat)(e),a=r?`/${r.replace(/^\/+/,"")}`:"/realtime";return`wss://fal.run/${o}${a}?${n.toString()}`}var Xp=128;function ef(e){return e.status==="error"&&e.error==="Unauthorized"}var tf={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Oi=new Map,Zn=new Map;function rf(e,t,i){if(!Oi.has(e)){let r=(0,b.interpret)(Zp,i);Oi.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,ji.throttle)(r.send,t,!0):r.send}))}return Oi.get(e)}var Qe=()=>{},nf={send:Qe,close:Qe};function of(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!Jn(e)}function Jn(e){return e.type==="x-fal-error"}function af(e){return Yn(this,void 0,void 0,function*(){if(typeof e=="string")return JSON.parse(e);let t=i=>Yn(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,We.decode)(yield t(e)):e instanceof Blob?(0,We.decode)(yield t(e)):e})}function sf(e){return e instanceof Uint8Array?e:(0,We.encode)(e)}function lf({data:e,decodeMessage:t,onResult:i,onError:r,send:n}){let o=a=>{if(ef(a)){n({type:"unauthorized",error:new Error("Unauthorized")});return}if(of(a)){i(a);return}if(Jn(a)){if(a.error==="TIMEOUT")return;r(new $t.ApiError({message:`${a.error}: ${a.reason}`,status:400,body:a}));return}};Promise.resolve(t?t(e):e).then(o).catch(a=>{var l;r(new $t.ApiError({message:(l=a?.message)!==null&&l!==void 0?l:"Failed to decode realtime message",status:400}))})}function cf({config:e}){return{connect(t,i){let{clientOnly:r=(0,ji.isReact)()&&!(0,Wn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,path:a,throttleInterval:l=Xp,encodeMessage:c,decodeMessage:u,tokenProvider:s,tokenExpirationSeconds:d}=i;if(r&&!(0,Wn.isBrowser)())return nf;let m=c??(_=>sf(_)),p=u??(_=>af(_)),f,y;Zn.set(n,{decodeMessage:p,onError:i.onError,onResult:i.onResult});let v=()=>Zn.get(n),g=rf(n,l,({context:_,machine:M,send:N})=>{let{enqueuedMessage:re,token:Xe,websocket:ue}=_;if(y=re,M.current==="active"&&re&&ue?.readyState===WebSocket.OPEN&&N({type:"send",message:re}),M.current==="authRequired"&&Xe===void 0&&f!==M.current&&(N({type:"initiateAuth"}),(s?()=>s(t):()=>(console.warn("[fal.realtime] Using the default token provider is deprecated. Please provide a `tokenProvider` function to `fal.realtime.connect()`. See https://docs.fal.ai/fal-client/authentication for more information."),(0,Qn.getTemporaryAuthToken)(t,e)))().then(C=>{N({type:"authenticated",token:C});let $=s?d:Qn.TOKEN_EXPIRATION_SECONDS;if($!==void 0){let de=Math.round($*.9*1e3);setTimeout(()=>{N({type:"expireToken"})},de)}}).catch(C=>{N({type:"unauthorized",error:C})})),M.current==="connecting"&&f!==M.current&&Xe!==void 0){let z=new WebSocket(Jp(t,{token:Xe,maxBuffering:o,path:a}));z.onopen=()=>{var C,$;N({type:"connected",websocket:z});let de=($=(C=g.context)===null||C===void 0?void 0:C.enqueuedMessage)!==null&&$!==void 0?$:y;de&&(z.send(m(de)),g.context=Object.assign(Object.assign({},g.context),{enqueuedMessage:void 0}))},z.onclose=C=>{if(C.code!==tf.NORMAL_CLOSURE){let{onError:$=Qe}=v();$(new $t.ApiError({message:`Error closing the connection: ${C.reason}`,status:C.code}))}N({type:"connectionClosed",code:C.code})},z.onerror=C=>{let{onError:$=Qe}=v();$(new $t.ApiError({message:"Unknown error",status:500}))},z.onmessage=C=>{let{decodeMessage:$=p,onResult:de,onError:ho=Qe}=v();lf({data:C.data,decodeMessage:$,onResult:de,onError:ho,send:N})}}f=M.current});return{send:_=>{g.throttledSend({type:"send",message:m(_)})},close:()=>{g.send({type:"close"})}}}}}});var Di=k(Je=>{"use strict";var eo=Je&&Je.__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(Je,"__esModule",{value:!0});Je.createFalClient=mf;var uf=ft(),df=ct(),gf=an(),pf=Xn(),to=xe(),ff=Q(),io=ri(),hf=si();function mf(e={}){let t=(0,uf.createConfig)(e),i=(0,io.createStorageClient)({config:t}),r=(0,gf.createQueueClient)({config:t,storage:i}),n=(0,hf.createStreamingClient)({config:t,storage:i}),o=(0,pf.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return eo(this,arguments,void 0,function*(l,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,to.dispatchRequest)({method:c.method,targetUrl:(0,to.buildUrl)(l,c),input:u,headers:Object.assign(Object.assign({},(0,io.buildObjectLifecycleHeaders)(c.storageSettings)),(0,df.buildTimeoutHeaders)(c.startTimeout)),config:Object.assign(Object.assign({},t),{responseHandler:ff.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(a,l)=>eo(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 no=k(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.isQueueStatus=ro;Ot.isCompletedQueueStatus=yf;function ro(e){return e&&e.status&&e.response_url}function yf(e){return ro(e)&&e.status==="COMPLETED"}});var lo=k(I=>{"use strict";var bf=I&&I.__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]}),_f=I&&I.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&bf(t,e,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 oo=Di(),vf=Di();Object.defineProperty(I,"createFalClient",{enumerable:!0,get:function(){return vf.createFalClient}});var ao=Xt();Object.defineProperty(I,"withMiddleware",{enumerable:!0,get:function(){return ao.withMiddleware}});Object.defineProperty(I,"withProxy",{enumerable:!0,get:function(){return ao.withProxy}});var so=Q();Object.defineProperty(I,"ApiError",{enumerable:!0,get:function(){return so.ApiError}});Object.defineProperty(I,"ValidationError",{enumerable:!0,get:function(){return so.ValidationError}});var wf=qe();Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return wf.isRetryableError}});_f(no(),I);var Ef=W();Object.defineProperty(I,"parseEndpointId",{enumerable:!0,get:function(){return Ef.parseEndpointId}});I.fal=function(){let t=(0,oo.createFalClient)();return{config(i){t=(0,oo.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 ko=`
|
|
5
|
+
`;else if(v==="event")a=_;else if(v==="id"&&!_.includes("\0"))o=_;else if(v==="retry"){let M=parseInt(_,10);Number.isNaN(M)||e({type:"reconnect-interval",value:M})}}}var Xr=[239,187,191];function kg(e){return Xr.every((t,i)=>e.charCodeAt(i)===t)}ni.createParser=Eg});var oi=k(X=>{"use strict";var xg=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())})};Object.defineProperty(X,"__esModule",{value:!0});X.TOKEN_EXPIRATION_SECONDS=void 0;X.getTemporaryAuthToken=Tg;var Sg=ft(),Ig=Se(),Ag=W();X.TOKEN_EXPIRATION_SECONDS=120;function Tg(e,t){return xg(this,void 0,void 0,function*(){let i=(0,Ag.parseEndpointId)(e),r=yield(0,Ig.dispatchRequest)({method:"POST",targetUrl:`${(0,Sg.getRestApiUrl)()}/tokens/`,config:t,input:{allowed_apps:[i.alias],token_expiration:X.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var si=k(U=>{"use strict";var Ae=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())})},Ve=U&&U.__await||function(e){return this instanceof Ve?(this.v=e,this):new Ve(e)},Cg=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(f){return Promise.resolve(f).then(p,d)}}function l(p,f){r[p]&&(n[p]=function(y){return new Promise(function(v,g){o.push([p,y,v,g])>1||c(p,y)})},f&&(n[p]=f(n[p])))}function c(p,f){try{u(r[p](f))}catch(y){m(o[0][3],y)}}function u(p){p.value instanceof Ve?Promise.resolve(p.value.v).then(s,d):m(o[0][2],p)}function s(p){c("next",p)}function d(p){c("throw",p)}function m(p,f){p(f),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty(U,"__esModule",{value:!0});U.FalStream=void 0;U.createStreamingClient=jg;var Mg=en(),$g=oi(),tn=Se(),Ie=Q(),ai="text/event-stream",Og=15*1e3,ht=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=()=>Ae(this,void 0,void 0,function*(){var o,a;let{endpointId:l,options:c}=this,{input:u,method:s="post",connectionMode:d="server",tokenProvider:m}=c;try{if(d==="client"){let f=yield(m?()=>m(l):()=>(console.warn('[fal.stream] Using the default token provider is deprecated. Please provide a `tokenProvider` function when using `connectionMode: "client"`. See https://docs.fal.ai/fal-client/authentication for more information.'),(0,$g.getTemporaryAuthToken)(l,this.config)))(),{fetch:y}=this.config,v=new URL(this.url);v.searchParams.set("fal_jwt_token",f);let g=yield y(v.toString(),{method:s.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:ai,"content-type":"application/json"},body:u&&s!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return this._requestId=g.headers.get("x-fal-request-id"),yield this.handleResponse(g)}return yield(0,tn.dispatchRequest)({method:s.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:ai},responseHandler:p=>Ae(this,void 0,void 0,function*(){return this._requestId=p.headers.get("x-fal-request-id"),yield this.handleResponse(p)}),signal:this.abortController.signal}})}catch(p){this.handleError(p)}}),this.handleResponse=o=>Ae(this,void 0,void 0,function*(){var a,l;if(!o.ok){try{yield(0,Ie.defaultResponseHandler)(o)}catch(y){this.emit("error",y)}return}let c=o.body;if(!c){this.emit("error",new Ie.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(ai)){let y=c.getReader(),v=()=>{y.read().then(({done:g,value:h})=>{if(g){this.emit("done",this.currentData);return}this.buffer.push(h),this.currentData=h,this.emit("data",h),v()})};v();return}let s=new TextDecoder("utf-8"),d=o.body.getReader(),m=(0,Mg.createParser)(y=>{if(y.type==="event"){let v=y.data;try{let g=JSON.parse(v);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:Og,f=()=>Ae(this,void 0,void 0,function*(){let{value:y,done:v}=yield d.read();this.lastEventTimestamp=Date.now(),m.feed(s.decode(y)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new Ie.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408,requestId:this._requestId||void 0})),v?this.emit("done",this.currentData):f().catch(this.handleError)});f().catch(this.handleError)}),this.handleError=o=>{var a;if(o.name==="AbortError"||this.signal.aborted)return;let l=o instanceof Ie.ApiError?o:new Ie.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=()=>Ae(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,tn.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new Ie.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 Cg(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 Ve(n)),yield Ve(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};U.FalStream=ht;function jg({config:e,storage:t}){return{stream(i,r){return Ae(this,void 0,void 0,function*(){let n=r.input?yield t.transformInput(r.input):void 0;return new ht(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var an=k(ee=>{"use strict";var se=ee&&ee.__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())})},Dg=ee&&ee.__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(ee,"__esModule",{value:!0});ee.createQueueClient=void 0;var li=ct(),H=Se(),Pg=Q(),on=qe(),Ug=ri(),Ng=si(),mt=W(),rn=500,nn={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:on.DEFAULT_RETRYABLE_STATUS_CODES},Lg={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...on.DEFAULT_RETRYABLE_STATUS_CODES,500]},Rg=({config:e,storage:t})=>{let i={submit(r,n){return se(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a,hint:l,startTimeout:c,headers:u,storageSettings:s}=n,d=Dg(n,["webhookUrl","priority","hint","startTimeout","headers","storageSettings"]),m=n.input?yield t.transformInput(n.input):void 0,p=Object.fromEntries(Object.entries(u??{}).map(([f,y])=>[f.toLowerCase(),y]));return(0,H.dispatchRequest)({method:n.method,targetUrl:(0,H.buildUrl)(r,Object.assign(Object.assign({},d),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},p),(0,Ug.buildObjectLifecycleHeaders)(s)),{[li.QUEUE_PRIORITY_HEADER]:a??"normal"}),l&&{[li.RUNNER_HINT_HEADER]:l}),(0,li.buildTimeoutHeaders)(c)),input:m,config:e,options:{signal:n.abortSignal,retry:nn}})})},status(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,abortSignal:c}){let u=(0,mt.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"";return(0,H.dispatchRequest)({method:"get",targetUrl:(0,H.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:l?"1":"0"},path:`/requests/${a}/status`}),config:e,options:{signal:c,retry:Lg}})})},streamStatus(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,logs:l=!1,connectionMode:c}){let u=(0,mt.parseEndpointId)(o),s=u.namespace?`${u.namespace}/`:"",d={logs:l?"1":"0"},m=(0,H.buildUrl)(`${s}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new Ng.FalStream(o,e,{url:m,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(r,n){return se(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",m=>{n.onQueueUpdate&&("logs"in m&&Array.isArray(m.logs)&&m.logs.length>0&&s.push(...m.logs),n.onQueueUpdate("logs"in m?Object.assign(Object.assign({},m),{logs:s}):m))});let d=yield u.done();return l&&clearTimeout(l),d}return new Promise((u,s)=>{var d;let m,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:rn,f=()=>{l&&clearTimeout(l),m&&clearTimeout(m)};a&&(l=setTimeout(()=>{f(),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=()=>se(this,void 0,void 0,function*(){var v;try{let g=yield i.status(r,{requestId:o,logs:(v=n.logs)!==null&&v!==void 0?v:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){f(),u(g);return}m=setTimeout(y,p)}catch(g){f(),s(g)}});y().catch(s)})})},result(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,mt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,H.dispatchRequest)({method:"get",targetUrl:(0,H.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:Pg.resultResponseHandler}),options:{signal:l,retry:nn}})})},cancel(r,n){return se(this,arguments,void 0,function*(o,{requestId:a,abortSignal:l}){let c=(0,mt.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,H.dispatchRequest)({method:"put",targetUrl:(0,H.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:l}})})}};return i};ee.createQueueClient=Rg});var yt=k(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.utf8Count=Fg;G.utf8EncodeJs=sn;G.utf8EncodeTE=ln;G.utf8Encode=qg;G.utf8DecodeJs=cn;G.utf8DecodeTD=un;G.utf8Decode=Kg;function Fg(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 sn(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 Bg=new TextEncoder,zg=50;function ln(e,t,i){Bg.encodeInto(e,t.subarray(i))}function qg(e,t,i){e.length>zg?ln(e,t,i):sn(e,t,i)}var Vg=4096;function cn(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>=Vg&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var Hg=new TextDecoder,Gg=200;function un(e,t,i){let r=e.subarray(t,t+i);return Hg.decode(r)}function Kg(e,t,i){return i>Gg?un(e,t,i):cn(e,t,i)}});var ui=k(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.ExtData=void 0;var ci=class{type;data;constructor(t,i){this.type=t,this.data=i}};bt.ExtData=ci});var vt=k(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.DecodeError=void 0;var di=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})}};_t.DecodeError=di});var wt=k(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.UINT32_MAX=void 0;te.setUint64=Yg;te.setInt64=Qg;te.getInt64=Wg;te.getUint64=Zg;te.UINT32_MAX=4294967295;function Yg(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 Wg(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function Zg(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var gi=k(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.timestampExtension=j.EXT_TIMESTAMP=void 0;j.encodeTimeSpecToTimestamp=gn;j.encodeDateToTimeSpec=pn;j.encodeTimestampExtension=fn;j.decodeTimestampToTimeSpec=hn;j.decodeTimestampExtension=mn;var Jg=vt(),dn=wt();j.EXT_TIMESTAMP=-1;var Xg=4294967296-1,ep=17179869184-1;function gn({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=ep)if(t===0&&e<=Xg){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,dn.setInt64)(r,4,e),i}}function pn(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 fn(e){if(e instanceof Date){let t=pn(e);return gn(t)}else return null}function hn(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,dn.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new Jg.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function mn(e){let t=hn(e);return new Date(t.sec*1e3+t.nsec/1e6)}j.timestampExtension={type:j.EXT_TIMESTAMP,encode:fn,decode:mn}});var xt=k(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.ExtensionCodec=void 0;var Et=ui(),tp=gi(),pi=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(tp.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 Et.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 Et.ExtData(a,o)}}}return t instanceof Et.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 Et.ExtData(i,t)}};kt.ExtensionCodec=pi});var hi=k(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.ensureUint8Array=rp;function ip(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function rp(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):ip(e)?new Uint8Array(e):Uint8Array.from(e)}});var yi=k(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.Encoder=B.DEFAULT_INITIAL_BUFFER_SIZE=B.DEFAULT_MAX_DEPTH=void 0;var yn=yt(),np=xt(),bn=wt(),op=hi();B.DEFAULT_MAX_DEPTH=100;B.DEFAULT_INITIAL_BUFFER_SIZE=2048;var mi=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(t){this.extensionCodec=t?.extensionCodec??np.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.maxDepth=t?.maxDepth??B.DEFAULT_MAX_DEPTH,this.initialBufferSize=t?.initialBufferSize??B.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,yn.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,yn.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,op.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,bn.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,bn.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}};B.Encoder=mi});var _n=k(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.encode=sp;var ap=yi();function sp(e,t){return new ap.Encoder(t).encodeSharedRef(e)}});var vn=k(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.prettyByte=lp;function lp(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var wn=k(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.CachedKeyDecoder=void 0;var cp=yt(),up=16,dp=16,vi=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(t=up,i=dp){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,cp.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};St.CachedKeyDecoder=vi});var At=k(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.Decoder=void 0;var wi=vn(),gp=xt(),le=wt(),pp=yt(),En=hi(),fp=wn(),K=vt(),Ei="array",Ge="map_key",xn="map_value",hp=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new K.DecodeError("The type of key must be string or number but "+typeof e)},ki=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(t){let i=this.getUninitializedStateFromPool();i.type=Ei,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=Ge,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===Ei){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===Ge||t.type===xn){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}},He=-1,Si=new DataView(new ArrayBuffer(0)),mp=new Uint8Array(Si.buffer);try{Si.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 kn=new RangeError("Insufficient data"),yp=new fp.CachedKeyDecoder,xi=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Si;bytes=mp;headByte=He;stack=new ki;entered=!1;constructor(t){this.extensionCodec=t?.extensionCodec??gp.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.rawStrings=t?.rawStrings??!1,this.maxStrLength=t?.maxStrLength??le.UINT32_MAX,this.maxBinLength=t?.maxBinLength??le.UINT32_MAX,this.maxArrayLength=t?.maxArrayLength??le.UINT32_MAX,this.maxMapLength=t?.maxMapLength??le.UINT32_MAX,this.maxExtLength=t?.maxExtLength??le.UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:yp,this.mapKeyConverter=t?.mapKeyConverter??hp}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=He,this.stack.reset()}setBuffer(t){let i=(0,En.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===He&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,En.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,wi.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 K.DecodeError(`Unrecognized type byte: ${(0,wi.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===Ei)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===Ge){if(i==="__proto__")throw new K.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=xn;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=Ge;continue e}}return i}}readHeadByte(){return this.headByte===He&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=He}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 K.DecodeError(`Unrecognized array type byte: ${(0,wi.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new K.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new K.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 K.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw kn;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,pp.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ge:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new K.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw kn;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 K.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,le.getUint64)(this.view,this.pos);return this.pos+=8,t}readI64(){let t=(0,le.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}};It.Decoder=xi});var In=k(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.decode=bp;Tt.decodeMulti=_p;var Sn=At();function bp(e,t){return new Sn.Decoder(t).decode(e)}function _p(e,t){return new Sn.Decoder(t).decodeMulti(e)}});var Cn=k(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.isAsyncIterable=An;Ke.asyncIterableFromStream=Tn;Ke.ensureAsyncIterable=vp;function An(e){return e[Symbol.asyncIterator]!=null}async function*Tn(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function vp(e){return An(e)?e:Tn(e)}});var Mn=k(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.decodeAsync=wp;Ye.decodeArrayStream=Ep;Ye.decodeMultiStream=kp;var Ii=At(),Ai=Cn();async function wp(e,t){let i=(0,Ai.ensureAsyncIterable)(e);return new Ii.Decoder(t).decodeAsync(i)}function Ep(e,t){let i=(0,Ai.ensureAsyncIterable)(e);return new Ii.Decoder(t).decodeArrayStream(i)}function kp(e,t){let i=(0,Ai.ensureAsyncIterable)(e);return new Ii.Decoder(t).decodeStream(i)}});var On=k(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.decodeTimestampExtension=E.encodeTimestampExtension=E.decodeTimestampToTimeSpec=E.encodeTimeSpecToTimestamp=E.encodeDateToTimeSpec=E.EXT_TIMESTAMP=E.ExtData=E.ExtensionCodec=E.Encoder=E.DecodeError=E.Decoder=E.decodeMultiStream=E.decodeArrayStream=E.decodeAsync=E.decodeMulti=E.decode=E.encode=void 0;var xp=_n();Object.defineProperty(E,"encode",{enumerable:!0,get:function(){return xp.encode}});var $n=In();Object.defineProperty(E,"decode",{enumerable:!0,get:function(){return $n.decode}});Object.defineProperty(E,"decodeMulti",{enumerable:!0,get:function(){return $n.decodeMulti}});var Ti=Mn();Object.defineProperty(E,"decodeAsync",{enumerable:!0,get:function(){return Ti.decodeAsync}});Object.defineProperty(E,"decodeArrayStream",{enumerable:!0,get:function(){return Ti.decodeArrayStream}});Object.defineProperty(E,"decodeMultiStream",{enumerable:!0,get:function(){return Ti.decodeMultiStream}});var Sp=At();Object.defineProperty(E,"Decoder",{enumerable:!0,get:function(){return Sp.Decoder}});var Ip=vt();Object.defineProperty(E,"DecodeError",{enumerable:!0,get:function(){return Ip.DecodeError}});var Ap=yi();Object.defineProperty(E,"Encoder",{enumerable:!0,get:function(){return Ap.Encoder}});var Tp=xt();Object.defineProperty(E,"ExtensionCodec",{enumerable:!0,get:function(){return Tp.ExtensionCodec}});var Cp=ui();Object.defineProperty(E,"ExtData",{enumerable:!0,get:function(){return Cp.ExtData}});var Te=gi();Object.defineProperty(E,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return Te.EXT_TIMESTAMP}});Object.defineProperty(E,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return Te.encodeDateToTimeSpec}});Object.defineProperty(E,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return Te.encodeTimeSpecToTimestamp}});Object.defineProperty(E,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return Te.decodeTimestampToTimeSpec}});Object.defineProperty(E,"encodeTimestampExtension",{enumerable:!0,get:function(){return Te.encodeTimestampExtension}});Object.defineProperty(E,"decodeTimestampExtension",{enumerable:!0,get:function(){return Te.decodeTimestampExtension}})});var Kn=k(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});function A(e){return{enumerable:!0,value:e}}function jn(e){return{enumerable:!0,writable:!0,value:e}}var ce={},Mp=()=>!0,Dn=()=>({}),Un=e=>e,$p=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),Op=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),ie=(e,t)=>Object.freeze(Object.create(e,t));function Pn(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function Nn(e){return ie(this,{fn:A(e)})}var Ln={},Rn=Nn.bind(Ln),jp=e=>Rn((t,i)=>!!~e(t,i)&&t),Fn={},Dp=Nn.bind(Fn);function Ct(e,t){return t.filter(i=>e.isPrototypeOf(i))}function Bn(e,t,...i){let r=Pn(Ct(Fn,i).map(o=>o.fn),Mp,$p),n=Pn(Ct(Ln,i).map(o=>o.fn),Un,Op);return ie(this,{from:A(e),to:A(t),guards:A(r),reducers:A(n)})}var zn={},qn={},Pp=Bn.bind(zn),Up=Bn.bind(qn,null);function Np(e,t,i){return Mi(t,e,i,this.immediates)||e}function Vn(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 Lp={enter:Un};function Rp(...e){let t=Ct(zn,e),i=Ct(qn,e),r={final:A(e.length===0),transitions:A(Vn(t))};return i.length&&(r.immediates=A(i),r.enter=A(Np)),ie(Lp,r)}var Fp={enter(e,t,i){let r=this.fn.call(t,t.context,i);return Ci.isPrototypeOf(r)?ie(Hn,{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)}},Hn={enter(e,t,i){if(t.child=Gn(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,Mi(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function Bp(e,...t){let i=A(Vn(t));return Ci.isPrototypeOf(e)?ie(Hn,{machine:A(e),transitions:i}):ie(Fp,{fn:A(e),transitions:i})}var Ci={get state(){return{name:this.current,value:this.states[this.current]}}};function zp(e,t,i=Dn){return typeof e!="string"&&(i=t||Dn,t=e,e=Object.keys(t)[0]),ce._create&&ce._create(e,t),ie(Ci,{context:A(i),current:A(e),states:A(t)})}function Mi(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=ie(c,{current:A(o),original:{value:c}});return ce._onEnter&&ce._onEnter(t,o,e.context,n,i),u.state.value.enter(u,e,i)}}function qp(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?Mi(e,r,t,n.transitions.get(i))||r:(ce._send&&ce._send(i,o),r)}var Vp={send(e){this.machine=qp(this,e),this.onChange(this)}};function Gn(e,t,i,r){let n=Object.create(Vp,{machine:jn(e),context:jn(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}D.action=jp;D.createMachine=zp;D.d=ce;D.guard=Dp;D.immediate=Up;D.interpret=Gn;D.invoke=Bp;D.reduce=Rn;D.state=Rp;D.transition=Pp});var Xn=k(Ze=>{"use strict";var Yn=Ze&&Ze.__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(Ze,"__esModule",{value:!0});Ze.createRealtimeClient=cf;var We=On(),b=Kn(),Qn=oi(),$t=Q(),Wn=pt(),ji=W(),Hp=()=>({enqueuedMessage:void 0});function Gp(e){return e.token!==void 0}function Kp(e){return!Gp(e)}function Mt(e,t){return Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function Y(e){return e.websocket&&e.websocket.readyState===WebSocket.OPEN&&e.websocket.close(),Object.assign(Object.assign({},e),{websocket:void 0})}function Yp(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,We.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function $i(e){return Object.assign(Object.assign({},e),{token:void 0})}function Qp(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function Wp(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var Zp=(0,b.createMachine)("idle",{idle:(0,b.state)((0,b.transition)("send","connecting",(0,b.reduce)(Mt)),(0,b.transition)("expireToken","idle",(0,b.reduce)($i)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),connecting:(0,b.state)((0,b.transition)("connecting","connecting"),(0,b.transition)("connected","active",(0,b.reduce)(Wp)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(Y)),(0,b.transition)("send","connecting",(0,b.reduce)(Mt)),(0,b.transition)("close","idle",(0,b.reduce)(Y)),(0,b.immediate)("authRequired",(0,b.guard)(Kp))),authRequired:(0,b.state)((0,b.transition)("initiateAuth","authInProgress"),(0,b.transition)("send","authRequired",(0,b.reduce)(Mt)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),authInProgress:(0,b.state)((0,b.transition)("authenticated","connecting",(0,b.reduce)(Qp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)($i),(0,b.reduce)(Y)),(0,b.transition)("send","authInProgress",(0,b.reduce)(Mt)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),active:(0,b.state)((0,b.transition)("send","active",(0,b.reduce)(Yp)),(0,b.transition)("unauthorized","idle",(0,b.reduce)($i)),(0,b.transition)("connectionClosed","idle",(0,b.reduce)(Y)),(0,b.transition)("close","idle",(0,b.reduce)(Y))),failed:(0,b.state)((0,b.transition)("send","failed"),(0,b.transition)("close","idle",(0,b.reduce)(Y)))},Hp);function Jp(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,ji.ensureEndpointIdFormat)(e),a=r?`/${r.replace(/^\/+/,"")}`:"/realtime";return`wss://fal.run/${o}${a}?${n.toString()}`}var Xp=128;function ef(e){return e.status==="error"&&e.error==="Unauthorized"}var tf={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Oi=new Map,Zn=new Map;function rf(e,t,i){if(!Oi.has(e)){let r=(0,b.interpret)(Zp,i);Oi.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,ji.throttle)(r.send,t,!0):r.send}))}return Oi.get(e)}var Qe=()=>{},nf={send:Qe,close:Qe};function of(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!Jn(e)}function Jn(e){return e.type==="x-fal-error"}function af(e){return Yn(this,void 0,void 0,function*(){if(typeof e=="string")return JSON.parse(e);let t=i=>Yn(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,We.decode)(yield t(e)):e instanceof Blob?(0,We.decode)(yield t(e)):e})}function sf(e){return e instanceof Uint8Array?e:(0,We.encode)(e)}function lf({data:e,decodeMessage:t,onResult:i,onError:r,send:n}){let o=a=>{if(ef(a)){n({type:"unauthorized",error:new Error("Unauthorized")});return}if(of(a)){i(a);return}if(Jn(a)){if(a.error==="TIMEOUT")return;r(new $t.ApiError({message:`${a.error}: ${a.reason}`,status:400,body:a}));return}};Promise.resolve(t?t(e):e).then(o).catch(a=>{var l;r(new $t.ApiError({message:(l=a?.message)!==null&&l!==void 0?l:"Failed to decode realtime message",status:400}))})}function cf({config:e}){return{connect(t,i){let{clientOnly:r=(0,ji.isReact)()&&!(0,Wn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,path:a,throttleInterval:l=Xp,encodeMessage:c,decodeMessage:u,tokenProvider:s,tokenExpirationSeconds:d}=i;if(r&&!(0,Wn.isBrowser)())return nf;let m=c??(_=>sf(_)),p=u??(_=>af(_)),f,y;Zn.set(n,{decodeMessage:p,onError:i.onError,onResult:i.onResult});let v=()=>Zn.get(n),g=rf(n,l,({context:_,machine:M,send:N})=>{let{enqueuedMessage:re,token:Xe,websocket:ue}=_;if(y=re,M.current==="active"&&re&&ue?.readyState===WebSocket.OPEN&&N({type:"send",message:re}),M.current==="authRequired"&&Xe===void 0&&f!==M.current&&(N({type:"initiateAuth"}),(s?()=>s(t):()=>(console.warn("[fal.realtime] Using the default token provider is deprecated. Please provide a `tokenProvider` function to `fal.realtime.connect()`. See https://docs.fal.ai/fal-client/authentication for more information."),(0,Qn.getTemporaryAuthToken)(t,e)))().then(C=>{N({type:"authenticated",token:C});let $=s?d:Qn.TOKEN_EXPIRATION_SECONDS;if($!==void 0){let de=Math.round($*.9*1e3);setTimeout(()=>{N({type:"expireToken"})},de)}}).catch(C=>{N({type:"unauthorized",error:C})})),M.current==="connecting"&&f!==M.current&&Xe!==void 0){let z=new WebSocket(Jp(t,{token:Xe,maxBuffering:o,path:a}));z.onopen=()=>{var C,$;N({type:"connected",websocket:z});let de=($=(C=g.context)===null||C===void 0?void 0:C.enqueuedMessage)!==null&&$!==void 0?$:y;de&&(z.send(m(de)),g.context=Object.assign(Object.assign({},g.context),{enqueuedMessage:void 0}))},z.onclose=C=>{if(C.code!==tf.NORMAL_CLOSURE){let{onError:$=Qe}=v();$(new $t.ApiError({message:`Error closing the connection: ${C.reason}`,status:C.code}))}N({type:"connectionClosed",code:C.code})},z.onerror=C=>{let{onError:$=Qe}=v();$(new $t.ApiError({message:"Unknown error",status:500}))},z.onmessage=C=>{let{decodeMessage:$=p,onResult:de,onError:ho=Qe}=v();lf({data:C.data,decodeMessage:$,onResult:de,onError:ho,send:N})}}f=M.current});return{send:_=>{g.throttledSend({type:"send",message:m(_)})},close:()=>{g.send({type:"close"})}}}}}});var Di=k(Je=>{"use strict";var eo=Je&&Je.__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(Je,"__esModule",{value:!0});Je.createFalClient=mf;var uf=ft(),df=ct(),gf=an(),pf=Xn(),to=Se(),ff=Q(),io=ri(),hf=si();function mf(e={}){let t=(0,uf.createConfig)(e),i=(0,io.createStorageClient)({config:t}),r=(0,gf.createQueueClient)({config:t,storage:i}),n=(0,hf.createStreamingClient)({config:t,storage:i}),o=(0,pf.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return eo(this,arguments,void 0,function*(l,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,to.dispatchRequest)({method:c.method,targetUrl:(0,to.buildUrl)(l,c),input:u,headers:Object.assign(Object.assign({},(0,io.buildObjectLifecycleHeaders)(c.storageSettings)),(0,df.buildTimeoutHeaders)(c.startTimeout)),config:Object.assign(Object.assign({},t),{responseHandler:ff.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(a,l)=>eo(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 no=k(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.isQueueStatus=ro;Ot.isCompletedQueueStatus=yf;function ro(e){return e&&e.status&&e.response_url}function yf(e){return ro(e)&&e.status==="COMPLETED"}});var lo=k(I=>{"use strict";var bf=I&&I.__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]}),_f=I&&I.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&bf(t,e,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 oo=Di(),vf=Di();Object.defineProperty(I,"createFalClient",{enumerable:!0,get:function(){return vf.createFalClient}});var ao=Xt();Object.defineProperty(I,"withMiddleware",{enumerable:!0,get:function(){return ao.withMiddleware}});Object.defineProperty(I,"withProxy",{enumerable:!0,get:function(){return ao.withProxy}});var so=Q();Object.defineProperty(I,"ApiError",{enumerable:!0,get:function(){return so.ApiError}});Object.defineProperty(I,"ValidationError",{enumerable:!0,get:function(){return so.ValidationError}});var wf=qe();Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return wf.isRetryableError}});_f(no(),I);var Ef=W();Object.defineProperty(I,"parseEndpointId",{enumerable:!0,get:function(){return Ef.parseEndpointId}});I.fal=function(){let t=(0,oo.createFalClient)();return{config(i){t=(0,oo.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 ko=`
|
|
6
6
|
<svg>
|
|
7
7
|
<symbol
|
|
8
8
|
fill="none"
|
|
@@ -68,7 +68,7 @@ var mo=Object.create;var Pi=Object.defineProperty;var yo=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
|
-
`,Wi=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(h=>g.groups?.includes(h)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(h=>g.groups?.includes(h)))),o){let g=o.toLowerCase();d=d.filter(h=>{let w=h.label?.[r]?.toLowerCase(),_=h.tags?.[r]||[];return w&&w.includes(g)||_.some(M=>M.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(h=>{let w=h.tags?.[r]||[];return g.some(_=>w.includes(_))})}n&&d.sort((g,h)=>{let w=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(h.id);return w&&!_?-1:!w&&_?1:0}),s&&s!=="id"?d.sort((g,h)=>{let w=g.meta?.[s],_=h.meta?.[s];return w===void 0?1:_===void 0?-1:typeof w=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(w):w.localeCompare(_):typeof w=="number"&&typeof _=="number"?u==="Descending"?_-w:w-_:0}):s==="id"&&d.sort((g,h)=>u==="Descending"?h.id.localeCompare(g.id):g.id.localeCompare(h.id));let m=d.length,p=t*i,f=p+i,y=d.slice(p,f).map(g=>{let h=g.label?.[r]||"",w=this.translateLabel?this.translateLabel(g.id,h,r):h;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:w,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),v=f<m?t+1:void 0;return{assets:y,currentPage:t,nextPage:v,total:m}}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 So=typeof global=="object"&&global&&global.Object===Object&&global,Zi=So,xo=typeof self=="object"&&self&&self.Object===Object&&self,Io=Zi||xo||Function("return this")(),q=Io,Ao=q.Symbol,pe=Ao,Ji=Object.prototype,To=Ji.hasOwnProperty,Co=Ji.toString,Me=pe?pe.toStringTag:void 0;function Mo(e){var t=To.call(e,Me),i=e[Me];try{e[Me]=void 0;var r=!0}catch{}var n=Co.call(e);return r&&(t?e[Me]=i:delete e[Me]),n}var $o=Mo,Oo=Object.prototype,jo=Oo.toString;function Do(e){return jo.call(e)}var Po=Do,Uo="[object Null]",No="[object Undefined]",Ui=pe?pe.toStringTag:void 0;function Lo(e){return e==null?e===void 0?No:Uo:Ui&&Ui in Object(e)?$o(e):Po(e)}var De=Lo;function Ro(e){return e!=null&&typeof e=="object"}var Bt=Ro,Af=Array.isArray;function Fo(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Xi=Fo,Bo="[object AsyncFunction]",zo="[object Function]",qo="[object GeneratorFunction]",Vo="[object Proxy]";function Ho(e){if(!Xi(e))return!1;var t=De(e);return t==zo||t==qo||t==Bo||t==Vo}var Go=Ho,Ko=q["__core-js_shared__"],Dt=Ko,Ni=function(){var e=/[^.]+$/.exec(Dt&&Dt.keys&&Dt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Yo(e){return!!Ni&&Ni in e}var Qo=Yo,Wo=Function.prototype,Zo=Wo.toString;function Jo(e){if(e!=null){try{return Zo.call(e)}catch{}try{return e+""}catch{}}return""}var ne=Jo,Xo=/[\\^$.*+?()[\]{}|]/g,ea=/^\[object .+?Constructor\]$/,ta=Function.prototype,ia=Object.prototype,ra=ta.toString,na=ia.hasOwnProperty,oa=RegExp("^"+ra.call(na).replace(Xo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aa(e){if(!Xi(e)||Qo(e))return!1;var t=Go(e)?oa:ea;return t.test(ne(e))}var sa=aa;function la(e,t){return e?.[t]}var ca=la;function ua(e,t){var i=ca(e,t);return sa(i)?i:void 0}var fe=ua,da=fe(q,"WeakMap"),Ut=da;function ga(e,t){return e===t||e!==e&&t!==t}var pa=ga,fa=9007199254740991;function ha(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=fa}var ma=ha;var Tf=Object.prototype;var ya="[object Arguments]";function ba(e){return Bt(e)&&De(e)==ya}var Li=ba,er=Object.prototype,_a=er.hasOwnProperty,va=er.propertyIsEnumerable,Cf=Li(function(){return arguments}())?Li:function(e){return Bt(e)&&_a.call(e,"callee")&&!va.call(e,"callee")};var tr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ri=tr&&typeof module=="object"&&module&&!module.nodeType&&module,wa=Ri&&Ri.exports===tr,Fi=wa?q.Buffer:void 0,Mf=Fi?Fi.isBuffer:void 0;var Ea="[object Arguments]",ka="[object Array]",Sa="[object Boolean]",xa="[object Date]",Ia="[object Error]",Aa="[object Function]",Ta="[object Map]",Ca="[object Number]",Ma="[object Object]",$a="[object RegExp]",Oa="[object Set]",ja="[object String]",Da="[object WeakMap]",Pa="[object ArrayBuffer]",Ua="[object DataView]",Na="[object Float32Array]",La="[object Float64Array]",Ra="[object Int8Array]",Fa="[object Int16Array]",Ba="[object Int32Array]",za="[object Uint8Array]",qa="[object Uint8ClampedArray]",Va="[object Uint16Array]",Ha="[object Uint32Array]",S={};S[Na]=S[La]=S[Ra]=S[Fa]=S[Ba]=S[za]=S[qa]=S[Va]=S[Ha]=!0;S[Ea]=S[ka]=S[Pa]=S[Sa]=S[Ua]=S[xa]=S[Ia]=S[Aa]=S[Ta]=S[Ca]=S[Ma]=S[$a]=S[Oa]=S[ja]=S[Da]=!1;function Ga(e){return Bt(e)&&ma(e.length)&&!!S[De(e)]}var Ka=Ga;function Ya(e){return function(t){return e(t)}}var Qa=Ya,ir=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$e=ir&&typeof module=="object"&&module&&!module.nodeType&&module,Wa=$e&&$e.exports===ir,Pt=Wa&&Zi.process,Za=function(){try{var e=$e&&$e.require&&$e.require("util").types;return e||Pt&&Pt.binding&&Pt.binding("util")}catch{}}(),Bi=Za,zi=Bi&&Bi.isTypedArray,$f=zi?Qa(zi):Ka;var Ja=Object.prototype,Of=Ja.hasOwnProperty;function Xa(e,t){return function(i){return e(t(i))}}var es=Xa,jf=es(Object.keys,Object);var ts=Object.prototype,Df=ts.hasOwnProperty;var is=fe(Object,"create"),Oe=is;function rs(){this.__data__=Oe?Oe(null):{},this.size=0}var ns=rs;function os(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var as=os,ss="__lodash_hash_undefined__",ls=Object.prototype,cs=ls.hasOwnProperty;function us(e){var t=this.__data__;if(Oe){var i=t[e];return i===ss?void 0:i}return cs.call(t,e)?t[e]:void 0}var ds=us,gs=Object.prototype,ps=gs.hasOwnProperty;function fs(e){var t=this.__data__;return Oe?t[e]!==void 0:ps.call(t,e)}var hs=fs,ms="__lodash_hash_undefined__";function ys(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Oe&&t===void 0?ms:t,this}var bs=ys;function he(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])}}he.prototype.clear=ns;he.prototype.delete=as;he.prototype.get=ds;he.prototype.has=hs;he.prototype.set=bs;var qi=he;function _s(){this.__data__=[],this.size=0}var vs=_s;function ws(e,t){for(var i=e.length;i--;)if(pa(e[i][0],t))return i;return-1}var et=ws,Es=Array.prototype,ks=Es.splice;function Ss(e){var t=this.__data__,i=et(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():ks.call(t,i,1),--this.size,!0}var xs=Ss;function Is(e){var t=this.__data__,i=et(t,e);return i<0?void 0:t[i][1]}var As=Is;function Ts(e){return et(this.__data__,e)>-1}var Cs=Ts;function Ms(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 $s=Ms;function me(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])}}me.prototype.clear=vs;me.prototype.delete=xs;me.prototype.get=As;me.prototype.has=Cs;me.prototype.set=$s;var tt=me,Os=fe(q,"Map"),je=Os;function js(){this.size=0,this.__data__={hash:new qi,map:new(je||tt),string:new qi}}var Ds=js;function Ps(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Us=Ps;function Ns(e,t){var i=e.__data__;return Us(t)?i[typeof t=="string"?"string":"hash"]:i.map}var it=Ns;function Ls(e){var t=it(this,e).delete(e);return this.size-=t?1:0,t}var Rs=Ls;function Fs(e){return it(this,e).get(e)}var Bs=Fs;function zs(e){return it(this,e).has(e)}var qs=zs;function Vs(e,t){var i=it(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Hs=Vs;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=Ds;ye.prototype.delete=Rs;ye.prototype.get=Bs;ye.prototype.has=qs;ye.prototype.set=Hs;var rr=ye;function Gs(){this.__data__=new tt,this.size=0}var Ks=Gs;function Ys(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Qs=Ys;function Ws(e){return this.__data__.get(e)}var Zs=Ws;function Js(e){return this.__data__.has(e)}var Xs=Js,el=200;function tl(e,t){var i=this.__data__;if(i instanceof tt){var r=i.__data__;if(!je||r.length<el-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new rr(r)}return i.set(e,t),this.size=i.size,this}var il=tl;function Pe(e){var t=this.__data__=new tt(e);this.size=t.size}Pe.prototype.clear=Ks;Pe.prototype.delete=Qs;Pe.prototype.get=Zs;Pe.prototype.has=Xs;Pe.prototype.set=il;var rl=Object.prototype,Pf=rl.propertyIsEnumerable;var nl=fe(q,"DataView"),Nt=nl,ol=fe(q,"Promise"),Lt=ol,al=fe(q,"Set"),Rt=al,Vi="[object Map]",sl="[object Object]",Hi="[object Promise]",Gi="[object Set]",Ki="[object WeakMap]",Yi="[object DataView]",ll=ne(Nt),cl=ne(je),ul=ne(Lt),dl=ne(Rt),gl=ne(Ut),ge=De;(Nt&&ge(new Nt(new ArrayBuffer(1)))!=Yi||je&&ge(new je)!=Vi||Lt&&ge(Lt.resolve())!=Hi||Rt&&ge(new Rt)!=Gi||Ut&&ge(new Ut)!=Ki)&&(ge=function(e){var t=De(e),i=t==sl?e.constructor:void 0,r=i?ne(i):"";if(r)switch(r){case ll:return Yi;case cl:return Vi;case ul:return Hi;case dl:return Gi;case gl:return Ki}return t});var Uf=q.Uint8Array;var pl="__lodash_hash_undefined__";function fl(e){return this.__data__.set(e,pl),this}var hl=fl;function ml(e){return this.__data__.has(e)}var yl=ml;function Ft(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new rr;++t<i;)this.add(e[t])}Ft.prototype.add=Ft.prototype.push=hl;Ft.prototype.has=yl;var Qi=pe?pe.prototype:void 0,Nf=Qi?Qi.valueOf:void 0;var bl=Object.prototype,Lf=bl.hasOwnProperty;var _l=Object.prototype,Rf=_l.hasOwnProperty;var Ff=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Bf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),zf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function zt(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}var nr={Formats:ko};var vl=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(h=>g.groups?.includes(h)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(h=>g.groups?.includes(h)))),o){let g=o.toLowerCase();d=d.filter(h=>{let w=h.label?.[r]?.toLowerCase(),_=h.tags?.[r]||[];return w&&w.includes(g)||_.some(M=>M.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(h=>{let w=h.tags?.[r]||[];return g.some(_=>w.includes(_))})}n&&d.sort((g,h)=>{let w=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(h.id);return w&&!_?-1:!w&&_?1:0}),s&&s!=="id"?d.sort((g,h)=>{let w=g.meta?.[s],_=h.meta?.[s];return w===void 0?1:_===void 0?-1:typeof w=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(w):w.localeCompare(_):typeof w=="number"&&typeof _=="number"?u==="Descending"?_-w:w-_:0}):s==="id"&&d.sort((g,h)=>u==="Descending"?h.id.localeCompare(g.id):g.id.localeCompare(h.id));let m=d.length,p=t*i,f=p+i,y=d.slice(p,f).map(g=>{let h=g.label?.[r]||"",w=this.translateLabel?this.translateLabel(g.id,h,r):h;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:w,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),v=f<m?t+1:void 0;return{assets:y,currentPage:t,nextPage:v,total:m}}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 wl=typeof global=="object"&&global&&global.Object===Object&&global,vr=wl,El=typeof self=="object"&&self&&self.Object===Object&&self,kl=vr||El||Function("return this")(),V=kl,Sl=V.Symbol,_e=Sl,wr=Object.prototype,xl=wr.hasOwnProperty,Il=wr.toString,Ue=_e?_e.toStringTag:void 0;function Al(e){var t=xl.call(e,Ue),i=e[Ue];try{e[Ue]=void 0;var r=!0}catch{}var n=Il.call(e);return r&&(t?e[Ue]=i:delete e[Ue]),n}var Tl=Al,Cl=Object.prototype,Ml=Cl.toString;function $l(e){return Ml.call(e)}var Ol=$l,jl="[object Null]",Dl="[object Undefined]",or=_e?_e.toStringTag:void 0;function Pl(e){return e==null?e===void 0?Dl:jl:or&&or in Object(e)?Tl(e):Ol(e)}var Fe=Pl;function Ul(e){return e!=null&&typeof e=="object"}var Jt=Ul,Hf=Array.isArray;function Nl(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Er=Nl,Ll="[object AsyncFunction]",Rl="[object Function]",Fl="[object GeneratorFunction]",Bl="[object Proxy]";function zl(e){if(!Er(e))return!1;var t=Fe(e);return t==Rl||t==Fl||t==Ll||t==Bl}var ql=zl,Vl=V["__core-js_shared__"],qt=Vl,ar=function(){var e=/[^.]+$/.exec(qt&&qt.keys&&qt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Hl(e){return!!ar&&ar in e}var Gl=Hl,Kl=Function.prototype,Yl=Kl.toString;function Ql(e){if(e!=null){try{return Yl.call(e)}catch{}try{return e+""}catch{}}return""}var oe=Ql,Wl=/[\\^$.*+?()[\]{}|]/g,Zl=/^\[object .+?Constructor\]$/,Jl=Function.prototype,Xl=Object.prototype,ec=Jl.toString,tc=Xl.hasOwnProperty,ic=RegExp("^"+ec.call(tc).replace(Wl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rc(e){if(!Er(e)||Gl(e))return!1;var t=ql(e)?ic:Zl;return t.test(oe(e))}var nc=rc;function oc(e,t){return e?.[t]}var ac=oc;function sc(e,t){var i=ac(e,t);return nc(i)?i:void 0}var ve=sc,lc=ve(V,"WeakMap"),Gt=lc;function cc(e,t){return e===t||e!==e&&t!==t}var uc=cc,dc=9007199254740991;function gc(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=dc}var pc=gc,Gf=Object.prototype,fc="[object Arguments]";function hc(e){return Jt(e)&&Fe(e)==fc}var sr=hc,kr=Object.prototype,mc=kr.hasOwnProperty,yc=kr.propertyIsEnumerable,Kf=sr(function(){return arguments}())?sr:function(e){return Jt(e)&&mc.call(e,"callee")&&!yc.call(e,"callee")},Sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lr=Sr&&typeof module=="object"&&module&&!module.nodeType&&module,bc=lr&&lr.exports===Sr,cr=bc?V.Buffer:void 0,Yf=cr?cr.isBuffer:void 0,_c="[object Arguments]",vc="[object Array]",wc="[object Boolean]",Ec="[object Date]",kc="[object Error]",Sc="[object Function]",xc="[object Map]",Ic="[object Number]",Ac="[object Object]",Tc="[object RegExp]",Cc="[object Set]",Mc="[object String]",$c="[object WeakMap]",Oc="[object ArrayBuffer]",jc="[object DataView]",Dc="[object Float32Array]",Pc="[object Float64Array]",Uc="[object Int8Array]",Nc="[object Int16Array]",Lc="[object Int32Array]",Rc="[object Uint8Array]",Fc="[object Uint8ClampedArray]",Bc="[object Uint16Array]",zc="[object Uint32Array]",x={};x[Dc]=x[Pc]=x[Uc]=x[Nc]=x[Lc]=x[Rc]=x[Fc]=x[Bc]=x[zc]=!0;x[_c]=x[vc]=x[Oc]=x[wc]=x[jc]=x[Ec]=x[kc]=x[Sc]=x[xc]=x[Ic]=x[Ac]=x[Tc]=x[Cc]=x[Mc]=x[$c]=!1;function qc(e){return Jt(e)&&pc(e.length)&&!!x[Fe(e)]}var Vc=qc;function Hc(e){return function(t){return e(t)}}var Gc=Hc,xr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ne=xr&&typeof module=="object"&&module&&!module.nodeType&&module,Kc=Ne&&Ne.exports===xr,Vt=Kc&&vr.process,Yc=function(){try{var e=Ne&&Ne.require&&Ne.require("util").types;return e||Vt&&Vt.binding&&Vt.binding("util")}catch{}}(),ur=Yc,dr=ur&&ur.isTypedArray,Qf=dr?Gc(dr):Vc,Qc=Object.prototype,Wf=Qc.hasOwnProperty;function Wc(e,t){return function(i){return e(t(i))}}var Zc=Wc,Zf=Zc(Object.keys,Object),Jc=Object.prototype,Jf=Jc.hasOwnProperty,Xc=ve(Object,"create"),Le=Xc;function eu(){this.__data__=Le?Le(null):{},this.size=0}var tu=eu;function iu(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ru=iu,nu="__lodash_hash_undefined__",ou=Object.prototype,au=ou.hasOwnProperty;function su(e){var t=this.__data__;if(Le){var i=t[e];return i===nu?void 0:i}return au.call(t,e)?t[e]:void 0}var lu=su,cu=Object.prototype,uu=cu.hasOwnProperty;function du(e){var t=this.__data__;return Le?t[e]!==void 0:uu.call(t,e)}var gu=du,pu="__lodash_hash_undefined__";function fu(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Le&&t===void 0?pu:t,this}var hu=fu;function we(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])}}we.prototype.clear=tu;we.prototype.delete=ru;we.prototype.get=lu;we.prototype.has=gu;we.prototype.set=hu;var gr=we;function mu(){this.__data__=[],this.size=0}var yu=mu;function bu(e,t){for(var i=e.length;i--;)if(uc(e[i][0],t))return i;return-1}var rt=bu,_u=Array.prototype,vu=_u.splice;function wu(e){var t=this.__data__,i=rt(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():vu.call(t,i,1),--this.size,!0}var Eu=wu;function ku(e){var t=this.__data__,i=rt(t,e);return i<0?void 0:t[i][1]}var Su=ku;function xu(e){return rt(this.__data__,e)>-1}var Iu=xu;function Au(e,t){var i=this.__data__,r=rt(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var Tu=Au;function Ee(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])}}Ee.prototype.clear=yu;Ee.prototype.delete=Eu;Ee.prototype.get=Su;Ee.prototype.has=Iu;Ee.prototype.set=Tu;var nt=Ee,Cu=ve(V,"Map"),Re=Cu;function Mu(){this.size=0,this.__data__={hash:new gr,map:new(Re||nt),string:new gr}}var $u=Mu;function Ou(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ju=Ou;function Du(e,t){var i=e.__data__;return ju(t)?i[typeof t=="string"?"string":"hash"]:i.map}var ot=Du;function Pu(e){var t=ot(this,e).delete(e);return this.size-=t?1:0,t}var Uu=Pu;function Nu(e){return ot(this,e).get(e)}var Lu=Nu;function Ru(e){return ot(this,e).has(e)}var Fu=Ru;function Bu(e,t){var i=ot(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var zu=Bu;function ke(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])}}ke.prototype.clear=$u;ke.prototype.delete=Uu;ke.prototype.get=Lu;ke.prototype.has=Fu;ke.prototype.set=zu;var Ir=ke;function qu(){this.__data__=new nt,this.size=0}var Vu=qu;function Hu(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Gu=Hu;function Ku(e){return this.__data__.get(e)}var Yu=Ku;function Qu(e){return this.__data__.has(e)}var Wu=Qu,Zu=200;function Ju(e,t){var i=this.__data__;if(i instanceof nt){var r=i.__data__;if(!Re||r.length<Zu-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Ir(r)}return i.set(e,t),this.size=i.size,this}var Xu=Ju;function Be(e){var t=this.__data__=new nt(e);this.size=t.size}Be.prototype.clear=Vu;Be.prototype.delete=Gu;Be.prototype.get=Yu;Be.prototype.has=Wu;Be.prototype.set=Xu;var ed=Object.prototype,Xf=ed.propertyIsEnumerable,td=ve(V,"DataView"),Kt=td,id=ve(V,"Promise"),Yt=id,rd=ve(V,"Set"),Qt=rd,pr="[object Map]",nd="[object Object]",fr="[object Promise]",hr="[object Set]",mr="[object WeakMap]",yr="[object DataView]",od=oe(Kt),ad=oe(Re),sd=oe(Yt),ld=oe(Qt),cd=oe(Gt),be=Fe;(Kt&&be(new Kt(new ArrayBuffer(1)))!=yr||Re&&be(new Re)!=pr||Yt&&be(Yt.resolve())!=fr||Qt&&be(new Qt)!=hr||Gt&&be(new Gt)!=mr)&&(be=function(e){var t=Fe(e),i=t==nd?e.constructor:void 0,r=i?oe(i):"";if(r)switch(r){case od:return yr;case ad:return pr;case sd:return fr;case ld:return hr;case cd:return mr}return t});var eh=V.Uint8Array,ud="__lodash_hash_undefined__";function dd(e){return this.__data__.set(e,ud),this}var gd=dd;function pd(e){return this.__data__.has(e)}var fd=pd;function Wt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Ir;++t<i;)this.add(e[t])}Wt.prototype.add=Wt.prototype.push=gd;Wt.prototype.has=fd;var br=_e?_e.prototype:void 0,th=br?br.valueOf:void 0,hd=Object.prototype,ih=hd.hasOwnProperty,md=Object.prototype,rh=md.hasOwnProperty,nh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),oh=new RegExp(/[A-Fa-f0-9]{1}/,"g"),ah=new RegExp(/[A-Fa-f0-9]{2}/,"g");function yd(e){return e!==void 0}var bd=yd;function Ar(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function Tr(e){return typeof e?.translate=="function"}function _r(e,t,i){return e&&Ar(e)&&Tr(e.i18n)?e.i18n.translate(t):i}function at(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 Cr(e,t,i="style",r="image"){return(n,o)=>{if(!Ar(e))return o;let a=_d(t,i,n,r);if(Tr(e.i18n)){let l=e.i18n.translate(a);return l!==a[a.length-1]?l:o}return o}}function _d(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 vd(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=Zt(e);return at(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."}}),wd(e,i),{[r]:(o,a)=>{let{builder:l,experimental:{global:c},payload:u}=o,s,d=o.providerConfig,m=o.config,p=d?.properties?.[a.id]??m?.properties?.[a.id];p?.default&&(typeof p.default=="function"?s=p.default({}):s=p.default);let f=s??u?.url??t.defaultUrl,y=c(`${e}.${a.id}`,f);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:v=>{v.meta?.uri!=null&&y.setValue(v.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:y.value,required:!0})}}}function wd(e,t){t?.ui.registerPanel(Zt(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(Zt(e))):t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function Zt(e){return`ly.img.ai.${e}.imageSelection`}var Ed=vd;function kd(e,t){let{cesdk:i}=t;if(i==null)return{};let r=t.propertyKey??"style",n=xd(e);at(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=Ad({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=Td({cesdk:i,providerId:e,styles:a}),c=l.id;return Cd(l,{cesdk:i}),Sd({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[m]=l.getActiveAssetIds(),p=l.getAsset(m);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:m}=u;if(a.length>0){let p=m("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 f={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:f})}}),()=>({id:s.id,type:"string",value:p.value.id})}return()=>({id:s.id,type:"string",value:"none"})}}}function Sd(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 xd(e){return`ly.img.ai.${e}.styleSelection`}var Id=[{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 Ad(e){return Id.map(t=>t.id==="none"?e.includeNone?{id:t.id,label:_r(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/None.svg`}:void 0:{id:t.id,label:_r(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/${t.id}.jpeg`}).filter(bd)}var Td=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 vl(r,t),o=e.styles[0];return n.setAssetActive(o.id),n},Cd=(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"})},Md=kd;var $d="ly.img.ai";function ze(e){return`${$d}.${e}`}function Mr(e){return`${e.replace(/\/+$/,"")}/`}function $r(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 Ht="@imgly/plugin-ai-generation",sh=`
|
|
71
|
+
`,Wi=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(h=>g.groups?.includes(h)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(h=>g.groups?.includes(h)))),o){let g=o.toLowerCase();d=d.filter(h=>{let w=h.label?.[r]?.toLowerCase(),_=h.tags?.[r]||[];return w&&w.includes(g)||_.some(M=>M.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(h=>{let w=h.tags?.[r]||[];return g.some(_=>w.includes(_))})}n&&d.sort((g,h)=>{let w=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(h.id);return w&&!_?-1:!w&&_?1:0}),s&&s!=="id"?d.sort((g,h)=>{let w=g.meta?.[s],_=h.meta?.[s];return w===void 0?1:_===void 0?-1:typeof w=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(w):w.localeCompare(_):typeof w=="number"&&typeof _=="number"?u==="Descending"?_-w:w-_:0}):s==="id"&&d.sort((g,h)=>u==="Descending"?h.id.localeCompare(g.id):g.id.localeCompare(h.id));let m=d.length,p=t*i,f=p+i,y=d.slice(p,f).map(g=>{let h=g.label?.[r]||"",w=this.translateLabel?this.translateLabel(g.id,h,r):h;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:w,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),v=f<m?t+1:void 0;return{assets:y,currentPage:t,nextPage:v,total:m}}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 xo=typeof global=="object"&&global&&global.Object===Object&&global,Zi=xo,So=typeof self=="object"&&self&&self.Object===Object&&self,Io=Zi||So||Function("return this")(),q=Io,Ao=q.Symbol,pe=Ao,Ji=Object.prototype,To=Ji.hasOwnProperty,Co=Ji.toString,Me=pe?pe.toStringTag:void 0;function Mo(e){var t=To.call(e,Me),i=e[Me];try{e[Me]=void 0;var r=!0}catch{}var n=Co.call(e);return r&&(t?e[Me]=i:delete e[Me]),n}var $o=Mo,Oo=Object.prototype,jo=Oo.toString;function Do(e){return jo.call(e)}var Po=Do,Uo="[object Null]",No="[object Undefined]",Ui=pe?pe.toStringTag:void 0;function Lo(e){return e==null?e===void 0?No:Uo:Ui&&Ui in Object(e)?$o(e):Po(e)}var De=Lo;function Ro(e){return e!=null&&typeof e=="object"}var Bt=Ro,Af=Array.isArray;function Fo(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Xi=Fo,Bo="[object AsyncFunction]",zo="[object Function]",qo="[object GeneratorFunction]",Vo="[object Proxy]";function Ho(e){if(!Xi(e))return!1;var t=De(e);return t==zo||t==qo||t==Bo||t==Vo}var Go=Ho,Ko=q["__core-js_shared__"],Dt=Ko,Ni=function(){var e=/[^.]+$/.exec(Dt&&Dt.keys&&Dt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Yo(e){return!!Ni&&Ni in e}var Qo=Yo,Wo=Function.prototype,Zo=Wo.toString;function Jo(e){if(e!=null){try{return Zo.call(e)}catch{}try{return e+""}catch{}}return""}var ne=Jo,Xo=/[\\^$.*+?()[\]{}|]/g,ea=/^\[object .+?Constructor\]$/,ta=Function.prototype,ia=Object.prototype,ra=ta.toString,na=ia.hasOwnProperty,oa=RegExp("^"+ra.call(na).replace(Xo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aa(e){if(!Xi(e)||Qo(e))return!1;var t=Go(e)?oa:ea;return t.test(ne(e))}var sa=aa;function la(e,t){return e?.[t]}var ca=la;function ua(e,t){var i=ca(e,t);return sa(i)?i:void 0}var fe=ua,da=fe(q,"WeakMap"),Ut=da;function ga(e,t){return e===t||e!==e&&t!==t}var pa=ga,fa=9007199254740991;function ha(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=fa}var ma=ha;var Tf=Object.prototype;var ya="[object Arguments]";function ba(e){return Bt(e)&&De(e)==ya}var Li=ba,er=Object.prototype,_a=er.hasOwnProperty,va=er.propertyIsEnumerable,Cf=Li(function(){return arguments}())?Li:function(e){return Bt(e)&&_a.call(e,"callee")&&!va.call(e,"callee")};var tr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ri=tr&&typeof module=="object"&&module&&!module.nodeType&&module,wa=Ri&&Ri.exports===tr,Fi=wa?q.Buffer:void 0,Mf=Fi?Fi.isBuffer:void 0;var Ea="[object Arguments]",ka="[object Array]",xa="[object Boolean]",Sa="[object Date]",Ia="[object Error]",Aa="[object Function]",Ta="[object Map]",Ca="[object Number]",Ma="[object Object]",$a="[object RegExp]",Oa="[object Set]",ja="[object String]",Da="[object WeakMap]",Pa="[object ArrayBuffer]",Ua="[object DataView]",Na="[object Float32Array]",La="[object Float64Array]",Ra="[object Int8Array]",Fa="[object Int16Array]",Ba="[object Int32Array]",za="[object Uint8Array]",qa="[object Uint8ClampedArray]",Va="[object Uint16Array]",Ha="[object Uint32Array]",x={};x[Na]=x[La]=x[Ra]=x[Fa]=x[Ba]=x[za]=x[qa]=x[Va]=x[Ha]=!0;x[Ea]=x[ka]=x[Pa]=x[xa]=x[Ua]=x[Sa]=x[Ia]=x[Aa]=x[Ta]=x[Ca]=x[Ma]=x[$a]=x[Oa]=x[ja]=x[Da]=!1;function Ga(e){return Bt(e)&&ma(e.length)&&!!x[De(e)]}var Ka=Ga;function Ya(e){return function(t){return e(t)}}var Qa=Ya,ir=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$e=ir&&typeof module=="object"&&module&&!module.nodeType&&module,Wa=$e&&$e.exports===ir,Pt=Wa&&Zi.process,Za=function(){try{var e=$e&&$e.require&&$e.require("util").types;return e||Pt&&Pt.binding&&Pt.binding("util")}catch{}}(),Bi=Za,zi=Bi&&Bi.isTypedArray,$f=zi?Qa(zi):Ka;var Ja=Object.prototype,Of=Ja.hasOwnProperty;function Xa(e,t){return function(i){return e(t(i))}}var es=Xa,jf=es(Object.keys,Object);var ts=Object.prototype,Df=ts.hasOwnProperty;var is=fe(Object,"create"),Oe=is;function rs(){this.__data__=Oe?Oe(null):{},this.size=0}var ns=rs;function os(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var as=os,ss="__lodash_hash_undefined__",ls=Object.prototype,cs=ls.hasOwnProperty;function us(e){var t=this.__data__;if(Oe){var i=t[e];return i===ss?void 0:i}return cs.call(t,e)?t[e]:void 0}var ds=us,gs=Object.prototype,ps=gs.hasOwnProperty;function fs(e){var t=this.__data__;return Oe?t[e]!==void 0:ps.call(t,e)}var hs=fs,ms="__lodash_hash_undefined__";function ys(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Oe&&t===void 0?ms:t,this}var bs=ys;function he(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])}}he.prototype.clear=ns;he.prototype.delete=as;he.prototype.get=ds;he.prototype.has=hs;he.prototype.set=bs;var qi=he;function _s(){this.__data__=[],this.size=0}var vs=_s;function ws(e,t){for(var i=e.length;i--;)if(pa(e[i][0],t))return i;return-1}var et=ws,Es=Array.prototype,ks=Es.splice;function xs(e){var t=this.__data__,i=et(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():ks.call(t,i,1),--this.size,!0}var Ss=xs;function Is(e){var t=this.__data__,i=et(t,e);return i<0?void 0:t[i][1]}var As=Is;function Ts(e){return et(this.__data__,e)>-1}var Cs=Ts;function Ms(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 $s=Ms;function me(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])}}me.prototype.clear=vs;me.prototype.delete=Ss;me.prototype.get=As;me.prototype.has=Cs;me.prototype.set=$s;var tt=me,Os=fe(q,"Map"),je=Os;function js(){this.size=0,this.__data__={hash:new qi,map:new(je||tt),string:new qi}}var Ds=js;function Ps(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Us=Ps;function Ns(e,t){var i=e.__data__;return Us(t)?i[typeof t=="string"?"string":"hash"]:i.map}var it=Ns;function Ls(e){var t=it(this,e).delete(e);return this.size-=t?1:0,t}var Rs=Ls;function Fs(e){return it(this,e).get(e)}var Bs=Fs;function zs(e){return it(this,e).has(e)}var qs=zs;function Vs(e,t){var i=it(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Hs=Vs;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=Ds;ye.prototype.delete=Rs;ye.prototype.get=Bs;ye.prototype.has=qs;ye.prototype.set=Hs;var rr=ye;function Gs(){this.__data__=new tt,this.size=0}var Ks=Gs;function Ys(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Qs=Ys;function Ws(e){return this.__data__.get(e)}var Zs=Ws;function Js(e){return this.__data__.has(e)}var Xs=Js,el=200;function tl(e,t){var i=this.__data__;if(i instanceof tt){var r=i.__data__;if(!je||r.length<el-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new rr(r)}return i.set(e,t),this.size=i.size,this}var il=tl;function Pe(e){var t=this.__data__=new tt(e);this.size=t.size}Pe.prototype.clear=Ks;Pe.prototype.delete=Qs;Pe.prototype.get=Zs;Pe.prototype.has=Xs;Pe.prototype.set=il;var rl=Object.prototype,Pf=rl.propertyIsEnumerable;var nl=fe(q,"DataView"),Nt=nl,ol=fe(q,"Promise"),Lt=ol,al=fe(q,"Set"),Rt=al,Vi="[object Map]",sl="[object Object]",Hi="[object Promise]",Gi="[object Set]",Ki="[object WeakMap]",Yi="[object DataView]",ll=ne(Nt),cl=ne(je),ul=ne(Lt),dl=ne(Rt),gl=ne(Ut),ge=De;(Nt&&ge(new Nt(new ArrayBuffer(1)))!=Yi||je&&ge(new je)!=Vi||Lt&&ge(Lt.resolve())!=Hi||Rt&&ge(new Rt)!=Gi||Ut&&ge(new Ut)!=Ki)&&(ge=function(e){var t=De(e),i=t==sl?e.constructor:void 0,r=i?ne(i):"";if(r)switch(r){case ll:return Yi;case cl:return Vi;case ul:return Hi;case dl:return Gi;case gl:return Ki}return t});var Uf=q.Uint8Array;var pl="__lodash_hash_undefined__";function fl(e){return this.__data__.set(e,pl),this}var hl=fl;function ml(e){return this.__data__.has(e)}var yl=ml;function Ft(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new rr;++t<i;)this.add(e[t])}Ft.prototype.add=Ft.prototype.push=hl;Ft.prototype.has=yl;var Qi=pe?pe.prototype:void 0,Nf=Qi?Qi.valueOf:void 0;var bl=Object.prototype,Lf=bl.hasOwnProperty;var _l=Object.prototype,Rf=_l.hasOwnProperty;var Ff=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Bf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),zf=new RegExp(/[A-Fa-f0-9]{2}/,"g");function zt(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}var nr={Formats:ko};var vl=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(h=>g.groups?.includes(h)))),c&&c.length>0&&(d=d.filter(g=>!g.groups||!c.some(h=>g.groups?.includes(h)))),o){let g=o.toLowerCase();d=d.filter(h=>{let w=h.label?.[r]?.toLowerCase(),_=h.tags?.[r]||[];return w&&w.includes(g)||_.some(M=>M.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(h=>{let w=h.tags?.[r]||[];return g.some(_=>w.includes(_))})}n&&d.sort((g,h)=>{let w=this.activeAssetIds.has(g.id),_=this.activeAssetIds.has(h.id);return w&&!_?-1:!w&&_?1:0}),s&&s!=="id"?d.sort((g,h)=>{let w=g.meta?.[s],_=h.meta?.[s];return w===void 0?1:_===void 0?-1:typeof w=="string"&&typeof _=="string"?u==="Descending"?_.localeCompare(w):w.localeCompare(_):typeof w=="number"&&typeof _=="number"?u==="Descending"?_-w:w-_:0}):s==="id"&&d.sort((g,h)=>u==="Descending"?h.id.localeCompare(g.id):g.id.localeCompare(h.id));let m=d.length,p=t*i,f=p+i,y=d.slice(p,f).map(g=>{let h=g.label?.[r]||"",w=this.translateLabel?this.translateLabel(g.id,h,r):h;return{id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:w,tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)}}),v=f<m?t+1:void 0;return{assets:y,currentPage:t,nextPage:v,total:m}}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 wl=typeof global=="object"&&global&&global.Object===Object&&global,vr=wl,El=typeof self=="object"&&self&&self.Object===Object&&self,kl=vr||El||Function("return this")(),V=kl,xl=V.Symbol,_e=xl,wr=Object.prototype,Sl=wr.hasOwnProperty,Il=wr.toString,Ue=_e?_e.toStringTag:void 0;function Al(e){var t=Sl.call(e,Ue),i=e[Ue];try{e[Ue]=void 0;var r=!0}catch{}var n=Il.call(e);return r&&(t?e[Ue]=i:delete e[Ue]),n}var Tl=Al,Cl=Object.prototype,Ml=Cl.toString;function $l(e){return Ml.call(e)}var Ol=$l,jl="[object Null]",Dl="[object Undefined]",or=_e?_e.toStringTag:void 0;function Pl(e){return e==null?e===void 0?Dl:jl:or&&or in Object(e)?Tl(e):Ol(e)}var Fe=Pl;function Ul(e){return e!=null&&typeof e=="object"}var Jt=Ul,Hf=Array.isArray;function Nl(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Er=Nl,Ll="[object AsyncFunction]",Rl="[object Function]",Fl="[object GeneratorFunction]",Bl="[object Proxy]";function zl(e){if(!Er(e))return!1;var t=Fe(e);return t==Rl||t==Fl||t==Ll||t==Bl}var ql=zl,Vl=V["__core-js_shared__"],qt=Vl,ar=function(){var e=/[^.]+$/.exec(qt&&qt.keys&&qt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Hl(e){return!!ar&&ar in e}var Gl=Hl,Kl=Function.prototype,Yl=Kl.toString;function Ql(e){if(e!=null){try{return Yl.call(e)}catch{}try{return e+""}catch{}}return""}var oe=Ql,Wl=/[\\^$.*+?()[\]{}|]/g,Zl=/^\[object .+?Constructor\]$/,Jl=Function.prototype,Xl=Object.prototype,ec=Jl.toString,tc=Xl.hasOwnProperty,ic=RegExp("^"+ec.call(tc).replace(Wl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rc(e){if(!Er(e)||Gl(e))return!1;var t=ql(e)?ic:Zl;return t.test(oe(e))}var nc=rc;function oc(e,t){return e?.[t]}var ac=oc;function sc(e,t){var i=ac(e,t);return nc(i)?i:void 0}var ve=sc,lc=ve(V,"WeakMap"),Gt=lc;function cc(e,t){return e===t||e!==e&&t!==t}var uc=cc,dc=9007199254740991;function gc(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=dc}var pc=gc,Gf=Object.prototype,fc="[object Arguments]";function hc(e){return Jt(e)&&Fe(e)==fc}var sr=hc,kr=Object.prototype,mc=kr.hasOwnProperty,yc=kr.propertyIsEnumerable,Kf=sr(function(){return arguments}())?sr:function(e){return Jt(e)&&mc.call(e,"callee")&&!yc.call(e,"callee")},xr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lr=xr&&typeof module=="object"&&module&&!module.nodeType&&module,bc=lr&&lr.exports===xr,cr=bc?V.Buffer:void 0,Yf=cr?cr.isBuffer:void 0,_c="[object Arguments]",vc="[object Array]",wc="[object Boolean]",Ec="[object Date]",kc="[object Error]",xc="[object Function]",Sc="[object Map]",Ic="[object Number]",Ac="[object Object]",Tc="[object RegExp]",Cc="[object Set]",Mc="[object String]",$c="[object WeakMap]",Oc="[object ArrayBuffer]",jc="[object DataView]",Dc="[object Float32Array]",Pc="[object Float64Array]",Uc="[object Int8Array]",Nc="[object Int16Array]",Lc="[object Int32Array]",Rc="[object Uint8Array]",Fc="[object Uint8ClampedArray]",Bc="[object Uint16Array]",zc="[object Uint32Array]",S={};S[Dc]=S[Pc]=S[Uc]=S[Nc]=S[Lc]=S[Rc]=S[Fc]=S[Bc]=S[zc]=!0;S[_c]=S[vc]=S[Oc]=S[wc]=S[jc]=S[Ec]=S[kc]=S[xc]=S[Sc]=S[Ic]=S[Ac]=S[Tc]=S[Cc]=S[Mc]=S[$c]=!1;function qc(e){return Jt(e)&&pc(e.length)&&!!S[Fe(e)]}var Vc=qc;function Hc(e){return function(t){return e(t)}}var Gc=Hc,Sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ne=Sr&&typeof module=="object"&&module&&!module.nodeType&&module,Kc=Ne&&Ne.exports===Sr,Vt=Kc&&vr.process,Yc=function(){try{var e=Ne&&Ne.require&&Ne.require("util").types;return e||Vt&&Vt.binding&&Vt.binding("util")}catch{}}(),ur=Yc,dr=ur&&ur.isTypedArray,Qf=dr?Gc(dr):Vc,Qc=Object.prototype,Wf=Qc.hasOwnProperty;function Wc(e,t){return function(i){return e(t(i))}}var Zc=Wc,Zf=Zc(Object.keys,Object),Jc=Object.prototype,Jf=Jc.hasOwnProperty,Xc=ve(Object,"create"),Le=Xc;function eu(){this.__data__=Le?Le(null):{},this.size=0}var tu=eu;function iu(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ru=iu,nu="__lodash_hash_undefined__",ou=Object.prototype,au=ou.hasOwnProperty;function su(e){var t=this.__data__;if(Le){var i=t[e];return i===nu?void 0:i}return au.call(t,e)?t[e]:void 0}var lu=su,cu=Object.prototype,uu=cu.hasOwnProperty;function du(e){var t=this.__data__;return Le?t[e]!==void 0:uu.call(t,e)}var gu=du,pu="__lodash_hash_undefined__";function fu(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Le&&t===void 0?pu:t,this}var hu=fu;function we(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])}}we.prototype.clear=tu;we.prototype.delete=ru;we.prototype.get=lu;we.prototype.has=gu;we.prototype.set=hu;var gr=we;function mu(){this.__data__=[],this.size=0}var yu=mu;function bu(e,t){for(var i=e.length;i--;)if(uc(e[i][0],t))return i;return-1}var rt=bu,_u=Array.prototype,vu=_u.splice;function wu(e){var t=this.__data__,i=rt(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():vu.call(t,i,1),--this.size,!0}var Eu=wu;function ku(e){var t=this.__data__,i=rt(t,e);return i<0?void 0:t[i][1]}var xu=ku;function Su(e){return rt(this.__data__,e)>-1}var Iu=Su;function Au(e,t){var i=this.__data__,r=rt(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var Tu=Au;function Ee(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])}}Ee.prototype.clear=yu;Ee.prototype.delete=Eu;Ee.prototype.get=xu;Ee.prototype.has=Iu;Ee.prototype.set=Tu;var nt=Ee,Cu=ve(V,"Map"),Re=Cu;function Mu(){this.size=0,this.__data__={hash:new gr,map:new(Re||nt),string:new gr}}var $u=Mu;function Ou(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ju=Ou;function Du(e,t){var i=e.__data__;return ju(t)?i[typeof t=="string"?"string":"hash"]:i.map}var ot=Du;function Pu(e){var t=ot(this,e).delete(e);return this.size-=t?1:0,t}var Uu=Pu;function Nu(e){return ot(this,e).get(e)}var Lu=Nu;function Ru(e){return ot(this,e).has(e)}var Fu=Ru;function Bu(e,t){var i=ot(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var zu=Bu;function ke(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])}}ke.prototype.clear=$u;ke.prototype.delete=Uu;ke.prototype.get=Lu;ke.prototype.has=Fu;ke.prototype.set=zu;var Ir=ke;function qu(){this.__data__=new nt,this.size=0}var Vu=qu;function Hu(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Gu=Hu;function Ku(e){return this.__data__.get(e)}var Yu=Ku;function Qu(e){return this.__data__.has(e)}var Wu=Qu,Zu=200;function Ju(e,t){var i=this.__data__;if(i instanceof nt){var r=i.__data__;if(!Re||r.length<Zu-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Ir(r)}return i.set(e,t),this.size=i.size,this}var Xu=Ju;function Be(e){var t=this.__data__=new nt(e);this.size=t.size}Be.prototype.clear=Vu;Be.prototype.delete=Gu;Be.prototype.get=Yu;Be.prototype.has=Wu;Be.prototype.set=Xu;var ed=Object.prototype,Xf=ed.propertyIsEnumerable,td=ve(V,"DataView"),Kt=td,id=ve(V,"Promise"),Yt=id,rd=ve(V,"Set"),Qt=rd,pr="[object Map]",nd="[object Object]",fr="[object Promise]",hr="[object Set]",mr="[object WeakMap]",yr="[object DataView]",od=oe(Kt),ad=oe(Re),sd=oe(Yt),ld=oe(Qt),cd=oe(Gt),be=Fe;(Kt&&be(new Kt(new ArrayBuffer(1)))!=yr||Re&&be(new Re)!=pr||Yt&&be(Yt.resolve())!=fr||Qt&&be(new Qt)!=hr||Gt&&be(new Gt)!=mr)&&(be=function(e){var t=Fe(e),i=t==nd?e.constructor:void 0,r=i?oe(i):"";if(r)switch(r){case od:return yr;case ad:return pr;case sd:return fr;case ld:return hr;case cd:return mr}return t});var eh=V.Uint8Array,ud="__lodash_hash_undefined__";function dd(e){return this.__data__.set(e,ud),this}var gd=dd;function pd(e){return this.__data__.has(e)}var fd=pd;function Wt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Ir;++t<i;)this.add(e[t])}Wt.prototype.add=Wt.prototype.push=gd;Wt.prototype.has=fd;var br=_e?_e.prototype:void 0,th=br?br.valueOf:void 0,hd=Object.prototype,ih=hd.hasOwnProperty,md=Object.prototype,rh=md.hasOwnProperty,nh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),oh=new RegExp(/[A-Fa-f0-9]{1}/,"g"),ah=new RegExp(/[A-Fa-f0-9]{2}/,"g");function yd(e){return e!==void 0}var bd=yd;function Ar(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function Tr(e){return typeof e?.translate=="function"}function _r(e,t,i){return e&&Ar(e)&&Tr(e.i18n)?e.i18n.translate(t):i}function at(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 Cr(e,t,i="style",r="image"){return(n,o)=>{if(!Ar(e))return o;let a=_d(t,i,n,r);if(Tr(e.i18n)){let l=e.i18n.translate(a);return l!==a[a.length-1]?l:o}return o}}function _d(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 vd(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=Zt(e);return at(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."}}),wd(e,i),{[r]:(o,a)=>{let{builder:l,experimental:{global:c},payload:u}=o,s,d=o.providerConfig,m=o.config,p=d?.properties?.[a.id]??m?.properties?.[a.id];p?.default&&(typeof p.default=="function"?s=p.default({}):s=p.default);let f=s??u?.url??t.defaultUrl,y=c(`${e}.${a.id}`,f);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:v=>{v.meta?.uri!=null&&y.setValue(v.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:y.value,required:!0})}}}function wd(e,t){t?.ui.registerPanel(Zt(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(Zt(e))):t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function Zt(e){return`ly.img.ai.${e}.imageSelection`}var Ed=vd;function kd(e,t){let{cesdk:i}=t;if(i==null)return{};let r=t.propertyKey??"style",n=Sd(e);at(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=Ad({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=Td({cesdk:i,providerId:e,styles:a}),c=l.id;return Cd(l,{cesdk:i}),xd({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[m]=l.getActiveAssetIds(),p=l.getAsset(m);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:m}=u;if(a.length>0){let p=m("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 f={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:f})}}),()=>({id:s.id,type:"string",value:p.value.id})}return()=>({id:s.id,type:"string",value:"none"})}}}function xd(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 Sd(e){return`ly.img.ai.${e}.styleSelection`}var Id=[{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 Ad(e){return Id.map(t=>t.id==="none"?e.includeNone?{id:t.id,label:_r(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/None.svg`}:void 0:{id:t.id,label:_r(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/${t.id}.jpeg`}).filter(bd)}var Td=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 vl(r,t),o=e.styles[0];return n.setAssetActive(o.id),n},Cd=(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"})},Md=kd;var $d="ly.img.ai";function ze(e){return`${$d}.${e}`}function Mr(e){return`${e.replace(/\/+$/,"")}/`}function $r(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 Ht="@imgly/plugin-ai-generation",sh=`
|
|
72
72
|
<svg>
|
|
73
73
|
<symbol
|
|
74
74
|
fill="none"
|
|
@@ -129,7 +129,7 @@ var mo=Object.create;var Pi=Object.defineProperty;var yo=Object.getOwnPropertyDe
|
|
|
129
129
|
|
|
130
130
|
</symbol>
|
|
131
131
|
</svg>
|
|
132
|
-
`;var Or={ImageUrl:Ed,StyleTransfer:Md};var jr={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 jd={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 st(e){return jd[e]}var Dd=[{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"}],dh=Dd[0],Pd=[{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"}],gh=Pd[0],lt=[{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"}],ph=lt[0],Ud=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 Dr(e,t){return Ud(`${t}thumbnails/`)[e]}var co=Eo(lo());function uo(e,t){return(0,co.createFalClient)({proxyUrl:e,requestMiddleware:async r=>({...r,headers:{...r.headers,...t??{}}})})}function jt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function go(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.${zt(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.${zt(r)}`,{type:r});return e.storage.upload(l)}return t}}function kf(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=uo(t.proxyUrl,e.headers),e.initialize?.(o)},input:{quickActions:{supported:$r(e.supportedQuickActions??{},t.supportedQuickActions)},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?Or.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&&jt(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=st(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 go(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 po=kf;var Ce;function fo(e){return async({cesdk:t})=>Sf(t,e)}function Sf(e,t){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=Mr(t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/");e.ui.addIconSet("@imgly/plugin/formats",nr.Formats),Ce=new Wi(n,lt.map(({id:c,label:u})=>({id:c,label:u,thumbUri:Dr(c,o)})),{translateLabel:Cr(e,r,"style","sticker")});let a=Ce.getActiveSelectValue();e.engine.asset.addSource(Ce),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:c})=>c,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${ze(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 lt.forEach(({id:c,label:u})=>{l[`ly.img.plugin-ai-sticker-generation-web.${r}.property.style.${c}`]=u}),at(e,{en:{[`panel.${ze("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",...l}}),po({falKey:i,modelKey:r,name:"Recraft 20b",schema:jr,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:Ce.getTranslatedLabel(d.value||"icon/broken_line")||d.value||"icon/broken_line",labelAlignment:"left",onClick:()=>{let m={onSelect:async p=>{if(p.id==="back")return;let f=p.id;Ce.clearActiveAssets(),Ce.setAssetActive(p.id),d.setValue(f),e.ui.closePanel(`${ze(r)}.styleSelection`)}};e.ui.openPanel(`${ze(r)}.styleSelection`,{payload:m})}}),()=>({id:s.id,type:"string",value:d.value??"icon/broken_line"})}},getBlockInput:c=>{if(jt(c.image_size))return Promise.resolve({sticker:{width:c.image_size.width??512,height:c.image_size.height??512}});let u=st(c.image_size??"square_hd");return Promise.resolve({sticker:u})}},t)}var xf={Recraft20b:fo},mm=xf;export{mm as default};
|
|
132
|
+
`;var Or={ImageUrl:Ed,StyleTransfer:Md};var jr={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 jd={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 st(e){return jd[e]}var Dd=[{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"}],dh=Dd[0],Pd=[{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"}],gh=Pd[0],lt=[{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"}],ph=lt[0],Ud=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 Dr(e,t){return Ud(`${t}thumbnails/`)[e]}var co=Eo(lo());function uo(e,t){return(0,co.createFalClient)({proxyUrl:e,requestMiddleware:async r=>({...r,headers:{...r.headers,...t??{}}})})}function jt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function go(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.${zt(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.${zt(r)}`,{type:r});return e.storage.upload(l)}return t}}function kf(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=uo(t.proxyUrl,e.headers),e.initialize?.(o)},input:{quickActions:{supported:$r(e.supportedQuickActions??{},t.supportedQuickActions)},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?Or.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&&jt(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=st(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 go(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 po=kf;var Ce;function fo(e){return async({cesdk:t})=>xf(t,e)}function xf(e,t){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=Mr(t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/");e.ui.addIconSet("@imgly/plugin/formats",nr.Formats),Ce=new Wi(n,lt.map(({id:c,label:u})=>({id:c,label:u,thumbUri:Dr(c,o)})),{translateLabel:Cr(e,r,"style","sticker")});let a=Ce.getActiveSelectValue();e.engine.asset.addSource(Ce),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:c})=>c,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${ze(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 lt.forEach(({id:c,label:u})=>{l[`ly.img.plugin-ai-sticker-generation-web.${r}.property.style.${c}`]=u}),at(e,{en:{[`panel.${ze("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",...l}}),po({falKey:i,modelKey:r,name:"Recraft 20b",schema:jr,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:Ce.getTranslatedLabel(d.value||"icon/broken_line")||d.value||"icon/broken_line",labelAlignment:"left",onClick:()=>{let m={onSelect:async p=>{if(p.id==="back")return;let f=p.id;Ce.clearActiveAssets(),Ce.setAssetActive(p.id),d.setValue(f),e.ui.closePanel(`${ze(r)}.styleSelection`)}};e.ui.openPanel(`${ze(r)}.styleSelection`,{payload:m})}}),()=>({id:s.id,type:"string",value:d.value??"icon/broken_line"})}},getBlockInput:c=>{if(jt(c.image_size))return Promise.resolve({sticker:{width:c.image_size.width??512,height:c.image_size.height??512}});let u=st(c.image_size??"square_hd");return Promise.resolve({sticker:u})}},t)}var Sf={Recraft20b:fo},mm=Sf;export{mm as default};
|
|
133
133
|
/*! Bundled license information:
|
|
134
134
|
|
|
135
135
|
lodash-es/lodash.js:
|