@animaapp/anima-sdk-react 0.2.3 → 0.2.4

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,13 +1,13 @@
1
1
 
2
- vite v6.0.11 building for production...
3
- transforming (1) src/index.ts../node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs (1:0): Module level directives cause errors when bundled, "use client" in "../node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs" was ignored.
2
+ vite v6.0.11 building for production...
3
+ transforming (1) src/index.ts../node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs (1:0): Module level directives cause errors when bundled, "use client" in "../node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs" was ignored.
4
4
  ✓ 25 modules transformed.
5
5
  rendering chunks (1)...
6
6
  [vite:dts] Start generate declaration files...
7
- computing gzip size (0)...computing gzip size (1)...dist/index.cjs 112.80 kB │ gzip: 33.30 kB │ map: 414.96 kB
7
+ computing gzip size (0)...computing gzip size (1)...dist/index.cjs 112.84 kB │ gzip: 33.30 kB │ map: 415.02 kB
8
8
  [vite:dts] Start rollup declaration files...
9
9
  Analysis will use the bundled TypeScript version 5.7.2
10
- [vite:dts] Declaration files built in 1321ms.
10
+ [vite:dts] Declaration files built in 1579ms.
11
11
  
12
- rendering chunks (1)...computing gzip size (1)...dist/index.js 167.05 kB │ gzip: 41.91 kB │ map: 432.27 kB
13
- ✓ built in 1.61s
12
+ rendering chunks (1)...computing gzip size (1)...dist/index.js 167.07 kB │ gzip: 41.91 kB │ map: 432.33 kB
13
+ ✓ built in 1.91s
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  `;break;case"id":o=v.includes("\0")?void 0:v;break;case"retry":/^\d+$/.test(v)?r(parseInt(v,10)):n(new qr(`Invalid \`retry\` value: "${v}"`,{type:"invalid-retry",value:v,line:m}));break;default:n(new qr(`Unknown field "${l.length>20?`${l.slice(0,20)}…`:l}"`,{type:"unknown-field",field:l,value:v,line:m}));break}}function g(){u.length>0&&e({id:o,event:c||void 0,data:u.endsWith(`
3
3
  `)?u.slice(0,-1):u}),o=void 0,u="",c=""}function b(l={}){a&&l.consume&&p(a),o=void 0,u="",c="",a=""}return{feed:h,reset:b}}function la(t){const e=[];let n="";const r=t.length;for(let s=0;s<r;s++){const a=t[s];a==="\r"&&t[s+1]===`
4
4
  `?(e.push(n),n="",s++):a==="\r"||a===`
5
- `?(e.push(n),n=""):n+=a}return[e,n]}class Kr extends Event{constructor(e,n){var r,s;super(e),this.code=(r=n==null?void 0:n.code)!=null?r:void 0,this.message=(s=n==null?void 0:n.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,n,r){return r(Hr(this),n)}[Symbol.for("Deno.customInspect")](e,n){return e(Hr(this),n)}}function fa(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Bn(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Bn).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Bn(t.cause)}`:t.message:`${t}`}function Hr(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Es=t=>{throw TypeError(t)},Or=(t,e,n)=>e.has(t)||Es("Cannot "+n),A=(t,e,n)=>(Or(t,e,"read from private field"),n?n.call(t):e.get(t)),B=(t,e,n)=>e.has(t)?Es("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),L=(t,e,n,r)=>(Or(t,e,"write to private field"),e.set(t,n),n),Ne=(t,e,n)=>(Or(t,e,"access private method"),n),se,He,ut,sn,dn,Nt,ft,Pt,De,ct,ht,dt,Et,he,qn,Kn,Hn,Gr,Gn,Jn,xt,Xn,Yn;class an extends EventTarget{constructor(e,n){var r,s;super(),B(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,B(this,se),B(this,He),B(this,ut),B(this,sn),B(this,dn),B(this,Nt),B(this,ft),B(this,Pt,null),B(this,De),B(this,ct),B(this,ht,null),B(this,dt,null),B(this,Et,null),B(this,Kn,a=>qe(this,null,function*(){var i;A(this,ct).reset();const{body:o,redirected:u,status:c,headers:h}=a;if(c===204){Ne(this,he,xt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?L(this,ut,new URL(a.url)):L(this,ut,void 0),c!==200){Ne(this,he,xt).call(this,`Non-200 status code (${c})`,c);return}if(!(h.get("content-type")||"").startsWith("text/event-stream")){Ne(this,he,xt).call(this,'Invalid content type, expected "text/event-stream"',c);return}if(A(this,se)===this.CLOSED)return;L(this,se,this.OPEN);const p=new Event("open");if((i=A(this,Et))==null||i.call(this,p),this.dispatchEvent(p),typeof o!="object"||!o||!("getReader"in o)){Ne(this,he,xt).call(this,"Invalid response body, expected a web ReadableStream",c),this.close();return}const k=new TextDecoder,g=o.getReader();let b=!0;do{const{done:l,value:v}=yield g.read();v&&A(this,ct).feed(k.decode(v,{stream:!l})),l&&(b=!1,A(this,ct).reset(),Ne(this,he,Xn).call(this))}while(b)})),B(this,Hn,a=>{L(this,De,void 0),!(a.name==="AbortError"||a.type==="aborted")&&Ne(this,he,Xn).call(this,Bn(a))}),B(this,Gn,a=>{typeof a.id=="string"&&L(this,Pt,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:A(this,ut)?A(this,ut).origin:A(this,He).origin,lastEventId:a.id||""});A(this,dt)&&(!a.event||a.event==="message")&&A(this,dt).call(this,i),this.dispatchEvent(i)}),B(this,Jn,a=>{L(this,Nt,a)}),B(this,Yn,()=>{L(this,ft,void 0),A(this,se)===this.CONNECTING&&Ne(this,he,qn).call(this)});try{if(e instanceof URL)L(this,He,e);else if(typeof e=="string")L(this,He,new URL(e,ha()));else throw new Error("Invalid URL")}catch(a){throw fa("An invalid or illegal string was specified")}L(this,ct,da({onEvent:A(this,Gn),onRetry:A(this,Jn)})),L(this,se,this.CONNECTING),L(this,Nt,3e3),L(this,dn,(r=n==null?void 0:n.fetch)!=null?r:globalThis.fetch),L(this,sn,(s=n==null?void 0:n.withCredentials)!=null?s:!1),Ne(this,he,qn).call(this)}get readyState(){return A(this,se)}get url(){return A(this,He).href}get withCredentials(){return A(this,sn)}get onerror(){return A(this,ht)}set onerror(e){L(this,ht,e)}get onmessage(){return A(this,dt)}set onmessage(e){L(this,dt,e)}get onopen(){return A(this,Et)}set onopen(e){L(this,Et,e)}addEventListener(e,n,r){const s=n;super.addEventListener(e,s,r)}removeEventListener(e,n,r){const s=n;super.removeEventListener(e,s,r)}close(){A(this,ft)&&clearTimeout(A(this,ft)),A(this,se)!==this.CLOSED&&(A(this,De)&&A(this,De).abort(),L(this,se,this.CLOSED),L(this,De,void 0))}}se=new WeakMap,He=new WeakMap,ut=new WeakMap,sn=new WeakMap,dn=new WeakMap,Nt=new WeakMap,ft=new WeakMap,Pt=new WeakMap,De=new WeakMap,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,Et=new WeakMap,he=new WeakSet,qn=function(){L(this,se,this.CONNECTING),L(this,De,new AbortController),A(this,dn)(A(this,He),Ne(this,he,Gr).call(this)).then(A(this,Kn)).catch(A(this,Hn))},Kn=new WeakMap,Hn=new WeakMap,Gr=function(){var t;const e={mode:"cors",redirect:"follow",headers:Be({Accept:"text/event-stream"},A(this,Pt)?{"Last-Event-ID":A(this,Pt)}:void 0),cache:"no-store",signal:(t=A(this,De))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Gn=new WeakMap,Jn=new WeakMap,xt=function(t,e){var n;A(this,se)!==this.CLOSED&&L(this,se,this.CLOSED);const r=new Kr("error",{code:e,message:t});(n=A(this,ht))==null||n.call(this,r),this.dispatchEvent(r)},Xn=function(t,e){var n;if(A(this,se)===this.CLOSED)return;L(this,se,this.CONNECTING);const r=new Kr("error",{code:e,message:t});(n=A(this,ht))==null||n.call(this,r),this.dispatchEvent(r),L(this,ft,setTimeout(A(this,Yn),A(this,Nt)))},Yn=new WeakMap,an.CONNECTING=0,an.OPEN=1,an.CLOSED=2;function ha(){const t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}var xs=Symbol.for("immer-nothing"),Jr=Symbol.for("immer-draftable"),ue=Symbol.for("immer-state"),pa=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function ae(t,...e){if(process.env.NODE_ENV!=="production"){const n=pa[t],r=typeof n=="function"?n.apply(null,e):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var mt=Object.getPrototypeOf;function yt(t){return!!t&&!!t[ue]}function Ye(t){var e;return t?Ss(t)||Array.isArray(t)||!!t[Jr]||!!((e=t.constructor)!=null&&e[Jr])||En(t)||xn(t):!1}var ma=Object.prototype.constructor.toString();function Ss(t){if(!t||typeof t!="object")return!1;const e=mt(t);if(e===null)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===ma}function ln(t,e){kn(t)===0?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,r)=>e(r,n,t))}function kn(t){const e=t[ue];return e?e.type_:Array.isArray(t)?1:En(t)?2:xn(t)?3:0}function Qn(t,e){return kn(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Os(t,e,n){const r=kn(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function ya(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function En(t){return t instanceof Map}function xn(t){return t instanceof Set}function Ke(t){return t.copy_||t.base_}function er(t,e){if(En(t))return new Map(t);if(xn(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Ss(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[ue];let s=Reflect.ownKeys(r);for(let a=0;a<s.length;a++){const i=s[a],o=r[i];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[i]})}return Object.create(mt(t),r)}else{const r=mt(t);if(r!==null&&n)return Be({},t);const s=Object.create(r);return Object.assign(s,t)}}function Rt(t,e=!1){return Sn(t)||yt(t)||!Ye(t)||(kn(t)>1&&(t.set=t.add=t.clear=t.delete=ga),Object.freeze(t),e&&Object.entries(t).forEach(([n,r])=>Rt(r,!0))),t}function ga(){ae(2)}function Sn(t){return Object.isFrozen(t)}var _a={};function Qe(t){const e=_a[t];return e||ae(0,t),e}var jt;function Ts(){return jt}function va(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Xr(t,e){e&&(Qe("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function tr(t){nr(t),t.drafts_.forEach(ba),t.drafts_=null}function nr(t){t===jt&&(jt=t.parent_)}function Yr(t){return jt=va(jt,t)}function ba(t){const e=t[ue];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Qr(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[ue].modified_&&(tr(e),ae(4)),Ye(t)&&(t=fn(e,t),e.parent_||hn(e,t)),e.patches_&&Qe("Patches").generateReplacementPatches_(n[ue].base_,t,e.patches_,e.inversePatches_)):t=fn(e,n,[]),tr(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==xs?t:void 0}function fn(t,e,n){if(Sn(e))return e;const r=e[ue];if(!r)return ln(e,(s,a)=>es(t,r,e,s,a,n)),e;if(r.scope_!==t)return e;if(!r.modified_)return hn(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let a=s,i=!1;r.type_===3&&(a=new Set(s),s.clear(),i=!0),ln(a,(o,u)=>es(t,r,s,o,u,n,i)),hn(t,s,!1),n&&t.patches_&&Qe("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function es(t,e,n,r,s,a,i){if(process.env.NODE_ENV!=="production"&&s===n&&ae(5),yt(s)){const o=a&&e&&e.type_!==3&&!Qn(e.assigned_,r)?a.concat(r):void 0,u=fn(t,s,o);if(Os(n,r,u),yt(u))t.canAutoFreeze_=!1;else return}else i&&n.add(s);if(Ye(s)&&!Sn(s)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;fn(t,s),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&hn(t,s)}}function hn(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Rt(e,n)}function wa(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Ts(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,a=Tr;n&&(s=[r],a=It);const{revoke:i,proxy:o}=Proxy.revocable(s,a);return r.draft_=o,r.revoke_=i,o}var Tr={get(t,e){if(e===ue)return t;const n=Ke(t);if(!Qn(n,e))return ka(t,n,e);const r=n[e];return t.finalized_||!Ye(r)?r:r===Pn(t.base_,e)?(Rn(t),t.copy_[e]=sr(r,t)):r},has(t,e){return e in Ke(t)},ownKeys(t){return Reflect.ownKeys(Ke(t))},set(t,e,n){const r=As(Ke(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const s=Pn(Ke(t),e),a=s==null?void 0:s[ue];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(ya(n,s)&&(n!==void 0||Qn(t.base_,e)))return!0;Rn(t),rr(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return Pn(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,Rn(t),rr(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ke(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){ae(11)},getPrototypeOf(t){return mt(t.base_)},setPrototypeOf(){ae(12)}},It={};ln(Tr,(t,e)=>{It[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});It.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&ae(13),It.set.call(this,t,e,void 0)};It.set=function(t,e,n){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&ae(14),Tr.set.call(this,t[0],e,n,t[0])};function Pn(t,e){const n=t[ue];return(n?Ke(n):t)[e]}function ka(t,e,n){var s;const r=As(e,n);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(t.draft_):void 0}function As(t,e){if(!(e in t))return;let n=mt(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=mt(n)}}function rr(t){t.modified_||(t.modified_=!0,t.parent_&&rr(t.parent_))}function Rn(t){t.copy_||(t.copy_=er(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Ea=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const i=this;return function(u=a,...c){return i.produce(u,h=>n.call(this,h,...c))}}typeof n!="function"&&ae(6),r!==void 0&&typeof r!="function"&&ae(7);let s;if(Ye(e)){const a=Yr(this),i=sr(e,void 0);let o=!0;try{s=n(i),o=!1}finally{o?tr(a):nr(a)}return Xr(a,r),Qr(s,a)}else if(!e||typeof e!="object"){if(s=n(e),s===void 0&&(s=e),s===xs&&(s=void 0),this.autoFreeze_&&Rt(s,!0),r){const a=[],i=[];Qe("Patches").generateReplacementPatches_(e,s,a,i),r(a,i)}return s}else ae(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(i,...o)=>this.produceWithPatches(i,u=>e(u,...o));let r,s;return[this.produce(e,n,(i,o)=>{r=i,s=o}),r,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){Ye(t)||ae(8),yt(t)&&(t=xa(t));const e=Yr(this),n=sr(t,void 0);return n[ue].isManual_=!0,nr(e),n}finishDraft(t,e){const n=t&&t[ue];(!n||!n.isManual_)&&ae(9);const{scope_:r}=n;return Xr(r,e),Qr(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const s=e[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(e=e.slice(n+1));const r=Qe("Patches").applyPatches_;return yt(t)?r(t,e):this.produce(t,s=>r(s,e))}};function sr(t,e){const n=En(t)?Qe("MapSet").proxyMap_(t,e):xn(t)?Qe("MapSet").proxySet_(t,e):wa(t,e);return(e?e.scope_:Ts()).drafts_.push(n),n}function xa(t){return yt(t)||ae(10,t),Cs(t)}function Cs(t){if(!Ye(t)||Sn(t))return t;const e=t[ue];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=er(t,e.scope_.immer_.useStrictShallowCopy_)}else n=er(t,!0);return ln(n,(r,s)=>{Os(n,r,Cs(s))}),e&&(e.finalized_=!1),n}var ce=new Ea,Sa=ce.produce;ce.produceWithPatches.bind(ce);ce.setAutoFreeze.bind(ce);ce.setUseStrictShallowCopy.bind(ce);ce.applyPatches.bind(ce);ce.createDraft.bind(ce);ce.finishDraft.bind(ce);function Oa(t){var e=F.useState(function(){return Rt(typeof t=="function"?t():t,!0)}),n=e[1];return[e[0],F.useCallback(function(r){n(typeof r=="function"?Sa(r):Rt(r))},[])]}const ts={status:"idle",error:null,result:null,tasks:{fetchDesign:{status:"pending"},codeGeneration:{status:"pending",progress:0},uploadAssets:{status:"pending"}}},ns=t=>"path"in t?{filePath:t.path.replace(/^\//,""),referencePath:t.path==="/"?"":t.path}:{filePath:t.filePath.replace(/^\//,""),referencePath:t.referencePath==="/"?"":t.referencePath},Ta=({url:t,method:e="POST"})=>{const[n,r]=Oa(ts);return{getCode:a=>qe(exports,null,function*(){var c,h,p,k;r(g=>{g.status="pending",g.error=null,g.result=null,g.tasks=ts.tasks});const i=structuredClone(a);if(((c=a.assetsStorage)==null?void 0:c.strategy)==="local"){const{referencePath:g}=ns(a.assetsStorage);a.assetsStorage={strategy:"external",url:g}}const o=new an(t,{fetch:(g,b)=>fetch(g,Br(Be({},b),{method:e,body:JSON.stringify(a)}))}),u=new Promise(g=>{const b={};o.addEventListener("start",l=>{const v=JSON.parse(l.data);b.sessionId=v.sessionId,r(m=>{m.tasks.fetchDesign.status="running"})}),o.addEventListener("pre_codegen",l=>{JSON.parse(l.data).message==="Anima model built"&&r(m=>{m.tasks.fetchDesign.status="finished",m.tasks.codeGeneration.status="running",m.tasks.uploadAssets.status="running"})}),o.addEventListener("figma_metadata",l=>{const v=JSON.parse(l.data);b.figmaFileName=v.figmaFileName,b.figmaSelectedFrameName=v.figmaSelectedFrameName}),o.addEventListener("aborted",()=>{r(l=>{l.status="aborted"}),g({result:null,error:new Error("The request was aborted")})}),o.addEventListener("generating_code",l=>{const v=JSON.parse(l.data);v.payload.status==="success"&&(b.files=v.payload.files),r(m=>{m.tasks.codeGeneration.progress=v.payload.progress})}),o.addEventListener("codegen_completed",()=>{r(l=>{l.tasks.codeGeneration.status="finished"})}),o.addEventListener("assets_uploaded",()=>{r(l=>{l.tasks.uploadAssets.status="finished"})}),o.addEventListener("assets_list",l=>{const v=JSON.parse(l.data);b.assets=v.payload.assets}),o.addEventListener("error",l=>{if(l instanceof MessageEvent){const v=JSON.parse(l.data);r(m=>{m.status="error",m.error=new Error(v.payload.message)}),g({result:null,error:new Error(v.payload.message)})}else console.error("EventSource error:",l),r(v=>{v.status="error",v.error=new Error("HTTP error: "+l.message)}),g({result:null,error:new Error("HTTP error: "+l.message)})}),o.addEventListener("done",l=>{const v=JSON.parse(l.data);b.tokenUsage=v.payload.tokenUsage,r(m=>{m.status="success",m.result=b}),g({result:b,error:null})})});try{const{result:g,error:b}=yield u,l=structuredClone(g);if(((h=i.assetsStorage)==null?void 0:h.strategy)==="local"&&((p=l==null?void 0:l.assets)!=null&&p.length)){const{filePath:v}=ns(i.assetsStorage),m=l.assets.map(R=>qe(exports,null,function*(){const D=yield(yield fetch(R.url)).arrayBuffer();return{assetName:R.name,base64:oa(D)}})),V=yield Promise.allSettled(m);for(const R of V){const K={};if(R.status==="fulfilled"){const{assetName:D,base64:q}=R.value;K[D]=q;const j=v?`${v}/${D}`:D;l.files[j]={content:q,isBinary:!0}}}}return b?{result:null,error:b}:Object.keys((k=l==null?void 0:l.files)!=null?k:{}).length===0?{result:null,error:new Error("No files received")}:{result:l,error:b}}finally{o.close()}}),status:n.status,tasks:n.tasks,error:n.error,result:n.result}};var tn={exports:{}},jn={};/**
5
+ `?(e.push(n),n=""):n+=a}return[e,n]}class Kr extends Event{constructor(e,n){var r,s;super(e),this.code=(r=n==null?void 0:n.code)!=null?r:void 0,this.message=(s=n==null?void 0:n.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,n,r){return r(Hr(this),n)}[Symbol.for("Deno.customInspect")](e,n){return e(Hr(this),n)}}function fa(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Bn(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Bn).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Bn(t.cause)}`:t.message:`${t}`}function Hr(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Es=t=>{throw TypeError(t)},Or=(t,e,n)=>e.has(t)||Es("Cannot "+n),A=(t,e,n)=>(Or(t,e,"read from private field"),n?n.call(t):e.get(t)),B=(t,e,n)=>e.has(t)?Es("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),L=(t,e,n,r)=>(Or(t,e,"write to private field"),e.set(t,n),n),Ne=(t,e,n)=>(Or(t,e,"access private method"),n),se,He,ut,sn,dn,Nt,ft,Pt,De,ct,ht,dt,Et,he,qn,Kn,Hn,Gr,Gn,Jn,xt,Xn,Yn;class an extends EventTarget{constructor(e,n){var r,s;super(),B(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,B(this,se),B(this,He),B(this,ut),B(this,sn),B(this,dn),B(this,Nt),B(this,ft),B(this,Pt,null),B(this,De),B(this,ct),B(this,ht,null),B(this,dt,null),B(this,Et,null),B(this,Kn,a=>qe(this,null,function*(){var i;A(this,ct).reset();const{body:o,redirected:u,status:c,headers:h}=a;if(c===204){Ne(this,he,xt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?L(this,ut,new URL(a.url)):L(this,ut,void 0),c!==200){Ne(this,he,xt).call(this,`Non-200 status code (${c})`,c);return}if(!(h.get("content-type")||"").startsWith("text/event-stream")){Ne(this,he,xt).call(this,'Invalid content type, expected "text/event-stream"',c);return}if(A(this,se)===this.CLOSED)return;L(this,se,this.OPEN);const p=new Event("open");if((i=A(this,Et))==null||i.call(this,p),this.dispatchEvent(p),typeof o!="object"||!o||!("getReader"in o)){Ne(this,he,xt).call(this,"Invalid response body, expected a web ReadableStream",c),this.close();return}const k=new TextDecoder,g=o.getReader();let b=!0;do{const{done:l,value:v}=yield g.read();v&&A(this,ct).feed(k.decode(v,{stream:!l})),l&&(b=!1,A(this,ct).reset(),Ne(this,he,Xn).call(this))}while(b)})),B(this,Hn,a=>{L(this,De,void 0),!(a.name==="AbortError"||a.type==="aborted")&&Ne(this,he,Xn).call(this,Bn(a))}),B(this,Gn,a=>{typeof a.id=="string"&&L(this,Pt,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:A(this,ut)?A(this,ut).origin:A(this,He).origin,lastEventId:a.id||""});A(this,dt)&&(!a.event||a.event==="message")&&A(this,dt).call(this,i),this.dispatchEvent(i)}),B(this,Jn,a=>{L(this,Nt,a)}),B(this,Yn,()=>{L(this,ft,void 0),A(this,se)===this.CONNECTING&&Ne(this,he,qn).call(this)});try{if(e instanceof URL)L(this,He,e);else if(typeof e=="string")L(this,He,new URL(e,ha()));else throw new Error("Invalid URL")}catch(a){throw fa("An invalid or illegal string was specified")}L(this,ct,da({onEvent:A(this,Gn),onRetry:A(this,Jn)})),L(this,se,this.CONNECTING),L(this,Nt,3e3),L(this,dn,(r=n==null?void 0:n.fetch)!=null?r:globalThis.fetch),L(this,sn,(s=n==null?void 0:n.withCredentials)!=null?s:!1),Ne(this,he,qn).call(this)}get readyState(){return A(this,se)}get url(){return A(this,He).href}get withCredentials(){return A(this,sn)}get onerror(){return A(this,ht)}set onerror(e){L(this,ht,e)}get onmessage(){return A(this,dt)}set onmessage(e){L(this,dt,e)}get onopen(){return A(this,Et)}set onopen(e){L(this,Et,e)}addEventListener(e,n,r){const s=n;super.addEventListener(e,s,r)}removeEventListener(e,n,r){const s=n;super.removeEventListener(e,s,r)}close(){A(this,ft)&&clearTimeout(A(this,ft)),A(this,se)!==this.CLOSED&&(A(this,De)&&A(this,De).abort(),L(this,se,this.CLOSED),L(this,De,void 0))}}se=new WeakMap,He=new WeakMap,ut=new WeakMap,sn=new WeakMap,dn=new WeakMap,Nt=new WeakMap,ft=new WeakMap,Pt=new WeakMap,De=new WeakMap,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,Et=new WeakMap,he=new WeakSet,qn=function(){L(this,se,this.CONNECTING),L(this,De,new AbortController),A(this,dn)(A(this,He),Ne(this,he,Gr).call(this)).then(A(this,Kn)).catch(A(this,Hn))},Kn=new WeakMap,Hn=new WeakMap,Gr=function(){var t;const e={mode:"cors",redirect:"follow",headers:Be({Accept:"text/event-stream"},A(this,Pt)?{"Last-Event-ID":A(this,Pt)}:void 0),cache:"no-store",signal:(t=A(this,De))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Gn=new WeakMap,Jn=new WeakMap,xt=function(t,e){var n;A(this,se)!==this.CLOSED&&L(this,se,this.CLOSED);const r=new Kr("error",{code:e,message:t});(n=A(this,ht))==null||n.call(this,r),this.dispatchEvent(r)},Xn=function(t,e){var n;if(A(this,se)===this.CLOSED)return;L(this,se,this.CONNECTING);const r=new Kr("error",{code:e,message:t});(n=A(this,ht))==null||n.call(this,r),this.dispatchEvent(r),L(this,ft,setTimeout(A(this,Yn),A(this,Nt)))},Yn=new WeakMap,an.CONNECTING=0,an.OPEN=1,an.CLOSED=2;function ha(){const t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}var xs=Symbol.for("immer-nothing"),Jr=Symbol.for("immer-draftable"),ue=Symbol.for("immer-state"),pa=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function ae(t,...e){if(process.env.NODE_ENV!=="production"){const n=pa[t],r=typeof n=="function"?n.apply(null,e):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var mt=Object.getPrototypeOf;function yt(t){return!!t&&!!t[ue]}function Ye(t){var e;return t?Ss(t)||Array.isArray(t)||!!t[Jr]||!!((e=t.constructor)!=null&&e[Jr])||En(t)||xn(t):!1}var ma=Object.prototype.constructor.toString();function Ss(t){if(!t||typeof t!="object")return!1;const e=mt(t);if(e===null)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===ma}function ln(t,e){kn(t)===0?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,r)=>e(r,n,t))}function kn(t){const e=t[ue];return e?e.type_:Array.isArray(t)?1:En(t)?2:xn(t)?3:0}function Qn(t,e){return kn(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Os(t,e,n){const r=kn(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function ya(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function En(t){return t instanceof Map}function xn(t){return t instanceof Set}function Ke(t){return t.copy_||t.base_}function er(t,e){if(En(t))return new Map(t);if(xn(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Ss(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[ue];let s=Reflect.ownKeys(r);for(let a=0;a<s.length;a++){const i=s[a],o=r[i];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[i]})}return Object.create(mt(t),r)}else{const r=mt(t);if(r!==null&&n)return Be({},t);const s=Object.create(r);return Object.assign(s,t)}}function Rt(t,e=!1){return Sn(t)||yt(t)||!Ye(t)||(kn(t)>1&&(t.set=t.add=t.clear=t.delete=ga),Object.freeze(t),e&&Object.entries(t).forEach(([n,r])=>Rt(r,!0))),t}function ga(){ae(2)}function Sn(t){return Object.isFrozen(t)}var _a={};function Qe(t){const e=_a[t];return e||ae(0,t),e}var jt;function Ts(){return jt}function va(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Xr(t,e){e&&(Qe("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function tr(t){nr(t),t.drafts_.forEach(ba),t.drafts_=null}function nr(t){t===jt&&(jt=t.parent_)}function Yr(t){return jt=va(jt,t)}function ba(t){const e=t[ue];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Qr(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[ue].modified_&&(tr(e),ae(4)),Ye(t)&&(t=fn(e,t),e.parent_||hn(e,t)),e.patches_&&Qe("Patches").generateReplacementPatches_(n[ue].base_,t,e.patches_,e.inversePatches_)):t=fn(e,n,[]),tr(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==xs?t:void 0}function fn(t,e,n){if(Sn(e))return e;const r=e[ue];if(!r)return ln(e,(s,a)=>es(t,r,e,s,a,n)),e;if(r.scope_!==t)return e;if(!r.modified_)return hn(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let a=s,i=!1;r.type_===3&&(a=new Set(s),s.clear(),i=!0),ln(a,(o,u)=>es(t,r,s,o,u,n,i)),hn(t,s,!1),n&&t.patches_&&Qe("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function es(t,e,n,r,s,a,i){if(process.env.NODE_ENV!=="production"&&s===n&&ae(5),yt(s)){const o=a&&e&&e.type_!==3&&!Qn(e.assigned_,r)?a.concat(r):void 0,u=fn(t,s,o);if(Os(n,r,u),yt(u))t.canAutoFreeze_=!1;else return}else i&&n.add(s);if(Ye(s)&&!Sn(s)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;fn(t,s),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&hn(t,s)}}function hn(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Rt(e,n)}function wa(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Ts(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,a=Tr;n&&(s=[r],a=It);const{revoke:i,proxy:o}=Proxy.revocable(s,a);return r.draft_=o,r.revoke_=i,o}var Tr={get(t,e){if(e===ue)return t;const n=Ke(t);if(!Qn(n,e))return ka(t,n,e);const r=n[e];return t.finalized_||!Ye(r)?r:r===Pn(t.base_,e)?(Rn(t),t.copy_[e]=sr(r,t)):r},has(t,e){return e in Ke(t)},ownKeys(t){return Reflect.ownKeys(Ke(t))},set(t,e,n){const r=As(Ke(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const s=Pn(Ke(t),e),a=s==null?void 0:s[ue];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(ya(n,s)&&(n!==void 0||Qn(t.base_,e)))return!0;Rn(t),rr(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return Pn(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,Rn(t),rr(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ke(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){ae(11)},getPrototypeOf(t){return mt(t.base_)},setPrototypeOf(){ae(12)}},It={};ln(Tr,(t,e)=>{It[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});It.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&ae(13),It.set.call(this,t,e,void 0)};It.set=function(t,e,n){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&ae(14),Tr.set.call(this,t[0],e,n,t[0])};function Pn(t,e){const n=t[ue];return(n?Ke(n):t)[e]}function ka(t,e,n){var s;const r=As(e,n);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(t.draft_):void 0}function As(t,e){if(!(e in t))return;let n=mt(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=mt(n)}}function rr(t){t.modified_||(t.modified_=!0,t.parent_&&rr(t.parent_))}function Rn(t){t.copy_||(t.copy_=er(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Ea=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const i=this;return function(u=a,...c){return i.produce(u,h=>n.call(this,h,...c))}}typeof n!="function"&&ae(6),r!==void 0&&typeof r!="function"&&ae(7);let s;if(Ye(e)){const a=Yr(this),i=sr(e,void 0);let o=!0;try{s=n(i),o=!1}finally{o?tr(a):nr(a)}return Xr(a,r),Qr(s,a)}else if(!e||typeof e!="object"){if(s=n(e),s===void 0&&(s=e),s===xs&&(s=void 0),this.autoFreeze_&&Rt(s,!0),r){const a=[],i=[];Qe("Patches").generateReplacementPatches_(e,s,a,i),r(a,i)}return s}else ae(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(i,...o)=>this.produceWithPatches(i,u=>e(u,...o));let r,s;return[this.produce(e,n,(i,o)=>{r=i,s=o}),r,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){Ye(t)||ae(8),yt(t)&&(t=xa(t));const e=Yr(this),n=sr(t,void 0);return n[ue].isManual_=!0,nr(e),n}finishDraft(t,e){const n=t&&t[ue];(!n||!n.isManual_)&&ae(9);const{scope_:r}=n;return Xr(r,e),Qr(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const s=e[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(e=e.slice(n+1));const r=Qe("Patches").applyPatches_;return yt(t)?r(t,e):this.produce(t,s=>r(s,e))}};function sr(t,e){const n=En(t)?Qe("MapSet").proxyMap_(t,e):xn(t)?Qe("MapSet").proxySet_(t,e):wa(t,e);return(e?e.scope_:Ts()).drafts_.push(n),n}function xa(t){return yt(t)||ae(10,t),Cs(t)}function Cs(t){if(!Ye(t)||Sn(t))return t;const e=t[ue];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=er(t,e.scope_.immer_.useStrictShallowCopy_)}else n=er(t,!0);return ln(n,(r,s)=>{Os(n,r,Cs(s))}),e&&(e.finalized_=!1),n}var ce=new Ea,Sa=ce.produce;ce.produceWithPatches.bind(ce);ce.setAutoFreeze.bind(ce);ce.setUseStrictShallowCopy.bind(ce);ce.applyPatches.bind(ce);ce.createDraft.bind(ce);ce.finishDraft.bind(ce);function Oa(t){var e=F.useState(function(){return Rt(typeof t=="function"?t():t,!0)}),n=e[1];return[e[0],F.useCallback(function(r){n(typeof r=="function"?Sa(r):Rt(r))},[])]}const ts={status:"idle",error:null,result:null,tasks:{fetchDesign:{status:"pending"},codeGeneration:{status:"pending",progress:0},uploadAssets:{status:"pending"}}},ns=t=>"path"in t?{filePath:t.path.replace(/^\//,""),referencePath:t.path==="/"?"":t.path}:{filePath:t.filePath.replace(/^\//,""),referencePath:t.referencePath==="/"?"":t.referencePath},Ta=({url:t,method:e="POST"})=>{const[n,r]=Oa(ts);return{getCode:a=>qe(exports,null,function*(){var c,h,p,k;r(g=>{g.status="pending",g.error=null,g.result=null,g.tasks=ts.tasks});const i=structuredClone(a);if(((c=a.assetsStorage)==null?void 0:c.strategy)==="local"){const{referencePath:g}=ns(a.assetsStorage);a.assetsStorage={strategy:"external",url:g}}const o=new an(t,{fetch:(g,b)=>fetch(g,Br(Be({},b),{method:e,body:JSON.stringify(a)}))}),u=new Promise(g=>{const b={};o.addEventListener("start",l=>{const v=JSON.parse(l.data);b.sessionId=v.sessionId,r(m=>{m.tasks.fetchDesign.status="running"})}),o.addEventListener("pre_codegen",l=>{JSON.parse(l.data).message==="Anima model built"&&r(m=>{m.tasks.fetchDesign.status="finished",m.tasks.codeGeneration.status="running",m.tasks.uploadAssets.status="running"})}),o.addEventListener("figma_metadata",l=>{const v=JSON.parse(l.data);b.figmaFileName=v.figmaFileName,b.figmaSelectedFrameName=v.figmaSelectedFrameName}),o.addEventListener("aborted",()=>{r(l=>{l.status="aborted"}),g({result:null,error:new Error("The request was aborted")})}),o.addEventListener("generating_code",l=>{const v=JSON.parse(l.data);v.payload.status==="success"&&(b.files=v.payload.files),r(m=>{m.tasks.codeGeneration.progress=v.payload.progress,m.tasks.codeGeneration.status="running"})}),o.addEventListener("codegen_completed",()=>{r(l=>{l.tasks.codeGeneration.status="finished"})}),o.addEventListener("assets_uploaded",()=>{r(l=>{l.tasks.uploadAssets.status="finished"})}),o.addEventListener("assets_list",l=>{const v=JSON.parse(l.data);b.assets=v.payload.assets}),o.addEventListener("error",l=>{if(l instanceof MessageEvent){const v=JSON.parse(l.data);r(m=>{m.status="error",m.error=new Error(v.payload.message)}),g({result:null,error:new Error(v.payload.message)})}else console.error("EventSource error:",l),r(v=>{v.status="error",v.error=new Error("HTTP error: "+l.message)}),g({result:null,error:new Error("HTTP error: "+l.message)})}),o.addEventListener("done",l=>{const v=JSON.parse(l.data);b.tokenUsage=v.payload.tokenUsage,r(m=>{m.status="success",m.result=b}),g({result:b,error:null})})});try{const{result:g,error:b}=yield u,l=structuredClone(g);if(((h=i.assetsStorage)==null?void 0:h.strategy)==="local"&&((p=l==null?void 0:l.assets)!=null&&p.length)){const{filePath:v}=ns(i.assetsStorage),m=l.assets.map(R=>qe(exports,null,function*(){const D=yield(yield fetch(R.url)).arrayBuffer();return{assetName:R.name,base64:oa(D)}})),V=yield Promise.allSettled(m);for(const R of V){const K={};if(R.status==="fulfilled"){const{assetName:D,base64:q}=R.value;K[D]=q;const j=v?`${v}/${D}`:D;l.files[j]={content:q,isBinary:!0}}}}return b?{result:null,error:b}:Object.keys((k=l==null?void 0:l.files)!=null?k:{}).length===0?{result:null,error:new Error("No files received")}:{result:l,error:b}}finally{o.close()}}),status:n.status,tasks:n.tasks,error:n.error,result:n.result}};var tn={exports:{}},jn={};/**
6
6
  * @license React
7
7
  * use-sync-external-store-shim.production.js
8
8
  *