@imgly/plugin-ai-video-generation-web 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- var Fn=Object.create;var br=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Hn=Object.getPrototypeOf,Qn=Object.prototype.hasOwnProperty;var v=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Gn=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zn(e))!Qn.call(t,n)&&n!==r&&br(t,n,{get:()=>e[n],enumerable:!(i=Vn(e,n))||i.enumerable});return t};var vr=(t,e,r)=>(r=t!=null?Fn(Hn(t)):{},Gn(e||!t||!t.__esModule?br(r,"default",{value:t,enumerable:!0}):r,t));var yt=v(j=>{"use strict";var Wn=j&&j.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(j,"__esModule",{value:!0});j.TARGET_URL_HEADER=void 0;j.withMiddleware=Yn;j.withProxy=Zn;function Yn(...t){let e=r=>typeof r=="function";return r=>Wn(this,void 0,void 0,function*(){let i=Object.assign({},r);for(let n of t.filter(e))i=yield n(i);return i})}j.TARGET_URL_HEADER="x-fal-target-url";function Zn(t){let e=r=>Promise.resolve(r);return typeof window>"u"?e:r=>r.headers&&j.TARGET_URL_HEADER in r?e(r):Promise.resolve(Object.assign(Object.assign({},r),{url:t.targetUrl,headers:Object.assign(Object.assign({},r.headers||{}),{[j.TARGET_URL_HEADER]:r.url})}))}});var K=v(P=>{"use strict";var xr=P&&P.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.ValidationError=P.ApiError=void 0;P.defaultResponseHandler=Er;P.resultResponseHandler=Jn;var Xn="x-fal-request-id",re=class extends Error{constructor({message:e,status:r,body:i}){super(e),this.name="ApiError",this.status=r,this.body=i}};P.ApiError=re;var Fe=class extends re{constructor(e){super(e),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(r=>r.loc[r.loc.length-1]===e)}};P.ValidationError=Fe;function Er(t){return xr(this,void 0,void 0,function*(){var e;let{status:r,statusText:i}=t,n=(e=t.headers.get("Content-Type"))!==null&&e!==void 0?e:"";if(!t.ok){if(n.includes("application/json")){let o=yield t.json(),s=r===422?Fe:re;throw new s({message:o.message||i,status:r,body:o})}throw new re({message:`HTTP ${r}: ${i}`,status:r})}return n.includes("application/json")?t.json():n.includes("text/html")?t.text():n.includes("application/octet-stream")?t.arrayBuffer():t.text()})}function Jn(t){return xr(this,void 0,void 0,function*(){return{data:yield Er(t),requestId:t.headers.get(Xn)||""}})}});var Ir=v((Pf,eo)=>{eo.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.3.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 He=v(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isBrowser=to;ze.getUserAgent=ro;function to(){return typeof window<"u"&&typeof window.document<"u"}var Ve=null;function ro(){if(Ve!==null)return Ve;let t=Ir();return Ve=`${t.name}/${t.version}`,Ve}});var Qe=v(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.credentialsFromEnv=void 0;R.resolveDefaultFetch=_r;R.createConfig=lo;R.getRestApiUrl=co;var kr=yt(),io=K(),no=He();function _r(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function oo(){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 so=()=>{if(oo())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};R.credentialsFromEnv=so;var ao={credentials:R.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:io.defaultResponseHandler};function lo(t){var e;let r=Object.assign(Object.assign(Object.assign({},ao),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:_r()});t.proxyUrl&&(r=Object.assign(Object.assign({},r),{requestMiddleware:(0,kr.withMiddleware)(r.requestMiddleware,(0,kr.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:i,suppressLocalCredentialsWarning:n}=r,o=typeof i=="function"?i():i;return(0,no.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),r}function co(){return"https://rest.alpha.fal.ai"}});var W=v(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.ensureEndpointIdFormat=Ar;F.parseEndpointId=po;F.isValidUrl=fo;F.throttle=ho;F.isReact=go;F.isPlainObject=mo;function Ar(t){if(t.split("/").length>1)return t;let[,r,i]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(t)||[];if(r&&i)return`${r}/${i}`;throw new Error(`Invalid app id: ${t}. Must be in the format <appOwner>/<appId>`)}var uo=["workflows","comfy"];function po(t){let r=Ar(t).split("/");return uo.includes(r[0])?{owner:r[1],alias:r[2],path:r.slice(3).join("/")||void 0,namespace:r[0]}:{owner:r[0],alias:r[1],path:r.slice(2).join("/")||void 0}}function fo(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function ho(t,e,r=!1){let i,n;return(...o)=>{!n&&r?(t(...o),n=Date.now()):(i&&clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=e&&(t(...o),n=Date.now())},e-(Date.now()-n)))}}var bt;function go(){if(bt===void 0){let t=new Error().stack;bt=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return bt}function mo(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}});var ie=v(V=>{"use strict";var yo=V&&V.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})},bo=V&&V.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(V,"__esModule",{value:!0});V.dispatchRequest=wo;V.buildUrl=xo;var Sr=He(),Cr=W(),vo=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function wo(t){return yo(this,void 0,void 0,function*(){var e,r,i;let{targetUrl:n,input:o,config:s,options:a={}}=t,{credentials:l,requestMiddleware:u,responseHandler:c,fetch:d}=s,h=(0,Sr.isBrowser)()?{}:{"User-Agent":(0,Sr.getUserAgent)()},p=typeof l=="function"?l():l,{method:g,url:b,headers:w}=yield u({method:((r=(e=t.method)!==null&&e!==void 0?e:a.method)!==null&&r!==void 0?r:"post").toUpperCase(),url:n,headers:t.headers}),m=p?{Authorization:`Key ${p}`}:{},x=Object.assign(Object.assign(Object.assign(Object.assign({},m),{Accept:"application/json","Content-Type":"application/json"}),h),w??{}),{responseHandler:S}=a,A=bo(a,["responseHandler"]),C=yield d(b,Object.assign(Object.assign(Object.assign(Object.assign({},A),{method:g,headers:Object.assign(Object.assign({},x),(i=A.headers)!==null&&i!==void 0?i:{})}),!vo&&{mode:"cors"}),{signal:a.signal,body:g.toLowerCase()!=="get"&&o?JSON.stringify(o):void 0}));return yield(S??c)(C)})}function xo(t,e={}){var r,i;let n=((r=e.method)!==null&&r!==void 0?r:"post").toLowerCase(),o=((i=e.path)!==null&&i!==void 0?i:"").replace(/^\//,"").replace(/\/{2,}/,"/"),s=e.input,a=Object.assign(Object.assign({},e.query||{}),n==="get"?s:{}),l=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:"";if((0,Cr.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${o}${l}`;let u=(0,Cr.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${l}`}});var Mr=v(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});function Eo(t){let e,r,i,n,o,s,a;return l(),{feed:u,reset:l};function l(){e=!0,r="",i=0,n=-1,o=void 0,s=void 0,a=""}function u(d){r=r?r+d:d,e&&Io(r)&&(r=r.slice(Tr.length)),e=!1;let h=r.length,p=0,g=!1;for(;p<h;){g&&(r[p]===`
1
+ var Rn=Object.create;var br=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Hn=Object.getPrototypeOf,Qn=Object.prototype.hasOwnProperty;var v=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Gn=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zn(e))!Qn.call(t,n)&&n!==r&&br(t,n,{get:()=>e[n],enumerable:!(i=Vn(e,n))||i.enumerable});return t};var vr=(t,e,r)=>(r=t!=null?Rn(Hn(t)):{},Gn(e||!t||!t.__esModule?br(r,"default",{value:t,enumerable:!0}):r,t));var yt=v(j=>{"use strict";var Wn=j&&j.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(j,"__esModule",{value:!0});j.TARGET_URL_HEADER=void 0;j.withMiddleware=Yn;j.withProxy=Zn;function Yn(...t){let e=r=>typeof r=="function";return r=>Wn(this,void 0,void 0,function*(){let i=Object.assign({},r);for(let n of t.filter(e))i=yield n(i);return i})}j.TARGET_URL_HEADER="x-fal-target-url";function Zn(t){let e=r=>Promise.resolve(r);return typeof window>"u"?e:r=>r.headers&&j.TARGET_URL_HEADER in r?e(r):Promise.resolve(Object.assign(Object.assign({},r),{url:t.targetUrl,headers:Object.assign(Object.assign({},r.headers||{}),{[j.TARGET_URL_HEADER]:r.url})}))}});var K=v(P=>{"use strict";var xr=P&&P.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.ValidationError=P.ApiError=void 0;P.defaultResponseHandler=kr;P.resultResponseHandler=Jn;var Xn="x-fal-request-id",re=class extends Error{constructor({message:e,status:r,body:i}){super(e),this.name="ApiError",this.status=r,this.body=i}};P.ApiError=re;var Re=class extends re{constructor(e){super(e),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(r=>r.loc[r.loc.length-1]===e)}};P.ValidationError=Re;function kr(t){return xr(this,void 0,void 0,function*(){var e;let{status:r,statusText:i}=t,n=(e=t.headers.get("Content-Type"))!==null&&e!==void 0?e:"";if(!t.ok){if(n.includes("application/json")){let o=yield t.json(),s=r===422?Re:re;throw new s({message:o.message||i,status:r,body:o})}throw new re({message:`HTTP ${r}: ${i}`,status:r})}return n.includes("application/json")?t.json():n.includes("text/html")?t.text():n.includes("application/octet-stream")?t.arrayBuffer():t.text()})}function Jn(t){return xr(this,void 0,void 0,function*(){return{data:yield kr(t),requestId:t.headers.get(Xn)||""}})}});var Ir=v((Pf,eo)=>{eo.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.3.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 He=v(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isBrowser=to;ze.getUserAgent=ro;function to(){return typeof window<"u"&&typeof window.document<"u"}var Ve=null;function ro(){if(Ve!==null)return Ve;let t=Ir();return Ve=`${t.name}/${t.version}`,Ve}});var Qe=v(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.credentialsFromEnv=void 0;F.resolveDefaultFetch=_r;F.createConfig=lo;F.getRestApiUrl=co;var Er=yt(),io=K(),no=He();function _r(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function oo(){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 so=()=>{if(oo())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};F.credentialsFromEnv=so;var ao={credentials:F.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:io.defaultResponseHandler};function lo(t){var e;let r=Object.assign(Object.assign(Object.assign({},ao),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:_r()});t.proxyUrl&&(r=Object.assign(Object.assign({},r),{requestMiddleware:(0,Er.withMiddleware)(r.requestMiddleware,(0,Er.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:i,suppressLocalCredentialsWarning:n}=r,o=typeof i=="function"?i():i;return(0,no.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),r}function co(){return"https://rest.alpha.fal.ai"}});var W=v(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.ensureEndpointIdFormat=Ar;R.parseEndpointId=po;R.isValidUrl=fo;R.throttle=ho;R.isReact=go;R.isPlainObject=mo;function Ar(t){if(t.split("/").length>1)return t;let[,r,i]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(t)||[];if(r&&i)return`${r}/${i}`;throw new Error(`Invalid app id: ${t}. Must be in the format <appOwner>/<appId>`)}var uo=["workflows","comfy"];function po(t){let r=Ar(t).split("/");return uo.includes(r[0])?{owner:r[1],alias:r[2],path:r.slice(3).join("/")||void 0,namespace:r[0]}:{owner:r[0],alias:r[1],path:r.slice(2).join("/")||void 0}}function fo(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function ho(t,e,r=!1){let i,n;return(...o)=>{!n&&r?(t(...o),n=Date.now()):(i&&clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=e&&(t(...o),n=Date.now())},e-(Date.now()-n)))}}var bt;function go(){if(bt===void 0){let t=new Error().stack;bt=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return bt}function mo(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}});var ie=v(V=>{"use strict";var yo=V&&V.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})},bo=V&&V.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(V,"__esModule",{value:!0});V.dispatchRequest=wo;V.buildUrl=xo;var Sr=He(),Cr=W(),vo=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function wo(t){return yo(this,void 0,void 0,function*(){var e,r,i;let{targetUrl:n,input:o,config:s,options:a={}}=t,{credentials:l,requestMiddleware:u,responseHandler:c,fetch:d}=s,h=(0,Sr.isBrowser)()?{}:{"User-Agent":(0,Sr.getUserAgent)()},p=typeof l=="function"?l():l,{method:g,url:b,headers:w}=yield u({method:((r=(e=t.method)!==null&&e!==void 0?e:a.method)!==null&&r!==void 0?r:"post").toUpperCase(),url:n,headers:t.headers}),m=p?{Authorization:`Key ${p}`}:{},x=Object.assign(Object.assign(Object.assign(Object.assign({},m),{Accept:"application/json","Content-Type":"application/json"}),h),w??{}),{responseHandler:S}=a,A=bo(a,["responseHandler"]),C=yield d(b,Object.assign(Object.assign(Object.assign(Object.assign({},A),{method:g,headers:Object.assign(Object.assign({},x),(i=A.headers)!==null&&i!==void 0?i:{})}),!vo&&{mode:"cors"}),{signal:a.signal,body:g.toLowerCase()!=="get"&&o?JSON.stringify(o):void 0}));return yield(S??c)(C)})}function xo(t,e={}){var r,i;let n=((r=e.method)!==null&&r!==void 0?r:"post").toLowerCase(),o=((i=e.path)!==null&&i!==void 0?i:"").replace(/^\//,"").replace(/\/{2,}/,"/"),s=e.input,a=Object.assign(Object.assign({},e.query||{}),n==="get"?s:{}),l=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:"";if((0,Cr.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${o}${l}`;let u=(0,Cr.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${l}`}});var Mr=v(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});function ko(t){let e,r,i,n,o,s,a;return l(),{feed:u,reset:l};function l(){e=!0,r="",i=0,n=-1,o=void 0,s=void 0,a=""}function u(d){r=r?r+d:d,e&&Io(r)&&(r=r.slice(Tr.length)),e=!1;let h=r.length,p=0,g=!1;for(;p<h;){g&&(r[p]===`
2
2
  `&&++p,g=!1);let b=-1,w=n,m;for(let x=i;b<0&&x<h;++x)m=r[x],m===":"&&w<0?w=x-p:m==="\r"?(g=!0,b=x-p):m===`
3
3
  `&&(b=x-p);if(b<0){i=h-p,n=w;break}else i=0,n=-1;c(r,p,w,b),p+=b+1}p===h?r="":p>0&&(r=r.slice(p))}function c(d,h,p,g){if(g===0){a.length>0&&(t({type:"event",id:o,event:s||void 0,data:a.slice(0,-1)}),a="",o=void 0),s=void 0;return}let b=p<0,w=d.slice(h,h+(b?g:p)),m=0;b?m=g:d[h+p+1]===" "?m=p+2:m=p+1;let x=h+m,S=g-m,A=d.slice(x,x+S).toString();if(w==="data")a+=A?"".concat(A,`
4
4
  `):`
5
- `;else if(w==="event")s=A;else if(w==="id"&&!A.includes("\0"))o=A;else if(w==="retry"){let C=parseInt(A,10);Number.isNaN(C)||t({type:"reconnect-interval",value:C})}}}var Tr=[239,187,191];function Io(t){return Tr.every((e,r)=>t.charCodeAt(r)===e)}vt.createParser=Eo});var wt=v(z=>{"use strict";var ko=z&&z.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(z,"__esModule",{value:!0});z.TOKEN_EXPIRATION_SECONDS=void 0;z.getTemporaryAuthToken=Co;var _o=Qe(),Ao=ie(),So=W();z.TOKEN_EXPIRATION_SECONDS=120;function Co(t,e){return ko(this,void 0,void 0,function*(){let r=(0,So.parseEndpointId)(t),i=yield(0,Ao.dispatchRequest)({method:"POST",targetUrl:`${(0,_o.getRestApiUrl)()}/tokens/`,config:e,input:{allowed_apps:[r.alias],token_expiration:z.TOKEN_EXPIRATION_SECONDS}});return typeof i!="string"&&i.detail?i.detail:i})}});var Et=v(O=>{"use strict";var ve=O&&O.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})},we=O&&O.__await||function(t){return this instanceof we?(this.v=t,this):new we(t)},To=O&&O.__asyncGenerator||function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,o=[];return n={},a("next"),a("throw"),a("return",s),n[Symbol.asyncIterator]=function(){return this},n;function s(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){i[p]&&(n[p]=function(b){return new Promise(function(w,m){o.push([p,b,w,m])>1||l(p,b)})},g&&(n[p]=g(n[p])))}function l(p,g){try{u(i[p](g))}catch(b){h(o[0][3],b)}}function u(p){p.value instanceof we?Promise.resolve(p.value.v).then(c,d):h(o[0][2],p)}function c(p){l("next",p)}function d(p){l("throw",p)}function h(p,g){p(g),o.shift(),o.length&&l(o[0][0],o[0][1])}};Object.defineProperty(O,"__esModule",{value:!0});O.FalStream=void 0;O.createStreamingClient=Po;var Mo=Mr(),Oo=wt(),Or=ie(),ne=K(),xt="text/event-stream",jo=15*1e3,Ge=class{constructor(e,r,i){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this.abortController=new AbortController,this.start=()=>ve(this,void 0,void 0,function*(){var o,s;let{endpointId:a,options:l}=this,{input:u,method:c="post",connectionMode:d="server"}=l;try{if(d==="client"){let h=yield(0,Oo.getTemporaryAuthToken)(a,this.config),{fetch:p}=this.config,g=new URL(this.url);g.searchParams.set("fal_jwt_token",h);let b=yield p(g.toString(),{method:c.toUpperCase(),headers:{accept:(o=l.accept)!==null&&o!==void 0?o:xt,"content-type":"application/json"},body:u&&c!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return yield this.handleResponse(b)}return yield(0,Or.dispatchRequest)({method:c.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(s=l.accept)!==null&&s!==void 0?s:xt},responseHandler:this.handleResponse,signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>ve(this,void 0,void 0,function*(){var s,a;if(!o.ok){try{yield(0,ne.defaultResponseHandler)(o)}catch(b){this.emit("error",b)}return}let l=o.body;if(!l){this.emit("error",new ne.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((s=o.headers.get("content-type"))!==null&&s!==void 0?s:"").startsWith(xt)){let b=l.getReader(),w=()=>{b.read().then(({done:m,value:x})=>{if(m){this.emit("done",this.currentData);return}this.currentData=x,this.emit("data",x),w()})};w();return}let c=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,Mo.createParser)(b=>{if(b.type==="event"){let w=b.data;try{let m=JSON.parse(w);this.buffer.push(m),this.currentData=m,this.emit("data",m),this.emit("message",m)}catch(m){this.emit("error",m)}}}),p=(a=this.options.timeout)!==null&&a!==void 0?a:jo,g=()=>ve(this,void 0,void 0,function*(){let{value:b,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(c.decode(b)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new ne.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):g().catch(this.handleError)});g().catch(this.handleError)}),this.handleError=o=>{var s;if(o.name==="AbortError"||this.signal.aborted)return;let a=o instanceof ne.ApiError?o:new ne.ApiError({message:(s=o.message)!==null&&s!==void 0?s:"An unknown error occurred",status:500});this.emit("error",a)},this.on=(o,s)=>{var a;this.listeners.has(o)||this.listeners.set(o,[]),(a=this.listeners.get(o))===null||a===void 0||a.push(s)},this.emit=(o,s)=>{let a=this.listeners.get(o)||[];for(let l of a)l(s)},this.done=()=>ve(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=e,this.config=r,this.url=(n=i.url)!==null&&n!==void 0?n:(0,Or.buildUrl)(e,{path:"/stream",query:i.queryParams}),this.options=i,this.donePromise=new Promise((o,s)=>{this.streamClosed&&s(new ne.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var a;o((a=this.currentData)!==null&&a!==void 0?a:{})}),this.on("done",a=>{this.streamClosed=!0,o(a)}),this.on("error",a=>{this.streamClosed=!0,s(a)})}),i.signal&&i.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return To(this,arguments,function*(){let r=!0,i=()=>r=!1;for(this.on("error",i),this.on("done",i);r||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield we(n)),yield we(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}};O.FalStream=Ge;function Po({config:t,storage:e}){return{stream(r,i){return ve(this,void 0,void 0,function*(){let n=i.input?yield e.transformInput(i.input):void 0;return new Ge(r,t,Object.assign(Object.assign({},i),{input:n}))})}}}});var Pr=v(H=>{"use strict";var Y=H&&H.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})},Do=H&&H.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(H,"__esModule",{value:!0});H.createQueueClient=void 0;var U=ie(),Uo=K(),$o=Et(),Ke=W(),jr=500,Lo=({config:t,storage:e})=>{let r={submit(i,n){return Y(this,void 0,void 0,function*(){let{webhookUrl:o,priority:s}=n,a=Do(n,["webhookUrl","priority"]),l=n.input?yield e.transformInput(n.input):void 0;return(0,U.dispatchRequest)({method:n.method,targetUrl:(0,U.buildUrl)(i,Object.assign(Object.assign({},a),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:{"x-fal-queue-priority":s??"normal"},input:l,config:t,options:{signal:n.abortSignal}})})},status(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,abortSignal:l}){let u=(0,Ke.parseEndpointId)(o),c=u.namespace?`${u.namespace}/`:"";return(0,U.dispatchRequest)({method:"get",targetUrl:(0,U.buildUrl)(`${c}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:a?"1":"0"},path:`/requests/${s}/status`}),config:t,options:{signal:l}})})},streamStatus(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,connectionMode:l}){let u=(0,Ke.parseEndpointId)(o),c=u.namespace?`${u.namespace}/`:"",d={logs:a?"1":"0"},h=(0,U.buildUrl)(`${c}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${s}/status/stream`,query:d});return new $o.FalStream(o,t,{url:h,method:"get",connectionMode:l,queryParams:d})})},subscribeToStatus(i,n){return Y(this,void 0,void 0,function*(){let o=n.requestId,s=n.timeout,a,l=()=>{};if(n.mode==="streaming"){let u=yield r.streamStatus(i,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),c=[];s&&(a=setTimeout(()=>{throw u.abort(),r.cancel(i,{requestId:o}).catch(l),new Error(`Client timed out waiting for the request to complete after ${s}ms`)},s)),u.on("data",h=>{n.onQueueUpdate&&("logs"in h&&Array.isArray(h.logs)&&h.logs.length>0&&c.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:c}):h))});let d=yield u.done();return a&&clearTimeout(a),d}return new Promise((u,c)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:jr,g=()=>{a&&clearTimeout(a),h&&clearTimeout(h)};s&&(a=setTimeout(()=>{g(),r.cancel(i,{requestId:o}).catch(l),c(new Error(`Client timed out waiting for the request to complete after ${s}ms`))},s));let b=()=>Y(this,void 0,void 0,function*(){var w;try{let m=yield r.status(i,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(m),m.status==="COMPLETED"){g(),u(m);return}h=setTimeout(b,p)}catch(m){g(),c(m)}});b().catch(c)})})},result(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let l=(0,Ke.parseEndpointId)(o),u=l.namespace?`${l.namespace}/`:"";return(0,U.dispatchRequest)({method:"get",targetUrl:(0,U.buildUrl)(`${u}${l.owner}/${l.alias}`,{subdomain:"queue",path:`/requests/${s}`}),config:Object.assign(Object.assign({},t),{responseHandler:Uo.resultResponseHandler}),options:{signal:a}})})},cancel(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let l=(0,Ke.parseEndpointId)(o),u=l.namespace?`${l.namespace}/`:"";yield(0,U.dispatchRequest)({method:"put",targetUrl:(0,U.buildUrl)(`${u}${l.owner}/${l.alias}`,{subdomain:"queue",path:`/requests/${s}/cancel`}),config:t,options:{signal:a}})})}};return r};H.createQueueClient=Lo});var We=v($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.utf8Count=No;$.utf8EncodeJs=Dr;$.utf8EncodeTE=Ur;$.utf8Encode=Ro;$.utf8DecodeJs=$r;$.utf8DecodeTD=Lr;$.utf8Decode=Ho;function No(t){let e=t.length,r=0,i=0;for(;i<e;){let n=t.charCodeAt(i++);if(n&4294967168)if(!(n&4294965248))r+=2;else{if(n>=55296&&n<=56319&&i<e){let o=t.charCodeAt(i);(o&64512)===56320&&(++i,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?r+=4:r+=3}else{r++;continue}}return r}function Dr(t,e,r){let i=t.length,n=r,o=0;for(;o<i;){let s=t.charCodeAt(o++);if(s&4294967168)if(!(s&4294965248))e[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<i){let a=t.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}s&4294901760?(e[n++]=s>>18&7|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128):(e[n++]=s>>12&15|224,e[n++]=s>>6&63|128)}else{e[n++]=s;continue}e[n++]=s&63|128}}var qo=new TextEncoder,Bo=50;function Ur(t,e,r){qo.encodeInto(t,e.subarray(r))}function Ro(t,e,r){t.length>Bo?Ur(t,e,r):Dr(t,e,r)}var Fo=4096;function $r(t,e,r){let i=e,n=i+r,o=[],s="";for(;i<n;){let a=t[i++];if(!(a&128))o.push(a);else if((a&224)===192){let l=t[i++]&63;o.push((a&31)<<6|l)}else if((a&240)===224){let l=t[i++]&63,u=t[i++]&63;o.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=t[i++]&63,u=t[i++]&63,c=t[i++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(a);o.length>=Fo&&(s+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(s+=String.fromCharCode(...o)),s}var Vo=new TextDecoder,zo=200;function Lr(t,e,r){let i=t.subarray(e,e+r);return Vo.decode(i)}function Ho(t,e,r){return r>zo?Lr(t,e,r):$r(t,e,r)}});var kt=v(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.ExtData=void 0;var It=class{constructor(e,r){this.type=e,this.data=r}};Ye.ExtData=It});var Xe=v(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.DecodeError=void 0;var _t=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};Ze.DecodeError=_t});var Je=v(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.UINT32_MAX=void 0;Q.setUint64=Qo;Q.setInt64=Go;Q.getInt64=Ko;Q.getUint64=Wo;Q.UINT32_MAX=4294967295;function Qo(t,e,r){let i=r/4294967296,n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Go(t,e,r){let i=Math.floor(r/4294967296),n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Ko(t,e){let r=t.getInt32(e),i=t.getUint32(e+4);return r*4294967296+i}function Wo(t,e){let r=t.getUint32(e),i=t.getUint32(e+4);return r*4294967296+i}});var At=v(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.timestampExtension=T.EXT_TIMESTAMP=void 0;T.encodeTimeSpecToTimestamp=qr;T.encodeDateToTimeSpec=Br;T.encodeTimestampExtension=Rr;T.decodeTimestampToTimeSpec=Fr;T.decodeTimestampExtension=Vr;var Yo=Xe(),Nr=Je();T.EXT_TIMESTAMP=-1;var Zo=4294967296-1,Xo=17179869184-1;function qr({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Xo)if(e===0&&t<=Zo){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,i=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,e<<2|r&3),o.setUint32(4,i),n}else{let r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,e),(0,Nr.setInt64)(i,4,t),r}}function Br(t){let e=t.getTime(),r=Math.floor(e/1e3),i=(e-r*1e3)*1e6,n=Math.floor(i/1e9);return{sec:r+n,nsec:i-n*1e9}}function Rr(t){if(t instanceof Date){let e=Br(t);return qr(e)}else return null}function Fr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),i=e.getUint32(4),n=(r&3)*4294967296+i,o=r>>>2;return{sec:n,nsec:o}}case 12:{let r=(0,Nr.getInt64)(e,4),i=e.getUint32(0);return{sec:r,nsec:i}}default:throw new Yo.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Vr(t){let e=Fr(t);return new Date(e.sec*1e3+e.nsec/1e6)}T.timestampExtension={type:T.EXT_TIMESTAMP,encode:Rr,decode:Vr}});var rt=v(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.ExtensionCodec=void 0;var et=kt(),Jo=At(),xe=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Jo.timestampExtension)}register({type:e,encode:r,decode:i}){if(e>=0)this.encoders[e]=r,this.decoders[e]=i;else{let n=-1-e;this.builtInEncoders[n]=r,this.builtInDecoders[n]=i}}tryToEncode(e,r){for(let i=0;i<this.builtInEncoders.length;i++){let n=this.builtInEncoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=-1-i;return new et.ExtData(s,o)}}}for(let i=0;i<this.encoders.length;i++){let n=this.encoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=i;return new et.ExtData(s,o)}}}return e instanceof et.ExtData?e:null}decode(e,r,i){let n=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return n?n(e,r,i):new et.ExtData(r,e)}};tt.ExtensionCodec=xe;xe.defaultCodec=new xe});var Ct=v(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.ensureUint8Array=ts;function es(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function ts(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):es(t)?new Uint8Array(t):Uint8Array.from(t)}});var Mt=v(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.Encoder=D.DEFAULT_INITIAL_BUFFER_SIZE=D.DEFAULT_MAX_DEPTH=void 0;var zr=We(),rs=rt(),Hr=Je(),is=Ct();D.DEFAULT_MAX_DEPTH=100;D.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Tt=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??rs.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??D.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??D.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),i=new Uint8Array(r),n=new DataView(r);i.set(this.bytes),this.view=n,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let i=(0,zr.utf8Count)(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),(0,zr.utf8Encode)(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,r){let i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let i=(0,is.ensureUint8Array)(e);this.writeU8a(i)}encodeArray(e,r){let i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(let n of e)this.doEncode(n,r+1)}countWithoutUndefined(e,r){let i=0;for(let n of r)e[n]!==void 0&&i++;return i}encodeMap(e,r){let i=Object.keys(e);this.sortKeys&&i.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.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 i){let s=e[o];this.ignoreUndefined&&s===void 0||(this.encodeString(o),this.doEncode(s,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let i=e.data(this.pos+6),n=i.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(i);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Hr.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Hr.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};D.Encoder=Tt});var Qr=v(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.encode=os;var ns=Mt();function os(t,e){return new ns.Encoder(e).encodeSharedRef(t)}});var Gr=v(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.prettyByte=ss;function ss(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var Kr=v(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.CachedKeyDecoder=void 0;var as=We(),ls=16,cs=16,Pt=class{constructor(e=ls,r=cs){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,i){let n=this.caches[i-1];e:for(let o of n){let s=o.bytes;for(let a=0;a<i;a++)if(s[a]!==e[r+a])continue e;return o.str}return null}store(e,r){let i=this.caches[e.length-1],n={bytes:e,str:r};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=n:i.push(n)}decode(e,r,i){let n=this.find(e,r,i);if(n!=null)return this.hit++,n;this.miss++;let o=(0,as.utf8DecodeJs)(e,r,i),s=Uint8Array.prototype.slice.call(e,r,r+i);return this.store(s,o),o}};it.CachedKeyDecoder=Pt});var ot=v(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.Decoder=void 0;var Dt=Gr(),us=rt(),Z=Je(),ds=We(),Wr=Ct(),ps=Kr(),L=Xe(),Ut="array",Ie="map_key",Zr="map_value",fs=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new L.DecodeError("The type of key must be string or number but "+typeof t)},$t=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=Ut,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=Ie,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Ut){let i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===Ie||e.type===Zr){let i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Ee=-1,Nt=new DataView(new ArrayBuffer(0)),hs=new Uint8Array(Nt.buffer);try{Nt.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Yr=new RangeError("Insufficient data"),gs=new ps.CachedKeyDecoder,Lt=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=Nt,this.bytes=hs,this.headByte=Ee,this.stack=new $t,this.entered=!1,this.extensionCodec=e?.extensionCodec??us.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??Z.UINT32_MAX,this.maxBinLength=e?.maxBinLength??Z.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??Z.UINT32_MAX,this.maxMapLength=e?.maxMapLength??Z.UINT32_MAX,this.maxExtLength=e?.maxExtLength??Z.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:gs,this.mapKeyConverter=e?.mapKeyConverter??fs}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ee,this.stack.reset()}setBuffer(e){let r=(0,Wr.ensureUint8Array)(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Ee&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),i=(0,Wr.ensureUint8Array)(e),n=new Uint8Array(r.length+i.length);n.set(r),n.set(i,r.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:i}=this;return new RangeError(`Extra ${r.byteLength-i} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,i;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),r=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}let{headByte:n,pos:o,totalPos:s}=this;throw new RangeError(`Insufficient data in parsing ${(0,Dt.prettyByte)(n)} at ${s} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let i=r,n=-1;for await(let o of e){if(r&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),i&&(n=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(s){if(!(s instanceof RangeError))throw s}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{let n=e-160;r=this.decodeString(n,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let n=this.lookU8();r=this.decodeString(n,1)}else if(e===218){let n=this.lookU16();r=this.decodeString(n,2)}else if(e===219){let n=this.lookU32();r=this.decodeString(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===196){let n=this.lookU8();r=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();r=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();r=this.decodeBinary(n,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();r=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();r=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();r=this.decodeExtension(n,4)}else throw new L.DecodeError(`Unrecognized type byte: ${(0,Dt.prettyByte)(e)}`);this.complete();let i=this.stack;for(;i.length>0;){let n=i.top();if(n.type===Ut)if(n.array[n.position]=r,n.position++,n.position===n.size)r=n.array,i.release(n);else continue e;else if(n.type===Ie){if(r==="__proto__")throw new L.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(r),n.type=Zr;continue e}else if(n.map[n.key]=r,n.readCount++,n.readCount===n.size)r=n.map,i.release(n);else{n.key=null,n.type=Ie;continue e}}return r}}readHeadByte(){return this.headByte===Ee&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ee}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new L.DecodeError(`Unrecognized array type byte: ${(0,Dt.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new L.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new L.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new L.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Yr;let i=this.pos+r,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,i,e):n=(0,ds.utf8Decode)(this.bytes,i,e),this.pos+=r+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ie:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new L.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Yr;let i=this.pos+r,n=this.bytes.subarray(i,i+e);return this.pos+=r+e,n}decodeExtension(e,r){if(e>this.maxExtLength)throw new L.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let i=this.view.getInt8(this.pos+r),n=this.decodeBinary(e,r+1);return this.extensionCodec.decode(n,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,Z.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,Z.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};nt.Decoder=Lt});var Jr=v(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.decode=ms;st.decodeMulti=ys;var Xr=ot();function ms(t,e){return new Xr.Decoder(e).decode(t)}function ys(t,e){return new Xr.Decoder(e).decodeMulti(t)}});var ri=v(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.isAsyncIterable=ei;ke.asyncIterableFromStream=ti;ke.ensureAsyncIterable=bs;function ei(t){return t[Symbol.asyncIterator]!=null}async function*ti(t){let e=t.getReader();try{for(;;){let{done:r,value:i}=await e.read();if(r)return;yield i}}finally{e.releaseLock()}}function bs(t){return ei(t)?t:ti(t)}});var ii=v(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.decodeAsync=vs;_e.decodeArrayStream=ws;_e.decodeMultiStream=xs;var qt=ot(),Bt=ri();async function vs(t,e){let r=(0,Bt.ensureAsyncIterable)(t);return new qt.Decoder(e).decodeAsync(r)}function ws(t,e){let r=(0,Bt.ensureAsyncIterable)(t);return new qt.Decoder(e).decodeArrayStream(r)}function xs(t,e){let r=(0,Bt.ensureAsyncIterable)(t);return new qt.Decoder(e).decodeStream(r)}});var oi=v(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.decodeTimestampExtension=y.encodeTimestampExtension=y.decodeTimestampToTimeSpec=y.encodeTimeSpecToTimestamp=y.encodeDateToTimeSpec=y.EXT_TIMESTAMP=y.ExtData=y.ExtensionCodec=y.Encoder=y.DecodeError=y.Decoder=y.decodeMultiStream=y.decodeArrayStream=y.decodeAsync=y.decodeMulti=y.decode=y.encode=void 0;var Es=Qr();Object.defineProperty(y,"encode",{enumerable:!0,get:function(){return Es.encode}});var ni=Jr();Object.defineProperty(y,"decode",{enumerable:!0,get:function(){return ni.decode}});Object.defineProperty(y,"decodeMulti",{enumerable:!0,get:function(){return ni.decodeMulti}});var Rt=ii();Object.defineProperty(y,"decodeAsync",{enumerable:!0,get:function(){return Rt.decodeAsync}});Object.defineProperty(y,"decodeArrayStream",{enumerable:!0,get:function(){return Rt.decodeArrayStream}});Object.defineProperty(y,"decodeMultiStream",{enumerable:!0,get:function(){return Rt.decodeMultiStream}});var Is=ot();Object.defineProperty(y,"Decoder",{enumerable:!0,get:function(){return Is.Decoder}});var ks=Xe();Object.defineProperty(y,"DecodeError",{enumerable:!0,get:function(){return ks.DecodeError}});var _s=Mt();Object.defineProperty(y,"Encoder",{enumerable:!0,get:function(){return _s.Encoder}});var As=rt();Object.defineProperty(y,"ExtensionCodec",{enumerable:!0,get:function(){return As.ExtensionCodec}});var Ss=kt();Object.defineProperty(y,"ExtData",{enumerable:!0,get:function(){return Ss.ExtData}});var oe=At();Object.defineProperty(y,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return oe.EXT_TIMESTAMP}});Object.defineProperty(y,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return oe.encodeDateToTimeSpec}});Object.defineProperty(y,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return oe.encodeTimeSpecToTimestamp}});Object.defineProperty(y,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return oe.decodeTimestampToTimeSpec}});Object.defineProperty(y,"encodeTimestampExtension",{enumerable:!0,get:function(){return oe.encodeTimestampExtension}});Object.defineProperty(y,"decodeTimestampExtension",{enumerable:!0,get:function(){return oe.decodeTimestampExtension}})});var wi=v(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});function _(t){return{enumerable:!0,value:t}}function si(t){return{enumerable:!0,writable:!0,value:t}}var X={},Cs=()=>!0,ai=()=>({}),ci=t=>t,Ts=(t,e,r,i)=>t.apply(r,i)&&e.apply(r,i),Ms=(t,e,r,[i,n])=>e.call(r,t.call(r,i,n),n),G=(t,e)=>Object.freeze(Object.create(t,e));function li(t,e,r){return t.reduce((i,n)=>function(...o){return r(i,n,this,o)},e)}function ui(t){return G(this,{fn:_(t)})}var di={},pi=ui.bind(di),Os=t=>pi((e,r)=>!!~t(e,r)&&e),fi={},js=ui.bind(fi);function at(t,e){return e.filter(r=>t.isPrototypeOf(r))}function hi(t,e,...r){let i=li(at(fi,r).map(o=>o.fn),Cs,Ts),n=li(at(di,r).map(o=>o.fn),ci,Ms);return G(this,{from:_(t),to:_(e),guards:_(i),reducers:_(n)})}var gi={},mi={},Ps=hi.bind(gi),Ds=hi.bind(mi,null);function Us(t,e,r){return Vt(e,t,r,this.immediates)||t}function yi(t){let e=new Map;for(let r of t)e.has(r.from)||e.set(r.from,[]),e.get(r.from).push(r);return e}var $s={enter:ci};function Ls(...t){let e=at(gi,t),r=at(mi,t),i={final:_(t.length===0),transitions:_(yi(e))};return r.length&&(i.immediates=_(r),i.enter=_(Us)),G($s,i)}var Ns={enter(t,e,r){let i=this.fn.call(e,e.context,r);return Ft.isPrototypeOf(i)?G(bi,{machine:_(i),transitions:_(this.transitions)}).enter(t,e,r):(i.then(n=>e.send({type:"done",data:n})).catch(n=>e.send({type:"error",error:n})),t)}},bi={enter(t,e,r){if(e.child=vi(this.machine,i=>{e.onChange(i),e.child==i&&i.machine.state.value.final&&(delete e.child,e.send({type:"done",data:i.context}))},e.context,r),e.child.machine.state.value.final){let i=e.child.context;return delete e.child,Vt(e,t,{type:"done",data:i},this.transitions.get("done"))}return t}};function qs(t,...e){let r=_(yi(e));return Ft.isPrototypeOf(t)?G(bi,{machine:_(t),transitions:r}):G(Ns,{fn:_(t),transitions:r})}var Ft={get state(){return{name:this.current,value:this.states[this.current]}}};function Bs(t,e,r=ai){return typeof t!="string"&&(r=e||ai,e=t,t=Object.keys(e)[0]),X._create&&X._create(t,e),G(Ft,{context:_(r),current:_(t),states:_(e)})}function Vt(t,e,r,i){let{context:n}=t;for(let{to:o,guards:s,reducers:a}of i)if(s(n,r)){t.context=a.call(t,n,r);let l=e.original||e,u=G(l,{current:_(o),original:{value:l}});return X._onEnter&&X._onEnter(e,o,t.context,n,r),u.state.value.enter(u,t,r)}}function Rs(t,e){let r=e.type||e,{machine:i}=t,{value:n,name:o}=i.state;return n.transitions.has(r)?Vt(t,i,e,n.transitions.get(r))||i:(X._send&&X._send(r,o),i)}var Fs={send(t){this.machine=Rs(this,t),this.onChange(this)}};function vi(t,e,r,i){let n=Object.create(Fs,{machine:si(t),context:si(t.context(r,i)),onChange:_(e)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,i),n}M.action=Os;M.createMachine=Bs;M.d=X;M.guard=js;M.immediate=Ds;M.interpret=vi;M.invoke=qs;M.reduce=pi;M.state=Ls;M.transition=Ps});var _i=v(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.createRealtimeClient=ia;var ct=oi(),f=wi(),xi=wt(),zt=K(),Ei=He(),Gt=W(),Vs=()=>({enqueuedMessage:void 0});function zs(t){return t.token!==void 0}function Hs(t){return!zs(t)}function lt(t,e){return Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function N(t){return t.websocket&&t.websocket.readyState===WebSocket.OPEN&&t.websocket.close(),Object.assign(Object.assign({},t),{websocket:void 0})}function Qs(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,ct.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function Ht(t){return Object.assign(Object.assign({},t),{token:void 0})}function Gs(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Ks(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var Ws=(0,f.createMachine)("idle",{idle:(0,f.state)((0,f.transition)("send","connecting",(0,f.reduce)(lt)),(0,f.transition)("expireToken","idle",(0,f.reduce)(Ht)),(0,f.transition)("close","idle",(0,f.reduce)(N))),connecting:(0,f.state)((0,f.transition)("connecting","connecting"),(0,f.transition)("connected","active",(0,f.reduce)(Ks)),(0,f.transition)("connectionClosed","idle",(0,f.reduce)(N)),(0,f.transition)("send","connecting",(0,f.reduce)(lt)),(0,f.transition)("close","idle",(0,f.reduce)(N)),(0,f.immediate)("authRequired",(0,f.guard)(Hs))),authRequired:(0,f.state)((0,f.transition)("initiateAuth","authInProgress"),(0,f.transition)("send","authRequired",(0,f.reduce)(lt)),(0,f.transition)("close","idle",(0,f.reduce)(N))),authInProgress:(0,f.state)((0,f.transition)("authenticated","connecting",(0,f.reduce)(Gs)),(0,f.transition)("unauthorized","idle",(0,f.reduce)(Ht),(0,f.reduce)(N)),(0,f.transition)("send","authInProgress",(0,f.reduce)(lt)),(0,f.transition)("close","idle",(0,f.reduce)(N))),active:(0,f.state)((0,f.transition)("send","active",(0,f.reduce)(Qs)),(0,f.transition)("unauthorized","idle",(0,f.reduce)(Ht)),(0,f.transition)("connectionClosed","idle",(0,f.reduce)(N)),(0,f.transition)("close","idle",(0,f.reduce)(N))),failed:(0,f.state)((0,f.transition)("send","failed"),(0,f.transition)("close","idle",(0,f.reduce)(N)))},Vs);function Ys(t,{token:e,maxBuffering:r}){if(r!==void 0&&(r<1||r>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let i=new URLSearchParams({fal_jwt_token:e});return r!==void 0&&i.set("max_buffering",r.toFixed(0)),`wss://fal.run/${(0,Gt.ensureEndpointIdFormat)(t)}/realtime?${i.toString()}`}var Zs=128;function Xs(t){return t.status==="error"&&t.error==="Unauthorized"}var Js={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Qt=new Map,Ii=new Map;function ea(t,e,r){if(!Qt.has(t)){let i=(0,f.interpret)(Ws,r);Qt.set(t,Object.assign(Object.assign({},i),{throttledSend:e>0?(0,Gt.throttle)(i.send,e,!0):i.send}))}return Qt.get(t)}var Ae=()=>{},ta={send:Ae,close:Ae};function ra(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!ki(t)}function ki(t){return t.type==="x-fal-error"}function ia({config:t}){return{connect(e,r){let{clientOnly:i=(0,Gt.isReact)()&&!(0,Ei.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:s=Zs}=r;if(i&&!(0,Ei.isBrowser)())return ta;let a;Ii.set(n,{onError:r.onError,onResult:r.onResult});let l=()=>Ii.get(n),u=ea(n,s,({context:h,machine:p,send:g})=>{let{enqueuedMessage:b,token:w}=h;if(p.current==="active"&&b&&g({type:"send",message:b}),p.current==="authRequired"&&w===void 0&&a!==p.current&&(g({type:"initiateAuth"}),(0,xi.getTemporaryAuthToken)(e,t).then(m=>{g({type:"authenticated",token:m});let x=Math.round(xi.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{g({type:"expireToken"})},x)}).catch(m=>{g({type:"unauthorized",error:m})})),p.current==="connecting"&&a!==p.current&&w!==void 0){let m=new WebSocket(Ys(e,{token:w,maxBuffering:o}));m.onopen=()=>{g({type:"connected",websocket:m})},m.onclose=x=>{if(x.code!==Js.NORMAL_CLOSURE){let{onError:S=Ae}=l();S(new zt.ApiError({message:`Error closing the connection: ${x.reason}`,status:x.code}))}g({type:"connectionClosed",code:x.code})},m.onerror=x=>{let{onError:S=Ae}=l();S(new zt.ApiError({message:"Unknown error",status:500}))},m.onmessage=x=>{let{onResult:S}=l();if(x.data instanceof ArrayBuffer){let C=(0,ct.decode)(new Uint8Array(x.data));S(C);return}if(x.data instanceof Uint8Array){let C=(0,ct.decode)(x.data);S(C);return}if(x.data instanceof Blob){x.data.arrayBuffer().then(C=>{let yr=(0,ct.decode)(new Uint8Array(C));S(yr)});return}let A=JSON.parse(x.data);if(Xs(A)){g({type:"unauthorized",error:new Error("Unauthorized")});return}if(ra(A)){S(A);return}if(ki(A)){if(A.error==="TIMEOUT")return;let{onError:C=Ae}=l();C(new zt.ApiError({message:`${A.error}: ${A.reason}`,status:400,body:A}));return}}}a=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var Mi=v(Se=>{"use strict";var J=Se&&Se.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Se,"__esModule",{value:!0});Se.createStorageClient=la;var Ai=Qe(),Si=ie(),na=W();function Ci(t){var e;let[r,i]=t.split("/");return(e=i.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function oa(t,e,r){return J(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${Ci(r)}`;return yield(0,Si.dispatchRequest)({method:"POST",targetUrl:`${(0,Ai.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function sa(t,e,r){return J(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${Ci(r)}`;return yield(0,Si.dispatchRequest)({method:"POST",targetUrl:`${(0,Ai.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function Ti(t,e,r){return J(this,arguments,void 0,function*(i,n,o,s=3){if(s===0)throw new Error("Part upload failed, retries exhausted");let{fetch:a,responseHandler:l}=o;try{let u=yield a(i,{method:"PUT",body:n});return yield l(u)}catch{return yield Ti(i,n,o,s-1)}})}function aa(t,e){return J(this,void 0,void 0,function*(){let{fetch:r,responseHandler:i}=e,n=t.type||"application/octet-stream",{upload_url:o,file_url:s}=yield sa(t,e,n),a=10*1024*1024,l=Math.ceil(t.size/a),u=new URL(o),c=[];for(let p=0;p<l;p++){let g=p*a,b=Math.min(g+a,t.size),w=t.slice(g,b),m=p+1,x=`${u.origin}${u.pathname}/${m}${u.search}`;c.push(yield Ti(x,w,e))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield r(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:c.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield i(h),s})}function la({config:t}){let e={upload:r=>J(this,void 0,void 0,function*(){if(r.size>94371840)return yield aa(r,t);let i=r.type||"application/octet-stream",{fetch:n,responseHandler:o}=t,{upload_url:s,file_url:a}=yield oa(r,t,i),l=yield n(s,{method:"PUT",body:r,headers:{"Content-Type":r.type||"application/octet-stream"}});return yield o(l),a}),transformInput:r=>J(this,void 0,void 0,function*(){if(Array.isArray(r))return Promise.all(r.map(i=>e.transformInput(i)));if(r instanceof Blob)return yield e.upload(r);if((0,na.isPlainObject)(r)){let n=Object.entries(r).map(s=>J(this,[s],void 0,function*([a,l]){return[a,yield e.transformInput(l)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return r})};return e}});var Wt=v(Ce=>{"use strict";var Oi=Ce&&Ce.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Ce,"__esModule",{value:!0});Ce.createFalClient=ga;var ca=Qe(),ua=Pr(),da=_i(),ji=ie(),pa=K(),fa=Mi(),ha=Et();function ga(t={}){let e=(0,ca.createConfig)(t),r=(0,fa.createStorageClient)({config:e}),i=(0,ua.createQueueClient)({config:e,storage:r}),n=(0,ha.createStreamingClient)({config:e,storage:r}),o=(0,da.createRealtimeClient)({config:e});return{queue:i,realtime:o,storage:r,streaming:n,stream:n.stream,run(s){return Oi(this,arguments,void 0,function*(a,l={}){let u=l.input?yield r.transformInput(l.input):void 0;return(0,ji.dispatchRequest)({method:l.method,targetUrl:(0,ji.buildUrl)(a,l),input:u,config:Object.assign(Object.assign({},e),{responseHandler:pa.resultResponseHandler}),options:{signal:l.abortSignal}})})},subscribe:(s,a)=>Oi(this,void 0,void 0,function*(){let{request_id:l}=yield i.submit(s,a);return a.onEnqueue&&a.onEnqueue(l),yield i.subscribeToStatus(s,Object.assign({requestId:l},a)),i.result(s,{requestId:l})})}}});var Di=v(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.isQueueStatus=Pi;ut.isCompletedQueueStatus=ma;function Pi(t){return t&&t.status&&t.response_url}function ma(t){return Pi(t)&&t.status==="COMPLETED"}});var Yt=v(k=>{"use strict";var ya=k&&k.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),ba=k&&k.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ya(e,t,r)};Object.defineProperty(k,"__esModule",{value:!0});k.fal=k.parseEndpointId=k.ValidationError=k.ApiError=k.withProxy=k.withMiddleware=k.createFalClient=void 0;var Ui=Wt(),va=Wt();Object.defineProperty(k,"createFalClient",{enumerable:!0,get:function(){return va.createFalClient}});var $i=yt();Object.defineProperty(k,"withMiddleware",{enumerable:!0,get:function(){return $i.withMiddleware}});Object.defineProperty(k,"withProxy",{enumerable:!0,get:function(){return $i.withProxy}});var Li=K();Object.defineProperty(k,"ApiError",{enumerable:!0,get:function(){return Li.ApiError}});Object.defineProperty(k,"ValidationError",{enumerable:!0,get:function(){return Li.ValidationError}});ba(Di(),k);var wa=W();Object.defineProperty(k,"parseEndpointId",{enumerable:!0,get:function(){return wa.parseEndpointId}});k.fal=function(){let e=(0,Ui.createFalClient)();return{config(r){e=(0,Ui.createFalClient)(r)},get queue(){return e.queue},get realtime(){return e.realtime},get storage(){return e.storage},get streaming(){return e.streaming},run(r,i){return e.run(r,i)},subscribe(r,i){return e.subscribe(r,i)},stream(r,i){return e.stream(r,i)}}}()});var wr={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},MinimaxVideo01LiveInput:{title:"TextToVideoLiveRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0}},"x-fal-order-properties":["prompt"],required:["prompt"]},MinimaxVideo01LiveOutput:{title:"T2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/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/minimax/video-01-live/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/minimax/video-01-live":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/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/MinimaxVideo01LiveOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var Zt=vr(Yt());async function Ni(t,e){if(t!=null){if(t.startsWith("blob:")){let i=await(await fetch(t)).blob(),n=new File([i],"image.png",{type:"image/png"});return Zt.fal.storage.upload(n)}if(e!=null&&t.startsWith("buffer:")){let r=await e.engine.editor.getMimeType(t),i=e.engine.editor.getBufferLength(t),n=e.engine.editor.getBufferData(t,0,i),o=new File([n],"image.png",{type:r});return Zt.fal.storage.upload(o)}return t}}function xa(t,e){let{cesdk:r}=e,i=e.propertyKey??"image_url";return Ea(t,r),{[i]:(n,o)=>{let{builder:s,experimental:{global:a},payload:l}=n,u=l?.url??e.defaultUrl,c=a(`${t}.${o.id}`,u);return s.MediaPreview(o.id,{preview:{type:"image",uri:c.value},action:{label:"Select Image",onClick:()=>{if(r==null)return;let d=tr(t);r.ui.openPanel(d,{payload:{onSelect:h=>{h.meta?.uri!=null&&c.setValue(h.meta?.uri)}}})}}}),()=>({id:o.id,type:"string",value:c.value})}}}function Ea(t,e){e?.ui.registerPanel(tr(t),({builder:r,payload:i})=>{r.Library(`${t}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let s=await e.engine.editor.getMimeType(o);s==="image/svg+xml"?e.ui.showNotification({type:"warning",message:"SVG images are not supported. Please choose a different image."}):s.startsWith("image/")?(i?.onSelect(n),e?.ui.closePanel(tr(t))):e.ui.showNotification({type:"warning",message:`Only images are supported. Found '${s}'. Please choose a different image.`})}})})}function tr(t){return`ly.img.ai/${t}.imageSelection`}var Ia=xa;function ka(){return async(t,e,r)=>{console.group("[GENERATION]"),console.log("Generating with input:",JSON.stringify(t,null,2));let i,n=Date.now();try{return i=await r(t,e),i}finally{i!=null&&(console.log(`Generation took ${Date.now()-n}ms`),console.log("Generation result:",JSON.stringify(i,null,2))),console.groupEnd()}}}var en=ka;var _a=typeof global=="object"&&global&&global.Object===Object&&global,tn=_a,Aa=typeof self=="object"&&self&&self.Object===Object&&self,Sa=tn||Aa||Function("return this")(),q=Sa,Ca=q.Symbol,ae=Ca,rn=Object.prototype,Ta=rn.hasOwnProperty,Ma=rn.toString,Te=ae?ae.toStringTag:void 0;function Oa(t){var e=Ta.call(t,Te),r=t[Te];try{t[Te]=void 0;var i=!0}catch{}var n=Ma.call(t);return i&&(e?t[Te]=r:delete t[Te]),n}var ja=Oa,Pa=Object.prototype,Da=Pa.toString;function Ua(t){return Da.call(t)}var $a=Ua,La="[object Null]",Na="[object Undefined]",qi=ae?ae.toStringTag:void 0;function qa(t){return t==null?t===void 0?Na:La:qi&&qi in Object(t)?ja(t):$a(t)}var De=qa;function Ba(t){return t!=null&&typeof t=="object"}var ar=Ba,dh=Array.isArray;function Ra(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var nn=Ra,Fa="[object AsyncFunction]",Va="[object Function]",za="[object GeneratorFunction]",Ha="[object Proxy]";function Qa(t){if(!nn(t))return!1;var e=De(t);return e==Va||e==za||e==Fa||e==Ha}var Ga=Qa,Ka=q["__core-js_shared__"],Xt=Ka,Bi=function(){var t=/[^.]+$/.exec(Xt&&Xt.keys&&Xt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Wa(t){return!!Bi&&Bi in t}var Ya=Wa,Za=Function.prototype,Xa=Za.toString;function Ja(t){if(t!=null){try{return Xa.call(t)}catch{}try{return t+""}catch{}}return""}var ee=Ja,el=/[\\^$.*+?()[\]{}|]/g,tl=/^\[object .+?Constructor\]$/,rl=Function.prototype,il=Object.prototype,nl=rl.toString,ol=il.hasOwnProperty,sl=RegExp("^"+nl.call(ol).replace(el,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function al(t){if(!nn(t)||Ya(t))return!1;var e=Ga(t)?sl:tl;return e.test(ee(t))}var ll=al;function cl(t,e){return t?.[e]}var ul=cl;function dl(t,e){var r=ul(t,e);return ll(r)?r:void 0}var le=dl,pl=le(q,"WeakMap"),rr=pl;function fl(t,e){return t===e||t!==t&&e!==e}var hl=fl,gl=9007199254740991;function ml(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=gl}var yl=ml,ph=Object.prototype,bl="[object Arguments]";function vl(t){return ar(t)&&De(t)==bl}var Ri=vl,on=Object.prototype,wl=on.hasOwnProperty,xl=on.propertyIsEnumerable,fh=Ri(function(){return arguments}())?Ri:function(t){return ar(t)&&wl.call(t,"callee")&&!xl.call(t,"callee")},sn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Fi=sn&&typeof module=="object"&&module&&!module.nodeType&&module,El=Fi&&Fi.exports===sn,Vi=El?q.Buffer:void 0,hh=Vi?Vi.isBuffer:void 0,Il="[object Arguments]",kl="[object Array]",_l="[object Boolean]",Al="[object Date]",Sl="[object Error]",Cl="[object Function]",Tl="[object Map]",Ml="[object Number]",Ol="[object Object]",jl="[object RegExp]",Pl="[object Set]",Dl="[object String]",Ul="[object WeakMap]",$l="[object ArrayBuffer]",Ll="[object DataView]",Nl="[object Float32Array]",ql="[object Float64Array]",Bl="[object Int8Array]",Rl="[object Int16Array]",Fl="[object Int32Array]",Vl="[object Uint8Array]",zl="[object Uint8ClampedArray]",Hl="[object Uint16Array]",Ql="[object Uint32Array]",E={};E[Nl]=E[ql]=E[Bl]=E[Rl]=E[Fl]=E[Vl]=E[zl]=E[Hl]=E[Ql]=!0;E[Il]=E[kl]=E[$l]=E[_l]=E[Ll]=E[Al]=E[Sl]=E[Cl]=E[Tl]=E[Ml]=E[Ol]=E[jl]=E[Pl]=E[Dl]=E[Ul]=!1;function Gl(t){return ar(t)&&yl(t.length)&&!!E[De(t)]}var Kl=Gl;function Wl(t){return function(e){return t(e)}}var Yl=Wl,an=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=an&&typeof module=="object"&&module&&!module.nodeType&&module,Zl=Oe&&Oe.exports===an,Jt=Zl&&tn.process,Xl=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||Jt&&Jt.binding&&Jt.binding("util")}catch{}}(),zi=Xl,Hi=zi&&zi.isTypedArray,gh=Hi?Yl(Hi):Kl,Jl=Object.prototype,mh=Jl.hasOwnProperty;function ec(t,e){return function(r){return t(e(r))}}var tc=ec,yh=tc(Object.keys,Object),rc=Object.prototype,bh=rc.hasOwnProperty,ic=le(Object,"create"),je=ic;function nc(){this.__data__=je?je(null):{},this.size=0}var oc=nc;function sc(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var ac=sc,lc="__lodash_hash_undefined__",cc=Object.prototype,uc=cc.hasOwnProperty;function dc(t){var e=this.__data__;if(je){var r=e[t];return r===lc?void 0:r}return uc.call(e,t)?e[t]:void 0}var pc=dc,fc=Object.prototype,hc=fc.hasOwnProperty;function gc(t){var e=this.__data__;return je?e[t]!==void 0:hc.call(e,t)}var mc=gc,yc="__lodash_hash_undefined__";function bc(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=je&&e===void 0?yc:e,this}var vc=bc;function ce(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ce.prototype.clear=oc;ce.prototype.delete=ac;ce.prototype.get=pc;ce.prototype.has=mc;ce.prototype.set=vc;var Qi=ce;function wc(){this.__data__=[],this.size=0}var xc=wc;function Ec(t,e){for(var r=t.length;r--;)if(hl(t[r][0],e))return r;return-1}var dt=Ec,Ic=Array.prototype,kc=Ic.splice;function _c(t){var e=this.__data__,r=dt(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():kc.call(e,r,1),--this.size,!0}var Ac=_c;function Sc(t){var e=this.__data__,r=dt(e,t);return r<0?void 0:e[r][1]}var Cc=Sc;function Tc(t){return dt(this.__data__,t)>-1}var Mc=Tc;function Oc(t,e){var r=this.__data__,i=dt(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var jc=Oc;function ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ue.prototype.clear=xc;ue.prototype.delete=Ac;ue.prototype.get=Cc;ue.prototype.has=Mc;ue.prototype.set=jc;var pt=ue,Pc=le(q,"Map"),Pe=Pc;function Dc(){this.size=0,this.__data__={hash:new Qi,map:new(Pe||pt),string:new Qi}}var Uc=Dc;function $c(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Lc=$c;function Nc(t,e){var r=t.__data__;return Lc(e)?r[typeof e=="string"?"string":"hash"]:r.map}var ft=Nc;function qc(t){var e=ft(this,t).delete(t);return this.size-=e?1:0,e}var Bc=qc;function Rc(t){return ft(this,t).get(t)}var Fc=Rc;function Vc(t){return ft(this,t).has(t)}var zc=Vc;function Hc(t,e){var r=ft(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var Qc=Hc;function de(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}de.prototype.clear=Uc;de.prototype.delete=Bc;de.prototype.get=Fc;de.prototype.has=zc;de.prototype.set=Qc;var ln=de;function Gc(){this.__data__=new pt,this.size=0}var Kc=Gc;function Wc(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Yc=Wc;function Zc(t){return this.__data__.get(t)}var Xc=Zc;function Jc(t){return this.__data__.has(t)}var eu=Jc,tu=200;function ru(t,e){var r=this.__data__;if(r instanceof pt){var i=r.__data__;if(!Pe||i.length<tu-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new ln(i)}return r.set(t,e),this.size=r.size,this}var iu=ru;function Ue(t){var e=this.__data__=new pt(t);this.size=e.size}Ue.prototype.clear=Kc;Ue.prototype.delete=Yc;Ue.prototype.get=Xc;Ue.prototype.has=eu;Ue.prototype.set=iu;var nu=Object.prototype,vh=nu.propertyIsEnumerable,ou=le(q,"DataView"),ir=ou,su=le(q,"Promise"),nr=su,au=le(q,"Set"),or=au,Gi="[object Map]",lu="[object Object]",Ki="[object Promise]",Wi="[object Set]",Yi="[object WeakMap]",Zi="[object DataView]",cu=ee(ir),uu=ee(Pe),du=ee(nr),pu=ee(or),fu=ee(rr),se=De;(ir&&se(new ir(new ArrayBuffer(1)))!=Zi||Pe&&se(new Pe)!=Gi||nr&&se(nr.resolve())!=Ki||or&&se(new or)!=Wi||rr&&se(new rr)!=Yi)&&(se=function(t){var e=De(t),r=e==lu?t.constructor:void 0,i=r?ee(r):"";if(i)switch(i){case cu:return Zi;case uu:return Gi;case du:return Ki;case pu:return Wi;case fu:return Yi}return e});var wh=q.Uint8Array,hu="__lodash_hash_undefined__";function gu(t){return this.__data__.set(t,hu),this}var mu=gu;function yu(t){return this.__data__.has(t)}var bu=yu;function sr(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new ln;++e<r;)this.add(t[e])}sr.prototype.add=sr.prototype.push=mu;sr.prototype.has=bu;var Xi=ae?ae.prototype:void 0,xh=Xi?Xi.valueOf:void 0,vu=Object.prototype,Eh=vu.hasOwnProperty,wu=Object.prototype,Ih=wu.hasOwnProperty,kh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),_h=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Ah=new RegExp(/[A-Fa-f0-9]{2}/,"g");var er="@imgly/plugin-ai-generation",Sh=`
5
+ `;else if(w==="event")s=A;else if(w==="id"&&!A.includes("\0"))o=A;else if(w==="retry"){let C=parseInt(A,10);Number.isNaN(C)||t({type:"reconnect-interval",value:C})}}}var Tr=[239,187,191];function Io(t){return Tr.every((e,r)=>t.charCodeAt(r)===e)}vt.createParser=ko});var wt=v(z=>{"use strict";var Eo=z&&z.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(z,"__esModule",{value:!0});z.TOKEN_EXPIRATION_SECONDS=void 0;z.getTemporaryAuthToken=Co;var _o=Qe(),Ao=ie(),So=W();z.TOKEN_EXPIRATION_SECONDS=120;function Co(t,e){return Eo(this,void 0,void 0,function*(){let r=(0,So.parseEndpointId)(t),i=yield(0,Ao.dispatchRequest)({method:"POST",targetUrl:`${(0,_o.getRestApiUrl)()}/tokens/`,config:e,input:{allowed_apps:[r.alias],token_expiration:z.TOKEN_EXPIRATION_SECONDS}});return typeof i!="string"&&i.detail?i.detail:i})}});var kt=v(O=>{"use strict";var ve=O&&O.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})},we=O&&O.__await||function(t){return this instanceof we?(this.v=t,this):new we(t)},To=O&&O.__asyncGenerator||function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,o=[];return n={},a("next"),a("throw"),a("return",s),n[Symbol.asyncIterator]=function(){return this},n;function s(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){i[p]&&(n[p]=function(b){return new Promise(function(w,m){o.push([p,b,w,m])>1||l(p,b)})},g&&(n[p]=g(n[p])))}function l(p,g){try{u(i[p](g))}catch(b){h(o[0][3],b)}}function u(p){p.value instanceof we?Promise.resolve(p.value.v).then(c,d):h(o[0][2],p)}function c(p){l("next",p)}function d(p){l("throw",p)}function h(p,g){p(g),o.shift(),o.length&&l(o[0][0],o[0][1])}};Object.defineProperty(O,"__esModule",{value:!0});O.FalStream=void 0;O.createStreamingClient=Po;var Mo=Mr(),Oo=wt(),Or=ie(),ne=K(),xt="text/event-stream",jo=15*1e3,Ge=class{constructor(e,r,i){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this.abortController=new AbortController,this.start=()=>ve(this,void 0,void 0,function*(){var o,s;let{endpointId:a,options:l}=this,{input:u,method:c="post",connectionMode:d="server"}=l;try{if(d==="client"){let h=yield(0,Oo.getTemporaryAuthToken)(a,this.config),{fetch:p}=this.config,g=new URL(this.url);g.searchParams.set("fal_jwt_token",h);let b=yield p(g.toString(),{method:c.toUpperCase(),headers:{accept:(o=l.accept)!==null&&o!==void 0?o:xt,"content-type":"application/json"},body:u&&c!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return yield this.handleResponse(b)}return yield(0,Or.dispatchRequest)({method:c.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(s=l.accept)!==null&&s!==void 0?s:xt},responseHandler:this.handleResponse,signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>ve(this,void 0,void 0,function*(){var s,a;if(!o.ok){try{yield(0,ne.defaultResponseHandler)(o)}catch(b){this.emit("error",b)}return}let l=o.body;if(!l){this.emit("error",new ne.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((s=o.headers.get("content-type"))!==null&&s!==void 0?s:"").startsWith(xt)){let b=l.getReader(),w=()=>{b.read().then(({done:m,value:x})=>{if(m){this.emit("done",this.currentData);return}this.currentData=x,this.emit("data",x),w()})};w();return}let c=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,Mo.createParser)(b=>{if(b.type==="event"){let w=b.data;try{let m=JSON.parse(w);this.buffer.push(m),this.currentData=m,this.emit("data",m),this.emit("message",m)}catch(m){this.emit("error",m)}}}),p=(a=this.options.timeout)!==null&&a!==void 0?a:jo,g=()=>ve(this,void 0,void 0,function*(){let{value:b,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(c.decode(b)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new ne.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):g().catch(this.handleError)});g().catch(this.handleError)}),this.handleError=o=>{var s;if(o.name==="AbortError"||this.signal.aborted)return;let a=o instanceof ne.ApiError?o:new ne.ApiError({message:(s=o.message)!==null&&s!==void 0?s:"An unknown error occurred",status:500});this.emit("error",a)},this.on=(o,s)=>{var a;this.listeners.has(o)||this.listeners.set(o,[]),(a=this.listeners.get(o))===null||a===void 0||a.push(s)},this.emit=(o,s)=>{let a=this.listeners.get(o)||[];for(let l of a)l(s)},this.done=()=>ve(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=e,this.config=r,this.url=(n=i.url)!==null&&n!==void 0?n:(0,Or.buildUrl)(e,{path:"/stream",query:i.queryParams}),this.options=i,this.donePromise=new Promise((o,s)=>{this.streamClosed&&s(new ne.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var a;o((a=this.currentData)!==null&&a!==void 0?a:{})}),this.on("done",a=>{this.streamClosed=!0,o(a)}),this.on("error",a=>{this.streamClosed=!0,s(a)})}),i.signal&&i.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return To(this,arguments,function*(){let r=!0,i=()=>r=!1;for(this.on("error",i),this.on("done",i);r||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield we(n)),yield we(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}};O.FalStream=Ge;function Po({config:t,storage:e}){return{stream(r,i){return ve(this,void 0,void 0,function*(){let n=i.input?yield e.transformInput(i.input):void 0;return new Ge(r,t,Object.assign(Object.assign({},i),{input:n}))})}}}});var Pr=v(H=>{"use strict";var Y=H&&H.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})},Do=H&&H.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(H,"__esModule",{value:!0});H.createQueueClient=void 0;var U=ie(),Uo=K(),$o=kt(),Ke=W(),jr=500,Lo=({config:t,storage:e})=>{let r={submit(i,n){return Y(this,void 0,void 0,function*(){let{webhookUrl:o,priority:s}=n,a=Do(n,["webhookUrl","priority"]),l=n.input?yield e.transformInput(n.input):void 0;return(0,U.dispatchRequest)({method:n.method,targetUrl:(0,U.buildUrl)(i,Object.assign(Object.assign({},a),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:{"x-fal-queue-priority":s??"normal"},input:l,config:t,options:{signal:n.abortSignal}})})},status(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,abortSignal:l}){let u=(0,Ke.parseEndpointId)(o),c=u.namespace?`${u.namespace}/`:"";return(0,U.dispatchRequest)({method:"get",targetUrl:(0,U.buildUrl)(`${c}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:a?"1":"0"},path:`/requests/${s}/status`}),config:t,options:{signal:l}})})},streamStatus(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,connectionMode:l}){let u=(0,Ke.parseEndpointId)(o),c=u.namespace?`${u.namespace}/`:"",d={logs:a?"1":"0"},h=(0,U.buildUrl)(`${c}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${s}/status/stream`,query:d});return new $o.FalStream(o,t,{url:h,method:"get",connectionMode:l,queryParams:d})})},subscribeToStatus(i,n){return Y(this,void 0,void 0,function*(){let o=n.requestId,s=n.timeout,a,l=()=>{};if(n.mode==="streaming"){let u=yield r.streamStatus(i,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),c=[];s&&(a=setTimeout(()=>{throw u.abort(),r.cancel(i,{requestId:o}).catch(l),new Error(`Client timed out waiting for the request to complete after ${s}ms`)},s)),u.on("data",h=>{n.onQueueUpdate&&("logs"in h&&Array.isArray(h.logs)&&h.logs.length>0&&c.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:c}):h))});let d=yield u.done();return a&&clearTimeout(a),d}return new Promise((u,c)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:jr,g=()=>{a&&clearTimeout(a),h&&clearTimeout(h)};s&&(a=setTimeout(()=>{g(),r.cancel(i,{requestId:o}).catch(l),c(new Error(`Client timed out waiting for the request to complete after ${s}ms`))},s));let b=()=>Y(this,void 0,void 0,function*(){var w;try{let m=yield r.status(i,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(m),m.status==="COMPLETED"){g(),u(m);return}h=setTimeout(b,p)}catch(m){g(),c(m)}});b().catch(c)})})},result(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let l=(0,Ke.parseEndpointId)(o),u=l.namespace?`${l.namespace}/`:"";return(0,U.dispatchRequest)({method:"get",targetUrl:(0,U.buildUrl)(`${u}${l.owner}/${l.alias}`,{subdomain:"queue",path:`/requests/${s}`}),config:Object.assign(Object.assign({},t),{responseHandler:Uo.resultResponseHandler}),options:{signal:a}})})},cancel(i,n){return Y(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let l=(0,Ke.parseEndpointId)(o),u=l.namespace?`${l.namespace}/`:"";yield(0,U.dispatchRequest)({method:"put",targetUrl:(0,U.buildUrl)(`${u}${l.owner}/${l.alias}`,{subdomain:"queue",path:`/requests/${s}/cancel`}),config:t,options:{signal:a}})})}};return r};H.createQueueClient=Lo});var We=v($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.utf8Count=No;$.utf8EncodeJs=Dr;$.utf8EncodeTE=Ur;$.utf8Encode=Fo;$.utf8DecodeJs=$r;$.utf8DecodeTD=Lr;$.utf8Decode=Ho;function No(t){let e=t.length,r=0,i=0;for(;i<e;){let n=t.charCodeAt(i++);if(n&4294967168)if(!(n&4294965248))r+=2;else{if(n>=55296&&n<=56319&&i<e){let o=t.charCodeAt(i);(o&64512)===56320&&(++i,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?r+=4:r+=3}else{r++;continue}}return r}function Dr(t,e,r){let i=t.length,n=r,o=0;for(;o<i;){let s=t.charCodeAt(o++);if(s&4294967168)if(!(s&4294965248))e[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<i){let a=t.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}s&4294901760?(e[n++]=s>>18&7|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128):(e[n++]=s>>12&15|224,e[n++]=s>>6&63|128)}else{e[n++]=s;continue}e[n++]=s&63|128}}var qo=new TextEncoder,Bo=50;function Ur(t,e,r){qo.encodeInto(t,e.subarray(r))}function Fo(t,e,r){t.length>Bo?Ur(t,e,r):Dr(t,e,r)}var Ro=4096;function $r(t,e,r){let i=e,n=i+r,o=[],s="";for(;i<n;){let a=t[i++];if(!(a&128))o.push(a);else if((a&224)===192){let l=t[i++]&63;o.push((a&31)<<6|l)}else if((a&240)===224){let l=t[i++]&63,u=t[i++]&63;o.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=t[i++]&63,u=t[i++]&63,c=t[i++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(a);o.length>=Ro&&(s+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(s+=String.fromCharCode(...o)),s}var Vo=new TextDecoder,zo=200;function Lr(t,e,r){let i=t.subarray(e,e+r);return Vo.decode(i)}function Ho(t,e,r){return r>zo?Lr(t,e,r):$r(t,e,r)}});var Et=v(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.ExtData=void 0;var It=class{constructor(e,r){this.type=e,this.data=r}};Ye.ExtData=It});var Xe=v(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.DecodeError=void 0;var _t=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};Ze.DecodeError=_t});var Je=v(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.UINT32_MAX=void 0;Q.setUint64=Qo;Q.setInt64=Go;Q.getInt64=Ko;Q.getUint64=Wo;Q.UINT32_MAX=4294967295;function Qo(t,e,r){let i=r/4294967296,n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Go(t,e,r){let i=Math.floor(r/4294967296),n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Ko(t,e){let r=t.getInt32(e),i=t.getUint32(e+4);return r*4294967296+i}function Wo(t,e){let r=t.getUint32(e),i=t.getUint32(e+4);return r*4294967296+i}});var At=v(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.timestampExtension=T.EXT_TIMESTAMP=void 0;T.encodeTimeSpecToTimestamp=qr;T.encodeDateToTimeSpec=Br;T.encodeTimestampExtension=Fr;T.decodeTimestampToTimeSpec=Rr;T.decodeTimestampExtension=Vr;var Yo=Xe(),Nr=Je();T.EXT_TIMESTAMP=-1;var Zo=4294967296-1,Xo=17179869184-1;function qr({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Xo)if(e===0&&t<=Zo){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,i=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,e<<2|r&3),o.setUint32(4,i),n}else{let r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,e),(0,Nr.setInt64)(i,4,t),r}}function Br(t){let e=t.getTime(),r=Math.floor(e/1e3),i=(e-r*1e3)*1e6,n=Math.floor(i/1e9);return{sec:r+n,nsec:i-n*1e9}}function Fr(t){if(t instanceof Date){let e=Br(t);return qr(e)}else return null}function Rr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),i=e.getUint32(4),n=(r&3)*4294967296+i,o=r>>>2;return{sec:n,nsec:o}}case 12:{let r=(0,Nr.getInt64)(e,4),i=e.getUint32(0);return{sec:r,nsec:i}}default:throw new Yo.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Vr(t){let e=Rr(t);return new Date(e.sec*1e3+e.nsec/1e6)}T.timestampExtension={type:T.EXT_TIMESTAMP,encode:Fr,decode:Vr}});var rt=v(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.ExtensionCodec=void 0;var et=Et(),Jo=At(),xe=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Jo.timestampExtension)}register({type:e,encode:r,decode:i}){if(e>=0)this.encoders[e]=r,this.decoders[e]=i;else{let n=-1-e;this.builtInEncoders[n]=r,this.builtInDecoders[n]=i}}tryToEncode(e,r){for(let i=0;i<this.builtInEncoders.length;i++){let n=this.builtInEncoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=-1-i;return new et.ExtData(s,o)}}}for(let i=0;i<this.encoders.length;i++){let n=this.encoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=i;return new et.ExtData(s,o)}}}return e instanceof et.ExtData?e:null}decode(e,r,i){let n=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return n?n(e,r,i):new et.ExtData(r,e)}};tt.ExtensionCodec=xe;xe.defaultCodec=new xe});var Ct=v(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.ensureUint8Array=ts;function es(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function ts(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):es(t)?new Uint8Array(t):Uint8Array.from(t)}});var Mt=v(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.Encoder=D.DEFAULT_INITIAL_BUFFER_SIZE=D.DEFAULT_MAX_DEPTH=void 0;var zr=We(),rs=rt(),Hr=Je(),is=Ct();D.DEFAULT_MAX_DEPTH=100;D.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Tt=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??rs.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??D.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??D.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),i=new Uint8Array(r),n=new DataView(r);i.set(this.bytes),this.view=n,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let i=(0,zr.utf8Count)(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),(0,zr.utf8Encode)(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,r){let i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let i=(0,is.ensureUint8Array)(e);this.writeU8a(i)}encodeArray(e,r){let i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(let n of e)this.doEncode(n,r+1)}countWithoutUndefined(e,r){let i=0;for(let n of r)e[n]!==void 0&&i++;return i}encodeMap(e,r){let i=Object.keys(e);this.sortKeys&&i.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.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 i){let s=e[o];this.ignoreUndefined&&s===void 0||(this.encodeString(o),this.doEncode(s,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let i=e.data(this.pos+6),n=i.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(i);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Hr.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Hr.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};D.Encoder=Tt});var Qr=v(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.encode=os;var ns=Mt();function os(t,e){return new ns.Encoder(e).encodeSharedRef(t)}});var Gr=v(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.prettyByte=ss;function ss(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var Kr=v(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.CachedKeyDecoder=void 0;var as=We(),ls=16,cs=16,Pt=class{constructor(e=ls,r=cs){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,i){let n=this.caches[i-1];e:for(let o of n){let s=o.bytes;for(let a=0;a<i;a++)if(s[a]!==e[r+a])continue e;return o.str}return null}store(e,r){let i=this.caches[e.length-1],n={bytes:e,str:r};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=n:i.push(n)}decode(e,r,i){let n=this.find(e,r,i);if(n!=null)return this.hit++,n;this.miss++;let o=(0,as.utf8DecodeJs)(e,r,i),s=Uint8Array.prototype.slice.call(e,r,r+i);return this.store(s,o),o}};it.CachedKeyDecoder=Pt});var ot=v(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.Decoder=void 0;var Dt=Gr(),us=rt(),Z=Je(),ds=We(),Wr=Ct(),ps=Kr(),L=Xe(),Ut="array",Ie="map_key",Zr="map_value",fs=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new L.DecodeError("The type of key must be string or number but "+typeof t)},$t=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=Ut,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=Ie,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Ut){let i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===Ie||e.type===Zr){let i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},ke=-1,Nt=new DataView(new ArrayBuffer(0)),hs=new Uint8Array(Nt.buffer);try{Nt.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Yr=new RangeError("Insufficient data"),gs=new ps.CachedKeyDecoder,Lt=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=Nt,this.bytes=hs,this.headByte=ke,this.stack=new $t,this.entered=!1,this.extensionCodec=e?.extensionCodec??us.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??Z.UINT32_MAX,this.maxBinLength=e?.maxBinLength??Z.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??Z.UINT32_MAX,this.maxMapLength=e?.maxMapLength??Z.UINT32_MAX,this.maxExtLength=e?.maxExtLength??Z.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:gs,this.mapKeyConverter=e?.mapKeyConverter??fs}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=ke,this.stack.reset()}setBuffer(e){let r=(0,Wr.ensureUint8Array)(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===ke&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),i=(0,Wr.ensureUint8Array)(e),n=new Uint8Array(r.length+i.length);n.set(r),n.set(i,r.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:i}=this;return new RangeError(`Extra ${r.byteLength-i} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,i;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),r=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}let{headByte:n,pos:o,totalPos:s}=this;throw new RangeError(`Insufficient data in parsing ${(0,Dt.prettyByte)(n)} at ${s} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let i=r,n=-1;for await(let o of e){if(r&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),i&&(n=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(s){if(!(s instanceof RangeError))throw s}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{let n=e-160;r=this.decodeString(n,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let n=this.lookU8();r=this.decodeString(n,1)}else if(e===218){let n=this.lookU16();r=this.decodeString(n,2)}else if(e===219){let n=this.lookU32();r=this.decodeString(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===196){let n=this.lookU8();r=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();r=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();r=this.decodeBinary(n,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();r=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();r=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();r=this.decodeExtension(n,4)}else throw new L.DecodeError(`Unrecognized type byte: ${(0,Dt.prettyByte)(e)}`);this.complete();let i=this.stack;for(;i.length>0;){let n=i.top();if(n.type===Ut)if(n.array[n.position]=r,n.position++,n.position===n.size)r=n.array,i.release(n);else continue e;else if(n.type===Ie){if(r==="__proto__")throw new L.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(r),n.type=Zr;continue e}else if(n.map[n.key]=r,n.readCount++,n.readCount===n.size)r=n.map,i.release(n);else{n.key=null,n.type=Ie;continue e}}return r}}readHeadByte(){return this.headByte===ke&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=ke}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new L.DecodeError(`Unrecognized array type byte: ${(0,Dt.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new L.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new L.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new L.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Yr;let i=this.pos+r,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,i,e):n=(0,ds.utf8Decode)(this.bytes,i,e),this.pos+=r+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ie:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new L.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Yr;let i=this.pos+r,n=this.bytes.subarray(i,i+e);return this.pos+=r+e,n}decodeExtension(e,r){if(e>this.maxExtLength)throw new L.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let i=this.view.getInt8(this.pos+r),n=this.decodeBinary(e,r+1);return this.extensionCodec.decode(n,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,Z.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,Z.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};nt.Decoder=Lt});var Jr=v(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.decode=ms;st.decodeMulti=ys;var Xr=ot();function ms(t,e){return new Xr.Decoder(e).decode(t)}function ys(t,e){return new Xr.Decoder(e).decodeMulti(t)}});var ri=v(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.isAsyncIterable=ei;Ee.asyncIterableFromStream=ti;Ee.ensureAsyncIterable=bs;function ei(t){return t[Symbol.asyncIterator]!=null}async function*ti(t){let e=t.getReader();try{for(;;){let{done:r,value:i}=await e.read();if(r)return;yield i}}finally{e.releaseLock()}}function bs(t){return ei(t)?t:ti(t)}});var ii=v(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.decodeAsync=vs;_e.decodeArrayStream=ws;_e.decodeMultiStream=xs;var qt=ot(),Bt=ri();async function vs(t,e){let r=(0,Bt.ensureAsyncIterable)(t);return new qt.Decoder(e).decodeAsync(r)}function ws(t,e){let r=(0,Bt.ensureAsyncIterable)(t);return new qt.Decoder(e).decodeArrayStream(r)}function xs(t,e){let r=(0,Bt.ensureAsyncIterable)(t);return new qt.Decoder(e).decodeStream(r)}});var oi=v(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.decodeTimestampExtension=y.encodeTimestampExtension=y.decodeTimestampToTimeSpec=y.encodeTimeSpecToTimestamp=y.encodeDateToTimeSpec=y.EXT_TIMESTAMP=y.ExtData=y.ExtensionCodec=y.Encoder=y.DecodeError=y.Decoder=y.decodeMultiStream=y.decodeArrayStream=y.decodeAsync=y.decodeMulti=y.decode=y.encode=void 0;var ks=Qr();Object.defineProperty(y,"encode",{enumerable:!0,get:function(){return ks.encode}});var ni=Jr();Object.defineProperty(y,"decode",{enumerable:!0,get:function(){return ni.decode}});Object.defineProperty(y,"decodeMulti",{enumerable:!0,get:function(){return ni.decodeMulti}});var Ft=ii();Object.defineProperty(y,"decodeAsync",{enumerable:!0,get:function(){return Ft.decodeAsync}});Object.defineProperty(y,"decodeArrayStream",{enumerable:!0,get:function(){return Ft.decodeArrayStream}});Object.defineProperty(y,"decodeMultiStream",{enumerable:!0,get:function(){return Ft.decodeMultiStream}});var Is=ot();Object.defineProperty(y,"Decoder",{enumerable:!0,get:function(){return Is.Decoder}});var Es=Xe();Object.defineProperty(y,"DecodeError",{enumerable:!0,get:function(){return Es.DecodeError}});var _s=Mt();Object.defineProperty(y,"Encoder",{enumerable:!0,get:function(){return _s.Encoder}});var As=rt();Object.defineProperty(y,"ExtensionCodec",{enumerable:!0,get:function(){return As.ExtensionCodec}});var Ss=Et();Object.defineProperty(y,"ExtData",{enumerable:!0,get:function(){return Ss.ExtData}});var oe=At();Object.defineProperty(y,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return oe.EXT_TIMESTAMP}});Object.defineProperty(y,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return oe.encodeDateToTimeSpec}});Object.defineProperty(y,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return oe.encodeTimeSpecToTimestamp}});Object.defineProperty(y,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return oe.decodeTimestampToTimeSpec}});Object.defineProperty(y,"encodeTimestampExtension",{enumerable:!0,get:function(){return oe.encodeTimestampExtension}});Object.defineProperty(y,"decodeTimestampExtension",{enumerable:!0,get:function(){return oe.decodeTimestampExtension}})});var wi=v(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});function _(t){return{enumerable:!0,value:t}}function si(t){return{enumerable:!0,writable:!0,value:t}}var X={},Cs=()=>!0,ai=()=>({}),ci=t=>t,Ts=(t,e,r,i)=>t.apply(r,i)&&e.apply(r,i),Ms=(t,e,r,[i,n])=>e.call(r,t.call(r,i,n),n),G=(t,e)=>Object.freeze(Object.create(t,e));function li(t,e,r){return t.reduce((i,n)=>function(...o){return r(i,n,this,o)},e)}function ui(t){return G(this,{fn:_(t)})}var di={},pi=ui.bind(di),Os=t=>pi((e,r)=>!!~t(e,r)&&e),fi={},js=ui.bind(fi);function at(t,e){return e.filter(r=>t.isPrototypeOf(r))}function hi(t,e,...r){let i=li(at(fi,r).map(o=>o.fn),Cs,Ts),n=li(at(di,r).map(o=>o.fn),ci,Ms);return G(this,{from:_(t),to:_(e),guards:_(i),reducers:_(n)})}var gi={},mi={},Ps=hi.bind(gi),Ds=hi.bind(mi,null);function Us(t,e,r){return Vt(e,t,r,this.immediates)||t}function yi(t){let e=new Map;for(let r of t)e.has(r.from)||e.set(r.from,[]),e.get(r.from).push(r);return e}var $s={enter:ci};function Ls(...t){let e=at(gi,t),r=at(mi,t),i={final:_(t.length===0),transitions:_(yi(e))};return r.length&&(i.immediates=_(r),i.enter=_(Us)),G($s,i)}var Ns={enter(t,e,r){let i=this.fn.call(e,e.context,r);return Rt.isPrototypeOf(i)?G(bi,{machine:_(i),transitions:_(this.transitions)}).enter(t,e,r):(i.then(n=>e.send({type:"done",data:n})).catch(n=>e.send({type:"error",error:n})),t)}},bi={enter(t,e,r){if(e.child=vi(this.machine,i=>{e.onChange(i),e.child==i&&i.machine.state.value.final&&(delete e.child,e.send({type:"done",data:i.context}))},e.context,r),e.child.machine.state.value.final){let i=e.child.context;return delete e.child,Vt(e,t,{type:"done",data:i},this.transitions.get("done"))}return t}};function qs(t,...e){let r=_(yi(e));return Rt.isPrototypeOf(t)?G(bi,{machine:_(t),transitions:r}):G(Ns,{fn:_(t),transitions:r})}var Rt={get state(){return{name:this.current,value:this.states[this.current]}}};function Bs(t,e,r=ai){return typeof t!="string"&&(r=e||ai,e=t,t=Object.keys(e)[0]),X._create&&X._create(t,e),G(Rt,{context:_(r),current:_(t),states:_(e)})}function Vt(t,e,r,i){let{context:n}=t;for(let{to:o,guards:s,reducers:a}of i)if(s(n,r)){t.context=a.call(t,n,r);let l=e.original||e,u=G(l,{current:_(o),original:{value:l}});return X._onEnter&&X._onEnter(e,o,t.context,n,r),u.state.value.enter(u,t,r)}}function Fs(t,e){let r=e.type||e,{machine:i}=t,{value:n,name:o}=i.state;return n.transitions.has(r)?Vt(t,i,e,n.transitions.get(r))||i:(X._send&&X._send(r,o),i)}var Rs={send(t){this.machine=Fs(this,t),this.onChange(this)}};function vi(t,e,r,i){let n=Object.create(Rs,{machine:si(t),context:si(t.context(r,i)),onChange:_(e)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,i),n}M.action=Os;M.createMachine=Bs;M.d=X;M.guard=js;M.immediate=Ds;M.interpret=vi;M.invoke=qs;M.reduce=pi;M.state=Ls;M.transition=Ps});var _i=v(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.createRealtimeClient=ia;var ct=oi(),f=wi(),xi=wt(),zt=K(),ki=He(),Gt=W(),Vs=()=>({enqueuedMessage:void 0});function zs(t){return t.token!==void 0}function Hs(t){return!zs(t)}function lt(t,e){return Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function N(t){return t.websocket&&t.websocket.readyState===WebSocket.OPEN&&t.websocket.close(),Object.assign(Object.assign({},t),{websocket:void 0})}function Qs(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,ct.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function Ht(t){return Object.assign(Object.assign({},t),{token:void 0})}function Gs(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Ks(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var Ws=(0,f.createMachine)("idle",{idle:(0,f.state)((0,f.transition)("send","connecting",(0,f.reduce)(lt)),(0,f.transition)("expireToken","idle",(0,f.reduce)(Ht)),(0,f.transition)("close","idle",(0,f.reduce)(N))),connecting:(0,f.state)((0,f.transition)("connecting","connecting"),(0,f.transition)("connected","active",(0,f.reduce)(Ks)),(0,f.transition)("connectionClosed","idle",(0,f.reduce)(N)),(0,f.transition)("send","connecting",(0,f.reduce)(lt)),(0,f.transition)("close","idle",(0,f.reduce)(N)),(0,f.immediate)("authRequired",(0,f.guard)(Hs))),authRequired:(0,f.state)((0,f.transition)("initiateAuth","authInProgress"),(0,f.transition)("send","authRequired",(0,f.reduce)(lt)),(0,f.transition)("close","idle",(0,f.reduce)(N))),authInProgress:(0,f.state)((0,f.transition)("authenticated","connecting",(0,f.reduce)(Gs)),(0,f.transition)("unauthorized","idle",(0,f.reduce)(Ht),(0,f.reduce)(N)),(0,f.transition)("send","authInProgress",(0,f.reduce)(lt)),(0,f.transition)("close","idle",(0,f.reduce)(N))),active:(0,f.state)((0,f.transition)("send","active",(0,f.reduce)(Qs)),(0,f.transition)("unauthorized","idle",(0,f.reduce)(Ht)),(0,f.transition)("connectionClosed","idle",(0,f.reduce)(N)),(0,f.transition)("close","idle",(0,f.reduce)(N))),failed:(0,f.state)((0,f.transition)("send","failed"),(0,f.transition)("close","idle",(0,f.reduce)(N)))},Vs);function Ys(t,{token:e,maxBuffering:r}){if(r!==void 0&&(r<1||r>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let i=new URLSearchParams({fal_jwt_token:e});return r!==void 0&&i.set("max_buffering",r.toFixed(0)),`wss://fal.run/${(0,Gt.ensureEndpointIdFormat)(t)}/realtime?${i.toString()}`}var Zs=128;function Xs(t){return t.status==="error"&&t.error==="Unauthorized"}var Js={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Qt=new Map,Ii=new Map;function ea(t,e,r){if(!Qt.has(t)){let i=(0,f.interpret)(Ws,r);Qt.set(t,Object.assign(Object.assign({},i),{throttledSend:e>0?(0,Gt.throttle)(i.send,e,!0):i.send}))}return Qt.get(t)}var Ae=()=>{},ta={send:Ae,close:Ae};function ra(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!Ei(t)}function Ei(t){return t.type==="x-fal-error"}function ia({config:t}){return{connect(e,r){let{clientOnly:i=(0,Gt.isReact)()&&!(0,ki.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:s=Zs}=r;if(i&&!(0,ki.isBrowser)())return ta;let a;Ii.set(n,{onError:r.onError,onResult:r.onResult});let l=()=>Ii.get(n),u=ea(n,s,({context:h,machine:p,send:g})=>{let{enqueuedMessage:b,token:w}=h;if(p.current==="active"&&b&&g({type:"send",message:b}),p.current==="authRequired"&&w===void 0&&a!==p.current&&(g({type:"initiateAuth"}),(0,xi.getTemporaryAuthToken)(e,t).then(m=>{g({type:"authenticated",token:m});let x=Math.round(xi.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{g({type:"expireToken"})},x)}).catch(m=>{g({type:"unauthorized",error:m})})),p.current==="connecting"&&a!==p.current&&w!==void 0){let m=new WebSocket(Ys(e,{token:w,maxBuffering:o}));m.onopen=()=>{g({type:"connected",websocket:m})},m.onclose=x=>{if(x.code!==Js.NORMAL_CLOSURE){let{onError:S=Ae}=l();S(new zt.ApiError({message:`Error closing the connection: ${x.reason}`,status:x.code}))}g({type:"connectionClosed",code:x.code})},m.onerror=x=>{let{onError:S=Ae}=l();S(new zt.ApiError({message:"Unknown error",status:500}))},m.onmessage=x=>{let{onResult:S}=l();if(x.data instanceof ArrayBuffer){let C=(0,ct.decode)(new Uint8Array(x.data));S(C);return}if(x.data instanceof Uint8Array){let C=(0,ct.decode)(x.data);S(C);return}if(x.data instanceof Blob){x.data.arrayBuffer().then(C=>{let yr=(0,ct.decode)(new Uint8Array(C));S(yr)});return}let A=JSON.parse(x.data);if(Xs(A)){g({type:"unauthorized",error:new Error("Unauthorized")});return}if(ra(A)){S(A);return}if(Ei(A)){if(A.error==="TIMEOUT")return;let{onError:C=Ae}=l();C(new zt.ApiError({message:`${A.error}: ${A.reason}`,status:400,body:A}));return}}}a=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var Mi=v(Se=>{"use strict";var J=Se&&Se.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Se,"__esModule",{value:!0});Se.createStorageClient=la;var Ai=Qe(),Si=ie(),na=W();function Ci(t){var e;let[r,i]=t.split("/");return(e=i.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function oa(t,e,r){return J(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${Ci(r)}`;return yield(0,Si.dispatchRequest)({method:"POST",targetUrl:`${(0,Ai.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function sa(t,e,r){return J(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${Ci(r)}`;return yield(0,Si.dispatchRequest)({method:"POST",targetUrl:`${(0,Ai.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function Ti(t,e,r){return J(this,arguments,void 0,function*(i,n,o,s=3){if(s===0)throw new Error("Part upload failed, retries exhausted");let{fetch:a,responseHandler:l}=o;try{let u=yield a(i,{method:"PUT",body:n});return yield l(u)}catch{return yield Ti(i,n,o,s-1)}})}function aa(t,e){return J(this,void 0,void 0,function*(){let{fetch:r,responseHandler:i}=e,n=t.type||"application/octet-stream",{upload_url:o,file_url:s}=yield sa(t,e,n),a=10*1024*1024,l=Math.ceil(t.size/a),u=new URL(o),c=[];for(let p=0;p<l;p++){let g=p*a,b=Math.min(g+a,t.size),w=t.slice(g,b),m=p+1,x=`${u.origin}${u.pathname}/${m}${u.search}`;c.push(yield Ti(x,w,e))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield r(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:c.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield i(h),s})}function la({config:t}){let e={upload:r=>J(this,void 0,void 0,function*(){if(r.size>94371840)return yield aa(r,t);let i=r.type||"application/octet-stream",{fetch:n,responseHandler:o}=t,{upload_url:s,file_url:a}=yield oa(r,t,i),l=yield n(s,{method:"PUT",body:r,headers:{"Content-Type":r.type||"application/octet-stream"}});return yield o(l),a}),transformInput:r=>J(this,void 0,void 0,function*(){if(Array.isArray(r))return Promise.all(r.map(i=>e.transformInput(i)));if(r instanceof Blob)return yield e.upload(r);if((0,na.isPlainObject)(r)){let n=Object.entries(r).map(s=>J(this,[s],void 0,function*([a,l]){return[a,yield e.transformInput(l)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return r})};return e}});var Wt=v(Ce=>{"use strict";var Oi=Ce&&Ce.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(i.next(c))}catch(d){s(d)}}function l(c){try{u(i.throw(c))}catch(d){s(d)}}function u(c){c.done?o(c.value):n(c.value).then(a,l)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Ce,"__esModule",{value:!0});Ce.createFalClient=ga;var ca=Qe(),ua=Pr(),da=_i(),ji=ie(),pa=K(),fa=Mi(),ha=kt();function ga(t={}){let e=(0,ca.createConfig)(t),r=(0,fa.createStorageClient)({config:e}),i=(0,ua.createQueueClient)({config:e,storage:r}),n=(0,ha.createStreamingClient)({config:e,storage:r}),o=(0,da.createRealtimeClient)({config:e});return{queue:i,realtime:o,storage:r,streaming:n,stream:n.stream,run(s){return Oi(this,arguments,void 0,function*(a,l={}){let u=l.input?yield r.transformInput(l.input):void 0;return(0,ji.dispatchRequest)({method:l.method,targetUrl:(0,ji.buildUrl)(a,l),input:u,config:Object.assign(Object.assign({},e),{responseHandler:pa.resultResponseHandler}),options:{signal:l.abortSignal}})})},subscribe:(s,a)=>Oi(this,void 0,void 0,function*(){let{request_id:l}=yield i.submit(s,a);return a.onEnqueue&&a.onEnqueue(l),yield i.subscribeToStatus(s,Object.assign({requestId:l},a)),i.result(s,{requestId:l})})}}});var Di=v(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.isQueueStatus=Pi;ut.isCompletedQueueStatus=ma;function Pi(t){return t&&t.status&&t.response_url}function ma(t){return Pi(t)&&t.status==="COMPLETED"}});var Yt=v(E=>{"use strict";var ya=E&&E.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),ba=E&&E.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ya(e,t,r)};Object.defineProperty(E,"__esModule",{value:!0});E.fal=E.parseEndpointId=E.ValidationError=E.ApiError=E.withProxy=E.withMiddleware=E.createFalClient=void 0;var Ui=Wt(),va=Wt();Object.defineProperty(E,"createFalClient",{enumerable:!0,get:function(){return va.createFalClient}});var $i=yt();Object.defineProperty(E,"withMiddleware",{enumerable:!0,get:function(){return $i.withMiddleware}});Object.defineProperty(E,"withProxy",{enumerable:!0,get:function(){return $i.withProxy}});var Li=K();Object.defineProperty(E,"ApiError",{enumerable:!0,get:function(){return Li.ApiError}});Object.defineProperty(E,"ValidationError",{enumerable:!0,get:function(){return Li.ValidationError}});ba(Di(),E);var wa=W();Object.defineProperty(E,"parseEndpointId",{enumerable:!0,get:function(){return wa.parseEndpointId}});E.fal=function(){let e=(0,Ui.createFalClient)();return{config(r){e=(0,Ui.createFalClient)(r)},get queue(){return e.queue},get realtime(){return e.realtime},get storage(){return e.storage},get streaming(){return e.streaming},run(r,i){return e.run(r,i)},subscribe(r,i){return e.subscribe(r,i)},stream(r,i){return e.stream(r,i)}}}()});var wr={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},MinimaxVideo01LiveInput:{title:"TextToVideoLiveRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0}},"x-fal-order-properties":["prompt"],required:["prompt"]},MinimaxVideo01LiveOutput:{title:"T2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/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/minimax/video-01-live/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/minimax/video-01-live":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/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/MinimaxVideo01LiveOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var Zt=vr(Yt());async function Ni(t,e){if(t!=null){if(t.startsWith("blob:")){let i=await(await fetch(t)).blob(),n=new File([i],"image.png",{type:"image/png"});return Zt.fal.storage.upload(n)}if(e!=null&&t.startsWith("buffer:")){let r=await e.engine.editor.getMimeType(t),i=e.engine.editor.getBufferLength(t),n=e.engine.editor.getBufferData(t,0,i),o=new File([n],"image.png",{type:r});return Zt.fal.storage.upload(o)}return t}}function xa(t,e){let{cesdk:r}=e,i=e.propertyKey??"image_url";return ka(t,r),{[i]:(n,o)=>{let{builder:s,experimental:{global:a},payload:l}=n,u=l?.url??e.defaultUrl,c=a(`${t}.${o.id}`,u);return s.MediaPreview(o.id,{preview:{type:"image",uri:c.value},action:{label:"Select Image",onClick:()=>{if(r==null)return;let d=tr(t);r.ui.openPanel(d,{payload:{onSelect:h=>{h.meta?.uri!=null&&c.setValue(h.meta?.uri)}}})}}}),()=>({id:o.id,type:"string",value:c.value})}}}function ka(t,e){e?.ui.registerPanel(tr(t),({builder:r,payload:i})=>{r.Library(`${t}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let s=await e.engine.editor.getMimeType(o);s==="image/svg+xml"?e.ui.showNotification({type:"warning",message:"SVG images are not supported. Please choose a different image."}):s.startsWith("image/")?(i?.onSelect(n),e?.ui.closePanel(tr(t))):e.ui.showNotification({type:"warning",message:`Only images are supported. Found '${s}'. Please choose a different image.`})}})})}function tr(t){return`ly.img.ai/${t}.imageSelection`}var Ia=xa;function Ea(){return async(t,e,r)=>{console.group("[GENERATION]"),console.log("Generating with input:",JSON.stringify(t,null,2));let i,n=Date.now();try{return i=await r(t,e),i}finally{i!=null&&(console.log(`Generation took ${Date.now()-n}ms`),console.log("Generation result:",JSON.stringify(i,null,2))),console.groupEnd()}}}var en=Ea;var _a=typeof global=="object"&&global&&global.Object===Object&&global,tn=_a,Aa=typeof self=="object"&&self&&self.Object===Object&&self,Sa=tn||Aa||Function("return this")(),q=Sa,Ca=q.Symbol,ae=Ca,rn=Object.prototype,Ta=rn.hasOwnProperty,Ma=rn.toString,Te=ae?ae.toStringTag:void 0;function Oa(t){var e=Ta.call(t,Te),r=t[Te];try{t[Te]=void 0;var i=!0}catch{}var n=Ma.call(t);return i&&(e?t[Te]=r:delete t[Te]),n}var ja=Oa,Pa=Object.prototype,Da=Pa.toString;function Ua(t){return Da.call(t)}var $a=Ua,La="[object Null]",Na="[object Undefined]",qi=ae?ae.toStringTag:void 0;function qa(t){return t==null?t===void 0?Na:La:qi&&qi in Object(t)?ja(t):$a(t)}var De=qa;function Ba(t){return t!=null&&typeof t=="object"}var ar=Ba,dh=Array.isArray;function Fa(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var nn=Fa,Ra="[object AsyncFunction]",Va="[object Function]",za="[object GeneratorFunction]",Ha="[object Proxy]";function Qa(t){if(!nn(t))return!1;var e=De(t);return e==Va||e==za||e==Ra||e==Ha}var Ga=Qa,Ka=q["__core-js_shared__"],Xt=Ka,Bi=function(){var t=/[^.]+$/.exec(Xt&&Xt.keys&&Xt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Wa(t){return!!Bi&&Bi in t}var Ya=Wa,Za=Function.prototype,Xa=Za.toString;function Ja(t){if(t!=null){try{return Xa.call(t)}catch{}try{return t+""}catch{}}return""}var ee=Ja,el=/[\\^$.*+?()[\]{}|]/g,tl=/^\[object .+?Constructor\]$/,rl=Function.prototype,il=Object.prototype,nl=rl.toString,ol=il.hasOwnProperty,sl=RegExp("^"+nl.call(ol).replace(el,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function al(t){if(!nn(t)||Ya(t))return!1;var e=Ga(t)?sl:tl;return e.test(ee(t))}var ll=al;function cl(t,e){return t?.[e]}var ul=cl;function dl(t,e){var r=ul(t,e);return ll(r)?r:void 0}var le=dl,pl=le(q,"WeakMap"),rr=pl;function fl(t,e){return t===e||t!==t&&e!==e}var hl=fl,gl=9007199254740991;function ml(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=gl}var yl=ml,ph=Object.prototype,bl="[object Arguments]";function vl(t){return ar(t)&&De(t)==bl}var Fi=vl,on=Object.prototype,wl=on.hasOwnProperty,xl=on.propertyIsEnumerable,fh=Fi(function(){return arguments}())?Fi:function(t){return ar(t)&&wl.call(t,"callee")&&!xl.call(t,"callee")},sn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ri=sn&&typeof module=="object"&&module&&!module.nodeType&&module,kl=Ri&&Ri.exports===sn,Vi=kl?q.Buffer:void 0,hh=Vi?Vi.isBuffer:void 0,Il="[object Arguments]",El="[object Array]",_l="[object Boolean]",Al="[object Date]",Sl="[object Error]",Cl="[object Function]",Tl="[object Map]",Ml="[object Number]",Ol="[object Object]",jl="[object RegExp]",Pl="[object Set]",Dl="[object String]",Ul="[object WeakMap]",$l="[object ArrayBuffer]",Ll="[object DataView]",Nl="[object Float32Array]",ql="[object Float64Array]",Bl="[object Int8Array]",Fl="[object Int16Array]",Rl="[object Int32Array]",Vl="[object Uint8Array]",zl="[object Uint8ClampedArray]",Hl="[object Uint16Array]",Ql="[object Uint32Array]",k={};k[Nl]=k[ql]=k[Bl]=k[Fl]=k[Rl]=k[Vl]=k[zl]=k[Hl]=k[Ql]=!0;k[Il]=k[El]=k[$l]=k[_l]=k[Ll]=k[Al]=k[Sl]=k[Cl]=k[Tl]=k[Ml]=k[Ol]=k[jl]=k[Pl]=k[Dl]=k[Ul]=!1;function Gl(t){return ar(t)&&yl(t.length)&&!!k[De(t)]}var Kl=Gl;function Wl(t){return function(e){return t(e)}}var Yl=Wl,an=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=an&&typeof module=="object"&&module&&!module.nodeType&&module,Zl=Oe&&Oe.exports===an,Jt=Zl&&tn.process,Xl=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||Jt&&Jt.binding&&Jt.binding("util")}catch{}}(),zi=Xl,Hi=zi&&zi.isTypedArray,gh=Hi?Yl(Hi):Kl,Jl=Object.prototype,mh=Jl.hasOwnProperty;function ec(t,e){return function(r){return t(e(r))}}var tc=ec,yh=tc(Object.keys,Object),rc=Object.prototype,bh=rc.hasOwnProperty,ic=le(Object,"create"),je=ic;function nc(){this.__data__=je?je(null):{},this.size=0}var oc=nc;function sc(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var ac=sc,lc="__lodash_hash_undefined__",cc=Object.prototype,uc=cc.hasOwnProperty;function dc(t){var e=this.__data__;if(je){var r=e[t];return r===lc?void 0:r}return uc.call(e,t)?e[t]:void 0}var pc=dc,fc=Object.prototype,hc=fc.hasOwnProperty;function gc(t){var e=this.__data__;return je?e[t]!==void 0:hc.call(e,t)}var mc=gc,yc="__lodash_hash_undefined__";function bc(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=je&&e===void 0?yc:e,this}var vc=bc;function ce(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ce.prototype.clear=oc;ce.prototype.delete=ac;ce.prototype.get=pc;ce.prototype.has=mc;ce.prototype.set=vc;var Qi=ce;function wc(){this.__data__=[],this.size=0}var xc=wc;function kc(t,e){for(var r=t.length;r--;)if(hl(t[r][0],e))return r;return-1}var dt=kc,Ic=Array.prototype,Ec=Ic.splice;function _c(t){var e=this.__data__,r=dt(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():Ec.call(e,r,1),--this.size,!0}var Ac=_c;function Sc(t){var e=this.__data__,r=dt(e,t);return r<0?void 0:e[r][1]}var Cc=Sc;function Tc(t){return dt(this.__data__,t)>-1}var Mc=Tc;function Oc(t,e){var r=this.__data__,i=dt(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var jc=Oc;function ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ue.prototype.clear=xc;ue.prototype.delete=Ac;ue.prototype.get=Cc;ue.prototype.has=Mc;ue.prototype.set=jc;var pt=ue,Pc=le(q,"Map"),Pe=Pc;function Dc(){this.size=0,this.__data__={hash:new Qi,map:new(Pe||pt),string:new Qi}}var Uc=Dc;function $c(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Lc=$c;function Nc(t,e){var r=t.__data__;return Lc(e)?r[typeof e=="string"?"string":"hash"]:r.map}var ft=Nc;function qc(t){var e=ft(this,t).delete(t);return this.size-=e?1:0,e}var Bc=qc;function Fc(t){return ft(this,t).get(t)}var Rc=Fc;function Vc(t){return ft(this,t).has(t)}var zc=Vc;function Hc(t,e){var r=ft(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var Qc=Hc;function de(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}de.prototype.clear=Uc;de.prototype.delete=Bc;de.prototype.get=Rc;de.prototype.has=zc;de.prototype.set=Qc;var ln=de;function Gc(){this.__data__=new pt,this.size=0}var Kc=Gc;function Wc(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Yc=Wc;function Zc(t){return this.__data__.get(t)}var Xc=Zc;function Jc(t){return this.__data__.has(t)}var eu=Jc,tu=200;function ru(t,e){var r=this.__data__;if(r instanceof pt){var i=r.__data__;if(!Pe||i.length<tu-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new ln(i)}return r.set(t,e),this.size=r.size,this}var iu=ru;function Ue(t){var e=this.__data__=new pt(t);this.size=e.size}Ue.prototype.clear=Kc;Ue.prototype.delete=Yc;Ue.prototype.get=Xc;Ue.prototype.has=eu;Ue.prototype.set=iu;var nu=Object.prototype,vh=nu.propertyIsEnumerable,ou=le(q,"DataView"),ir=ou,su=le(q,"Promise"),nr=su,au=le(q,"Set"),or=au,Gi="[object Map]",lu="[object Object]",Ki="[object Promise]",Wi="[object Set]",Yi="[object WeakMap]",Zi="[object DataView]",cu=ee(ir),uu=ee(Pe),du=ee(nr),pu=ee(or),fu=ee(rr),se=De;(ir&&se(new ir(new ArrayBuffer(1)))!=Zi||Pe&&se(new Pe)!=Gi||nr&&se(nr.resolve())!=Ki||or&&se(new or)!=Wi||rr&&se(new rr)!=Yi)&&(se=function(t){var e=De(t),r=e==lu?t.constructor:void 0,i=r?ee(r):"";if(i)switch(i){case cu:return Zi;case uu:return Gi;case du:return Ki;case pu:return Wi;case fu:return Yi}return e});var wh=q.Uint8Array,hu="__lodash_hash_undefined__";function gu(t){return this.__data__.set(t,hu),this}var mu=gu;function yu(t){return this.__data__.has(t)}var bu=yu;function sr(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new ln;++e<r;)this.add(t[e])}sr.prototype.add=sr.prototype.push=mu;sr.prototype.has=bu;var Xi=ae?ae.prototype:void 0,xh=Xi?Xi.valueOf:void 0,vu=Object.prototype,kh=vu.hasOwnProperty,wu=Object.prototype,Ih=wu.hasOwnProperty,Eh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),_h=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Ah=new RegExp(/[A-Fa-f0-9]{2}/,"g");var er="@imgly/plugin-ai-generation",Sh=`
6
6
  <svg>
7
7
  <symbol
8
8
  fill="none"
@@ -63,10 +63,10 @@ var Fn=Object.create;var br=Object.defineProperty;var Vn=Object.getOwnPropertyDe
63
63
 
64
64
  </symbol>
65
65
  </svg>
66
- `;var Ji="ly.img.ai.quickAction.order",Me="ly.img.ai.quickAction.actions";function xu(t,e){return{id:e,setQuickActionMenuOrder:r=>{t.ui.experimental.setGlobalStateValue(`${Ji}.${e}`,r)},getQuickActionMenuOrder:()=>t.ui.experimental.getGlobalStateValue(`${Ji}.${e}`,[]),registerQuickAction:r=>{if(!t.ui.experimental.hasGlobalStateValue(`${Me}.${e}`))t.ui.experimental.setGlobalStateValue(`${Me}.${e}`,{[r.id]:r});else{let i=t.ui.experimental.getGlobalStateValue(`${Me}.${e}`,{});t.ui.experimental.setGlobalStateValue(`${Me}.${e}`,{...i,[r.id]:r})}},getQuickAction:r=>t.ui.experimental.getGlobalStateValue(`${Me}.${e}`,{})[r]}}var cn=xu;function Eu(t){let e=t.quickAction.id;return{...t.quickAction,render:({builder:r},i)=>{r.Button(`${e}.button`,{label:`ly.img.ai.quickAction.${e}`,icon:"@imgly/Sparkle",labelAlignment:"left",variant:"plain",...t.buttonOptions,onClick:async()=>{try{t.onClick(i),i.closeMenu()}catch(n){i.handleGenerationError(n)}}})}}}var un=Eu;function Iu(){return({engine:t})=>{let e=t.block.findAllSelected();if(e==null||e.length!==1)return!1;let[r]=e;if(t.block.getType(r)!=="//ly.img.ubq/graphic"&&!t.block.supportsFill(r))return!1;let i=t.block.getFill(r);return t.block.getType(i)==="//ly.img.ubq/fill/image"}}var dn=Iu;var pn={ImageUrl:Ia};var lr=vr(Yt());function ku(t,e){let r=t.middleware??[];e.debug&&r.unshift(en());let i={id:t.modelKey,kind:"video",initialize:async n=>{lr.fal.config({proxyUrl:e.proxyUrl}),t.initialize?.(n)},input:{quickActions:{actions:t.quickActions??[]},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?pn.ImageUrl(t.modelKey,{cesdk:t.cesdk}):{},...t.renderCustomProperty},getBlockInput:t.getBlockInput,userFlow:t.useFlow??"placeholder"}},output:{abortable:!0,history:"@imgly/indexedDB",middleware:r,generate:async(n,{abortSignal:o})=>{let s=await Ni(n.image_url,t.cesdk),a=await lr.fal.subscribe(t.modelKey,{abortSignal:o,input:s!=null?{...n,image_url:s}:n,logs:!0}),l=a?.data?.video;if(l!=null){let u=l?.url;if(u!=null)return{kind:"video",url:u}}throw console.error("Cannot extract generated video from response:",a),new Error("Cannot find generated video")},generationHintText:"Video generation may take up to a few minutes. This panel can be closed and you'll be notified when it's ready."}};return e.debug&&console.log("Created Provider:",i),i}var pe=ku;function fn(t){return async({cesdk:e})=>_u(e,t)}function _u(t,e){return pe({modelKey:"fal-ai/minimax/video-01-live",schema:wr,inputReference:"#/components/schemas/MinimaxVideo01LiveInput",middleware:e.middleware,cesdk:t,getBlockInput:()=>Promise.resolve({video:{width:1280,height:720,duration:5}})},e)}var Au=typeof global=="object"&&global&&global.Object===Object&&global,Cn=Au,Su=typeof self=="object"&&self&&self.Object===Object&&self,Cu=Cn||Su||Function("return this")(),B=Cu,Tu=B.Symbol,he=Tu,Tn=Object.prototype,Mu=Tn.hasOwnProperty,Ou=Tn.toString,$e=he?he.toStringTag:void 0;function ju(t){var e=Mu.call(t,$e),r=t[$e];try{t[$e]=void 0;var i=!0}catch{}var n=Ou.call(t);return i&&(e?t[$e]=r:delete t[$e]),n}var Pu=ju,Du=Object.prototype,Uu=Du.toString;function $u(t){return Uu.call(t)}var Lu=$u,Nu="[object Null]",qu="[object Undefined]",hn=he?he.toStringTag:void 0;function Bu(t){return t==null?t===void 0?qu:Nu:hn&&hn in Object(t)?Pu(t):Lu(t)}var Be=Bu;function Ru(t){return t!=null&&typeof t=="object"}var mr=Ru,Rh=Array.isArray;function Fu(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Mn=Fu,Vu="[object AsyncFunction]",zu="[object Function]",Hu="[object GeneratorFunction]",Qu="[object Proxy]";function Gu(t){if(!Mn(t))return!1;var e=Be(t);return e==zu||e==Hu||e==Vu||e==Qu}var Ku=Gu,Wu=B["__core-js_shared__"],cr=Wu,gn=function(){var t=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Yu(t){return!!gn&&gn in t}var Zu=Yu,Xu=Function.prototype,Ju=Xu.toString;function ed(t){if(t!=null){try{return Ju.call(t)}catch{}try{return t+""}catch{}}return""}var te=ed,td=/[\\^$.*+?()[\]{}|]/g,rd=/^\[object .+?Constructor\]$/,id=Function.prototype,nd=Object.prototype,od=id.toString,sd=nd.hasOwnProperty,ad=RegExp("^"+od.call(sd).replace(td,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ld(t){if(!Mn(t)||Zu(t))return!1;var e=Ku(t)?ad:rd;return e.test(te(t))}var cd=ld;function ud(t,e){return t?.[e]}var dd=ud;function pd(t,e){var r=dd(t,e);return cd(r)?r:void 0}var ge=pd,fd=ge(B,"WeakMap"),dr=fd;function hd(t,e){return t===e||t!==t&&e!==e}var gd=hd,md=9007199254740991;function yd(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=md}var bd=yd;var Fh=Object.prototype;var vd="[object Arguments]";function wd(t){return mr(t)&&Be(t)==vd}var mn=wd,On=Object.prototype,xd=On.hasOwnProperty,Ed=On.propertyIsEnumerable,Vh=mn(function(){return arguments}())?mn:function(t){return mr(t)&&xd.call(t,"callee")&&!Ed.call(t,"callee")};var jn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yn=jn&&typeof module=="object"&&module&&!module.nodeType&&module,Id=yn&&yn.exports===jn,bn=Id?B.Buffer:void 0,zh=bn?bn.isBuffer:void 0;var kd="[object Arguments]",_d="[object Array]",Ad="[object Boolean]",Sd="[object Date]",Cd="[object Error]",Td="[object Function]",Md="[object Map]",Od="[object Number]",jd="[object Object]",Pd="[object RegExp]",Dd="[object Set]",Ud="[object String]",$d="[object WeakMap]",Ld="[object ArrayBuffer]",Nd="[object DataView]",qd="[object Float32Array]",Bd="[object Float64Array]",Rd="[object Int8Array]",Fd="[object Int16Array]",Vd="[object Int32Array]",zd="[object Uint8Array]",Hd="[object Uint8ClampedArray]",Qd="[object Uint16Array]",Gd="[object Uint32Array]",I={};I[qd]=I[Bd]=I[Rd]=I[Fd]=I[Vd]=I[zd]=I[Hd]=I[Qd]=I[Gd]=!0;I[kd]=I[_d]=I[Ld]=I[Ad]=I[Nd]=I[Sd]=I[Cd]=I[Td]=I[Md]=I[Od]=I[jd]=I[Pd]=I[Dd]=I[Ud]=I[$d]=!1;function Kd(t){return mr(t)&&bd(t.length)&&!!I[Be(t)]}var Wd=Kd;function Yd(t){return function(e){return t(e)}}var Zd=Yd,Pn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Le=Pn&&typeof module=="object"&&module&&!module.nodeType&&module,Xd=Le&&Le.exports===Pn,ur=Xd&&Cn.process,Jd=function(){try{var t=Le&&Le.require&&Le.require("util").types;return t||ur&&ur.binding&&ur.binding("util")}catch{}}(),vn=Jd,wn=vn&&vn.isTypedArray,Hh=wn?Zd(wn):Wd;var ep=Object.prototype,Qh=ep.hasOwnProperty;function tp(t,e){return function(r){return t(e(r))}}var rp=tp,Gh=rp(Object.keys,Object);var ip=Object.prototype,Kh=ip.hasOwnProperty;var np=ge(Object,"create"),Ne=np;function op(){this.__data__=Ne?Ne(null):{},this.size=0}var sp=op;function ap(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var lp=ap,cp="__lodash_hash_undefined__",up=Object.prototype,dp=up.hasOwnProperty;function pp(t){var e=this.__data__;if(Ne){var r=e[t];return r===cp?void 0:r}return dp.call(e,t)?e[t]:void 0}var fp=pp,hp=Object.prototype,gp=hp.hasOwnProperty;function mp(t){var e=this.__data__;return Ne?e[t]!==void 0:gp.call(e,t)}var yp=mp,bp="__lodash_hash_undefined__";function vp(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ne&&e===void 0?bp:e,this}var wp=vp;function me(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}me.prototype.clear=sp;me.prototype.delete=lp;me.prototype.get=fp;me.prototype.has=yp;me.prototype.set=wp;var xn=me;function xp(){this.__data__=[],this.size=0}var Ep=xp;function Ip(t,e){for(var r=t.length;r--;)if(gd(t[r][0],e))return r;return-1}var ht=Ip,kp=Array.prototype,_p=kp.splice;function Ap(t){var e=this.__data__,r=ht(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():_p.call(e,r,1),--this.size,!0}var Sp=Ap;function Cp(t){var e=this.__data__,r=ht(e,t);return r<0?void 0:e[r][1]}var Tp=Cp;function Mp(t){return ht(this.__data__,t)>-1}var Op=Mp;function jp(t,e){var r=this.__data__,i=ht(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var Pp=jp;function ye(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ye.prototype.clear=Ep;ye.prototype.delete=Sp;ye.prototype.get=Tp;ye.prototype.has=Op;ye.prototype.set=Pp;var gt=ye,Dp=ge(B,"Map"),qe=Dp;function Up(){this.size=0,this.__data__={hash:new xn,map:new(qe||gt),string:new xn}}var $p=Up;function Lp(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Np=Lp;function qp(t,e){var r=t.__data__;return Np(e)?r[typeof e=="string"?"string":"hash"]:r.map}var mt=qp;function Bp(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e}var Rp=Bp;function Fp(t){return mt(this,t).get(t)}var Vp=Fp;function zp(t){return mt(this,t).has(t)}var Hp=zp;function Qp(t,e){var r=mt(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var Gp=Qp;function be(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}be.prototype.clear=$p;be.prototype.delete=Rp;be.prototype.get=Vp;be.prototype.has=Hp;be.prototype.set=Gp;var Dn=be;function Kp(){this.__data__=new gt,this.size=0}var Wp=Kp;function Yp(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Zp=Yp;function Xp(t){return this.__data__.get(t)}var Jp=Xp;function ef(t){return this.__data__.has(t)}var tf=ef,rf=200;function nf(t,e){var r=this.__data__;if(r instanceof gt){var i=r.__data__;if(!qe||i.length<rf-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Dn(i)}return r.set(t,e),this.size=r.size,this}var of=nf;function Re(t){var e=this.__data__=new gt(t);this.size=e.size}Re.prototype.clear=Wp;Re.prototype.delete=Zp;Re.prototype.get=Jp;Re.prototype.has=tf;Re.prototype.set=of;var sf=Object.prototype,Wh=sf.propertyIsEnumerable;var af=ge(B,"DataView"),pr=af,lf=ge(B,"Promise"),fr=lf,cf=ge(B,"Set"),hr=cf,En="[object Map]",uf="[object Object]",In="[object Promise]",kn="[object Set]",_n="[object WeakMap]",An="[object DataView]",df=te(pr),pf=te(qe),ff=te(fr),hf=te(hr),gf=te(dr),fe=Be;(pr&&fe(new pr(new ArrayBuffer(1)))!=An||qe&&fe(new qe)!=En||fr&&fe(fr.resolve())!=In||hr&&fe(new hr)!=kn||dr&&fe(new dr)!=_n)&&(fe=function(t){var e=Be(t),r=e==uf?t.constructor:void 0,i=r?te(r):"";if(i)switch(i){case df:return An;case pf:return En;case ff:return In;case hf:return kn;case gf:return _n}return e});var Yh=B.Uint8Array;var mf="__lodash_hash_undefined__";function yf(t){return this.__data__.set(t,mf),this}var bf=yf;function vf(t){return this.__data__.has(t)}var wf=vf;function gr(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Dn;++e<r;)this.add(t[e])}gr.prototype.add=gr.prototype.push=bf;gr.prototype.has=wf;var Sn=he?he.prototype:void 0,Zh=Sn?Sn.valueOf:void 0;var xf=Object.prototype,Xh=xf.hasOwnProperty;var Ef=Object.prototype,Jh=Ef.hasOwnProperty;var eg=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),tg=new RegExp(/[A-Fa-f0-9]{1}/,"g"),rg=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function Un(t,e){if(t.startsWith("buffer:")){let r=await e.editor.getMimeType(t),i=e.editor.getBufferLength(t),n=e.editor.getBufferData(t,0,i),o=new Blob([n],{type:r});return URL.createObjectURL(o)}else return t}async function $n(t,e){let r=await Un(t,e);return new Promise((i,n)=>{let o=new Image;o.onload=()=>{i({width:o.width,height:o.height})},o.onerror=n,o.src=r})}async function Ln(t,e,r){let i,n=e.block.getFill(t),o=e.block.getSourceSet(n,"fill/image/sourceSet"),[s]=o;if(s==null){if(i=e.block.getString(n,"fill/image/imageFileURI"),i==null)throw new Error("No image source/uri found")}else i=s.uri;if(r?.throwErrorIfSvg&&await e.editor.getMimeType(i)==="image/svg+xml")throw new Error("SVG images are not supported");return Un(i,e)}var Nn={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"]},MinimaxVideo01LiveImageToVideoInput:{title:"ImageToVideoRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0},image_url:{title:"Image Url",type:"string",description:"URL of the image to use as the first frame"}},"x-fal-order-properties":["image_url","prompt"],required:["prompt","image_url"]},MinimaxVideo01LiveImageToVideoOutput:{title:"I2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/image-to-video/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/MinimaxVideo01LiveImageToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function qn(t){return async({cesdk:e})=>kf(e,t)}function kf(t,e){let r=_f(t),i=cn(t,"image");return i.setQuickActionMenuOrder([...i.getQuickActionMenuOrder(),"ly.img.separator","createVideo"]),pe({modelKey:"fal-ai/minimax/video-01-live/image-to-video",schema:Nn,inputReference:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput",cesdk:t,middleware:e.middleware,quickActions:r,getBlockInput:async n=>{let o=await $n(n.image_url,t.engine);return Promise.resolve({video:{width:o.width??1280,height:o.height??720,duration:5}})}},e)}function _f(t){return t.i18n.setTranslations({en:{"ly.img.ai.quickAction.createVideo":"Create Video..."}}),[un({quickAction:{id:"createVideo",kind:"image",version:"1",enable:dn()},buttonOptions:{icon:"@imgly/plugin-ai-generation/video"},onClick:async()=>{let[e]=t.engine.block.findAllSelected(),r=await Ln(e,t.engine,{throwErrorIfSvg:!0});t.ui.openPanel("ly.img.ai/video-generation"),t.ui.experimental.setGlobalStateValue("ly.img.ai.video-generation.fromType","fromImage"),t.ui.experimental.setGlobalStateValue("fal-ai/minimax/video-01-live/image-to-video.image_url",r)}})]}var Bn={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"]},PixverseV35TextToVideoInput:{title:"TextToVideoRequest",type:"object",properties:{prompt:{maxLength:2048,type:"string",title:"Prompt","x-imgly-builder":{component:"TextArea"}},aspect_ratio:{enum:["16:9","4:3","1:1","3:4","9:16"],title:"Aspect Ratio",type:"string",description:"The aspect ratio of the generated video",default:"16:9"},resolution:{enum:["360p","540p","720p","1080p"],title:"Resolution",type:"string",description:"The resolution of the generated video",default:"720p"},style:{enum:["anime","3d_animation","clay","comic","cyberpunk"],title:"Style",type:"string",description:"The style of the generated video"},duration:{enum:["5","8"],title:"Duration",type:"string",description:"The duration of the generated video in seconds. 8s videos cost double. 1080p videos are limited to 5 seconds",default:5},seed:{title:"Seed",type:"integer",description:`
66
+ `;var Ji="ly.img.ai.quickAction.order",Me="ly.img.ai.quickAction.actions";function xu(t,e){return{id:e,setQuickActionMenuOrder:r=>{t.ui.experimental.setGlobalStateValue(`${Ji}.${e}`,r)},getQuickActionMenuOrder:()=>t.ui.experimental.getGlobalStateValue(`${Ji}.${e}`,[]),registerQuickAction:r=>{if(!t.ui.experimental.hasGlobalStateValue(`${Me}.${e}`))t.ui.experimental.setGlobalStateValue(`${Me}.${e}`,{[r.id]:r});else{let i=t.ui.experimental.getGlobalStateValue(`${Me}.${e}`,{});t.ui.experimental.setGlobalStateValue(`${Me}.${e}`,{...i,[r.id]:r})}},getQuickAction:r=>t.ui.experimental.getGlobalStateValue(`${Me}.${e}`,{})[r]}}var cn=xu;function ku(t){let e=t.quickAction.id;return{confirmation:!0,lockDuringConfirmation:!1,...t.quickAction,render:({builder:r},i)=>{r.Button(`${e}.button`,{label:`ly.img.ai.quickAction.${e}`,icon:"@imgly/Sparkle",labelAlignment:"left",variant:"plain",...t.buttonOptions,onClick:async()=>{try{t.onClick(i),i.closeMenu()}catch(n){i.handleGenerationError(n)}}})}}}var un=ku;function Iu(){return({engine:t})=>{let e=t.block.findAllSelected();if(e==null||e.length!==1)return!1;let[r]=e;if(t.block.getType(r)!=="//ly.img.ubq/graphic"&&!t.block.supportsFill(r))return!1;let i=t.block.getFill(r);return t.block.getType(i)==="//ly.img.ubq/fill/image"}}var dn=Iu;var pn={ImageUrl:Ia};var lr=vr(Yt());function Eu(t,e){let r=t.middleware??[];e.debug&&r.unshift(en());let i={id:t.modelKey,kind:"video",initialize:async n=>{lr.fal.config({proxyUrl:e.proxyUrl}),t.initialize?.(n)},input:{quickActions:{actions:t.quickActions??[]},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?pn.ImageUrl(t.modelKey,{cesdk:t.cesdk}):{},...t.renderCustomProperty},getBlockInput:t.getBlockInput,userFlow:t.useFlow??"placeholder"}},output:{abortable:!0,history:"@imgly/indexedDB",middleware:r,generate:async(n,{abortSignal:o})=>{let s=await Ni(n.image_url,t.cesdk),a=await lr.fal.subscribe(t.modelKey,{abortSignal:o,input:s!=null?{...n,image_url:s}:n,logs:!0}),l=a?.data?.video;if(l!=null){let u=l?.url;if(u!=null)return{kind:"video",url:u}}throw console.error("Cannot extract generated video from response:",a),new Error("Cannot find generated video")},generationHintText:"Video generation may take up to a few minutes. This panel can be closed and you'll be notified when it's ready."}};return e.debug&&console.log("Created Provider:",i),i}var pe=Eu;function fn(t){return async({cesdk:e})=>_u(e,t)}function _u(t,e){return pe({modelKey:"fal-ai/minimax/video-01-live",schema:wr,inputReference:"#/components/schemas/MinimaxVideo01LiveInput",middleware:e.middleware,cesdk:t,getBlockInput:()=>Promise.resolve({video:{width:1280,height:720,duration:5}})},e)}var Au=typeof global=="object"&&global&&global.Object===Object&&global,Cn=Au,Su=typeof self=="object"&&self&&self.Object===Object&&self,Cu=Cn||Su||Function("return this")(),B=Cu,Tu=B.Symbol,he=Tu,Tn=Object.prototype,Mu=Tn.hasOwnProperty,Ou=Tn.toString,$e=he?he.toStringTag:void 0;function ju(t){var e=Mu.call(t,$e),r=t[$e];try{t[$e]=void 0;var i=!0}catch{}var n=Ou.call(t);return i&&(e?t[$e]=r:delete t[$e]),n}var Pu=ju,Du=Object.prototype,Uu=Du.toString;function $u(t){return Uu.call(t)}var Lu=$u,Nu="[object Null]",qu="[object Undefined]",hn=he?he.toStringTag:void 0;function Bu(t){return t==null?t===void 0?qu:Nu:hn&&hn in Object(t)?Pu(t):Lu(t)}var Be=Bu;function Fu(t){return t!=null&&typeof t=="object"}var mr=Fu,Fh=Array.isArray;function Ru(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Mn=Ru,Vu="[object AsyncFunction]",zu="[object Function]",Hu="[object GeneratorFunction]",Qu="[object Proxy]";function Gu(t){if(!Mn(t))return!1;var e=Be(t);return e==zu||e==Hu||e==Vu||e==Qu}var Ku=Gu,Wu=B["__core-js_shared__"],cr=Wu,gn=function(){var t=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Yu(t){return!!gn&&gn in t}var Zu=Yu,Xu=Function.prototype,Ju=Xu.toString;function ed(t){if(t!=null){try{return Ju.call(t)}catch{}try{return t+""}catch{}}return""}var te=ed,td=/[\\^$.*+?()[\]{}|]/g,rd=/^\[object .+?Constructor\]$/,id=Function.prototype,nd=Object.prototype,od=id.toString,sd=nd.hasOwnProperty,ad=RegExp("^"+od.call(sd).replace(td,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ld(t){if(!Mn(t)||Zu(t))return!1;var e=Ku(t)?ad:rd;return e.test(te(t))}var cd=ld;function ud(t,e){return t?.[e]}var dd=ud;function pd(t,e){var r=dd(t,e);return cd(r)?r:void 0}var ge=pd,fd=ge(B,"WeakMap"),dr=fd;function hd(t,e){return t===e||t!==t&&e!==e}var gd=hd,md=9007199254740991;function yd(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=md}var bd=yd;var Rh=Object.prototype;var vd="[object Arguments]";function wd(t){return mr(t)&&Be(t)==vd}var mn=wd,On=Object.prototype,xd=On.hasOwnProperty,kd=On.propertyIsEnumerable,Vh=mn(function(){return arguments}())?mn:function(t){return mr(t)&&xd.call(t,"callee")&&!kd.call(t,"callee")};var jn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yn=jn&&typeof module=="object"&&module&&!module.nodeType&&module,Id=yn&&yn.exports===jn,bn=Id?B.Buffer:void 0,zh=bn?bn.isBuffer:void 0;var Ed="[object Arguments]",_d="[object Array]",Ad="[object Boolean]",Sd="[object Date]",Cd="[object Error]",Td="[object Function]",Md="[object Map]",Od="[object Number]",jd="[object Object]",Pd="[object RegExp]",Dd="[object Set]",Ud="[object String]",$d="[object WeakMap]",Ld="[object ArrayBuffer]",Nd="[object DataView]",qd="[object Float32Array]",Bd="[object Float64Array]",Fd="[object Int8Array]",Rd="[object Int16Array]",Vd="[object Int32Array]",zd="[object Uint8Array]",Hd="[object Uint8ClampedArray]",Qd="[object Uint16Array]",Gd="[object Uint32Array]",I={};I[qd]=I[Bd]=I[Fd]=I[Rd]=I[Vd]=I[zd]=I[Hd]=I[Qd]=I[Gd]=!0;I[Ed]=I[_d]=I[Ld]=I[Ad]=I[Nd]=I[Sd]=I[Cd]=I[Td]=I[Md]=I[Od]=I[jd]=I[Pd]=I[Dd]=I[Ud]=I[$d]=!1;function Kd(t){return mr(t)&&bd(t.length)&&!!I[Be(t)]}var Wd=Kd;function Yd(t){return function(e){return t(e)}}var Zd=Yd,Pn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Le=Pn&&typeof module=="object"&&module&&!module.nodeType&&module,Xd=Le&&Le.exports===Pn,ur=Xd&&Cn.process,Jd=function(){try{var t=Le&&Le.require&&Le.require("util").types;return t||ur&&ur.binding&&ur.binding("util")}catch{}}(),vn=Jd,wn=vn&&vn.isTypedArray,Hh=wn?Zd(wn):Wd;var ep=Object.prototype,Qh=ep.hasOwnProperty;function tp(t,e){return function(r){return t(e(r))}}var rp=tp,Gh=rp(Object.keys,Object);var ip=Object.prototype,Kh=ip.hasOwnProperty;var np=ge(Object,"create"),Ne=np;function op(){this.__data__=Ne?Ne(null):{},this.size=0}var sp=op;function ap(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var lp=ap,cp="__lodash_hash_undefined__",up=Object.prototype,dp=up.hasOwnProperty;function pp(t){var e=this.__data__;if(Ne){var r=e[t];return r===cp?void 0:r}return dp.call(e,t)?e[t]:void 0}var fp=pp,hp=Object.prototype,gp=hp.hasOwnProperty;function mp(t){var e=this.__data__;return Ne?e[t]!==void 0:gp.call(e,t)}var yp=mp,bp="__lodash_hash_undefined__";function vp(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ne&&e===void 0?bp:e,this}var wp=vp;function me(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}me.prototype.clear=sp;me.prototype.delete=lp;me.prototype.get=fp;me.prototype.has=yp;me.prototype.set=wp;var xn=me;function xp(){this.__data__=[],this.size=0}var kp=xp;function Ip(t,e){for(var r=t.length;r--;)if(gd(t[r][0],e))return r;return-1}var ht=Ip,Ep=Array.prototype,_p=Ep.splice;function Ap(t){var e=this.__data__,r=ht(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():_p.call(e,r,1),--this.size,!0}var Sp=Ap;function Cp(t){var e=this.__data__,r=ht(e,t);return r<0?void 0:e[r][1]}var Tp=Cp;function Mp(t){return ht(this.__data__,t)>-1}var Op=Mp;function jp(t,e){var r=this.__data__,i=ht(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var Pp=jp;function ye(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ye.prototype.clear=kp;ye.prototype.delete=Sp;ye.prototype.get=Tp;ye.prototype.has=Op;ye.prototype.set=Pp;var gt=ye,Dp=ge(B,"Map"),qe=Dp;function Up(){this.size=0,this.__data__={hash:new xn,map:new(qe||gt),string:new xn}}var $p=Up;function Lp(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Np=Lp;function qp(t,e){var r=t.__data__;return Np(e)?r[typeof e=="string"?"string":"hash"]:r.map}var mt=qp;function Bp(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e}var Fp=Bp;function Rp(t){return mt(this,t).get(t)}var Vp=Rp;function zp(t){return mt(this,t).has(t)}var Hp=zp;function Qp(t,e){var r=mt(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var Gp=Qp;function be(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}be.prototype.clear=$p;be.prototype.delete=Fp;be.prototype.get=Vp;be.prototype.has=Hp;be.prototype.set=Gp;var Dn=be;function Kp(){this.__data__=new gt,this.size=0}var Wp=Kp;function Yp(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Zp=Yp;function Xp(t){return this.__data__.get(t)}var Jp=Xp;function ef(t){return this.__data__.has(t)}var tf=ef,rf=200;function nf(t,e){var r=this.__data__;if(r instanceof gt){var i=r.__data__;if(!qe||i.length<rf-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Dn(i)}return r.set(t,e),this.size=r.size,this}var of=nf;function Fe(t){var e=this.__data__=new gt(t);this.size=e.size}Fe.prototype.clear=Wp;Fe.prototype.delete=Zp;Fe.prototype.get=Jp;Fe.prototype.has=tf;Fe.prototype.set=of;var sf=Object.prototype,Wh=sf.propertyIsEnumerable;var af=ge(B,"DataView"),pr=af,lf=ge(B,"Promise"),fr=lf,cf=ge(B,"Set"),hr=cf,kn="[object Map]",uf="[object Object]",In="[object Promise]",En="[object Set]",_n="[object WeakMap]",An="[object DataView]",df=te(pr),pf=te(qe),ff=te(fr),hf=te(hr),gf=te(dr),fe=Be;(pr&&fe(new pr(new ArrayBuffer(1)))!=An||qe&&fe(new qe)!=kn||fr&&fe(fr.resolve())!=In||hr&&fe(new hr)!=En||dr&&fe(new dr)!=_n)&&(fe=function(t){var e=Be(t),r=e==uf?t.constructor:void 0,i=r?te(r):"";if(i)switch(i){case df:return An;case pf:return kn;case ff:return In;case hf:return En;case gf:return _n}return e});var Yh=B.Uint8Array;var mf="__lodash_hash_undefined__";function yf(t){return this.__data__.set(t,mf),this}var bf=yf;function vf(t){return this.__data__.has(t)}var wf=vf;function gr(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Dn;++e<r;)this.add(t[e])}gr.prototype.add=gr.prototype.push=bf;gr.prototype.has=wf;var Sn=he?he.prototype:void 0,Zh=Sn?Sn.valueOf:void 0;var xf=Object.prototype,Xh=xf.hasOwnProperty;var kf=Object.prototype,Jh=kf.hasOwnProperty;var eg=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),tg=new RegExp(/[A-Fa-f0-9]{1}/,"g"),rg=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function Un(t,e){if(t.startsWith("buffer:")){let r=await e.editor.getMimeType(t),i=e.editor.getBufferLength(t),n=e.editor.getBufferData(t,0,i),o=new Blob([n],{type:r});return URL.createObjectURL(o)}else return t}async function $n(t,e){let r=await Un(t,e);return new Promise((i,n)=>{let o=new Image;o.onload=()=>{i({width:o.width,height:o.height})},o.onerror=n,o.src=r})}async function Ln(t,e,r){let i,n=e.block.getFill(t),o=e.block.getSourceSet(n,"fill/image/sourceSet"),[s]=o;if(s==null){if(i=e.block.getString(n,"fill/image/imageFileURI"),i==null)throw new Error("No image source/uri found")}else i=s.uri;if(r?.throwErrorIfSvg&&await e.editor.getMimeType(i)==="image/svg+xml")throw new Error("SVG images are not supported");return Un(i,e)}var Nn={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"]},MinimaxVideo01LiveImageToVideoInput:{title:"ImageToVideoRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0},image_url:{title:"Image Url",type:"string",description:"URL of the image to use as the first frame"}},"x-fal-order-properties":["image_url","prompt"],required:["prompt","image_url"]},MinimaxVideo01LiveImageToVideoOutput:{title:"I2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/image-to-video/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/MinimaxVideo01LiveImageToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function qn(t){return async({cesdk:e})=>Ef(e,t)}function Ef(t,e){let r=_f(t),i=cn(t,"image");return i.setQuickActionMenuOrder([...i.getQuickActionMenuOrder(),"ly.img.separator","createVideo"]),pe({modelKey:"fal-ai/minimax/video-01-live/image-to-video",schema:Nn,inputReference:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput",cesdk:t,middleware:e.middleware,quickActions:r,getBlockInput:async n=>{let o=await $n(n.image_url,t.engine);return Promise.resolve({video:{width:o.width??1280,height:o.height??720,duration:5}})}},e)}function _f(t){return t.i18n.setTranslations({en:{"ly.img.ai.quickAction.createVideo":"Create Video..."}}),[un({quickAction:{id:"createVideo",kind:"image",version:"1",enable:dn()},buttonOptions:{icon:"@imgly/plugin-ai-generation/video"},onClick:async()=>{let[e]=t.engine.block.findAllSelected(),r=await Ln(e,t.engine,{throwErrorIfSvg:!0});t.ui.openPanel("ly.img.ai/video-generation"),t.ui.experimental.setGlobalStateValue("ly.img.ai.video-generation.fromType","fromImage"),t.ui.experimental.setGlobalStateValue("fal-ai/minimax/video-01-live/image-to-video.image_url",r)}})]}var Bn={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"]},PixverseV35TextToVideoInput:{title:"TextToVideoRequest",type:"object",properties:{prompt:{maxLength:2048,type:"string",title:"Prompt","x-imgly-builder":{component:"TextArea"}},aspect_ratio:{enum:["16:9","4:3","1:1","3:4","9:16"],title:"Aspect Ratio",type:"string",description:"The aspect ratio of the generated video",default:"16:9"},resolution:{enum:["360p","540p","720p","1080p"],title:"Resolution",type:"string",description:"The resolution of the generated video",default:"720p"},style:{enum:["anime","3d_animation","clay","comic","cyberpunk"],title:"Style",type:"string",description:"The style of the generated video"},duration:{enum:["5","8"],title:"Duration",type:"string",description:"The duration of the generated video in seconds. 8s videos cost double. 1080p videos are limited to 5 seconds",default:5},seed:{title:"Seed",type:"integer",description:`
67
67
  The same seed and the same prompt given to the same version of the model
68
68
  will output the same video every time.
69
- `},negative_prompt:{maxLength:2048,type:"string",title:"Negative Prompt",description:"Negative prompt to be used for the generation",default:""}},"x-fal-order-properties":["prompt","aspect_ratio","resolution","style","duration"],required:["prompt"]},PixverseV35TextToVideoOutput:{title:"VideoOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/pixverse/v3.5/text-to-video/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/pixverse/v3.5/text-to-video/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/pixverse/v3.5/text-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/PixverseV35TextToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/pixverse/v3.5/text-to-video/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/PixverseV35TextToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Rn(t){return async({cesdk:e})=>Sf(e,t)}function Sf(t,e){return pe({modelKey:"fal-ai/pixverse/v3.5/text-to-video",schema:Bn,inputReference:"#/components/schemas/PixverseV35TextToVideoInput",cesdk:t,middleware:e.middleware,getBlockInput:r=>{if(r.aspect_ratio!=null&&r.resolution!=null){let[i,n]=r.aspect_ratio.split(":").map(Number),o=parseInt(r.resolution,10),s=Math.round(o*i/n);if(r.duration!=null){let a=typeof r.duration=="string"?parseInt(r.duration,10):r.duration;return Promise.resolve({video:{width:s,height:o,duration:a}})}throw new Error("Cannot determine video duration")}else throw new Error("Cannot determine video dimensions \u2013 aspect ratio and resolution must be set")}},e)}var Cf={MinimaxVideo01Live:fn,MinimaxVideo01LiveImageToVideo:qn,PixverseV35TextToVideo:Rn},wg=Cf;export{wg as default};
69
+ `},negative_prompt:{maxLength:2048,type:"string",title:"Negative Prompt",description:"Negative prompt to be used for the generation",default:""}},"x-fal-order-properties":["prompt","aspect_ratio","resolution","style","duration"],required:["prompt"]},PixverseV35TextToVideoOutput:{title:"VideoOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/pixverse/v3.5/text-to-video/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/pixverse/v3.5/text-to-video/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/pixverse/v3.5/text-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/PixverseV35TextToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/pixverse/v3.5/text-to-video/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/PixverseV35TextToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Fn(t){return async({cesdk:e})=>Sf(e,t)}function Sf(t,e){return pe({modelKey:"fal-ai/pixverse/v3.5/text-to-video",schema:Bn,inputReference:"#/components/schemas/PixverseV35TextToVideoInput",cesdk:t,middleware:e.middleware,getBlockInput:r=>{if(r.aspect_ratio!=null&&r.resolution!=null){let[i,n]=r.aspect_ratio.split(":").map(Number),o=parseInt(r.resolution,10),s=Math.round(o*i/n);if(r.duration!=null){let a=typeof r.duration=="string"?parseInt(r.duration,10):r.duration;return Promise.resolve({video:{width:s,height:o,duration:a}})}throw new Error("Cannot determine video duration")}else throw new Error("Cannot determine video dimensions \u2013 aspect ratio and resolution must be set")}},e)}var Cf={MinimaxVideo01Live:fn,MinimaxVideo01LiveImageToVideo:qn,PixverseV35TextToVideo:Fn},wg=Cf;export{wg as default};
70
70
  /*! Bundled license information:
71
71
 
72
72
  @imgly/plugin-ai-generation-web/dist/index.mjs: