flash-story-app 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/serve.js CHANGED
@@ -199,7 +199,7 @@ RULES:
199
199
  - Work incrementally: inspect if unsure, edit, verify, then continue.${ee}
200
200
 
201
201
  WHEN DONE: reply with a SHORT natural-language summary of what you changed and
202
- DO NOT call any more tools. That final message ends the session.`}}var xf=Symbol.for("immer-nothing"),Ka=Symbol.for("immer-draftable"),Wn=Symbol.for("immer-state"),qv=process.env.NODE_ENV!=="production"?[function(n){return`The plugin for '${n}' has not been loaded into Immer. To enable the plugin, import and call \`enable${n}()\` when initializing your application.`},function(n){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 '${n}'`},"This object has been frozen and should not be mutated",function(n){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},"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(n){return`'current' expects a draft, got: ${n}`},"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(n){return`'original' expects a draft, got: ${n}`}]:[];function tn(n,...e){if(process.env.NODE_ENV!=="production"){const t=qv[n],i=typeof t=="function"?t.apply(null,e):t;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${n}. Full error at: https://bit.ly/3cXEKWf`)}var na=Object.getPrototypeOf;function is(n){return!!n&&!!n[Wn]}function xr(n){return n?Yv(n)||Array.isArray(n)||!!n[Ka]||!!n.constructor?.[Ka]||_a(n)||Do(n):!1}var qb=Object.prototype.constructor.toString(),vp=new WeakMap;function Yv(n){if(!n||typeof n!="object")return!1;const e=Object.getPrototypeOf(n);if(e===null||e===Object.prototype)return!0;const t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(t===Object)return!0;if(typeof t!="function")return!1;let i=vp.get(t);return i===void 0&&(i=Function.toString.call(t),vp.set(t,i)),i===qb}function So(n,e,t=!0){rs(n)===0?(t?Reflect.ownKeys(n):Object.keys(n)).forEach(r=>{e(r,n[r],n)}):n.forEach((i,r)=>e(r,i,n))}function rs(n){const e=n[Wn];return e?e.type_:Array.isArray(n)?1:_a(n)?2:Do(n)?3:0}function bo(n,e){return rs(n)===2?n.has(e):Object.prototype.hasOwnProperty.call(n,e)}function qc(n,e){return rs(n)===2?n.get(e):n[e]}function Zv(n,e,t){const i=rs(n);i===2?n.set(e,t):i===3?n.add(t):n[e]=t}function Yb(n,e){return n===e?n!==0||1/n===1/e:n!==n&&e!==e}function _a(n){return n instanceof Map}function Do(n){return n instanceof Set}function Br(n){return n.copy_||n.base_}function nd(n,e){if(_a(n))return new Map(n);if(Do(n))return new Set(n);if(Array.isArray(n))return Array.prototype.slice.call(n);const t=Yv(n);if(e===!0||e==="class_only"&&!t){const i=Object.getOwnPropertyDescriptors(n);delete i[Wn];let r=Reflect.ownKeys(i);for(let s=0;s<r.length;s++){const a=r[s],o=i[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(i[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[a]})}return Object.create(na(n),i)}else{const i=na(n);if(i!==null&&t)return{...n};const r=Object.create(i);return Object.assign(r,n)}}function Sf(n,e=!1){return Rc(n)||is(n)||!xr(n)||(rs(n)>1&&Object.defineProperties(n,{set:Ho,add:Ho,clear:Ho,delete:Ho}),Object.freeze(n),e&&Object.values(n).forEach(t=>Sf(t,!0))),n}function Zb(){tn(2)}var Ho={value:Zb};function Rc(n){return n===null||typeof n!="object"?!0:Object.isFrozen(n)}var id={};function ss(n){const e=id[n];return e||tn(0,n),e}function Kb(n,e){id[n]||(id[n]=e)}var wo;function Kv(){return wo}function Jb(n,e){return{drafts_:[],parent_:n,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yp(n,e){e&&(ss("Patches"),n.patches_=[],n.inversePatches_=[],n.patchListener_=e)}function rd(n){sd(n),n.drafts_.forEach(Qb),n.drafts_=null}function sd(n){n===wo&&(wo=n.parent_)}function xp(n){return wo=Jb(wo,n)}function Qb(n){const e=n[Wn];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Sp(n,e){e.unfinalizedDrafts_=e.drafts_.length;const t=e.drafts_[0];return n!==void 0&&n!==t?(t[Wn].modified_&&(rd(e),tn(4)),xr(n)&&(n=ic(e,n),e.parent_||rc(e,n)),e.patches_&&ss("Patches").generateReplacementPatches_(t[Wn].base_,n,e.patches_,e.inversePatches_)):n=ic(e,t,[]),rd(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),n!==xf?n:void 0}function ic(n,e,t){if(Rc(e))return e;const i=n.immer_.shouldUseStrictIteration(),r=e[Wn];if(!r)return So(e,(s,a)=>bp(n,r,e,s,a,t),i),e;if(r.scope_!==n)return e;if(!r.modified_)return rc(n,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let a=s,o=!1;r.type_===3&&(a=new Set(s),s.clear(),o=!0),So(a,(l,c)=>bp(n,r,s,l,c,t,o),i),rc(n,s,!1),t&&n.patches_&&ss("Patches").generatePatches_(r,t,n.patches_,n.inversePatches_)}return r.copy_}function bp(n,e,t,i,r,s,a){if(r==null||typeof r!="object"&&!a)return;const o=Rc(r);if(!(o&&!a)){if(process.env.NODE_ENV!=="production"&&r===t&&tn(5),is(r)){const l=s&&e&&e.type_!==3&&!bo(e.assigned_,i)?s.concat(i):void 0,c=ic(n,r,l);if(Zv(t,i,c),is(c))n.canAutoFreeze_=!1;else return}else a&&t.add(r);if(xr(r)&&!o){if(!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||e&&e.base_&&e.base_[i]===r&&o)return;ic(n,r),(!e||!e.scope_.parent_)&&typeof i!="symbol"&&(_a(t)?t.has(i):Object.prototype.propertyIsEnumerable.call(t,i))&&rc(n,r)}}}function rc(n,e,t=!1){!n.parent_&&n.immer_.autoFreeze_&&n.canAutoFreeze_&&Sf(e,t)}function ew(n,e){const t=Array.isArray(n),i={type_:t?1:0,scope_:e?e.scope_:Kv(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:n,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=i,s=bf;t&&(r=[i],s=Mo);const{revoke:a,proxy:o}=Proxy.revocable(r,s);return i.draft_=o,i.revoke_=a,o}var bf={get(n,e){if(e===Wn)return n;const t=Br(n);if(!bo(t,e))return tw(n,t,e);const i=t[e];return n.finalized_||!xr(i)?i:i===Yc(n.base_,e)?(Zc(n),n.copy_[e]=od(i,n)):i},has(n,e){return e in Br(n)},ownKeys(n){return Reflect.ownKeys(Br(n))},set(n,e,t){const i=Jv(Br(n),e);if(i?.set)return i.set.call(n.draft_,t),!0;if(!n.modified_){const r=Yc(Br(n),e),s=r?.[Wn];if(s&&s.base_===t)return n.copy_[e]=t,n.assigned_[e]=!1,!0;if(Yb(t,r)&&(t!==void 0||bo(n.base_,e)))return!0;Zc(n),ad(n)}return n.copy_[e]===t&&(t!==void 0||e in n.copy_)||Number.isNaN(t)&&Number.isNaN(n.copy_[e])||(n.copy_[e]=t,n.assigned_[e]=!0),!0},deleteProperty(n,e){return Yc(n.base_,e)!==void 0||e in n.base_?(n.assigned_[e]=!1,Zc(n),ad(n)):delete n.assigned_[e],n.copy_&&delete n.copy_[e],!0},getOwnPropertyDescriptor(n,e){const t=Br(n),i=Reflect.getOwnPropertyDescriptor(t,e);return i&&{writable:!0,configurable:n.type_!==1||e!=="length",enumerable:i.enumerable,value:t[e]}},defineProperty(){tn(11)},getPrototypeOf(n){return na(n.base_)},setPrototypeOf(){tn(12)}},Mo={};So(bf,(n,e)=>{Mo[n]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});Mo.deleteProperty=function(n,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&tn(13),Mo.set.call(this,n,e,void 0)};Mo.set=function(n,e,t){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&tn(14),bf.set.call(this,n[0],e,t,n[0])};function Yc(n,e){const t=n[Wn];return(t?Br(t):n)[e]}function tw(n,e,t){const i=Jv(e,t);return i?"value"in i?i.value:i.get?.call(n.draft_):void 0}function Jv(n,e){if(!(e in n))return;let t=na(n);for(;t;){const i=Object.getOwnPropertyDescriptor(t,e);if(i)return i;t=na(t)}}function ad(n){n.modified_||(n.modified_=!0,n.parent_&&ad(n.parent_))}function Zc(n){n.copy_||(n.copy_=nd(n.base_,n.scope_.immer_.useStrictShallowCopy_))}var nw=class{constructor(n){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,t,i)=>{if(typeof e=="function"&&typeof t!="function"){const s=t;t=e;const a=this;return function(l=s,...c){return a.produce(l,d=>t.call(this,d,...c))}}typeof t!="function"&&tn(6),i!==void 0&&typeof i!="function"&&tn(7);let r;if(xr(e)){const s=xp(this),a=od(e,void 0);let o=!0;try{r=t(a),o=!1}finally{o?rd(s):sd(s)}return yp(s,i),Sp(r,s)}else if(!e||typeof e!="object"){if(r=t(e),r===void 0&&(r=e),r===xf&&(r=void 0),this.autoFreeze_&&Sf(r,!0),i){const s=[],a=[];ss("Patches").generateReplacementPatches_(e,r,s,a),i(s,a)}return r}else tn(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,l=>e(l,...o));let i,r;return[this.produce(e,t,(a,o)=>{i=a,r=o}),i,r]},typeof n?.autoFreeze=="boolean"&&this.setAutoFreeze(n.autoFreeze),typeof n?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(n.useStrictShallowCopy),typeof n?.useStrictIteration=="boolean"&&this.setUseStrictIteration(n.useStrictIteration)}createDraft(n){xr(n)||tn(8),is(n)&&(n=iw(n));const e=xp(this),t=od(n,void 0);return t[Wn].isManual_=!0,sd(e),t}finishDraft(n,e){const t=n&&n[Wn];(!t||!t.isManual_)&&tn(9);const{scope_:i}=t;return yp(i,e),Sp(void 0,i)}setAutoFreeze(n){this.autoFreeze_=n}setUseStrictShallowCopy(n){this.useStrictShallowCopy_=n}setUseStrictIteration(n){this.useStrictIteration_=n}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(n,e){let t;for(t=e.length-1;t>=0;t--){const r=e[t];if(r.path.length===0&&r.op==="replace"){n=r.value;break}}t>-1&&(e=e.slice(t+1));const i=ss("Patches").applyPatches_;return is(n)?i(n,e):this.produce(n,r=>i(r,e))}};function od(n,e){const t=_a(n)?ss("MapSet").proxyMap_(n,e):Do(n)?ss("MapSet").proxySet_(n,e):ew(n,e);return(e?e.scope_:Kv()).drafts_.push(t),t}function iw(n){return is(n)||tn(10,n),Qv(n)}function Qv(n){if(!xr(n)||Rc(n))return n;const e=n[Wn];let t,i=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,t=nd(n,e.scope_.immer_.useStrictShallowCopy_),i=e.scope_.immer_.shouldUseStrictIteration()}else t=nd(n,!0);return So(t,(r,s)=>{Zv(t,r,Qv(s))},i),e&&(e.finalized_=!1),t}function rw(){process.env.NODE_ENV!=="production"&&qv.push('Sets cannot have "replace" patches.',function(u){return"Unsupported patch operation: "+u},function(u){return"Cannot apply patch, path doesn't resolve: "+u},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const e="replace",t="add",i="remove";function r(u,f,m,v){switch(u.type_){case 0:case 2:return a(u,f,m,v);case 1:return s(u,f,m,v);case 3:return o(u,f,m,v)}}function s(u,f,m,v){let{base_:g,assigned_:p}=u,y=u.copy_;y.length<g.length&&([g,y]=[y,g],[m,v]=[v,m]);for(let x=0;x<g.length;x++)if(p[x]&&y[x]!==g[x]){const S=f.concat([x]);m.push({op:e,path:S,value:h(y[x])}),v.push({op:e,path:S,value:h(g[x])})}for(let x=g.length;x<y.length;x++){const S=f.concat([x]);m.push({op:t,path:S,value:h(y[x])})}for(let x=y.length-1;g.length<=x;--x){const S=f.concat([x]);v.push({op:i,path:S})}}function a(u,f,m,v){const{base_:g,copy_:p}=u;So(u.assigned_,(y,x)=>{const S=qc(g,y),T=qc(p,y),C=x?bo(g,y)?e:t:i;if(S===T&&C===e)return;const E=f.concat(y);m.push(C===i?{op:C,path:E}:{op:C,path:E,value:T}),v.push(C===t?{op:i,path:E}:C===i?{op:t,path:E,value:h(S)}:{op:e,path:E,value:h(S)})})}function o(u,f,m,v){let{base_:g,copy_:p}=u,y=0;g.forEach(x=>{if(!p.has(x)){const S=f.concat([y]);m.push({op:i,path:S,value:x}),v.unshift({op:t,path:S,value:x})}y++}),y=0,p.forEach(x=>{if(!g.has(x)){const S=f.concat([y]);m.push({op:t,path:S,value:x}),v.unshift({op:i,path:S,value:x})}y++})}function l(u,f,m,v){m.push({op:e,path:[],value:f===xf?void 0:f}),v.push({op:e,path:[],value:u})}function c(u,f){return f.forEach(m=>{const{path:v,op:g}=m;let p=u;for(let T=0;T<v.length-1;T++){const C=rs(p);let E=v[T];typeof E!="string"&&typeof E!="number"&&(E=""+E),(C===0||C===1)&&(E==="__proto__"||E==="constructor")&&tn(19),typeof p=="function"&&E==="prototype"&&tn(19),p=qc(p,E),typeof p!="object"&&tn(18,v.join("/"))}const y=rs(p),x=d(m.value),S=v[v.length-1];switch(g){case e:switch(y){case 2:return p.set(S,x);case 3:tn(16);default:return p[S]=x}case t:switch(y){case 1:return S==="-"?p.push(x):p.splice(S,0,x);case 2:return p.set(S,x);case 3:return p.add(x);default:return p[S]=x}case i:switch(y){case 1:return p.splice(S,1);case 2:return p.delete(S);case 3:return p.delete(m.value);default:return delete p[S]}default:tn(17,g)}}),u}function d(u){if(!xr(u))return u;if(Array.isArray(u))return u.map(d);if(_a(u))return new Map(Array.from(u.entries()).map(([m,v])=>[m,d(v)]));if(Do(u))return new Set(Array.from(u).map(d));const f=Object.create(na(u));for(const m in u)f[m]=d(u[m]);return bo(u,Ka)&&(f[Ka]=u[Ka]),f}function h(u){return is(u)?d(u):u}Kb("Patches",{applyPatches_:c,generatePatches_:r,generateReplacementPatches_:l})}var Eo=new nw;Eo.produce;var sw=Eo.produceWithPatches.bind(Eo),wp=Eo.applyPatches.bind(Eo);const ld=8;function e0(n){return typeof n=="string"}function t0(n){if(n.length>ld)return`custom easing supports at most ${ld} points`;let e=0;for(const[t,i]of n){if(!(t>0&&t<1))return`point x must be inside (0,1): ${t}`;if(t<=e)return"point x values must be strictly increasing";if(!(i>=-1&&i<=2))return`point y out of range [-1,2]: ${i}`;e=t}return null}function aw(n,e){if(n.length===0)return e;const t=[0,...n.map(u=>u[0]),1],i=[0,...n.map(u=>u[1]),1],r=t.length,s=[],a=[];for(let u=0;u<r-1;u++)s.push(t[u+1]-t[u]),a.push((i[u+1]-i[u])/(t[u+1]-t[u]));const o=[a[0]];for(let u=1;u<r-1;u++)if(a[u-1]*a[u]<=0)o.push(0);else{const f=2*s[u]+s[u-1],m=s[u]+2*s[u-1];o.push((f+m)/(f/a[u-1]+m/a[u]))}o.push(a[r-2]);let l=0;for(;l<r-2&&e>t[l+1];)l++;const c=(e-t[l])/s[l],d=c*c,h=d*c;return(2*h-3*d+1)*i[l]+(h-2*d+c)*s[l]*o[l]+(-2*h+3*d)*i[l+1]+(h-d)*s[l]*o[l+1]}function ow(n){return n<0?0:n>1?1:n}function fr(n,e,t){return n+(e-n)*t}function n0(n,e){const t=ow(e);if(!e0(n))return t<=0?0:t>=1?1:aw(n.custom,t);switch(n){case"linear":return t;case"ease":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeIn":return t*t*t;case"easeOut":return 1-Math.pow(1-t,3);case"easeInOut":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"hold":return t>=1?1:0;case"spring":return t<=0?0:t>=1?1:1-Math.exp(-6*t)*Math.cos(9*t);default:return n}}const i0=re.union([re.enum(["linear","ease","easeIn","easeOut","easeInOut","hold","spring"]),re.object({custom:re.array(re.tuple([re.number(),re.number()])).max(ld)}).strict().refine(n=>t0(n.custom)===null,{message:"invalid custom easing points"})]),To=re.tuple([re.number(),re.number(),re.number()]),lw=re.object({t:re.number(),pos:To,rotY:re.number(),easing:i0}).strict(),cw=re.object({t:re.number(),poseId:re.string(),holdSec:re.number(),transitionSec:re.number()}).strict(),uw=re.object({dir:re.enum(["cw","ccw"]),turns:re.number().int().min(0).max(vf).optional(),pivot:To.optional()}).strict(),hw=re.object({t:re.number(),pos:To,lookAt:To,fov:re.number(),easing:i0,orbit:uw.optional()}).strict(),dw=re.object({op:re.literal("placeEntity"),id:re.string(),pos:To,rotY:re.number().optional()}).strict(),fw=re.object({op:re.literal("setTransformKeys"),id:re.string(),keys:re.array(lw)}).strict(),pw=re.object({op:re.literal("setPoseKeys"),id:re.string(),keys:re.array(cw)}).strict(),mw=re.object({op:re.literal("setCameraKeys"),keys:re.array(hw)}).strict(),gw=re.object(Object.fromEntries(Yi.map(n=>[n,re.number().optional()]))).strict(),_w=re.object({op:re.literal("definePose"),poseId:re.string().optional(),label:re.string(),joints:gw}).strict(),vw=re.object({age:re.enum(["adult_m","adult_f","elder","teen","child"]),build:re.enum(["thin","medium","heavy"])}).strict(),yw=re.object({name:re.string().optional(),color:re.string().optional(),heightCm:re.number().optional(),bodyType:vw.optional(),primitive:re.object({size:re.tuple([re.number(),re.number(),re.number()]).optional(),tex:re.string().optional(),bend:re.number().optional(),radius:re.number().optional()}).strict().optional(),modelUrl:re.string().optional()}).strict(),xw=re.object({op:re.literal("updateEntity"),id:re.string(),patch:yw}).strict(),Sw=re.discriminatedUnion("op",[dw,fw,pw,mw,_w,xw]),bw=re.object({ops:re.array(Sw),note:re.string().optional()}).strict();function ww(n,e){const t=bw.safeParse(e);if(!t.success)return{ok:!1,error:t.error.issues.map(o=>o.message).join("; ")};const i=n.shots[0],r=n.settings.durationSec,s=new Set(i.entities.map(o=>o.id)),a=o=>o>=0&&o<=r;for(const o of e.ops){if("id"in o&&!s.has(o.id))return{ok:!1,error:`unknown entity id: ${o.id}`};switch(o.op){case"placeEntity":break;case"setTransformKeys":for(const l of o.keys)if(!a(l.t))return{ok:!1,error:`transform time ${l.t} out of range [0,${r}]`};break;case"setPoseKeys":for(const l of o.keys){if(!a(l.t))return{ok:!1,error:`pose time ${l.t} out of range [0,${r}]`};if(!Ev(l.poseId,n))return{ok:!1,error:`unknown poseId: ${l.poseId}`}}break;case"setCameraKeys":for(const l of o.keys)if(!a(l.t))return{ok:!1,error:`camera time ${l.t} out of range [0,${r}]`};break;case"definePose":if(!o.label||!o.label.trim())return{ok:!1,error:"pose label must be non-empty"};if(o.poseId&&Js(o.poseId))return{ok:!1,error:`cannot overwrite built-in pose: ${o.label} (${o.poseId})`};{const l=Tv(o.joints);if(!l.ok)return{ok:!1,error:`pose ${o.label}: ${l.error}`}}break;case"updateEntity":if(o.patch.heightCm!==void 0&&(o.patch.heightCm<120||o.patch.heightCm>210))return{ok:!1,error:`height ${o.patch.heightCm} out of range 120–210`};break;default:return o}}return{ok:!0}}const Mw=1e-4;function Ew(n,e,t,i,r="linear"){const s=n.map(o=>({...o,pos:[...o.pos]})),a=s.findIndex(o=>Math.abs(o.t-e)<Mw);return a>=0?(s[a].pos=[...t],s[a].rotY=i):s.push({t:e,pos:[...t],rotY:i,easing:r}),s.sort((o,l)=>o.t-l.t),s}const Mp=/[㐀-鿿豈-﫿぀-ヿ가-힯]/g,Tw=4.5,Aw=2.5,Rw=.4,Ep=.8;function Tp(n){return n.split(/\s+/).filter(e=>/[a-z0-9]/i.test(e)).length}function Cw(n){const e=n.trim();if(!e)return Ep;const t=/^[\x00-\x7F]*$/.test(e);let i,r;if(t)i=Tp(e),r=Aw;else{const a=(e.match(Mp)??[]).length,o=Tp(e.replace(Mp," "));i=a+o,r=Tw}const s=i/r+Rw;return Math.max(Ep,Math.round(s*10)/10)}rw();function Ap(n){let e=1,t=`pose_${e}`;for(;Object.prototype.hasOwnProperty.call(n,t)||Js(t);)e+=1,t=`pose_${e}`;return t}function r0(n){return{doc:n,past:[],future:[]}}function We(n,e){return{...n,error:e}}function Kc(n,e,t=!1){if(!t&&n.length===0)return"track must contain at least one key";for(const i of n)if(i<0||i>e)return`keyframe time out of range: ${i}`;return null}function Wo(n,e){let t=e.length+1;for(;e.some(i=>i.id===`${n}_${t}`);)t+=1;return`${n}_${t}`}function Pw(n){if(n.kind!=="primitive")return n.kind==="character"?"char":"model";const e=n.primitive?.shape;return e==="image"?"img":e==="panorama"?"pano":"prim"}function Iw(n){let e=n.length+1;for(;n.some(t=>t.id===`marker_${e}`);)e+=1;return`marker_${e}`}function Jc(n){for(const e of n)if(!e0(e)){const t=t0(e.custom);if(t)return`invalid custom easing: ${t}`}return null}function Ot(n,e){const[t,i,r]=sw(n.doc,e);return i.length===0?{...n,error:void 0}:n.batch?{...n,doc:t,batch:{...n.batch,patches:[...n.batch.patches,...i],inverse:[...n.batch.inverse,...r]},error:void 0}:{doc:t,past:[...n.past,{patches:i,inverse:r}],future:[],error:void 0}}function s0(n,e){switch(e.type){case"addEntity":{const{entity:t}=e,i=n.doc.shots[0],r=t.id??Wo(Pw(t),i.entities);if(i.entities.some(o=>o.id===r))return We(n,`entity id already exists: ${r}`);let s=t.color;if(t.kind==="character"){const o=i.entities.filter(l=>l.kind==="character").map(l=>l.color);if(o.length>=Vb)return We(n,"six-color limit reached: cannot add a 7th character (split into another shot)");if(s===void 0){const l=Wb(o);if(l===null)return We(n,"no main color available");s=l}else if(!Za(s))return We(n,"character color must be a main color")}else s===void 0&&(s="#888888");if(t.kind==="character"&&t.heightCm!==void 0&&(t.heightCm<120||t.heightCm>210))return We(n,"height must be 120–210cm");const a={id:r,name:t.name,kind:t.kind,color:s,heightCm:t.heightCm,transform:t.transform??[{t:0,pos:[0,0,0],rotY:0,easing:"linear"}],poses:[],primitive:t.primitive,modelUrl:t.modelUrl};return Ot(n,o=>{o.shots[0].entities.push(a)})}case"removeEntity":return n.doc.shots[0].entities.some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].entities,s=r.findIndex(a=>a.id===e.id);s>=0&&r.splice(s,1)}):We(n,`unknown entity id: ${e.id}`);case"setColor":{const t=n.doc.shots[0].entities.find(i=>i.id===e.id);return t?t.kind==="character"&&!Za(e.color)?We(n,"character color must be a main color"):Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r&&(r.color=e.color)}):We(n,`unknown entity id: ${e.id}`)}case"setHeight":return n.doc.shots[0].entities.find(i=>i.id===e.id)?e.heightCm<120||e.heightCm>210?We(n,"height must be 120–210cm"):Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r&&(r.heightCm=e.heightCm)}):We(n,`unknown entity id: ${e.id}`);case"updateEntity":{const t=n.doc.shots[0],i=t.entities.find(s=>s.id===e.id);if(!i)return We(n,`unknown entity id: ${e.id}`);const{patch:r}=e;if(r.color!==void 0&&i.kind==="character"){if(!Za(r.color))return We(n,"character color must be a main color");if(t.entities.some(a=>a.id!==i.id&&a.kind==="character"&&a.color===r.color))return We(n,`color ${r.color} already used by another character`)}return r.heightCm!==void 0&&(r.heightCm<120||r.heightCm>210)?We(n,"height must be 120–210cm"):r.bodyType!==void 0&&i.kind!=="character"?We(n,"bodyType is only valid on a character"):r.primitive!==void 0&&i.kind!=="primitive"?We(n,"primitive fields are only valid on a primitive"):r.note!==void 0&&r.note.length>500?We(n,"note must be at most 500 characters"):r.primitive?.size!==void 0&&r.primitive.size.some(s=>!(s>0))?We(n,"primitive size components must be > 0"):Ot(n,s=>{const a=s.shots[0].entities.find(o=>o.id===e.id);if(r.name!==void 0&&(a.name=r.name),r.color!==void 0&&(a.color=r.color),r.heightCm!==void 0&&(a.heightCm=r.heightCm),r.bodyType!==void 0&&(a.bodyType=r.bodyType),r.modelUrl!==void 0&&(a.modelUrl=r.modelUrl),r.hidden!==void 0&&(r.hidden?a.hidden=!0:delete a.hidden),r.locked!==void 0&&(r.locked?a.locked=!0:delete a.locked),"referenceSheet"in r&&(a.referenceSheet=r.referenceSheet),"note"in r&&(a.note=r.note),r.primitive!==void 0&&a.primitive){const o=r.primitive;o.shape!==void 0&&o.shape!==a.primitive.shape&&(a.primitive.shape=o.shape,o.shape==="panorama"&&o.radius===void 0&&a.primitive.radius===void 0&&(a.primitive.radius=7),o.shape==="image"&&o.bend===void 0&&a.primitive.bend===void 0&&(a.primitive.bend=0)),o.size!==void 0&&(a.primitive.size=o.size),o.tex!==void 0&&(a.primitive.tex=o.tex),o.bend!==void 0&&(a.primitive.bend=o.bend),o.radius!==void 0&&(a.primitive.radius=o.radius)}})}case"setSettings":{const{patch:t}=e;return t.fps!==void 0&&!Yl.includes(t.fps)?We(n,`fps must be one of ${Yl.join("/")}`):t.aspect!==void 0&&!["16:9","9:16","1:1"].includes(t.aspect)?We(n,`invalid aspect: ${t.aspect}`):Ot(n,i=>{t.fps!==void 0&&(i.settings.fps=t.fps),t.aspect!==void 0&&(i.settings.aspect=t.aspect),t.name!==void 0&&(i.name=t.name)})}case"definePose":{const t=e.label?.trim();if(!t)return We(n,"pose label must be non-empty");const i=e.poseId?.trim()||Ap(n.doc.customPoses);if(Js(i))return We(n,`cannot overwrite built-in pose: ${t} (${i})`);const r=Tv(e.joints);if(!r.ok)return We(n,`pose ${t}: ${r.error}`);const s={...e.joints};return Ot(n,a=>{a.customPoses[i]=e.hidden!==void 0?{label:t,joints:s,hidden:e.hidden}:{label:t,joints:s}})}case"deletePose":return Js(e.poseId)?We(n,`cannot delete built-in pose: ${e.poseId}`):Object.prototype.hasOwnProperty.call(n.doc.customPoses,e.poseId)?n.doc.shots[0].entities.some(i=>i.poses.some(r=>r.poseId===e.poseId))?We(n,`custom pose ${e.poseId} is still referenced by a pose key`):Ot(n,i=>{delete i.customPoses[e.poseId]}):We(n,`unknown custom pose: ${e.poseId}`);case"moveKeyframe":{const t=n.doc.shots[0].entities.find(i=>i.id===e.id);return t?e.index<0||e.index>=t.transform.length?We(n,`transform index out of range: ${e.index}`):Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r.transform[e.index].pos=e.pos,r.transform[e.index].rotY=e.rotY}):We(n,`unknown entity id: ${e.id}`)}case"upsertTransformKey":{if(!n.doc.shots[0].entities.find(i=>i.id===e.id))return We(n,`unknown entity id: ${e.id}`);if(e.t<0||e.t>n.doc.settings.durationSec)return We(n,`keyframe time out of range: ${e.t}`);if(e.easing){const i=Jc([e.easing]);if(i)return We(n,i)}return Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r.transform=Ew(r.transform,e.t,e.pos,e.rotY,e.easing)})}case"setTransformTrack":{if(!n.doc.shots[0].entities.find(s=>s.id===e.id))return We(n,`unknown entity id: ${e.id}`);const i=Kc(e.keys.map(s=>s.t),n.doc.settings.durationSec)??Jc(e.keys.map(s=>s.easing));if(i)return We(n,i);const r=[...e.keys].sort((s,a)=>s.t-a.t);return Ot(n,s=>{s.shots[0].entities.find(a=>a.id===e.id).transform=r})}case"setPoseTrack":{if(!n.doc.shots[0].entities.find(s=>s.id===e.id))return We(n,`unknown entity id: ${e.id}`);for(const s of e.keys)if(!Ev(s.poseId,n.doc))return We(n,`unknown poseId: ${s.poseId}`);const i=e.keys.length?Kc(e.keys.map(s=>s.t),n.doc.settings.durationSec,!0):null;if(i)return We(n,i);const r=[...e.keys].sort((s,a)=>s.t-a.t);return Ot(n,s=>{s.shots[0].entities.find(a=>a.id===e.id).poses=r})}case"setCameraTrack":{const t=Kc(e.keys.map(o=>o.t),n.doc.settings.durationSec)??Jc(e.keys.map(o=>o.easing));if(t)return We(n,t);const i=n.doc.shots[0],r=e.cameraId?i.cameras.find(o=>o.id===e.cameraId):i.cameras[0];if(!r)return We(n,`unknown camera id: ${e.cameraId}`);const s=r.id,a=[...e.keys].sort((o,l)=>o.t-l.t);return Ot(n,o=>{o.shots[0].cameras.find(l=>l.id===s).keyframes=a})}case"addCamera":{const t=n.doc.shots[0].cameras,i=e.id??Wo("cam",t);if(t.some(a=>a.id===i))return We(n,`camera id already exists: ${i}`);const r=e.name?.trim()||`相机 ${t.length+1}`,s=t[0].keyframes[0];return Ot(n,a=>{a.shots[0].cameras.push({id:i,name:r,keyframes:[{...s,pos:[...s.pos],lookAt:[...s.lookAt]}]})})}case"renameCamera":return n.doc.shots[0].cameras.some(i=>i.id===e.id)?e.name.trim()?Ot(n,i=>{i.shots[0].cameras.find(r=>r.id===e.id).name=e.name.trim()}):We(n,"camera name must be non-empty"):We(n,`unknown camera id: ${e.id}`);case"deleteCamera":{const t=n.doc.shots[0].cameras;return t.some(i=>i.id===e.id)?t.length<=1?We(n,"cannot delete the last camera"):Ot(n,i=>{const r=i.shots[0];r.cameras.splice(r.cameras.findIndex(s=>s.id===e.id),1),r.cameraSwitches=r.cameraSwitches.filter(s=>s.cameraId!==e.id),r.cameraSwitches.some(s=>s.t===0)||r.cameraSwitches.unshift({t:0,cameraId:r.cameras[0].id})}):We(n,`unknown camera id: ${e.id}`)}case"setCameraSwitches":{const t=n.doc.shots[0];for(const s of e.switches){if(!t.cameras.some(a=>a.id===s.cameraId))return We(n,`unknown camera id: ${s.cameraId}`);if(s.t<0||s.t>n.doc.settings.durationSec)return We(n,`switch time out of range: ${s.t}`)}const i=[...e.switches].sort((s,a)=>s.t-a.t),r=[];for(const s of i)r.length&&Math.abs(r[r.length-1].t-s.t)<1e-9?r[r.length-1]=s:r.push(s);return(!r.length||r[0].t!==0)&&r.unshift({t:0,cameraId:t.cameras[0].id}),Ot(n,s=>{s.shots[0].cameraSwitches=r})}case"addDialogueTrack":{const t=n.doc.shots[0].dialogueTracks,i=e.id??Wo("dlg",t);return t.some(r=>r.id===i)?We(n,`dialogue track id already exists: ${i}`):Ot(n,r=>{r.shots[0].dialogueTracks.push({id:i,cues:[]})})}case"deleteDialogueTrack":return n.doc.shots[0].dialogueTracks.some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].dialogueTracks;r.splice(r.findIndex(s=>s.id===e.id),1)}):We(n,`unknown dialogue track: ${e.id}`);case"upsertDialogueCue":{const t=n.doc.shots[0],i=t.dialogueTracks.find(l=>l.id===e.trackId);if(!i)return We(n,`unknown dialogue track: ${e.trackId}`);const r=e.cue;if(!t.entities.some(l=>l.id===r.entityId))return We(n,`unknown entity id: ${r.entityId}`);const s=r.text.trim();if(!s)return We(n,"dialogue text must be non-empty");if(s.length>200)return We(n,"dialogue text must be at most 200 characters");if(r.t<0||r.t>n.doc.settings.durationSec)return We(n,`dialogue time out of range: ${r.t}`);const a=r.durationSec??Cw(s);if(!(a>0))return We(n,"dialogue durationSec must be > 0");const o=r.id??Wo("cue",i.cues);return Ot(n,l=>{const c=l.shots[0].dialogueTracks.find(h=>h.id===e.trackId),d=c.cues.find(h=>h.id===o);d?(d.entityId=r.entityId,d.text=s,d.t=r.t,d.durationSec=a):c.cues.push({id:o,entityId:r.entityId,text:s,t:r.t,durationSec:a}),c.cues.sort((h,u)=>h.t-u.t)})}case"deleteDialogueCue":{const t=n.doc.shots[0].dialogueTracks.find(i=>i.id===e.trackId);return t?t.cues.some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].dialogueTracks.find(s=>s.id===e.trackId);r.cues.splice(r.cues.findIndex(s=>s.id===e.id),1)}):We(n,`unknown cue id: ${e.id}`):We(n,`unknown dialogue track: ${e.trackId}`)}case"addMarker":{const t=e.label.trim();if(!t)return We(n,"marker label must be non-empty");if(e.t<0||e.t>n.doc.settings.durationSec)return We(n,`marker time out of range: ${e.t}`);const i=n.doc.shots[0].markers??[],r=e.id??Iw(i);return i.some(s=>s.id===r)?We(n,`marker id already exists: ${r}`):Ot(n,s=>{const a=s.shots[0];a.markers||(a.markers=[]),a.markers.push({id:r,t:e.t,label:t}),a.markers.sort((o,l)=>o.t-l.t)})}case"updateMarker":return(n.doc.shots[0].markers??[]).some(i=>i.id===e.id)?e.label!==void 0&&!e.label.trim()?We(n,"marker label must be non-empty"):e.t!==void 0&&(e.t<0||e.t>n.doc.settings.durationSec)?We(n,`marker time out of range: ${e.t}`):Ot(n,i=>{const r=i.shots[0].markers,s=r.find(a=>a.id===e.id);e.t!==void 0&&(s.t=e.t),e.label!==void 0&&(s.label=e.label.trim()),r.sort((a,o)=>a.t-o.t)}):We(n,`unknown marker id: ${e.id}`);case"deleteMarker":return(n.doc.shots[0].markers??[]).some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].markers;r.splice(r.findIndex(s=>s.id===e.id),1)}):We(n,`unknown marker id: ${e.id}`);case"setDuration":return e.durationSec>0?Ot(n,t=>{t.settings.durationSec=e.durationSec}):We(n,"durationSec must be > 0");case"applyAiPatch":{const t=ww(n.doc,e.patch);return t.ok?Ot(n,i=>{const r=i.shots[0];for(const s of e.patch.ops)switch(s.op){case"placeEntity":{const a=r.entities.find(l=>l.id===s.id);if(!a)break;const o=a.transform[0]??{t:0,pos:[0,0,0],rotY:0,easing:"linear"};o.pos=s.pos,s.rotY!==void 0&&(o.rotY=s.rotY),a.transform[0]=o;break}case"setTransformKeys":{const a=r.entities.find(o=>o.id===s.id);a&&(a.transform=s.keys);break}case"setPoseKeys":{const a=r.entities.find(o=>o.id===s.id);a&&(a.poses=s.keys);break}case"setCameraKeys":{Av(r).keyframes=[...s.keys].sort((a,o)=>a.t-o.t);break}case"definePose":{const a=s.poseId?.trim()||Ap(i.customPoses);i.customPoses[a]={label:s.label,joints:{...s.joints}};break}case"updateEntity":{const a=r.entities.find(l=>l.id===s.id);if(!a)break;const o=s.patch;o.name!==void 0&&(a.name=o.name),o.color!==void 0&&(a.color=o.color),o.heightCm!==void 0&&(a.heightCm=o.heightCm),o.bodyType!==void 0&&(a.bodyType=o.bodyType),o.modelUrl!==void 0&&(a.modelUrl=o.modelUrl),o.primitive!==void 0&&a.primitive&&(o.primitive.size!==void 0&&(a.primitive.size=o.primitive.size),o.primitive.tex!==void 0&&(a.primitive.tex=o.primitive.tex),o.primitive.bend!==void 0&&(a.primitive.bend=o.primitive.bend),o.primitive.radius!==void 0&&(a.primitive.radius=o.primitive.radius));break}}}):We(n,t.error)}case"beginBatch":return n.batch?We(n,"a batch is already open"):{...n,batch:{patches:[],inverse:[],baseDoc:n.doc},error:void 0};case"commitBatch":{if(!n.batch)return n;const{patches:t,inverse:i}=n.batch;return t.length===0?{...n,batch:void 0,error:void 0}:{doc:n.doc,past:[...n.past,{patches:t,inverse:[...i].reverse()}],future:[],batch:void 0,error:void 0}}case"abortBatch":return n.batch?{...n,doc:n.batch.baseDoc,batch:void 0,error:void 0}:n;case"undo":{if(n.past.length===0)return{...n,error:void 0};const t=n.past[n.past.length-1];return{doc:wp(n.doc,t.inverse),past:n.past.slice(0,-1),future:[t,...n.future],error:void 0}}case"redo":{if(n.future.length===0)return{...n,error:void 0};const[t,...i]=n.future;return{doc:wp(n.doc,t.patches),past:[...n.past,t],future:i,error:void 0}}default:return e}}class Lw{state;constructor(e){this.state=r0(e)}get doc(){return this.state.doc}dispatch(e){return this.state=s0(this.state,e),this.state.error??null}}const sc=.001,Cc=(n,e,t)=>Math.min(t,Math.max(e,n));function ia(n){const e=Math.hypot(n[0],n[1],n[2]);return e===0?{radius:0,phi:Math.PI/2,theta:0}:{radius:e,phi:Math.acos(Cc(n[1]/e,-1,1)),theta:Math.atan2(n[0],n[2])}}function wf(n){const e=Math.sin(n.phi);return[n.radius*e*Math.sin(n.theta),n.radius*Math.cos(n.phi),n.radius*e*Math.cos(n.theta)]}function Rp(n,e){const t=Math.PI*2,i=(e-n)%t;return i<0?i+t:i}function ac(n,e,t){return[fr(n[0],e[0],t),fr(n[1],e[1],t),fr(n[2],e[2],t)]}function a0(n,e){const t=n[0],i=n[n.length-1];if(e<=t.t)return{left:t,right:t,u:0};if(e>=i.t)return{left:i,right:i,u:0};for(let r=0;r<n.length-1;r++){const s=n[r],a=n[r+1];if(e>=s.t&&e<=a.t){const o=a.t-s.t,l=o===0?0:(e-s.t)/o;return{left:s,right:a,u:l}}}return{left:i,right:i,u:0}}function Dw(n,e){const{left:t,right:i,u:r}=a0(n,e);if(t===i)return{pos:[...t.pos],rotY:t.rotY};const s=n0(t.easing,r);return{pos:ac(t.pos,i.pos,s),rotY:fr(t.rotY,i.rotY,s)}}function Nw(n,e){const{left:t,right:i,u:r}=a0(n,e);if(t===i)return{pos:[...t.pos],lookAt:[...t.lookAt],fov:t.fov};const s=n0(t.easing,r),a=ac(t.lookAt,i.lookAt,s);return{pos:t.orbit?Ow(t,i,a,s):ac(t.pos,i.pos,s),lookAt:a,fov:fr(t.fov,i.fov,s)}}function Ow(n,e,t,i){const r=n.orbit,s=ia(oc(n.pos,r.pivot??n.lookAt)),a=ia(oc(e.pos,r.pivot??e.lookAt));if(s.radius===0)return ac(n.pos,e.pos,i);const o=wf({radius:fr(s.radius,a.radius,i),phi:Cc(fr(s.phi,a.phi,i),sc,Math.PI-sc),theta:s.theta+o0(n,e)*i}),l=r.pivot??t;return[l[0]+o[0],l[1]+o[1],l[2]+o[2]]}function o0(n,e){const t=n.orbit;if(!t)return 0;const i=ia(oc(n.pos,t.pivot??n.lookAt)),r=ia(oc(e.pos,t.pivot??e.lookAt)),s=t.dir==="ccw"?1:-1;return(t.dir==="ccw"?Rp(i.theta,r.theta):-Rp(r.theta,i.theta))+s*Math.PI*2*Math.max(0,Math.round(t.turns??0))}const oc=(n,e)=>[n[0]-e[0],n[1]-e[1],n[2]-e[2]];function tr(n,e){return Vx(n,e)}function kw(n,e,t){const i={};for(const r of Yi)i[r]=fr(n[r],e[r],t);return i}function Uw(n,e,t){if(n.length===0)return{...Yr.idle};const i=n[0];if(e<=i.t)return{...tr(i.poseId,t)};const r=n[n.length-1];if(e>=r.t)return{...tr(r.poseId,t)};for(let s=0;s<n.length-1;s++){const a=n[s],o=n[s+1];if(e>=a.t&&e<=o.t){const l=a.t+Math.max(0,a.holdSec);if(e<=l)return{...tr(a.poseId,t)};const c=Math.max(0,o.transitionSec);if(c===0)return{...tr(a.poseId,t)};const d=Math.max(l,o.t-c);if(e<=d)return{...tr(a.poseId,t)};const h=o.t-d,u=h<=0?1:(e-d)/h;return kw(tr(a.poseId,t),tr(o.poseId,t),u)}}return{...tr(r.poseId,t)}}function Il(n,e,t){const i=n.shots.find(a=>a.id===e);if(!i)throw new Error(`unknown shot id: ${e}`);const r=i.entities.map(a=>{const{pos:o,rotY:l}=Dw(a.transform,t),c=a.poses&&a.poses.length>0?Uw(a.poses,t,n):{...Yr.idle};return{id:a.id,name:a.name,kind:a.kind,color:a.color,pos:o,rotY:l,jointAngles:c,heightCm:a.heightCm,bodyType:a.bodyType,primitive:a.primitive,modelUrl:a.modelUrl,hidden:a.hidden}}),s=Av(i,Fw(i,t));return{entities:r,camera:Nw(s.keyframes,t)}}function Fw(n,e){let t=n.cameras[0]?.id;for(const i of n.cameraSwitches)if(i.t<=e+1e-9)t=i.cameraId;else break;return t}function Bw(n,e){if(n.length===0)return null;let t=n[0].poseId;for(const i of n)if(i.t<=e)t=i.poseId;else break;return t}function Ga(n){return Number(n.toFixed(2)).toString()}function Go(n){return`(${n.map(Ga).join(", ")})`}function cd(n,e){const t=n.shots[0],i=Il(n,t.id,e),{durationSec:r}=n.settings,s=[];if(s.push(`SCENE SUMMARY at t=${Ga(e)}s of ${Ga(r)}s (Y-up, meters, characters face -Z at rotY=0, angles in radians).`),i.entities.length===0)s.push(" (no entities in the scene)");else for(const o of i.entities){const l=t.entities.find(d=>d.id===o.id);let c=` - ${o.name} [${o.id}] kind=${o.kind} color=${o.color}(${Gs(o.color)}) pos=${Go(o.pos)} rotY=${Ga(o.rotY)}`;if(o.kind==="character"){const d=l?Bw(l.poses,e):null;c+=` pose=${d??"idle"} height=${o.heightCm??180}cm`}o.kind==="primitive"&&o.primitive&&(c+=` shape=${o.primitive.shape} size=${Go(o.primitive.size)}`),s.push(c)}const a=i.camera;return s.push(` camera: pos=${Go(a.pos)} lookAt=${Go(a.lookAt)} fov=${Ga(a.fov)}deg`),s.join(`
202
+ DO NOT call any more tools. That final message ends the session.`}}var xf=Symbol.for("immer-nothing"),Ka=Symbol.for("immer-draftable"),Wn=Symbol.for("immer-state"),qv=process.env.NODE_ENV!=="production"?[function(n){return`The plugin for '${n}' has not been loaded into Immer. To enable the plugin, import and call \`enable${n}()\` when initializing your application.`},function(n){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 '${n}'`},"This object has been frozen and should not be mutated",function(n){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},"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(n){return`'current' expects a draft, got: ${n}`},"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(n){return`'original' expects a draft, got: ${n}`}]:[];function tn(n,...e){if(process.env.NODE_ENV!=="production"){const t=qv[n],i=typeof t=="function"?t.apply(null,e):t;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${n}. Full error at: https://bit.ly/3cXEKWf`)}var na=Object.getPrototypeOf;function is(n){return!!n&&!!n[Wn]}function xr(n){return n?Yv(n)||Array.isArray(n)||!!n[Ka]||!!n.constructor?.[Ka]||_a(n)||Do(n):!1}var qb=Object.prototype.constructor.toString(),vp=new WeakMap;function Yv(n){if(!n||typeof n!="object")return!1;const e=Object.getPrototypeOf(n);if(e===null||e===Object.prototype)return!0;const t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(t===Object)return!0;if(typeof t!="function")return!1;let i=vp.get(t);return i===void 0&&(i=Function.toString.call(t),vp.set(t,i)),i===qb}function So(n,e,t=!0){rs(n)===0?(t?Reflect.ownKeys(n):Object.keys(n)).forEach(r=>{e(r,n[r],n)}):n.forEach((i,r)=>e(r,i,n))}function rs(n){const e=n[Wn];return e?e.type_:Array.isArray(n)?1:_a(n)?2:Do(n)?3:0}function bo(n,e){return rs(n)===2?n.has(e):Object.prototype.hasOwnProperty.call(n,e)}function qc(n,e){return rs(n)===2?n.get(e):n[e]}function Zv(n,e,t){const i=rs(n);i===2?n.set(e,t):i===3?n.add(t):n[e]=t}function Yb(n,e){return n===e?n!==0||1/n===1/e:n!==n&&e!==e}function _a(n){return n instanceof Map}function Do(n){return n instanceof Set}function Br(n){return n.copy_||n.base_}function nd(n,e){if(_a(n))return new Map(n);if(Do(n))return new Set(n);if(Array.isArray(n))return Array.prototype.slice.call(n);const t=Yv(n);if(e===!0||e==="class_only"&&!t){const i=Object.getOwnPropertyDescriptors(n);delete i[Wn];let r=Reflect.ownKeys(i);for(let s=0;s<r.length;s++){const a=r[s],o=i[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(i[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[a]})}return Object.create(na(n),i)}else{const i=na(n);if(i!==null&&t)return{...n};const r=Object.create(i);return Object.assign(r,n)}}function Sf(n,e=!1){return Rc(n)||is(n)||!xr(n)||(rs(n)>1&&Object.defineProperties(n,{set:Ho,add:Ho,clear:Ho,delete:Ho}),Object.freeze(n),e&&Object.values(n).forEach(t=>Sf(t,!0))),n}function Zb(){tn(2)}var Ho={value:Zb};function Rc(n){return n===null||typeof n!="object"?!0:Object.isFrozen(n)}var id={};function ss(n){const e=id[n];return e||tn(0,n),e}function Kb(n,e){id[n]||(id[n]=e)}var wo;function Kv(){return wo}function Jb(n,e){return{drafts_:[],parent_:n,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yp(n,e){e&&(ss("Patches"),n.patches_=[],n.inversePatches_=[],n.patchListener_=e)}function rd(n){sd(n),n.drafts_.forEach(Qb),n.drafts_=null}function sd(n){n===wo&&(wo=n.parent_)}function xp(n){return wo=Jb(wo,n)}function Qb(n){const e=n[Wn];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Sp(n,e){e.unfinalizedDrafts_=e.drafts_.length;const t=e.drafts_[0];return n!==void 0&&n!==t?(t[Wn].modified_&&(rd(e),tn(4)),xr(n)&&(n=ic(e,n),e.parent_||rc(e,n)),e.patches_&&ss("Patches").generateReplacementPatches_(t[Wn].base_,n,e.patches_,e.inversePatches_)):n=ic(e,t,[]),rd(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),n!==xf?n:void 0}function ic(n,e,t){if(Rc(e))return e;const i=n.immer_.shouldUseStrictIteration(),r=e[Wn];if(!r)return So(e,(s,a)=>bp(n,r,e,s,a,t),i),e;if(r.scope_!==n)return e;if(!r.modified_)return rc(n,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let a=s,o=!1;r.type_===3&&(a=new Set(s),s.clear(),o=!0),So(a,(l,c)=>bp(n,r,s,l,c,t,o),i),rc(n,s,!1),t&&n.patches_&&ss("Patches").generatePatches_(r,t,n.patches_,n.inversePatches_)}return r.copy_}function bp(n,e,t,i,r,s,a){if(r==null||typeof r!="object"&&!a)return;const o=Rc(r);if(!(o&&!a)){if(process.env.NODE_ENV!=="production"&&r===t&&tn(5),is(r)){const l=s&&e&&e.type_!==3&&!bo(e.assigned_,i)?s.concat(i):void 0,c=ic(n,r,l);if(Zv(t,i,c),is(c))n.canAutoFreeze_=!1;else return}else a&&t.add(r);if(xr(r)&&!o){if(!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||e&&e.base_&&e.base_[i]===r&&o)return;ic(n,r),(!e||!e.scope_.parent_)&&typeof i!="symbol"&&(_a(t)?t.has(i):Object.prototype.propertyIsEnumerable.call(t,i))&&rc(n,r)}}}function rc(n,e,t=!1){!n.parent_&&n.immer_.autoFreeze_&&n.canAutoFreeze_&&Sf(e,t)}function ew(n,e){const t=Array.isArray(n),i={type_:t?1:0,scope_:e?e.scope_:Kv(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:n,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=i,s=bf;t&&(r=[i],s=Mo);const{revoke:a,proxy:o}=Proxy.revocable(r,s);return i.draft_=o,i.revoke_=a,o}var bf={get(n,e){if(e===Wn)return n;const t=Br(n);if(!bo(t,e))return tw(n,t,e);const i=t[e];return n.finalized_||!xr(i)?i:i===Yc(n.base_,e)?(Zc(n),n.copy_[e]=od(i,n)):i},has(n,e){return e in Br(n)},ownKeys(n){return Reflect.ownKeys(Br(n))},set(n,e,t){const i=Jv(Br(n),e);if(i?.set)return i.set.call(n.draft_,t),!0;if(!n.modified_){const r=Yc(Br(n),e),s=r?.[Wn];if(s&&s.base_===t)return n.copy_[e]=t,n.assigned_[e]=!1,!0;if(Yb(t,r)&&(t!==void 0||bo(n.base_,e)))return!0;Zc(n),ad(n)}return n.copy_[e]===t&&(t!==void 0||e in n.copy_)||Number.isNaN(t)&&Number.isNaN(n.copy_[e])||(n.copy_[e]=t,n.assigned_[e]=!0),!0},deleteProperty(n,e){return Yc(n.base_,e)!==void 0||e in n.base_?(n.assigned_[e]=!1,Zc(n),ad(n)):delete n.assigned_[e],n.copy_&&delete n.copy_[e],!0},getOwnPropertyDescriptor(n,e){const t=Br(n),i=Reflect.getOwnPropertyDescriptor(t,e);return i&&{writable:!0,configurable:n.type_!==1||e!=="length",enumerable:i.enumerable,value:t[e]}},defineProperty(){tn(11)},getPrototypeOf(n){return na(n.base_)},setPrototypeOf(){tn(12)}},Mo={};So(bf,(n,e)=>{Mo[n]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});Mo.deleteProperty=function(n,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&tn(13),Mo.set.call(this,n,e,void 0)};Mo.set=function(n,e,t){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&tn(14),bf.set.call(this,n[0],e,t,n[0])};function Yc(n,e){const t=n[Wn];return(t?Br(t):n)[e]}function tw(n,e,t){const i=Jv(e,t);return i?"value"in i?i.value:i.get?.call(n.draft_):void 0}function Jv(n,e){if(!(e in n))return;let t=na(n);for(;t;){const i=Object.getOwnPropertyDescriptor(t,e);if(i)return i;t=na(t)}}function ad(n){n.modified_||(n.modified_=!0,n.parent_&&ad(n.parent_))}function Zc(n){n.copy_||(n.copy_=nd(n.base_,n.scope_.immer_.useStrictShallowCopy_))}var nw=class{constructor(n){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,t,i)=>{if(typeof e=="function"&&typeof t!="function"){const s=t;t=e;const a=this;return function(l=s,...c){return a.produce(l,d=>t.call(this,d,...c))}}typeof t!="function"&&tn(6),i!==void 0&&typeof i!="function"&&tn(7);let r;if(xr(e)){const s=xp(this),a=od(e,void 0);let o=!0;try{r=t(a),o=!1}finally{o?rd(s):sd(s)}return yp(s,i),Sp(r,s)}else if(!e||typeof e!="object"){if(r=t(e),r===void 0&&(r=e),r===xf&&(r=void 0),this.autoFreeze_&&Sf(r,!0),i){const s=[],a=[];ss("Patches").generateReplacementPatches_(e,r,s,a),i(s,a)}return r}else tn(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,l=>e(l,...o));let i,r;return[this.produce(e,t,(a,o)=>{i=a,r=o}),i,r]},typeof n?.autoFreeze=="boolean"&&this.setAutoFreeze(n.autoFreeze),typeof n?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(n.useStrictShallowCopy),typeof n?.useStrictIteration=="boolean"&&this.setUseStrictIteration(n.useStrictIteration)}createDraft(n){xr(n)||tn(8),is(n)&&(n=iw(n));const e=xp(this),t=od(n,void 0);return t[Wn].isManual_=!0,sd(e),t}finishDraft(n,e){const t=n&&n[Wn];(!t||!t.isManual_)&&tn(9);const{scope_:i}=t;return yp(i,e),Sp(void 0,i)}setAutoFreeze(n){this.autoFreeze_=n}setUseStrictShallowCopy(n){this.useStrictShallowCopy_=n}setUseStrictIteration(n){this.useStrictIteration_=n}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(n,e){let t;for(t=e.length-1;t>=0;t--){const r=e[t];if(r.path.length===0&&r.op==="replace"){n=r.value;break}}t>-1&&(e=e.slice(t+1));const i=ss("Patches").applyPatches_;return is(n)?i(n,e):this.produce(n,r=>i(r,e))}};function od(n,e){const t=_a(n)?ss("MapSet").proxyMap_(n,e):Do(n)?ss("MapSet").proxySet_(n,e):ew(n,e);return(e?e.scope_:Kv()).drafts_.push(t),t}function iw(n){return is(n)||tn(10,n),Qv(n)}function Qv(n){if(!xr(n)||Rc(n))return n;const e=n[Wn];let t,i=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,t=nd(n,e.scope_.immer_.useStrictShallowCopy_),i=e.scope_.immer_.shouldUseStrictIteration()}else t=nd(n,!0);return So(t,(r,s)=>{Zv(t,r,Qv(s))},i),e&&(e.finalized_=!1),t}function rw(){process.env.NODE_ENV!=="production"&&qv.push('Sets cannot have "replace" patches.',function(u){return"Unsupported patch operation: "+u},function(u){return"Cannot apply patch, path doesn't resolve: "+u},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const e="replace",t="add",i="remove";function r(u,f,m,v){switch(u.type_){case 0:case 2:return a(u,f,m,v);case 1:return s(u,f,m,v);case 3:return o(u,f,m,v)}}function s(u,f,m,v){let{base_:g,assigned_:p}=u,y=u.copy_;y.length<g.length&&([g,y]=[y,g],[m,v]=[v,m]);for(let x=0;x<g.length;x++)if(p[x]&&y[x]!==g[x]){const S=f.concat([x]);m.push({op:e,path:S,value:h(y[x])}),v.push({op:e,path:S,value:h(g[x])})}for(let x=g.length;x<y.length;x++){const S=f.concat([x]);m.push({op:t,path:S,value:h(y[x])})}for(let x=y.length-1;g.length<=x;--x){const S=f.concat([x]);v.push({op:i,path:S})}}function a(u,f,m,v){const{base_:g,copy_:p}=u;So(u.assigned_,(y,x)=>{const S=qc(g,y),T=qc(p,y),C=x?bo(g,y)?e:t:i;if(S===T&&C===e)return;const E=f.concat(y);m.push(C===i?{op:C,path:E}:{op:C,path:E,value:T}),v.push(C===t?{op:i,path:E}:C===i?{op:t,path:E,value:h(S)}:{op:e,path:E,value:h(S)})})}function o(u,f,m,v){let{base_:g,copy_:p}=u,y=0;g.forEach(x=>{if(!p.has(x)){const S=f.concat([y]);m.push({op:i,path:S,value:x}),v.unshift({op:t,path:S,value:x})}y++}),y=0,p.forEach(x=>{if(!g.has(x)){const S=f.concat([y]);m.push({op:t,path:S,value:x}),v.unshift({op:i,path:S,value:x})}y++})}function l(u,f,m,v){m.push({op:e,path:[],value:f===xf?void 0:f}),v.push({op:e,path:[],value:u})}function c(u,f){return f.forEach(m=>{const{path:v,op:g}=m;let p=u;for(let T=0;T<v.length-1;T++){const C=rs(p);let E=v[T];typeof E!="string"&&typeof E!="number"&&(E=""+E),(C===0||C===1)&&(E==="__proto__"||E==="constructor")&&tn(19),typeof p=="function"&&E==="prototype"&&tn(19),p=qc(p,E),typeof p!="object"&&tn(18,v.join("/"))}const y=rs(p),x=d(m.value),S=v[v.length-1];switch(g){case e:switch(y){case 2:return p.set(S,x);case 3:tn(16);default:return p[S]=x}case t:switch(y){case 1:return S==="-"?p.push(x):p.splice(S,0,x);case 2:return p.set(S,x);case 3:return p.add(x);default:return p[S]=x}case i:switch(y){case 1:return p.splice(S,1);case 2:return p.delete(S);case 3:return p.delete(m.value);default:return delete p[S]}default:tn(17,g)}}),u}function d(u){if(!xr(u))return u;if(Array.isArray(u))return u.map(d);if(_a(u))return new Map(Array.from(u.entries()).map(([m,v])=>[m,d(v)]));if(Do(u))return new Set(Array.from(u).map(d));const f=Object.create(na(u));for(const m in u)f[m]=d(u[m]);return bo(u,Ka)&&(f[Ka]=u[Ka]),f}function h(u){return is(u)?d(u):u}Kb("Patches",{applyPatches_:c,generatePatches_:r,generateReplacementPatches_:l})}var Eo=new nw;Eo.produce;var sw=Eo.produceWithPatches.bind(Eo),wp=Eo.applyPatches.bind(Eo);const ld=8;function e0(n){return typeof n=="string"}function t0(n){if(n.length>ld)return`custom easing supports at most ${ld} points`;let e=0;for(const[t,i]of n){if(!(t>0&&t<1))return`point x must be inside (0,1): ${t}`;if(t<=e)return"point x values must be strictly increasing";if(!(i>=-1&&i<=2))return`point y out of range [-1,2]: ${i}`;e=t}return null}function aw(n,e){if(n.length===0)return e;const t=[0,...n.map(u=>u[0]),1],i=[0,...n.map(u=>u[1]),1],r=t.length,s=[],a=[];for(let u=0;u<r-1;u++)s.push(t[u+1]-t[u]),a.push((i[u+1]-i[u])/(t[u+1]-t[u]));const o=[a[0]];for(let u=1;u<r-1;u++)if(a[u-1]*a[u]<=0)o.push(0);else{const f=2*s[u]+s[u-1],m=s[u]+2*s[u-1];o.push((f+m)/(f/a[u-1]+m/a[u]))}o.push(a[r-2]);let l=0;for(;l<r-2&&e>t[l+1];)l++;const c=(e-t[l])/s[l],d=c*c,h=d*c;return(2*h-3*d+1)*i[l]+(h-2*d+c)*s[l]*o[l]+(-2*h+3*d)*i[l+1]+(h-d)*s[l]*o[l+1]}function ow(n){return n<0?0:n>1?1:n}function fr(n,e,t){return n+(e-n)*t}function n0(n,e){const t=ow(e);if(!e0(n))return t<=0?0:t>=1?1:aw(n.custom,t);switch(n){case"linear":return t;case"ease":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeIn":return t*t*t;case"easeOut":return 1-Math.pow(1-t,3);case"easeInOut":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"hold":return t>=1?1:0;case"spring":return t<=0?0:t>=1?1:1-Math.exp(-6*t)*Math.cos(9*t);default:return n}}const i0=re.union([re.enum(["linear","ease","easeIn","easeOut","easeInOut","hold","spring"]),re.object({custom:re.array(re.tuple([re.number(),re.number()])).max(ld)}).strict().refine(n=>t0(n.custom)===null,{message:"invalid custom easing points"})]),To=re.tuple([re.number(),re.number(),re.number()]),lw=re.object({t:re.number(),pos:To,rotY:re.number(),easing:i0}).strict(),cw=re.object({t:re.number(),poseId:re.string(),holdSec:re.number(),transitionSec:re.number()}).strict(),uw=re.object({dir:re.enum(["cw","ccw"]),turns:re.number().int().min(0).max(vf).optional(),pivot:To.optional()}).strict(),hw=re.object({t:re.number(),pos:To,lookAt:To,fov:re.number(),easing:i0,orbit:uw.optional()}).strict(),dw=re.object({op:re.literal("placeEntity"),id:re.string(),pos:To,rotY:re.number().optional()}).strict(),fw=re.object({op:re.literal("setTransformKeys"),id:re.string(),keys:re.array(lw)}).strict(),pw=re.object({op:re.literal("setPoseKeys"),id:re.string(),keys:re.array(cw)}).strict(),mw=re.object({op:re.literal("setCameraKeys"),keys:re.array(hw)}).strict(),gw=re.object(Object.fromEntries(Yi.map(n=>[n,re.number().optional()]))).strict(),_w=re.object({op:re.literal("definePose"),poseId:re.string().optional(),label:re.string(),joints:gw}).strict(),vw=re.object({age:re.enum(["adult_m","adult_f","elder","teen","child"]),build:re.enum(["thin","medium","heavy"])}).strict(),yw=re.object({name:re.string().optional(),color:re.string().optional(),heightCm:re.number().optional(),bodyType:vw.optional(),primitive:re.object({size:re.tuple([re.number(),re.number(),re.number()]).optional(),tex:re.string().optional(),bend:re.number().optional(),radius:re.number().optional()}).strict().optional(),modelUrl:re.string().optional()}).strict(),xw=re.object({op:re.literal("updateEntity"),id:re.string(),patch:yw}).strict(),Sw=re.discriminatedUnion("op",[dw,fw,pw,mw,_w,xw]),bw=re.object({ops:re.array(Sw),note:re.string().optional()}).strict();function ww(n,e){const t=bw.safeParse(e);if(!t.success)return{ok:!1,error:t.error.issues.map(o=>o.message).join("; ")};const i=n.shots[0],r=n.settings.durationSec,s=new Set(i.entities.map(o=>o.id)),a=o=>o>=0&&o<=r;for(const o of e.ops){if("id"in o&&!s.has(o.id))return{ok:!1,error:`unknown entity id: ${o.id}`};switch(o.op){case"placeEntity":break;case"setTransformKeys":for(const l of o.keys)if(!a(l.t))return{ok:!1,error:`transform time ${l.t} out of range [0,${r}]`};break;case"setPoseKeys":for(const l of o.keys){if(!a(l.t))return{ok:!1,error:`pose time ${l.t} out of range [0,${r}]`};if(!Ev(l.poseId,n))return{ok:!1,error:`unknown poseId: ${l.poseId}`}}break;case"setCameraKeys":for(const l of o.keys)if(!a(l.t))return{ok:!1,error:`camera time ${l.t} out of range [0,${r}]`};break;case"definePose":if(!o.label||!o.label.trim())return{ok:!1,error:"pose label must be non-empty"};if(o.poseId&&Js(o.poseId))return{ok:!1,error:`cannot overwrite built-in pose: ${o.label} (${o.poseId})`};{const l=Tv(o.joints);if(!l.ok)return{ok:!1,error:`pose ${o.label}: ${l.error}`}}break;case"updateEntity":if(o.patch.heightCm!==void 0&&(o.patch.heightCm<120||o.patch.heightCm>210))return{ok:!1,error:`height ${o.patch.heightCm} out of range 120–210`};break;default:return o}}return{ok:!0}}const Mw=1e-4;function Ew(n,e,t,i,r="linear"){const s=n.map(o=>({...o,pos:[...o.pos]})),a=s.findIndex(o=>Math.abs(o.t-e)<Mw);return a>=0?(s[a].pos=[...t],s[a].rotY=i):s.push({t:e,pos:[...t],rotY:i,easing:r}),s.sort((o,l)=>o.t-l.t),s}const Mp=/[㐀-鿿豈-﫿぀-ヿ가-힯]/g,Tw=4.5,Aw=2.5,Rw=.4,Ep=.8;function Tp(n){return n.split(/\s+/).filter(e=>/[a-z0-9]/i.test(e)).length}function Cw(n){const e=n.trim();if(!e)return Ep;const t=/^[\x00-\x7F]*$/.test(e);let i,r;if(t)i=Tp(e),r=Aw;else{const a=(e.match(Mp)??[]).length,o=Tp(e.replace(Mp," "));i=a+o,r=Tw}const s=i/r+Rw;return Math.max(Ep,Math.round(s*10)/10)}rw();function Ap(n){let e=1,t=`pose_${e}`;for(;Object.prototype.hasOwnProperty.call(n,t)||Js(t);)e+=1,t=`pose_${e}`;return t}function r0(n){return{doc:n,past:[],future:[]}}function We(n,e){return{...n,error:e}}function Kc(n,e,t=!1){if(!t&&n.length===0)return"track must contain at least one key";for(const i of n)if(i<0||i>e)return`keyframe time out of range: ${i}`;return null}function Wo(n,e){let t=e.length+1;for(;e.some(i=>i.id===`${n}_${t}`);)t+=1;return`${n}_${t}`}function Pw(n){if(n.kind!=="primitive")return n.kind==="character"?"char":"model";const e=n.primitive?.shape;return e==="image"?"img":e==="panorama"?"pano":"prim"}function Iw(n){let e=n.length+1;for(;n.some(t=>t.id===`marker_${e}`);)e+=1;return`marker_${e}`}function Jc(n){for(const e of n)if(!e0(e)){const t=t0(e.custom);if(t)return`invalid custom easing: ${t}`}return null}function Ot(n,e){const[t,i,r]=sw(n.doc,e);return i.length===0?{...n,error:void 0}:n.batch?{...n,doc:t,batch:{...n.batch,patches:[...n.batch.patches,...i],inverse:[...n.batch.inverse,...r]},error:void 0}:{doc:t,past:[...n.past,{patches:i,inverse:r}],future:[],error:void 0}}function s0(n,e){switch(e.type){case"addEntity":{const{entity:t}=e,i=n.doc.shots[0],r=t.id??Wo(Pw(t),i.entities);if(i.entities.some(o=>o.id===r))return We(n,`entity id already exists: ${r}`);let s=t.color;if(t.kind==="character"){const o=i.entities.filter(l=>l.kind==="character").map(l=>l.color);if(o.length>=Vb)return We(n,"six-color limit reached: cannot add a 7th character (split into another shot)");if(s===void 0){const l=Wb(o);if(l===null)return We(n,"no main color available");s=l}else if(!Za(s))return We(n,"character color must be a main color")}else s===void 0&&(s="#888888");if(t.kind==="character"&&t.heightCm!==void 0&&(t.heightCm<120||t.heightCm>210))return We(n,"height must be 120–210cm");const a={id:r,name:t.name,kind:t.kind,color:s,heightCm:t.heightCm,transform:t.transform??[{t:0,pos:[0,0,0],rotY:0,easing:"linear"}],poses:[],primitive:t.primitive,modelUrl:t.modelUrl};return Ot(n,o=>{o.shots[0].entities.push(a)})}case"removeEntity":return n.doc.shots[0].entities.some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].entities,s=r.findIndex(a=>a.id===e.id);s>=0&&r.splice(s,1)}):We(n,`unknown entity id: ${e.id}`);case"setColor":{const t=n.doc.shots[0].entities.find(i=>i.id===e.id);return t?t.kind==="character"&&!Za(e.color)?We(n,"character color must be a main color"):Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r&&(r.color=e.color)}):We(n,`unknown entity id: ${e.id}`)}case"setHeight":return n.doc.shots[0].entities.find(i=>i.id===e.id)?e.heightCm<120||e.heightCm>210?We(n,"height must be 120–210cm"):Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r&&(r.heightCm=e.heightCm)}):We(n,`unknown entity id: ${e.id}`);case"updateEntity":{const t=n.doc.shots[0],i=t.entities.find(s=>s.id===e.id);if(!i)return We(n,`unknown entity id: ${e.id}`);const{patch:r}=e;if(r.color!==void 0&&i.kind==="character"){if(!Za(r.color))return We(n,"character color must be a main color");if(t.entities.some(a=>a.id!==i.id&&a.kind==="character"&&a.color===r.color))return We(n,`color ${r.color} already used by another character`)}return r.heightCm!==void 0&&(r.heightCm<120||r.heightCm>210)?We(n,"height must be 120–210cm"):r.bodyType!==void 0&&i.kind!=="character"?We(n,"bodyType is only valid on a character"):r.primitive!==void 0&&i.kind!=="primitive"?We(n,"primitive fields are only valid on a primitive"):r.note!==void 0&&r.note.length>500?We(n,"note must be at most 500 characters"):r.primitive?.size!==void 0&&r.primitive.size.some(s=>!(s>0))?We(n,"primitive size components must be > 0"):Ot(n,s=>{const a=s.shots[0].entities.find(o=>o.id===e.id);if(r.name!==void 0&&(a.name=r.name),r.color!==void 0&&(a.color=r.color),r.heightCm!==void 0&&(a.heightCm=r.heightCm),r.bodyType!==void 0&&(a.bodyType=r.bodyType),r.modelUrl!==void 0&&(a.modelUrl=r.modelUrl),r.hidden!==void 0&&(r.hidden?a.hidden=!0:delete a.hidden),r.locked!==void 0&&(r.locked?a.locked=!0:delete a.locked),"referenceSheet"in r&&(a.referenceSheet=r.referenceSheet),"note"in r&&(a.note=r.note),r.primitive!==void 0&&a.primitive){const o=r.primitive;o.shape!==void 0&&o.shape!==a.primitive.shape&&(a.primitive.shape=o.shape,o.shape==="panorama"&&o.radius===void 0&&a.primitive.radius===void 0&&(a.primitive.radius=7),o.shape==="image"&&o.bend===void 0&&a.primitive.bend===void 0&&(a.primitive.bend=0)),o.size!==void 0&&(a.primitive.size=o.size),o.tex!==void 0&&(a.primitive.tex=o.tex),o.bend!==void 0&&(a.primitive.bend=o.bend),o.radius!==void 0&&(a.primitive.radius=o.radius)}})}case"setSettings":{const{patch:t}=e;return t.fps!==void 0&&!Yl.includes(t.fps)?We(n,`fps must be one of ${Yl.join("/")}`):t.aspect!==void 0&&!["16:9","9:16","1:1"].includes(t.aspect)?We(n,`invalid aspect: ${t.aspect}`):Ot(n,i=>{t.fps!==void 0&&(i.settings.fps=t.fps),t.aspect!==void 0&&(i.settings.aspect=t.aspect),t.name!==void 0&&(i.name=t.name)})}case"definePose":{const t=e.label?.trim();if(!t)return We(n,"pose label must be non-empty");const i=e.poseId?.trim()||Ap(n.doc.customPoses);if(Js(i))return We(n,`cannot overwrite built-in pose: ${t} (${i})`);const r=Tv(e.joints);if(!r.ok)return We(n,`pose ${t}: ${r.error}`);const s={...e.joints};return Ot(n,a=>{a.customPoses[i]=e.hidden!==void 0?{label:t,joints:s,hidden:e.hidden}:{label:t,joints:s}})}case"deletePose":return Js(e.poseId)?We(n,`cannot delete built-in pose: ${e.poseId}`):Object.prototype.hasOwnProperty.call(n.doc.customPoses,e.poseId)?n.doc.shots[0].entities.some(i=>i.poses.some(r=>r.poseId===e.poseId))?We(n,`custom pose ${e.poseId} is still referenced by a pose key`):Ot(n,i=>{delete i.customPoses[e.poseId]}):We(n,`unknown custom pose: ${e.poseId}`);case"moveKeyframe":{const t=n.doc.shots[0].entities.find(i=>i.id===e.id);return t?e.index<0||e.index>=t.transform.length?We(n,`transform index out of range: ${e.index}`):Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r.transform[e.index].pos=e.pos,r.transform[e.index].rotY=e.rotY}):We(n,`unknown entity id: ${e.id}`)}case"upsertTransformKey":{if(!n.doc.shots[0].entities.find(i=>i.id===e.id))return We(n,`unknown entity id: ${e.id}`);if(e.t<0||e.t>n.doc.settings.durationSec)return We(n,`keyframe time out of range: ${e.t}`);if(e.easing){const i=Jc([e.easing]);if(i)return We(n,i)}return Ot(n,i=>{const r=i.shots[0].entities.find(s=>s.id===e.id);r.transform=Ew(r.transform,e.t,e.pos,e.rotY,e.easing)})}case"setTransformTrack":{if(!n.doc.shots[0].entities.find(s=>s.id===e.id))return We(n,`unknown entity id: ${e.id}`);const i=Kc(e.keys.map(s=>s.t),n.doc.settings.durationSec)??Jc(e.keys.map(s=>s.easing));if(i)return We(n,i);const r=[...e.keys].sort((s,a)=>s.t-a.t);return Ot(n,s=>{s.shots[0].entities.find(a=>a.id===e.id).transform=r})}case"setPoseTrack":{if(!n.doc.shots[0].entities.find(s=>s.id===e.id))return We(n,`unknown entity id: ${e.id}`);for(const s of e.keys)if(!Ev(s.poseId,n.doc))return We(n,`unknown poseId: ${s.poseId}`);const i=e.keys.length?Kc(e.keys.map(s=>s.t),n.doc.settings.durationSec,!0):null;if(i)return We(n,i);const r=[...e.keys].sort((s,a)=>s.t-a.t);return Ot(n,s=>{s.shots[0].entities.find(a=>a.id===e.id).poses=r})}case"setCameraTrack":{const t=Kc(e.keys.map(o=>o.t),n.doc.settings.durationSec)??Jc(e.keys.map(o=>o.easing));if(t)return We(n,t);const i=n.doc.shots[0],r=e.cameraId?i.cameras.find(o=>o.id===e.cameraId):i.cameras[0];if(!r)return We(n,`unknown camera id: ${e.cameraId}`);const s=r.id,a=[...e.keys].sort((o,l)=>o.t-l.t);return Ot(n,o=>{o.shots[0].cameras.find(l=>l.id===s).keyframes=a})}case"addCamera":{const t=n.doc.shots[0].cameras,i=e.id??Wo("cam",t);if(t.some(a=>a.id===i))return We(n,`camera id already exists: ${i}`);const r=e.name?.trim()||`相机 ${t.length+1}`,s=t[0].keyframes[0];return Ot(n,a=>{a.shots[0].cameras.push({id:i,name:r,keyframes:[{...s,pos:[...s.pos],lookAt:[...s.lookAt]}]})})}case"renameCamera":return n.doc.shots[0].cameras.some(i=>i.id===e.id)?e.name.trim()?Ot(n,i=>{i.shots[0].cameras.find(r=>r.id===e.id).name=e.name.trim()}):We(n,"camera name must be non-empty"):We(n,`unknown camera id: ${e.id}`);case"setCamerasLocked":return n.doc.shots[0].camerasLocked===!0===e.locked?{...n,error:void 0}:Ot(n,i=>{const r=i.shots[0];e.locked?r.camerasLocked=!0:delete r.camerasLocked});case"deleteCamera":{const t=n.doc.shots[0].cameras;return t.some(i=>i.id===e.id)?t.length<=1?We(n,"cannot delete the last camera"):Ot(n,i=>{const r=i.shots[0];r.cameras.splice(r.cameras.findIndex(s=>s.id===e.id),1),r.cameraSwitches=r.cameraSwitches.filter(s=>s.cameraId!==e.id),r.cameraSwitches.some(s=>s.t===0)||r.cameraSwitches.unshift({t:0,cameraId:r.cameras[0].id})}):We(n,`unknown camera id: ${e.id}`)}case"setCameraSwitches":{const t=n.doc.shots[0];for(const s of e.switches){if(!t.cameras.some(a=>a.id===s.cameraId))return We(n,`unknown camera id: ${s.cameraId}`);if(s.t<0||s.t>n.doc.settings.durationSec)return We(n,`switch time out of range: ${s.t}`)}const i=[...e.switches].sort((s,a)=>s.t-a.t),r=[];for(const s of i)r.length&&Math.abs(r[r.length-1].t-s.t)<1e-9?r[r.length-1]=s:r.push(s);return(!r.length||r[0].t!==0)&&r.unshift({t:0,cameraId:t.cameras[0].id}),Ot(n,s=>{s.shots[0].cameraSwitches=r})}case"addDialogueTrack":{const t=n.doc.shots[0].dialogueTracks,i=e.id??Wo("dlg",t);return t.some(r=>r.id===i)?We(n,`dialogue track id already exists: ${i}`):Ot(n,r=>{r.shots[0].dialogueTracks.push({id:i,cues:[]})})}case"deleteDialogueTrack":return n.doc.shots[0].dialogueTracks.some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].dialogueTracks;r.splice(r.findIndex(s=>s.id===e.id),1)}):We(n,`unknown dialogue track: ${e.id}`);case"upsertDialogueCue":{const t=n.doc.shots[0],i=t.dialogueTracks.find(l=>l.id===e.trackId);if(!i)return We(n,`unknown dialogue track: ${e.trackId}`);const r=e.cue;if(!t.entities.some(l=>l.id===r.entityId))return We(n,`unknown entity id: ${r.entityId}`);const s=r.text.trim();if(!s)return We(n,"dialogue text must be non-empty");if(s.length>200)return We(n,"dialogue text must be at most 200 characters");if(r.t<0||r.t>n.doc.settings.durationSec)return We(n,`dialogue time out of range: ${r.t}`);const a=r.durationSec??Cw(s);if(!(a>0))return We(n,"dialogue durationSec must be > 0");const o=r.id??Wo("cue",i.cues);return Ot(n,l=>{const c=l.shots[0].dialogueTracks.find(h=>h.id===e.trackId),d=c.cues.find(h=>h.id===o);d?(d.entityId=r.entityId,d.text=s,d.t=r.t,d.durationSec=a):c.cues.push({id:o,entityId:r.entityId,text:s,t:r.t,durationSec:a}),c.cues.sort((h,u)=>h.t-u.t)})}case"deleteDialogueCue":{const t=n.doc.shots[0].dialogueTracks.find(i=>i.id===e.trackId);return t?t.cues.some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].dialogueTracks.find(s=>s.id===e.trackId);r.cues.splice(r.cues.findIndex(s=>s.id===e.id),1)}):We(n,`unknown cue id: ${e.id}`):We(n,`unknown dialogue track: ${e.trackId}`)}case"addMarker":{const t=e.label.trim();if(!t)return We(n,"marker label must be non-empty");if(e.t<0||e.t>n.doc.settings.durationSec)return We(n,`marker time out of range: ${e.t}`);const i=n.doc.shots[0].markers??[],r=e.id??Iw(i);return i.some(s=>s.id===r)?We(n,`marker id already exists: ${r}`):Ot(n,s=>{const a=s.shots[0];a.markers||(a.markers=[]),a.markers.push({id:r,t:e.t,label:t}),a.markers.sort((o,l)=>o.t-l.t)})}case"updateMarker":return(n.doc.shots[0].markers??[]).some(i=>i.id===e.id)?e.label!==void 0&&!e.label.trim()?We(n,"marker label must be non-empty"):e.t!==void 0&&(e.t<0||e.t>n.doc.settings.durationSec)?We(n,`marker time out of range: ${e.t}`):Ot(n,i=>{const r=i.shots[0].markers,s=r.find(a=>a.id===e.id);e.t!==void 0&&(s.t=e.t),e.label!==void 0&&(s.label=e.label.trim()),r.sort((a,o)=>a.t-o.t)}):We(n,`unknown marker id: ${e.id}`);case"deleteMarker":return(n.doc.shots[0].markers??[]).some(i=>i.id===e.id)?Ot(n,i=>{const r=i.shots[0].markers;r.splice(r.findIndex(s=>s.id===e.id),1)}):We(n,`unknown marker id: ${e.id}`);case"setDuration":return e.durationSec>0?Ot(n,t=>{t.settings.durationSec=e.durationSec}):We(n,"durationSec must be > 0");case"applyAiPatch":{const t=ww(n.doc,e.patch);return t.ok?Ot(n,i=>{const r=i.shots[0];for(const s of e.patch.ops)switch(s.op){case"placeEntity":{const a=r.entities.find(l=>l.id===s.id);if(!a)break;const o=a.transform[0]??{t:0,pos:[0,0,0],rotY:0,easing:"linear"};o.pos=s.pos,s.rotY!==void 0&&(o.rotY=s.rotY),a.transform[0]=o;break}case"setTransformKeys":{const a=r.entities.find(o=>o.id===s.id);a&&(a.transform=s.keys);break}case"setPoseKeys":{const a=r.entities.find(o=>o.id===s.id);a&&(a.poses=s.keys);break}case"setCameraKeys":{Av(r).keyframes=[...s.keys].sort((a,o)=>a.t-o.t);break}case"definePose":{const a=s.poseId?.trim()||Ap(i.customPoses);i.customPoses[a]={label:s.label,joints:{...s.joints}};break}case"updateEntity":{const a=r.entities.find(l=>l.id===s.id);if(!a)break;const o=s.patch;o.name!==void 0&&(a.name=o.name),o.color!==void 0&&(a.color=o.color),o.heightCm!==void 0&&(a.heightCm=o.heightCm),o.bodyType!==void 0&&(a.bodyType=o.bodyType),o.modelUrl!==void 0&&(a.modelUrl=o.modelUrl),o.primitive!==void 0&&a.primitive&&(o.primitive.size!==void 0&&(a.primitive.size=o.primitive.size),o.primitive.tex!==void 0&&(a.primitive.tex=o.primitive.tex),o.primitive.bend!==void 0&&(a.primitive.bend=o.primitive.bend),o.primitive.radius!==void 0&&(a.primitive.radius=o.primitive.radius));break}}}):We(n,t.error)}case"beginBatch":return n.batch?We(n,"a batch is already open"):{...n,batch:{patches:[],inverse:[],baseDoc:n.doc},error:void 0};case"commitBatch":{if(!n.batch)return n;const{patches:t,inverse:i}=n.batch;return t.length===0?{...n,batch:void 0,error:void 0}:{doc:n.doc,past:[...n.past,{patches:t,inverse:[...i].reverse()}],future:[],batch:void 0,error:void 0}}case"abortBatch":return n.batch?{...n,doc:n.batch.baseDoc,batch:void 0,error:void 0}:n;case"undo":{if(n.past.length===0)return{...n,error:void 0};const t=n.past[n.past.length-1];return{doc:wp(n.doc,t.inverse),past:n.past.slice(0,-1),future:[t,...n.future],error:void 0}}case"redo":{if(n.future.length===0)return{...n,error:void 0};const[t,...i]=n.future;return{doc:wp(n.doc,t.patches),past:[...n.past,t],future:i,error:void 0}}default:return e}}class Lw{state;constructor(e){this.state=r0(e)}get doc(){return this.state.doc}dispatch(e){return this.state=s0(this.state,e),this.state.error??null}}const sc=.001,Cc=(n,e,t)=>Math.min(t,Math.max(e,n));function ia(n){const e=Math.hypot(n[0],n[1],n[2]);return e===0?{radius:0,phi:Math.PI/2,theta:0}:{radius:e,phi:Math.acos(Cc(n[1]/e,-1,1)),theta:Math.atan2(n[0],n[2])}}function wf(n){const e=Math.sin(n.phi);return[n.radius*e*Math.sin(n.theta),n.radius*Math.cos(n.phi),n.radius*e*Math.cos(n.theta)]}function Rp(n,e){const t=Math.PI*2,i=(e-n)%t;return i<0?i+t:i}function ac(n,e,t){return[fr(n[0],e[0],t),fr(n[1],e[1],t),fr(n[2],e[2],t)]}function a0(n,e){const t=n[0],i=n[n.length-1];if(e<=t.t)return{left:t,right:t,u:0};if(e>=i.t)return{left:i,right:i,u:0};for(let r=0;r<n.length-1;r++){const s=n[r],a=n[r+1];if(e>=s.t&&e<=a.t){const o=a.t-s.t,l=o===0?0:(e-s.t)/o;return{left:s,right:a,u:l}}}return{left:i,right:i,u:0}}function Dw(n,e){const{left:t,right:i,u:r}=a0(n,e);if(t===i)return{pos:[...t.pos],rotY:t.rotY};const s=n0(t.easing,r);return{pos:ac(t.pos,i.pos,s),rotY:fr(t.rotY,i.rotY,s)}}function Nw(n,e){const{left:t,right:i,u:r}=a0(n,e);if(t===i)return{pos:[...t.pos],lookAt:[...t.lookAt],fov:t.fov};const s=n0(t.easing,r),a=ac(t.lookAt,i.lookAt,s);return{pos:t.orbit?Ow(t,i,a,s):ac(t.pos,i.pos,s),lookAt:a,fov:fr(t.fov,i.fov,s)}}function Ow(n,e,t,i){const r=n.orbit,s=ia(oc(n.pos,r.pivot??n.lookAt)),a=ia(oc(e.pos,r.pivot??e.lookAt));if(s.radius===0)return ac(n.pos,e.pos,i);const o=wf({radius:fr(s.radius,a.radius,i),phi:Cc(fr(s.phi,a.phi,i),sc,Math.PI-sc),theta:s.theta+o0(n,e)*i}),l=r.pivot??t;return[l[0]+o[0],l[1]+o[1],l[2]+o[2]]}function o0(n,e){const t=n.orbit;if(!t)return 0;const i=ia(oc(n.pos,t.pivot??n.lookAt)),r=ia(oc(e.pos,t.pivot??e.lookAt)),s=t.dir==="ccw"?1:-1;return(t.dir==="ccw"?Rp(i.theta,r.theta):-Rp(r.theta,i.theta))+s*Math.PI*2*Math.max(0,Math.round(t.turns??0))}const oc=(n,e)=>[n[0]-e[0],n[1]-e[1],n[2]-e[2]];function tr(n,e){return Vx(n,e)}function kw(n,e,t){const i={};for(const r of Yi)i[r]=fr(n[r],e[r],t);return i}function Uw(n,e,t){if(n.length===0)return{...Yr.idle};const i=n[0];if(e<=i.t)return{...tr(i.poseId,t)};const r=n[n.length-1];if(e>=r.t)return{...tr(r.poseId,t)};for(let s=0;s<n.length-1;s++){const a=n[s],o=n[s+1];if(e>=a.t&&e<=o.t){const l=a.t+Math.max(0,a.holdSec);if(e<=l)return{...tr(a.poseId,t)};const c=Math.max(0,o.transitionSec);if(c===0)return{...tr(a.poseId,t)};const d=Math.max(l,o.t-c);if(e<=d)return{...tr(a.poseId,t)};const h=o.t-d,u=h<=0?1:(e-d)/h;return kw(tr(a.poseId,t),tr(o.poseId,t),u)}}return{...tr(r.poseId,t)}}function Il(n,e,t){const i=n.shots.find(a=>a.id===e);if(!i)throw new Error(`unknown shot id: ${e}`);const r=i.entities.map(a=>{const{pos:o,rotY:l}=Dw(a.transform,t),c=a.poses&&a.poses.length>0?Uw(a.poses,t,n):{...Yr.idle};return{id:a.id,name:a.name,kind:a.kind,color:a.color,pos:o,rotY:l,jointAngles:c,heightCm:a.heightCm,bodyType:a.bodyType,primitive:a.primitive,modelUrl:a.modelUrl,hidden:a.hidden}}),s=Av(i,Fw(i,t));return{entities:r,camera:Nw(s.keyframes,t)}}function Fw(n,e){let t=n.cameras[0]?.id;for(const i of n.cameraSwitches)if(i.t<=e+1e-9)t=i.cameraId;else break;return t}function Bw(n,e){if(n.length===0)return null;let t=n[0].poseId;for(const i of n)if(i.t<=e)t=i.poseId;else break;return t}function Ga(n){return Number(n.toFixed(2)).toString()}function Go(n){return`(${n.map(Ga).join(", ")})`}function cd(n,e){const t=n.shots[0],i=Il(n,t.id,e),{durationSec:r}=n.settings,s=[];if(s.push(`SCENE SUMMARY at t=${Ga(e)}s of ${Ga(r)}s (Y-up, meters, characters face -Z at rotY=0, angles in radians).`),i.entities.length===0)s.push(" (no entities in the scene)");else for(const o of i.entities){const l=t.entities.find(d=>d.id===o.id);let c=` - ${o.name} [${o.id}] kind=${o.kind} color=${o.color}(${Gs(o.color)}) pos=${Go(o.pos)} rotY=${Ga(o.rotY)}`;if(o.kind==="character"){const d=l?Bw(l.poses,e):null;c+=` pose=${d??"idle"} height=${o.heightCm??180}cm`}o.kind==="primitive"&&o.primitive&&(c+=` shape=${o.primitive.shape} size=${Go(o.primitive.size)}`),s.push(c)}const a=i.camera;return s.push(` camera: pos=${Go(a.pos)} lookAt=${Go(a.lookAt)} fov=${Ga(a.fov)}deg`),s.join(`
203
203
  `)}function zw(n,e,t=6e3){const i=r=>({sync:s=>{const a=Date.now();try{return s()}finally{console.log(`[perf] tool ${r} ${Date.now()-a}ms`)}},async:async s=>{const a=Date.now();try{return await s()}finally{console.log(`[perf] tool ${r} ${Date.now()-a}ms`)}}});return{begin:()=>n.dispatch({type:"beginBatch"}),commit:()=>n.dispatch({type:"commitBatch"}),abort:()=>n.dispatch({type:"abortBatch"}),execute:r=>i("execute").sync(()=>n.dispatch(r)),screenshot:r=>i("screenshot").async(async()=>{const s=await e.requestScreenshot(n.doc.id,r,t);return s&&s.image?{kind:"image",dataUrl:s.image,overlays:r.overlays??[]}:{kind:"summary",summary:cd(n.doc,r.t??0)}}),poseScreenshot:r=>i("poseScreenshot").async(async()=>{const s=r.t??0;return{kind:"summary",summary:cd(n.doc,s)}})}}class Vw{content="";reasoning="";calls=new Map;push(e){const t=[];typeof e.reasoning_content=="string"&&e.reasoning_content.length>0&&(this.reasoning+=e.reasoning_content,t.push({type:"reasoning-delta",delta:e.reasoning_content})),typeof e.content=="string"&&e.content.length>0&&(this.content+=e.content,t.push({type:"text-delta",delta:e.content}));for(const i of e.tool_calls??[]){const r=i.index;let s=this.calls.get(r);s||(s={index:r,id:"",name:"",args:"",started:!1},this.calls.set(r,s)),i.id&&(s.id+=i.id),i.function?.name&&(s.name+=i.function.name),!s.started&&s.id&&s.name&&(s.started=!0,t.push({type:"tool-start",index:r,id:s.id,name:s.name})),i.function&&typeof i.function.arguments=="string"&&(s.args+=i.function.arguments,s.started&&i.function.arguments.length>0&&t.push({type:"tool-args-delta",index:r,id:s.id,delta:i.function.arguments}))}return t}get text(){return this.content}finish(){const e=[...this.calls.values()].filter(t=>t.name.length>0).sort((t,i)=>t.index-i.index).map(t=>({id:t.id,name:t.name,arguments:t.args}));return{content:this.content.length>0?this.content:void 0,...this.reasoning.length>0?{reasoning:this.reasoning}:{},toolCalls:e}}}function Hw(n){return n.map(e=>{switch(e.role){case"system":return{role:"system",content:e.content};case"user":return e.images&&e.images.length?{role:"user",content:[{type:"text",text:e.content},...e.images.map(t=>({type:"image_url",image_url:{url:t}}))]}:{role:"user",content:e.content};case"assistant":return{role:"assistant",content:e.content??"",...e.toolCalls&&e.toolCalls.length?{tool_calls:e.toolCalls.map(t=>({id:t.id,type:"function",function:{name:t.name,arguments:t.arguments}}))}:{},...e.reasoning?{reasoning_content:e.reasoning}:{}};case"tool":return e.image?{role:"tool",tool_call_id:e.toolCallId,content:[{type:"text",text:e.content},{type:"image_url",image_url:{url:e.image}}]}:{role:"tool",tool_call_id:e.toolCallId,content:e.content}}})}function Ww(n,e){const t=n.map((r,s)=>r.role==="tool"&&r.image?s:-1).filter(r=>r>=0),i=new Set(t.slice(-Math.max(0,e)));return n.map((r,s)=>r.role==="tool"&&r.image&&!i.has(s)?{...r,image:void 0}:r)}function Gw(n){if(!n.startsWith("data:"))return null;const e=n.slice(5).trim();if(e==="[DONE]"||e==="")return null;const i=JSON.parse(e).choices?.[0]?.delta;return i?[i]:[]}function jw(n){const e=n.fetchFn??((...i)=>fetch(...i));let t=0;return{async chatWithTools(i){const r=t+=1,s=Date.now(),a=Ww(i.messages,n.maxContextImages??1),o=a.filter(p=>p.role==="tool"&&p.image).length,l={};n.reasoningEffort==="off"?l.thinking={type:"disabled"}:(n.reasoningEffort==="low"||n.reasoningEffort==="high"||n.reasoningEffort==="max")&&(l.reasoning_effort=n.reasoningEffort,l.thinking={type:"enabled"});const c=JSON.stringify({model:i.model,messages:Hw(a),tools:i.tools,tool_choice:"auto",stream:!0,...l}),d=await e(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n.apiKey}`},body:c,signal:i.signal});if(!d.ok||!d.body){const p=await d.text().catch(()=>"");throw new Error(`LLM upstream ${d.status}: ${p.slice(0,300)}`)}const h=new Vw,u=d.body.getReader(),f=new TextDecoder;let m="",v=null,g=0;for(;;){const{done:p,value:y}=await u.read();if(p)break;v??=Date.now()-s,g+=y.byteLength,m+=f.decode(y,{stream:!0});let x;for(;(x=m.indexOf(`
204
204
  `))>=0;){const S=m.slice(0,x).trim();m=m.slice(x+1);const T=Gw(S);if(T!==null)for(const C of T)for(const E of h.push(C))i.onStreamEvent?.(E)}}return console.log(`[perf] upstream round=${r} ttfb=${v??"n/a"}ms stream=${Date.now()-s}ms reqKB=${(c.length/1024).toFixed(0)} resKB=${(g/1024).toFixed(0)} imgs=${o}`),h.finish()}}}const $w={0:"off",1:"low",2:"high",3:"max"},Cp=400;class Xw{constructor(e){this.deps=e}sessions=new Map;seq=0;async create(e){if(!await this.deps.store.get(e.projectId))return{error:"not-found"};const i=`s_${this.seq+=1}`,r={id:i,projectId:e.projectId,controller:new AbortController,done:!1,error:null,buffer:[],subscriber:null,doneWaiters:[]};return this.sessions.set(i,r),this.run(r,e),{id:i}}get(e){return this.sessions.get(e)}cancel(e){const t=this.sessions.get(e);return!t||t.done?!1:(t.controller.abort(),!0)}waitForDone(e){return e.done?Promise.resolve():new Promise(t=>e.doneWaiters.push(t))}emit(e,t){e.buffer.push(t),e.buffer.length>Cp&&e.buffer.splice(0,e.buffer.length-Cp),e.subscriber?.next(t)}finish(e,t,i){e.done=!0,e.error=t,i&&(e.result=i);const r=e.doneWaiters.splice(0);for(const s of r)s()}async run(e,t){const i=Date.now();let r=0;try{const s=await this.deps.store.get(t.projectId);if(!s){this.emit(e,{type:"error",message:"project not found"}),this.finish(e,"project not found");return}const a=new Lw(s.doc),o=zw(a,this.deps.registry),l=this.deps.llmOptions(),c=this.deps.transportFactory?this.deps.transportFactory(l):jw({...l,...t.reasoningEffort!==void 0?{reasoningEffort:$w[t.reasoningEffort]}:{}}),d=Xb(s.doc,t.locale,{attachedImages:t.images?.length??0});let h=null,u=null;try{h=await Bb({model:t.model||this.deps.defaultModel,systemPrompt:d,userInstruction:t.instruction,userImages:t.images,transport:c,host:o,maxRounds:t.maxRounds,signal:e.controller.signal,onEvent:m=>{m.type==="done"&&(e.result=m.result),this.emit(e,m),m.type==="tool-result"&&this.deps.registry.broadcast(e.projectId,{v:1,type:"agent-progress",projectId:e.projectId,doc:a.doc})}})}catch(m){u=m instanceof Error?m.message:String(m),this.emit(e,{type:"done",result:{reason:e.controller.signal.aborted?"aborted":"error",rounds:h?.rounds??0,applied:!1}})}if(h&&h.applied){const m=Date.now();await this.persist(e.projectId,a.doc),r=Date.now()-m}this.finish(e,u);const f=Date.now()-i;console.log(`[agent] session ${e.id} finished: reason=${h?.reason??"error"} rounds=${h?.rounds??0} applied=${h?.applied===!0}${u?` fatal=${u}`:""}`),console.log(`[perf] session ${e.id} total=${f}ms persist=${r}ms rounds=${h?.rounds??0}`)}catch(s){const a=s instanceof Error?s.message:String(s);this.emit(e,{type:"done",result:{reason:"error",rounds:0,applied:!1}}),this.finish(e,a)}}async persist(e,t){try{await this.deps.store.put(e,t)}catch{}}}function qw(n){const e=new hs;return e.post("/sessions",async t=>{const i=await t.req.json().catch(()=>null);if(!i||typeof i.projectId!="string"||typeof i.instruction!="string")return t.json({error:"invalid-body"},400);const r={projectId:i.projectId,instruction:i.instruction,images:Array.isArray(i.images)?i.images.filter(o=>typeof o=="string"):void 0,model:typeof i.model=="string"?i.model.trim():"",maxRounds:typeof i.maxRounds=="number"?i.maxRounds:16,locale:i.locale==="en"?"en":"zh",reasoningEffort:typeof i.reasoningEffort=="number"&&[0,1,2,3].includes(i.reasoningEffort)?i.reasoningEffort:void 0},{id:s,error:a}=await n.create(r);return a?t.json({error:a},404):t.json({sessionId:s},201)}),e.get("/sessions/:id/events",t=>{const i=process.env.FS_DEBUG_SSE==="1";return Lx(t,async r=>{const s=n.get(t.req.param("id"));if(!s){await r.writeSSE({data:JSON.stringify({type:"error",message:"unknown-session"})});return}const a=[];s.subscriber={next:o=>{i&&console.log(`[sse] send ${o.type} (done=${String(s.done)})`),a.push(r.writeSSE({data:JSON.stringify(o)}).then(()=>{},()=>{}))}},i&&console.log(`[sse] subscribed ${s.id} buffer=${s.buffer.map(o=>o.type).join(",")||"(empty)"}`);for(const o of s.buffer)i&&console.log(`[sse] replay ${o.type}`),await r.writeSSE({data:JSON.stringify(o)});for(;!s.done;)await n.waitForDone(s);await Promise.all(a),i&&console.log(`[sse] closing ${s.id} (done=${String(s.done)})`)})}),e.post("/sessions/:id/cancel",t=>{const i=n.cancel(t.req.param("id"));return t.json({ok:i})}),e}var yn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Qc={},eu={},Dn={},jo={exports:{}},$o={exports:{}},Pp;function Pc(){if(Pp)return $o.exports;Pp=1,typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?$o.exports={nextTick:n}:$o.exports=process;function n(e,t,i,r){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var s=arguments.length,a,o;switch(s){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,i)});case 4:return process.nextTick(function(){e.call(null,t,i,r)});default:for(a=new Array(s-1),o=0;o<a.length;)a[o++]=arguments[o];return process.nextTick(function(){e.apply(null,a)})}}return $o.exports}var tu,Ip;function Yw(){if(Ip)return tu;Ip=1;var n={}.toString;return tu=Array.isArray||function(e){return n.call(e)=="[object Array]"},tu}var nu,Lp;function l0(){return Lp||(Lp=1,nu=wv),nu}var Xo={exports:{}},Dp;function Ic(){return Dp||(Dp=1,(function(n,e){var t=Mv,i=t.Buffer;function r(a,o){for(var l in a)o[l]=a[l]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=t:(r(t,e),e.Buffer=s);function s(a,o,l){return i(a,o,l)}r(i,s),s.from=function(a,o,l){if(typeof a=="number")throw new TypeError("Argument must not be a number");return i(a,o,l)},s.alloc=function(a,o,l){if(typeof a!="number")throw new TypeError("Argument must be a number");var c=i(a);return o!==void 0?typeof l=="string"?c.fill(o,l):c.fill(o):c.fill(0),c},s.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return i(a)},s.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(a)}})(Xo,Xo.exports)),Xo.exports}var dn={},Np;function No(){if(Np)return dn;Np=1;function n(v){return Array.isArray?Array.isArray(v):m(v)==="[object Array]"}dn.isArray=n;function e(v){return typeof v=="boolean"}dn.isBoolean=e;function t(v){return v===null}dn.isNull=t;function i(v){return v==null}dn.isNullOrUndefined=i;function r(v){return typeof v=="number"}dn.isNumber=r;function s(v){return typeof v=="string"}dn.isString=s;function a(v){return typeof v=="symbol"}dn.isSymbol=a;function o(v){return v===void 0}dn.isUndefined=o;function l(v){return m(v)==="[object RegExp]"}dn.isRegExp=l;function c(v){return typeof v=="object"&&v!==null}dn.isObject=c;function d(v){return m(v)==="[object Date]"}dn.isDate=d;function h(v){return m(v)==="[object Error]"||v instanceof Error}dn.isError=h;function u(v){return typeof v=="function"}dn.isFunction=u;function f(v){return v===null||typeof v=="boolean"||typeof v=="number"||typeof v=="string"||typeof v=="symbol"||typeof v>"u"}dn.isPrimitive=f,dn.isBuffer=Mv.Buffer.isBuffer;function m(v){return Object.prototype.toString.call(v)}return dn}var qo={exports:{}},Yo={exports:{}},Op;function Zw(){return Op||(Op=1,typeof Object.create=="function"?Yo.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Yo.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}),Yo.exports}var kp;function Oo(){if(kp)return qo.exports;kp=1;try{var n=require("util");if(typeof n.inherits!="function")throw"";qo.exports=n.inherits}catch{qo.exports=Zw()}return qo.exports}var iu={exports:{}},Up;function Kw(){return Up||(Up=1,(function(n){function e(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}var t=Ic().Buffer,i=_f;function r(s,a,o){s.copy(a,o)}n.exports=(function(){function s(){e(this,s),this.head=null,this.tail=null,this.length=0}return s.prototype.push=function(o){var l={data:o,next:null};this.length>0?this.tail.next=l:this.head=l,this.tail=l,++this.length},s.prototype.unshift=function(o){var l={data:o,next:this.head};this.length===0&&(this.tail=l),this.head=l,++this.length},s.prototype.shift=function(){if(this.length!==0){var o=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,o}},s.prototype.clear=function(){this.head=this.tail=null,this.length=0},s.prototype.join=function(o){if(this.length===0)return"";for(var l=this.head,c=""+l.data;l=l.next;)c+=o+l.data;return c},s.prototype.concat=function(o){if(this.length===0)return t.alloc(0);for(var l=t.allocUnsafe(o>>>0),c=this.head,d=0;c;)r(c.data,l,d),d+=c.data.length,c=c.next;return l},s})(),i&&i.inspect&&i.inspect.custom&&(n.exports.prototype[i.inspect.custom]=function(){var s=i.inspect({length:this.length});return this.constructor.name+" "+s})})(iu)),iu.exports}var ru,Fp;function c0(){if(Fp)return ru;Fp=1;var n=Pc();function e(r,s){var a=this,o=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return o||l?(s?s(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(i,this,r)):n.nextTick(i,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,function(c){!s&&c?a._writableState?a._writableState.errorEmitted||(a._writableState.errorEmitted=!0,n.nextTick(i,a,c)):n.nextTick(i,a,c):s&&s(c)}),this)}function t(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function i(r,s){r.emit("error",s)}return ru={destroy:e,undestroy:t},ru}var su,Bp;function Jw(){return Bp||(Bp=1,su=_f.deprecate),su}var au,zp;function u0(){if(zp)return au;zp=1;var n=Pc();au=v;function e(k){var N=this;this.next=null,this.entry=null,this.finish=function(){ee(N,k)}}var t=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:n.nextTick,i;v.WritableState=f;var r=Object.create(No());r.inherits=Oo();var s={deprecate:Jw()},a=l0(),o=Ic().Buffer,l=(typeof yn<"u"?yn:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(k){return o.from(k)}function d(k){return o.isBuffer(k)||k instanceof l}var h=c0();r.inherits(v,a);function u(){}function f(k,N){i=i||ra(),k=k||{};var W=N instanceof i;this.objectMode=!!k.objectMode,W&&(this.objectMode=this.objectMode||!!k.writableObjectMode);var ie=k.highWaterMark,_e=k.writableHighWaterMark,Ee=this.objectMode?16:16*1024;ie||ie===0?this.highWaterMark=ie:W&&(_e||_e===0)?this.highWaterMark=_e:this.highWaterMark=Ee,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var Pe=k.decodeStrings===!1;this.decodeStrings=!Pe,this.defaultEncoding=k.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ce){E(N,ce)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}f.prototype.getBuffer=function(){for(var N=this.bufferedRequest,W=[];N;)W.push(N),N=N.next;return W},(function(){try{Object.defineProperty(f.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var m;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(m=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(k){return m.call(this,k)?!0:this!==v?!1:k&&k._writableState instanceof f}})):m=function(k){return k instanceof this};function v(k){if(i=i||ra(),!m.call(v,this)&&!(this instanceof i))return new v(k);this._writableState=new f(k,this),this.writable=!0,k&&(typeof k.write=="function"&&(this._write=k.write),typeof k.writev=="function"&&(this._writev=k.writev),typeof k.destroy=="function"&&(this._destroy=k.destroy),typeof k.final=="function"&&(this._final=k.final)),a.call(this)}v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function g(k,N){var W=new Error("write after end");k.emit("error",W),n.nextTick(N,W)}function p(k,N,W,ie){var _e=!0,Ee=!1;return W===null?Ee=new TypeError("May not write null values to stream"):typeof W!="string"&&W!==void 0&&!N.objectMode&&(Ee=new TypeError("Invalid non-string/buffer chunk")),Ee&&(k.emit("error",Ee),n.nextTick(ie,Ee),_e=!1),_e}v.prototype.write=function(k,N,W){var ie=this._writableState,_e=!1,Ee=!ie.objectMode&&d(k);return Ee&&!o.isBuffer(k)&&(k=c(k)),typeof N=="function"&&(W=N,N=null),Ee?N="buffer":N||(N=ie.defaultEncoding),typeof W!="function"&&(W=u),ie.ended?g(this,W):(Ee||p(this,ie,k,W))&&(ie.pendingcb++,_e=x(this,ie,Ee,k,N,W)),_e},v.prototype.cork=function(){var k=this._writableState;k.corked++},v.prototype.uncork=function(){var k=this._writableState;k.corked&&(k.corked--,!k.writing&&!k.corked&&!k.bufferProcessing&&k.bufferedRequest&&b(this,k))},v.prototype.setDefaultEncoding=function(N){if(typeof N=="string"&&(N=N.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((N+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+N);return this._writableState.defaultEncoding=N,this};function y(k,N,W){return!k.objectMode&&k.decodeStrings!==!1&&typeof N=="string"&&(N=o.from(N,W)),N}Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function x(k,N,W,ie,_e,Ee){if(!W){var Pe=y(N,ie,_e);ie!==Pe&&(W=!0,_e="buffer",ie=Pe)}var ce=N.objectMode?1:ie.length;N.length+=ce;var ve=N.length<N.highWaterMark;if(ve||(N.needDrain=!0),N.writing||N.corked){var we=N.lastBufferedRequest;N.lastBufferedRequest={chunk:ie,encoding:_e,isBuf:W,callback:Ee,next:null},we?we.next=N.lastBufferedRequest:N.bufferedRequest=N.lastBufferedRequest,N.bufferedRequestCount+=1}else S(k,N,!1,ce,ie,_e,Ee);return ve}function S(k,N,W,ie,_e,Ee,Pe){N.writelen=ie,N.writecb=Pe,N.writing=!0,N.sync=!0,W?k._writev(_e,N.onwrite):k._write(_e,Ee,N.onwrite),N.sync=!1}function T(k,N,W,ie,_e){--N.pendingcb,W?(n.nextTick(_e,ie),n.nextTick(Z,k,N),k._writableState.errorEmitted=!0,k.emit("error",ie)):(_e(ie),k._writableState.errorEmitted=!0,k.emit("error",ie),Z(k,N))}function C(k){k.writing=!1,k.writecb=null,k.length-=k.writelen,k.writelen=0}function E(k,N){var W=k._writableState,ie=W.sync,_e=W.writecb;if(C(W),N)T(k,W,ie,N,_e);else{var Ee=R(W);!Ee&&!W.corked&&!W.bufferProcessing&&W.bufferedRequest&&b(k,W),ie?t(U,k,W,Ee,_e):U(k,W,Ee,_e)}}function U(k,N,W,ie){W||Y(k,N),N.pendingcb--,ie(),Z(k,N)}function Y(k,N){N.length===0&&N.needDrain&&(N.needDrain=!1,k.emit("drain"))}function b(k,N){N.bufferProcessing=!0;var W=N.bufferedRequest;if(k._writev&&W&&W.next){var ie=N.bufferedRequestCount,_e=new Array(ie),Ee=N.corkedRequestsFree;Ee.entry=W;for(var Pe=0,ce=!0;W;)_e[Pe]=W,W.isBuf||(ce=!1),W=W.next,Pe+=1;_e.allBuffers=ce,S(k,N,!0,N.length,_e,"",Ee.finish),N.pendingcb++,N.lastBufferedRequest=null,Ee.next?(N.corkedRequestsFree=Ee.next,Ee.next=null):N.corkedRequestsFree=new e(N),N.bufferedRequestCount=0}else{for(;W;){var ve=W.chunk,we=W.encoding,I=W.callback,D=N.objectMode?1:ve.length;if(S(k,N,!1,D,ve,we,I),W=W.next,N.bufferedRequestCount--,N.writing)break}W===null&&(N.lastBufferedRequest=null)}N.bufferedRequest=W,N.bufferProcessing=!1}v.prototype._write=function(k,N,W){W(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(k,N,W){var ie=this._writableState;typeof k=="function"?(W=k,k=null,N=null):typeof N=="function"&&(W=N,N=null),k!=null&&this.write(k,N),ie.corked&&(ie.corked=1,this.uncork()),ie.ending||de(this,ie,W)};function R(k){return k.ending&&k.length===0&&k.bufferedRequest===null&&!k.finished&&!k.writing}function X(k,N){k._final(function(W){N.pendingcb--,W&&k.emit("error",W),N.prefinished=!0,k.emit("prefinish"),Z(k,N)})}function j(k,N){!N.prefinished&&!N.finalCalled&&(typeof k._final=="function"?(N.pendingcb++,N.finalCalled=!0,n.nextTick(X,k,N)):(N.prefinished=!0,k.emit("prefinish")))}function Z(k,N){var W=R(N);return W&&(j(k,N),N.pendingcb===0&&(N.finished=!0,k.emit("finish"))),W}function de(k,N,W){N.ending=!0,Z(k,N),W&&(N.finished?n.nextTick(W):k.once("finish",W)),N.ended=!0,k.writable=!1}function ee(k,N,W){var ie=k.entry;for(k.entry=null;ie;){var _e=ie.callback;N.pendingcb--,_e(W),ie=ie.next}N.corkedRequestsFree.next=k}return Object.defineProperty(v.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(k){this._writableState&&(this._writableState.destroyed=k)}}),v.prototype.destroy=h.destroy,v.prototype._undestroy=h.undestroy,v.prototype._destroy=function(k,N){this.end(),N(k)},au}var ou,Vp;function ra(){if(Vp)return ou;Vp=1;var n=Pc(),e=Object.keys||function(h){var u=[];for(var f in h)u.push(f);return u};ou=l;var t=Object.create(No());t.inherits=Oo();var i=h0(),r=u0();t.inherits(l,i);for(var s=e(r.prototype),a=0;a<s.length;a++){var o=s[a];l.prototype[o]||(l.prototype[o]=r.prototype[o])}function l(h){if(!(this instanceof l))return new l(h);i.call(this,h),r.call(this,h),h&&h.readable===!1&&(this.readable=!1),h&&h.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,h&&h.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",c)}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function c(){this.allowHalfOpen||this._writableState.ended||n.nextTick(d,this)}function d(h){h.end()}return Object.defineProperty(l.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(h){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=h,this._writableState.destroyed=h)}}),l.prototype._destroy=function(h,u){this.push(null),this.end(),n.nextTick(u,h)},ou}var lu={},Hp;function Wp(){if(Hp)return lu;Hp=1;var n=Ic().Buffer,e=n.isEncoding||function(p){switch(p=""+p,p&&p.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(p){if(!p)return"utf8";for(var y;;)switch(p){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return p;default:if(y)return;p=(""+p).toLowerCase(),y=!0}}function i(p){var y=t(p);if(typeof y!="string"&&(n.isEncoding===e||!e(p)))throw new Error("Unknown encoding: "+p);return y||p}lu.StringDecoder=r;function r(p){this.encoding=i(p);var y;switch(this.encoding){case"utf16le":this.text=h,this.end=u,y=4;break;case"utf8":this.fillLast=l,y=4;break;case"base64":this.text=f,this.end=m,y=3;break;default:this.write=v,this.end=g;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(y)}r.prototype.write=function(p){if(p.length===0)return"";var y,x;if(this.lastNeed){if(y=this.fillLast(p),y===void 0)return"";x=this.lastNeed,this.lastNeed=0}else x=0;return x<p.length?y?y+this.text(p,x):this.text(p,x):y||""},r.prototype.end=d,r.prototype.text=c,r.prototype.fillLast=function(p){if(this.lastNeed<=p.length)return p.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);p.copy(this.lastChar,this.lastTotal-this.lastNeed,0,p.length),this.lastNeed-=p.length};function s(p){return p<=127?0:p>>5===6?2:p>>4===14?3:p>>3===30?4:p>>6===2?-1:-2}function a(p,y,x){var S=y.length-1;if(S<x)return 0;var T=s(y[S]);return T>=0?(T>0&&(p.lastNeed=T-1),T):--S<x||T===-2?0:(T=s(y[S]),T>=0?(T>0&&(p.lastNeed=T-2),T):--S<x||T===-2?0:(T=s(y[S]),T>=0?(T>0&&(T===2?T=0:p.lastNeed=T-3),T):0))}function o(p,y,x){if((y[0]&192)!==128)return p.lastNeed=0,"�";if(p.lastNeed>1&&y.length>1){if((y[1]&192)!==128)return p.lastNeed=1,"�";if(p.lastNeed>2&&y.length>2&&(y[2]&192)!==128)return p.lastNeed=2,"�"}}function l(p){var y=this.lastTotal-this.lastNeed,x=o(this,p);if(x!==void 0)return x;if(this.lastNeed<=p.length)return p.copy(this.lastChar,y,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);p.copy(this.lastChar,y,0,p.length),this.lastNeed-=p.length}function c(p,y){var x=a(this,p,y);if(!this.lastNeed)return p.toString("utf8",y);this.lastTotal=x;var S=p.length-(x-this.lastNeed);return p.copy(this.lastChar,0,S),p.toString("utf8",y,S)}function d(p){var y=p&&p.length?this.write(p):"";return this.lastNeed?y+"�":y}function h(p,y){if((p.length-y)%2===0){var x=p.toString("utf16le",y);if(x){var S=x.charCodeAt(x.length-1);if(S>=55296&&S<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=p[p.length-2],this.lastChar[1]=p[p.length-1],x.slice(0,-1)}return x}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=p[p.length-1],p.toString("utf16le",y,p.length-1)}function u(p){var y=p&&p.length?this.write(p):"";if(this.lastNeed){var x=this.lastTotal-this.lastNeed;return y+this.lastChar.toString("utf16le",0,x)}return y}function f(p,y){var x=(p.length-y)%3;return x===0?p.toString("base64",y):(this.lastNeed=3-x,this.lastTotal=3,x===1?this.lastChar[0]=p[p.length-1]:(this.lastChar[0]=p[p.length-2],this.lastChar[1]=p[p.length-1]),p.toString("base64",y,p.length-x))}function m(p){var y=p&&p.length?this.write(p):"";return this.lastNeed?y+this.lastChar.toString("base64",0,3-this.lastNeed):y}function v(p){return p.toString(this.encoding)}function g(p){return p&&p.length?this.write(p):""}return lu}var cu,Gp;function h0(){if(Gp)return cu;Gp=1;var n=Pc();cu=y;var e=Yw(),t;y.ReadableState=p,Dx.EventEmitter;var i=function(I,D){return I.listeners(D).length},r=l0(),s=Ic().Buffer,a=(typeof yn<"u"?yn:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(I){return s.from(I)}function l(I){return s.isBuffer(I)||I instanceof a}var c=Object.create(No());c.inherits=Oo();var d=_f,h=void 0;d&&d.debuglog?h=d.debuglog("stream"):h=function(){};var u=Kw(),f=c0(),m;c.inherits(y,r);var v=["error","close","destroy","pause","resume"];function g(I,D,se){if(typeof I.prependListener=="function")return I.prependListener(D,se);!I._events||!I._events[D]?I.on(D,se):e(I._events[D])?I._events[D].unshift(se):I._events[D]=[se,I._events[D]]}function p(I,D){t=t||ra(),I=I||{};var se=D instanceof t;this.objectMode=!!I.objectMode,se&&(this.objectMode=this.objectMode||!!I.readableObjectMode);var ge=I.highWaterMark,De=I.readableHighWaterMark,Se=this.objectMode?16:16*1024;ge||ge===0?this.highWaterMark=ge:se&&(De||De===0)?this.highWaterMark=De:this.highWaterMark=Se,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new u,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=I.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,I.encoding&&(m||(m=Wp().StringDecoder),this.decoder=new m(I.encoding),this.encoding=I.encoding)}function y(I){if(t=t||ra(),!(this instanceof y))return new y(I);this._readableState=new p(I,this),this.readable=!0,I&&(typeof I.read=="function"&&(this._read=I.read),typeof I.destroy=="function"&&(this._destroy=I.destroy)),r.call(this)}Object.defineProperty(y.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(I){this._readableState&&(this._readableState.destroyed=I)}}),y.prototype.destroy=f.destroy,y.prototype._undestroy=f.undestroy,y.prototype._destroy=function(I,D){this.push(null),D(I)},y.prototype.push=function(I,D){var se=this._readableState,ge;return se.objectMode?ge=!0:typeof I=="string"&&(D=D||se.defaultEncoding,D!==se.encoding&&(I=s.from(I,D),D=""),ge=!0),x(this,I,D,!1,ge)},y.prototype.unshift=function(I){return x(this,I,null,!0,!1)};function x(I,D,se,ge,De){var Se=I._readableState;if(D===null)Se.reading=!1,b(I,Se);else{var z;De||(z=T(Se,D)),z?I.emit("error",z):Se.objectMode||D&&D.length>0?(typeof D!="string"&&!Se.objectMode&&Object.getPrototypeOf(D)!==s.prototype&&(D=o(D)),ge?Se.endEmitted?I.emit("error",new Error("stream.unshift() after end event")):S(I,Se,D,!0):Se.ended?I.emit("error",new Error("stream.push() after EOF")):(Se.reading=!1,Se.decoder&&!se?(D=Se.decoder.write(D),Se.objectMode||D.length!==0?S(I,Se,D,!1):j(I,Se)):S(I,Se,D,!1))):ge||(Se.reading=!1)}return C(Se)}function S(I,D,se,ge){D.flowing&&D.length===0&&!D.sync?(I.emit("data",se),I.read(0)):(D.length+=D.objectMode?1:se.length,ge?D.buffer.unshift(se):D.buffer.push(se),D.needReadable&&R(I)),j(I,D)}function T(I,D){var se;return!l(D)&&typeof D!="string"&&D!==void 0&&!I.objectMode&&(se=new TypeError("Invalid non-string/buffer chunk")),se}function C(I){return!I.ended&&(I.needReadable||I.length<I.highWaterMark||I.length===0)}y.prototype.isPaused=function(){return this._readableState.flowing===!1},y.prototype.setEncoding=function(I){return m||(m=Wp().StringDecoder),this._readableState.decoder=new m(I),this._readableState.encoding=I,this};var E=8388608;function U(I){return I>=E?I=E:(I--,I|=I>>>1,I|=I>>>2,I|=I>>>4,I|=I>>>8,I|=I>>>16,I++),I}function Y(I,D){return I<=0||D.length===0&&D.ended?0:D.objectMode?1:I!==I?D.flowing&&D.length?D.buffer.head.data.length:D.length:(I>D.highWaterMark&&(D.highWaterMark=U(I)),I<=D.length?I:D.ended?D.length:(D.needReadable=!0,0))}y.prototype.read=function(I){h("read",I),I=parseInt(I,10);var D=this._readableState,se=I;if(I!==0&&(D.emittedReadable=!1),I===0&&D.needReadable&&(D.length>=D.highWaterMark||D.ended))return h("read: emitReadable",D.length,D.ended),D.length===0&&D.ended?ce(this):R(this),null;if(I=Y(I,D),I===0&&D.ended)return D.length===0&&ce(this),null;var ge=D.needReadable;h("need readable",ge),(D.length===0||D.length-I<D.highWaterMark)&&(ge=!0,h("length less than watermark",ge)),D.ended||D.reading?(ge=!1,h("reading or ended",ge)):ge&&(h("do read"),D.reading=!0,D.sync=!0,D.length===0&&(D.needReadable=!0),this._read(D.highWaterMark),D.sync=!1,D.reading||(I=Y(se,D)));var De;return I>0?De=ie(I,D):De=null,De===null?(D.needReadable=!0,I=0):D.length-=I,D.length===0&&(D.ended||(D.needReadable=!0),se!==I&&D.ended&&ce(this)),De!==null&&this.emit("data",De),De};function b(I,D){if(!D.ended){if(D.decoder){var se=D.decoder.end();se&&se.length&&(D.buffer.push(se),D.length+=D.objectMode?1:se.length)}D.ended=!0,R(I)}}function R(I){var D=I._readableState;D.needReadable=!1,D.emittedReadable||(h("emitReadable",D.flowing),D.emittedReadable=!0,D.sync?n.nextTick(X,I):X(I))}function X(I){h("emit readable"),I.emit("readable"),W(I)}function j(I,D){D.readingMore||(D.readingMore=!0,n.nextTick(Z,I,D))}function Z(I,D){for(var se=D.length;!D.reading&&!D.flowing&&!D.ended&&D.length<D.highWaterMark&&(h("maybeReadMore read 0"),I.read(0),se!==D.length);)se=D.length;D.readingMore=!1}y.prototype._read=function(I){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(I,D){var se=this,ge=this._readableState;switch(ge.pipesCount){case 0:ge.pipes=I;break;case 1:ge.pipes=[ge.pipes,I];break;default:ge.pipes.push(I);break}ge.pipesCount+=1,h("pipe count=%d opts=%j",ge.pipesCount,D);var De=(!D||D.end!==!1)&&I!==process.stdout&&I!==process.stderr,Se=De?Tt:me;ge.endEmitted?n.nextTick(Se):se.once("end",Se),I.on("unpipe",z);function z(xe,fe){h("onunpipe"),xe===se&&fe&&fe.hasUnpiped===!1&&(fe.hasUnpiped=!0,ke())}function Tt(){h("onend"),I.end()}var Je=de(se);I.on("drain",Je);var et=!1;function ke(){h("cleanup"),I.removeListener("close",P),I.removeListener("finish",ne),I.removeListener("drain",Je),I.removeListener("error",F),I.removeListener("unpipe",z),se.removeListener("end",Tt),se.removeListener("end",me),se.removeListener("data",Ge),et=!0,ge.awaitDrain&&(!I._writableState||I._writableState.needDrain)&&Je()}var Fe=!1;se.on("data",Ge);function Ge(xe){h("ondata"),Fe=!1;var fe=I.write(xe);fe===!1&&!Fe&&((ge.pipesCount===1&&ge.pipes===I||ge.pipesCount>1&&we(ge.pipes,I)!==-1)&&!et&&(h("false write response, pause",ge.awaitDrain),ge.awaitDrain++,Fe=!0),se.pause())}function F(xe){h("onerror",xe),me(),I.removeListener("error",F),i(I,"error")===0&&I.emit("error",xe)}g(I,"error",F);function P(){I.removeListener("finish",ne),me()}I.once("close",P);function ne(){h("onfinish"),I.removeListener("close",P),me()}I.once("finish",ne);function me(){h("unpipe"),se.unpipe(I)}return I.emit("pipe",se),ge.flowing||(h("pipe resume"),se.resume()),I};function de(I){return function(){var D=I._readableState;h("pipeOnDrain",D.awaitDrain),D.awaitDrain&&D.awaitDrain--,D.awaitDrain===0&&i(I,"data")&&(D.flowing=!0,W(I))}}y.prototype.unpipe=function(I){var D=this._readableState,se={hasUnpiped:!1};if(D.pipesCount===0)return this;if(D.pipesCount===1)return I&&I!==D.pipes?this:(I||(I=D.pipes),D.pipes=null,D.pipesCount=0,D.flowing=!1,I&&I.emit("unpipe",this,se),this);if(!I){var ge=D.pipes,De=D.pipesCount;D.pipes=null,D.pipesCount=0,D.flowing=!1;for(var Se=0;Se<De;Se++)ge[Se].emit("unpipe",this,{hasUnpiped:!1});return this}var z=we(D.pipes,I);return z===-1?this:(D.pipes.splice(z,1),D.pipesCount-=1,D.pipesCount===1&&(D.pipes=D.pipes[0]),I.emit("unpipe",this,se),this)},y.prototype.on=function(I,D){var se=r.prototype.on.call(this,I,D);if(I==="data")this._readableState.flowing!==!1&&this.resume();else if(I==="readable"){var ge=this._readableState;!ge.endEmitted&&!ge.readableListening&&(ge.readableListening=ge.needReadable=!0,ge.emittedReadable=!1,ge.reading?ge.length&&R(this):n.nextTick(ee,this))}return se},y.prototype.addListener=y.prototype.on;function ee(I){h("readable nexttick read 0"),I.read(0)}y.prototype.resume=function(){var I=this._readableState;return I.flowing||(h("resume"),I.flowing=!0,k(this,I)),this};function k(I,D){D.resumeScheduled||(D.resumeScheduled=!0,n.nextTick(N,I,D))}function N(I,D){D.reading||(h("resume read 0"),I.read(0)),D.resumeScheduled=!1,D.awaitDrain=0,I.emit("resume"),W(I),D.flowing&&!D.reading&&I.read(0)}y.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function W(I){var D=I._readableState;for(h("flow",D.flowing);D.flowing&&I.read()!==null;);}y.prototype.wrap=function(I){var D=this,se=this._readableState,ge=!1;I.on("end",function(){if(h("wrapped end"),se.decoder&&!se.ended){var z=se.decoder.end();z&&z.length&&D.push(z)}D.push(null)}),I.on("data",function(z){if(h("wrapped data"),se.decoder&&(z=se.decoder.write(z)),!(se.objectMode&&z==null)&&!(!se.objectMode&&(!z||!z.length))){var Tt=D.push(z);Tt||(ge=!0,I.pause())}});for(var De in I)this[De]===void 0&&typeof I[De]=="function"&&(this[De]=(function(z){return function(){return I[z].apply(I,arguments)}})(De));for(var Se=0;Se<v.length;Se++)I.on(v[Se],this.emit.bind(this,v[Se]));return this._read=function(z){h("wrapped _read",z),ge&&(ge=!1,I.resume())},this},Object.defineProperty(y.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),y._fromList=ie;function ie(I,D){if(D.length===0)return null;var se;return D.objectMode?se=D.buffer.shift():!I||I>=D.length?(D.decoder?se=D.buffer.join(""):D.buffer.length===1?se=D.buffer.head.data:se=D.buffer.concat(D.length),D.buffer.clear()):se=_e(I,D.buffer,D.decoder),se}function _e(I,D,se){var ge;return I<D.head.data.length?(ge=D.head.data.slice(0,I),D.head.data=D.head.data.slice(I)):I===D.head.data.length?ge=D.shift():ge=se?Ee(I,D):Pe(I,D),ge}function Ee(I,D){var se=D.head,ge=1,De=se.data;for(I-=De.length;se=se.next;){var Se=se.data,z=I>Se.length?Se.length:I;if(z===Se.length?De+=Se:De+=Se.slice(0,I),I-=z,I===0){z===Se.length?(++ge,se.next?D.head=se.next:D.head=D.tail=null):(D.head=se,se.data=Se.slice(z));break}++ge}return D.length-=ge,De}function Pe(I,D){var se=s.allocUnsafe(I),ge=D.head,De=1;for(ge.data.copy(se),I-=ge.data.length;ge=ge.next;){var Se=ge.data,z=I>Se.length?Se.length:I;if(Se.copy(se,se.length-I,0,z),I-=z,I===0){z===Se.length?(++De,ge.next?D.head=ge.next:D.head=D.tail=null):(D.head=ge,ge.data=Se.slice(z));break}++De}return D.length-=De,se}function ce(I){var D=I._readableState;if(D.length>0)throw new Error('"endReadable()" called on non-empty stream');D.endEmitted||(D.ended=!0,n.nextTick(ve,D,I))}function ve(I,D){!I.endEmitted&&I.length===0&&(I.endEmitted=!0,D.readable=!1,D.emit("end"))}function we(I,D){for(var se=0,ge=I.length;se<ge;se++)if(I[se]===D)return se;return-1}return cu}var uu,jp;function d0(){if(jp)return uu;jp=1,uu=i;var n=ra(),e=Object.create(No());e.inherits=Oo(),e.inherits(i,n);function t(a,o){var l=this._transformState;l.transforming=!1;var c=l.writecb;if(!c)return this.emit("error",new Error("write callback called multiple times"));l.writechunk=null,l.writecb=null,o!=null&&this.push(o),c(a);var d=this._readableState;d.reading=!1,(d.needReadable||d.length<d.highWaterMark)&&this._read(d.highWaterMark)}function i(a){if(!(this instanceof i))return new i(a);n.call(this,a),this._transformState={afterTransform:t.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,a&&(typeof a.transform=="function"&&(this._transform=a.transform),typeof a.flush=="function"&&(this._flush=a.flush)),this.on("prefinish",r)}function r(){var a=this;typeof this._flush=="function"?this._flush(function(o,l){s(a,o,l)}):s(this,null,null)}i.prototype.push=function(a,o){return this._transformState.needTransform=!1,n.prototype.push.call(this,a,o)},i.prototype._transform=function(a,o,l){throw new Error("_transform() is not implemented")},i.prototype._write=function(a,o,l){var c=this._transformState;if(c.writecb=l,c.writechunk=a,c.writeencoding=o,!c.transforming){var d=this._readableState;(c.needTransform||d.needReadable||d.length<d.highWaterMark)&&this._read(d.highWaterMark)}},i.prototype._read=function(a){var o=this._transformState;o.writechunk!==null&&o.writecb&&!o.transforming?(o.transforming=!0,this._transform(o.writechunk,o.writeencoding,o.afterTransform)):o.needTransform=!0},i.prototype._destroy=function(a,o){var l=this;n.prototype._destroy.call(this,a,function(c){o(c),l.emit("close")})};function s(a,o,l){if(o)return a.emit("error",o);if(l!=null&&a.push(l),a._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(a._transformState.transforming)throw new Error("Calling transform done when still transforming");return a.push(null)}return uu}var hu,$p;function Qw(){if($p)return hu;$p=1,hu=t;var n=d0(),e=Object.create(No());e.inherits=Oo(),e.inherits(t,n);function t(i){if(!(this instanceof t))return new t(i);n.call(this,i)}return t.prototype._transform=function(i,r,s){s(null,i)},hu}var Xp;function f0(){return Xp||(Xp=1,(function(n,e){var t=wv;process.env.READABLE_STREAM==="disable"&&t?(n.exports=t,e=n.exports=t.Readable,e.Readable=t.Readable,e.Writable=t.Writable,e.Duplex=t.Duplex,e.Transform=t.Transform,e.PassThrough=t.PassThrough,e.Stream=t):(e=n.exports=h0(),e.Stream=t||e,e.Readable=e,e.Writable=u0(),e.Duplex=ra(),e.Transform=d0(),e.PassThrough=Qw())})(jo,jo.exports)),jo.exports}var qp;function Sr(){if(qp)return Dn;if(qp=1,Dn.base64=!0,Dn.array=!0,Dn.string=!0,Dn.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",Dn.nodebuffer=typeof Buffer<"u",Dn.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")Dn.blob=!1;else{var n=new ArrayBuffer(0);try{Dn.blob=new Blob([n],{type:"application/zip"}).size===0}catch{try{var e=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,t=new e;t.append(n),Dn.blob=t.getBlob("application/zip").size===0}catch{Dn.blob=!1}}}try{Dn.nodestream=!!f0().Readable}catch{Dn.nodestream=!1}return Dn}var Zo={},Yp;function p0(){if(Yp)return Zo;Yp=1;var n=jt(),e=Sr(),t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return Zo.encode=function(i){for(var r=[],s,a,o,l,c,d,h,u=0,f=i.length,m=f,v=n.getTypeOf(i)!=="string";u<i.length;)m=f-u,v?(s=i[u++],a=u<f?i[u++]:0,o=u<f?i[u++]:0):(s=i.charCodeAt(u++),a=u<f?i.charCodeAt(u++):0,o=u<f?i.charCodeAt(u++):0),l=s>>2,c=(s&3)<<4|a>>4,d=m>1?(a&15)<<2|o>>6:64,h=m>2?o&63:64,r.push(t.charAt(l)+t.charAt(c)+t.charAt(d)+t.charAt(h));return r.join("")},Zo.decode=function(i){var r,s,a,o,l,c,d,h=0,u=0,f="data:";if(i.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");i=i.replace(/[^A-Za-z0-9+/=]/g,"");var m=i.length*3/4;if(i.charAt(i.length-1)===t.charAt(64)&&m--,i.charAt(i.length-2)===t.charAt(64)&&m--,m%1!==0)throw new Error("Invalid base64 input, bad content length.");var v;for(e.uint8array?v=new Uint8Array(m|0):v=new Array(m|0);h<i.length;)o=t.indexOf(i.charAt(h++)),l=t.indexOf(i.charAt(h++)),c=t.indexOf(i.charAt(h++)),d=t.indexOf(i.charAt(h++)),r=o<<2|l>>4,s=(l&15)<<4|c>>2,a=(c&3)<<6|d,v[u++]=r,c!==64&&(v[u++]=s),d!==64&&(v[u++]=a);return v},Zo}var du,Zp;function Lc(){return Zp||(Zp=1,du={isNode:typeof Buffer<"u",newBufferFrom:function(n,e){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,e);if(typeof n=="number")throw new Error('The "data" argument must not be a number');return new Buffer(n,e)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var e=new Buffer(n);return e.fill(0),e},isBuffer:function(n){return Buffer.isBuffer(n)},isStream:function(n){return n&&typeof n.on=="function"&&typeof n.pause=="function"&&typeof n.resume=="function"}}),du}var fu,Kp;function eM(){if(Kp)return fu;Kp=1;var n=yn.MutationObserver||yn.WebKitMutationObserver,e;if(process.browser)if(n){var t=0,i=new n(l),r=yn.document.createTextNode("");i.observe(r,{characterData:!0}),e=function(){r.data=t=++t%2}}else if(!yn.setImmediate&&typeof yn.MessageChannel<"u"){var s=new yn.MessageChannel;s.port1.onmessage=l,e=function(){s.port2.postMessage(0)}}else"document"in yn&&"onreadystatechange"in yn.document.createElement("script")?e=function(){var d=yn.document.createElement("script");d.onreadystatechange=function(){l(),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},yn.document.documentElement.appendChild(d)}:e=function(){setTimeout(l,0)};else e=function(){process.nextTick(l)};var a,o=[];function l(){a=!0;for(var d,h,u=o.length;u;){for(h=o,o=[],d=-1;++d<u;)h[d]();u=o.length}a=!1}fu=c;function c(d){o.push(d)===1&&!a&&e()}return fu}var pu,Jp;function tM(){if(Jp)return pu;Jp=1;var n=eM();function e(){}var t={},i=["REJECTED"],r=["FULFILLED"],s=["PENDING"];if(!process.browser)var a=["UNHANDLED"];pu=o;function o(p){if(typeof p!="function")throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,process.browser||(this.handled=a),p!==e&&h(this,p)}o.prototype.finally=function(p){if(typeof p!="function")return this;var y=this.constructor;return this.then(x,S);function x(T){function C(){return T}return y.resolve(p()).then(C)}function S(T){function C(){throw T}return y.resolve(p()).then(C)}},o.prototype.catch=function(p){return this.then(null,p)},o.prototype.then=function(p,y){if(typeof p!="function"&&this.state===r||typeof y!="function"&&this.state===i)return this;var x=new this.constructor(e);if(process.browser||this.handled===a&&(this.handled=null),this.state!==s){var S=this.state===r?p:y;c(x,S,this.outcome)}else this.queue.push(new l(x,p,y));return x};function l(p,y,x){this.promise=p,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}l.prototype.callFulfilled=function(p){t.resolve(this.promise,p)},l.prototype.otherCallFulfilled=function(p){c(this.promise,this.onFulfilled,p)},l.prototype.callRejected=function(p){t.reject(this.promise,p)},l.prototype.otherCallRejected=function(p){c(this.promise,this.onRejected,p)};function c(p,y,x){n(function(){var S;try{S=y(x)}catch(T){return t.reject(p,T)}S===p?t.reject(p,new TypeError("Cannot resolve promise with itself")):t.resolve(p,S)})}t.resolve=function(p,y){var x=u(d,y);if(x.status==="error")return t.reject(p,x.value);var S=x.value;if(S)h(p,S);else{p.state=r,p.outcome=y;for(var T=-1,C=p.queue.length;++T<C;)p.queue[T].callFulfilled(y)}return p},t.reject=function(p,y){p.state=i,p.outcome=y,process.browser||p.handled===a&&n(function(){p.handled===a&&process.emit("unhandledRejection",y,p)});for(var x=-1,S=p.queue.length;++x<S;)p.queue[x].callRejected(y);return p};function d(p){var y=p&&p.then;if(p&&(typeof p=="object"||typeof p=="function")&&typeof y=="function")return function(){y.apply(p,arguments)}}function h(p,y){var x=!1;function S(U){x||(x=!0,t.reject(p,U))}function T(U){x||(x=!0,t.resolve(p,U))}function C(){y(T,S)}var E=u(C);E.status==="error"&&S(E.value)}function u(p,y){var x={};try{x.value=p(y),x.status="success"}catch(S){x.status="error",x.value=S}return x}o.resolve=f;function f(p){return p instanceof this?p:t.resolve(new this(e),p)}o.reject=m;function m(p){var y=new this(e);return t.reject(y,p)}o.all=v;function v(p){var y=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=p.length,S=!1;if(!x)return this.resolve([]);for(var T=new Array(x),C=0,E=-1,U=new this(e);++E<x;)Y(p[E],E);return U;function Y(b,R){y.resolve(b).then(X,function(j){S||(S=!0,t.reject(U,j))});function X(j){T[R]=j,++C===x&&!S&&(S=!0,t.resolve(U,T))}}}o.race=g;function g(p){var y=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=p.length,S=!1;if(!x)return this.resolve([]);for(var T=-1,C=new this(e);++T<x;)E(p[T]);return C;function E(U){y.resolve(U).then(function(Y){S||(S=!0,t.resolve(C,Y))},function(Y){S||(S=!0,t.reject(C,Y))})}}return pu}var mu,Qp;function ko(){if(Qp)return mu;Qp=1;var n=null;return typeof Promise<"u"?n=Promise:n=tM(),mu={Promise:n},mu}var gu={},em;function nM(){return em||(em=1,(function(n,e){if(n.setImmediate)return;var t=1,i={},r=!1,s=n.document,a;function o(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),S=0;S<x.length;S++)x[S]=arguments[S+1];var T={callback:y,args:x};return i[t]=T,a(t),t++}function l(y){delete i[y]}function c(y){var x=y.callback,S=y.args;switch(S.length){case 0:x();break;case 1:x(S[0]);break;case 2:x(S[0],S[1]);break;case 3:x(S[0],S[1],S[2]);break;default:x.apply(e,S);break}}function d(y){if(r)setTimeout(d,0,y);else{var x=i[y];if(x){r=!0;try{c(x)}finally{l(y),r=!1}}}}function h(){a=function(y){process.nextTick(function(){d(y)})}}function u(){if(n.postMessage&&!n.importScripts){var y=!0,x=n.onmessage;return n.onmessage=function(){y=!1},n.postMessage("","*"),n.onmessage=x,y}}function f(){var y="setImmediate$"+Math.random()+"$",x=function(S){S.source===n&&typeof S.data=="string"&&S.data.indexOf(y)===0&&d(+S.data.slice(y.length))};n.addEventListener?n.addEventListener("message",x,!1):n.attachEvent("onmessage",x),a=function(S){n.postMessage(y+S,"*")}}function m(){var y=new MessageChannel;y.port1.onmessage=function(x){var S=x.data;d(S)},a=function(x){y.port2.postMessage(x)}}function v(){var y=s.documentElement;a=function(x){var S=s.createElement("script");S.onreadystatechange=function(){d(x),S.onreadystatechange=null,y.removeChild(S),S=null},y.appendChild(S)}}function g(){a=function(y){setTimeout(d,0,y)}}var p=Object.getPrototypeOf&&Object.getPrototypeOf(n);p=p&&p.setTimeout?p:n,{}.toString.call(n.process)==="[object process]"?h():u()?f():n.MessageChannel?m():s&&"onreadystatechange"in s.createElement("script")?v():g(),p.setImmediate=o,p.clearImmediate=l})(typeof self>"u"?typeof yn>"u"?gu:yn:self)),gu}var tm;function jt(){return tm||(tm=1,(function(n){var e=Sr(),t=p0(),i=Lc(),r=ko();nM();function s(u){var f=null;return e.uint8array?f=new Uint8Array(u.length):f=new Array(u.length),o(u,f)}n.newBlob=function(u,f){n.checkSupport("blob");try{return new Blob([u],{type:f})}catch{try{var m=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,v=new m;return v.append(u),v.getBlob(f)}catch{throw new Error("Bug : can't construct the Blob.")}}};function a(u){return u}function o(u,f){for(var m=0;m<u.length;++m)f[m]=u.charCodeAt(m)&255;return f}var l={stringifyByChunk:function(u,f,m){var v=[],g=0,p=u.length;if(p<=m)return String.fromCharCode.apply(null,u);for(;g<p;)f==="array"||f==="nodebuffer"?v.push(String.fromCharCode.apply(null,u.slice(g,Math.min(g+m,p)))):v.push(String.fromCharCode.apply(null,u.subarray(g,Math.min(g+m,p)))),g+=m;return v.join("")},stringifyByChar:function(u){for(var f="",m=0;m<u.length;m++)f+=String.fromCharCode(u[m]);return f},applyCanBeUsed:{uint8array:(function(){try{return e.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return e.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}})()}};function c(u){var f=65536,m=n.getTypeOf(u),v=!0;if(m==="uint8array"?v=l.applyCanBeUsed.uint8array:m==="nodebuffer"&&(v=l.applyCanBeUsed.nodebuffer),v)for(;f>1;)try{return l.stringifyByChunk(u,m,f)}catch{f=Math.floor(f/2)}return l.stringifyByChar(u)}n.applyFromCharCode=c;function d(u,f){for(var m=0;m<u.length;m++)f[m]=u[m];return f}var h={};h.string={string:a,array:function(u){return o(u,new Array(u.length))},arraybuffer:function(u){return h.string.uint8array(u).buffer},uint8array:function(u){return o(u,new Uint8Array(u.length))},nodebuffer:function(u){return o(u,i.allocBuffer(u.length))}},h.array={string:c,array:a,arraybuffer:function(u){return new Uint8Array(u).buffer},uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return i.newBufferFrom(u)}},h.arraybuffer={string:function(u){return c(new Uint8Array(u))},array:function(u){return d(new Uint8Array(u),new Array(u.byteLength))},arraybuffer:a,uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return i.newBufferFrom(new Uint8Array(u))}},h.uint8array={string:c,array:function(u){return d(u,new Array(u.length))},arraybuffer:function(u){return u.buffer},uint8array:a,nodebuffer:function(u){return i.newBufferFrom(u)}},h.nodebuffer={string:c,array:function(u){return d(u,new Array(u.length))},arraybuffer:function(u){return h.nodebuffer.uint8array(u).buffer},uint8array:function(u){return d(u,new Uint8Array(u.length))},nodebuffer:a},n.transformTo=function(u,f){if(f||(f=""),!u)return f;n.checkSupport(u);var m=n.getTypeOf(f),v=h[m][u](f);return v},n.resolve=function(u){for(var f=u.split("/"),m=[],v=0;v<f.length;v++){var g=f[v];g==="."||g===""&&v!==0&&v!==f.length-1||(g===".."?m.pop():m.push(g))}return m.join("/")},n.getTypeOf=function(u){if(typeof u=="string")return"string";if(Object.prototype.toString.call(u)==="[object Array]")return"array";if(e.nodebuffer&&i.isBuffer(u))return"nodebuffer";if(e.uint8array&&u instanceof Uint8Array)return"uint8array";if(e.arraybuffer&&u instanceof ArrayBuffer)return"arraybuffer"},n.checkSupport=function(u){var f=e[u.toLowerCase()];if(!f)throw new Error(u+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(u){var f="",m,v;for(v=0;v<(u||"").length;v++)m=u.charCodeAt(v),f+="\\x"+(m<16?"0":"")+m.toString(16).toUpperCase();return f},n.delay=function(u,f,m){setImmediate(function(){u.apply(m||null,f||[])})},n.inherits=function(u,f){var m=function(){};m.prototype=f.prototype,u.prototype=new m},n.extend=function(){var u={},f,m;for(f=0;f<arguments.length;f++)for(m in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],m)&&typeof u[m]>"u"&&(u[m]=arguments[f][m]);return u},n.prepareContent=function(u,f,m,v,g){var p=r.Promise.resolve(f).then(function(y){var x=e.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1);return x&&typeof FileReader<"u"?new r.Promise(function(S,T){var C=new FileReader;C.onload=function(E){S(E.target.result)},C.onerror=function(E){T(E.target.error)},C.readAsArrayBuffer(y)}):y});return p.then(function(y){var x=n.getTypeOf(y);return x?(x==="arraybuffer"?y=n.transformTo("uint8array",y):x==="string"&&(g?y=t.decode(y):m&&v!==!0&&(y=s(y))),y):r.Promise.reject(new Error("Can't read the data of '"+u+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}})(eu)),eu}var _u,nm;function Qn(){if(nm)return _u;nm=1;function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}return n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return this.isFinished?!1:(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var i=0;i<this._listeners[e].length;i++)this._listeners[e][i].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(i){t.processChunk(i)}),e.on("end",function(){t.end()}),e.on("error",function(i){t.error(i)}),this},pause:function(){return this.isPaused||this.isFinished?!1:(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var e=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},_u=n,_u}var im;function Uo(){return im||(im=1,(function(n){for(var e=jt(),t=Sr(),i=Lc(),r=Qn(),s=new Array(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;s[254]=s[254]=1;var o=function(u){var f,m,v,g,p,y=u.length,x=0;for(g=0;g<y;g++)m=u.charCodeAt(g),(m&64512)===55296&&g+1<y&&(v=u.charCodeAt(g+1),(v&64512)===56320&&(m=65536+(m-55296<<10)+(v-56320),g++)),x+=m<128?1:m<2048?2:m<65536?3:4;for(t.uint8array?f=new Uint8Array(x):f=new Array(x),p=0,g=0;p<x;g++)m=u.charCodeAt(g),(m&64512)===55296&&g+1<y&&(v=u.charCodeAt(g+1),(v&64512)===56320&&(m=65536+(m-55296<<10)+(v-56320),g++)),m<128?f[p++]=m:m<2048?(f[p++]=192|m>>>6,f[p++]=128|m&63):m<65536?(f[p++]=224|m>>>12,f[p++]=128|m>>>6&63,f[p++]=128|m&63):(f[p++]=240|m>>>18,f[p++]=128|m>>>12&63,f[p++]=128|m>>>6&63,f[p++]=128|m&63);return f},l=function(u,f){var m;for(f=f||u.length,f>u.length&&(f=u.length),m=f-1;m>=0&&(u[m]&192)===128;)m--;return m<0||m===0?f:m+s[u[m]]>f?m:f},c=function(u){var f,m,v,g,p=u.length,y=new Array(p*2);for(m=0,f=0;f<p;){if(v=u[f++],v<128){y[m++]=v;continue}if(g=s[v],g>4){y[m++]=65533,f+=g-1;continue}for(v&=g===2?31:g===3?15:7;g>1&&f<p;)v=v<<6|u[f++]&63,g--;if(g>1){y[m++]=65533;continue}v<65536?y[m++]=v:(v-=65536,y[m++]=55296|v>>10&1023,y[m++]=56320|v&1023)}return y.length!==m&&(y.subarray?y=y.subarray(0,m):y.length=m),e.applyFromCharCode(y)};n.utf8encode=function(f){return t.nodebuffer?i.newBufferFrom(f,"utf-8"):o(f)},n.utf8decode=function(f){return t.nodebuffer?e.transformTo("nodebuffer",f).toString("utf-8"):(f=e.transformTo(t.uint8array?"uint8array":"array",f),c(f))};function d(){r.call(this,"utf-8 decode"),this.leftOver=null}e.inherits(d,r),d.prototype.processChunk=function(u){var f=e.transformTo(t.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(t.uint8array){var m=f;f=new Uint8Array(m.length+this.leftOver.length),f.set(this.leftOver,0),f.set(m,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var v=l(f),g=f;v!==f.length&&(t.uint8array?(g=f.subarray(0,v),this.leftOver=f.subarray(v,f.length)):(g=f.slice(0,v),this.leftOver=f.slice(v,f.length))),this.push({data:n.utf8decode(g),meta:u.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=d;function h(){r.call(this,"utf-8 encode")}e.inherits(h,r),h.prototype.processChunk=function(u){this.push({data:n.utf8encode(u.data),meta:u.meta})},n.Utf8EncodeWorker=h})(Qc)),Qc}var vu,rm;function iM(){if(rm)return vu;rm=1;var n=Qn(),e=jt();function t(i){n.call(this,"ConvertWorker to "+i),this.destType=i}return e.inherits(t,n),t.prototype.processChunk=function(i){this.push({data:e.transformTo(this.destType,i.data),meta:i.meta})},vu=t,vu}var yu,sm;function rM(){if(sm)return yu;sm=1;var n=f0().Readable,e=jt();e.inherits(t,n);function t(i,r,s){n.call(this,r),this._helper=i;var a=this;i.on("data",function(o,l){a.push(o)||a._helper.pause(),s&&s(l)}).on("error",function(o){a.emit("error",o)}).on("end",function(){a.push(null)})}return t.prototype._read=function(){this._helper.resume()},yu=t,yu}var xu,am;function m0(){if(am)return xu;am=1;var n=jt(),e=iM(),t=Qn(),i=p0(),r=Sr(),s=ko(),a=null;if(r.nodestream)try{a=rM()}catch{}function o(h,u,f){switch(h){case"blob":return n.newBlob(n.transformTo("arraybuffer",u),f);case"base64":return i.encode(u);default:return n.transformTo(h,u)}}function l(h,u){var f,m=0,v=null,g=0;for(f=0;f<u.length;f++)g+=u[f].length;switch(h){case"string":return u.join("");case"array":return Array.prototype.concat.apply([],u);case"uint8array":for(v=new Uint8Array(g),f=0;f<u.length;f++)v.set(u[f],m),m+=u[f].length;return v;case"nodebuffer":return Buffer.concat(u);default:throw new Error("concat : unsupported type '"+h+"'")}}function c(h,u){return new s.Promise(function(f,m){var v=[],g=h._internalType,p=h._outputType,y=h._mimeType;h.on("data",function(x,S){v.push(x),u&&u(S)}).on("error",function(x){v=[],m(x)}).on("end",function(){try{var x=o(p,l(g,v),y);f(x)}catch(S){m(S)}v=[]}).resume()})}function d(h,u,f){var m=u;switch(u){case"blob":case"arraybuffer":m="uint8array";break;case"base64":m="string";break}try{this._internalType=m,this._outputType=u,this._mimeType=f,n.checkSupport(m),this._worker=h.pipe(new e(m)),h.lock()}catch(v){this._worker=new t("error"),this._worker.error(v)}}return d.prototype={accumulate:function(h){return c(this,h)},on:function(h,u){var f=this;return h==="data"?this._worker.on(h,function(m){u.call(f,m.data,m.meta)}):this._worker.on(h,function(){n.delay(u,arguments,f)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(h){if(n.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new a(this,{objectMode:this._outputType!=="nodebuffer"},h)}},xu=d,xu}var $n={},om;function g0(){return om||(om=1,$n.base64=!1,$n.binary=!1,$n.dir=!1,$n.createFolders=!0,$n.date=null,$n.compression=null,$n.compressionOptions=null,$n.comment=null,$n.unixPermissions=null,$n.dosPermissions=null),$n}var Su,lm;function _0(){if(lm)return Su;lm=1;var n=jt(),e=Qn(),t=16*1024;function i(r){e.call(this,"DataWorker");var s=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,r.then(function(a){s.dataIsReady=!0,s.data=a,s.max=a&&a.length||0,s.type=n.getTypeOf(a),s.isPaused||s._tickAndRepeat()},function(a){s.error(a)})}return n.inherits(i,e),i.prototype.cleanUp=function(){e.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return e.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0):!1},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var r=t,s=null,a=Math.min(this.max,this.index+r);if(this.index>=this.max)return this.end();switch(this.type){case"string":s=this.data.substring(this.index,a);break;case"uint8array":s=this.data.subarray(this.index,a);break;case"array":case"nodebuffer":s=this.data.slice(this.index,a);break}return this.index=a,this.push({data:s,meta:{percent:this.max?this.index/this.max*100:0}})},Su=i,Su}var bu,cm;function Mf(){if(cm)return bu;cm=1;var n=jt();function e(){for(var s,a=[],o=0;o<256;o++){s=o;for(var l=0;l<8;l++)s=s&1?3988292384^s>>>1:s>>>1;a[o]=s}return a}var t=e();function i(s,a,o,l){var c=t,d=l+o;s=s^-1;for(var h=l;h<d;h++)s=s>>>8^c[(s^a[h])&255];return s^-1}function r(s,a,o,l){var c=t,d=l+o;s=s^-1;for(var h=l;h<d;h++)s=s>>>8^c[(s^a.charCodeAt(h))&255];return s^-1}return bu=function(a,o){if(typeof a>"u"||!a.length)return 0;var l=n.getTypeOf(a)!=="string";return l?i(o|0,a,a.length,0):r(o|0,a,a.length,0)},bu}var wu,um;function v0(){if(um)return wu;um=1;var n=Qn(),e=Mf(),t=jt();function i(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}return t.inherits(i,n),i.prototype.processChunk=function(r){this.streamInfo.crc32=e(r.data,this.streamInfo.crc32||0),this.push(r)},wu=i,wu}var Mu,hm;function sM(){if(hm)return Mu;hm=1;var n=jt(),e=Qn();function t(i){e.call(this,"DataLengthProbe for "+i),this.propName=i,this.withStreamInfo(i,0)}return n.inherits(t,e),t.prototype.processChunk=function(i){if(i){var r=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=r+i.data.length}e.prototype.processChunk.call(this,i)},Mu=t,Mu}var Eu,dm;function Ef(){if(dm)return Eu;dm=1;var n=ko(),e=_0(),t=v0(),i=sM();function r(s,a,o,l,c){this.compressedSize=s,this.uncompressedSize=a,this.crc32=o,this.compression=l,this.compressedContent=c}return r.prototype={getContentWorker:function(){var s=new e(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new i("data_length")),a=this;return s.on("end",function(){if(this.streamInfo.data_length!==a.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),s},getCompressedWorker:function(){return new e(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},r.createWorkerFrom=function(s,a,o){return s.pipe(new t).pipe(new i("uncompressedSize")).pipe(a.compressWorker(o)).pipe(new i("compressedSize")).withStreamInfo("compression",a)},Eu=r,Eu}var Tu,fm;function aM(){if(fm)return Tu;fm=1;var n=m0(),e=_0(),t=Uo(),i=Ef(),r=Qn(),s=function(c,d,h){this.name=c,this.dir=h.dir,this.date=h.date,this.comment=h.comment,this.unixPermissions=h.unixPermissions,this.dosPermissions=h.dosPermissions,this._data=d,this._dataBinary=h.binary,this.options={compression:h.compression,compressionOptions:h.compressionOptions}};s.prototype={internalStream:function(c){var d=null,h="string";try{if(!c)throw new Error("No output type specified.");h=c.toLowerCase();var u=h==="string"||h==="text";(h==="binarystring"||h==="text")&&(h="string"),d=this._decompressWorker();var f=!this._dataBinary;f&&!u&&(d=d.pipe(new t.Utf8EncodeWorker)),!f&&u&&(d=d.pipe(new t.Utf8DecodeWorker))}catch(m){d=new r("error"),d.error(m)}return new n(d,h,"")},async:function(c,d){return this.internalStream(c).accumulate(d)},nodeStream:function(c,d){return this.internalStream(c||"nodebuffer").toNodejsStream(d)},_compressWorker:function(c,d){if(this._data instanceof i&&this._data.compression.magic===c.magic)return this._data.getCompressedWorker();var h=this._decompressWorker();return this._dataBinary||(h=h.pipe(new t.Utf8EncodeWorker)),i.createWorkerFrom(h,c,d)},_decompressWorker:function(){return this._data instanceof i?this._data.getContentWorker():this._data instanceof r?this._data:new e(this._data)}};for(var a=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],o=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},l=0;l<a.length;l++)s.prototype[a[l]]=o;return Tu=s,Tu}var Au={},Ko={},Ea={},Ru={},pm;function br(){return pm||(pm=1,(function(n){var e=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function t(s,a){return Object.prototype.hasOwnProperty.call(s,a)}n.assign=function(s){for(var a=Array.prototype.slice.call(arguments,1);a.length;){var o=a.shift();if(o){if(typeof o!="object")throw new TypeError(o+"must be non-object");for(var l in o)t(o,l)&&(s[l]=o[l])}}return s},n.shrinkBuf=function(s,a){return s.length===a?s:s.subarray?s.subarray(0,a):(s.length=a,s)};var i={arraySet:function(s,a,o,l,c){if(a.subarray&&s.subarray){s.set(a.subarray(o,o+l),c);return}for(var d=0;d<l;d++)s[c+d]=a[o+d]},flattenChunks:function(s){var a,o,l,c,d,h;for(l=0,a=0,o=s.length;a<o;a++)l+=s[a].length;for(h=new Uint8Array(l),c=0,a=0,o=s.length;a<o;a++)d=s[a],h.set(d,c),c+=d.length;return h}},r={arraySet:function(s,a,o,l,c){for(var d=0;d<l;d++)s[c+d]=a[o+d]},flattenChunks:function(s){return[].concat.apply([],s)}};n.setTyped=function(s){s?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,i)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,r))},n.setTyped(e)})(Ru)),Ru}var ms={},ii={},Er={},mm;function oM(){if(mm)return Er;mm=1;var n=br(),e=4,t=0,i=1,r=2;function s(A){for(var oe=A.length;--oe>=0;)A[oe]=0}var a=0,o=1,l=2,c=3,d=258,h=29,u=256,f=u+1+h,m=30,v=19,g=2*f+1,p=15,y=16,x=7,S=256,T=16,C=17,E=18,U=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Y=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X=512,j=new Array((f+2)*2);s(j);var Z=new Array(m*2);s(Z);var de=new Array(X);s(de);var ee=new Array(d-c+1);s(ee);var k=new Array(h);s(k);var N=new Array(m);s(N);function W(A,oe,he,pe,G){this.static_tree=A,this.extra_bits=oe,this.extra_base=he,this.elems=pe,this.max_length=G,this.has_stree=A&&A.length}var ie,_e,Ee;function Pe(A,oe){this.dyn_tree=A,this.max_code=0,this.stat_desc=oe}function ce(A){return A<256?de[A]:de[256+(A>>>7)]}function ve(A,oe){A.pending_buf[A.pending++]=oe&255,A.pending_buf[A.pending++]=oe>>>8&255}function we(A,oe,he){A.bi_valid>y-he?(A.bi_buf|=oe<<A.bi_valid&65535,ve(A,A.bi_buf),A.bi_buf=oe>>y-A.bi_valid,A.bi_valid+=he-y):(A.bi_buf|=oe<<A.bi_valid&65535,A.bi_valid+=he)}function I(A,oe,he){we(A,he[oe*2],he[oe*2+1])}function D(A,oe){var he=0;do he|=A&1,A>>>=1,he<<=1;while(--oe>0);return he>>>1}function se(A){A.bi_valid===16?(ve(A,A.bi_buf),A.bi_buf=0,A.bi_valid=0):A.bi_valid>=8&&(A.pending_buf[A.pending++]=A.bi_buf&255,A.bi_buf>>=8,A.bi_valid-=8)}function ge(A,oe){var he=oe.dyn_tree,pe=oe.max_code,G=oe.stat_desc.static_tree,te=oe.stat_desc.has_stree,M=oe.stat_desc.extra_bits,O=oe.stat_desc.extra_base,ye=oe.stat_desc.max_length,_,V,$,w,H,Q,Ne=0;for(w=0;w<=p;w++)A.bl_count[w]=0;for(he[A.heap[A.heap_max]*2+1]=0,_=A.heap_max+1;_<g;_++)V=A.heap[_],w=he[he[V*2+1]*2+1]+1,w>ye&&(w=ye,Ne++),he[V*2+1]=w,!(V>pe)&&(A.bl_count[w]++,H=0,V>=O&&(H=M[V-O]),Q=he[V*2],A.opt_len+=Q*(w+H),te&&(A.static_len+=Q*(G[V*2+1]+H)));if(Ne!==0){do{for(w=ye-1;A.bl_count[w]===0;)w--;A.bl_count[w]--,A.bl_count[w+1]+=2,A.bl_count[ye]--,Ne-=2}while(Ne>0);for(w=ye;w!==0;w--)for(V=A.bl_count[w];V!==0;)$=A.heap[--_],!($>pe)&&(he[$*2+1]!==w&&(A.opt_len+=(w-he[$*2+1])*he[$*2],he[$*2+1]=w),V--)}}function De(A,oe,he){var pe=new Array(p+1),G=0,te,M;for(te=1;te<=p;te++)pe[te]=G=G+he[te-1]<<1;for(M=0;M<=oe;M++){var O=A[M*2+1];O!==0&&(A[M*2]=D(pe[O]++,O))}}function Se(){var A,oe,he,pe,G,te=new Array(p+1);for(he=0,pe=0;pe<h-1;pe++)for(k[pe]=he,A=0;A<1<<U[pe];A++)ee[he++]=pe;for(ee[he-1]=pe,G=0,pe=0;pe<16;pe++)for(N[pe]=G,A=0;A<1<<Y[pe];A++)de[G++]=pe;for(G>>=7;pe<m;pe++)for(N[pe]=G<<7,A=0;A<1<<Y[pe]-7;A++)de[256+G++]=pe;for(oe=0;oe<=p;oe++)te[oe]=0;for(A=0;A<=143;)j[A*2+1]=8,A++,te[8]++;for(;A<=255;)j[A*2+1]=9,A++,te[9]++;for(;A<=279;)j[A*2+1]=7,A++,te[7]++;for(;A<=287;)j[A*2+1]=8,A++,te[8]++;for(De(j,f+1,te),A=0;A<m;A++)Z[A*2+1]=5,Z[A*2]=D(A,5);ie=new W(j,U,u+1,f,p),_e=new W(Z,Y,0,m,p),Ee=new W(new Array(0),b,0,v,x)}function z(A){var oe;for(oe=0;oe<f;oe++)A.dyn_ltree[oe*2]=0;for(oe=0;oe<m;oe++)A.dyn_dtree[oe*2]=0;for(oe=0;oe<v;oe++)A.bl_tree[oe*2]=0;A.dyn_ltree[S*2]=1,A.opt_len=A.static_len=0,A.last_lit=A.matches=0}function Tt(A){A.bi_valid>8?ve(A,A.bi_buf):A.bi_valid>0&&(A.pending_buf[A.pending++]=A.bi_buf),A.bi_buf=0,A.bi_valid=0}function Je(A,oe,he,pe){Tt(A),ve(A,he),ve(A,~he),n.arraySet(A.pending_buf,A.window,oe,he,A.pending),A.pending+=he}function et(A,oe,he,pe){var G=oe*2,te=he*2;return A[G]<A[te]||A[G]===A[te]&&pe[oe]<=pe[he]}function ke(A,oe,he){for(var pe=A.heap[he],G=he<<1;G<=A.heap_len&&(G<A.heap_len&&et(oe,A.heap[G+1],A.heap[G],A.depth)&&G++,!et(oe,pe,A.heap[G],A.depth));)A.heap[he]=A.heap[G],he=G,G<<=1;A.heap[he]=pe}function Fe(A,oe,he){var pe,G,te=0,M,O;if(A.last_lit!==0)do pe=A.pending_buf[A.d_buf+te*2]<<8|A.pending_buf[A.d_buf+te*2+1],G=A.pending_buf[A.l_buf+te],te++,pe===0?I(A,G,oe):(M=ee[G],I(A,M+u+1,oe),O=U[M],O!==0&&(G-=k[M],we(A,G,O)),pe--,M=ce(pe),I(A,M,he),O=Y[M],O!==0&&(pe-=N[M],we(A,pe,O)));while(te<A.last_lit);I(A,S,oe)}function Ge(A,oe){var he=oe.dyn_tree,pe=oe.stat_desc.static_tree,G=oe.stat_desc.has_stree,te=oe.stat_desc.elems,M,O,ye=-1,_;for(A.heap_len=0,A.heap_max=g,M=0;M<te;M++)he[M*2]!==0?(A.heap[++A.heap_len]=ye=M,A.depth[M]=0):he[M*2+1]=0;for(;A.heap_len<2;)_=A.heap[++A.heap_len]=ye<2?++ye:0,he[_*2]=1,A.depth[_]=0,A.opt_len--,G&&(A.static_len-=pe[_*2+1]);for(oe.max_code=ye,M=A.heap_len>>1;M>=1;M--)ke(A,he,M);_=te;do M=A.heap[1],A.heap[1]=A.heap[A.heap_len--],ke(A,he,1),O=A.heap[1],A.heap[--A.heap_max]=M,A.heap[--A.heap_max]=O,he[_*2]=he[M*2]+he[O*2],A.depth[_]=(A.depth[M]>=A.depth[O]?A.depth[M]:A.depth[O])+1,he[M*2+1]=he[O*2+1]=_,A.heap[1]=_++,ke(A,he,1);while(A.heap_len>=2);A.heap[--A.heap_max]=A.heap[1],ge(A,oe),De(he,ye,A.bl_count)}function F(A,oe,he){var pe,G=-1,te,M=oe[1],O=0,ye=7,_=4;for(M===0&&(ye=138,_=3),oe[(he+1)*2+1]=65535,pe=0;pe<=he;pe++)te=M,M=oe[(pe+1)*2+1],!(++O<ye&&te===M)&&(O<_?A.bl_tree[te*2]+=O:te!==0?(te!==G&&A.bl_tree[te*2]++,A.bl_tree[T*2]++):O<=10?A.bl_tree[C*2]++:A.bl_tree[E*2]++,O=0,G=te,M===0?(ye=138,_=3):te===M?(ye=6,_=3):(ye=7,_=4))}function P(A,oe,he){var pe,G=-1,te,M=oe[1],O=0,ye=7,_=4;for(M===0&&(ye=138,_=3),pe=0;pe<=he;pe++)if(te=M,M=oe[(pe+1)*2+1],!(++O<ye&&te===M)){if(O<_)do I(A,te,A.bl_tree);while(--O!==0);else te!==0?(te!==G&&(I(A,te,A.bl_tree),O--),I(A,T,A.bl_tree),we(A,O-3,2)):O<=10?(I(A,C,A.bl_tree),we(A,O-3,3)):(I(A,E,A.bl_tree),we(A,O-11,7));O=0,G=te,M===0?(ye=138,_=3):te===M?(ye=6,_=3):(ye=7,_=4)}}function ne(A){var oe;for(F(A,A.dyn_ltree,A.l_desc.max_code),F(A,A.dyn_dtree,A.d_desc.max_code),Ge(A,A.bl_desc),oe=v-1;oe>=3&&A.bl_tree[R[oe]*2+1]===0;oe--);return A.opt_len+=3*(oe+1)+5+5+4,oe}function me(A,oe,he,pe){var G;for(we(A,oe-257,5),we(A,he-1,5),we(A,pe-4,4),G=0;G<pe;G++)we(A,A.bl_tree[R[G]*2+1],3);P(A,A.dyn_ltree,oe-1),P(A,A.dyn_dtree,he-1)}function xe(A){var oe=4093624447,he;for(he=0;he<=31;he++,oe>>>=1)if(oe&1&&A.dyn_ltree[he*2]!==0)return t;if(A.dyn_ltree[18]!==0||A.dyn_ltree[20]!==0||A.dyn_ltree[26]!==0)return i;for(he=32;he<u;he++)if(A.dyn_ltree[he*2]!==0)return i;return t}var fe=!1;function He(A){fe||(Se(),fe=!0),A.l_desc=new Pe(A.dyn_ltree,ie),A.d_desc=new Pe(A.dyn_dtree,_e),A.bl_desc=new Pe(A.bl_tree,Ee),A.bi_buf=0,A.bi_valid=0,z(A)}function Ce(A,oe,he,pe){we(A,(a<<1)+(pe?1:0),3),Je(A,oe,he)}function Ie(A){we(A,o<<1,3),I(A,S,j),se(A)}function ut(A,oe,he,pe){var G,te,M=0;A.level>0?(A.strm.data_type===r&&(A.strm.data_type=xe(A)),Ge(A,A.l_desc),Ge(A,A.d_desc),M=ne(A),G=A.opt_len+3+7>>>3,te=A.static_len+3+7>>>3,te<=G&&(G=te)):G=te=he+5,he+4<=G&&oe!==-1?Ce(A,oe,he,pe):A.strategy===e||te===G?(we(A,(o<<1)+(pe?1:0),3),Fe(A,j,Z)):(we(A,(l<<1)+(pe?1:0),3),me(A,A.l_desc.max_code+1,A.d_desc.max_code+1,M+1),Fe(A,A.dyn_ltree,A.dyn_dtree)),z(A),pe&&Tt(A)}function Me(A,oe,he){return A.pending_buf[A.d_buf+A.last_lit*2]=oe>>>8&255,A.pending_buf[A.d_buf+A.last_lit*2+1]=oe&255,A.pending_buf[A.l_buf+A.last_lit]=he&255,A.last_lit++,oe===0?A.dyn_ltree[he*2]++:(A.matches++,oe--,A.dyn_ltree[(ee[he]+u+1)*2]++,A.dyn_dtree[ce(oe)*2]++),A.last_lit===A.lit_bufsize-1}return Er._tr_init=He,Er._tr_stored_block=Ce,Er._tr_flush_block=ut,Er._tr_tally=Me,Er._tr_align=Ie,Er}var Cu,gm;function y0(){if(gm)return Cu;gm=1;function n(e,t,i,r){for(var s=e&65535|0,a=e>>>16&65535|0,o=0;i!==0;){o=i>2e3?2e3:i,i-=o;do s=s+t[r++]|0,a=a+s|0;while(--o);s%=65521,a%=65521}return s|a<<16|0}return Cu=n,Cu}var Pu,_m;function x0(){if(_m)return Pu;_m=1;function n(){for(var i,r=[],s=0;s<256;s++){i=s;for(var a=0;a<8;a++)i=i&1?3988292384^i>>>1:i>>>1;r[s]=i}return r}var e=n();function t(i,r,s,a){var o=e,l=a+s;i^=-1;for(var c=a;c<l;c++)i=i>>>8^o[(i^r[c])&255];return i^-1}return Pu=t,Pu}var Iu,vm;function Tf(){return vm||(vm=1,Iu={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}),Iu}var ym;function lM(){if(ym)return ii;ym=1;var n=br(),e=oM(),t=y0(),i=x0(),r=Tf(),s=0,a=1,o=3,l=4,c=5,d=0,h=1,u=-2,f=-3,m=-5,v=-1,g=1,p=2,y=3,x=4,S=0,T=2,C=8,E=9,U=15,Y=8,b=29,R=256,X=R+1+b,j=30,Z=19,de=2*X+1,ee=15,k=3,N=258,W=N+k+1,ie=32,_e=42,Ee=69,Pe=73,ce=91,ve=103,we=113,I=666,D=1,se=2,ge=3,De=4,Se=3;function z(_,V){return _.msg=r[V],V}function Tt(_){return(_<<1)-(_>4?9:0)}function Je(_){for(var V=_.length;--V>=0;)_[V]=0}function et(_){var V=_.state,$=V.pending;$>_.avail_out&&($=_.avail_out),$!==0&&(n.arraySet(_.output,V.pending_buf,V.pending_out,$,_.next_out),_.next_out+=$,V.pending_out+=$,_.total_out+=$,_.avail_out-=$,V.pending-=$,V.pending===0&&(V.pending_out=0))}function ke(_,V){e._tr_flush_block(_,_.block_start>=0?_.block_start:-1,_.strstart-_.block_start,V),_.block_start=_.strstart,et(_.strm)}function Fe(_,V){_.pending_buf[_.pending++]=V}function Ge(_,V){_.pending_buf[_.pending++]=V>>>8&255,_.pending_buf[_.pending++]=V&255}function F(_,V,$,w){var H=_.avail_in;return H>w&&(H=w),H===0?0:(_.avail_in-=H,n.arraySet(V,_.input,_.next_in,H,$),_.state.wrap===1?_.adler=t(_.adler,V,H,$):_.state.wrap===2&&(_.adler=i(_.adler,V,H,$)),_.next_in+=H,_.total_in+=H,H)}function P(_,V){var $=_.max_chain_length,w=_.strstart,H,Q,Ne=_.prev_length,be=_.nice_match,Re=_.strstart>_.w_size-W?_.strstart-(_.w_size-W):0,ot=_.window,In=_.w_mask,It=_.prev,ht=_.strstart+N,kt=ot[w+Ne-1],Xt=ot[w+Ne];_.prev_length>=_.good_match&&($>>=2),be>_.lookahead&&(be=_.lookahead);do if(H=V,!(ot[H+Ne]!==Xt||ot[H+Ne-1]!==kt||ot[H]!==ot[w]||ot[++H]!==ot[w+1])){w+=2,H++;do;while(ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&ot[++w]===ot[++H]&&w<ht);if(Q=N-(ht-w),w=ht-N,Q>Ne){if(_.match_start=V,Ne=Q,Q>=be)break;kt=ot[w+Ne-1],Xt=ot[w+Ne]}}while((V=It[V&In])>Re&&--$!==0);return Ne<=_.lookahead?Ne:_.lookahead}function ne(_){var V=_.w_size,$,w,H,Q,Ne;do{if(Q=_.window_size-_.lookahead-_.strstart,_.strstart>=V+(V-W)){n.arraySet(_.window,_.window,V,V,0),_.match_start-=V,_.strstart-=V,_.block_start-=V,w=_.hash_size,$=w;do H=_.head[--$],_.head[$]=H>=V?H-V:0;while(--w);w=V,$=w;do H=_.prev[--$],_.prev[$]=H>=V?H-V:0;while(--w);Q+=V}if(_.strm.avail_in===0)break;if(w=F(_.strm,_.window,_.strstart+_.lookahead,Q),_.lookahead+=w,_.lookahead+_.insert>=k)for(Ne=_.strstart-_.insert,_.ins_h=_.window[Ne],_.ins_h=(_.ins_h<<_.hash_shift^_.window[Ne+1])&_.hash_mask;_.insert&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[Ne+k-1])&_.hash_mask,_.prev[Ne&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=Ne,Ne++,_.insert--,!(_.lookahead+_.insert<k)););}while(_.lookahead<W&&_.strm.avail_in!==0)}function me(_,V){var $=65535;for($>_.pending_buf_size-5&&($=_.pending_buf_size-5);;){if(_.lookahead<=1){if(ne(_),_.lookahead===0&&V===s)return D;if(_.lookahead===0)break}_.strstart+=_.lookahead,_.lookahead=0;var w=_.block_start+$;if((_.strstart===0||_.strstart>=w)&&(_.lookahead=_.strstart-w,_.strstart=w,ke(_,!1),_.strm.avail_out===0)||_.strstart-_.block_start>=_.w_size-W&&(ke(_,!1),_.strm.avail_out===0))return D}return _.insert=0,V===l?(ke(_,!0),_.strm.avail_out===0?ge:De):(_.strstart>_.block_start&&(ke(_,!1),_.strm.avail_out===0),D)}function xe(_,V){for(var $,w;;){if(_.lookahead<W){if(ne(_),_.lookahead<W&&V===s)return D;if(_.lookahead===0)break}if($=0,_.lookahead>=k&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,$=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),$!==0&&_.strstart-$<=_.w_size-W&&(_.match_length=P(_,$)),_.match_length>=k)if(w=e._tr_tally(_,_.strstart-_.match_start,_.match_length-k),_.lookahead-=_.match_length,_.match_length<=_.max_lazy_match&&_.lookahead>=k){_.match_length--;do _.strstart++,_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,$=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart;while(--_.match_length!==0);_.strstart++}else _.strstart+=_.match_length,_.match_length=0,_.ins_h=_.window[_.strstart],_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+1])&_.hash_mask;else w=e._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++;if(w&&(ke(_,!1),_.strm.avail_out===0))return D}return _.insert=_.strstart<k-1?_.strstart:k-1,V===l?(ke(_,!0),_.strm.avail_out===0?ge:De):_.last_lit&&(ke(_,!1),_.strm.avail_out===0)?D:se}function fe(_,V){for(var $,w,H;;){if(_.lookahead<W){if(ne(_),_.lookahead<W&&V===s)return D;if(_.lookahead===0)break}if($=0,_.lookahead>=k&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,$=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),_.prev_length=_.match_length,_.prev_match=_.match_start,_.match_length=k-1,$!==0&&_.prev_length<_.max_lazy_match&&_.strstart-$<=_.w_size-W&&(_.match_length=P(_,$),_.match_length<=5&&(_.strategy===g||_.match_length===k&&_.strstart-_.match_start>4096)&&(_.match_length=k-1)),_.prev_length>=k&&_.match_length<=_.prev_length){H=_.strstart+_.lookahead-k,w=e._tr_tally(_,_.strstart-1-_.prev_match,_.prev_length-k),_.lookahead-=_.prev_length-1,_.prev_length-=2;do++_.strstart<=H&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,$=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart);while(--_.prev_length!==0);if(_.match_available=0,_.match_length=k-1,_.strstart++,w&&(ke(_,!1),_.strm.avail_out===0))return D}else if(_.match_available){if(w=e._tr_tally(_,0,_.window[_.strstart-1]),w&&ke(_,!1),_.strstart++,_.lookahead--,_.strm.avail_out===0)return D}else _.match_available=1,_.strstart++,_.lookahead--}return _.match_available&&(w=e._tr_tally(_,0,_.window[_.strstart-1]),_.match_available=0),_.insert=_.strstart<k-1?_.strstart:k-1,V===l?(ke(_,!0),_.strm.avail_out===0?ge:De):_.last_lit&&(ke(_,!1),_.strm.avail_out===0)?D:se}function He(_,V){for(var $,w,H,Q,Ne=_.window;;){if(_.lookahead<=N){if(ne(_),_.lookahead<=N&&V===s)return D;if(_.lookahead===0)break}if(_.match_length=0,_.lookahead>=k&&_.strstart>0&&(H=_.strstart-1,w=Ne[H],w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H])){Q=_.strstart+N;do;while(w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H]&&w===Ne[++H]&&H<Q);_.match_length=N-(Q-H),_.match_length>_.lookahead&&(_.match_length=_.lookahead)}if(_.match_length>=k?($=e._tr_tally(_,1,_.match_length-k),_.lookahead-=_.match_length,_.strstart+=_.match_length,_.match_length=0):($=e._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++),$&&(ke(_,!1),_.strm.avail_out===0))return D}return _.insert=0,V===l?(ke(_,!0),_.strm.avail_out===0?ge:De):_.last_lit&&(ke(_,!1),_.strm.avail_out===0)?D:se}function Ce(_,V){for(var $;;){if(_.lookahead===0&&(ne(_),_.lookahead===0)){if(V===s)return D;break}if(_.match_length=0,$=e._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++,$&&(ke(_,!1),_.strm.avail_out===0))return D}return _.insert=0,V===l?(ke(_,!0),_.strm.avail_out===0?ge:De):_.last_lit&&(ke(_,!1),_.strm.avail_out===0)?D:se}function Ie(_,V,$,w,H){this.good_length=_,this.max_lazy=V,this.nice_length=$,this.max_chain=w,this.func=H}var ut;ut=[new Ie(0,0,0,0,me),new Ie(4,4,8,4,xe),new Ie(4,5,16,8,xe),new Ie(4,6,32,32,xe),new Ie(4,4,16,16,fe),new Ie(8,16,32,32,fe),new Ie(8,16,128,128,fe),new Ie(8,32,128,256,fe),new Ie(32,128,258,1024,fe),new Ie(32,258,258,4096,fe)];function Me(_){_.window_size=2*_.w_size,Je(_.head),_.max_lazy_match=ut[_.level].max_lazy,_.good_match=ut[_.level].good_length,_.nice_match=ut[_.level].nice_length,_.max_chain_length=ut[_.level].max_chain,_.strstart=0,_.block_start=0,_.lookahead=0,_.insert=0,_.match_length=_.prev_length=k-1,_.match_available=0,_.ins_h=0}function A(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=C,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new n.Buf16(de*2),this.dyn_dtree=new n.Buf16((2*j+1)*2),this.bl_tree=new n.Buf16((2*Z+1)*2),Je(this.dyn_ltree),Je(this.dyn_dtree),Je(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(ee+1),this.heap=new n.Buf16(2*X+1),Je(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*X+1),Je(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function oe(_){var V;return!_||!_.state?z(_,u):(_.total_in=_.total_out=0,_.data_type=T,V=_.state,V.pending=0,V.pending_out=0,V.wrap<0&&(V.wrap=-V.wrap),V.status=V.wrap?_e:we,_.adler=V.wrap===2?0:1,V.last_flush=s,e._tr_init(V),d)}function he(_){var V=oe(_);return V===d&&Me(_.state),V}function pe(_,V){return!_||!_.state||_.state.wrap!==2?u:(_.state.gzhead=V,d)}function G(_,V,$,w,H,Q){if(!_)return u;var Ne=1;if(V===v&&(V=6),w<0?(Ne=0,w=-w):w>15&&(Ne=2,w-=16),H<1||H>E||$!==C||w<8||w>15||V<0||V>9||Q<0||Q>x)return z(_,u);w===8&&(w=9);var be=new A;return _.state=be,be.strm=_,be.wrap=Ne,be.gzhead=null,be.w_bits=w,be.w_size=1<<be.w_bits,be.w_mask=be.w_size-1,be.hash_bits=H+7,be.hash_size=1<<be.hash_bits,be.hash_mask=be.hash_size-1,be.hash_shift=~~((be.hash_bits+k-1)/k),be.window=new n.Buf8(be.w_size*2),be.head=new n.Buf16(be.hash_size),be.prev=new n.Buf16(be.w_size),be.lit_bufsize=1<<H+6,be.pending_buf_size=be.lit_bufsize*4,be.pending_buf=new n.Buf8(be.pending_buf_size),be.d_buf=1*be.lit_bufsize,be.l_buf=3*be.lit_bufsize,be.level=V,be.strategy=Q,be.method=$,he(_)}function te(_,V){return G(_,V,C,U,Y,S)}function M(_,V){var $,w,H,Q;if(!_||!_.state||V>c||V<0)return _?z(_,u):u;if(w=_.state,!_.output||!_.input&&_.avail_in!==0||w.status===I&&V!==l)return z(_,_.avail_out===0?m:u);if(w.strm=_,$=w.last_flush,w.last_flush=V,w.status===_e)if(w.wrap===2)_.adler=0,Fe(w,31),Fe(w,139),Fe(w,8),w.gzhead?(Fe(w,(w.gzhead.text?1:0)+(w.gzhead.hcrc?2:0)+(w.gzhead.extra?4:0)+(w.gzhead.name?8:0)+(w.gzhead.comment?16:0)),Fe(w,w.gzhead.time&255),Fe(w,w.gzhead.time>>8&255),Fe(w,w.gzhead.time>>16&255),Fe(w,w.gzhead.time>>24&255),Fe(w,w.level===9?2:w.strategy>=p||w.level<2?4:0),Fe(w,w.gzhead.os&255),w.gzhead.extra&&w.gzhead.extra.length&&(Fe(w,w.gzhead.extra.length&255),Fe(w,w.gzhead.extra.length>>8&255)),w.gzhead.hcrc&&(_.adler=i(_.adler,w.pending_buf,w.pending,0)),w.gzindex=0,w.status=Ee):(Fe(w,0),Fe(w,0),Fe(w,0),Fe(w,0),Fe(w,0),Fe(w,w.level===9?2:w.strategy>=p||w.level<2?4:0),Fe(w,Se),w.status=we);else{var Ne=C+(w.w_bits-8<<4)<<8,be=-1;w.strategy>=p||w.level<2?be=0:w.level<6?be=1:w.level===6?be=2:be=3,Ne|=be<<6,w.strstart!==0&&(Ne|=ie),Ne+=31-Ne%31,w.status=we,Ge(w,Ne),w.strstart!==0&&(Ge(w,_.adler>>>16),Ge(w,_.adler&65535)),_.adler=1}if(w.status===Ee)if(w.gzhead.extra){for(H=w.pending;w.gzindex<(w.gzhead.extra.length&65535)&&!(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>H&&(_.adler=i(_.adler,w.pending_buf,w.pending-H,H)),et(_),H=w.pending,w.pending===w.pending_buf_size));)Fe(w,w.gzhead.extra[w.gzindex]&255),w.gzindex++;w.gzhead.hcrc&&w.pending>H&&(_.adler=i(_.adler,w.pending_buf,w.pending-H,H)),w.gzindex===w.gzhead.extra.length&&(w.gzindex=0,w.status=Pe)}else w.status=Pe;if(w.status===Pe)if(w.gzhead.name){H=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>H&&(_.adler=i(_.adler,w.pending_buf,w.pending-H,H)),et(_),H=w.pending,w.pending===w.pending_buf_size)){Q=1;break}w.gzindex<w.gzhead.name.length?Q=w.gzhead.name.charCodeAt(w.gzindex++)&255:Q=0,Fe(w,Q)}while(Q!==0);w.gzhead.hcrc&&w.pending>H&&(_.adler=i(_.adler,w.pending_buf,w.pending-H,H)),Q===0&&(w.gzindex=0,w.status=ce)}else w.status=ce;if(w.status===ce)if(w.gzhead.comment){H=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>H&&(_.adler=i(_.adler,w.pending_buf,w.pending-H,H)),et(_),H=w.pending,w.pending===w.pending_buf_size)){Q=1;break}w.gzindex<w.gzhead.comment.length?Q=w.gzhead.comment.charCodeAt(w.gzindex++)&255:Q=0,Fe(w,Q)}while(Q!==0);w.gzhead.hcrc&&w.pending>H&&(_.adler=i(_.adler,w.pending_buf,w.pending-H,H)),Q===0&&(w.status=ve)}else w.status=ve;if(w.status===ve&&(w.gzhead.hcrc?(w.pending+2>w.pending_buf_size&&et(_),w.pending+2<=w.pending_buf_size&&(Fe(w,_.adler&255),Fe(w,_.adler>>8&255),_.adler=0,w.status=we)):w.status=we),w.pending!==0){if(et(_),_.avail_out===0)return w.last_flush=-1,d}else if(_.avail_in===0&&Tt(V)<=Tt($)&&V!==l)return z(_,m);if(w.status===I&&_.avail_in!==0)return z(_,m);if(_.avail_in!==0||w.lookahead!==0||V!==s&&w.status!==I){var Re=w.strategy===p?Ce(w,V):w.strategy===y?He(w,V):ut[w.level].func(w,V);if((Re===ge||Re===De)&&(w.status=I),Re===D||Re===ge)return _.avail_out===0&&(w.last_flush=-1),d;if(Re===se&&(V===a?e._tr_align(w):V!==c&&(e._tr_stored_block(w,0,0,!1),V===o&&(Je(w.head),w.lookahead===0&&(w.strstart=0,w.block_start=0,w.insert=0))),et(_),_.avail_out===0))return w.last_flush=-1,d}return V!==l?d:w.wrap<=0?h:(w.wrap===2?(Fe(w,_.adler&255),Fe(w,_.adler>>8&255),Fe(w,_.adler>>16&255),Fe(w,_.adler>>24&255),Fe(w,_.total_in&255),Fe(w,_.total_in>>8&255),Fe(w,_.total_in>>16&255),Fe(w,_.total_in>>24&255)):(Ge(w,_.adler>>>16),Ge(w,_.adler&65535)),et(_),w.wrap>0&&(w.wrap=-w.wrap),w.pending!==0?d:h)}function O(_){var V;return!_||!_.state?u:(V=_.state.status,V!==_e&&V!==Ee&&V!==Pe&&V!==ce&&V!==ve&&V!==we&&V!==I?z(_,u):(_.state=null,V===we?z(_,f):d))}function ye(_,V){var $=V.length,w,H,Q,Ne,be,Re,ot,In;if(!_||!_.state||(w=_.state,Ne=w.wrap,Ne===2||Ne===1&&w.status!==_e||w.lookahead))return u;for(Ne===1&&(_.adler=t(_.adler,V,$,0)),w.wrap=0,$>=w.w_size&&(Ne===0&&(Je(w.head),w.strstart=0,w.block_start=0,w.insert=0),In=new n.Buf8(w.w_size),n.arraySet(In,V,$-w.w_size,w.w_size,0),V=In,$=w.w_size),be=_.avail_in,Re=_.next_in,ot=_.input,_.avail_in=$,_.next_in=0,_.input=V,ne(w);w.lookahead>=k;){H=w.strstart,Q=w.lookahead-(k-1);do w.ins_h=(w.ins_h<<w.hash_shift^w.window[H+k-1])&w.hash_mask,w.prev[H&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=H,H++;while(--Q);w.strstart=H,w.lookahead=k-1,ne(w)}return w.strstart+=w.lookahead,w.block_start=w.strstart,w.insert=w.lookahead,w.lookahead=0,w.match_length=w.prev_length=k-1,w.match_available=0,_.next_in=Re,_.input=ot,_.avail_in=be,w.wrap=Ne,d}return ii.deflateInit=te,ii.deflateInit2=G,ii.deflateReset=he,ii.deflateResetKeep=oe,ii.deflateSetHeader=pe,ii.deflate=M,ii.deflateEnd=O,ii.deflateSetDictionary=ye,ii.deflateInfo="pako deflate (from Nodeca project)",ii}var Tr={},xm;function S0(){if(xm)return Tr;xm=1;var n=br(),e=!0,t=!0;try{String.fromCharCode.apply(null,[0])}catch{e=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{t=!1}for(var i=new n.Buf8(256),r=0;r<256;r++)i[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;i[254]=i[254]=1,Tr.string2buf=function(a){var o,l,c,d,h,u=a.length,f=0;for(d=0;d<u;d++)l=a.charCodeAt(d),(l&64512)===55296&&d+1<u&&(c=a.charCodeAt(d+1),(c&64512)===56320&&(l=65536+(l-55296<<10)+(c-56320),d++)),f+=l<128?1:l<2048?2:l<65536?3:4;for(o=new n.Buf8(f),h=0,d=0;h<f;d++)l=a.charCodeAt(d),(l&64512)===55296&&d+1<u&&(c=a.charCodeAt(d+1),(c&64512)===56320&&(l=65536+(l-55296<<10)+(c-56320),d++)),l<128?o[h++]=l:l<2048?(o[h++]=192|l>>>6,o[h++]=128|l&63):l<65536?(o[h++]=224|l>>>12,o[h++]=128|l>>>6&63,o[h++]=128|l&63):(o[h++]=240|l>>>18,o[h++]=128|l>>>12&63,o[h++]=128|l>>>6&63,o[h++]=128|l&63);return o};function s(a,o){if(o<65534&&(a.subarray&&t||!a.subarray&&e))return String.fromCharCode.apply(null,n.shrinkBuf(a,o));for(var l="",c=0;c<o;c++)l+=String.fromCharCode(a[c]);return l}return Tr.buf2binstring=function(a){return s(a,a.length)},Tr.binstring2buf=function(a){for(var o=new n.Buf8(a.length),l=0,c=o.length;l<c;l++)o[l]=a.charCodeAt(l);return o},Tr.buf2string=function(a,o){var l,c,d,h,u=o||a.length,f=new Array(u*2);for(c=0,l=0;l<u;){if(d=a[l++],d<128){f[c++]=d;continue}if(h=i[d],h>4){f[c++]=65533,l+=h-1;continue}for(d&=h===2?31:h===3?15:7;h>1&&l<u;)d=d<<6|a[l++]&63,h--;if(h>1){f[c++]=65533;continue}d<65536?f[c++]=d:(d-=65536,f[c++]=55296|d>>10&1023,f[c++]=56320|d&1023)}return s(f,c)},Tr.utf8border=function(a,o){var l;for(o=o||a.length,o>a.length&&(o=a.length),l=o-1;l>=0&&(a[l]&192)===128;)l--;return l<0||l===0?o:l+i[a[l]]>o?l:o},Tr}var Lu,Sm;function b0(){if(Sm)return Lu;Sm=1;function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}return Lu=n,Lu}var bm;function cM(){if(bm)return ms;bm=1;var n=lM(),e=br(),t=S0(),i=Tf(),r=b0(),s=Object.prototype.toString,a=0,o=4,l=0,c=1,d=2,h=-1,u=0,f=8;function m(y){if(!(this instanceof m))return new m(y);this.options=e.assign({level:h,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},y||{});var x=this.options;x.raw&&x.windowBits>0?x.windowBits=-x.windowBits:x.gzip&&x.windowBits>0&&x.windowBits<16&&(x.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0;var S=n.deflateInit2(this.strm,x.level,x.method,x.windowBits,x.memLevel,x.strategy);if(S!==l)throw new Error(i[S]);if(x.header&&n.deflateSetHeader(this.strm,x.header),x.dictionary){var T;if(typeof x.dictionary=="string"?T=t.string2buf(x.dictionary):s.call(x.dictionary)==="[object ArrayBuffer]"?T=new Uint8Array(x.dictionary):T=x.dictionary,S=n.deflateSetDictionary(this.strm,T),S!==l)throw new Error(i[S]);this._dict_set=!0}}m.prototype.push=function(y,x){var S=this.strm,T=this.options.chunkSize,C,E;if(this.ended)return!1;E=x===~~x?x:x===!0?o:a,typeof y=="string"?S.input=t.string2buf(y):s.call(y)==="[object ArrayBuffer]"?S.input=new Uint8Array(y):S.input=y,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new e.Buf8(T),S.next_out=0,S.avail_out=T),C=n.deflate(S,E),C!==c&&C!==l)return this.onEnd(C),this.ended=!0,!1;(S.avail_out===0||S.avail_in===0&&(E===o||E===d))&&(this.options.to==="string"?this.onData(t.buf2binstring(e.shrinkBuf(S.output,S.next_out))):this.onData(e.shrinkBuf(S.output,S.next_out)))}while((S.avail_in>0||S.avail_out===0)&&C!==c);return E===o?(C=n.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===l):(E===d&&(this.onEnd(l),S.avail_out=0),!0)},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===l&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg};function v(y,x){var S=new m(x);if(S.push(y,!0),S.err)throw S.msg||i[S.err];return S.result}function g(y,x){return x=x||{},x.raw=!0,v(y,x)}function p(y,x){return x=x||{},x.gzip=!0,v(y,x)}return ms.Deflate=m,ms.deflate=v,ms.deflateRaw=g,ms.gzip=p,ms}var gs={},Xn={},Du,wm;function uM(){if(wm)return Du;wm=1;var n=30,e=12;return Du=function(i,r){var s,a,o,l,c,d,h,u,f,m,v,g,p,y,x,S,T,C,E,U,Y,b,R,X,j;s=i.state,a=i.next_in,X=i.input,o=a+(i.avail_in-5),l=i.next_out,j=i.output,c=l-(r-i.avail_out),d=l+(i.avail_out-257),h=s.dmax,u=s.wsize,f=s.whave,m=s.wnext,v=s.window,g=s.hold,p=s.bits,y=s.lencode,x=s.distcode,S=(1<<s.lenbits)-1,T=(1<<s.distbits)-1;e:do{p<15&&(g+=X[a++]<<p,p+=8,g+=X[a++]<<p,p+=8),C=y[g&S];t:for(;;){if(E=C>>>24,g>>>=E,p-=E,E=C>>>16&255,E===0)j[l++]=C&65535;else if(E&16){U=C&65535,E&=15,E&&(p<E&&(g+=X[a++]<<p,p+=8),U+=g&(1<<E)-1,g>>>=E,p-=E),p<15&&(g+=X[a++]<<p,p+=8,g+=X[a++]<<p,p+=8),C=x[g&T];n:for(;;){if(E=C>>>24,g>>>=E,p-=E,E=C>>>16&255,E&16){if(Y=C&65535,E&=15,p<E&&(g+=X[a++]<<p,p+=8,p<E&&(g+=X[a++]<<p,p+=8)),Y+=g&(1<<E)-1,Y>h){i.msg="invalid distance too far back",s.mode=n;break e}if(g>>>=E,p-=E,E=l-c,Y>E){if(E=Y-E,E>f&&s.sane){i.msg="invalid distance too far back",s.mode=n;break e}if(b=0,R=v,m===0){if(b+=u-E,E<U){U-=E;do j[l++]=v[b++];while(--E);b=l-Y,R=j}}else if(m<E){if(b+=u+m-E,E-=m,E<U){U-=E;do j[l++]=v[b++];while(--E);if(b=0,m<U){E=m,U-=E;do j[l++]=v[b++];while(--E);b=l-Y,R=j}}}else if(b+=m-E,E<U){U-=E;do j[l++]=v[b++];while(--E);b=l-Y,R=j}for(;U>2;)j[l++]=R[b++],j[l++]=R[b++],j[l++]=R[b++],U-=3;U&&(j[l++]=R[b++],U>1&&(j[l++]=R[b++]))}else{b=l-Y;do j[l++]=j[b++],j[l++]=j[b++],j[l++]=j[b++],U-=3;while(U>2);U&&(j[l++]=j[b++],U>1&&(j[l++]=j[b++]))}}else if((E&64)===0){C=x[(C&65535)+(g&(1<<E)-1)];continue n}else{i.msg="invalid distance code",s.mode=n;break e}break}}else if((E&64)===0){C=y[(C&65535)+(g&(1<<E)-1)];continue t}else if(E&32){s.mode=e;break e}else{i.msg="invalid literal/length code",s.mode=n;break e}break}}while(a<o&&l<d);U=p>>3,a-=U,p-=U<<3,g&=(1<<p)-1,i.next_in=a,i.next_out=l,i.avail_in=a<o?5+(o-a):5-(a-o),i.avail_out=l<d?257+(d-l):257-(l-d),s.hold=g,s.bits=p},Du}var Nu,Mm;function hM(){if(Mm)return Nu;Mm=1;var n=br(),e=15,t=852,i=592,r=0,s=1,a=2,o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];return Nu=function(u,f,m,v,g,p,y,x){var S=x.bits,T=0,C=0,E=0,U=0,Y=0,b=0,R=0,X=0,j=0,Z=0,de,ee,k,N,W,ie=null,_e=0,Ee,Pe=new n.Buf16(e+1),ce=new n.Buf16(e+1),ve=null,we=0,I,D,se;for(T=0;T<=e;T++)Pe[T]=0;for(C=0;C<v;C++)Pe[f[m+C]]++;for(Y=S,U=e;U>=1&&Pe[U]===0;U--);if(Y>U&&(Y=U),U===0)return g[p++]=1<<24|64<<16|0,g[p++]=1<<24|64<<16|0,x.bits=1,0;for(E=1;E<U&&Pe[E]===0;E++);for(Y<E&&(Y=E),X=1,T=1;T<=e;T++)if(X<<=1,X-=Pe[T],X<0)return-1;if(X>0&&(u===r||U!==1))return-1;for(ce[1]=0,T=1;T<e;T++)ce[T+1]=ce[T]+Pe[T];for(C=0;C<v;C++)f[m+C]!==0&&(y[ce[f[m+C]]++]=C);if(u===r?(ie=ve=y,Ee=19):u===s?(ie=o,_e-=257,ve=l,we-=257,Ee=256):(ie=c,ve=d,Ee=-1),Z=0,C=0,T=E,W=p,b=Y,R=0,k=-1,j=1<<Y,N=j-1,u===s&&j>t||u===a&&j>i)return 1;for(;;){I=T-R,y[C]<Ee?(D=0,se=y[C]):y[C]>Ee?(D=ve[we+y[C]],se=ie[_e+y[C]]):(D=96,se=0),de=1<<T-R,ee=1<<b,E=ee;do ee-=de,g[W+(Z>>R)+ee]=I<<24|D<<16|se|0;while(ee!==0);for(de=1<<T-1;Z&de;)de>>=1;if(de!==0?(Z&=de-1,Z+=de):Z=0,C++,--Pe[T]===0){if(T===U)break;T=f[m+y[C]]}if(T>Y&&(Z&N)!==k){for(R===0&&(R=Y),W+=E,b=T-R,X=1<<b;b+R<U&&(X-=Pe[b+R],!(X<=0));)b++,X<<=1;if(j+=1<<b,u===s&&j>t||u===a&&j>i)return 1;k=Z&N,g[k]=Y<<24|b<<16|W-p|0}}return Z!==0&&(g[W+Z]=T-R<<24|64<<16|0),x.bits=Y,0},Nu}var Em;function dM(){if(Em)return Xn;Em=1;var n=br(),e=y0(),t=x0(),i=uM(),r=hM(),s=0,a=1,o=2,l=4,c=5,d=6,h=0,u=1,f=2,m=-2,v=-3,g=-4,p=-5,y=8,x=1,S=2,T=3,C=4,E=5,U=6,Y=7,b=8,R=9,X=10,j=11,Z=12,de=13,ee=14,k=15,N=16,W=17,ie=18,_e=19,Ee=20,Pe=21,ce=22,ve=23,we=24,I=25,D=26,se=27,ge=28,De=29,Se=30,z=31,Tt=32,Je=852,et=592,ke=15,Fe=ke;function Ge(G){return(G>>>24&255)+(G>>>8&65280)+((G&65280)<<8)+((G&255)<<24)}function F(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function P(G){var te;return!G||!G.state?m:(te=G.state,G.total_in=G.total_out=te.total=0,G.msg="",te.wrap&&(G.adler=te.wrap&1),te.mode=x,te.last=0,te.havedict=0,te.dmax=32768,te.head=null,te.hold=0,te.bits=0,te.lencode=te.lendyn=new n.Buf32(Je),te.distcode=te.distdyn=new n.Buf32(et),te.sane=1,te.back=-1,h)}function ne(G){var te;return!G||!G.state?m:(te=G.state,te.wsize=0,te.whave=0,te.wnext=0,P(G))}function me(G,te){var M,O;return!G||!G.state||(O=G.state,te<0?(M=0,te=-te):(M=(te>>4)+1,te<48&&(te&=15)),te&&(te<8||te>15))?m:(O.window!==null&&O.wbits!==te&&(O.window=null),O.wrap=M,O.wbits=te,ne(G))}function xe(G,te){var M,O;return G?(O=new F,G.state=O,O.window=null,M=me(G,te),M!==h&&(G.state=null),M):m}function fe(G){return xe(G,Fe)}var He=!0,Ce,Ie;function ut(G){if(He){var te;for(Ce=new n.Buf32(512),Ie=new n.Buf32(32),te=0;te<144;)G.lens[te++]=8;for(;te<256;)G.lens[te++]=9;for(;te<280;)G.lens[te++]=7;for(;te<288;)G.lens[te++]=8;for(r(a,G.lens,0,288,Ce,0,G.work,{bits:9}),te=0;te<32;)G.lens[te++]=5;r(o,G.lens,0,32,Ie,0,G.work,{bits:5}),He=!1}G.lencode=Ce,G.lenbits=9,G.distcode=Ie,G.distbits=5}function Me(G,te,M,O){var ye,_=G.state;return _.window===null&&(_.wsize=1<<_.wbits,_.wnext=0,_.whave=0,_.window=new n.Buf8(_.wsize)),O>=_.wsize?(n.arraySet(_.window,te,M-_.wsize,_.wsize,0),_.wnext=0,_.whave=_.wsize):(ye=_.wsize-_.wnext,ye>O&&(ye=O),n.arraySet(_.window,te,M-O,ye,_.wnext),O-=ye,O?(n.arraySet(_.window,te,M-O,O,0),_.wnext=O,_.whave=_.wsize):(_.wnext+=ye,_.wnext===_.wsize&&(_.wnext=0),_.whave<_.wsize&&(_.whave+=ye))),0}function A(G,te){var M,O,ye,_,V,$,w,H,Q,Ne,be,Re,ot,In,It=0,ht,kt,Xt,Jt,ei,ti,Lt,un,Ht=new n.Buf8(4),Gn,Ln,Mr=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!G||!G.state||!G.output||!G.input&&G.avail_in!==0)return m;M=G.state,M.mode===Z&&(M.mode=de),V=G.next_out,ye=G.output,w=G.avail_out,_=G.next_in,O=G.input,$=G.avail_in,H=M.hold,Q=M.bits,Ne=$,be=w,un=h;e:for(;;)switch(M.mode){case x:if(M.wrap===0){M.mode=de;break}for(;Q<16;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(M.wrap&2&&H===35615){M.check=0,Ht[0]=H&255,Ht[1]=H>>>8&255,M.check=t(M.check,Ht,2,0),H=0,Q=0,M.mode=S;break}if(M.flags=0,M.head&&(M.head.done=!1),!(M.wrap&1)||(((H&255)<<8)+(H>>8))%31){G.msg="incorrect header check",M.mode=Se;break}if((H&15)!==y){G.msg="unknown compression method",M.mode=Se;break}if(H>>>=4,Q-=4,Lt=(H&15)+8,M.wbits===0)M.wbits=Lt;else if(Lt>M.wbits){G.msg="invalid window size",M.mode=Se;break}M.dmax=1<<Lt,G.adler=M.check=1,M.mode=H&512?X:Z,H=0,Q=0;break;case S:for(;Q<16;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(M.flags=H,(M.flags&255)!==y){G.msg="unknown compression method",M.mode=Se;break}if(M.flags&57344){G.msg="unknown header flags set",M.mode=Se;break}M.head&&(M.head.text=H>>8&1),M.flags&512&&(Ht[0]=H&255,Ht[1]=H>>>8&255,M.check=t(M.check,Ht,2,0)),H=0,Q=0,M.mode=T;case T:for(;Q<32;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}M.head&&(M.head.time=H),M.flags&512&&(Ht[0]=H&255,Ht[1]=H>>>8&255,Ht[2]=H>>>16&255,Ht[3]=H>>>24&255,M.check=t(M.check,Ht,4,0)),H=0,Q=0,M.mode=C;case C:for(;Q<16;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}M.head&&(M.head.xflags=H&255,M.head.os=H>>8),M.flags&512&&(Ht[0]=H&255,Ht[1]=H>>>8&255,M.check=t(M.check,Ht,2,0)),H=0,Q=0,M.mode=E;case E:if(M.flags&1024){for(;Q<16;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}M.length=H,M.head&&(M.head.extra_len=H),M.flags&512&&(Ht[0]=H&255,Ht[1]=H>>>8&255,M.check=t(M.check,Ht,2,0)),H=0,Q=0}else M.head&&(M.head.extra=null);M.mode=U;case U:if(M.flags&1024&&(Re=M.length,Re>$&&(Re=$),Re&&(M.head&&(Lt=M.head.extra_len-M.length,M.head.extra||(M.head.extra=new Array(M.head.extra_len)),n.arraySet(M.head.extra,O,_,Re,Lt)),M.flags&512&&(M.check=t(M.check,O,Re,_)),$-=Re,_+=Re,M.length-=Re),M.length))break e;M.length=0,M.mode=Y;case Y:if(M.flags&2048){if($===0)break e;Re=0;do Lt=O[_+Re++],M.head&&Lt&&M.length<65536&&(M.head.name+=String.fromCharCode(Lt));while(Lt&&Re<$);if(M.flags&512&&(M.check=t(M.check,O,Re,_)),$-=Re,_+=Re,Lt)break e}else M.head&&(M.head.name=null);M.length=0,M.mode=b;case b:if(M.flags&4096){if($===0)break e;Re=0;do Lt=O[_+Re++],M.head&&Lt&&M.length<65536&&(M.head.comment+=String.fromCharCode(Lt));while(Lt&&Re<$);if(M.flags&512&&(M.check=t(M.check,O,Re,_)),$-=Re,_+=Re,Lt)break e}else M.head&&(M.head.comment=null);M.mode=R;case R:if(M.flags&512){for(;Q<16;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(H!==(M.check&65535)){G.msg="header crc mismatch",M.mode=Se;break}H=0,Q=0}M.head&&(M.head.hcrc=M.flags>>9&1,M.head.done=!0),G.adler=M.check=0,M.mode=Z;break;case X:for(;Q<32;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}G.adler=M.check=Ge(H),H=0,Q=0,M.mode=j;case j:if(M.havedict===0)return G.next_out=V,G.avail_out=w,G.next_in=_,G.avail_in=$,M.hold=H,M.bits=Q,f;G.adler=M.check=1,M.mode=Z;case Z:if(te===c||te===d)break e;case de:if(M.last){H>>>=Q&7,Q-=Q&7,M.mode=se;break}for(;Q<3;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}switch(M.last=H&1,H>>>=1,Q-=1,H&3){case 0:M.mode=ee;break;case 1:if(ut(M),M.mode=Ee,te===d){H>>>=2,Q-=2;break e}break;case 2:M.mode=W;break;case 3:G.msg="invalid block type",M.mode=Se}H>>>=2,Q-=2;break;case ee:for(H>>>=Q&7,Q-=Q&7;Q<32;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if((H&65535)!==(H>>>16^65535)){G.msg="invalid stored block lengths",M.mode=Se;break}if(M.length=H&65535,H=0,Q=0,M.mode=k,te===d)break e;case k:M.mode=N;case N:if(Re=M.length,Re){if(Re>$&&(Re=$),Re>w&&(Re=w),Re===0)break e;n.arraySet(ye,O,_,Re,V),$-=Re,_+=Re,w-=Re,V+=Re,M.length-=Re;break}M.mode=Z;break;case W:for(;Q<14;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(M.nlen=(H&31)+257,H>>>=5,Q-=5,M.ndist=(H&31)+1,H>>>=5,Q-=5,M.ncode=(H&15)+4,H>>>=4,Q-=4,M.nlen>286||M.ndist>30){G.msg="too many length or distance symbols",M.mode=Se;break}M.have=0,M.mode=ie;case ie:for(;M.have<M.ncode;){for(;Q<3;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}M.lens[Mr[M.have++]]=H&7,H>>>=3,Q-=3}for(;M.have<19;)M.lens[Mr[M.have++]]=0;if(M.lencode=M.lendyn,M.lenbits=7,Gn={bits:M.lenbits},un=r(s,M.lens,0,19,M.lencode,0,M.work,Gn),M.lenbits=Gn.bits,un){G.msg="invalid code lengths set",M.mode=Se;break}M.have=0,M.mode=_e;case _e:for(;M.have<M.nlen+M.ndist;){for(;It=M.lencode[H&(1<<M.lenbits)-1],ht=It>>>24,kt=It>>>16&255,Xt=It&65535,!(ht<=Q);){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(Xt<16)H>>>=ht,Q-=ht,M.lens[M.have++]=Xt;else{if(Xt===16){for(Ln=ht+2;Q<Ln;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(H>>>=ht,Q-=ht,M.have===0){G.msg="invalid bit length repeat",M.mode=Se;break}Lt=M.lens[M.have-1],Re=3+(H&3),H>>>=2,Q-=2}else if(Xt===17){for(Ln=ht+3;Q<Ln;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}H>>>=ht,Q-=ht,Lt=0,Re=3+(H&7),H>>>=3,Q-=3}else{for(Ln=ht+7;Q<Ln;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}H>>>=ht,Q-=ht,Lt=0,Re=11+(H&127),H>>>=7,Q-=7}if(M.have+Re>M.nlen+M.ndist){G.msg="invalid bit length repeat",M.mode=Se;break}for(;Re--;)M.lens[M.have++]=Lt}}if(M.mode===Se)break;if(M.lens[256]===0){G.msg="invalid code -- missing end-of-block",M.mode=Se;break}if(M.lenbits=9,Gn={bits:M.lenbits},un=r(a,M.lens,0,M.nlen,M.lencode,0,M.work,Gn),M.lenbits=Gn.bits,un){G.msg="invalid literal/lengths set",M.mode=Se;break}if(M.distbits=6,M.distcode=M.distdyn,Gn={bits:M.distbits},un=r(o,M.lens,M.nlen,M.ndist,M.distcode,0,M.work,Gn),M.distbits=Gn.bits,un){G.msg="invalid distances set",M.mode=Se;break}if(M.mode=Ee,te===d)break e;case Ee:M.mode=Pe;case Pe:if($>=6&&w>=258){G.next_out=V,G.avail_out=w,G.next_in=_,G.avail_in=$,M.hold=H,M.bits=Q,i(G,be),V=G.next_out,ye=G.output,w=G.avail_out,_=G.next_in,O=G.input,$=G.avail_in,H=M.hold,Q=M.bits,M.mode===Z&&(M.back=-1);break}for(M.back=0;It=M.lencode[H&(1<<M.lenbits)-1],ht=It>>>24,kt=It>>>16&255,Xt=It&65535,!(ht<=Q);){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(kt&&(kt&240)===0){for(Jt=ht,ei=kt,ti=Xt;It=M.lencode[ti+((H&(1<<Jt+ei)-1)>>Jt)],ht=It>>>24,kt=It>>>16&255,Xt=It&65535,!(Jt+ht<=Q);){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}H>>>=Jt,Q-=Jt,M.back+=Jt}if(H>>>=ht,Q-=ht,M.back+=ht,M.length=Xt,kt===0){M.mode=D;break}if(kt&32){M.back=-1,M.mode=Z;break}if(kt&64){G.msg="invalid literal/length code",M.mode=Se;break}M.extra=kt&15,M.mode=ce;case ce:if(M.extra){for(Ln=M.extra;Q<Ln;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}M.length+=H&(1<<M.extra)-1,H>>>=M.extra,Q-=M.extra,M.back+=M.extra}M.was=M.length,M.mode=ve;case ve:for(;It=M.distcode[H&(1<<M.distbits)-1],ht=It>>>24,kt=It>>>16&255,Xt=It&65535,!(ht<=Q);){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if((kt&240)===0){for(Jt=ht,ei=kt,ti=Xt;It=M.distcode[ti+((H&(1<<Jt+ei)-1)>>Jt)],ht=It>>>24,kt=It>>>16&255,Xt=It&65535,!(Jt+ht<=Q);){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}H>>>=Jt,Q-=Jt,M.back+=Jt}if(H>>>=ht,Q-=ht,M.back+=ht,kt&64){G.msg="invalid distance code",M.mode=Se;break}M.offset=Xt,M.extra=kt&15,M.mode=we;case we:if(M.extra){for(Ln=M.extra;Q<Ln;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}M.offset+=H&(1<<M.extra)-1,H>>>=M.extra,Q-=M.extra,M.back+=M.extra}if(M.offset>M.dmax){G.msg="invalid distance too far back",M.mode=Se;break}M.mode=I;case I:if(w===0)break e;if(Re=be-w,M.offset>Re){if(Re=M.offset-Re,Re>M.whave&&M.sane){G.msg="invalid distance too far back",M.mode=Se;break}Re>M.wnext?(Re-=M.wnext,ot=M.wsize-Re):ot=M.wnext-Re,Re>M.length&&(Re=M.length),In=M.window}else In=ye,ot=V-M.offset,Re=M.length;Re>w&&(Re=w),w-=Re,M.length-=Re;do ye[V++]=In[ot++];while(--Re);M.length===0&&(M.mode=Pe);break;case D:if(w===0)break e;ye[V++]=M.length,w--,M.mode=Pe;break;case se:if(M.wrap){for(;Q<32;){if($===0)break e;$--,H|=O[_++]<<Q,Q+=8}if(be-=w,G.total_out+=be,M.total+=be,be&&(G.adler=M.check=M.flags?t(M.check,ye,be,V-be):e(M.check,ye,be,V-be)),be=w,(M.flags?H:Ge(H))!==M.check){G.msg="incorrect data check",M.mode=Se;break}H=0,Q=0}M.mode=ge;case ge:if(M.wrap&&M.flags){for(;Q<32;){if($===0)break e;$--,H+=O[_++]<<Q,Q+=8}if(H!==(M.total&4294967295)){G.msg="incorrect length check",M.mode=Se;break}H=0,Q=0}M.mode=De;case De:un=u;break e;case Se:un=v;break e;case z:return g;case Tt:default:return m}return G.next_out=V,G.avail_out=w,G.next_in=_,G.avail_in=$,M.hold=H,M.bits=Q,(M.wsize||be!==G.avail_out&&M.mode<Se&&(M.mode<se||te!==l))&&Me(G,G.output,G.next_out,be-G.avail_out),Ne-=G.avail_in,be-=G.avail_out,G.total_in+=Ne,G.total_out+=be,M.total+=be,M.wrap&&be&&(G.adler=M.check=M.flags?t(M.check,ye,be,G.next_out-be):e(M.check,ye,be,G.next_out-be)),G.data_type=M.bits+(M.last?64:0)+(M.mode===Z?128:0)+(M.mode===Ee||M.mode===k?256:0),(Ne===0&&be===0||te===l)&&un===h&&(un=p),un}function oe(G){if(!G||!G.state)return m;var te=G.state;return te.window&&(te.window=null),G.state=null,h}function he(G,te){var M;return!G||!G.state||(M=G.state,(M.wrap&2)===0)?m:(M.head=te,te.done=!1,h)}function pe(G,te){var M=te.length,O,ye,_;return!G||!G.state||(O=G.state,O.wrap!==0&&O.mode!==j)?m:O.mode===j&&(ye=1,ye=e(ye,te,M,0),ye!==O.check)?v:(_=Me(G,te,M,M),_?(O.mode=z,g):(O.havedict=1,h))}return Xn.inflateReset=ne,Xn.inflateReset2=me,Xn.inflateResetKeep=P,Xn.inflateInit=fe,Xn.inflateInit2=xe,Xn.inflate=A,Xn.inflateEnd=oe,Xn.inflateGetHeader=he,Xn.inflateSetDictionary=pe,Xn.inflateInfo="pako inflate (from Nodeca project)",Xn}var Ou,Tm;function w0(){return Tm||(Tm=1,Ou={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}),Ou}var ku,Am;function fM(){if(Am)return ku;Am=1;function n(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}return ku=n,ku}var Rm;function pM(){if(Rm)return gs;Rm=1;var n=dM(),e=br(),t=S0(),i=w0(),r=Tf(),s=b0(),a=fM(),o=Object.prototype.toString;function l(h){if(!(this instanceof l))return new l(h);this.options=e.assign({chunkSize:16384,windowBits:0,to:""},h||{});var u=this.options;u.raw&&u.windowBits>=0&&u.windowBits<16&&(u.windowBits=-u.windowBits,u.windowBits===0&&(u.windowBits=-15)),u.windowBits>=0&&u.windowBits<16&&!(h&&h.windowBits)&&(u.windowBits+=32),u.windowBits>15&&u.windowBits<48&&(u.windowBits&15)===0&&(u.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var f=n.inflateInit2(this.strm,u.windowBits);if(f!==i.Z_OK)throw new Error(r[f]);if(this.header=new a,n.inflateGetHeader(this.strm,this.header),u.dictionary&&(typeof u.dictionary=="string"?u.dictionary=t.string2buf(u.dictionary):o.call(u.dictionary)==="[object ArrayBuffer]"&&(u.dictionary=new Uint8Array(u.dictionary)),u.raw&&(f=n.inflateSetDictionary(this.strm,u.dictionary),f!==i.Z_OK)))throw new Error(r[f])}l.prototype.push=function(h,u){var f=this.strm,m=this.options.chunkSize,v=this.options.dictionary,g,p,y,x,S,T=!1;if(this.ended)return!1;p=u===~~u?u:u===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof h=="string"?f.input=t.binstring2buf(h):o.call(h)==="[object ArrayBuffer]"?f.input=new Uint8Array(h):f.input=h,f.next_in=0,f.avail_in=f.input.length;do{if(f.avail_out===0&&(f.output=new e.Buf8(m),f.next_out=0,f.avail_out=m),g=n.inflate(f,i.Z_NO_FLUSH),g===i.Z_NEED_DICT&&v&&(g=n.inflateSetDictionary(this.strm,v)),g===i.Z_BUF_ERROR&&T===!0&&(g=i.Z_OK,T=!1),g!==i.Z_STREAM_END&&g!==i.Z_OK)return this.onEnd(g),this.ended=!0,!1;f.next_out&&(f.avail_out===0||g===i.Z_STREAM_END||f.avail_in===0&&(p===i.Z_FINISH||p===i.Z_SYNC_FLUSH))&&(this.options.to==="string"?(y=t.utf8border(f.output,f.next_out),x=f.next_out-y,S=t.buf2string(f.output,y),f.next_out=x,f.avail_out=m-x,x&&e.arraySet(f.output,f.output,y,x,0),this.onData(S)):this.onData(e.shrinkBuf(f.output,f.next_out))),f.avail_in===0&&f.avail_out===0&&(T=!0)}while((f.avail_in>0||f.avail_out===0)&&g!==i.Z_STREAM_END);return g===i.Z_STREAM_END&&(p=i.Z_FINISH),p===i.Z_FINISH?(g=n.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===i.Z_OK):(p===i.Z_SYNC_FLUSH&&(this.onEnd(i.Z_OK),f.avail_out=0),!0)},l.prototype.onData=function(h){this.chunks.push(h)},l.prototype.onEnd=function(h){h===i.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg};function c(h,u){var f=new l(u);if(f.push(h,!0),f.err)throw f.msg||r[f.err];return f.result}function d(h,u){return u=u||{},u.raw=!0,c(h,u)}return gs.Inflate=l,gs.inflate=c,gs.inflateRaw=d,gs.ungzip=c,gs}var Uu,Cm;function mM(){if(Cm)return Uu;Cm=1;var n=br().assign,e=cM(),t=pM(),i=w0(),r={};return n(r,e,t,i),Uu=r,Uu}var Pm;function gM(){if(Pm)return Ea;Pm=1;var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",e=mM(),t=jt(),i=Qn(),r=n?"uint8array":"array";Ea.magic="\b\0";function s(a,o){i.call(this,"FlateWorker/"+a),this._pako=null,this._pakoAction=a,this._pakoOptions=o,this.meta={}}return t.inherits(s,i),s.prototype.processChunk=function(a){this.meta=a.meta,this._pako===null&&this._createPako(),this._pako.push(t.transformTo(r,a.data),!1)},s.prototype.flush=function(){i.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this._pako=null},s.prototype._createPako=function(){this._pako=new e[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var a=this;this._pako.onData=function(o){a.push({data:o,meta:a.meta})}},Ea.compressWorker=function(a){return new s("Deflate",a)},Ea.uncompressWorker=function(){return new s("Inflate",{})},Ea}var Im;function M0(){if(Im)return Ko;Im=1;var n=Qn();return Ko.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},Ko.DEFLATE=gM(),Ko}var nr={},Lm;function E0(){return Lm||(Lm=1,nr.LOCAL_FILE_HEADER="PK",nr.CENTRAL_FILE_HEADER="PK",nr.CENTRAL_DIRECTORY_END="PK",nr.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",nr.ZIP64_CENTRAL_DIRECTORY_END="PK",nr.DATA_DESCRIPTOR="PK\x07\b"),nr}var Fu,Dm;function _M(){if(Dm)return Fu;Dm=1;var n=jt(),e=Qn(),t=Uo(),i=Mf(),r=E0(),s=function(u,f){var m="",v;for(v=0;v<f;v++)m+=String.fromCharCode(u&255),u=u>>>8;return m},a=function(u,f){var m=u;return u||(m=f?16893:33204),(m&65535)<<16},o=function(u){return(u||0)&63},l=function(u,f,m,v,g,p){var y=u.file,x=u.compression,S=p!==t.utf8encode,T=n.transformTo("string",p(y.name)),C=n.transformTo("string",t.utf8encode(y.name)),E=y.comment,U=n.transformTo("string",p(E)),Y=n.transformTo("string",t.utf8encode(E)),b=C.length!==y.name.length,R=Y.length!==E.length,X,j,Z="",de="",ee="",k=y.dir,N=y.date,W={crc32:0,compressedSize:0,uncompressedSize:0};(!f||m)&&(W.crc32=u.crc32,W.compressedSize=u.compressedSize,W.uncompressedSize=u.uncompressedSize);var ie=0;f&&(ie|=8),!S&&(b||R)&&(ie|=2048);var _e=0,Ee=0;k&&(_e|=16),g==="UNIX"?(Ee=798,_e|=a(y.unixPermissions,k)):(Ee=20,_e|=o(y.dosPermissions)),X=N.getUTCHours(),X=X<<6,X=X|N.getUTCMinutes(),X=X<<5,X=X|N.getUTCSeconds()/2,j=N.getUTCFullYear()-1980,j=j<<4,j=j|N.getUTCMonth()+1,j=j<<5,j=j|N.getUTCDate(),b&&(de=s(1,1)+s(i(T),4)+C,Z+="up"+s(de.length,2)+de),R&&(ee=s(1,1)+s(i(U),4)+Y,Z+="uc"+s(ee.length,2)+ee);var Pe="";Pe+=`
205
205
  \0`,Pe+=s(ie,2),Pe+=x.magic,Pe+=s(X,2),Pe+=s(j,2),Pe+=s(W.crc32,4),Pe+=s(W.compressedSize,4),Pe+=s(W.uncompressedSize,4),Pe+=s(T.length,2),Pe+=s(Z.length,2);var ce=r.LOCAL_FILE_HEADER+Pe+T+Z,ve=r.CENTRAL_FILE_HEADER+s(Ee,2)+Pe+s(U.length,2)+"\0\0\0\0"+s(_e,4)+s(v,4)+T+Z+U;return{fileRecord:ce,dirRecord:ve}},c=function(u,f,m,v,g){var p="",y=n.transformTo("string",g(v));return p=r.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(u,2)+s(u,2)+s(f,4)+s(m,4)+s(y.length,2)+y,p},d=function(u){var f="";return f=r.DATA_DESCRIPTOR+s(u.crc32,4)+s(u.compressedSize,4)+s(u.uncompressedSize,4),f};function h(u,f,m,v){e.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=m,this.encodeFileName=v,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}return n.inherits(h,e),h.prototype.push=function(u){var f=u.meta.percent||0,m=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,e.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:m?(f+100*(m-v-1))/m:100}}))},h.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var f=this.streamFiles&&!u.file.dir;if(f){var m=l(u,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(u){this.accumulate=!1;var f=this.streamFiles&&!u.file.dir,m=l(u,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),f)this.push({data:d(u),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var u=this.bytesWritten,f=0;f<this.dirRecords.length;f++)this.push({data:this.dirRecords[f],meta:{percent:100}});var m=this.bytesWritten-u,v=c(this.dirRecords.length,m,u,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(u){this._sources.push(u);var f=this;return u.on("data",function(m){f.processChunk(m)}),u.on("end",function(){f.closedSource(f.previous.streamInfo),f._sources.length?f.prepareNextSource():f.end()}),u.on("error",function(m){f.error(m)}),this},h.prototype.resume=function(){if(!e.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0},h.prototype.error=function(u){var f=this._sources;if(!e.prototype.error.call(this,u))return!1;for(var m=0;m<f.length;m++)try{f[m].error(u)}catch{}return!0},h.prototype.lock=function(){e.prototype.lock.call(this);for(var u=this._sources,f=0;f<u.length;f++)u[f].lock()},Fu=h,Fu}var Nm;function vM(){if(Nm)return Au;Nm=1;var n=M0(),e=_M(),t=function(i,r){var s=i||r,a=n[s];if(!a)throw new Error(s+" is not a valid compression method !");return a};return Au.generateWorker=function(i,r,s){var a=new e(r.streamFiles,s,r.platform,r.encodeFileName),o=0;try{i.forEach(function(l,c){o++;var d=t(c.options.compression,r.compression),h=c.options.compressionOptions||r.compressionOptions||{},u=c.dir,f=c.date;c._compressWorker(d,h).withStreamInfo("file",{name:l,dir:u,date:f,comment:c.comment||"",unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions}).pipe(a)}),a.entriesCount=o}catch(l){a.error(l)}return a},Au}var Bu,Om;function yM(){if(Om)return Bu;Om=1;var n=jt(),e=Qn();function t(i,r){e.call(this,"Nodejs stream input adapter for "+i),this._upstreamEnded=!1,this._bindStream(r)}return n.inherits(t,e),t.prototype._bindStream=function(i){var r=this;this._stream=i,i.pause(),i.on("data",function(s){r.push({data:s,meta:{percent:0}})}).on("error",function(s){r.isPaused?this.generatedError=s:r.error(s)}).on("end",function(){r.isPaused?r._upstreamEnded=!0:r.end()})},t.prototype.pause=function(){return e.prototype.pause.call(this)?(this._stream.pause(),!0):!1},t.prototype.resume=function(){return e.prototype.resume.call(this)?(this._upstreamEnded?this.end():this._stream.resume(),!0):!1},Bu=t,Bu}var zu,km;function xM(){if(km)return zu;km=1;var n=Uo(),e=jt(),t=Qn(),i=m0(),r=g0(),s=Ef(),a=aM(),o=vM(),l=Lc(),c=yM(),d=function(g,p,y){var x=e.getTypeOf(p),S,T=e.extend(y||{},r);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&T.unixPermissions&16384&&(T.dir=!0),T.dosPermissions&&T.dosPermissions&16&&(T.dir=!0),T.dir&&(g=u(g)),T.createFolders&&(S=h(g))&&f.call(this,S,!0);var C=x==="string"&&T.binary===!1&&T.base64===!1;(!y||typeof y.binary>"u")&&(T.binary=!C);var E=p instanceof s&&p.uncompressedSize===0;(E||T.dir||!p||p.length===0)&&(T.base64=!1,T.binary=!0,p="",T.compression="STORE",x="string");var U=null;p instanceof s||p instanceof t?U=p:l.isNode&&l.isStream(p)?U=new c(g,p):U=e.prepareContent(g,p,T.binary,T.optimizedBinaryString,T.base64);var Y=new a(g,U,T);this.files[g]=Y},h=function(g){g.slice(-1)==="/"&&(g=g.substring(0,g.length-1));var p=g.lastIndexOf("/");return p>0?g.substring(0,p):""},u=function(g){return g.slice(-1)!=="/"&&(g+="/"),g},f=function(g,p){return p=typeof p<"u"?p:r.createFolders,g=u(g),this.files[g]||d.call(this,g,null,{dir:!0,createFolders:p}),this.files[g]};function m(g){return Object.prototype.toString.call(g)==="[object RegExp]"}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(g){var p,y,x;for(p in this.files)x=this.files[p],y=p.slice(this.root.length,p.length),y&&p.slice(0,this.root.length)===this.root&&g(y,x)},filter:function(g){var p=[];return this.forEach(function(y,x){g(y,x)&&p.push(x)}),p},file:function(g,p,y){if(arguments.length===1)if(m(g)){var x=g;return this.filter(function(T,C){return!C.dir&&x.test(T)})}else{var S=this.files[this.root+g];return S&&!S.dir?S:null}else g=this.root+g,d.call(this,g,p,y);return this},folder:function(g){if(!g)return this;if(m(g))return this.filter(function(S,T){return T.dir&&g.test(S)});var p=this.root+g,y=f.call(this,p),x=this.clone();return x.root=y.name,x},remove:function(g){g=this.root+g;var p=this.files[g];if(p||(g.slice(-1)!=="/"&&(g+="/"),p=this.files[g]),p&&!p.dir)delete this.files[g];else for(var y=this.filter(function(S,T){return T.name.slice(0,g.length)===g}),x=0;x<y.length;x++)delete this.files[y[x].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(g){var p,y={};try{if(y=e.extend(g||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode}),y.type=y.type.toLowerCase(),y.compression=y.compression.toUpperCase(),y.type==="binarystring"&&(y.type="string"),!y.type)throw new Error("No output type specified.");e.checkSupport(y.type),(y.platform==="darwin"||y.platform==="freebsd"||y.platform==="linux"||y.platform==="sunos")&&(y.platform="UNIX"),y.platform==="win32"&&(y.platform="DOS");var x=y.comment||this.comment||"";p=o.generateWorker(this,y,x)}catch(S){p=new t("error"),p.error(S)}return new i(p,y.type||"string",y.mimeType)},generateAsync:function(g,p){return this.generateInternalStream(g).accumulate(p)},generateNodeStream:function(g,p){return g=g||{},g.type||(g.type="nodebuffer"),this.generateInternalStream(g).toNodejsStream(p)}};return zu=v,zu}var Vu,Um;function T0(){if(Um)return Vu;Um=1;var n=jt();function e(t){this.data=t,this.length=t.length,this.index=0,this.zero=0}return e.prototype={checkOffset:function(t){this.checkIndex(this.index+t)},checkIndex:function(t){if(this.length<this.zero+t||t<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+t+"). Corrupted zip ?")},setIndex:function(t){this.checkIndex(t),this.index=t},skip:function(t){this.setIndex(this.index+t)},byteAt:function(){},readInt:function(t){var i=0,r;for(this.checkOffset(t),r=this.index+t-1;r>=this.index;r--)i=(i<<8)+this.byteAt(r);return this.index+=t,i},readString:function(t){return n.transformTo("string",this.readData(t))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC((t>>25&127)+1980,(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(t&31)<<1))}},Vu=e,Vu}var Hu,Fm;function A0(){if(Fm)return Hu;Fm=1;var n=T0(),e=jt();function t(i){n.call(this,i);for(var r=0;r<this.data.length;r++)i[r]=i[r]&255}return e.inherits(t,n),t.prototype.byteAt=function(i){return this.data[this.zero+i]},t.prototype.lastIndexOfSignature=function(i){for(var r=i.charCodeAt(0),s=i.charCodeAt(1),a=i.charCodeAt(2),o=i.charCodeAt(3),l=this.length-4;l>=0;--l)if(this.data[l]===r&&this.data[l+1]===s&&this.data[l+2]===a&&this.data[l+3]===o)return l-this.zero;return-1},t.prototype.readAndCheckSignature=function(i){var r=i.charCodeAt(0),s=i.charCodeAt(1),a=i.charCodeAt(2),o=i.charCodeAt(3),l=this.readData(4);return r===l[0]&&s===l[1]&&a===l[2]&&o===l[3]},t.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var r=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,r},Hu=t,Hu}var Wu,Bm;function SM(){if(Bm)return Wu;Bm=1;var n=T0(),e=jt();function t(i){n.call(this,i)}return e.inherits(t,n),t.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},t.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},t.prototype.readAndCheckSignature=function(i){var r=this.readData(4);return i===r},t.prototype.readData=function(i){this.checkOffset(i);var r=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,r},Wu=t,Wu}var Gu,zm;function R0(){if(zm)return Gu;zm=1;var n=A0(),e=jt();function t(i){n.call(this,i)}return e.inherits(t,n),t.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var r=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,r},Gu=t,Gu}var ju,Vm;function bM(){if(Vm)return ju;Vm=1;var n=R0(),e=jt();function t(i){n.call(this,i)}return e.inherits(t,n),t.prototype.readData=function(i){this.checkOffset(i);var r=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,r},ju=t,ju}var $u,Hm;function C0(){if(Hm)return $u;Hm=1;var n=jt(),e=Sr(),t=A0(),i=SM(),r=bM(),s=R0();return $u=function(a){var o=n.getTypeOf(a);return n.checkSupport(o),o==="string"&&!e.uint8array?new i(a):o==="nodebuffer"?new r(a):e.uint8array?new s(n.transformTo("uint8array",a)):new t(n.transformTo("array",a))},$u}var Xu,Wm;function wM(){if(Wm)return Xu;Wm=1;var n=C0(),e=jt(),t=Ef(),i=Mf(),r=Uo(),s=M0(),a=Sr(),o=0,l=3,c=function(h){for(var u in s)if(Object.prototype.hasOwnProperty.call(s,u)&&s[u].magic===h)return s[u];return null};function d(h,u){this.options=h,this.loadOptions=u}return d.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(h){var u,f;if(h.skip(22),this.fileNameLength=h.readInt(2),f=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(u=c(this.compressionMethod),u===null)throw new Error("Corrupted zip : compression "+e.pretty(this.compressionMethod)+" unknown (inner file : "+e.transformTo("string",this.fileName)+")");this.decompressed=new t(this.compressedSize,this.uncompressedSize,this.crc32,u,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var u=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(u),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),h===o&&(this.dosPermissions=this.externalFileAttributes&63),h===l&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=n(this.extraFields[1].value);this.uncompressedSize===e.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===e.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===e.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===e.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var u=h.index+this.extraFieldsLength,f,m,v;for(this.extraFields||(this.extraFields={});h.index+4<u;)f=h.readInt(2),m=h.readInt(2),v=h.readData(m),this.extraFields[f]={id:f,length:m,value:v};h.setIndex(u)},handleUTF8:function(){var h=a.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=r.utf8decode(this.fileName),this.fileCommentStr=r.utf8decode(this.fileComment);else{var u=this.findExtraFieldUnicodePath();if(u!==null)this.fileNameStr=u;else{var f=e.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var v=e.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var u=n(h.value);return u.readInt(1)!==1||i(this.fileName)!==u.readInt(4)?null:r.utf8decode(u.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var u=n(h.value);return u.readInt(1)!==1||i(this.fileComment)!==u.readInt(4)?null:r.utf8decode(u.readData(h.length-5))}return null}},Xu=d,Xu}var qu,Gm;function MM(){if(Gm)return qu;Gm=1;var n=C0(),e=jt(),t=E0(),i=wM(),r=Sr();function s(a){this.files=[],this.loadOptions=a}return s.prototype={checkSignature:function(a){if(!this.reader.readAndCheckSignature(a)){this.reader.index-=4;var o=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+e.pretty(o)+", expected "+e.pretty(a)+")")}},isSignature:function(a,o){var l=this.reader.index;this.reader.setIndex(a);var c=this.reader.readString(4),d=c===o;return this.reader.setIndex(l),d},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var a=this.reader.readData(this.zipCommentLength),o=r.uint8array?"uint8array":"array",l=e.transformTo(o,a);this.zipComment=this.loadOptions.decodeFileName(l)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a=this.zip64EndOfCentralSize-44,o=0,l,c,d;o<a;)l=this.reader.readInt(2),c=this.reader.readInt(4),d=this.reader.readData(c),this.zip64ExtensibleData[l]={id:l,length:c,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,o;for(a=0;a<this.files.length;a++)o=this.files[a],this.reader.setIndex(o.localHeaderOffset),this.checkSignature(t.LOCAL_FILE_HEADER),o.readLocalPart(this.reader),o.handleUTF8(),o.processAttributes()},readCentralDir:function(){var a;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(t.CENTRAL_FILE_HEADER);)a=new i({zip64:this.zip64},this.loadOptions),a.readCentralPart(this.reader),this.files.push(a);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var a=this.reader.lastIndexOfSignature(t.CENTRAL_DIRECTORY_END);if(a<0){var o=!this.isSignature(0,t.LOCAL_FILE_HEADER);throw o?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(a);var l=a;if(this.checkSignature(t.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===e.MAX_VALUE_16BITS||this.diskWithCentralDirStart===e.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===e.MAX_VALUE_16BITS||this.centralDirRecords===e.MAX_VALUE_16BITS||this.centralDirSize===e.MAX_VALUE_32BITS||this.centralDirOffset===e.MAX_VALUE_32BITS){if(this.zip64=!0,a=this.reader.lastIndexOfSignature(t.ZIP64_CENTRAL_DIRECTORY_LOCATOR),a<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(a),this.checkSignature(t.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,t.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(t.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(t.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var c=this.centralDirOffset+this.centralDirSize;this.zip64&&(c+=20,c+=12+this.zip64EndOfCentralSize);var d=l-c;if(d>0)this.isSignature(l,t.CENTRAL_FILE_HEADER)||(this.reader.zero=d);else if(d<0)throw new Error("Corrupted zip: missing "+Math.abs(d)+" bytes.")},prepareReader:function(a){this.reader=n(a)},load:function(a){this.prepareReader(a),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},qu=s,qu}var Yu,jm;function EM(){if(jm)return Yu;jm=1;var n=jt(),e=ko(),t=Uo(),i=MM(),r=v0(),s=Lc();function a(o){return new e.Promise(function(l,c){var d=o.decompressed.getContentWorker().pipe(new r);d.on("error",function(h){c(h)}).on("end",function(){d.streamInfo.crc32!==o.decompressed.crc32?c(new Error("Corrupted zip : CRC32 mismatch")):l()}).resume()})}return Yu=function(o,l){var c=this;return l=n.extend(l||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:t.utf8decode}),s.isNode&&s.isStream(o)?e.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",o,!0,l.optimizedBinaryString,l.base64).then(function(d){var h=new i(l);return h.load(d),h}).then(function(h){var u=[e.Promise.resolve(h)],f=h.files;if(l.checkCRC32)for(var m=0;m<f.length;m++)u.push(a(f[m]));return e.Promise.all(u)}).then(function(h){for(var u=h.shift(),f=u.files,m=0;m<f.length;m++){var v=f[m],g=v.fileNameStr,p=n.resolve(v.fileNameStr);c.file(p,v.decompressed,{binary:!0,optimizedBinaryString:!0,date:v.date,dir:v.dir,comment:v.fileCommentStr.length?v.fileCommentStr:null,unixPermissions:v.unixPermissions,dosPermissions:v.dosPermissions,createFolders:l.createFolders}),v.dir||(c.file(p).unsafeOriginalName=g)}return u.zipComment.length&&(c.comment=u.zipComment),c})},Yu}var Zu,$m;function TM(){if($m)return Zu;$m=1;function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new n;for(var t in this)typeof this[t]!="function"&&(e[t]=this[t]);return e}}return n.prototype=xM(),n.prototype.loadAsync=EM(),n.support=Sr(),n.defaults=g0(),n.version="3.10.1",n.loadAsync=function(e,t){return new n().loadAsync(e,t)},n.external=ko(),Zu=n,Zu}TM();function Xm(n,e){const t=/\.([a-z0-9]+)$/i.exec(n);if(t)return t[1].toLowerCase();if(e){const i={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","model/gltf-binary":"glb"};if(i[e])return i[e];const r=e.split("/")[1];if(r)return r.replace(/[^a-z0-9]/gi,"")}return""}const AM={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!0},RM="http://127.0.0.1:8787";function CM(n=AM){return n.MODE==="development"?n.VITE_FLASHSTORY_SERVER??RM:""}const PM=/\{\{([#^])([a-zA-Z][\w]*)\}\}((?:(?!\{\{[#^])[\s\S])*?)\{\{\/\2\}\}/g,IM=/\{\{([a-zA-Z][\w]*)\}\}/g,LM=8;function P0(n,e){const t=new Set,i=a=>Object.prototype.hasOwnProperty.call(e,a)?!0:(t.add(a),!1);let r=n;for(let a=0;a<LM;a+=1){const o=r.replace(PM,(l,c,d,h)=>{const u=i(d)&&e[d].trim()!=="";return c==="#"===u?h:""});if(o===r)break;r=o}const s=r.replace(IM,(a,o)=>i(o)?e[o]:"");return{text:DM(s),unknownVariables:[...t]}}function DM(n){return`${n.replace(/[ \t]+$/gm,"").replace(/\n{3,}/g,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flash-story-app",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "FlashStory — one npx command runs the whole shot-editor (B/S, WEB.md). Local-first: data lives under ~/.flashstory/data.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",