1import{Pa as It,Va as gi,da as Ge,f as ze,ib as vi,mb as Je,na as Et,nb as _i,w as At,x as Ct}from"./chunk-JCVPIXVC.js";import{a as g,b as F}from"./chunk-TTLSD7JL.js";var cr=class{#e=new Map;on(e,t){return this.#e.has(e)||this.#e.set(e,new Set),this.#e.get(e).add(t),()=>{this.#e.get(e)?.delete(t)}}off(e,t){this.#e.get(e)?.delete(t)}emit(e,...t){let i=this.#e.get(e);if(i)for(let s of[...i])try{s(...t)}catch(r){console.warn("[TypedEmitter] listener error:",r)}}clear(){this.#e.clear()}};function yi(e,t){let s=(t+e).split(` 2`),r=s.pop()??"",n=[],a=0;for(let o of s){if(!o.startsWith("data: "))continue;let h=o.slice(6);if(h.trim())try{n.push(JSON.parse(h))}catch(l){a++;let p=h.length>80?h.slice(0,80)+"...":h;console.warn(`[SSE] JSON parse error: ${l.message} \u2014 data: ${p}`)}}return a>3&&console.error(`[SSE] ${a} parse errors in single chunk \u2014 connection may be corrupted`),{events:n,remaining:r,parseErrors:a}}var hr={maxRetries:1/0,baseDelayMs:1e3,maxDelayMs:1e4};function lr(e){let t=e?.status;return typeof t=="number"&&t>=400?!0:e instanceof Error&&e.message.startsWith("HTTP ")}function ur(e,t){let i=g(g({},hr),t),s=null,r=null,n=null,a=!1,o=!1,h=0;function l(){a=!0,r?.abort(),r=null,n?.(),n=null,s?.abort()}let p=m=>Math.min(i.baseDelayMs*2**(m-1),i.maxDelayMs),u=m=>new Promise(y=>{let A=setTimeout(()=>{n=null,y()},m);n=()=>{clearTimeout(A),y()}});return{reader:new ReadableStream({async pull(m){for(;!a;)try{if(!s){r=new AbortController;let b=await e(r.signal);if(r=null,a){b.abort(),m.close();return}if(s=b,h>0||o){let w=o;o=!1,i.onReconnected?.({voluntary:w})}}let{done:y,value:A}=await s.reader.read();if(y){if(s?.abort(),s=null,o){h=0;continue}if(h++,h>i.maxRetries){let w=new Error("Stream closed (reconnect budget exhausted)");i.onGiveUp?.(w),m.error(w);return}let b=p(h);i.onRetry?.(h,b),await u(b);continue}h=0,m.enqueue(A);return}catch(y){if(a){m.close();return}if(s?.abort(),s=null,o){h=0;continue}if(lr(y)){i.onGiveUp?.(y instanceof Error?y:new Error(String(y))),m.error(y);return}if(h++,h>i.maxRetries){i.onGiveUp?.(y instanceof Error?y:new Error(String(y))),m.error(y);return}let A=p(h);i.onRetry?.(h,A),await u(A)}m.close()},cancel(){l()}}).getReader(),abort(){l()},requestReconnect(){a||o||(o=!0,n?.(),s?.abort())}}}function nt(e,t){if(e===t||typeof e=="number"&&typeof t=="number"&&Number.isNaN(e)&&Number.isNaN(t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;let i=Array.isArray(e),s=Array.isArray(t);if(i!==s)return!1;if(i){let a=e,o=t;if(a.length!==o.length)return!1;for(let h=0;h<a.length;h++)if(!nt(a[h],o[h]))return!1;return!0}let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let a of r)if(!Object.prototype.hasOwnProperty.call(t,a)||!nt(e[a],t[a]))return!1;return!0}var pr=new Set(["derived"]);function ie(e){return e.startsWith("_")||pr.has(e)||/Action$/.test(e)}function Mt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!ie(t)))}var wi=class{#e;#t=new Map;#i;#a;#r=0;constructor(e,t={}){this.#e=e,this.#i=t.pendingTtlMs??5e3,this.#a=t.canonicalCompare??nt}patch(e){if(this.#r>0){this.#e.patch(e);return}this.#r++;try{let t=Date.now();for(let[i,s]of Object.entries(e))this.#t.set(i,{raw:s,sentAt:t});this.#e.patch(e)}finally{this.#r--}}patchInitial(e){for(let t of Object.keys(e))this.#t.delete(t);if(this.#r>0){this.#e.patch(e);return}this.#r++;try{this.#e.patch(e)}finally{this.#r--}}applyRemote(e,t,i){if(!e)return!1;this.#r++;try{let s=Date.now();this.#s(s);let r={};for(let[n,a]of Object.entries(e)){if(ie(n)||Ge(ze(n)))continue;let o=this.#t.get(n);if(o)if(this.#a(a,o.raw))this.#t.delete(n),r[n]=a;else continue;else r[n]=a}if(t==="replace"){let n=this.#e.snapshot(),a={};for(let h of Object.keys(n))ie(h)||this.#t.has(h)||h in r||(a[h]=void 0);let o=g(g({},a),r);return Object.keys(o).length===0?!1:(this.#e.patch(o),!0)}else return Object.keys(r).length===0?!1:(this.#e.patch(r),!0)}finally{this.#r--}}clearPending(){this.#t.clear()}markPendingWriteback(e,t){}clearPendingWriteback(){}init(e){for(let t of Object.keys(e))this.#t.delete(t);this.#e.init(e)}get isSplitMode(){return this.#e.isSplitMode}get(e){return this.#e.get(e)}getKeySignalForRead(e){return this.#e.getKeySignalForRead(e)}entries(){return this.#e.entries()}
2snapshot(){return this.#e.snapshot()}autosaveSnapshot(){return this.#e.snapshot()}subscribe(e){return this.#e.subscribe(e)}emit(e,t){this.#e.emit(e,t)}on(e,t){return this.#e.on(e,t)}destroy(){this.#t.clear(),this.#e.destroy()}__pendingSizeForTests(){return this.#t.size}#s(e){for(let[t,i]of this.#t)e-i.sentAt>this.#i&&this.#t.delete(t)}},Si=class{#e;#t={};#i=[];#a=new Map;#r=new Map;#s=1e4;constructor(e){if(!e.isSplitMode||!e.patchServer||!e.patchClient||!e.replaceServer)throw new Error("SplitModeReconciler requires a split-mode GameStore");this.#e=e}get isSplitMode(){return!0}patch(e){this.#e.patchClient(e)}patchInitial(e){let t={},i={};for(let[s,r]of Object.entries(e))ie(s)?t[s]=r:i[s]=r;Object.keys(i).length>0&&this.#e.patchServer(i),Object.keys(t).length>0&&this.#e.patchClient(t),Object.assign(this.#t,i)}init(e){let t={},i={};for(let[s,r]of Object.entries(e))ie(s)?t[s]=r:i[s]=r;Object.keys(i).length>0&&this.#e.patchServer(i),Object.keys(t).length>0&&this.#e.patchClient(t),Object.assign(this.#t,i)}markPendingWriteback(e,t=2e3){let i={keys:new Set(e),expiresAt:Date.now()+t};return this.#i.push(i),i}removeEnvelope(e){let t=this.#i.indexOf(e);t>=0&&this.#i.splice(t,1)}clearPendingWriteback(){this.#i.length=0}applyRemote(e,t,i){if(!e)return!1;let s={};for(let[n,a]of Object.entries(e))ie(n)||Ge(ze(n))||(s[n]=a);if(i==="remote"&&this.#i.length>0){let n=Date.now();for(;this.#i.length>0&&this.#i[0].expiresAt<n;)this.#i.shift();if(this.#i.length>0){let a=this.#i[0],o=!1;for(let h of a.keys)if(Object.prototype.hasOwnProperty.call(s,h)){o=!0;break}if(o){this.#i.shift();let h=a.keys,l={};for(let p of Object.keys(s))h.has(p)&&(l[p]=s[p]);for(let p of Object.keys(s))delete s[p];Object.assign(s,l)}}}if(t==="replace")return this.#e.replaceServer(s),this.#t=g({},s),this.#o(Object.keys(s)),!0;let r={};for(let[n,a]of Object.entries(s))nt(a,this.#t[n])||(r[n]=a);if(Object.keys(r).length===0)return this.#o(Object.keys(s)),!1;this.#e.patchServer(r);for(let[n,a]of Object.entries(r))this.#t[n]=a;return this.#o(Object.keys(s)),!0}#o(e){for(let t of e){let i=this.#a.get(t);if(i!==void 0)clearTimeout(i),this.#a.delete(t),this.#e.unsetClient(t);else{let s=this.#r.get(t);s!==void 0&&clearTimeout(s);let r=setTimeout(()=>this.#r.delete(t),this.#s);this.#r.set(t,r)}}}clearPending(){this.#i.length=0;for(let e of this.#a.values())clearTimeout(e);this.#a.clear();for(let e of this.#r.values())clearTimeout(e);this.#r.clear()}get(e){return this.#e.get(e)}getKeySignalForRead(e){return this.#e.getKeySignalForRead(e)}entries(){return this.#e.entries()}snapshot(){return this.#e.snapshot()}autosaveSnapshot(){let e=this.#e.clientSnapshot?.()??{};return Object.freeze(g(g({},this.#t),e))}subscribe(e){return this.#e.subscribe(e)}emit(e,t){this.#e.emit(e,t)}on(e,t){return this.#e.on(e,t)}destroy(){this.#e.destroy()}patchServer(e){this.#e.patchServer(e),Object.assign(this.#t,e)}patchClient(e){this.#e.patchClient(e)}unsetClient(e){this.#e.unsetClient(e)}unsetClientOnAck(e){let t=e,i=this.#r.get(t);if(i!==void 0){clearTimeout(i),this.#r.delete(t),this.#e.unsetClient(t);return}let s=this.#a.get(e);s&&clearTimeout(s);let r=setTimeout(()=>{this.#a.delete(e)&&this.#e.unsetClient(e)},5e3);this.#a.set(e,r)}unsetServer(e){this.#e.unsetServer(e),delete this.#t[e]}replaceServer(e){this.#e.replaceServer(e),this.#t=g({},e)}getServer(e){return this.#e.getServer(e)}getClient(e){return this.#e.getClient(e)}hasClient(e){return this.#e.hasClient(e)}hasServer(e){return this.#e.hasServer(e)}serverKeys(){return this.#e.serverKeys()}__pendingSizeForTests(){return this.#i.length+this.#a.size}__pendingEnvelopeCountForTests(){return this.#i.length}},fr=class{#e="connecting";#t=0;#i=new Set;get state(){return this.#e}get generation(){return this.#t}armGeneration(){return this.#t+=1,this.#t}markConnecting(){this.#a("connecting")}markValidEvent(e){e===this.#t&&(this.#e==="connecting"||this.#e==="reconnecting"||this.#e==="degraded")&&this.#a("connected")}markReconnecting(e){e===this.#t&&this.#e!=="dead"&&this.#a("reconnecting")}markDegraded(e){e===this.#t&&this.#e==="connected"&&this.#a("degraded")}markChunkReceived(e){e===this.#t&&this.#e==="degraded"&&this.#a("connected")}markDead(){this.#a("dead")}
2onChange(e){return this.#i.add(e),()=>{this.#i.delete(e)}}#a(e){if(e!==this.#e){this.#e=e;for(let t of[...this.#i])try{t(e)}catch(i){console.warn("[ConnectionStateMachine] listener error:",i)}}}},dr=6e3,mr=Math.ceil(6e4/dr),gr=40,vr=Math.ceil(6e4/gr);function _r(e){return e==="public-respond"?"public-respond":"ui-event"}function yr(e){return e==="public-respond"?vr:mr}var Qe=new Set(["accepted","acked","timed-out","failed","canceled"]),wr=class{#e=[];#t=0;#i=new Map;#a=!1;#r=null;#s=null;#o=!1;onDispatchError;onDeadRun;onAckTimeout;onAckRecovered;get size(){return this.#e.length}get pendingPromiseCount(){return this.#n.size}enqueue(e){if(e.dedupKey!==void 0){let n=this.#e.findIndex(a=>a.dedupKey===e.dedupKey&&a.lifecycle==="queued");if(n>=0&&!this.#e.slice(n+1).some(o=>o.lifecycle==="queued"&&o.dedupKey===void 0)){let o=this.#e[n];return o.dispatch=e.dispatch,o.dedupPayload=e.dedupPayload,o.ackExpectation=e.ackExpectation,o.retryPolicy=e.retryPolicy,o.notFoundPolicy=e.notFoundPolicy,o.supersedes=e.supersedes,o.kind=e.kind,o.generation=e.generation,{id:o.id,promise:this.#R(o)}}}let t=e.id??`op-${++this.#t}`,i,s=new Promise(n=>{i=n}),r=F(g({},e),{id:t,lifecycle:"queued",settle:i});return this.#n.set(r.id,s),this.#e.push(r),this.#S(),{id:t,promise:s}}setPaused(e){this.#o=e,e||this.#S()}supersede(e){let t=this.#e.find(i=>i.id===e);!t||Qe.has(t.lifecycle)||this.#w(t,"canceled")}clear(e){for(let t of[...this.#e]){let i=t.lifecycle==="accepted"&&t.ackTimer!==void 0;(!Qe.has(t.lifecycle)||i)&&this.#w(t,e)}this.#g.clear(),this.#O(),this.#l!==null&&(clearTimeout(this.#l),this.#l=null,this.#y=!1)}notifyStateKeySeen(e,t,i){for(let r of[...this.#e]){let n=r.ackExpectation;!n||n.expectStateKey!==e||"expectValue"in n&&n.expectValue!==void 0&&n.expectValue!==t||i!==void 0&&r.generation!==void 0&&r.generation!==i||(r.lifecycle==="accepted"?(r.ackTimer!==void 0&&(clearTimeout(r.ackTimer),r.ackTimer=void 0),this.#w(r,"acked")):r.lifecycle==="dispatched"&&(r.ackObserved=!0))}let s=this.#g.get(e);if(s){let r=[];for(let n of s){let a=n.ackExpectation,o=a&&"expectValue"in a&&a.expectValue!==void 0&&a.expectValue!==t;if(!(i!==void 0&&n.generation!==void 0&&n.generation!==i)){if(o){r.push(n);continue}this.onAckRecovered?.(n)}}r.length>0?this.#g.set(e,r):this.#g.delete(e)}}snapshot(){return this.#e.map(e=>({id:e.id,kind:e.kind,lifecycle:e.lifecycle,dedupKey:e.dedupKey}))}snapshotFull(){return this.#e.map(e=>({id:e.id,kind:e.kind,lifecycle:e.lifecycle,dedupKey:e.dedupKey,ackExpectation:e.ackExpectation,retryPolicy:e.retryPolicy,notFoundPolicy:e.notFoundPolicy}))}#n=new Map;#g=new Map;#R(e){return this.#n.get(e.id)}#w(e,t,i){if(e.ackTimer!==void 0&&(clearTimeout(e.ackTimer),e.ackTimer=void 0),t==="timed-out"&&e.ackExpectation){let r=e.ackExpectation.expectStateKey,n=this.#g.get(r)??[];n.push(g({},e)),this.#g.set(r,n)}e.lifecycle=t;let s=this.#e.indexOf(e);s>=0&&this.#e.splice(s,1),this.#n.delete(e.id),e.settle({id:e.id,lifecycle:t,error:i})}#S(){this.#a||this.#o||this.#y||(this.#y=!0,this.#l=setTimeout(()=>{this.#l=null,this.#y=!1,this.#d()},0))}#y=!1;#l=null;async#d(){if(!this.#a){this.#a=!0;try{for(;!this.#o;){let e=this.#e.find(n=>n.lifecycle==="queued");if(!e)break;let t=_r(e.kind),i=yr(t),s=this.#i.get(t),r=s===void 0?0:s+i-Date.now();r>0&&(await this.#h(r),this.#o||e.lifecycle!=="queued")||(this.#i.set(t,Date.now()),await this.#C(e))}}finally{this.#a=!1}}}async#C(e){e.lifecycle="dispatched";try{if(await e.dispatch(),Qe.has(e.lifecycle))return;if(e.lifecycle="accepted",e.ackExpectation===void 0)this.#w(e,"accepted");else if(e.ackObserved)e.ackObserved=void 0,this.#w(e,"acked");else{let t=e.ackExpectation;e.ackTimer=setTimeout(()=>{e.ackTimer=void 0,e.lifecycle==="accepted"&&(this.#w(e,"timed-out"),this.onAckTimeout?.(e))},t.timeoutMs)}}catch(t){if(Qe.has(e.lifecycle))return;let i=t instanceof Error?t:new Error(String(t));this.#k(e,i)}}#k(e,t){this.#w(e,"failed",t),this.onDispatchError?.(e,t)}#h(e){return new Promise(t=>{let i=()=>{this.#r=null,this.#s=null,t()};this.#s=i,this.#r=setTimeout(i,e)})}#O(){this.#r!==null&&(clearTimeout(this.#r),this.#r=null);let e=this.#s;this.#s=null,e?.()}};function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function me(e){return typeof e=="string"&&e.length>0}function Sr(e){if(!De(e))return{valid:!1,reason:"unrecognized event shape"};let t=e.eventType,i=e.type,s=e.kind;return s==="logic_state_sync"||s==="logic_state_version"?!me(e.logicSessionId)||!me(e.definitionRef)||!Number.isSafeInteger(e.lifecycleEpoch)||!me(e.serverStorageVersion)?{val
2id:!1,reason:`${s}: invalid identity/version`}:s==="logic_state_sync"&&(!me(e.previousServerStorageVersion)||!De(e.updates)||!Array.isArray(e.removedKeys)||!e.removedKeys.every(r=>typeof r=="string"))?{valid:!1,reason:"logic_state_sync: invalid patch"}:{valid:!0}:t==="init"?me(e.runId)?{valid:!0}:{valid:!1,reason:"init: missing runId"}:t==="step"?{valid:!0}:i==="ui:screen:init"?me(e.screenId)?{valid:!0}:{valid:!1,reason:"ui:screen:init: missing screenId"}:i==="ui:waiting"||i==="ui:screen:ready"?me(e.eventKey)?{valid:!0}:{valid:!1,reason:`${i}: missing eventKey`}:i==="ui:state:sync"?De(e.gameState)?{valid:!0}:{valid:!1,reason:"ui:state:sync: missing gameState"}:i==="chat_workflow_storage_updated"?!De(e.gameState)&&!De(e.storageData)?{valid:!1,reason:"chat_workflow_storage_updated: missing gameState/storageData"}:{valid:!0}:t==="game"?typeof i!="string"?{valid:!1,reason:"game: missing type"}:{valid:!0}:i!==void 0&&typeof i!="string"?{valid:!1,reason:"event: non-string type"}:typeof i=="string"||typeof t=="string"?{valid:!0}:{valid:!1,reason:"unrecognized event shape"}}var br=256*1024;function Fa(e,t,i={}){let s=t?xr(e,t):kr(e);return typeof process<"u"&&typeof process.env<"u",s}function xr(e,t){let i={};for(let[s,r]of Object.entries(t)){let a=(r.scope==="clientOnly"?e.getClient(s):e.getServer(s)).peek();a!==void 0&&(i[s]=a)}for(let s of e.serverKeys()){if(s.startsWith("_modal_")||ie(s)||s in i)continue;let r=e.getServer(s).peek();r!==void 0&&(i[s]=r)}for(let s of e.entries().keys()){if(!s.startsWith("_modal_")||s in i||!e.hasClient(s))continue;let r=e.getClient(s).peek();r!==void 0&&(i[s]=r)}return i}function kr(e){return Mt(e.snapshot())}function Ar(e,t){let i;try{i=JSON.stringify(e)}catch{return}let s=new TextEncoder().encode(i).byteLength;if(s>br){let n=`Autosave envelope exceeds 256KB backend cap (${(s/1024).toFixed(1)}KB). POST will be rejected with HTTP 400.`;console.error("[autosave-snapshot]",n),t&&t({kind:"shape-mismatch",message:n})}}var Cr=class{#e;#t=Number.NEGATIVE_INFINITY;#i=null;#a="";#r=!1;constructor(e){this.#e=e}markDirty(){this.#r=!0,this.scheduleFlush()}onBridgeEcho(){this.#r&&this.scheduleFlush()}acknowledgeCanonical(){this.#r=!1,this.#a=""}scheduleFlush(){let e=this.#e.now()-this.#t;e>=this.#e.windowMs?this.flushNow():this.#i||(this.#i=setTimeout(()=>{this.#i=null,this.flushNow()},this.#e.windowMs-e))}flushNow(){if(!this.#r)return;if(this.#e.hasPendingOps()){this.#o();return}if(this.#e.now()-this.#t<this.#e.windowMs){this.scheduleFlush();return}this.#s();let e=this.#e.getSnapshot();if(Object.keys(e).length===0&&!this.#e.persistEmptySnapshot){this.#r=!1;return}let t={[this.#e.storageName]:e};if(this.#n(t))return;let i=JSON.stringify(e);if(i===this.#a){this.#r=!1;return}this.#t=this.#e.now(),this.#a=i,this.#r=!1;let s=this.#e.getSaveStateOptions?.()??this.#e.saveStateOptions,r=this.#e.capturePostContext?.(e),n=this.#e.post(t,s,r);if(n===void 0){this.#e.onError?.(new Error("[AutosaveManager] post() returned undefined \u2014 transport has no saveState; autosave is inert"));return}n.catch(a=>{this.#a="",this.#r=!0,this.#e.onError?.(a,r)})}flushBeacon(){if(!this.#e.beacon||!this.#r||this.#e.hasPendingOps()||this.#e.now()-this.#t<this.#e.windowMs)return;let e=this.#e.getSnapshot();if(Object.keys(e).length===0&&!this.#e.persistEmptySnapshot)return;let t={[this.#e.storageName]:e};if(!this.#n(t))try{let i=this.#e.getSaveStateOptions?.()??this.#e.saveStateOptions;this.#e.beacon(t,i)}catch(i){this.#e.onError?.(i)}}destroy(){this.#s()}#s(){this.#i&&(clearTimeout(this.#i),this.#i=null)}#o(){this.#i||(this.#i=setTimeout(()=>{this.#i=null,this.#r&&this.scheduleFlush()},this.#e.windowMs))}#n(e){let t=!1;return Ar(e,s=>{s.kind==="shape-mismatch"&&s.message.includes("256KB")&&(t=!0),this.#e.onError?.(s)}),t}},Er="Default Storage",f=class extends TypeError{code;path;constructor(e,t,i){super(t),this.name="LogicContractError",this.code=e,this.path=i}},x=Object.freeze({version:1,maxActiveRootNodes:128,maxNodeSourceUtf8Bytes:32*1024,maxClosureSourceUtf8Bytes:512*1024,maxNameCharacters:120,maxDescriptionCharacters:1e3,maxListens:64,maxEmits:64,maxReads:128,maxWrites:128,maxEventTypeCharacters:128,maxStatePathCharacters:256,maxStatePathSegments:16,maxJsonDepth:32,maxAstNodes:4096,maxAstNesting:64,workerReadyTimeoutMs:5e3,maxSessionStartMessageUtf8Bytes:2*1024*1024,maxWorkerMessageUtf8Bytes:512*1024,maxSeenMessageIds:4096,workerResultForegroundDeadlineMs:250,deadlineDeliveryGraceMs:100,resumeGraceMs:1e3,maxHandlerResultUtf8Bytes:128*1024,maxEventPayloadUtf8Bytes:64*1024,maxEmittedEventsPerHandler:64,maxScheduledEventsPerHandler:32,maxEventsPerCausalRoot:1e3,maxAggregateQueuedEvents:1024,maxScheduleDelayMs:864e5,maxPendingSchedules:256,writebackTimeoutMs:3e4,canonicalVersionHeartbeatMs:3e4,maxAutosavePayloadUtf8Bytes:256*1024}),Ir=64,Rr=1e5,Or=16*1024*1024,Pr=new Set(["__proto__","prototype","constructor"]),ti=new TextEncoder;function Fr(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function jt(e,t,i){let s=Object.getOwnPropertyDescriptor(e,t);if(!s||!("value"in s)||!s.enumerable)throw new TypeError(`${i} must be an enumerable JSON data property`);return s}function $t(e,t,i,s,r){if(s.nodes+=1,s.nodes>Rr)throw new TypeError(`${t} exceeds the canonical JSON node limit`);if(r>Ir)throw new TypeError(`${t} exceeds the canonical JSON depth limit`);if(e===null)return null;if(typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError(`${t} contains a non-finite number`);return e}if(typeof e!="object")throw new TypeError(`${t} contains a non-JSON ${Fr(e)} value`);if(i.has(e))throw new TypeError(`${t} contains a circular reference`);if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError(`${t} contains symbol-keyed data`);i.add(e);try{if(Array.isArray(e)){let a=Object.getOwnPropertyNames(e),o=new Set(["length"]),h=[];for(let l=0;l<e.length;l+=1){let p=String(l);if(o.add(p),!Object.prototype.hasOwnProperty.call(e,p))throw new TypeError(`${t}[${l}] is a sparse array entry`);let u=jt(e,p,`${t}[${l}]`);h.push($t(u.value,`${t}[${l}]`,i,s,r+1))}if(a.some(l=>!o.has(l)))throw new TypeError(`${t}
2 contains non-index array properties`);return h}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new TypeError(`${t} must contain only plain JSON objects`);return Object.fromEntries(Object.getOwnPropertyNames(e).sort().map(a=>{let o=jt(e,a,`${t}.${a}`);return[a,$t(o.value,`${t}.${a}`,i,s,r+1)]}))}finally{i.delete(e)}}function $e(e){let t=JSON.stringify($t(e,"$",new Set,{nodes:0},0));if(ti.encode(t).byteLength>Or)throw new TypeError("$ exceeds the canonical JSON byte limit");return t}function Ce(e){return ti.encode($e(e))}function Tr(e){return ti.encode(e).byteLength}function qt(e,t,i,s){if(s>x.maxJsonDepth)throw new f("logic_result_invalid",`${t} exceeds JSON depth`,t);if(e===null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new f("logic_result_invalid",`${t} is not finite`,t);return e}if(typeof e!="object")throw new f("logic_result_invalid",`${t} is not JSON`,t);if(i.has(e))throw new f("logic_result_invalid",`${t} is circular`,t);if(Object.getOwnPropertySymbols(e).length>0)throw new f("logic_result_invalid",`${t} has symbol keys`,t);i.add(e);try{if(Array.isArray(e)){let a=[];for(let o=0;o<e.length;o+=1){if(!Object.prototype.hasOwnProperty.call(e,o))throw new f("logic_result_invalid",`${t} is sparse`,t);a.push(qt(e[o],`${t}[${o}]`,i,s+1))}if(Object.getOwnPropertyNames(e).some(o=>o!=="length"&&!/^\d+$/.test(o)))throw new f("logic_result_invalid",`${t} has array properties`,t);return a}let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new f("logic_result_invalid",`${t} is not a plain object`,t);let n=Object.create(null);for(let a of Object.getOwnPropertyNames(e)){if(Pr.has(a))throw new f("logic_result_invalid",`${t}.${a} is forbidden`,t);let o=jt(e,a,`${t}.${a}`);n[a]=qt(o.value,`${t}.${a}`,i,s+1)}return n}finally{i.delete(e)}}function T(e,t="$"){return qt(e,t,new Set,0)}function L(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function it(e){if(e!==null&&typeof e=="object"){Object.freeze(e);for(let t of Array.isArray(e)?e:Object.values(e))it(t)}return e}var Dr=/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/,Nr=/^[A-Za-z_][A-Za-z0-9_-]*$/,Br=new Set(["$server","server","$host","host","__proto__","prototype","constructor"]),Lr=new Set(["__proto__","prototype","constructor"]),Vr=new Set(["string","number","boolean","array","object","WxH","hex-color","iso-date"]);function Gi(e,t){return e<t?-1:e>t?1:0}function Mr(e){return[...new Set(e)].sort(Gi)}function jr(e){return e.replace(/\r\n?/g,` 3`)}function Ee(e,t="event.type"){if(typeof e!="string"||e.length>x.maxEventTypeCharacters||!Dr.test(e))throw new f("logic_definition_invalid",`${t} is not a canonical event type`,t);return e}function ee(e,t="state.path"){if(typeof e!="string"||e.length===0||e.length>x.maxStatePathCharacters)throw new f("logic_definition_invalid",`${t} is not a bounded state path`,t);let i=0,s=[],r=()=>{let n=i;for(;i<e.length&&/[A-Za-z0-9_-]/.test(e[i]);)i+=1;let a=e.slice(n,i);if(!Nr.test(a))throw new f("logic_definition_invalid",`${t} has an invalid property`,t);return a};for(s.push(r());i<e.length;)if(e[i]===".")i+=1,s.push(r());else if(e[i]==="["){let n=e.indexOf("]",i+1);if(n<0)throw new f("logic_definition_invalid",`${t} has an unterminated index`,t);let a=e.slice(i+1,n);if(!/^(?:0|[1-9][0-9]*)$/.test(a))throw new f("logic_definition_invalid",`${t} has an invalid array index`,t);let o=Number(a);if(!Number.isSafeInteger(o))throw new f("logic_definition_invalid",`${t} array index is unsafe`,t);s.push(o),i=n+1}else throw new f("logic_definition_invalid",`${t} has invalid syntax`,t);if(s.length>x.maxStatePathSegments)throw new f("logic_definition_invalid",`${t} has too many segments`,t);if(typeof s[0]!="string"||Br.has(s[0]))throw new f("logic_definition_invalid",`${t} starts with a reserved segment`,t);if(s.some(n=>typeof n=="string"&&Lr.has(n)))throw new f("logic_definition_invalid",`${t} contains a prototype segment`,t);return s}function Ae(e,t="state.path"){return ee(e,t).map((s,r)=>typeof s=="number"?`[${s}]`:r===0?s:`.${s}`).join("")}function xe(e,t,i,s){if(!Array.isArray(e)||e.length>
3t)throw new f("logic_definition_invalid",`${s} is not a bounded array`,s);return Mr(e.map((r,n)=>i(r,`${s}[${n}]`)))}function ii(e){if(!e||typeof e!="object"||Array.isArray(e))throw new f("logic_definition_invalid","variables.gameStateSchema must be an object","variables.gameStateSchema");let t=Object.create(null);for(let i of Object.keys(e).sort(Gi)){if(ee(i,`variables.gameStateSchema.${i}`),i.includes(".")||i.includes("["))throw new f("logic_definition_invalid","gameStateSchema keys must be top-level names",`variables.gameStateSchema.${i}`);let s=e[i];if(!s||typeof s!="object"||Array.isArray(s))throw new f("logic_definition_invalid","state declaration must be an object",`variables.gameStateSchema.${i}`);let r=s;if(!["clientOnly","serverMirror","serverOnly"].includes(String(r.scope)))throw new f("logic_definition_invalid","state scope is invalid",`variables.gameStateSchema.${i}.scope`);if(!Vr.has(r.type))throw new f("logic_definition_invalid","state type is invalid",`variables.gameStateSchema.${i}.type`);if(r.optimistic===!0||r.optimistic!==void 0&&r.optimistic!==!1)throw new f("logic_definition_invalid","Logic optimistic state is forbidden",`variables.gameStateSchema.${i}.optimistic`);if(r.description!==void 0&&typeof r.description!="string")throw new f("logic_definition_invalid","state description must be a string",`variables.gameStateSchema.${i}.description`);let n={scope:r.scope,type:r.type,optimistic:!1},a=typeof r.description=="string"?r.description.trim():"";a&&(n.description=a),t[i]=n}return t}function Ji(e,t="node"){if(!e||typeof e!="object"||Array.isArray(e))throw new f("logic_definition_invalid",`${t} must be an object`,t);let i=e,s=i.params;if(typeof i.id!="string"||i.id.trim()!==i.id||i.id.length===0||i.type!=="logic"||i.typeVersion!==1||!s||typeof s!="object"||Array.isArray(s))throw new f("logic_definition_invalid",`${t} is not a Logic Node V1`,t);if("next"in i&&i.next!==void 0)throw new f("logic_definition_invalid","Logic Node must not have next",`${t}.next`);let r=s,n=new Set(["name","description","source","listens","emits","reads","writes","catalogReads","catalogWrites"]),a=Object.keys(r).find(p=>!n.has(p));if(a)throw new f("logic_definition_invalid",a==="disabled"?"Logic Node disabled belongs at node.disabled, not params.disabled":`Logic Node params.${a} is not part of Logic Node V1`,`${t}.params.${a}`);if(i.disabled!==void 0&&typeof i.disabled!="boolean")throw new f("logic_definition_invalid","Logic Node disabled must be a top-level boolean when present",`${t}.disabled`);if(typeof r.name!="string"||typeof r.source!="string")throw new f("logic_definition_invalid","Logic name and source are required",`${t}.params`);let o=r.name.trim();if(r.description!==void 0&&typeof r.description!="string")throw new f("logic_definition_invalid","Logic description must be a string",`${t}.params.description`);let h=r.description?.trim(),l=jr(r.source);if(!o||o.length>x.maxNameCharacters)throw new f("logic_definition_invalid","Logic name exceeds limits",`${t}.params.name`);if(h!==void 0&&h.length>x.maxDescriptionCharacters)throw new f("logic_definition_invalid","Logic description exceeds limits",`${t}.params.description`);if(Tr(l)>x.maxNodeSourceUtf8Bytes)throw new f("logic_definition_invalid","Logic source exceeds 32 KiB",`${t}.params.source`);return F(g({id:i.id,type:"logic",typeVersion:1},i.disabled===!0?{disabled:!0}:{}),{params:F(g({name:o},h?{description:h}:{}),{source:l,listens:xe(r.listens,x.maxListens,Ee,`${t}.params.listens`),emits:xe(r.emits,x.maxEmits,(p,u)=>{let d=Ee(p,u);if(d.startsWith("runtime."))throw new f("logic_definition_invalid","runtime.* cannot be emitted",u);return d},`${t}.params.emits`),reads:xe(r.reads,x.maxReads,Ae,`${t}.params.reads`),writes:xe(r.writes,x.maxWrites,Ae,`${t}.params.writes`),catalogReads:xe(r.catalogReads??[],x.maxReads,Ae,t+".params.catalogReads"),catalogWrites:xe(r.catalogWrites??[],x.maxWrites,Ae,t+".params.catalogWrites")})})}var $r=new Set(["set","merge","increment","decrement","push","remove"]);function qr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Kr(e,t){return e.length<=t.length&&e.every((i,s)=>i===t[s])}function Ur(e){let t=ee(e,"catalog.path"),i=t[0];
3if(typeof i!="string")throw new f("logic_definition_invalid","Catalog path requires an alias",e);return{alias:i,segments:t.slice(1)}}function Wr(e,t){let i=ee(e,"catalog.path");return t.some(s=>Kr(ee(s,"catalog.declaration"),i))}function Hr(e,t){if(!Array.isArray(e)||e.length>32)throw new f("logic_result_invalid","result.catalogOps must contain at most 32 operations");return e.map((i,s)=>{if(!L(i))throw new f("logic_result_invalid",`result.catalogOps[${s}] must be an object`);let r=Object.keys(i).find(h=>!["op","path","value"].includes(h));if(r)throw new f("logic_result_invalid",`result.catalogOps[${s}].${r} is not allowed`);if(typeof i.op!="string"||!$r.has(i.op))throw new f("logic_result_invalid",`result.catalogOps[${s}].op is invalid`);if(typeof i.path!="string")throw new f("logic_result_invalid",`result.catalogOps[${s}].path is required`);let n=Ur(i.path);if(!Wr(i.path,t.params.catalogWrites))throw new f("logic_write_denied",`${i.path} is not declared in catalogWrites`,i.path);let a=i.op,o=qr(i,"value");if(["set","merge","push"].includes(a)&&!o)throw new f("logic_result_invalid",`${a} requires value`);if(a==="remove"&&o)throw new f("logic_result_invalid","remove does not accept value");if(["increment","decrement"].includes(a)&&o&&(typeof i.value!="number"||!Number.isFinite(i.value)))throw new f("logic_result_invalid",`${a} value must be a finite number`);if(a==="merge"&&!L(i.value))throw new f("logic_result_invalid","merge value must be an object");if(n.segments.length===0&&(!["set","merge"].includes(a)||a==="set"&&!L(i.value)))throw new f("logic_result_invalid","Catalog root supports only object set or merge");return g({op:a,path:i.path},o?{value:T(i.value,`result.catalogOps[${s}].value`)}:{})})}var zr=Object.freeze({version:1,canonicalJson:{input:{z:[{b:2,a:1}],a:-0},expected:'{"a":0,"z":[{"a":1,"b":2}]}'},lifecycleDefinition:{snapshot:{definition:{id:"wf-root",nodes:[],version:1},workflowDefinitionClosure:{"wf-child":{id:"wf-child",nodes:[],version:2}}},expectedRef:"sha256:f9f7abe01b510b2a758824c6abb4aa196ac8994f8dcb6fdc187e4ac36b123509"},gameSessionDefinition:{definition:{version:1,sourceKind:"nodegen_extension",rootWorkflowId:"wf-root",rootWorkflowRevision:"1",rootNodes:[{id:"logic-health",type:"logic",typeVersion:1,params:{name:"Health",source:"function onEvent(event, context) { return null; }",listens:["runtime.session_started"],emits:[],reads:["battle"],writes:["battle"],catalogReads:[],catalogWrites:[]}}],referencedDefinitions:[],gameStateSchema:{battle:{scope:"clientOnly",type:"object",optimistic:!1}},persistenceDescriptor:{kind:"catalog_default_storage",storageDefinitionId:"storage-definition-1",scopeMode:"per_user",storageSchemaVersion:1,gameStateSchemaHash:"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",logicInitialStateDefaults:{battle:{hp:10}}},logicRuntimeProfileVersion:1,logicRuntimeLimitsVersion:1},expectedRef:"sha256:d028de79e5a89e4eb5a9314fcdbc70e1076a41832e1a2c9becbdae588dcac208"},xoshiro128StarStar:{seed128:"00000001000000020000000300000004",firstUint32:[11520,0,5927040,70819200,2031721883,1637235492,1287239034,3734860849,3729100597,4258142804],stateAfter:"37f8b16b6f28b7985685570d8317705d"},source:{valid:`function onEvent(event, context) { 4 const hp = context.state.get("battle.hp"); 5 return { patches: [{ path: "battle.hp", value: Math.max(0, Number.parseInt(hp) - 1) }] }; 6}`,invalid:'function onEvent(event, context) { return fetch("https://example.com"); }'}}),Ta=$e(zr),Da=Object.freeze([{id:"client-session-across-navigation",lifecycleEpoch:1,scope:"clientOnly",initialState:{counter:0},defaultCounter:0,increments:[1,2],outcome:"applied",expectedCounter:3},{id:"resume-existing-autosave",lifecycleEpoch:1,scope:"clientOnly",initialState:{counter:41},defaultCounter:0,increments:[1],outcome:"applied",expectedCounter:42},{id:"additive-schema-missing-defaulted-key",lifecycleEpoch:1,scope:"clientOnly",initialState:{},defaultCounter:10,increments:[5],outcome:"applied",expectedCounter:15},{id:"server-mirror-authoritative-accept",lifecycleEpoch:1,scope:"serverMirror",initialState:{counter:7},defaultCounter:0,increments:[2],outcome:"applied",expectedCounter:9},{id:"server-mirror-authoritative-reject",lifecycleEpoch:1,scope:"serverMirror",initialState:{counter:7},defaultCounter:0,increments:[2],outcome:"rejected",expectedCounter:7},{id:"reconnect-takeover-new-lifecycle-epoch",lifecycleEpoch:2,scope:"clientOnly",
6initialState:{counter:3},defaultCounter:0,increments:[4],outcome:"applied",expectedCounter:7}]),Gr=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Qi=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],Jr="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D
67F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",Yi="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
6D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Rt={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Ot="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Qr={5:Ot,"5module":Ot+" export import",6:Ot+" const class extends export import super"},Xi=/^in(stanceof)?$/,Yr=new RegExp("["+Yi+"]"),Xr=new RegExp("["+Yi+Jr+"]");function Kt(e,t){for(var i=65536,s=0;s<t.length;s+=2){if(i+=t[s],i>e)return!1;if(i+=t[s+1],i>=e)return!0}return!1}function se(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Yr.test(String.fromCharCode(e)):t===!1?!1:Kt(e,Qi)}function fe(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Xr.test(String.fromCharCode(e)):t===!1?!1:Kt(e,Qi)||Kt(e,Gr)}var E=function(t,i){i===void 0&&(i={}),this.label=t,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function z(e,t){return new E(e,{beforeExpr:!0,binop:t})}var G={beforeExpr:!0},K={startsExpr:!0},si={};function C(e,t){return t===void 0&&(t={}),t.keyword=e,si[e]=new E(e,t)}var c={num:new E("num",K),regexp:new E("regexp",K),string:new E("string",K),name:new E("name",K),privateId:new E("privateId",K),eof:new E("eof"),bracketL:new E("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new E("]"),braceL:new E("{",{beforeExpr:!0,startsExpr:!0}),braceR:new E("}"),parenL:new E("(",{beforeExpr:!0,startsExpr:!0}),parenR:new E(")"),comma:new E(",",G),semi:new E(";",G),colon:new E(":",G),dot:new E("."),question:new E("?",G),questionDot:new E("?."),arrow:new E("=>",G),template:new E("template"),invalidTemplate:new E("invalidTemplate"),ellipsis:new E("...",G),backQuote:new E("`",K),dollarBraceL:new E("${",{beforeExpr:!0,startsExpr:!0}),eq:new E("=",{beforeExpr:!0,isAssign:!0}),assign:new E("_=",{beforeExpr:!0,isAssign:!0}),incDec:new E("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new E("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:z("||",1),logicalAND:z("&&",2),bitwiseOR:z("|",3),bitwiseXOR:z("^",4),bitwiseAND:z("&",5),equality:z("==/!=/===/!==",6),relational:z("</>/<=/>=",7),bitShift:z("<</>>/>>>",8),plusMin:new E("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:z("%",10),star:z("*",10),slash:z("/",10),starstar:new E("**",{beforeExpr:!0}),coalesce:z("??",1),_break:C("break"),_case:C("case",G),_catch:C("catch"),_continue:C("continue"),_debugger:C("debugger"),_default:C("default",G),_do:C("do",{isLoop:!0,beforeExpr:!0}),_else:C("else",G),_finally:C("finally"),_for:C("for",{isLoop:!0}),_function:C("function",K),_if:C("if"),_return:C("return",G),_switch:C("switch"),_throw:C("throw",G),_try:C("try"),_var:C("var"),_const:C("const"),_while:C("while",{isLoop:!0}),_with:C("with"),_new:C("new",{beforeExpr:!0,startsExpr:!0}),_this:C("this",K),_super:C("super",K),_class:C("class",K),_extends:C("extends",G),_export:C("export"),_import:C("import",K),_null:C("null",K),_true:C("true",K),_false:C("false",K),_in:C("in",{beforeExpr:!0,binop:7}),_instanceof:C("instanceof",{beforeExpr:!0,binop:7}),_typeof:C("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:C("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:C("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},U=/\r\n?|\n|\u2028|\u2029/,Zr=new RegExp(U.source,"g");function Re(e){return e===10||e===13||e===8232||e===8233}function Zi(e,t,i){i===void 0&&(i=e.length);for(var s=t;s<i;s++){var r=e.charCodeAt(s);if(Re(r))return s<i-1&&r===13&&e.charCodeAt(s+1)===10?s+2:s+1}return-1}var es=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,B=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ts=Object.prototype,en=ts.hasOwnProperty,tn=ts.toString,Oe=Object.hasOwn||function(e,t){return en.call(e,t)},bi=Array.isArray||function(e){return tn.call(e)==="[object Array]"},xi=Object.create(null);function pe(e){return xi[e]||(xi[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function oe(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var sn=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,qe=function(t,i){this.line=t,this.column=i};qe.prototype.offset=function(t){return new qe(this.line,this.column+t)};var gt=function(t,i,s){this.start=i,this.end=s,t.sourceFile!==null&&(this.source=t.sourceFile)};function is(e,t){for(var i=1,s=0;;){var r=Zi(e,s,t);if(r<0)return new qe(i,t-s);++i,s=r}}var Ut={ecmaVersion:null,sourceType:"script",strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowA
6waitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ki=!1;function rn(e){var t={};for(var i in Ut)t[i]=e&&Oe(e,i)?e[i]:Ut[i];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ki&&typeof console=="object"&&console.warn&&(ki=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required. 7Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),bi(t.onToken)){var s=t.onToken;t.onToken=function(r){return s.push(r)}}if(bi(t.onComment)&&(t.onComment=nn(t,t.onComment)),t.sourceType==="commonjs"&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}function nn(e,t){return function(i,s,r,n,a,o){var h={type:i?"Block":"Line",value:s,start:r,end:n};e.locations&&(h.loc=new gt(this,a,o)),e.ranges&&(h.range=[r,n]),t.push(h)}}var _e=1,ye=2,ri=4,ss=8,ni=16,rs=32,vt=64,ns=128,we=256,Ke=512,as=1024,_t=_e|ye|we;function ai(e,t){return ye|(e?ri:0)|(t?ss:0)}var at=0,oi=1,he=2,os=3,cs=4,hs=5,V=function(t,i,s){this.options=t=rn(t),this.sourceFile=t.sourceFile,this.keywords=pe(Qr[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var r="";t.allowReserved!==!0&&(r=Rt[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(r+=" await")),this.reservedWords=pe(r);var n=(r?r+" ":"")+Rt.strict;this.reservedWordsStrict=pe(n),this.reservedWordsStrictBind=pe(n+" "+Rt.strictBind),this.input=String(i),this.containsEsc=!1,s?(this.pos=s,this.lineStart=this.input.lastIndexOf(` 8`,s-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(U).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=c.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||t.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?ye:_e),this.regexpState=null,this.privateNameStack=[]},Q={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};V.prototype.parse=function(){var t=this,i=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return t.parseTopLevel(i)})};Q.inFunction.get=function(){return(this.currentVarScope().flags&ye)>0};Q.inGenerator.get=function(){return(this.currentVarScope().flags&ss)>0};Q.inAsync.get=function(){return(this.currentVarScope().flags&ri)>0};Q.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],i=t.flags;if(i&(we|Ke))return!1;if(i&ye)return(i&ri)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Q.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&_e)};Q.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&vt)>0||this.options.allowSuperOutsideMethod};Q.allowDirectSuper.get=function(){return(this.currentThisScope().flags&ns)>0};Q.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Q.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],i=t.flags;if(i&(we|Ke)||i&ye&&!(i&ni))return!0}return!1};Q.allowUsing.get=function(){var e=this.currentScope(),t=e.flags;return!(t&as||!this.inModule&&t&_e)};Q.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&we)>0};V.extend=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];for(var s=this,r=0;r<t.length;r++)s=t[r](s);return s};V.parse=function(t,i){return new this(i,t).parse()};V.parseExpressionAt=function(t,i,s){var r=new this(s,t,i);return r.nextToken(),r.parseExpression()};V.tokenizer=function(t,i){return new this(i,t)};Object.defineProperties(V.prototype,Q);var j=V.prototype,an=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;j.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){B.lastIndex=e,e+=B.exec(this.input)[0].length;var t=an.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){B.lastIndex=e+t[0].length;var i=B.exec(this.input),s=i.index+i[0].length,r=this.input.charAt(s);return r===";"||r==="}"||U.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(r)||r==="!"&&this.input.charAt(s+1)==="=")}e+=t[0].length,B.lastIndex=e,e+=B.exec(this.input)[0].length,this.input[e]===";"&&e++}};j.eat=function(e){return this.type===e?(this.next(),!0):!1};j.isContextual=function(e){return this.type===c.name&&this.value===e&&!this.containsEsc};j.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};j.catchStackOverflow=function(e){try{return e()}catch(t){if(t instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(t.message)||/\btoo much recursion\b/i.test(t.message)))this.raise(this.start,"Not enough stack space to parse input");else throw t}};j.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};j.canInsertSemicolon=function(){return this.type===c.eof||this.type===c.braceR||U.test(this.input.slice(this.lastTokEnd,this.start))};j.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};j.semicolon=function(){!this.eat(c.semi)&&!this.insertSemicolon()&&this.unexpected()};
8j.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};j.expect=function(e){this.eat(e)||this.unexpected()};j.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var yt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};j.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var i=t?e.parenthesizedAssign:e.parenthesizedBind;i>-1&&this.raiseRecoverable(i,t?"Assigning to rvalue":"Parenthesized pattern")}};j.checkExpressionErrors=function(e,t){if(!e)return!1;var i=e.shorthandAssign,s=e.doubleProto;if(!t)return i>=0||s>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),s>=0&&this.raiseRecoverable(s,"Redefinition of __proto__ property")};j.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};j.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var _=V.prototype;_.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==c.eof;){var i=this.parseStatement(null,!0,t);e.body.push(i)}if(this.inModule)for(var s=0,r=Object.keys(this.undefinedExports);s<r.length;s+=1){var n=r[s];this.raiseRecoverable(this.undefinedExports[n].start,"Export '"+n+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(e,"Program")};var ci={kind:"loop"},on={kind:"switch"};_.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;B.lastIndex=this.pos;var t=B.exec(this.input),i=this.pos+t[0].length,s=this.fullCharCodeAt(i);if(s===91||s===92)return!0;if(e)return!1;if(s===123)return!0;if(se(s)){var r=i;do i+=s<=65535?1:2;while(fe(s=this.fullCharCodeAt(i)));if(s===92)return!0;var n=this.input.slice(r,i);if(!Xi.test(n))return!0}return!1};_.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;B.lastIndex=this.pos;var e=B.exec(this.input),t=this.pos+e[0].length,i;return!U.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(fe(i=this.fullCharCodeAt(t+8))||i===92))};_.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;B.lastIndex=this.pos;var i=B.exec(this.input),s=this.pos+i[0].length;if(U.test(this.input.slice(this.pos,s)))return!1;if(e){var r=s+5,n;if(this.input.slice(s,r)!=="using"||r===this.input.length||fe(n=this.fullCharCodeAt(r))||n===92)return!1;B.lastIndex=r;var a=B.exec(this.input);if(s=r+a[0].length,a&&U.test(this.input.slice(r,s)))return!1}var o=this.fullCharCodeAt(s);if(!se(o)&&o!==92)return!1;var h=s;do s+=o<=65535?1:2;while(fe(o=this.fullCharCodeAt(s)));if(o===92)return!0;var l=this.input.slice(h,s);if(Xi.test(l))return!1;if(t&&!e&&l==="of"){B.lastIndex=s;var p=B.exec(this.input);if(s=s+p[0].length,this.input.charCodeAt(s)!==61||(o=this.input.charCodeAt(s+1))===61||o===62)return!1}return!0};_.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};_.isUsing=function(e){return this.isUsingKeyword(!1,e)};_.parseStatement=function(e,t,i){var s=this.type,r=this.startNode(),n;switch(this.isLet(e)&&(s=c._var,n="let"),s){case c._break:case c._continue:return this.parseBreakContinueStatement(r,s.keyword);case c._debugger:return this.parseDebuggerStatement(r);case c._do:return this.parseDoStatement(r);case c._for:return this.parseForStatement(r);case c._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>
8=6&&this.unexpected(),this.parseFunctionStatement(r,!1,!e);case c._class:return e&&this.unexpected(),this.parseClass(r,!0);case c._if:return this.parseIfStatement(r);case c._return:return this.parseReturnStatement(r);case c._switch:return this.parseSwitchStatement(r);case c._throw:return this.parseThrowStatement(r);case c._try:return this.parseTryStatement(r);case c._const:case c._var:return n=n||this.value,e&&n!=="var"&&this.unexpected(),this.parseVarStatement(r,n);case c._while:return this.parseWhileStatement(r);case c._with:return this.parseWithStatement(r);case c.braceL:return this.parseBlock(!0,r);case c.semi:return this.parseEmptyStatement(r);case c._export:case c._import:if(this.options.ecmaVersion>10&&s===c._import){B.lastIndex=this.pos;var a=B.exec(this.input),o=this.pos+a[0].length,h=this.input.charCodeAt(o);if(h===40||h===46)return this.parseExpressionStatement(r,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),s===c._import?this.parseImport(r):this.parseExport(r,i);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(r,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,"Using declaration is not allowed in single-statement positions"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(r,!1,l),this.semicolon(),this.finishNode(r,"VariableDeclaration");var p=this.value,u=this.parseExpression();return s===c.name&&u.type==="Identifier"&&this.eat(c.colon)?this.parseLabeledStatement(r,p,u,e):this.parseExpressionStatement(r,u)}};_.parseBreakContinueStatement=function(e,t){var i=t==="break";this.next(),this.eat(c.semi)||this.insertSemicolon()?e.label=null:this.type!==c.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var s=0;s<this.labels.length;++s){var r=this.labels[s];if((e.label==null||r.name===e.label.name)&&(r.kind!=null&&(i||r.kind==="loop")||e.label&&i))break}return s===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,i?"BreakStatement":"ContinueStatement")};_.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};_.parseDoStatement=function(e){return this.next(),this.labels.push(ci),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(c._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(c.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};_.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ci),this.enterScope(0),this.expect(c.parenL),this.type===c.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var i=this.isLet();if(this.type===c._var||this.type===c._const||i){var s=this.startNode(),r=i?"let":this.value;return this.next(),this.parseVar(s,!0,r),this.finishNode(s,"VariableDeclaration"),this.parseForAfterInit(e,s,t)}var n=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var h=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(h,!0,o),this.finishNode(h,"VariableDeclaration"),this.parseForAfterInit(e,h,t)}var l=this.containsEsc,p=new yt,u=this.start,d=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===c._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===c._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(d.start===u&&!l&&d.type==="Identifier"&&d.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),n&&a&&this.raise(d.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(d,!1,p),this.checkLValPattern(d),this.parseForIn(e,d)):(this.checkExpressionErrors(p,!0),t>-1&&this.unexpected(t),this.parseFor(e,d))};_.parseForAfterInit=function(e,t,i){return(this.type===c._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.type===c._in?((t.kind==="using"||t.kind==="await using")&&!t.declarations[0].init&&this.raise(this.start,"Using declaration is not allowed in for-in loops"),this.options.ecmaVersion>=9&&i>-1&&this.unexpected(i)):this.options.ecmaVersion>=9&&(e.await=i>-1),this.parseForIn(e,t)):(i>-1&&this.unexpected(i),this.parseFor(e,t))};_.parseFunctionStatement=function(e,t,i){return this.next(),this.parseFunction(e,Be|(i?0:Wt),!1,t)};_.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement
8("if"),e.alternate=this.eat(c._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};_.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(c.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};_.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(c.braceL),this.labels.push(on),this.enterScope(as);for(var t,i=!1;this.type!==c.braceR;)if(this.type===c._case||this.type===c._default){var s=this.type===c._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),s?t.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,t.test=null),this.expect(c.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};_.parseThrowStatement=function(e){return this.next(),U.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var cn=[];_.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?rs:0),this.checkLValPattern(e,t?cs:he),this.expect(c.parenR),e};_.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===c._catch){var t=this.startNode();this.next(),this.eat(c.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(c._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};_.parseVarStatement=function(e,t,i){return this.next(),this.parseVar(e,!1,t,i),this.semicolon(),this.finishNode(e,"VariableDeclaration")};_.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(ci),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};_.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};_.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};_.parseLabeledStatement=function(e,t,i,s){for(var r=0,n=this.labels;r<n.length;r+=1){var a=n[r];a.name===t&&this.raise(i.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===c._switch?"switch":null,h=this.labels.length-1;h>=0;h--){var l=this.labels[h];if(l.statementStart===e.start)l.statementStart=this.start,l.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(s?s.indexOf("label")===-1?s+"label":s:"label"),this.labels.pop(),e.label=i,this.finishNode(e,"LabeledStatement")};_.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};_.parseBlock=function(e,t,i){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(c.braceL),e&&this.enterScope(0);this.type!==c.braceR;){var s=this.parseStatement(null);t.body.push(s)}return i&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};_.parseFor=function(e,t){return e.init=t,this.expect(c.semi),e.test=this.type===c.semi?null:this.parseExpression(),this.expect(c.semi),e.update=this.type===c.parenR?null:this.parseExpression(),this.expect(c.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};_.parseForIn=function(e,t){var i=this.type===c._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(c.parenR),e.body=this.parseStatement
vendor: 5,409 bytes, line 8
8("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,i?"ForInStatement":"ForOfStatement")};_.parseVar=function(e,t,i,s){for(e.declarations=[],e.kind=i;;){var r=this.startNode();if(this.parseVarId(r,i),this.eat(c.eq)?r.init=this.parseMaybeAssign(t):!s&&i==="const"&&!(this.type===c._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!s&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==c._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!s&&r.id.type!=="Identifier"&&!(t&&(this.type===c._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):r.init=null,e.declarations.push(this.finishNode(r,"VariableDeclarator")),!this.eat(c.comma))break}return e};_.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?oi:he,!1)};var Be=1,Wt=2,ls=4;_.parseFunction=function(e,t,i,s,r){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!s)&&(this.type===c.star&&t&Wt&&this.unexpected(),e.generator=this.eat(c.star)),this.options.ecmaVersion>=8&&(e.async=!!s),t&Be&&(e.id=t&ls&&this.type!==c.name?null:this.parseIdent(),e.id&&!(t&Wt)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?oi:he:os));var n=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ai(e.async,e.generator)),t&Be||(e.id=this.type===c.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,i,!1,r),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&Be?"FunctionDeclaration":"FunctionExpression")};_.parseFunctionParams=function(e){this.expect(c.parenL),e.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};_.parseClass=function(e,t){this.next();var i=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var s=this.enterClassBody(),r=this.startNode(),n=!1;for(r.body=[],this.expect(c.braceL);this.type!==c.braceR;){var a=this.parseClassElement(e.superClass!==null);a&&(r.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(n&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),n=!0):a.key&&a.key.type==="PrivateIdentifier"&&hn(s,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=i,this.next(),e.body=this.finishNode(r,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};_.parseClassElement=function(e){if(this.eat(c.semi))return null;var t=this.options.ecmaVersion,i=this.startNode(),s="",r=!1,n=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(c.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===c.star?o=!0:s="static"}if(i.static=o,!s&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===c.star)&&!this.canInsertSemicolon()?n=!0:s="async"),!s&&(t>=9||!n)&&this.eat(c.star)&&(r=!0),!s&&!n&&!r){var h=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=h:s=h)}if(s?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=s,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),t<13||this.type===c.parenL||a!=="method"||r||n){var l=!i.static&&ot(i,"constructor"),p=l&&e;l&&a!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=l?"constructor":a,this.parseClassMethod(i,r,n,p)}else this.parseClassField(i);return i};_.isClassElementNameStart=function(){return this.type===c.name||this.type===c.privateId||this.type===c.num||this.type===c.string||this.type===c.bracketL||this.type.keyword};_.parseClassElementName=function(e){this.type===c.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};_.parseClassMethod=function(e,t,i,s){var r=e.key;e.kind==="constructor"?(t&&this.raise(r.start,"Constructor can't be a generator"),i&&this.raise(r.start,"Constructor can't be an async method")):e.static&&ot(e,"prototype")&&this.raise(r.start,"Classes may not have a static property named prototype");var n=e.value=this.parseMethod(t,i,s);return e.kind==="get"&&n.params.length!==0&&this.raiseRecoverable(n.start,"getter should have no params"),e.kind==="set"&&n.params.length!==1&&this.raiseRecoverable(n.start,"setter should have exactly one param"),e.kind==="set"&&n.params[0].type==="RestElement"&&this.raiseRecoverable(n.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};_.parseClassField=function(e){return ot(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&ot(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(c.eq)?(this.enterScope(Ke|vt),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};_.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(we|vt);this.type!==c.braceR;
8){var i=this.parseStatement(null);e.body.push(i)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};_.parseClassId=function(e,t){this.type===c.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,he,!1)):(t===!0&&this.unexpected(),e.id=null)};_.parseClassSuper=function(e){e.superClass=this.eat(c._extends)?this.parseExprSubscripts(null,!1):null};_.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};_.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,i=e.used;if(this.options.checkPrivateFields)for(var s=this.privateNameStack.length,r=s===0?null:this.privateNameStack[s-1],n=0;n<i.length;++n){var a=i[n];Oe(t,a.name)||(r?r.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function hn(e,t){var i=t.key.name,s=e[i],r="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(r=(t.static?"s":"i")+t.kind),s==="iget"&&r==="iset"||s==="iset"&&r==="iget"||s==="sget"&&r==="sset"||s==="sset"&&r==="sget"?(e[i]="true",!1):s?!0:(e[i]=r,!1)}function ot(e,t){var i=e.computed,s=e.key;return!i&&(s.type==="Identifier"&&s.name===t||s.type==="Literal"&&s.value===t)}_.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==c.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};_.parseExport=function(e,t){if(this.next(),this.eat(c.star))return this.parseExportAllDeclaration(e,t);if(this.eat(c._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==c.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var i=0,s=e.specifiers;i<s.length;i+=1){var r=s[i];this.checkUnreserved(r.local),this.checkLocalExport(r.local),r.local.type==="Literal"&&this.raise(r.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};_.parseExportDeclaration=function(e){return this.parseStatement(null)};_.parseExportDefaultDeclaration=function(){var e;if(this.type===c._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Be|ls,!1,e)}else if(this.type===c._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var s=this.parseMaybeAssign();return this.semicolon(),s}};_.checkExport=function(e,t,i){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Oe(e,t)&&this.raiseRecoverable(i,"Duplicate export '"+t+"'"),e[t]=!0)};_.checkPatternExport=function(e,t){var i=t.type;if(i==="Identifier")this.checkExport(e,t,t.start);else if(i==="ObjectPattern")for(var s=0,r=t.properties;s<r.length;s+=1){var n=r[s];this.checkPatternExport(e,n)}else if(i==="ArrayPattern")for(var a=0,o=t.elements;a<o.length;a+=1){var h=o[a];h&&this.checkPatternExport(e,h)}else i==="Property"?this.checkPatternExport(e,t.value):i==="AssignmentPattern"?this.checkPatternExport(e,t.left):i==="RestElement"&&this.checkPatternExport(e,t.argument)};_.checkVariableExport=function(e,t){if(e)for(var i=0,s=t;i<s.length;i+=1){var r=s[i];this.checkPatternExport(e,r.id)}};_.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};_.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exp
8orted.start),this.finishNode(t,"ExportSpecifier")};_.parseExportSpecifiers=function(e){var t=[],i=!0;for(this.expect(c.braceL);!this.eat(c.braceR);){if(i)i=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;t.push(this.parseExportSpecifier(e))}return t};_.parseImport=function(e){return this.next(),this.type===c.string?(e.specifiers=cn,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===c.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};_.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,he),this.finishNode(e,"ImportSpecifier")};_.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,he),this.finishNode(e,"ImportDefaultSpecifier")};_.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,he),this.finishNode(e,"ImportNamespaceSpecifier")};_.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===c.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(c.comma)))return e;if(this.type===c.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(c.braceL);!this.eat(c.braceR);){if(t)t=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;e.push(this.parseImportSpecifier())}return e};_.parseWithClause=function(){var e=[];if(!this.eat(c._with))return e;this.expect(c.braceL);for(var t={},i=!0;!this.eat(c.braceR);){if(i)i=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;var s=this.parseImportAttribute(),r=s.key.type==="Identifier"?s.key.name:s.key.value;Oe(t,r)&&this.raiseRecoverable(s.key.start,"Duplicate attribute key '"+r+"'"),t[r]=!0,e.push(s)}return e};_.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===c.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(c.colon),this.type!==c.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};_.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===c.string){var e=this.parseLiteral(this.value);return sn.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};_.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};_.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var Y=V.prototype;Y.toAssignable=function(e,t,i){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var s=0,r=e.properties;s<r.length;s+=1){var n=r[s];this.toAssignable(n,t),n.type==="RestElement"&&(n.argument.type==="ArrayPattern"||n.argument.type==="ObjectPattern")&&this.raise(n.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,i);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return e};Y.toAssignableList=function(e,t){for(var i=e.length,s=0;s<i;s++){var r=e[s];r&&this.toAssignable(r,t)}if(i){var n=e[i-1];this.options.ecmaVersion===6&&t&&n&&n.type==="RestElement"&&n.argument.type!=="Identifier"&&this.unexpected(n.argument.start)}return e};Y.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};Y.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==c.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};Y.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case c.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(c.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case c.braceL:return this.parseObj(!0)}return this.parseIdent()};Y.parseBindingList=function(e,t,i,s){for(var r=[],n=!0;!this.eat(e);)if(n?n=!1:this.expect(c.comma),t&&this.type===c.comma)r.push(null);else{if(i&&this.afterTrailingComma(e))break;
8if(this.type===c.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),r.push(a),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else r.push(this.parseAssignableListItem(s))}return r};Y.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};Y.parseBindingListItem=function(e){return e};Y.parseMaybeDefault=function(e,t,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(c.eq))return i;var s=this.startNodeAt(e,t);return s.left=i,s.right=this.parseMaybeAssign(),this.finishNode(s,"AssignmentPattern")};Y.checkLValSimple=function(e,t,i){t===void 0&&(t=at);var s=t!==at;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(s?"Binding ":"Assigning to ")+e.name+" in strict mode"),s&&(t===he&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),i&&(Oe(i,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),i[e.name]=!0),t!==hs&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":s&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return s&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,i);default:this.raise(e.start,(s?"Binding":"Assigning to")+" rvalue")}};Y.checkLValPattern=function(e,t,i){switch(t===void 0&&(t=at),e.type){case"ObjectPattern":for(var s=0,r=e.properties;s<r.length;s+=1){var n=r[s];this.checkLValInnerPattern(n,t,i)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var h=o[a];h&&this.checkLValInnerPattern(h,t,i)}break;default:this.checkLValSimple(e,t,i)}};Y.checkLValInnerPattern=function(e,t,i){switch(t===void 0&&(t=at),e.type){case"Property":this.checkLValInnerPattern(e.value,t,i);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,i);break;case"RestElement":this.checkLValPattern(e.argument,t,i);break;default:this.checkLValPattern(e,t,i)}};var Z=function(t,i,s,r,n){this.token=t,this.isExpr=!!i,this.preserveSpace=!!s,this.override=r,this.generator=!!n},P={b_stat:new Z("{",!1),b_expr:new Z("{",!0),b_tmpl:new Z("${",!1),p_stat:new Z("(",!1),p_expr:new Z("(",!0),q_tmpl:new Z("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new Z("function",!1),f_expr:new Z("function",!0),f_expr_gen:new Z("function",!0,!1,null,!0),f_gen:new Z("function",!1,!1,null,!0)},Pe=V.prototype;Pe.initialContext=function(){return[P.b_stat]};Pe.curContext=function(){return this.context[this.context.length-1]};Pe.braceIsBlock=function(e){var t=this.curContext();return t===P.f_expr||t===P.f_stat?!0:e===c.colon&&(t===P.b_stat||t===P.b_expr)?!t.isExpr:e===c._return||e===c.name&&this.exprAllowed?U.test(this.input.slice(this.lastTokEnd,this.start)):e===c._else||e===c.semi||e===c.eof||e===c.parenR||e===c.arrow?!0:e===c.braceL?t===P.b_stat:e===c._var||e===c._const||e===c.name?!1:!this.exprAllowed};Pe.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};Pe.updateContext=function(e){var t,i=this.type;i.keyword&&e===c.dot?this.exprAllowed=!1:(t=i.updateContext)?t.call(this,e):this.exprAllowed=i.beforeExpr};Pe.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};c.parenR.updateContext=c.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===P.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};c.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?P.b_stat:P.b_expr),this.exprAllowed=!0};c.dollarBraceL.updateContext=function(){this.context.push(P.b_tmpl),this.exprAllowed=!0};c.parenL.updateContext=function(e){var t=e===c._if||e===c._for||e===c._with||e===c._while;this.context.push(t?P.p_stat:P.p_expr),this.exprAllowed=!0};c.incDec.updateContext=function(){};c._function.updateContext=c._class.updateContext=function(e){e.beforeExpr&&e!==c._else&&!(e===c.semi&&this.curContext()!==P.p_stat)&&!(e===c._return&&U.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===c.colon||e===c.braceL)&&this.curContext()===P.b_stat)?this.context.push(P.f_expr):this.context.push(P.f_stat),this.exprAllowed=!1};c.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};c.backQuote.updateContext=function(){this.curContext()===P.q_tmpl?this.context.pop():this.context.push(P.q_tmpl),this.exprAllowed=!1};c.star.updateContext=function(e){if(e===c._function){var t=this.context.length-1;this.context[t]===P.f_expr?this.context[t]=P.f_expr_gen:this.context[t]=P.f_gen}this.exprAllowed=!0};c.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==c.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var S=V.prototype;S.checkPropClash=function(e,t,i){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var s=e.key,r;switch(s.type){case"Identifier":r=s.name;break;case"Literal":r=String(s.value);break;default:return}var n=e.kind;if(this.options.ecmaVersion>=6){r==="__proto__"&&n==="init"&&(t.proto&&(i?i.doubleProto<0&&(i.doubleProto=s.start):this.raiseRecoverable(s.start,"Redefinition of __proto__ property")),t.proto=!0);return}r="$"+r;var a=t[r];if(a){var o;n==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[n],o&&this.raiseRecoverable(s.start,"Redefinition of property")}else a=t[r]={init:!1,get:!1,set:!1};a[n]=!0}};S.parseExpression=function(e,t){var i=this;return this.catchStackOverflow(function(){var s=i.start,r=i.startLoc,n=i.parseMaybeAssign(e,t);if(i.type===c.comma){var a=i.startNodeAt(s,r);for(a.expressions=[n];i.eat(c.comma);)a.expressions.push(i.parseMaybeAssign(e,t));return i.finishNode(a,"SequenceExpression")}return n})};S.parseMaybeAssign=function(e,t,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var s=!1,r=-1,n=-1,a=-1;t?(r=t.parenthesizedAssign,n=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new yt,s=!0);var o=this.start,h=this.startLoc;(this.type===c.parenL||this.type===c.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var l=this.parseMaybeConditional(e,t);if(i&&(l=i.call(this,l,o,h)),this.type.isAssign){var p=this.startNodeAt(o,h);return p.operator=this.value,this.type===c.eq&&(l=this.toAssignable(l,!1,t)),s||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===c.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(p,"AssignmentExpression")}else s&&this.checkExpressionErrors(t,!0);return r>-1&&(t.parenthesizedAssign=r),n>-1&&(t.trailingComma=n),l};S.parseMaybeConditional=function(e,t){var i=this.start,s=this.startLoc,r=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return r;if(!(r.type==="ArrowFunctionExpression"&&r.start===i)&&this.eat(c.question)){var n=this.startNodeAt(i,s);return n.test=r,n.consequent=this.parseMaybeAssign(),this.expect(c.colon),n.alternate=this.parseMaybeAssign(e),this.finishNode(n,"ConditionalExpression")}return r};S.parseExprOps=function(e,t){var i=this.start,s=this.startLoc,r=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||r.start===i&&r.type==="ArrowFunctionExpression"?r:this.parseExprOp(r,i,s,-1,e)};S.parseExprOp=function(e,t,i,s,r){var n=this.type.binop;if(n!=null&&(!r||this.type!==c._in)&&n>s){var a=this.type===c.logicalOR||this.type===c.logicalAND,o=this.type===c.coalesce;o&&(n=c.logicalAND.binop);var h=this.value;this.next();var l=this.start,p=this.startLoc,u=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,r),l,p,n,r),d=this.buildBinary(t,i,e,u,h,a||o);
8return(a&&this.type===c.coalesce||o&&(this.type===c.logicalOR||this.type===c.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(d,t,i,s,r)}return e};S.buildBinary=function(e,t,i,s,r,n){s.type==="PrivateIdentifier"&&this.raise(s.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=i,a.operator=r,a.right=s,this.finishNode(a,n?"LogicalExpression":"BinaryExpression")};S.parseMaybeUnary=function(e,t,i,s){var r=this.start,n=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(s),t=!0;else if(this.type.prefix){var o=this.startNode(),h=this.type===c.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,h,s),this.checkExpressionErrors(e,!0),h?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&us(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Ht(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,a=this.finishNode(o,h?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===c.privateId)(s||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==c._in&&this.unexpected();else{if(a=this.parseExprSubscripts(e,s),this.checkExpressionErrors(e))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(r,n);l.operator=this.value,l.prefix=!1,l.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(l,"UpdateExpression")}}if(!i&&this.eat(c.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(r,n,a,this.parseMaybeUnary(null,!1,!1,s),"**",!1);else return a};function us(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&us(e.expression)}function Ht(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Ht(e.expression)||e.type==="ParenthesizedExpression"&&Ht(e.expression)}S.parseExprSubscripts=function(e,t){var i=this.start,s=this.startLoc,r=this.parseExprAtom(e,t);if(r.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return r;var n=this.parseSubscripts(r,i,s,!1,t);return e&&n.type==="MemberExpression"&&(e.parenthesizedAssign>=n.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=n.start&&(e.parenthesizedBind=-1),e.trailingComma>=n.start&&(e.trailingComma=-1)),n};S.parseSubscripts=function(e,t,i,s,r){for(var n=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,i,s,n,a,r);if(o.optional&&(a=!0),o===e||o.type==="ArrowFunctionExpression"){if(a){var h=this.startNodeAt(t,i);h.expression=o,o=this.finishNode(h,"ChainExpression")}return o}e=o}};S.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(c.arrow)};S.parseSubscriptAsyncArrow=function(e,t,i,s){return this.parseArrowExpression(this.startNodeAt(e,t),i,!0,s)};S.parseSubscript=function(e,t,i,s,r,n,a){var o=this.options.ecmaVersion>=11,h=o&&this.eat(c.questionDot);s&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(c.bracketL);if(l||h&&this.type!==c.parenL&&this.type!==c.backQuote||this.eat(c.dot)){var p=this.startNodeAt(t,i);p.object=e,l?(p.property=this.parseExpression(),this.expect(c.bracketR)):this.type===c.privateId&&e.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!l,o&&(p.optional=h),e=this.finishNode(p,"MemberExpression")}else if(!s&&this.eat(c.parenL)){var u=new yt,d=this.yieldPos,m=this.awaitPos,y=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var A=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1,u);if(r&&!h&&this.shouldParseAsyncArrow())return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=d,this.awaitPos=m,this.awaitIdentPos=y,this.parseSubscriptAsyncArrow(t,i,A,a);this.checkExpressionErrors(u,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=y||this.awaitIdentPos;var b=this.startNodeAt(t,i);b.callee=e,b.arguments=A,o&&(b.optional=h),e=this.finishNode(b,"CallExpression")}
vendor: 15,684 bytes, lines 8-10
8else if(this.type===c.backQuote){(h||n)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var w=this.startNodeAt(t,i);w.tag=e,w.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(w,"TaggedTemplateExpression")}return e};S.parseExprAtom=function(e,t,i){this.type===c.slash&&this.readRegexp();var s,r=this.potentialArrowAt===this.start;switch(this.type){case c._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),s=this.startNode(),this.next(),this.type===c.parenL&&!this.allowDirectSuper&&this.raise(s.start,"super() call outside constructor of a subclass"),this.type!==c.dot&&this.type!==c.bracketL&&this.type!==c.parenL&&this.unexpected(),this.finishNode(s,"Super");case c._this:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case c.name:var n=this.start,a=this.startLoc,o=this.containsEsc,h=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&h.name==="async"&&!this.canInsertSemicolon()&&this.eat(c._function))return this.overrideContext(P.f_expr),this.parseFunction(this.startNodeAt(n,a),0,!1,!0,t);if(r&&!this.canInsertSemicolon()){if(this.eat(c.arrow))return this.parseArrowExpression(this.startNodeAt(n,a),[h],!1,t);if(this.options.ecmaVersion>=8&&h.name==="async"&&this.type===c.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return h=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(c.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(n,a),[h],!0,t)}return h;case c.regexp:var l=this.value;return s=this.parseLiteral(l.value),s.regex={pattern:l.pattern,flags:l.flags},s;case c.num:case c.string:return this.parseLiteral(this.value);case c._null:case c._true:case c._false:return s=this.startNode(),s.value=this.type===c._null?null:this.type===c._true,s.raw=this.type.keyword,this.next(),this.finishNode(s,"Literal");case c.parenL:var p=this.start,u=this.parseParenAndDistinguishExpression(r,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(u)&&(e.parenthesizedAssign=p),e.parenthesizedBind<0&&(e.parenthesizedBind=p)),u;case c.bracketL:return s=this.startNode(),this.next(),s.elements=this.parseExprList(c.bracketR,!0,!0,e),this.finishNode(s,"ArrayExpression");case c.braceL:return this.overrideContext(P.b_expr),this.parseObj(!1,e);case c._function:return s=this.startNode(),this.next(),this.parseFunction(s,0);case c._class:return this.parseClass(this.startNode(),!1);case c._new:return this.parseNew();case c.backQuote:return this.parseTemplate();case c._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};S.parseExprAtomDefault=function(){this.unexpected()};S.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===c.parenL&&!e)return this.parseDynamicImport(t);if(this.type===c.dot){var i=this.startNodeAt(t.start,t.loc&&t.loc.start);return i.name="import",t.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};S.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(c.parenR)?e.options=null:(this.expect(c.comma),this.afterTrailingComma(c.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(c.parenR)||(this.expect(c.comma),this.afterTrailingComma(c.parenR)||this.unexpected())));else if(!this.eat(c.parenR)){var t=this.start;this.eat(c.comma)&&this.eat(c.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};S.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};S.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};S.parseParenExpression=function(){this.expect(c.parenL);var e=this.parseExpression();return this.expect(c.parenR),e};S.shouldParseArrow=function(e){return!this.canInsertSemicolon()};S.parseParenAndDistinguishExpression=function(e,t){var i=this.start,s=this.startLoc,r,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,h=[],l=!0,p=!1,u=new yt,d=this.yieldPos,m=this.awaitPos,y;for(this.yieldPos=0,this.awaitPos=0;this.type!==c.parenR;)if(l?l=!1:this.expect(c.comma),n&&this.afterTrailingComma(c.parenR,!0)){p=!0;break}else if(this.type===c.ellipsis){y=this.start,h.push(this.parseParenItem(this.parseRestBinding())),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else h.push(this.parseMaybeAssign(!1,u,this.parseParenItem));var A=this.lastTokEnd,b=this.lastTokEndLoc;if(this.expect(c.parenR),e&&this.shouldParseArrow(h)&&this.eat(c.arrow))return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=m,this.parseParenArrowList(i,s,h,t);(!h.length||p)&&this.unexpected(this.lastTokStart),y&&this.unexpected(y),this.checkExpressionErrors(u,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,h.length>1?(r=this.startNodeAt(a,o),r.expressions=h,this.finishNodeAt(r,"SequenceExpression",A,b)):r=h[0]}else r=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(i,s);return w.expression=r,this.finishNode(w,"ParenthesizedExpression")}else return r};S.parseParenItem=function(e){return e};S.parseParenArrowList=function(e,t,i,s){return this.parseArrowExpression(this.startNodeAt(e,t),i,!1,s)};var ln=[];S.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===c.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var i=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var s=this.start,r=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),s,r,!0,!1),e.callee.type==="Super"&&this.raiseRecoverable(s,"Invalid use of 'super'"),this.eat(c.parenL)?e.arguments=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1):e.arguments=ln,this.finishNode(e,"NewExpression")};S.parseTemplateElement=function(e){var t=e.isTagged,i=this.startNode();return this.type===c.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,` 9`),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,` 10`),cooked:this.value},this.next(),i.tail=this.type===c.backQuote,this.finishNode(i,"TemplateElement")};S.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var i=this.startNode();this.next(),i.expressions=[];var s=this.parseTemplateElement({isTagged:t});for(i.quasis=[s];!s.tail;)this.type===c.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(c.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(c.braceR),i.quasis.push(s=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(i,"TemplateLiteral")};S.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===c.name||this.type===c.num||this.type===c.string||this.type===c.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===c.star)&&!U.test(this.input.slice(this.lastTokEnd,this.start))};S.parseObj=function(e,t){var i=this.startNode(),s=!0,r={};for(i.properties=[],this.next();!this.eat(c.braceR);){if(s)s=!1;else if(this.expect(c.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(c.braceR))break;var n=this.parseProperty(e,t);e||this.checkPropClash(n,r,t),i.properties.push(n)}return this.finishNode(i,e?"ObjectPattern":"ObjectExpression")};S.parseProperty=function(e,t){var i=this.startNode(),s,r,n,a;if(this.options.ecmaVersion>=9&&this.eat(c.ellipsis))return e?(i.argument=this.parseIdent(!1),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,t),this.type===c.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(e||t)&&(n=this.start,a=this.startLoc),e||(s=this.eat(c.star)));var o=this.containsEsc;return this.parsePropertyName(i),!e&&!o&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(i)?(r=!0,s=this.options.ecmaVersion>=9&&this.eat(c.star),this.parsePropertyName(i)):r=!1,this.parsePropertyValue(i,e,s,r,n,a,t,o),this.finishNode(i,"Property")};S.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var i=e.kind==="get"?0:1;if(e.value.params.length!==i){var s=e.value.start;e.kind==="get"?this.raiseRecoverable(s,"getter should have no params"):this.raiseRecoverable(s,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};S.parsePropertyValue=function(e,t,i,s,r,n,a,o){(i||s)&&this.type===c.colon&&this.unexpected(),this.eat(c.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===c.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(i,s),e.kind="init"):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==c.comma&&this.type!==c.braceR&&this.type!==c.eq?((i||s)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((i||s)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=r),t?e.value=this.parseMaybeDefault(r,n,this.copyNode(e.key)):this.type===c.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(r,n,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};S.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(c.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(c.bracketR),e.key;e.computed=!1}return e.key=this.type===c.num||this.type===c.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};S.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};S.parseMethod=function(e,t,i){var s=this.startNode(),r=this.yieldPos,n=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=e),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ai(t,s.generator)|vt|(i?ns:0)),this.expect(c.parenL),s.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1,!0,!1),this.yieldPos=r,this.awaitPos=n,this.awaitIdentPos=a,this.finishNode(s,"FunctionExpression")};S.parseArrowExpression=function(e,t,i,s){var r=this.yieldPos,n=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(ai(i,!1)|ni),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,s),this.yieldPos=r,this.awaitPos=n,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")};S.parseFunctionBody=function(e,t,i,s){var r=t&&this.type!==c.braceL,n=this.strict,a=!1;if(r)e.body=this.parseMaybeAssign(s),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!n||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var h=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!n&&!a&&!t&&!i&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,hs),e.body=this.parseBlock(!1,void 0,a&&!n),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()};S.isSimpleParamList=function(e){for(var t=0,i=e;t<i.length;t+=1){var s=i[t];if(s.type!=="Identifier")return!1}return!0};S.checkParams=function(e,t){for(var i=Object.create(null),s=0,r=e.params;s<r.length;s+=1){var n=r[s];this.checkLValInnerPattern(n,oi,t?null:i)}};S.parseExprList=function(e,t,i,s){for(var r=[],n=!0;!this.eat(e);){if(n)n=!1;else if(this.expect(c.comma),t&&this.afterTrailingComma(e))break;var a=void 0;i&&this.type===c.comma?a=null:this.type===c.ellipsis?(a=this.parseSpread(s),s&&this.type===c.comma&&s.trailingComma<0&&(s.trailingComma=this.start)):a=this.parseMaybeAssign(!1,s),r.push(a)}return r};S.checkUnreserved=function(e){var t=e.start,i=e.end,s=e.name;if(this.inGenerator&&s==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&s==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&_t)&&s==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(s==="arguments"||s==="await")&&this.raise(t,"Cannot use "+s+" in class static initialization block"),this.keywords.test(s)&&this.raise(t,"Unexpected keyword '"+s+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,i).indexOf("\\")!==-1)){var r=this.strict?this.reservedWordsStrict:this.reservedWords;r.test(s)&&(!this.inAsync&&s==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+s+"' is reserved"))}};S.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};S.parseIdentNode=function(){var e=this.startNode();return this.type===c.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=c.name):this.unexpected(),e};S.parsePrivateIdent=function(){var e=this.startNode();return this.type===c.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.n
10ame+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};S.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===c.semi||this.canInsertSemicolon()||this.type!==c.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(c.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};S.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var ct=V.prototype;ct.raise=function(e,t){var i=is(this.input,e);t+=" ("+i.line+":"+i.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var s=new SyntaxError(t);throw s.pos=e,s.loc=i,s.raisedAt=this.pos,s};ct.raiseRecoverable=ct.raise;ct.curPosition=function(){if(this.options.locations)return new qe(this.curLine,this.pos-this.lineStart)};var de=V.prototype,un=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};de.enterScope=function(e){this.scopeStack.push(new un(e))};de.exitScope=function(){this.scopeStack.pop()};de.treatFunctionsAsVarInScope=function(e){return e.flags&ye||!this.inModule&&e.flags&_e};de.declareName=function(e,t,i){var s=!1;if(t===he){var r=this.currentScope();s=r.lexical.indexOf(e)>-1||r.functions.indexOf(e)>-1||r.var.indexOf(e)>-1,r.lexical.push(e),this.inModule&&r.flags&_e&&delete this.undefinedExports[e]}else if(t===cs){var n=this.currentScope();n.lexical.push(e)}else if(t===os){var a=this.currentScope();this.treatFunctionsAsVar?s=a.lexical.indexOf(e)>-1:s=a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var h=this.scopeStack[o];if(h.lexical.indexOf(e)>-1&&!(h.flags&rs&&h.lexical[0]===e)||!this.treatFunctionsAsVarInScope(h)&&h.functions.indexOf(e)>-1){s=!0;break}if(h.var.push(e),this.inModule&&h.flags&_e&&delete this.undefinedExports[e],h.flags&_t)break}s&&this.raiseRecoverable(i,"Identifier '"+e+"' has already been declared")};de.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};de.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};de.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(_t|Ke|we))return t}};de.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(_t|Ke|we)&&!(t.flags&ni))return t}};var wt=function(t,i,s){this.type="",this.start=i,this.end=0,t.options.locations&&(this.loc=new gt(t,s)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[i,0])},Ue=V.prototype;Ue.startNode=function(){return new wt(this,this.start,this.startLoc)};Ue.startNodeAt=function(e,t){return new wt(this,e,t)};function ps(e,t,i,s){return e.type=t,e.end=i,this.options.locations&&(e.loc.end=s),this.options.ranges&&(e.range[1]=i),e}Ue.finishNode=function(e,t){return ps.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Ue.finishNodeAt=function(e,t,i,s){return ps.call(this,e,t,i,s)};Ue.copyNode=function(e){var t=new wt(this,e.start,this.startLoc);for(var i in e)t[i]=e[i];return t};var pn="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",fs="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE L
10owercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",ds=fs+" Extended_Pictographic",ms=ds,gs=ms+" EBase EComp EMod EPres ExtPict",vs=gs,fn=vs,dn={9:fs,10:ds,11:ms,12:gs,13:vs,14:fn},mn="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",gn={9:"",10:"",11:"",12:"",13:"",14:mn},Ai="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",_s="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",ys=_s+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",ws=ys+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Ss=ws+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",bs=Ss+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",vn=bs+" "+pn,_n={9:_s,10:ys,11:ws,12:Ss,13:bs,14:vn},xs={};function yn(e){var t=xs[e]={binary:pe(dn[e]+" "+Ai),binaryOfStrings:pe(gn[e]),nonBinary:{General_Category:pe(Ai),Script:pe(_n[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Ye=0,Pt=[9,10,11,12,13,14];Ye<Pt.length;Ye+=1)Ci=Pt[Ye],yn(Ci);
10var Ci,Ye,Pt,v=V.prototype,ht=function(t,i){this.parent=t,this.base=i||this};ht.prototype.separatedFrom=function(t){for(var i=this;i;i=i.parent)for(var s=t;s;s=s.parent)if(i.base===s.base&&i!==s)return!0;return!1};ht.prototype.sibling=function(){return new ht(this.parent,this.base)};var re=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=xs[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};re.prototype.reset=function(t,i,s){var r=s.indexOf("v")!==-1,n=s.indexOf("u")!==-1;this.start=t|0,this.source=i+"",this.flags=s,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=n&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=n&&this.parser.options.ecmaVersion>=9)};re.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};re.prototype.at=function(t,i){i===void 0&&(i=!1);var s=this.source,r=s.length;if(t>=r)return-1;var n=s.charCodeAt(t);if(!(i||this.switchU)||n<=55295||n>=57344||t+1>=r)return n;var a=s.charCodeAt(t+1);return a>=56320&&a<=57343?(n<<10)+a-56613888:n};re.prototype.nextIndex=function(t,i){i===void 0&&(i=!1);var s=this.source,r=s.length;if(t>=r)return r;var n=s.charCodeAt(t),a;return!(i||this.switchU)||n<=55295||n>=57344||t+1>=r||(a=s.charCodeAt(t+1))<56320||a>57343?t+1:t+2};re.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};re.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};re.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};re.prototype.eat=function(t,i){return i===void 0&&(i=!1),this.current(i)===t?(this.advance(i),!0):!1};re.prototype.eatChars=function(t,i){i===void 0&&(i=!1);for(var s=this.pos,r=0,n=t;r<n.length;r+=1){var a=n[r],o=this.at(s,i);if(o===-1||o!==a)return!1;s=this.nextIndex(s,i)}return this.pos=s,!0};v.validateRegExpFlags=function(e){for(var t=e.validFlags,i=e.flags,s=!1,r=!1,n=0;n<i.length;n++){var a=i.charAt(n);t.indexOf(a)===-1&&this.raise(e.start,"Invalid regular expression flag"),i.indexOf(a,n+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),a==="u"&&(s=!0),a==="v"&&(r=!0)}this.options.ecmaVersion>=15&&s&&r&&this.raise(e.start,"Invalid regular expression flag")};function wn(e){for(var t in e)return!0;return!1}v.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&wn(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};v.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,i=e.backReferenceNames;t<i.length;t+=1){var s=i[t];e.groupNames[s]||e.raise("Invalid named capture referenced")}};v.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ht(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};v.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};v.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};v.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;
10if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!i,!0}return e.pos=t,!1};v.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};v.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};v.regexp_eatBracedQuantifier=function(e,t){var i=e.pos;if(e.eat(123)){var s=0,r=-1;if(this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue),e.eat(125)))return r!==-1&&r<s&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=i}return!1};v.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};v.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};v.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(e),s=e.eat(45);if(i||s){for(var r=0;r<i.length;r++){var n=i.charAt(r);i.indexOf(n,r+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(s){var a=this.regexp_eatModifiers(e);!i&&!a&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var h=a.charAt(o);(a.indexOf(h,o+1)>-1||i.indexOf(h)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};v.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};v.regexp_eatModifiers=function(e){for(var t="",i=0;(i=e.current())!==-1&&Sn(i);)t+=oe(i),e.advance();return t};function Sn(e){return e===105||e===109||e===115}v.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};v.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};v.regexp_eatSyntaxCharacter=function(e){var t=e.current();return ks(t)?(e.lastIntValue=t,e.advance(),!0):!1};function ks(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}v.regexp_eatPatternCharacters=function(e){for(var t=e.pos,i=0;(i=e.current())!==-1&&!ks(i);)e.advance();return e.pos!==t};v.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};v.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,i=e.groupNames[e.lastStringValue];if(i)if(t)for(var s=0,r=i;s<r.length;s+=1){var n=r[s];n.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(i||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};v.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};v.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=oe(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=oe(e.lastIntValue);return!0}return!1};v.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,s=e.current(i);return e.advance(i),s===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(s=e.lastIntValue),bn(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)};function bn(e){return se(e,!0)||e===36||e===95}v.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,s=e.current(i);return e.advance(i),s===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(s=e.lastIntValue),xn(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)};function xn(e){return fe(e,!0)||e===36||e===95||e===8204||e===8205}
10v.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};v.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var i=e.lastIntValue;if(e.switchU)return i>e.maxBackReference&&(e.maxBackReference=i),!0;if(i<=e.numCapturingParens)return!0;e.pos=t}return!1};v.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};v.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};v.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};v.regexp_eatZero=function(e){return e.current()===48&&!St(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};v.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};v.regexp_eatControlLetter=function(e){var t=e.current();return As(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function As(e){return e>=65&&e<=90||e>=97&&e<=122}v.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var i=e.pos,s=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var r=e.lastIntValue;if(s&&r>=55296&&r<=56319){var n=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=(r-55296)*1024+(a-56320)+65536,!0}e.pos=n,e.lastIntValue=r}return!0}if(s&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&kn(e.lastIntValue))return!0;s&&e.raise("Invalid unicode escape"),e.pos=i}return!1};function kn(e){return e>=0&&e<=1114111}v.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};v.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Cs=0,ce=1,J=2;v.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(An(t))return e.lastIntValue=-1,e.advance(),ce;var i=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((i=t===80)||t===112)){e.lastIntValue=-1,e.advance();var s;if(e.eat(123)&&(s=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return i&&s===J&&e.raise("Invalid property name"),s;e.raise("Invalid property name")}return Cs};function An(e){return e===100||e===68||e===115||e===83||e===119||e===87}v.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var i=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,i,s),ce}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,r)}return Cs};v.regexp_validateUnicodePropertyNameAndValue=function(e,t,i){Oe(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(i)||e.raise("Invalid property value")};v.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return ce;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return J;e.raise("Invalid property name")};v.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Es(t=e.current());)e.lastStringValue+=oe(t),e.advance();return e.lastStringValue!==""};function Es(e){return As(e)||e===95}v.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Cn(t=e.current());)e.lastStringValue+=oe(t),e.advance();return e.lastStringValue!==""};function Cn(e){return Es(e)||St(e)}v.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};
10v.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),i=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&i===J&&e.raise("Negated character class may contain strings"),!0}return!1};v.regexp_classContents=function(e){return e.current()===93?ce:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),ce)};v.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var i=e.lastIntValue;e.switchU&&(t===-1||i===-1)&&e.raise("Invalid character class"),t!==-1&&i!==-1&&t>i&&e.raise("Range out of order in character class")}}};v.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var i=e.current();(i===99||Os(i))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var s=e.current();return s!==93?(e.lastIntValue=s,e.advance(),!0):!1};v.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};v.regexp_classSetExpression=function(e){var t=ce,i;if(!this.regexp_eatClassSetRange(e))if(i=this.regexp_eatClassSetOperand(e)){i===J&&(t=J);for(var s=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(i=this.regexp_eatClassSetOperand(e))){i!==J&&(t=ce);continue}e.raise("Invalid character in character class")}if(s!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(s!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(i=this.regexp_eatClassSetOperand(e),!i)return t;i===J&&(t=J)}};v.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var i=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;return i!==-1&&s!==-1&&i>s&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};v.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?ce:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};v.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var i=e.eat(94),s=this.regexp_classContents(e);if(e.eat(93))return i&&s===J&&e.raise("Negated character class may contain strings"),s;e.pos=t}if(e.eat(92)){var r=this.regexp_eatCharacterClassEscape(e);if(r)return r;e.pos=t}return null};v.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var i=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return i}else e.raise("Invalid escape");e.pos=t}return null};v.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===J&&(t=J);return t};v.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?ce:J};v.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var i=e.current();return i<0||i===e.lookahead()&&En(i)||In(i)?!1:(e.advance(),e.lastIntValue=i,!0)};function En(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function In(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}v.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Rn(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Rn(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}v.regexp_eatClassControlLetter=function(e){var t=e.current();return St(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};v.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};v.regexp_eatDecimalDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;St(i=e.current());)e.lastIntValue=10*e.lastIntValue+(i-48),e.advance();return e.pos!==t};function St(e){return e>=48&&e<=57}v.regexp_eatHexDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;Is(i=e.current());)e.lastIntValue=16*e.lastIntValue+Rs(i),e.advance();return e.pos!==t};function Is(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Rs(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}v.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var i=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+i*8+e.lastIntValue:e.lastIntValue=t*8+i}else e.lastIntValue=t;return!0}return!1};v.regexp_eatOctalDigit=function(e){var t=e.current();return Os(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Os(e){return e>=48&&e<=55}v.regexp_eatFixedHexDigits=function(e,t){var i=e.pos;e.lastIntValue=0;for(var s=0;s<t;++s){var r=e.current();if(!Is(r))return e.pos=i,!1;e.lastIntValue=16*e.lastIntValue+Rs(r),e.advance()}return!0};var hi=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new gt(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])}
10,k=V.prototype;k.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new hi(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};k.getToken=function(){return this.next(),new hi(this)};typeof Symbol<"u"&&(k[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===c.eof,value:t}}}});k.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(c.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};k.readToken=function(e){return se(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};k.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var i=this.input.charCodeAt(e+1);return i<=56319||i>=57344?t:(t<<10)+i-56613888};k.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};k.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations)for(var s=void 0,r=t;(s=Zi(this.input,r,this.pos))>-1;)++this.curLine,r=this.lineStart=s;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,i),t,this.pos,e,this.curPosition())};k.skipLineComment=function(e){for(var t=this.pos,i=this.options.onComment&&this.curPosition(),s=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Re(s);)s=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,i,this.curPosition())};k.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&es.test(String.fromCharCode(e)))++this.pos;else break e}}};k.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=e,this.value=t,this.updateContext(i)};k.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(c.ellipsis)):(++this.pos,this.finishToken(c.dot))};k.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(c.assign,2):this.finishOp(c.slash,1)};k.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),i=1,s=e===42?c.star:c.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++i,s=c.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(c.assign,i+1):this.finishOp(s,i)};k.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(c.assign,3)}return this.finishOp(e===124?c.logicalOR:c.logicalAND,2)}return t===61?this.finishOp(c.assign,2):this.finishOp(e===124?c.bitwiseOR:c.bitwiseAND,1)};k.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(c.assign,2):this.finishOp(c.bitwiseXOR,1)};k.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||U.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(c.incDec,2):t===61?this.finishOp(c.assign,2):this.finishOp(c.plusMin,1)};k.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),i=1;return t===e?(i=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(c.assign,i+1):this.finishOp(c.bitShift,i)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(i=2),this.finishOp(c.relational,i))};k.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(c.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(c.arrow)):this.finishOp(e===61?c.eq:c.prefix,1)};k.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var i=this.input.charCodeAt(this.pos+2);
10if(i<48||i>57)return this.finishOp(c.questionDot,2)}if(t===63){if(e>=12){var s=this.input.charCodeAt(this.pos+2);if(s===61)return this.finishOp(c.assign,3)}return this.finishOp(c.coalesce,2)}}return this.finishOp(c.question,1)};k.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),se(t,!0)||t===92))return this.finishToken(c.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+oe(t)+"'")};k.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(c.parenL);case 41:return++this.pos,this.finishToken(c.parenR);case 59:return++this.pos,this.finishToken(c.semi);case 44:return++this.pos,this.finishToken(c.comma);case 91:return++this.pos,this.finishToken(c.bracketL);case 93:return++this.pos,this.finishToken(c.bracketR);case 123:return++this.pos,this.finishToken(c.braceL);case 125:return++this.pos,this.finishToken(c.braceR);case 58:return++this.pos,this.finishToken(c.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(c.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(c.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+oe(e)+"'")};k.finishOp=function(e,t){var i=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,i)};k.readRegexp=function(){for(var e,t,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(U.test(s)&&this.raise(i,"Unterminated regular expression"),e)e=!1;else{if(s==="[")t=!0;else if(s==="]"&&t)t=!1;else if(s==="/"&&!t)break;e=s==="\\"}++this.pos}var r=this.input.slice(i,this.pos);++this.pos;var n=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(n);var o=this.regexpState||(this.regexpState=new re(this));o.reset(i,r,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var h=null;try{h=new RegExp(r,a)}catch{}return this.finishToken(c.regexp,{pattern:r,flags:a,value:h})};k.readInt=function(e,t,i){for(var s=this.options.ecmaVersion>=12&&t===void 0,r=i&&this.input.charCodeAt(this.pos)===48,n=this.pos,a=0,o=0,h=0,l=t??1/0;h<l;++h,++this.pos){var p=this.input.charCodeAt(this.pos),u=void 0;if(s&&p===95){r&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),h===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=p;continue}if(p>=97?u=p-97+10:p>=65?u=p-65+10:p>=48&&p<=57?u=p-48:u=1/0,u>=e)break;o=p,a=a*e+u}return s&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===n||t!=null&&this.pos-n!==t?null:a};function On(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ps(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}k.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var i=this.readInt(e);return i==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=Ps(this.input.slice(t,this.pos)),++this.pos):se(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,i)};k.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var i=this.pos-t>=2&&this.input.charCodeAt(t)===48;i&&this.strict&&this.raise(t,"Invalid number");var s=this.input.charCodeAt(this.pos);if(!i&&!e&&this.options.ecmaVersion>=11&&s===110){var r=Ps(this.input.slice(t,this.pos));return++this.pos,se(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,r)}i&&/[89]/.test(this.input.slice(t,this.pos))&&(i=!1),s===46&&!i&&(++this.pos,this.readInt(10),s=this.input.charCodeAt(this.pos)),(s===69||s===101)&&!i&&(s=this.input.charCodeAt(++this.pos),(s===43||s===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),se(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n=On(this.input.slice(t,this.pos),i);return this.finishToken(c.num,n)};k.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else t=this.readHexChar(4);return t};k.readString=function(e){for(var t="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===e)break;s===92?(t+=this.input.slice(i,this.pos),t+=this.readEscapedChar(!1),i=this.pos):s===8232||s===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Re(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(i,this.pos++),this.finishToken(c.string,t)};var Fs={};k.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}
10catch(e){if(e===Fs)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};k.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Fs;this.raise(e,t)};k.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(i===96||i===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===c.template||this.type===c.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(c.dollarBraceL)):(++this.pos,this.finishToken(c.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(c.template,e));if(i===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Re(i)){switch(e+=this.input.slice(t,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=` 11`;break;default:e+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};k.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(c.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===` 12`&&++this.pos;case` 13`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};k.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return` 14`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return oe(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(s,8);return r>255&&(s=s.slice(0,-1),r=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),(s!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(r)}return Re(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};k.readHexChar=function(e){var t=this.pos,i=this.readInt(16,e);return i===null&&this.invalidStringToken(t,"Bad character escape sequence"),i};k.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,i=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var r=this.fullCharCodeAtPos();if(fe(r,s))this.pos+=r<=65535?1:2;else if(r===92){this.containsEsc=!0,e+=this.input.slice(i,this.pos);var n=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?se:fe)(a,s)||this.invalidStringToken(n,"Invalid Unicode escape"),e+=oe(a),i=this.pos}else break;t=!1}return e+this.input.slice(i,this.pos)};k.readWord=function(){var e=this.readWord1(),t=c.name;return this.keywords.test(e)&&(t=si[e]),this.finishToken(t,e)};var Pn="8.17.0";V.acorn={Parser:V,version:Pn,defaultOptions:Ut,Position:qe,SourceLocation:gt,getLineInfo:is,Node:wt,TokenType:E,tokTypes:c,keywordTypes:si,TokContext:Z,tokContexts:P,isIdentifierChar:fe,isIdentifierStart:se,Token:hi,isNewLine:Re,lineBreak:U,lineBreakG:Zr,nonASCIIwhitespace:es};var Fn=new Set(["at","concat","every","filter","find","findIndex","flat","flatMap","includes","indexOf","join","lastIndexOf","map","reduce","reduceRight","slice","some"]),Tn=new Set(["at","charAt","charCodeAt","codePointAt","concat","endsWith","includes","indexOf","lastIndexOf","padEnd","padStart","repeat","replace","replaceAll","slice","split","startsWith","substring","toLowerCase","toUpperCase","trim","trimEnd","trimStart"]),Na=new Set([...Fn,...Tn]),Dn="game-session-definition:v1",Ba=new TextEncoder().encode(`${Dn}\0`);function Ei(e,t){return(e<<t|e>>>32-t)>>>0}function Nn(e){if(!/^[0-9a-f]{32}
14$/.test(e))throw new f("logic_definition_invalid","seed128 must be 32 lowercase hex characters");let t=[Number.parseInt(e.slice(0,8),16)>>>0,Number.parseInt(e.slice(8,16),16)>>>0,Number.parseInt(e.slice(16,24),16)>>>0,Number.parseInt(e.slice(24,32),16)>>>0];if(t.every(i=>i===0))throw new f("logic_definition_invalid","seed128 cannot be all zero");return t}var Bn=class{#e;constructor(e){if(this.#e=typeof e=="string"?Nn(e):[...e],this.#e.every(t=>t===0))throw new f("logic_definition_invalid","xoshiro state cannot be all zero")}nextUint32(){let e=this.#e,t=Math.imul(Ei(Math.imul(e[1],5)>>>0,7),9)>>>0,i=e[1]<<9>>>0;return e[2]=(e[2]^e[0])>>>0,e[3]=(e[3]^e[1])>>>0,e[1]=(e[1]^e[2])>>>0,e[0]=(e[0]^e[3])>>>0,e[2]=(e[2]^i)>>>0,e[3]=Ei(e[3],11),t}next(){return this.nextUint32()/4294967296}snapshot(){return[...this.#e]}},Ln=["session.start","state.sync","event.enqueue","commit.applied","commit.rejected","writeback.applied","writeback.rejected","session.stop","worker.ready","event.dispatched","handler.started","handler.noop","handler.failed","result.commit","writeback.request","trace.step","worker.error"],Vn=/^sha256:[0-9a-f]{64}$/,Mn=/^(h|w):([1-9][0-9]*):([1-9][0-9]*)$/,jn=new Set(Ln);function Ts(e){let t=Mn.exec(e);if(!t)throw new f("logic_protocol_error","messageId is malformed");let i=Number(t[2]),s=Number(t[3]);if(!Number.isSafeInteger(i)||!Number.isSafeInteger(s))throw new f("logic_protocol_error","messageId exceeds safe integer range");return{sender:t[1],epoch:i,sequence:s}}function $n(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new f("logic_protocol_error","Worker message must be an object");let i=e;if(i.protocolVersion!==1||i.logicSessionId!==t.logicSessionId||i.definitionRef!==t.definitionRef||i.lifecycleEpoch!==t.lifecycleEpoch||typeof i.messageId!="string"||typeof i.kind!="string"||!jn.has(i.kind)||!Vn.test(t.definitionRef))throw new f("logic_protocol_error","Worker envelope identity mismatch");let s=Ts(i.messageId);if(s.sender!==t.sender||s.epoch!==t.lifecycleEpoch)throw new f("logic_protocol_error","Worker messageId identity mismatch");return i}var qn=class{#e=0;#t=new Map;accept(e,t){if(!Number.isSafeInteger(e)||e<=0||t.length===0)throw new f("logic_protocol_error","Invalid message sequence or digest");if(e===this.#e+1){for(this.#e=e,this.#t.set(e,t);this.#t.size>x.maxSeenMessageIds;)this.#t.delete(this.#t.keys().next().value);return"accepted"}if(e>this.#e+1)throw new f("logic_protocol_error","Worker message sequence has a gap");let i=this.#t.get(e);if(i===void 0)return"stale";if(i!==t)throw new f("logic_protocol_error","Duplicate messageId has different content");return"duplicate"}get highWater(){return this.#e}};function Kn(e){for(let t=e;t;t=Object.getPrototypeOf(t))if(Object.prototype.hasOwnProperty.call(t,"then"))return!0;return!1}function Xe(e,t,i){let s=new Set(t),r=Object.keys(e).find(n=>!s.has(n));if(r)throw new f("logic_result_invalid",`${i}.${r} is not allowed`,`${i}.${r}`)}function Ds(e,t){if(e==null)return null;if(typeof e=="object"&&Kn(e))throw new f("logic_handler_async_result","Logic handler returned a thenable");let i=T(e,"result");if(!L(i))throw new f("logic_result_invalid","Logic handler result must be an object");if(Ce(i).byteLength>x.maxHandlerResultUtf8Bytes)throw new f("logic_result_invalid","Logic handler result exceeds 128 KiB");Xe(i,["patches","catalogOps","emits","schedule"],"result");let s={};if(i.patches!==void 0){if(!Array.isArray(i.patches))throw new f("logic_result_invalid","result.patches must be an array");s.patches=i.patches.map((r,n)=>{if(!L(r))throw new f("logic_result_invalid",`result.patches[${n}] must be an object`);Xe(r,["path","value","delete"],`result.patches[${n}]`);let a=Ae(r.path,`result.patches[${n}].path`),o=Object.prototype.hasOwnProperty.call(r,"value");if(r.delete===!0===o||r.delete!==void 0&&r.delete!==!0)throw new f("logic_result_invalid",`result.patches[${n}] must specify value xor delete`);return r.delete===!0?{path:a,delete:!0}:{path:a,value:r.value}})}if(i.catalogOps!==void 0&&(s.catalogOps=Hr(i.catalogOps,t)),i.emits!==void 0){if(!Array.isArray(i.emits)||i.emits.length>x.maxEmittedEventsPerHandler)throw new f("logic_result_invalid","result.emits exceeds limits");s.emits=i.emits.map((r,n)=>{if(!L(r))throw new f("logic_result_invalid",`result.emits[${n}] must be an object`);Xe(r,["type","payload"],`result.emits[${n}]`);let a=Ee(r.type,`result.emits[${n}].type`);if(a.startsWith("runtime.")||!t.params.emits.includes(a))throw new f("logic_result_invalid",`${a} is not declared in emits`);if(!Object.prototype.hasOwnProperty.call(r,"payload"))throw new f("logic_result_invalid",`result.emits[${n}].payload is required`);if(Ce(r.payload).byteLength>x.maxEventPayloadUtf8Bytes)throw new f("logic_result_invalid",`result.emits[${n}] payload exceeds limits`);return{type:a,payload:r.payload}})}if(i.schedule!==void 0){if(!Array.isArray(i.schedule)||i.schedule.length>x.maxScheduledEventsPerHandler)throw new f("logic_schedule_invalid","result.schedule exceeds limits");s.schedule=i.schedule.map((r,n)=>{if(!L(r))throw new f("logic_schedule_invalid",`result.schedule[${n}] must be an object`);Xe(r,["type","payload","delayMs"],`result.schedule[${n}]`);let a=Ee(r.type,`result.schedule[${n}].type`);if(a.startsWith("runtime.")||!t.params.emits.includes(a))throw new f("logic_schedule_invalid",`${a} is not declared in emits`);if(!Object.prototype.hasOwnProperty.call(r,"payload"))throw new f("logic_schedule_invalid",`result.schedule[${n}].payload is required`);if(!Number.isInteger(r.delayMs)||Number(r.delayMs)<0||Number(r.delayMs)>x.maxScheduleDelayMs)throw new f("logic_schedule_invalid",`result.schedule[${n}
14].delayMs is invalid`);if(Ce(r.payload).byteLength>x.maxEventPayloadUtf8Bytes)throw new f("logic_schedule_invalid",`result.schedule[${n}] payload exceeds limits`);return{type:a,payload:r.payload,delayMs:Number(r.delayMs)}})}return s}function ve(e,t){if(t===null)return!1;switch(e){case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"array":return Array.isArray(t);case"object":return typeof t=="object"&&!Array.isArray(t);case"WxH":return typeof t=="string"&&/^\d+x\d+$/.test(t);case"hex-color":return typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t);case"iso-date":return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}T/.test(t)}}function zt(e,t){return e.length<=t.length&&e.every((i,s)=>i===t[s])}function Ns(e,t){let i=ee(e);return t.some(s=>zt(ee(s),i))}function Ii(e,t,i){if(!Ns(t,i))throw new f("logic_read_denied",`${t} is not declared in reads`,t);let s=ee(t),r=e[s[0]];for(let n of s.slice(1)){if(r==null||typeof r!="object")return null;if(typeof n=="number"){if(!Array.isArray(r)||n>=r.length)return null;r=r[n]}else{if(Array.isArray(r)||!Object.prototype.hasOwnProperty.call(r,n))return null;r=r[n]}}return r===void 0?null:T(r,t)}function Un(e){for(let t=0;t<e.length;t+=1)for(let i=t+1;i<e.length;i+=1)if(zt(e[t],e[i])||zt(e[i],e[t]))throw new f("logic_result_invalid","Patch paths overlap")}function Wn(e,t,i,s){let r=T(e,s),n=r;for(let o=0;o<t.length-1;o+=1){let h=t[o],l=t[o+1];if(typeof h=="number"){if(!Array.isArray(n)||h>=n.length)throw new f("logic_result_invalid",`${s} has a missing array container`,s);let p=n[h];if(p===null||typeof p!="object"||typeof l=="number"!==Array.isArray(p))throw new f("logic_result_invalid",`${s} has an incompatible container`,s);n=p}else{if(Array.isArray(n)||n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,h))throw new f("logic_result_invalid",`${s} has a missing object container`,s);let p=n[h];if(p===null||typeof p!="object"||typeof l=="number"!==Array.isArray(p))throw new f("logic_result_invalid",`${s} has an incompatible container`,s);n=p}}let a=t[t.length-1];if(typeof a=="number"){if(!Array.isArray(n)||a>=n.length)throw new f("logic_result_invalid",`${s} cannot grow an array`,s);i.delete===!0?n.splice(a,1):n[a]=T(i.value,s)}else{if(Array.isArray(n)||n===null||typeof n!="object")throw new f("logic_result_invalid",`${s} has an incompatible object`,s);i.delete===!0?delete n[a]:n[a]=T(i.value,s)}return r}function Bs(e){let t=e.patches.map((n,a)=>
14{if(!n||typeof n!="object"||Array.isArray(n))throw new f("logic_result_invalid",`patches[${a}] must be an object`);let o=Ae(n.path,`patches[${a}].path`),h=Object.prototype.hasOwnProperty.call(n,"value");if(n.delete===!0===h||n.delete!==void 0&&n.delete!==!0)throw new f("logic_result_invalid",`patches[${a}] must specify exactly value or delete`);if(!Ns(o,e.writes))throw new f("logic_write_denied",`${o} is not declared in writes`,o);return{patch:n,path:o,segments:ee(o)}});Un(t.map(({segments:n})=>n));let i=null,s=Object.create(null),r=[];for(let{patch:n,path:a,segments:o}of t){let h=o[0],l=e.schema[h];if(!l)throw new f("logic_write_denied",`${h} is absent from gameStateSchema`,a);if(l.scope==="serverOnly")throw new f("logic_scope_denied",`${h} is serverOnly`,a);if(i!==null&&i!==l.scope)throw new f("logic_scope_denied","A result cannot mix clientOnly and serverMirror patches");i=l.scope;let p;if(o.length===1)n.delete!==!0&&(p=T(n.value,a));else{let d=Object.prototype.hasOwnProperty.call(s,h)?s[h]:e.currentState[h];if(d==null||typeof d!="object")throw new f("logic_result_invalid",`${a} has no top-level container`,a);p=Wn(d,o.slice(1),n,a)}if(p===void 0){delete s[h],r.includes(h)||r.push(h);continue}if(!ve(l.type,p))throw new f("logic_type_mismatch",`${h} does not match ${l.type}`,a);let u=r.indexOf(h);u>=0&&r.splice(u,1),s[h]=p}return r.sort(),{scope:i,updates:s,removedKeys:r}}var Hn=["logic_definition_invalid","logic_source_invalid","logic_handler_timeout","logic_handler_failed","logic_handler_async_result","logic_result_invalid","logic_schedule_invalid","logic_read_denied","logic_write_denied","logic_scope_denied","logic_type_mismatch","logic_state_conflict","logic_catalog_conflict","logic_catalog_access_denied","logic_catalog_invalid","logic_queue_overflow","logic_protocol_error","logic_definition_mismatch","logic_lifecycle_stale","logic_trust_denied","logic_writeback_rejected","logic_writeback_unknown","logic_persistence_binding_invalid","logic_state_migration_required","logic_schema_migration_required","logic_undeclared_persisted_key","logic_screen_write_denied","logic_state_sync_invalid","logic_preview_mode_incompatible","logic_profile_capability_unsupported","logic_writer_conflict","logic_decommission_required","logic_decommission_in_progress","logic_post_writeback_unsupported","logic_sse_frame_truncated","logic_runtime_unavailable"];function ke(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new f("logic_protocol_error",`${t} must be an object`);return e}function Ft(e){if(typeof e!="string"||!/^[1-9][0-9]*$/.test(e)||!Number.isSafeInteger(Number(e)))throw new f("logic_protocol_error","requestId is invali
14d");return e}var zn=new Set(Hn);function Ri(e){if(typeof e!="string"||!zn.has(e))throw new f("logic_protocol_error","errorCode is invalid");return e}function Gn(e,t){let i=new URL(t),s=new URL(e,i);if(s.origin!==i.origin||!/^\/assets\/logic-runtime-worker\.v2\.[A-Za-z0-9_-]+\.js$/.test(s.pathname)||s.search!==""||s.hash!==""||!["http:","https:"].includes(s.protocol))throw new f("logic_runtime_unavailable","Worker URL is not a trusted build asset");return s.href}function Oi(e){let t=T(e,"logic.state");if(!L(t))throw new f("logic_state_sync_invalid","Logic state must be an object");return t}var Jn=class{#e;#t;#i=new qn;#a=new Map;#r;#s;#o=new Map;#n=new Map;#g=new Map;#R=new Map;#w=new Set;#S=e=>this.#F(e.data);#y=()=>this.#p("logic_handler_failed");#l;#d;#C=Promise.resolve();#k=0;#h=0;#O=0;#_=!1;#$;#b=!1;constructor(e){this.#e=e,this.#r=ii(e.definition.gameStateSchema),this.#s=e.stateStore;for(let[a,o]of Object.entries(e.initialCatalog??{})){let h=T(o.value,"logic.catalog."+a);if(!L(h)||!/^(0|[1-9][0-9]*)$/.test(o.version))throw new f("logic_catalog_invalid","Initial catalog snapshot is invalid: "+a);this.#o.set(a,o.version)}let t=Oi(e.stateStore.readableSnapshot());for(let[a,o]of Object.entries(t)){let h=this.#r[a];if(!h||h.scope==="serverOnly"||!ve(h.type,o))throw new f("logic_state_sync_invalid",`Initial readable state key ${a} is invalid`)}if(!Number.isSafeInteger(e.lifecycleEpoch)||e.lifecycleEpoch<=0||!Number.isSafeInteger(e.stateStore.revision)||e.stateStore.revision<0)throw new f("logic_protocol_error","Logic session counters are invalid");for(let[a,o]of e.definition.rootNodes.entries()){if(o.type!=="logic"||o.disabled===!0)continue;let h=Ji(o,`definition.rootNodes[${a}]`);this.#a.set(h.id,h)}let i=[...new Set([...this.#a.values()].flatMap(a=>[...a.params.catalogReads,...a.params.catalogWrites].map(o=>String(ee(o)[0]))))].sort(),s=[...this.#o.keys()].sort();if(i.length!==s.length||i.some((a,o)=>a!==s[o]))throw new f("logic_definition_mismatch","Initial catalog snapshots do not match declared Logic aliases");let r=Gn(e.workerUrl,e.expectedWorkerOrigin);this.#t=e.createWorker(r),this.#t.addEventListener("message",this.#S),this.#t.addEventListener("error",this.#y),this.#t.addEventListener("messageerror",this.#y),this.#l=e.activity.subscribe(a=>this.#f(a)),this.#d=e.stateStore.subscribe(a=>this.#E(a)),this.#$=e.setTimer(()=>this.#p("logic_runtime_unavailable"),x.workerReadyTimeoutMs);let n={definition:e.definition,readableState:t,initialCatalog:e.initialCatalog??{},stateRevision:e.stateStore.revision,seed128:e.seed128,clockProfileVersion:1,schedulerProfileVersion:1,limitProfile:x};this.#L("session.start",n,x.maxSessionStartMessageUtf8Bytes)}get ready(){return this.#_}get stopped(){return this.#b}get stateRevision(){return this.#s.revision}get serverStorageVersion(){return this.#s.serverStorageVersion??""}get hasPendingRequests(){return this.#n.size>0}get state(){return Oi(this.#s.readableSnapshot())}enqueue(e){this.dispatch(e).then(t=>{["applied","noop"].includes(t.aggregate)||this.#e.onDiagnostic?.(t.aggregate==="conflict"?"logic_state_conflict":"logic_runtime_unavailable",{dispatchId:t.dispatchId,aggregate:t.aggregate})})}dispatch(e){if(this.#b||!this.#_)throw new f("logic_runtime_unavailable","Logic Worker is not ready");let t=Ee(e.type);if(e.source==="screen"&&t.startsWith("runtime."))throw new f("logic_protocol_error","Screen cannot emit runtime events");let i=T(e.payload,"event.payload");if(this.#O+=1,!Number.isSafeInteger(this.#O))throw new f("logic_protocol_error","Dispatch sequence overflow");let s=`d:${this.#e.lifecycleEpoch}:${this.#O}`,r=this.#s.revision;return new Promise(n=>{let a={dispatchId:s,minimumStateRevision:r,resolve:n,handlers:[],settled:!1};a.timer=this.#e.setTimer(()=>{a.settled||(this.#m(a,"unavailable"),this.#p("logic_runtime_unavailable"))},x.workerReadyTimeoutMs),this.#g.set(s,a);try{this.#L("event.enqueue",{type:t,payload:i,source:e.source,dispatchId:s,minimumStateRevision:r})}catch{this.#m(a,"unavailable"),this.#p("logic_protocol_error")}})}syncState(e,t,i){this.#b||this.#s.commit(g({commitId:`backend:${this.#s.revision+1}`,origin:"backend_sync",baseRevision:this.#s.revision,updates:e,removedKeys:t},i!==void 0?{serverStorageVersion:i}:{}))}replaceState(e,t){this.#b||this.#s.replace(e,"recovery",`recovery:${this.#s.revision+1}`,t)}#E(e){if(this.#b||!e.changed||this.#w.delete(e.commitId))return;let t={};for(let[s,r]of Object.entries(e.updates))this.#r[s]?.scope!=="serverOnly"&&(t[s]=r);let i=e.removedKeys.filter(s=>this.#r[s]?.scope!=="serverOnly");this.#L("state.sync",{stateRevision:e.stateRevision,updates:t,removedKeys:i})}stop(e="session_stop"){if(!this.#b){try{this.#L("session.stop",{reason:e})}catch{}this.#ie()}}#F(e){this.#b||(this.#C=this.#C.then(()=>this.#K(e)).catch(t=>{this.#p(t instanceof f?t.code:"logic_protocol_error")}))}async#K(e){let t=$n(e,{logicSessionId:this.#e.logicSessionId,definitionRef:this.#e.definitionRef,lifecycleEpoch:this.#e.lifecycleEpoch,sender:"w"});if(Ce(t).byteLength>x.maxWorkerMessageUtf8Bytes)throw new f("logic_protocol_error","Worker response exceeds limit");let i=Ts(t.messageId).sequence,s=await this.#e.digest($e({kind:t.kind,payload:t.payload}));if(this.#i.accept(i,s)==="accepted")switch(t.kind){case"worker.ready":{let r=ke(t.payload,"worker.ready");if(r.runtimeProfileVersion!==1||r.limitProfileVersion!==1)throw new f("logic_definition_mismatch","Worker profile mismatch");if(this.#_||this.#n.size>0)throw new f("logic_protocol_error","Duplicate Worker ready");this.#_=!0,this.#c(this.#$),this.#$=void 0,this.#e.onReady?.();return}case"event.dispatched":this.#j(t.payload);return;case"handler.started":this.#z(t.payload);return;case"handler.noop":case"handler.failed":this.#U(t.kind,t.payload);return;case"result.commit":case"writeback.request":await this.#D(t.kind,t.payload);return;case"trace.step":this.#e.onTrace?.(t.payload);return;case"worker.error":this.#p(Ri(ke(t.payload,"worker.error").errorCode));return;default:throw new f("logic_protocol_error",`Worker cannot send ${t.kind}`)}}#j(e){if(!this.#_)throw new f("logic_protocol_error","Event dispatched before Worker ready");let t=ke(e,"event.dispatched");
14if(typeof t.dispatchId!="string"||typeof t.eventId!="string"||!Array.isArray(t.handlers)||!Number.isSafeInteger(t.stateRevision))throw new f("logic_protocol_error","Dispatched event payload is invalid");let i=this.#g.get(t.dispatchId);if(!i||i.eventId!==void 0)throw new f("logic_protocol_error","Dispatch correlation is invalid");if(t.stateRevision<i.minimumStateRevision||t.stateRevision>this.#s.revision)throw new f("logic_protocol_error","Event crossed the revision barrier incorrectly");i.eventId=t.eventId,this.#c(i.timer),i.timer=void 0,i.handlers=t.handlers.map(s=>{if(!s||typeof s.requestId!="string"||typeof s.nodeId!="string"||!this.#a.has(s.nodeId)||this.#R.has(s.requestId))throw new f("logic_protocol_error","Dispatched handler identity is invalid");return this.#R.set(s.requestId,i),{requestId:s.requestId,nodeId:s.nodeId}}),i.handlers.length===0&&this.#m(i,"noop")}#z(e){if(!this.#_)throw new f("logic_protocol_error","Handler started before Worker ready");let t=ke(e,"handler.started"),i=Ft(t.requestId),s=Number(i);if(s!==this.#h+1||this.#n.has(i))throw new f("logic_protocol_error","Worker request sequence is invalid");if(typeof t.nodeId!="string"||!this.#a.has(t.nodeId)||typeof t.eventId!="string")throw new f("logic_protocol_error","Handler identity is invali
14d");let r=this.#R.get(i),n=r?.handlers.find(h=>h.requestId===i),a=t.baseStateRevision;if(!r||!n||n.nodeId!==t.nodeId||r.eventId!==t.eventId||!Number.isSafeInteger(a)||a<r.minimumStateRevision||a>this.#s.revision)throw new f("logic_protocol_error","Handler began from an unexpected state revision");this.#h=s;let o={requestId:i,nodeId:t.nodeId,eventId:t.eventId,baseStateRevision:a,phase:"worker",budgetRemainingMs:x.workerResultForegroundDeadlineMs,deliveryRemainingMs:x.deadlineDeliveryGraceMs,dispatchId:r.dispatchId};this.#n.set(i,o),this.#e.activity.isForeground()&&this.#P(o)}#U(e,t){let i=ke(t,e),s=this.#x(Ft(i.requestId)),r=e==="handler.failed"?"failed":"noop",n=e==="handler.failed"?{errorCode:Ri(i.errorCode)}:void 0;this.#u(s),this.#n.delete(s.requestId),this.#N(s.requestId,r,n)}async#D(e,t){let i=ke(t,e),s=this.#x(Ft(i.requestId));if(i.nodeId!==s.nodeId||i.eventId!==s.eventId||i.baseStateRevision!==s.baseStateRevision)throw new f("logic_protocol_error","Worker result identity mismatch");this.#u(s),s.phase="host_outcome",s.resultKind=e==="result.commit"?"commit":"writeback";let r=this.#a.get(s.nodeId),n,a=[];try{if(n=Ds(i.result,r),!n)throw new f("logic_result_invalid","Non-empty Worker result is required");a=[...new Set((n.catalogOps??[]).map(l=>String(ee(l.path)[0])))].sort();for(let l of a)if(!this.#o.has(l))throw new f("logic_catalog_access_denied","Catalog alias is not bound: "+l);if(s.baseStateRevision!==this.#s.revision)throw new f("logic_state_conflict","State changed while handler was running");let o=Bs({patches:n.patches??[],writes:r.params.writes,schema:this.#r,currentState:this.#s.readableSnapshot()}),h=(n.catalogOps?.length??0)>0;if(e==="result.commit"){if(o.scope==="serverMirror"||a.length>0)throw new f("logic_scope_denied","serverMirror and catalog operations require writeback");let l=`logic:${s.requestId}`;this.#w.add(l);let p;try{p=this.#s.commit({commitId:l,origin:"logic",baseRevision:s.baseStateRevision,updates:o.updates,removedKeys:o.removedKeys})}finally{this.#w.delete(l)}this.#L("commit.applied",{requestId:s.requestId,stateRevision:p.stateRevision,updates:p.updates,removedKeys:p.removedKeys}),this.#n.delete(s.requestId),this.#N(s.requestId,p.changed||(n.emits?.length??0)>0||(n.schedule?.length??0)>0?"applied":"noop");return}if(o.scope!=="serverMirror"&&a.length===0)throw new f("logic_scope_denied","Writeback requires serverMirror patches or catalog operations");if(o.scope==="serverMirror"&&((n.emits?.length??0)>0||(n.schedule?.length??0)>0))throw new f("logic_scope_denied","serverMirror writeback cannot emit or schedule events")}catch(o){let h=o instanceof f?o.code:"logic_result_invalid",l=o instanceof f?o.message:"Logic result validation failed";this.#L(e==="result.commit"?"commit.rejected":"writeback.rejected",F(g({},e==="writeback.request"?{rejectionKind:"host_validation"}:{}),{requestId:s.requestId,errorCode:h,stateRevision:this.#s.revision})),this.#n.delete(s.requestId),this.#N(s.requestId,h==="logic_state_conflict"||h==="logic_catalog_conflict"?"conflict":"rejected",F(g({errorCode:h},e==="writeback.request"?{rejectionKind:"host_validation"}:{}),{message:l}));return}s.writebackTimer=this.#e.setTimer(()=>{this.#N(s.requestId,"unknown_persistence"),this.#p("logic_writeback_unknown")},x.writebackTimeoutMs);try{let o=this.#s.revision,h=this.#s.serverStorageVersion??"",l=await this.#e.writeback({logicSessionId:this.#e.logicSessionId,definitionRef:this.#e.definitionRef,lifecycleEpoch:this.#e.lifecycleEpoch,requestId:s.requestId,nodeId:s.nodeId,expectedServerStorageVersion:h,patches:n.patches??[],catalogOps:n.catalogOps??[],expectedCatalogVersions:Object.fromEntries(a.map(p=>[p,this.#o.get(p)]))});if(this.#b||this.#n.get(s.requestId)!==s)return;if(this.#c(s.writebackTimer),s.writebackTimer=void 0,l.status==="applied"||l.rejectionKind==="backend_ledgered"){let p=l.catalog??{},u=Object.keys(p).sort();if(u.length!==a.length||u.some((D,q)=>D!==a[q])){this.#N(s.requestId,"unknown_persistence"),this.#p("logic_protocol_error");return}for(let[D,q]of Object.entries(p)){if(!this.#o.has(D)||!/^(0|[1-9][0-9]*)$/.test(q.version)){this.#N(s.requestId,"unknown_persistence"),this.#p("logic_protocol_error");return}this.#o.set(D,q.version)}let d=this.#s.serverStorageVersion??"",m=new Set(l.removedKeys),A=!(l.status==="rejected"&&l.serverStorageVersion!==h)||Object.keys(this.#r).every(D=>Object.prototype.hasOwnProperty.call(l.updates,D)||m.has(D)),b=this.#s.revision===o&&d===h||d===l.serverStorageVersion,w=A&&b,I=this.#s.revision,$={},W=[];if(w){let D=`writeback:${s.requestId}:${l.operationId}`;this.#w.add(D);let q;try{q=this.#s.commit({commitId:D,origin:"backend_sync",baseRevision:this.#s.revision,updates:l.updates,removedKeys:l.removedKeys,serverStorageVersion:l.serverStorageVersion})}finally{this.#w.delete(D)}I=q.stateRevision,$=q.updates,W=q.removedKeys}let le={};for(let[D,q]of Object.entries($))this.#r[D]?.scope!=="serverOnly"&&(le[D]=q);let He=W.filter(D=>this.#r[D]?.scope!=="serverOnly");this.#L(l.status==="applied"?"writeback.applied":"writeback.rejected",F(g({},l.status==="rejected"?{rejectionKind:"backend_ledgered",errorCode:l.errorCode}:{}),{requestId:s.requestId,operationId:l.operationId,stateRevision:I,updates:le,removedKeys:He,serverStorageVersion:w?l.serverStorageVersion:d,catalog:p})),this.#N(s.requestId,l.status==="applied"?"applied":l.errorCode==="logic_catalog_conflict"||l.errorCode==="logic_state_conflict"?"conflict":"rejected",l.status==="rejected"?{errorCode:l.errorCode,rejectionKind:"backend_ledgered"}:void 0)}else this.#L("writeback.rejected",{rejectionKind:l.rejectionKind,requestId:s.requestId,errorCode:l.errorCode,stateRevision:this.#s.revision}),this.#N(s.requestId,"rejected",{errorCode:l.errorCode,rejectionKind:l.rejectionKind});this.#n.delete(s.requestId)}catch{!this.#b&&this.#n.get(s.requestId)===s&&(this.#c(s.writebackTimer),this.#L("writeback.rejected",{rejectionKind:"backend_pre_ledger",requestId:s.requestId,errorCode:"logic_writeback_rejected",stateRevision:this.#s.revision}),this.#n.delete(s.requestId),this.#N(s.requestId,"rejected",{errorCode:"logic_writeback_rejected",rejectionKind:"backend_pre_ledger"}))}}#x(e){let t=this.#n.get(e);if(!t||t.phase!=="worker")throw new f("logic_protocol_error","Worker request state is invali
14d");return t}#N(e,t,i){let s=this.#R.get(e);if(!s||s.settled)return;let r=s.handlers.find(n=>n.requestId===e);if(!r||r.status!==void 0)throw new f("logic_protocol_error","Handler outcome correlation is invalid");r.status=t,i&&(r.diagnostic=i),this.#R.delete(e),s.handlers.every(n=>n.status!==void 0)&&this.#m(s)}#m(e,t){if(e.settled)return;e.settled=!0,this.#c(e.timer),this.#g.delete(e.dispatchId);for(let r of e.handlers)this.#R.delete(r.requestId);let i=e.handlers.map(r=>r.status??(t==="cancelled"?"cancelled":t==="unavailable"?"unavailable":"failed")),s=t;s||(i.every(r=>r==="noop")?s="noop":i.every(r=>r==="applied"||r==="noop")?s="applied":i.length>0&&i.every(r=>r===i[0])?s=i[0]:s="partial"),e.resolve({dispatchId:e.dispatchId,aggregate:s,perNode:e.handlers.map((r,n)=>g({nodeId:r.nodeId,status:i[n],requestId:r.requestId},r.diagnostic))})}#L(e,t,i=x.maxWorkerMessageUtf8Bytes){if(this.#b)return;if(this.#k+=1,!Number.isSafeInteger(this.#k))throw new f("logic_protocol_error","Host message sequence overflow");let s={protocolVersion:1,logicSessionId:this.#e.logicSessionId,definitionRef:this.#e.definitionRef,lifecycleEpoch:this.#e.lifecycleEpoch,messageId:`h:${this.#e.lifecycleEpoch}:${this.#k}`,kind:e,payload:t};if(Ce(s).byteLength>i)throw new f("logic_protocol_error","Host message exceeds limit");this.#t.postMessage(s)}#P(e){if(this.#b||e.phase!=="worker")return;e.activeSinceMs=this.#e.nowMs();let t=e.budgetRemainingMs>0?e.budgetRemainingMs:e.deliveryRemainingMs;e.timer=this.#e.setTimer(()=>{e.timer=void 0,e.activeSinceMs=void 0,e.budgetRemainingMs>0?(e.budgetRemainingMs=0,this.#P(e)):(e.deliveryRemainingMs=0,this.#p("logic_handler_timeout"))},t)}#f(e){if(!this.#b)for(let t of this.#n.values())t.phase==="worker"&&(e?t.resumeTimer===void 0&&(t.resumeTimer=this.#e.setTimer(()=>{t.resumeTimer=void 0,this.#e.activity.isForeground()&&this.#P(t)},x.resumeGraceMs)):this.#I(t))}#I(e){if(e.resumeTimer!==void 0&&(this.#c(e.resumeTimer),e.resumeTimer=void 0),e.timer===void 0||e.activeSinceMs===void 0)return;let t=Math.max(0,this.#e.nowMs()-e.activeSinceMs);e.budgetRemainingMs>0?e.budgetRemainingMs=Math.max(0,e.budgetRemainingMs-t):e.deliveryRemainingMs=Math.max(0,e.deliveryRemainingMs-t),this.#c(e.timer),e.timer=void 0,e.activeSinceMs=void 0}#u(e){this.#c(e.timer),this.#c(e.resumeTimer),e.timer=void 0,e.resumeTimer=void 0,e.activeSinceMs=void 0}#c(e){e!==void 0&&this.#e.clearTimer(e)}#p(e){this.#b||(this.#e.onFatal?.(e),this.#ie())}#ie(){if(!this.#b){this.#b=!0,this.#c(this.#$);for(let e of this.#n.values())this.#u(e),this.#c(e.writebackTimer);this.#n.clear();for(let e of[...this.#g.values()])this.#m(e,"cancelled");this.#R.clear(),this.#l(),this.#d(),this.#t.removeEventListener("message",this.#S),this.#t.removeEventListener("error",this.#y),this.#t.removeEventListener("messageerror",this.#y),this.#t.terminate()}}},Ls,O,Vs,Ms,ue,Pi,js,$s,Tt,st,Le,qs,li,Gt,Jt,Qn,Ks={},lt=[],Yn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,bt=Array.isArray;function ne(e,t){for(var i in t)e[i]=t[i];return e}function ui(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Dt(e,t,i,s,r){var n={type:e,props:t,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Vs,__i:-1,__u:0};return r==null&&O.vnode!=null&&O.vnode(n),n}function xt(e){return e.children}function Ve(e,t){this.props=e,this.context=t}function Ie(e,t){if(t==null)return e.__?Ie(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if((i=e.__k[t])!=null&&i.__e!=null)return i.__e;return typeof e.type=="function"?Ie(e):null}function Xn(e){if(e.__P&&e.__d){var t=e.__v,i=t.__e,s=[],r=[],n=ne({},t);n.__v=t.__v+1,O.vnode&&O.vnode(n),zs(e.__P,n,t,e.__n,e.__P.namespaceURI,32&t.__u?[i]:null,s,i??Ie(t),!!(32&t.__u),r),n.__v=t.__v,n.__.__k[n.__i]=n,ta(s,n,r),t.__e=t.__=null,n.__e!=i&&Us(n)}}function Us(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Us(e)}function Fi(e){(!e.__d&&(e.__d=!0)&&ue.push(e)&&!ut.__r++||Pi!=O.debounceRendering)&&((Pi=O.debounceRendering)||js)(ut)}function ut(){try{for(var e,t=1;ue.length;)ue.length>t&&ue.sort($s),e=ue.shift(),t=ue.length,Xn(e)}finally{ue.length=ut.__r=0}}function Ws(e,t,i,s,r,n,a,o,h,l,p){var u,d,m,y,A,b,w,I=s&&s.__k||lt,$=t.length;for(h=Zn(i,t,I,h,$),u=0;u<$;u++)(m=i.__k[u])!=null&&(d=m.__i!=-1&&I[m.__i]||Ks,m.__i=u,b=zs(e,m,d,r,n,a,o,h,l,p),y=m.__e,m.ref&&d.ref!=m.ref&&(d.ref&&pi(d.ref,null,m),p.push(m.ref,m.__c||y,m)),A==null&&y!=null&&(A=y),(w=!!(4&m.__u))||d.__
vendor: 6,207 bytes, line 14
14k===m.__k?(h=Hs(m,h,e,w),w&&d.__e&&(d.__e=null)):typeof m.type=="function"&&b!==void 0?h=b:y&&(h=y.nextSibling),m.__u&=-7);return i.__e=A,h}function Zn(e,t,i,s,r){var n,a,o,h,l,p=i.length,u=p,d=0;for(e.__k=new Array(r),n=0;n<r;n++)(a=t[n])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[n]=Dt(null,a,null,null,null):bt(a)?a=e.__k[n]=Dt(xt,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[n]=Dt(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[n]=a,h=n+d,a.__=e,a.__b=e.__b+1,o=null,(l=a.__i=ea(a,i,h,u))!=-1&&(u--,(o=i[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(r>p?d--:r<p&&d++),typeof a.type!="function"&&(a.__u|=4)):l!=h&&(l==h-1?d--:l==h+1?d++:(l>h?d--:d++,a.__u|=4))):e.__k[n]=null;if(u)for(n=0;n<p;n++)(o=i[n])!=null&&(2&o.__u)==0&&(o.__e==s&&(s=Ie(o)),Js(o,o));return s}function Hs(e,t,i,s){var r,n;if(typeof e.type=="function"){for(r=e.__k,n=0;r&&n<r.length;n++)r[n]&&(r[n].__=e,t=Hs(r[n],t,i,s));return t}e.__e!=t&&(s&&(t&&e.type&&!t.parentNode&&(t=Ie(e)),i.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ea(e,t,i,s){var r,n,a,o=e.key,h=e.type,l=t[i],p=l!=null&&(2&l.__u)==0;if(l===null&&o==null||p&&o==l.key&&h==l.type)return i;if(s>(p?1:0)){for(r=i-1,n=i+1;r>=0||n<t.length;)if((l=t[a=r>=0?r--:n++])!=null&&(2&l.__u)==0&&o==l.key&&h==l.type)return a}return-1}function Ti(e,t,i){t[0]=="-"?e.setProperty(t,i??""):e[t]=i==null?"":typeof i!="number"||Yn.test(t)?i:i+"px"}function Ze(e,t,i,s,r){var n,a;e:if(t=="style")if(typeof i=="string")e.style.cssText=i;else{if(typeof s=="string"&&(e.style.cssText=s=""),s)for(t in s)i&&t in i||Ti(e.style,t,"");if(i)for(t in i)s&&i[t]==s[t]||Ti(e.style,t,i[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(qs,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+n]=i,i?s?i[Le]=s[Le]:(i[Le]=li,e.addEventListener(t,n?Jt:Gt,n)):e.removeEventListener(t,n?Jt:Gt,n);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=i??"";break e}catch{}typeof i=="function"||(i==null||i===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&i==1?"":i))}}function Di(e){return function(t){if(this.l){var i=this.l[t.type+e];if(t[st]==null)t[st]=li++;else if(t[st]<i[Le])return;return i(O.event?O.event(t):t)}}}function zs(e,t,i,s,r,n,a,o,h,l){var p,u,d,m,y,A,b,w,I,$,W,le,He,D,q,te=t.type;if(t.constructor!==void 0)return null;128&i.__u&&(h=!!(32&i.__u),n=[o=t.__e=i.__e]),(p=O.__b)&&p(t);e:if(typeof te=="function")try{if(w=t.props,I=te.prototype&&te.prototype.render,$=(p=te.contextType)&&s[p.__c],W=p?$?$.props.value:p.__:s,i.__c?b=(u=t.__c=i.__c).__=u.__E:(I?t.__c=u=new te(w,W):(t.__c=u=new Ve(w,W),u.constructor=te,u.render=sa),$&&$.sub(u),u.state||(u.state={}),u.__n=s,d=u.__d=!0,u.__h=[],u._sb=[]),I&&u.__s==null&&(u.__s=u.state),I&&te.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=ne({},u.__s)),ne(u.__s,te.getDerivedStateFromProps(w,u.__s))),m=u.props,y=u.state,u.__v=t,d)I&&te.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),I&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(I&&te.getDerivedStateFromProps==null&&w!==m&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(w,W),t.__v==i.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(w,u.__s,W)===!1){t.__v!=i.__v&&(u.props=w,u.state=u.__s,u.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(be){be&&(be.__=t)}),lt.push.apply(u.__h,u._sb),u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(w,u.__s,W),I&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(m,y,A)})}if(u.context=W,u.props=w,u.__P=e,u.__e=!1,le=O.__r,He=0,I)u.state=u.__s,u.__d=!1,le&&le(t),p=u.render(u.props,u.state,u.context),lt.push.apply(u.__h,u._sb),u._sb=[];else do u.__d=!1,le&&le(t),p=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++He<25);u.state=u.__s,u.getChildContext!=null&&(s=ne(ne({},s),u.getChildContext())),I&&!d&&u.getSnapshotBeforeUpdate!=null&&(A=u.getSnapshotBeforeUpdate(m,y)),D=p!=null&&p.type===xt&&p.key==null?Gs(p.props.children):p,o=Ws(e,bt(D)?D:[D],t,i,s,r,n,a,o,h,l),u.base=t.__e,t.__u&=-161,u.__h.length&&a.push(u),b&&(u.__E=u.__=null)}catch(be){if(t.__v=null,h||n!=null)if(be.then){for(t.__u|=h?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;n[n.indexOf(o)]=null,t.__e=o}else{for(q=n.length;q--;)ui(n[q]);Qt(t)}else t.__e=i.__e,t.__k=i.__k,be.then||Qt(t);O.__e(be,t,i)}else n==null&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):o=t.__e=ia(i.__e,t,i,s,r,n,a,h,l);return(p=O.diffed)&&p(t),128&t.__u?void 0:o}function Qt(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Qt))}function ta(e,t,i){for(var s=0;s<i.length;s++)pi(i[s],i[++s],i[++s]);O.__c&&O.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(n){n.call(r)})}catch(n){O.__e(n,r.__v)}})}function Gs(e){return typeof e!="object"||e==null||e.__b>0?e:bt(e)?e.map(Gs):ne({},e)}function ia(e,t,i,s,r,n,a,o,h){var l,p,u,d,m,y,A,b=i.props||Ks,w=t.props,I=t.type;if(I=="svg"?r="http://www.w3.org/2000/svg":I=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),n!=null){for(l=0;l<n.length;l++)if((m=n[l])&&"setAttribute"in m==!!I&&(I?m.localName==I:m.nodeType==3)){e=m,n[l]=null;break}}if(e==null){if(I==null)return document.createTextNode(w);e=document.createElementNS(r,I,w.is&&w),o&&(O.__m&&O.__m(t,n),o=!1),n=null}if(I==null)b===w||o&&e.data==w||(e.data=w);else{if(n=n&&Ls.call(e.childNodes),!o&&n!=null)for(b={},l=0;l<e.attributes.length;l++)b[(m=e.attributes[l]).name]=m.value;for(l in b)m=b[l],l=="dangerouslySetInnerHTML"?u=m:l=="children"||l in w||l=="value"&&"defaultValue"in w||l=="checked"&&"defaultChecked"in w||Ze(e,l,null,m,r);for(l in w)m=w[l],l=="children"?d=m:l=="dangerouslySetInnerHTML"?p=m:l=="value"?y=m:l=="checked"?A=m:o&&typeof m!="function"||b[l]===m||Ze(e,l,m,b[l],r);
vendor: 1,792 bytes, line 14
14if(p)o||u&&(p.__html==u.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(u&&(e.innerHTML=""),Ws(t.type=="template"?e.content:e,bt(d)?d:[d],t,i,s,I=="foreignObject"?"http://www.w3.org/1999/xhtml":r,n,a,n?n[0]:i.__k&&Ie(i,0),o,h),n!=null)for(l=n.length;l--;)ui(n[l]);o||(l="value",I=="progress"&&y==null?e.removeAttribute("value"):y!=null&&(y!==e[l]||I=="progress"&&!y||I=="option"&&y!=b[l])&&Ze(e,l,y,b[l],r),l="checked",A!=null&&A!=e[l]&&Ze(e,l,A,b[l],r))}return e}function pi(e,t,i){try{if(typeof e=="function"){var s=typeof e.__u=="function";s&&e.__u(),s&&t==null||(e.__u=e(t))}else e.current=t}catch(r){O.__e(r,i)}}function Js(e,t,i){var s,r;if(O.unmount&&O.unmount(e),(s=e.ref)&&(s.current&&s.current!=e.__e||pi(s,null,t)),(s=e.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(n){O.__e(n,t)}s.base=s.__P=null}if(s=e.__k)for(r=0;r<s.length;r++)s[r]&&Js(s[r],t,i||typeof e.type!="function");i||ui(e.__e),e.__c=e.__=e.__e=void 0}function sa(e,t,i){return this.constructor(e,i)}Ls=lt.slice,O={__e:function(e,t,i,s){for(var r,n,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&n.getDerivedStateFromError!=null&&(r.setState(n.getDerivedStateFromError(e)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,s||{}),a=r.__d),a)return r.__E=r}catch(o){e=o}throw e}},Vs=0,Ms=function(e){return e!=null&&e.constructor===void 0},Ve.prototype.setState=function(e,t){var i;i=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ne({},this.state),typeof e=="function"&&(e=e(ne({},i),this.props)),e&&ne(i,e),e!=null&&this.__v&&(t&&this._sb.push(t),Fi(this))},Ve.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Fi(this))},Ve.prototype.render=xt,ue=[],js=typeof Promise=="function"?Promise.prototype.then.bind(Prom
14ise.resolve()):setTimeout,$s=function(e,t){return e.__v.__b-t.__v.__b},ut.__r=0,Tt=Math.random().toString(8),st="__d"+Tt,Le="__a"+Tt,qs=/(PointerCapture)$|Capture$/i,li=0,Gt=Di(!1),Jt=Di(!0),Qn=0;var Yt,H,Nt,Ni,Bi=0,Qs=[],N=O,Li=N.__b,Vi=N.__r,Mi=N.diffed,ji=N.__c,$i=N.unmount,qi=N.__;function ra(e,t){N.__h&&N.__h(H,e,Bi||t),Bi=0;var i=H.__H||(H.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function Ys(e,t){var i=ra(Yt++,7);return oa(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function na(){for(var e;e=Qs.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rt),t.__h.some(Xt),t.__h=[]}catch(i){t.__h=[],N.__e(i,e.__v)}}}N.__b=function(e){H=null,Li&&Li(e)},N.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),qi&&qi(e,t)},N.__r=function(e){Vi&&Vi(e),Yt=0;var t=(H=e.__c).__H;t&&(Nt===H?(t.__h=[],H.__h=[],t.__.some(function(i){i.__N&&(i.__=i.__N),i.u=i.__N=void 0})):(t.__h.some(rt),t.__h.some(Xt),t.__h=[],Yt=0)),Nt=H},N.diffed=function(e){Mi&&Mi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Qs.push(t)!==1&&Ni===N.requestAnimationFrame||((Ni=N.requestAnimationFrame)||aa)(na)),t.__H.__.some(function(i){i.u&&(i.__H=i.u),i.u=void 0})),Nt=H=null},N.__c=function(e,t){t.some(function(i){try{i.__h.some(rt),i.__h=i.__h.filter(function(s){return!s.__||Xt(s)})}catch(s){t.some(function(r){r.__h&&(r.__h=[])}),t=[],N.__e(s,i.__v)}}),ji&&ji(e,t)},N.unmount=function(e){$i&&$i(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.some(function(s){try{rt(s)}catch(r){t=r}}),i.__H=void 0,t&&N.__e(t,i.__v))};var Ki=typeof requestAnimationFrame=="function";function aa(e){var t,i=function(){clearTimeout(s),Ki&&cancelAnimationFrame(t),setTimeout(e)},s=setTimeout(i,35);Ki&&(t=requestAnimationFrame(i))}function rt(e){var t=H,i=e.__c;typeof i=="function"&&(e.__c=void 0,i()),H=t}function Xt(e){var t=H;e.__c=e.__(),H=t}function oa(e,t){return!e||e.length!==t.length||t.some(function(i,s){return i!==e[s]})}var ca=Symbol.for("preact-signals");function kt(){if(ae>1){ae--;return}let e,t=!1;for((function(){let i=pt;for(pt=void 0;i!==void 0;)i.S.v===i.v&&(i.S.i=i.i),i=i.o})();Me!==void 0;){let i=Me;for(Me=void 0,ft++;i!==void 0;){let s=i.u;if(i.u=void 0,i.f&=-3,!(8&i.f)&&er(i))try{i.c()}catch(r){t||(e=r,t=!0)}i=s}}if(ft=0,ae--,t)throw e}function Zt(e){if(ae>0)return e();ei=++ha,ae++;try{return e()}finally{kt()}}var R,Me;function fi(e){let t=R;R=void 0;try{return e()}finally{R=t}}var pt,Ui,ae=0,ft=0,ha=0,ei=0,dt=0;function Xs(e){if(R===void 0)return;let t=e.n;if(t===void 0||t.t!==R)return t={i:0,S:e,p:R.s,n:void 0,t:R,e:void 0,x:void 0,r:t},R.s!==void 0&&(R.s.n=t),R.s=t,e.n=t,32&R.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=R.s,t.n=void 0,R.s.n=t,R.s=t),t}function M(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}M.prototype.brand=ca;M.prototype.h=function(){return!0};M.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t!==void 0?t.e=e:fi(()=>{var i;(i=this.W)==null||i.call(this)}))};M.prototype.U=function(e){if(this.t!==void 0){let t=e.e,i=e.x;t!==void 0&&(t.x=i,e.e=void 0),i!==void 0&&(i.e=t,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&fi(()=>{var s;(s=this.Z)==null||s.call(this)}))}};M.prototype.subscribe=function(e){return We(()=>{let t=this.value,i=R;R=void 0;try{e(t)}finally{R=i}},{name:"sub"})};M.prototype.valueOf=function(){return this.value};M.prototype.toString=function(){return this.value+""};M.prototype.toJSON=function(){return this.value};M.prototype.peek=function(){return fi(()=>this.value)};Object.defineProperty(M.prototype,"value",{get(){let e=Xs(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(ft>100)throw new Error("Cycle detected");(function(t){ae!==0&&ft===0&&t.l!==ei&&(t.l=ei,pt={S:t,v:t.v,i:t.i,o:pt})})(this),this.v=e,this.i++,dt++,ae++;try{for(let t=this.t;t!==void 0;t=t.x)t.t.N()}finally{kt()}}}});function Zs(e,t){return new M(e,t)}function er(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function tr(e){for(let t=e.s;t!==void 0;t=t.n){let i=t.S.n;if(i!==void 0&&(t.r=i),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ir(e){let t,i=e.s;for(;i!==void 0;){let s=i.p;i.i===-1?(i.S.U(i),s!==void 0&&(s.n=i.n),i.n!==void 0&&(i.n.p=s)):t=i,i.S.n=i.r,i.r!==void 0&&(i.r=void 0),i=s}e.s=t}function Se(e,t){M.call(this,void 0),this.x=e,this.s=void 0,this.g=dt-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Se.prototype=new M;Se.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===dt))return!0;
14if(this.g=dt,this.f|=1,this.i>0&&!er(this))return this.f&=-2,!0;let e=R;try{tr(this),R=this;let t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return R=e,ir(this),this.f&=-2,!0};Se.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let t=this.s;t!==void 0;t=t.n)t.S.S(t)}M.prototype.S.call(this,e)};Se.prototype.U=function(e){if(this.t!==void 0&&(M.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Se.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Se.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let e=Xs(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Wi(e,t){return new Se(e,t)}function sr(e){let t=e.m;if(e.m=void 0,typeof t=="function"){ae++;let i=R;R=void 0;try{t()}catch(s){throw e.f&=-2,e.f|=8,di(e),s}finally{R=i,kt()}}}function di(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,sr(e)}function la(e){if(R!==this)throw new Error("Out-of-order effect");ir(this),R=e,this.f&=-2,8&this.f&&di(this),kt()}function Fe(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Ui&&Ui.push(this)}Fe.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Fe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,sr(this),tr(this),ae++;let e=R;return R=this,la.bind(this,e)};Fe.prototype.N=function(){2&this.f||(this.f|=2,this.u=Me,Me=this)};Fe.prototype.d=function(){this.f|=8,1&this.f||di(this)};Fe.prototype.dispose=function(){this.d()};function We(e,t){let i=new Fe(e,t);try{i.c()}catch(r){throw i.d(),r}let s=i.d.bind(i);return s[Symbol.dispose]=s,s}var ua=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,rr,mi,et,nr=[];We(function(){rr=this.N})();function Te(e,t){O[e]=t.bind(null,O[e]||(()=>{}))}function mt(e){if(et){let t=et;et=void 0,t()}et=e&&e.S()}function ar({data:e}){let t=fa(e);t.value=e;let[i,s]=Ys(()=>{let r=this,n=this.__v;for(;n=n.__;)if(n.__c){n.__c.__$f|=4;break}let a=Wi(()=>{let p=t.value.value;return p===0?0:p===!0?"":p||""}),o=Wi(()=>!Array.isArray(a.value)&&!Ms(a.value)),h=We(function(){if(this.N=or,o.value){let p=a.value;r.__v&&r.__v.__e&&r.__v.__e.nodeType===3&&(r.__v.__e.data=p)}}),l=this.__$u.d;return this.__$u.d=function(){h(),l.call(this)},[o,a]},[]);return i.value?s.peek():s.value}ar.displayName="ReactiveTextNode";Object.defineProperties(M.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:ar},props:{configurable:!0,get(){let e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Te("__b",(e,t)=>{if(typeof t.type=="string"){let i,s=t.props;for(let r in s){if(r==="children")continue;let n=s[r];n instanceof M&&(i||(t.__np=i={}),i[r]=n,s[r]=n.peek())}}e(t)});Te("__r",(e,t)=>{if(e(t),t.type!==xt){mt();let i,s=t.__c;s&&(s.__$f&=-2,i=s.__$u,i===void 0&&(s.__$u=i=(function(r,n){let a;return We(function(){a=this},{name:n}),a.c=r,a})(()=>{var r;ua&&((r=i.y)==null||r.call(i)),s.__$f|=1,s.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),mi=s,mt(i)}});Te("__e",(e,t,i,s)=>{mt(),mi=void 0,e(t,i,s)});Te("diffed",(e,t)=>{mt(),mi=void 0;let i;if(typeof t.type=="string"&&(i=t.__e)){let s=t.__np,r=t.props;if(s){let n=i.U;if(n)for(let a in n){let o=n[a];o!==void 0&&!(a in s)&&(o.d(),n[a]=void 0)}else n={},i.U=n;for(let a in s){let o=n[a],h=s[a];o===void 0?(o=pa(i,a,h),n[a]=o):o.o(h,r)}for(let a in s)r[a]=s[a]}}e(t)});function pa(e,t,i,s){let r=t in e&&e.ownerSVGElement===void 0,n=Zs(i),a=i.peek();return{o:(o,h)=>{n.value=o,a=o.peek()},d:We(function(){this.N=or;let o=n.value.value;a!==o?(a=void 0,r?e[t]=o:o!=null&&(o!==!1||t[4]==="-")?e.setAttribute(t,o):e.removeAttribute(t)):a=void 0})}}Te("unmount",(e,t)=>{if(typeof t.type=="string"){let i=t.__e;if(i){let s=i.U;if(s){i.U=void 0;for(let r in s){let n=s[r];n&&n.d()}}}t.__np=void 0}else{let i=t.__c;if(i){let s=i.__$u;s&&(i.__$u=void 0,s.d())}}e(t)});Te("__h",(e,t,i,s)=>{(s<3||s===9)&&(t.__$f|=2),e(t,i,s)});Ve.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;let i=this.__$u,s=i&&i.s!==void 0;for(let r in t)return!0;
14if(this.__f||typeof this.u=="boolean"&&this.u===!0){let r=2&this.__$f;if(!(s||r||4&this.__$f)||1&this.__$f)return!0}else if(!(s||4&this.__$f)||3&this.__$f)return!0;for(let r in e)if(r!=="__source"&&e[r]!==this.props[r])return!0;for(let r in this.props)if(!(r in e))return!0;return!1};function fa(e,t){return Ys(()=>Zs(e,t),[])}var da=e=>{queueMicrotask(()=>{queueMicrotask(e)})};function ma(){Zt(()=>{let e;for(;e=nr.shift();)rr.call(e)})}function or(){nr.push(this)===1&&(O.requestAnimationFrame||da)(ma)}function X(e,t){let i=T(e,t);if(!L(i))throw new f("logic_state_sync_invalid",`${t} must be an object`);return i}function Bt(e,t){return e===t?!0:e===void 0||t===void 0?!1:$e(e)===$e(t)}function Lt(e,t){if(!Number.isSafeInteger(e)||e<0)throw new f("logic_protocol_error",`${t} must be a non-negative safe integer`)}var ga=class{#e;#t;#i=new Set;#a=[];#r;#s=new Map;#o;#n;#g;#R=0;#w=0;#S=!1;#y=!1;#l=!1;constructor(e){this.#e=e.backingStore,this.#t=ii(e.schema),this.#n=e.stateRevision??0,Lt(this.#n,"stateRevision"),this.#g=e.serverStorageVersion,this.#r=Math.max(1,Math.min(e.journalLimit??100,
141e3)),this.#o=this.#d(e.initialState);for(let t of Object.keys(this.#o))this.#s.set(t,this.#n);this.#h(this.#o,[])}get revision(){return this.#n}get serverStorageVersion(){return this.#g}get closed(){return this.#S}snapshot(){return Object.freeze(X(this.#o,"session.snapshot"))}readableSnapshot(){let e={};for(let[t,i]of Object.entries(this.#o))this.#t[t]?.scope!=="serverOnly"&&(e[t]=i);return Object.freeze(e)}read(e){return this.#o[e]}subscribe(e){return this.#S?()=>{}:(this.#i.add(e),()=>this.#i.delete(e))}recentCommits(){return this.#a.map(e=>F(g({},e),{updates:X(e.updates,"session.journal.updates"),removedKeys:[...e.removedKeys],changedKeys:[...e.changedKeys]}))}commit(e){if(this.#S)throw new f("logic_lifecycle_stale","Session state store is closed");if(this.#y||this.#l)throw new f("logic_protocol_error","Re-entrant session state commit is forbidden");if(!e.commitId||typeof e.commitId!="string")throw new f("logic_protocol_error","commitId is required");if(e.baseRevision!==void 0&&e.baseRevision!==this.#n)throw new f("logic_state_conflict","Session state revision changed");let t=X(e.updates,"session.commit.updates"),i=[...new Set(e.removedKeys??[])],s=X(this.#o,"session.current"),r={},n=[];for(let[u,d]of Object.entries(t))this.#C(e.origin,u,d),Bt(s[u],d)||(s[u]=d,r[u]=d);for(let u of i){if(typeof u!="string")throw new f("logic_state_sync_invalid","Removed state key must be a string");this.#k(e.origin,u),Object.prototype.hasOwnProperty.call(s,u)&&(delete s[u],n.push(u))}let a=this.#n,o=Object.keys(r).length>0||n.length>0,h=o?a+1:a;Lt(h,"next stateRevision");let l=e.serverStorageVersion!==void 0&&e.serverStorageVersion!==this.#g;this.#y=!0;try{if(o){this.#o=s,this.#n=h;for(let u of Object.keys(r))this.#s.set(u,h);for(let u of n)this.#s.set(u,h);this.#h(r,n)}e.serverStorageVersion!==void 0&&(this.#g=e.serverStorageVersion)}finally{this.#y=!1}let p=F(g({commitId:e.commitId,origin:e.origin,previousRevision:a,stateRevision:this.#n,updates:r,removedKeys:n,changedKeys:[...Object.keys(r),...n].sort()},this.#g!==void 0?{serverStorageVersion:this.#g}:{}),{changed:o});if(o||l)for(this.#a.push(p);this.#a.length>this.#r;)this.#a.shift();if(o){this.#l=!0;try{for(let u of[...this.#i])try{u(p)}catch(d){console.error("[SessionStateStore] commit subscriber failed",d)}}finally{this.#l=!1}}return p}replace(e,t,i,s){let r=this.#d(e);return this.commit(g({commitId:i,origin:t,updates:r,removedKeys:Object.keys(this.#o).filter(n=>!(n in r))},s!==void 0?{serverStorageVersion:s}:{}))}autosaveSnapshot(){let e={};for(let[t,i]of Object.entries(this.#t))i.scope==="clientOnly"&&Object.prototype.hasOwnProperty.call(this.#o,t)&&(e[t]=this.#o[t]);return Object.freeze(e)}createAutosaveRequest(){this.#R+=1,Lt(this.#R,"autosave sequence");let e=X(this.autosaveSnapshot(),"session.autosave"),t=Object.keys(e).sort(),i={};for(let s of Object.keys(this.#t))this.#t[s]?.scope==="clientOnly"&&(i[s]=this.#s.get(s)??0);return g({sequence:this.#R,baseRevision:this.#n,state:e,keys:t,keyRevisions:Object.freeze(i)},this.#g!==void 0?{expectedServerStorageVersion:this.#g}:{})}reconcileAutosaveEcho(e,t,i){if(e.sequence<this.#w)return{disposition:"stale",preservedLocalKeys:[]};if(e.sequence===this.#w)return{disposition:"duplicate",preservedLocalKeys:[]};if(this.#w=e.sequence,t===void 0)return this.#g=i,{disposition:"acknowledged",preservedLocalKeys:[]};let s=X(t,"session.autosave.canonical");for(let[h,l]of Object.entries(s)){let p=this.#t[h];if(!p||p.scope!=="clientOnly"||!ve(p.type,l))throw new f("logic_state_sync_invalid",`Canonical client state key ${h} is invalid`)}let r={},n=[],a=[];for(let[h,l]of Object.entries(this.#t)){if(l.scope!=="clientOnly")continue;let p=(this.#s.get(h)??0)>e.baseRevision,u=Object.prototype.hasOwnProperty.call(s,h);if(p){let d=u?s[h]:void 0;Bt(this.#o[h],d)||a.push(h);continue}u?r[h]=s[h]:n.push(h)}let o=this.commit({commitId:`autosave:${e.sequence}:${i}`,origin:"autosave_echo",baseRevision:this.#n,updates:r,removedKeys:n,serverStorageVersion:i});return{disposition:o.changed?"applied":"acknowledged",commit:o,preservedLocalKeys:a.sort()}}recoverAutosaveConflict(e,t,i){let s=this.#d(t),r=X(s,"session.autosave.recovery"),n=[],a=[];for(let[h,l]of Object.entries(this.#t)){if(l.scope!=="clientOnly"||(this.#s.get(h)??0)<=e.baseRevision)continue;let p=Object.prototype.hasOwnProperty.call(e.state,h),u=Object.prototype.hasOwnProperty.call(s,h);if(p!==u||p&&u&&!Bt(e.state[h],s[h])){a.push(h);continue}Object.prototype.hasOwnProperty.call(this.#o,h)?r[h]=this.#o[h]:delete r[h],n.push(h)}return this.#w=Math.max(this.#w,e.sequence),{commit:this.commit({commitId:`recovery:autosave:${e.sequence}:${i}`,origin:"recovery",baseRevision:this.#n,updates:r,removedKeys:Object.keys(this.#o).filter(h=>!Object.prototype.hasOwnProperty.call(r,h)),serverStorageVersion:i}),preservedLocalKeys:n.sort(),canonicalConflictKeys:a.sort()}}createWriter(){let e=new Set,t=!1,i=this.#e,s=a=>
14{if(t||this.#S)return;let o=X(a,"screen.local");for(let h of Object.keys(o))e.add(h);i.isSplitMode&&i.patchClient?i.patchClient(o):i.patch(o)},r=a=>{let o=X(a,"screen.commit"),h={},l={};for(let[p,u]of Object.entries(o))this.#t[p]?h[p]=u:l[p]=u;return Object.keys(l).length>0&&s(l),Object.keys(h).length===0?F(g({commitId:"screen:local-only",origin:"screen",previousRevision:this.#n,stateRevision:this.#n,updates:{},removedKeys:[],changedKeys:[]},this.#g!==void 0?{serverStorageVersion:this.#g}:{}),{changed:!1}):this.commit({commitId:`screen:${this.#n+1}`,origin:"screen",baseRevision:this.#n,updates:h})},n=()=>{t||(t=!0,Zt(()=>{for(let a of e)i.isSplitMode&&i.unsetClient&&i.unsetClient(a)}),e.clear())};return F(g(g(g(g(g(g(g(g(g(g(g(g(F(g({patch:a=>{r(a)},patchInitial:a=>{let o={},h={};for(let[l,p]of Object.entries(X(a,"screen.initial")))this.#t[l]?.scope==="clientOnly"&&!Object.prototype.hasOwnProperty.call(this.#o,l)?o[l]=p:this.#t[l]||(h[l]=p);Object.keys(o).length>0&&this.commit({commitId:`screen:init:${this.#n+1}`,origin:"session_init",baseRevision:this.#n,updates:o}),Object.keys(h).length>0&&s(h)},init:a=>{r(a)},get:a=>i.get(a),getKeySignalForRead:a=>i.getKeySignalForRead(a),entries:()=>i.entries(),snapshot:()=>i.snapshot(),subscribe:a=>i.subscribe(a),emit:(a,o)=>i.emit(a,o),on:(a,o)=>i.on(a,o)},i.eventListenerCounts?{eventListenerCounts:()=>i.eventListenerCounts()}:{}),{destroy:n,isSplitMode:i.isSplitMode}),i.patchClient?{patchClient:a=>{r(a)}}:{}),i.patchServer?{patchServer:a=>{throw new f("logic_screen_write_denied","Screen cannot write server state")}}:{}),i.unsetClient?{unsetClient:a=>{this.#t[a]?this.commit({commitId:`screen:unset:${this.#n+1}`,origin:"screen",baseRevision:this.#n,updates:{},removedKeys:[a]}):(i.unsetClient(a),e.delete(a))}}:{}),i.unsetClientOnAck?{unsetClientOnAck:a=>i.unsetClientOnAck(a)}:{}),i.unsetServer?{unsetServer:a=>{throw new f("logic_screen_write_denied","Screen cannot remove server state")}}:{}),i.replaceServer?{replaceServer:a=>{throw new f("logic_screen_write_denied","Screen cannot replace server state")}}:{}),i.getServer?{getServer:a=>i.getServer(a)}:{}),i.getClient?{getClient:a=>i.getClient(a)}:{}),i.hasClient?{hasClient:a=>i.hasClient(a)}:{}),i.hasServer?{hasServer:a=>i.hasServer(a)}:{}),i.serverKeys?{serverKeys:()=>i.serverKeys()}:{}),i.clientSnapshot?{clientSnapshot:()=>i.clientSnapshot()}:{}),{commitClientOnly:r,applyScreenLocal:s,close:n})}close(){this.#S||(this.#S=!0,this.#i.clear())}#d(e){let t=X(e,"session.state");for(let[i,s]of Object.entries(t)){let r=this.#t[i];if(!r||!ve(r.type,s))throw new f("logic_state_sync_invalid",`Session state key ${i}
14 is invalid`)}return t}#C(e,t,i){let s=this.#t[t];if(!s)throw new f("logic_write_denied",`${t} is absent from gameStateSchema`);if(!ve(s.type,i))throw new f("logic_type_mismatch",`${t} does not match ${s.type}`);if((e==="screen"||e==="logic"||e==="autosave_echo")&&s.scope!=="clientOnly")throw new f(e==="screen"?"logic_screen_write_denied":"logic_scope_denied",`${e} cannot write ${s.scope} state`)}#k(e,t){let i=this.#t[t];if(!i)throw new f("logic_write_denied",`${t} is absent from gameStateSchema`);if((e==="screen"||e==="logic"||e==="autosave_echo")&&i.scope!=="clientOnly")throw new f(e==="screen"?"logic_screen_write_denied":"logic_scope_denied",`${e} cannot remove ${i.scope} state`)}#h(e,t){let i={},s={};for(let[r,n]of Object.entries(e)){let a=this.#t[r]?.scope;a==="clientOnly"?i[r]=n:a==="serverMirror"&&(s[r]=n)}Zt(()=>{if(this.#e.isSplitMode){Object.keys(i).length>0&&this.#e.patchClient?.(i),Object.keys(s).length>0&&this.#e.patchServer?.(s);for(let r of t){let n=this.#t[r]?.scope;n==="clientOnly"?this.#e.unsetClient?.(r):n==="serverMirror"&&this.#e.unsetServer?.(r)}return}if(t.length>0)throw new f("logic_state_sync_invalid","State removal requires split-mode backing store");this.#e.patch(g(g({},i),s))})}};async function va(e){let t=new TextEncoder().encode(e),i=new Uint8Array(await crypto.subtle.digest("SHA-256",t));return Array.from(i,s=>s.toString(16).padStart(2,"0")).join("")}function _a(e){return new Worker(e,{type:"module",name:"logic-runtime-v1"})}function ya(){let e=!1,t=new Set,i=()=>!e&&document.visibilityState==="visible",s=()=>{let h=i();for(let l of[...t])l(h)},r=()=>{e=!0,s()},n=()=>{e=!1,s()};document.addEventListener("visibilitychange",s),document.addEventListener("freeze",r),document.addEventListener("resume",n),window.addEventListener("pagehide",r),window.addEventListener("pageshow",n);let a=!1,o=()=>{a||(a=!0,document.removeEventListener("visibilitychange",s),document.removeEventListener("freeze",r),document.removeEventListener("resume",n),window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",n),t.clear())};return{isForeground:i,subscribe(h){if(a)throw new Error("Logic activity source is destroyed");return t.add(h),()=>{t.delete(h),t.size===0&&o()}}}}function wa(e){let t=e.type;if(t){if(t==="ui:state:sync"||t==="ui:state:patch"){let i=e.gameState?Object.keys(e.gameState).join(", "):"";console.debug(`[sse] ${t} { ${i} }`);return}if(t==="ui:screen:init"){console.debug(`[sse] ${t} screenId=${e.screenId??"?"}`);return}if(t==="ui:waiting"||t==="ui:screen:ready"){console.debug(`[sse] ${t} eventKey=${e.eventKey??"?"}`);return}console.debug(`[sse] ${t}`)}}function je(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?"["+e.map(je).join(",")+"]":"{"+Object.keys(e).sort().map(i=>JSON.stringify(i)+":"+je(e[i])).join(",")+"}"}var Sa=75e3,ba=3e4,Hi={isPlaying:!1,isFinished:!1,error:null,currentGameEvent:null,gameState:{}},xa=class{#e;#t;#i;#a=null;#r;#s;#o;#n;#g;#R;#w;#S;#y;#l=null;#d=null;#C=null;#k=null;#h=null;#O=null;#_=Promise.resolve();#$=[];#b=0;#E=null;#F=null;#K;#j;#z;#U;#D;#x;#N=_i();#m;#L=void 0;#P=null;#f=null;#I=0;#u=null;#c=new fr;#p=0;#ie=[];#Q=void 0;#ce=void 0;#ne=void 0;#B=!1;#W=null;#ae=0;#V=null;#v=new wr;#me=null;#Se=0;#X=g({},Hi);#A=!1;#M=0;#Z=!1;#he=0;#le=0;#se=null;#oe=!1;#ee=new Set;#ge=new Map;#be=new Set;#ve=null;#H="";#_e={};#Ie=void 0;#xe={};constructor(e,t,i,s,r,n,a,o,h,l,p){this.#e=e,this.#g=p?.canvas,this.#R=p?.legacyFlexDefault??!1,this.#w=p?.assets,this.#y=p?.logicRuntime,this.#D=p?.previewRunLeaseId,this.#t=t,this.#i=i,this.#a=s??null,this.#x=new Et,this.#m=new wi(this.#x),this.#r=typeof r=="function"?r:r!==void 0?()=>r:void 0,this.#s=n,this.#n=a;let u=p?.autoSave;this.#S=u===!0?{enabled:!0}:u||void 0,p?.keepAlive,this.#K=o,this.#o=l,this.#j=h?.heartbeatTimeoutMs??Sa,this.#z=h?.restartInitTimeoutMs??ba,this.#U=h?.reconnect,this.#c.onChange(d=>this.#G(()=>{let m=this.#M;this.#x?.patch({_connectionState:d}),this.#i.emit("connection:state",d),this.#q(m)&&(d==="degraded"||d==="reconnecting")&&(this.#i.emit("flush:requested",{reason:d,generation:this.#p}),this.#E?.flushNow(),this.#K&&Promise.resolve().then(()=>this.#K?.()).catch(y=>console.warn("[WorkflowSession] onPreDeathFlush error:",y)))}
14)),this.#v.onAckTimeout=d=>{let m=d.generation??this.#p;m===this.#p&&(this.#T({error:"response not observed"}),this.#c.markDegraded(m))},this.#v.onAckRecovered=()=>{this.#X.error==="response not observed"&&this.#T({error:null})},this.#v.onDispatchError=(d,m)=>{m.message.includes("HTTP 404")&&d.kind!=="public-respond"&&this.#v.onDeadRun?.(d)},this.#v.onDeadRun=d=>{(d.generation??this.#p)===this.#p&&this.#Te("dead-run-404")}}enqueueWithAck(e,t){!this.#f||this.#A||this.#v.enqueue({kind:"ui-event",dispatch:t,ackExpectation:e,generation:this.#p})}emitWithAck(e,t,i,s){if(!this.#f||this.#A)return;let r=this.#f;this.#v.enqueue({kind:"ui-event",ackExpectation:s,generation:this.#p,dispatch:()=>i!==void 0?this.#e.sendUIEvent(r,e,t,i):this.#e.sendUIEvent(r,e,t)})}get state(){return F(g({},this.#X),{gameState:this.#x.snapshot()})}get autosaveSnapshot(){return this.#m.autosaveSnapshot()}get hasPendingOps(){return this.#v.size>0}get activeScreenHandle(){return this.#P}async cancelActiveRun(){let e=this.#f;!e||!this.#e.cancelRun||await this.#e.cancelRun(e)}get connectionState(){return this.#c.state}get gameStore(){return this.#x}getMountedSchema(){return this.#Ie}get options(){return this.#xe}get onError(){return this.#xe?.onError}#ke(){this.#Y(),this.#Se=Date.now();let e=this.#p;this.#me=setInterval(()=>{e===this.#p&&Date.now()-this.#Se>=this.#j&&this.#c.markDegraded(e)},this.#j)}#Y(){this.#me!==null&&(clearInterval(this.#me),this.#me=null)}#qe(){this.#E?.flushBeacon(),this.#F?.abort(),this.#E?.destroy(),this.#F=null,this.#E=null}async startLogic(e,t){if(It(),this.#oe||this.#Z)return;let i=this.#e.startLogicSession;if(!i)throw new Error("[WorkflowSession] Logic session transport is unavailable");if(!this.#y)throw new Error("[WorkflowSession] Logic Worker build configuration is unavailable");let s=++this.#b,r=await i.call(this.#e,e);if(s!==this.#b||this.#oe||this.#Z){this.#ue(r);return}this.#Oe(r,t)}#ue(e){let t=this.#e.stopLogicSession;t&&t.call(this.#e,e.logicSessionId,{definitionRef:e.definitionRef,lifecycleEpoch:e.lifecycleEpoch}).catch(()=>{})}#te(e){let t=this.#h;this.#O=null,this.#l?.stop(e),this.#l=null,this.#h=null,t&&this.#ue(t)}#Re(e){if(!this.#h||!this.#H.trim())return!1;let t="logic_sse_frame_truncated: Logic stream ended with an incomplete SSE frame";return this.#H="",e.abort(),this.#Y(),this.#te("logic_sse_frame_truncated"),this.#c.markDead(),this.#T({isPlaying:!1,error:t}),this.#i.emit("game:error",t),!0}#Oe(e,t){try{this.#Ke(e,t)}catch(i){throw this.#h===e?(this.#te("logic_start_failed"),this.#u?.abort(),this.#u=null):this.#ue(e),i}}#Ke(e,t){this.#fe({kind:"startLogic",response:e,entryPoint:t})||this.#pe(()=>this.#Pe(e.definition.rootNodes,e.initialState,void 0,e.definition.rootWorkflowId,t,e))}async start(e,t,i,s,r){It(),!this.#oe&&(this.#Z||(this.#b+=1,!this.#fe({kind:"start",nodes:e,storage:t,extensionId:i,workflowId:s,entryPoint:r})&&this.#pe(()=>this.#Pe(e,t,i,s,r))))}#Pe(e,t,i,s,r,n){this.#M+=1,this.#Ce();let a=this.#M;if(!this.#q(a))return;let o=this.#r?.(),h=this.#$e(o?{nodes:e,library:o}:e);if(h?.dynamicServerRefs.length)throw new Error("[WorkflowSession] dynamic $server.* construction is unsupported. Paths: "+h.dynamicServerRefs.map(u=>u.path).join(", "));let l=n!==void 0;if((h?.hasServerRefs||l)&&(this.#x.destroy(),this.#x=new Je,this.#m=new Si(this.#x)),this.#_e=t?g({},t):{},this.#ie=n?[]:e,this.#Q=i,this.#ce=s,this.#ne=r,n){if(n.capabilityProfile!=="logic_lite"&&n.capabilityProfile!=="full_v1"||n.runtimeProfileVersion!==1||n.limitProfileVersion!==1||n.stateRevision!==0)throw new Error("[WorkflowSession] Logic start profile mismatch");this.#h=n,this.#d=new ga({backingStore:this.#m,schema:n.definition.gameStateSchema,initialState:n.initialState,stateRevision:n.stateRevision,serverStorageVersion:n.serverStorageVersion}),this.#k=this.#d.subscribe(u=>{this.#T({gameState:g({},this.#x.snapshot())}),(u.origin==="screen"||u.origin==="logic")&&u.changedKeys.some(d=>n.definition.gameStateSchema[d]?.scope==="clientOnly")&&this.#E?.markDirty()})}if(this.#A=!1,this.#S?.enabled&&(this.#Q||n)&&!this.#E&&(this.#E=new Cr({getSnapshot:()=>this.#h?this.#Xe():Mt(this.autosaveSnapshot),hasPendingOps:()=>this.#v.size>0||(this.#l?.hasPendingRequests??!1),capturePostContext:()=>this.#h?this.#d?.createAutosaveRequest():void 0,post:(u,d,m)=>{let y=this.#e.saveState;if(!y)return;let A=this.#h;
14if(!A)return y.call(this.#e,this.#Q??"",u,d);let b=m;return b?this.#Be(async()=>{let w=await y.call(this.#e,this.#Q??"",u,F(g({},d),{expectedServerStorageVersion:b.expectedServerStorageVersion,baseRevision:b.baseRevision,snapshotKeys:b.keys}));return w&&this.#h===A&&this.#et(w,A,b),w}):Promise.reject(new Error("Logic autosave request context is missing"))},beacon:(u,d)=>{let m=this.#e.saveStateBeacon;if(!m)return!1;if(!this.#h)return m.call(this.#e,this.#Q??"",u,d);let y=this.#d?.createAutosaveRequest();return y?m.call(this.#e,this.#Q??"",u,F(g({},d),{expectedServerStorageVersion:y.expectedServerStorageVersion,baseRevision:y.baseRevision,snapshotKeys:y.keys})):!1},now:()=>Date.now(),windowMs:this.#S.windowMs??5500,storageName:Er,persistEmptySnapshot:this.#h!==null,saveStateOptions:this.#S.saveStateOptions,getSaveStateOptions:()=>this.#h?this.#Ze():this.#S?.saveStateOptions??{},onError:(u,d)=>{this.#tt(u,d)||console.warn("[WorkflowSession] autosave error:",u)}}),typeof document<"u"&&typeof window<"u")){this.#F=new AbortController;let u=this.#F.signal;document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.#E?.flushNow()},{signal:u}),this.#S.unload!=="off"&&(window.addEventListener("beforeunload",()=>this.#E?.flushBeacon(),{signal:u}),window.addEventListener("pagehide",()=>this.#E?.flushBeacon(),{signal:u}))}if(this.#T({isPlaying:!0}),!this.#q(a))return;this.#p=this.#c.armGeneration();let p=this.#c.state;this.#c.markConnecting(),!(p===this.#c.state&&(this.#x?.patch({_connectionState:this.#c.state}),this.#i.emit("connection:state",this.#c.state),!this.#q(a)))&&(this.#ke(),this.#Fe({freshStart:!1}))}#Fe(e){let t=this.#h;if(t&&(!this.#e.openPinnedLogicStream||!this.#e.reattachLogicStream))throw new Error("[WorkflowSession] Logic stream transport is unavailable");let i={nodes:this.#ie,storage:this.#_e,interactive:!0,extensionId:this.#Q,workflowId:this.#ce,entryPoint:this.#ne,freshStart:e.freshStart,previewRunLeaseId:this.#D},s=h=>t?this.#f?this.#e.reattachLogicStream(this.#f,this.#I,h):this.#e.openPinnedLogicStream(g({logicSessionId:t.logicSessionId,definitionRef:t.definitionRef},this.#ne?{entryPoint:this.#ne}:{}),h):this.#e.openStream(i,h,this.#f?{runId:this.#f,lastEventId:this.#I}:void 0),r={conn:null},n={};if(this.#U)for(let[h,l]of Object.entries(this.#U))l!==void 0&&(n[h]=l);let a=n.maxRetries??1/0,o=ur(s,F(g({maxRetries:1/0,baseDelayMs:1e3},n),{onRetry:h=>{this.#A||this.#u!==r.conn||this.#G(()=>{if(this.#Re(o))return;let l=this.#c.generation;this.#i.emit("reconnecting",h,a),!(this.#A||this.#u!==r.conn)&&this.#c.markReconnecting(l)})},onReconnected:()=>{this.#A||this.#u!==r.conn||this.#G(()=>{this.#A||this.#u!==r.conn||this.#Re(o)||(this.#p=this.#c.armGeneration(),this.#H="",this.#ke())})},onGiveUp:h=>{this.#A||this.#u!==r.conn||this.#G(()=>{this.#Y(),this.#te("logic_transport_give_up"),this.#c.markDead(),this.#T({isPlaying:!1,error:`Connection lost: ${h.message}`}),this.#i.emit("game:error",`Connection lost: ${h.message}`)})}}));r.conn=o,this.#u=o,this.#Ge(o).catch(h=>{console.warn("[WorkflowSession] readLoop error:",h)})}#Te(e){this.#B||this.#A||this.#fe({kind:"restart",reason:e})||this.#pe(()=>this.#Ue(e))}#Ue(e){this.#B=!0,this.#M+=1;let t=this.#f??void 0;this.#u?.abort(),this.#u=null,this.#p=this.#c.armGeneration(),this.#c.markConnecting(),this.#ke(),this.#We(e,t),this.#Fe({freshStart:!1})}#We(e,t,i=!1){let s=i&&this.#B&&this.#W!==null;if(this.#B=!0,this.#v.clear("failed"),this.#v.setPaused(!0),this.#H="",this.#f=null,this.#I=0,this.#ee.clear(),e!=="transport-reconnect"&&(this.#ge.clear(),this.#ve=null,this.#P?.destroy(),this.#P=null),(!s||!this.#V)&&(this.#V={reason:e,oldRunId:t}),s)return;this.#ae+=1;let r=this.#ae;this.#Ae(),this.#W=setTimeout(()=>{this.#W=null,!(!this.#B||r!==this.#ae)&&(this.#u?.abort(),this.#u=null,this.#B=!1,this.#V=null,this.#v.setPaused(!1),this.#Y(),this.#te("logic_restart_init_timeout"),this.#c.markDead(),this.#T({error:"connection lost",isPlaying:!1}))},this.#z)}__runIdForTests(){return this.#f}__keepAliveArmedForTests(){return!1}#Ae(){this.#W!==null&&(clearTimeout(this.#W),this.#W=null)}#He(e){let t=this.#V;if(!t)return;let i=this.#M;
14this.#Ae(),this.#B=!1,this.#V=null,this.#v.setPaused(!1),!(this.#X.error!==null&&(this.#T({error:null}),!this.#q(i)))&&(this.#x.patch({_sessionRestarted:!0}),this.#i.emit("session:restarted",{reason:t.reason,oldRunId:t.oldRunId,newRunId:e,generation:this.#p}))}async respond(e,t){if(!this.#f||this.#A)return;let i=this.#f,s=this.#M,{promise:r}=this.#v.enqueue({kind:"public-respond",generation:this.#p,dispatch:()=>this.#e.respond(i,e,t)}),n=await r;if(n.lifecycle==="failed"||n.lifecycle==="timed-out"){let a=n.error??new Error("respond failed");throw this.#q(s)&&this.#T({error:a instanceof Error?a.message:String(a)}),a}}reset(){this.#oe&&!this.#Z||(this.#b+=1,!(!this.#Z&&this.#fe({kind:"reset"}))&&this.#Ce())}#Ce(){this.#pe(()=>this.#ze())}#ze(){this.#M+=1,this.#Y(),this.#qe(),this.#Ae(),this.#B=!1,this.#V=null,this.#v.setPaused(!1),this.#v.clear("canceled");let e=this.#h;this.#O=null,this.#$=[],this.#l?.stop("workflow_session_reset"),this.#l=null,this.#C?.close(),this.#C=null,this.#k?.(),this.#k=null,this.#d?.close(),this.#d=null,this.#h=null,e&&this.#e.stopLogicSession&&this.#e.stopLogicSession(e.logicSessionId,{definitionRef:e.definitionRef,lifecycleEpoch:e.lifecycleEpoch}).catch(()=>{});let t=this.#u!==null;this.#u?.abort(),this.#u=null,t&&this.#c.markDead(),this.#P?.destroy(),this.#P=null,this.#f=null,this.#I=0,this.#x.destroy(),this.#x=new Et,this.#m=new wi(this.#x),this.#L=void 0,this.#X=g({},Hi),this.#ee.clear(),this.#ge.clear(),this.#be.clear(),this.#ve=null,this.#H="",this.#_e={},this.#Z||this.#i.emit("state:change",this.state)}__reconcilerPendingSizeForTests(){return this.#m.__pendingSizeForTests()}__forTestSetPending(e){this.#m.patch(e)}destroy(){this.#b+=1,!this.#oe&&(this.#fe({kind:"destroy"})||this.#pe(()=>{this.#oe=!0,this.#Z=!0,this.#A=!0,this.#M+=1,this.#Ce(),this.#N.destroy(),this.#i.clear(),this.#Z=!1}))}setHostData(e){this.#N.set(e)}__hostDataForTests(){return this.#N}applyStateSync(e){this.#G(()=>{this.#ye(e.gameState??e.storageData,"bridge","replace")})}#ye(e,t,i="patch"){if(this.#A||!e)return;let s=!1,r=this.#d,n=this.#h;if(r&&n){if(t==="bridge"){console.warn("[WorkflowSession] ignored legacy storage bridge during database-backed Logic session");return}let a={};for(let[l,p]of Object.entries(e))if(!ie(l)){if(!n.definition.gameStateSchema[l]){this.#J("logic_undeclared_persisted_key");return}a[l]=T(p,`external.${l}`)}let o=i==="replace"?Object.keys(r.snapshot()).filter(l=>!ie(l)&&!Object.prototype.hasOwnProperty.call(e,l)):[];s=r.commit({commitId:`${t}:${r.revision+1}`,origin:"backend_sync",baseRevision:r.revision,updates:a,removedKeys:o}).changed}else s=this.#m.applyRemote(e,i,t);s&&this.#i.emit("state:change",this.state,{source:t}),this.#E?.onBridgeEcho();for(let a of Object.keys(e))this.#v.notifyStateKeySeen(a,e[a],this.#p)}async#Ge(e){let t=new TextDecoder;this.#H="";try{for(;;){let{done:i,value:s}=await e.reader.read();if(i||this.#A||this.#u!==e)break;s&&s.byteLength>0&&(this.#Se=Date.now(),this.#c.markChunkReceived(this.#p));let{events:r,remaining:n}=yi(t.decode(s,{stream:!0}),this.#H);this.#H=n;for(let a of r){if(this.#A||this.#u!==e)break;this.#De(a,e)}}if(this.#H&&this.#u===e){let{events:i,parseErrors:s}=yi(` 15`,this.#H);if(this.#h&&(s>0||this.#H.trim()&&i.length===0))throw new Error("logic_sse_frame_truncated: Logic stream ended with an incomplete SSE frame");for(let r of i){if(this.#A||this.#u!==e)break;this.#De(r,e)}this.#H=""}}catch(i){if(this.#A||i.name==="AbortError"||this.#u!==e||!this.#X.isPlaying)return;this.#G(()=>{this.#te("logic_stream_error"),this.#T({error:i instanceof Error?i.message:String(i),isPlaying:!1}),this.#i.emit("game:error",i instanceof Error?i.message:String(i))});return}!this.#A&&this.#X.isPlaying&&this.#u===e&&this.#G(()=>{let i="Connection closed unexpectedly";this.#te("logic_stream_closed"),this.#T({isPlaying:!1,error:i}),this.#i.emit("game:error",i),this.#Y(),this.#c.markDead()}),this.#u===e&&this.#ee.clear()}#De(e,t){this.#G(()=>{if(this.#A||this.#u!==t)return;let i=Sr(e);if(!i.valid){console.warn(`[WorkflowSession] skipping malformed SSE event: ${i.reason}`);return}let s=e,r=s.streamSequence;if(Number.isSafeInteger(r)&&r>0){if(r<=this.#I){this.#c.markValidEvent(this.#p);return}if(this.#I>0&&r!==this.#I+1){console.warn(`[WorkflowSession] stream sequence gap: expected ${this.#I+1}, received ${r}`),t.requestReconnect?.();return}}this.#c.markValidEvent(this.#p),!(this.#A||this.#u!==t)&&(this.#it(s,t),Number.isSafeInteger(r)&&r>0&&(this.#I=r))})}#re(e){return!this.#A&&this.#u===e}#q(e){return!this.#A&&e===this.#M}#G(e){this.#he+=1;try{e()}finally{this.#he-=1,this.#Ne()}}#pe(e){this.#le+=1;try{e()}finally{this.#le-=1,this.#Ne()}}#Ne(){this.#he===0&&this.#le===0&&this.#Je()}#fe(e){return this.#he===0&&this.#le===0?!1:this.#se?.kind==="destroy"?(e.kind==="startLogic"&&this.#ue(e.response),!0):(this.#se?.kind==="startLogic"&&this.#ue(this.#se.response),this.#se=e,!0)}#Je(){for(;this.#se&&this.#he===0&&this.#le===0;){let e=this.#se;switch(this.#se=null,e.kind){case"start":this.start(e.nodes,e.storage,e.extensionId,e.workflowId,e.entryPoint);break;case"startLogic":this.#Oe(e.response,e.entryPoint);break;case"reset":this.reset();break;
15case"destroy":this.destroy();break;case"restart":this.#Te(e.reason);break}}}#Qe(e){let t=this.#h,i=this.#y;if(!t||!i)return;if(e.logicSessionId!==t.logicSessionId||e.definitionRef!==t.definitionRef||e.lifecycleEpoch!==t.lifecycleEpoch||typeof e.serverStorageVersion!="string"||!e.gameState){this.#J("logic_definition_mismatch");return}if(this.#l)return;let s=T(e.gameState,"logic.init.state");if(!L(s)){this.#J("logic_state_sync_invalid");return}let r=this.#d;if(!r){this.#J("logic_runtime_unavailable");return}if((je(r.snapshot())!==je(s)||r.serverStorageVersion!==e.serverStorageVersion)&&r.replace(s,"session_init",`session:init:${r.revision+1}`,e.serverStorageVersion),!this.#e.writebackLogicSession){this.#J("logic_runtime_unavailable");return}let n=i.createWorker??_a,a=new Jn({workerUrl:i.workerUrl,expectedWorkerOrigin:i.expectedWorkerOrigin,createWorker:n,digest:va,activity:ya(),nowMs:()=>performance.now(),setTimer:(o,h)=>setTimeout(o,h),clearTimer:o=>clearTimeout(o),logicSessionId:t.logicSessionId,definitionRef:t.definitionRef,lifecycleEpoch:t.lifecycleEpoch,definition:t.definition,stateStore:r,initialCatalog:t.initialCatalog??{},seed128:t.seed128,writeback:o=>this.#Be(async()=>{let h=await this.#e.writebackLogicSession(t.logicSessionId,{definitionRef:o.definitionRef,lifecycleEpoch:o.lifecycleEpoch,requestId:o.requestId,nodeId:o.nodeId,expectedServerStorageVersion:this.#l?.serverStorageVersion??o.expectedServerStorageVersion,patches:[...o.patches],catalogOps:[...o.catalogOps],expectedCatalogVersions:g({},o.expectedCatalogVersions)});if(h.requestId!==o.requestId)throw new Error("Logic writeback request mismatch");return h.outcome==="applied"?{status:"applied",operationId:h.operationId,updates:h.updates,removedKeys:h.removedKeys,serverStorageVersion:h.serverStorageVersion,catalog:h.catalog??{}}:{status:"rejected",rejectionKind:"backend_ledgered",operationId:h.operationId,errorCode:h.errorCode,updates:h.updates,removedKeys:h.removedKeys,serverStorageVersion:h.serverStorageVersion,catalog:h.catalog??{}}}),onReady:()=>i.onReady?.(),onTrace:o=>i.onTrace?.(o),onDiagnostic:(o,h)=>{console.warn("[WorkflowSession] Logic dispatch diagnostic",o,h)},onFatal:o=>{i.onFatal?.(o),this.#G(()=>this.#J(o))}});this.#l=a}#we(e,t){let i=this.#h,s=this.#l;if(!i||!s||this.#O)return;if(e.logicSessionId!==i.logicSessionId||e.definitionRef!==i.definitionRef||e.lifecycleEpoch!==i.lifecycleEpoch||!this.#e.getLogicSessionState){this.#J("logic_state_sync_invalid");return}let r=this.#e.getLogicSessionState(i.logicSessionId,i.definitionRef).then(n=>{if(this.#l!==s||this.#h!==i)return;if(n.logicSessionId!==i.logicSessionId||n.definitionRef!==i.definitionRef||n.lifecycleEpoch!==i.lifecycleEpoch||typeof n.serverStorageVersion!="string")throw new Error("Logic state response identity mismatch");let a=T(n.state,"logic.recovery.state");if(!L(a))throw new Error("Logic state response is invalid");if(!t){s.replaceState(a,n.serverStorageVersion);return}let o=this.#d;if(!o)throw new Error("Session state store is unavailable");let h=o.recoverAutosaveConflict(t.request,a,n.serverStorageVersion);console.warn("[WorkflowSession] Logic autosave conflict recovery",{preservedLocalKeys:h.preservedLocalKeys,canonicalConflictKeys:h.canonicalConflictKeys}),h.preservedLocalKeys.length>0&&this.#E?.markDirty()}).catch(()=>{this.#l===s&&this.#J("logic_state_sync_invalid")}).finally(()=>{this.#O===r&&(this.#O=null)});this.#O=r}#Ye(e){if(e.kind!=="logic_state_sync"&&e.kind!=="logic_state_version")return!1;let t=this.#h,i=this.#l;if(!t||!i||e.logicSessionId!==t.logicSessionId||e.definitionRef!==t.definitionRef||e.lifecycleEpoch!==t.lifecycleEpoch||typeof e.serverStorageVersion!="string")return this.#J("logic_state_sync_invalid"),!0;if(e.serverStorageVersion===i.serverStorageVersion)return!0;if(e.kind==="logic_state_version")return this.#we(e),!0;if(e.previousServerStorageVersion!==i.serverStorageVersion||!e.updates||!Array.isArray(e.removedKeys))return this.#we(e),!0;try{let s=T(e.updates,"logic.sync.updates");if(!L(s)||!e.removedKeys.every(r=>typeof r=="string"))throw new Error("invalid sync");i.syncState(s,e.removedKeys,e.serverStorageVersion)}catch{this.#we(e)}return!0}#Be(e){let t=this.#_.then(e,e);return this.#_=t.then(()=>{},()=>{}),t}#Xe(){let e=this.#h;if(!e)return Mt(this.autosaveSnapshot);let t=this.#d;if(!t)return{};let i=g({},t.autosaveSnapshot());return this.#$=Object.entries(e.definition.gameStateSchema).filter(([s,r])=>r.scope==="clientOnly"&&!Object.prototype.hasOwnProperty.call(i,s)).map(([s])=>s).sort(),i}#Ze(){let e=this.#h;return F(g({},this.#S?.saveStateOptions),{logicSessionId:e.logicSessionId,definitionRef:e.definitionRef,lifecycleEpoch:e.lifecycleEpoch,expectedServerStorageVersion:this.#l?.serverStorageVersion??e.serverStorageVersion,removedClientKeys:[...this.#$]})}#et(e,t,i){let s=this.#d;if(!s||this.#h!==t||typeof e.serverStorageVersion!="string")return;let r;if(e.canonicalClientState!==void 0){let a=T(e.canonicalClientState,"logic.autosave.canonicalClientState");
15if(!L(a)){this.#J("logic_state_sync_invalid");return}r=a}for(let a of Object.keys(r??{}))if(t.definition.gameStateSchema[a]?.scope!=="clientOnly"){this.#J("logic_state_sync_invalid");return}let n=s.reconcileAutosaveEcho(i,r,e.serverStorageVersion);n.preservedLocalKeys.length>0&&(console.warn("[WorkflowSession] autosave canonical correction preserved newer local keys",n.preservedLocalKeys),this.#E?.markDirty())}#tt(e,t){let i=this.#h;if(!i||!t||!e||typeof e!="object")return!1;let s=e;if(this.#O||s.status!==409||!s.body||typeof s.body!="object")return!1;let r=s.body;return r.code!=="logic_state_conflict"||typeof r.serverStorageVersion!="string"||r.canonicalClientState===null||typeof r.canonicalClientState!="object"||Array.isArray(r.canonicalClientState)?!1:(this.#E?.acknowledgeCanonical(),console.warn("[WorkflowSession] Logic autosave CAS conflict; starting canonical database recovery",{serverStorageVersion:r.serverStorageVersion}),this.#we({kind:"logic_state_version",logicSessionId:i.logicSessionId,definitionRef:i.definitionRef,lifecycleEpoch:i.lifecycleEpoch},{request:t}),!0)}#J(e){this.#A||(this.#te(e),this.#u?.abort(),this.#c.markDead(),this.#T({isPlaying:!1,error:e}),this.#i.emit("game:error",e))}#it(e,t){if(!this.#Ye(e)){if(e.eventType==="init"&&e.runId){if(this.#f&&this.#f!==e.runId){let i=`Stream reconnected as a different run (${this.#f} -> ${e.runId})`;this.#Y(),t.abort(),this.#te("logic_stream_identity_changed"),this.#c.markDead(),this.#T({isPlaying:!1,error:i}),this.#i.emit("game:error",i);return}this.#f=e.runId,this.#h&&this.#Qe(e),this.#B&&this.#V&&this.#He(e.runId);return}if(e.eventType==="step"){this.#i.emit("debug:step",e);return}if(e.type==="chat_workflow_storage_updated"){let i=e;this.#ye(i.gameState??i.storageData,"bridge","replace");return}if(e.type?.startsWith("ui:")){switch(wa(e),e.type){case"ui:screen:init":this.#Ve(e,t);break;case"ui:state:sync":case"ui:state:patch":this.#ye(e.gameState,"remote");break;case"ui:waiting":case"ui:screen:ready":this.#rt(e,t);break;default:this.#i.emit("ui:event",e);break}return}if(e.eventType==="game"){this.#st(e,t);return}}}#st(e,t){let i={type:e.type??"unknown",text:e.text,speaker:e.speaker,choices:e.choices,prompt:e.prompt,result:e.result,error:e.error},s=this.#M;if(e.type==="game:finished"){if(this.#Y(),this.#T({isPlaying:!1,isFinished:!0,currentGameEvent:i}),!this.#q(s)||!this.#re(t)||(this.#c.markDead(),!this.#q(s)||!this.#re(t)))return;this.#u?.abort(),this.#i.emit("game:finished",e.result);return}if(e.type==="game:error"){if(this.#Y(),this.#T({isPlaying:!1,error:e.error??"Unknown error",currentGameEvent:i}),!this.#q(s)||!this.#re(t)||(this.#c.markDead(),!this.#q(s)||!this.#re(t)))return;this.#u?.abort(),this.#i.emit("game:error",e.error??"Unknown error");return}this.#T({currentGameEvent:i}),!(!this.#q(s)||!this.#re(t))&&this.#i.emit("game:event",i)}async#Le(e,t){let i=this.#l;if(!i)return{dispatchId:`unavailable:${this.#M}`,aggregate:"unavailable",perNode:[]};try{let s=T(t??null,"screen.logic.payload"),r=this.#O;return r&&await r,this.#l!==i?{dispatchId:`cancelled:${this.#M}`,aggregate:"cancelled",perNode:[]}:await i.dispatch({type:e,payload:s,source:"screen"})}catch{return{dispatchId:`unavailable:${this.#M}`,aggregate:"unavailable",perNode:[]}}}#Ve(e,t){let i=e.layout?.schema??this.#ge.get(e.screenId??"");if(!i)return;let s=e.screenId;if(!s)return;let r;try{r=`${JSON.stringify(s)}::${je(i)}`}catch{r=`${JSON.stringify(s)}::__nohash_${Math.random()}`}if(r===this.#ve&&this.#P)return;this.#ve=r;let n=e.screenId;n!==this.#L&&(this.#m.clearPending(),this.#L=n),this.#P?.destroy(),this.#C?.close(),this.#C=this.#d?.createWriter()??null;for(let m of[...this.#ee])m.startsWith("screen:")&&this.#Ee(m);let a=i.library,o=this.#r?.(),h=o?g(g({},o),a??{}):a,l=h?F(g({},i),{library:h}):i;if(!this.#m.isSplitMode){let m=this.#$e([l]);if(m?.dynamicServerRefs.length)throw new Error("[WorkflowSession] dynamic $server.* construction is unsupported. Paths: "+m.dynamicServerRefs.map(y=>y.path).join(", "));if(m?.hasServerRefs){let y=this.#x.snapshot();if(this.#x.destroy(),this.#x=new Je,this.#m=new Si(this.#x),Object.keys(y).length>0){let A={},b={};for(let[$,W]of Object.entries(y))ie($)?A[$]=W:b[$]=W;let w=this.#x,I=this.#m;Object.keys(b).length>0&&I.patchServer(b),Object.keys(A).length>0&&w.patchClient(A)}}}if(i.initialGameState&&!this.#be.has(s)){let m=this.#je(i);m&&(this.#C?this.#C.patchInitial(m):this.#m.patchInitial(m))}if(this.#be.add(s),this.#ge.set(s,i),this.#i.emit("screen:init",{screenId:s,schema:l}),!this.#re(t))return;let u=this.#l?(m,y)=>
15this.#Le(m,y):void 0,d={schema:l,gameStore:this.#C??this.#m,screenId:s,script:l.script,slotEl:this.#a??void 0,onEvent:m=>this.#Me(m),onNavigate:m=>{this.#de("screen",`navigate:${m}`)},actionHandlers:this.#s,evalEngine:this.#n,onError:this.#o,hostData:this.#N,legacyFlexDefault:this.#R,canvas:this.#g,assets:this.#w,logic:u?{dispatch:u,emit:(m,y)=>{u(m,y).then(A=>{["applied","noop"].includes(A.aggregate)||console.warn("[WorkflowSession] fire-and-forget Logic dispatch failed",m,A.aggregate)})}}:void 0};this.#Ie=l,this.#xe=d,this.#P=vi(this.#t,d),this.#i.emit("screen:ready",s)}#rt(e,t){let i=e.eventKey;if(!(!i||!this.#f)&&(this.#ee.add(i),this.#i.emit("waiter:added",i),!!this.#re(t)&&i.endsWith(":interact")&&this.#P)){let s=this.#P;s.ready.then(()=>{this.#A||!this.#f||this.#P===s&&this.#Ee(i)})}}#Ee(e,t,i){this.#ee.delete(e);let s=e.split(":"),r=s[0],n=s.slice(1).join(":");if(!this.#f)return;let a=this.#f;this.#m.clearPendingWriteback();let o=this.#M,{promise:h}=this.#v.enqueue(g({kind:"waiter-response",generation:this.#p,dispatch:()=>t!==void 0?this.#e.sendUIEvent(a,r,n,t):this.#e.sendUIEvent(a,r,n)},i?{ackExpectation:i}:{}));h.then(l=>this.#G(()=>{if(!this.#q(o))return;if(l.lifecycle==="accepted"||l.lifecycle==="acked"){this.#i.emit("waiter:resolved",e);return}if(l.lifecycle==="canceled")return;let p=l.error;p!==void 0&&(String(p).includes("404")||(this.#ee.add(e),this.#T({error:String(p)})))}))}#Me(e){if(this.#f)switch(e.type){case"emit":if(e.key){let t;if(e.key==="state:writeback"&&e.value&&typeof e.value=="object"&&!Array.isArray(e.value)){let i=Object.keys(e.value);if(i.length>0){let s=this.#m.markPendingWriteback(i);s&&(t=s)}}else this.#m.clearPendingWriteback();if(e.key!=="state:writeback"&&this.#ee.has(e.key)){let i=e.awaitAck&&e.awaitAck.stateKey?g({expectStateKey:e.awaitAck.stateKey,timeoutMs:e.awaitAck.timeoutMs??3e4},"expectValue"in e.awaitAck?{expectValue:e.awaitAck.expectValue}:{}):void 0;this.#Ee(e.key,e.value,i)}else if(e.key.startsWith("element:")){let i=e.key.split(":");this.#de(i[1],i.slice(2).join(":"),e.value)}else if(e.key==="state:writeback"&&e.value&&typeof e.value=="object"&&!Array.isArray(e.value)){let i=e.value,s=Object.keys(i).sort();if(s.length===0)return;let r=e.unsetClientOnAck??[];this.#de("emit","state:writeback",i,`state:writeback:${JSON.stringify(s)}`,n=>{if(n.lifecycle==="accepted"||n.lifecycle==="acked"){if(r.length>0)for(let a of r)this.#m.unsetClientOnAck?.(a)}else if(t&&this.#m.removeEnvelope?.(t),r.length>0)for(let a of r)this.#m.unsetClient?.(a)})}else if(e.awaitAck&&e.awaitAck.stateKey){let i=g({expectStateKey:e.awaitAck.stateKey,timeoutMs:e.awaitAck.timeoutMs??3e4},"expectValue"in e.awaitAck?{expectValue:e.awaitAck.expectValue}:{});this.emitWithAck("emit",e.key,e.value,i)}else this.#de("emit",e.key,e.value)}break;case"logic":e.key&&this.#Le(e.key,e.value).then(t=>{["applied","noop"].includes(t.aggregate)||console.warn("[WorkflowSession] declarative Logic dispatch failed",e.key,t.aggregate)}).catch(t=>{console.warn("[WorkflowSession] declarative Logic dispatch failed",e.key,t)});break;case"navigate":this.#m.clearPendingWriteback(),this.#de("screen",`navigate:${e.key}`);break;case"error":break;case"state:change":this.#d||this.#E?.markDirty(),this.#i.emit("screen:state-change");break;case"navigate:blocked":break}}#de(e,t,i,s,r){if(!this.#f)return;let n=this.#f,a=this.#M,{promise:o}=this.#v.enqueue({kind:"ui-event",dedupKey:s,dedupPayload:i,generation:this.#p,dispatch:()=>i!==void 0?this.#e.sendUIEvent(n,e,t,i):this.#e.sendUIEvent(n,e,t)});o.then(h=>this.#G(()=>{if(!this.#q(a)||(r&&r(h),h.lifecycle!=="failed"&&h.lifecycle!=="timed-out"))return;let l=h.error;l!==void 0&&(String(l).includes("404")||this.#T({error:String(l)}))}))}#T(e){this.#X=g(g({},this.#X),e),this.#i.emit("state:change",this.state)}#je(e){if(!e.initialGameState)return;let{seed:t}=gi({literals:e.initialGameState,storage:this.#_e}),i=Object.keys(e.initialGameState),s={};for(let r of i)r in t&&(s[r]=t[r]);return Object.keys(s).length>0?s:void 0}_resolveSeedForReconciler(e){return this.#je(e)}#$e(e){try{if(typeof Ct!="function"||typeof At!="function"||typeof Je!="function")return}catch{return}let t=Ct(e);return At(t)}__reconcilerForTests(){return this.#m}__storeForTests(){return this.#x}__keepAliveForTests(){}__forTestCommitScreenState(e){if(!this.#d)throw new Error("Session state store is unavailable");let t=this.#d.createWriter();t.patch(e),t.close()}__simulateBridgePush(e){this.#ye(e,"bridge","replace")}__forTestOnScreenInit(e){this.#Ve(e,this.#u)}
15__forTestOnScreenEvent(e){this.#Me(e)}};function La(e){let t=new cr,i=new xa(e.transport,e.screenContainer,t,e.slotEl,e.library,e.actionHandlers,e.evalEngine,e.onPreDeathFlush,e.transportTiming,e.onError,{autoSave:e.autoSave,keepAlive:e.keepAlive,canvas:e.canvas,assets:e.assets,logicRuntime:e.logicRuntime,legacyFlexDefault:e.legacyFlexDefault,previewRunLeaseId:e.previewRunLeaseId});return{start:(s,r,n,a,o)=>{i.start(s,r,n,a,o).catch(h=>{t.emit("game:error",h instanceof Error?h.message:String(h))})},startLogic:async(s,r)=>{try{await i.startLogic(s,r)}catch(n){let a=n instanceof Error?n.message:String(n);throw t.emit("game:error",a),n}},respond:(s,r)=>i.respond(s,r),reset:()=>i.reset(),destroy:()=>i.destroy(),cancelActiveRun:()=>i.cancelActiveRun(),applyStateSync:s=>i.applyStateSync(s),setHostData:s=>i.setHostData(s),emitWithAck:(s,r,n,a)=>i.emitWithAck(s,r,n,a),on:(s,r)=>t.on(s,r),off:(s,r)=>t.off(s,r),get state(){return i.state},get activeScreenHandle(){return i.activeScreenHandle},get connectionState(){return i.connectionState},get autosaveSnapshot(){return i.autosaveSnapshot},get hasPendingOps(){return i.hasPendingOps},get gameStore(){return i.gameStore},getMountedSchema:()=>i.getMountedSchema(),get onError(){return i.onError}}}function zi(e,t,i){let s={extensionId:e,storages:t};return i?.chatId!==void 0&&(s.chatId=i.chatId),i?.workflowId!==void 0&&(s.workflowId=i.workflowId),i?.logicSessionId!==void 0&&(s.logicSessionId=i.logicSessionId),i?.definitionRef!==void 0&&(s.definitionRef=i.definitionRef),i?.lifecycleEpoch!==void 0&&(s.lifecycleEpoch=i.lifecycleEpoch),i?.expectedServerStorageVersion!==void 0&&(s.expectedServerStorageVersion=i.expectedServerStorageVersion),i?.removedClientKeys!==void 0&&(s.removedClientKeys=i.removedClientKeys),i?.baseRevision!==void 0&&(s.baseRevision=i.baseRevision),i?.snapshotKeys!==void 0&&(s.snapshotKeys=i.snapshotKeys),s}function ka(e,t){return Object.assign(new Error(`saveState failed: HTTP ${e}`),{status:e,body:t})}var Aa=class extends Error{constructor(e,t,i,s,r,n){super(e),this.status=t,this.body=i,this.code=s,this.offendingKey=r,this.requestId=n}name="RuntimeHttpError"};function Vt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function tt(...e){return e.find(t=>typeof t=="string"&&t.length>0)}async function ge(e,t){let i;try{i=await e.json()}catch{i=void 0}let s=Vt(i),r=Vt(s?.message)??Vt(s?.error),n=tt(s?.code,r?.code),a=tt(s?.offendingKey,s?.key,s?.path,r?.offendingKey,r?.key,r?.path),o=tt(s?.requestId,r?.requestId,e.headers?.get?.("x-request-id")),h=tt(s?.message,r?.message,s?.error),l=`${t?`${t}: `:""}HTTP ${e.status}`,p=[n?`code=${n}`:void 0,a?`key=${a}`:void 0,o?`requestId=${o}`:void 0].filter(Boolean),u=`${h??l}${p.length?` [${p.join(", ")}]`:""}`;return new Aa(u,e.status,i,n,a,o)}var Ca=Symbol("http-transport");function Va(e,t,i){let s=i?.route??(o=>o),r=async(o,h)=>{let l=new AbortController;h.signal&&h.signal.addEventListener("abort",()=>l.abort(),{once:!0});let p=await t(s(o),F(g({},h),{signal:l.signal}));if(!p.ok)throw await ge(p);if(!p.body)throw new Error("Response has no body");return{reader:p.body.getReader(),abort:()=>l.abort()}},n=async(o,h)=>{let l=await t(s(o),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(!l.ok)throw await ge(l);return await l.json()},a={async openStream(o,h,l){let p=new AbortController;h&&h.addEventListener("abort",()=>p.abort(),{once:!0});let u=l?`${e}/runtime/play/stream/${encodeURIComponent(l.runId)}`:`${e}/runtime/play/stream`,d=await t(s(u),{method:"POST",headers:l?{"Last-Event-ID":String(l.lastEventId)}:{"Content-Type":"application/json"},body:l?void 0:JSON.stringify(o),signal:p.signal});if(!d.ok)throw await ge(d);if(!d.body)throw new Error("Response has no body");return{reader:d.body.getReader(),abort:()=>p.abort()}},async sendUIEvent(o,h,l,p){let u=await t(s(`${e}/runtime/play/ui-event/${o}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({elementId:h,event:l,value:p})});if(!u.ok)throw await ge(u,"sendUIEvent failed")},async respond(o,h,l){let p=await t(s(`${e}/runtime/play/respond/${o}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,value:l})});if(!p.ok)throw await ge(p,"respond failed")},async cancelRun(o){let h=await t(s(`${e}/runtime/play/cancel/${encodeURIComponent(o)}`),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0});if(!h.ok&&h.status!==404)throw await ge(h,"cancelRun failed")}
15,async saveState(o,h,l){let p=zi(o,h,l),u=await t(s(`${e}/runtime/play/save-state`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)}),d;try{d=await u.json()}catch{d=void 0}if(!u.ok)throw ka(u.status,d);if(l?.logicSessionId!==void 0)return d},saveStateBeacon(o,h,l){if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return!1;let p=zi(o,h,l),u=new Blob([JSON.stringify(p)],{type:"application/json"});return navigator.sendBeacon(s(`${e}/runtime/play/save-state`),u)},startLogicSession(o){return n(`${e}/runtime/logic-sessions/start`,o)},openPinnedLogicStream(o,h){return r(`${e}/runtime/play/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:h})},reattachLogicStream(o,h,l){return r(`${e}/runtime/play/stream/${encodeURIComponent(o)}`,{method:"POST",headers:{"Last-Event-ID":String(h)},signal:l})},writebackLogicSession(o,h){return n(`${e}/runtime/logic-sessions/${encodeURIComponent(o)}/writeback`,h)},async getLogicSessionState(o,h){let l=new URLSearchParams({definitionRef:h}),p=await t(s(`${e}/runtime/logic-sessions/${encodeURIComponent(o)}/state?${l.toString()}`));if(!p.ok)throw await ge(p);return await p.json()},stopLogicSession(o,h){return n(`${e}/runtime/logic-sessions/${encodeURIComponent(o)}/stop`,h)}};return Object.defineProperty(a,Ca,{value:!0,enumerable:!1,writable:!1,configurable:!1}),a}function Ea(e,t){return e<t?-1:e>t?1:0}function Ne(e,t){return e instanceof f?e.code:t}function Ia(e){return(e.patches?.length??0)===0&&(e.catalogOps?.length??0)===0&&(e.emits?.length??0)===0&&(e.schedule?.length??0)===0}var Ma=class{#e;#t;#i;#a;#r;#s;#o;#n;#g;#R;#w=new Map;#S=new Map;#y=[];#l=new Map;#d=new Map;#C=new Map;#k=[];#h;#O;#_;#$=0;#b=0;#E=0;#F=null;#K=0;#j=new Map;#z;#U;#D=!1;constructor(e){if(this.#e=e.logicSessionId,this.#t=e.definitionRef,this.#i=e.lifecycleEpoch,this.#a=e.definition,this.#s=e.clock,this.#o=e.scheduler,this.#n=e.compile,this.#g=e.onOutput,this.#R=new Bn(e.seed128),!Number.isSafeInteger(e.lifecycleEpoch)||e.lifecycleEpoch<=0)throw new f("logic_protocol_error","lifecycleEpoch must be a positive safe integer");if(!Number.isSafeInteger(e.stateRevision)||e.stateRevision<0)throw new f("logic_protocol_error","stateRevision must be a non-negative safe integer");this.#r=ii(e.definition.gameStateSchema),this.#h=this.#x(e.initialState),this.#O=this.#N(e.initialCatalog??{}),this.#_=e.stateRevision;let t=e.definition.rootNodes.filter(i=>i.type==="logic"&&i.disabled!==!0).map((i,s)=>Ji(i,`definition.rootNodes[${s}]`));if(t.length>x.maxActiveRootNodes)throw new f("logic_definition_invalid","Active Logic Node limit exceeded");for(let i of t){let s=this.#n(i);if(typeof s!="function")throw new f("logic_source_invalid",`${i.id} did not compile to a function`);this.#w.set(i.id,s);for(let r of i.params.listens){let n=this.#S.get(r)??[];n.push(i),n.sort((a,o)=>Ea(a.id,o.id)),this.#S.set(r,n)}}this.#v({kind:"worker.ready",payload:{runtimeProfileVersion:1,limitProfileVersion:1}})}get stateRevision(){return this.#_}get stopped(){return this.#D}enqueue(e){if(!this.#D)try{let t=Ee(e.type);if(e.source==="screen"&&t.startsWith("runtime."))throw new f("logic_protocol_error","Screen cannot emit runtime.* events");if(e.source!=="screen"&&e.source!=="runtime")throw new f("logic_protocol_error","Invalid ingress source");let i=T(e.payload,"event.payload");if(Ce(i).byteLength>x.maxEventPayloadUtf8Bytes)throw new f("logic_result_invalid","Event payload exceeds limits");if(e.dispatchId!==void 0&&!/^[A-Za-z0-9:_-]{1,128}$/.test(e.dispatchId))throw new f("logic_protocol_error","dispatchId is invalid");if(e.minimumStateRevision!==void 0&&(!Number.isSafeInteger(e.minimumStateRevision)||e.minimumStateRevision<0))throw new f("logic_protocol_error","minimumStateRevision is invalid");let s=this.#P(t,i,e.source,void 0,g(g({},e.dispatchId!==void 0?{dispatchId:e.dispatchId}:{}),e.minimumStateRevision!==void 0?{minimumStateRevision:e.minimumStateRevision}:{}));this.#f(s),this.#V(s,"enqueue",{stateRevision:this.#_,redactedSummary:{source:s.source,subscriberCount:this.#S.get(s.type)?.length??0,queueDepth:this.#y.length}}),this.#I()}catch(t){this.#B(Ne(t,"logic_protocol_error"))}}syncState(e,t,i){if(!this.#D)try{if(e!==this.#_+1)throw new f("logic_state_sync_invali
15d","State sync revision is not the exact successor");this.#L(t,i),this.#_=e,this.#I()}catch(s){this.#B(Ne(s,"logic_state_sync_invalid"))}}applyOutcome(e,t){if(this.#D)return;let i=this.#F;if(!i||i.requestId!==e.requestId){this.#B("logic_protocol_error");return}try{let s=e.updates!==void 0||e.removedKeys!==void 0,r=Object.keys(e.updates??{}).length>0||(e.removedKeys?.length??0)>0;if(t&&e.stateRevision!==this.#_&&e.stateRevision!==this.#_+1)throw new f("logic_protocol_error","Applied outcome revision is not the exact successor");if(!t&&e.stateRevision!==this.#_&&e.stateRevision!==this.#_+1)throw new f("logic_protocol_error","Rejected outcome has an impossible revision");if(e.stateRevision===this.#_+1&&!s)throw new f("logic_protocol_error","Revision advance requires canonical state");if(e.stateRevision===this.#_&&r)throw new f("logic_protocol_error","Canonical delta requires a revision advance");s&&this.#L(e.updates??{},e.removedKeys??[]),e.catalog&&this.#m(e.catalog),this.#_=e.stateRevision,this.#F=null,this.#ie(i),t&&this.#p(i),this.#V(i.queueEntry.event,t?i.resultKind==="writeback"?"writeback":"commit":"reject",F(g({requestId:i.requestId,nodeId:i.node.id,stateRevision:this.#_,durationMs:this.#W(i.startedAtMs)},e.errorCode?{code:e.errorCode}:{}),{redactedSummary:{applied:t,patchCount:i.result.patches?.length??0,catalogOperationCount:i.result.catalogOps?.length??0,emittedEventCount:i.result.emits?.length??0,scheduledEventCount:i.result.schedule?.length??0}})),i.queueEntry.nextSubscriber+=1,this.#I()}catch(s){this.#B(Ne(s,"logic_protocol_error"))}}stop(){if(this.#D)return;let e=this.#F;this.#V(e?.queueEntry.event??this.#ae("stop"),"stop",F(g({},e?{requestId:e.requestId,nodeId:e.node.id}:{}),{stateRevision:this.#_,redactedSummary:{queueDepth:this.#y.length,scheduledCount:this.#k.length}})),this.#D=!0,this.#z!==void 0&&this.#o.clear(this.#z),this.#U!==void 0&&this.#o.clear(this.#U),this.#z=void 0,this.#U=void 0,this.#y.length=0,this.#k.length=0,this.#F=null,this.#K=0,this.#j.clear(),this.#l.clear(),this.#d.clear(),this.#C.clear()}#x(e){let t=T(e,"state");if(!L(t))throw new f("logic_state_sync_invalid","State must be an object");for(let[i,s]of Object.entries(t)){let r=this.#r[i];if(!r||!ve(r.type,s))throw new f("logic_state_sync_invalid",`State key ${i} is undeclared or invalid`)}return t}#N(e){let t={};for(let[i,s]of Object.entries(e)){if(!s||typeof s.version!="string"||!/^(0|[1-9][0-9]*)$/.test(s.version))throw new f("logic_catalog_invalid","Catalog snapshot version is invalid: "+i);let r=T(s.value,"catalog."+i);if(!L(r))throw new f("logic_catalog_invalid","Catalog snapshot root must be an object: "+i);t[i]=r}return t}#m(e){let t=this.#N(e);for(let[i,s]of Object.entries(t)){if(!Object.prototype.hasOwnProperty.call(this.#O,i))throw new f("logic_protocol_error","Unknown catalog alias in outcome: "+i);this.#O[i]=s}}#L(e,t){let i=T(this.#h,"state");if(!L(i))throw new f("logic_state_sync_invalid","State mirror is invalid");let s=T(e,"updates");if(!L(s))throw new f("logic_state_sync_invalid","State updates must be an object");for(let[r,n]of Object.entries(s)){let a=this.#r[r];if(!a||!ve(a.type,n))throw new f("logic_state_sync_invalid",`State update ${r} is invalid`);i[r]=n}for(let r of t){if(typeof r!="string"||!this.#r[r])throw new f("logic_state_sync_invalid",`Removed state key ${String(r)} is invalid`);delete i[r]}this.#h=i}#P(e,t,i,s,r={}){if(this.#$+=1,!Number.isSafeInteger(this.#$))throw new f("logic_protocol_error","Event sequence overflow");let n=`${this.#e}:${this.#i}:${this.#$}`,a=s??n,o=(this.#l.get(a)??0)+1,h=this.#j.get(a)??0;if(o+h>x.maxEventsPerCausalRoot)throw new f("logic_queue_overflow","Causal root event limit exceeded");return this.#l.set(a,o),it(g(g({id:n,type:e,payload:t,source:i,causalRootId:a,sequence:this.#$,occurredAtMs:this.#s.nowMs()},r.dispatchId!==void 0?{dispatchId:r.dispatchId}:{}),r.minimumStateRevision!==void 0?{minimumStateRevision:r.minimumStateRevision}:{}))}#f(e){if(this.#y.length+this.#K>=x.maxAggregateQueuedEvents)throw new f("logic_queue_overflow","Aggregate event queue limit exceeded");this.#y.push({event:e,subscribers:this.#S.get(e.type)??[],nextSubscriber:0,requestIds:[],announced:!1}
15),this.#d.set(e.causalRootId,(this.#d.get(e.causalRootId)??0)+1)}#I(){this.#D||this.#F||this.#z!==void 0||(this.#z=this.#o.set(0,()=>{this.#z=void 0,this.#u()}))}#u(){if(this.#D||this.#F)return;let e=0;for(;!this.#D&&!this.#F&&e<64;){let t=this.#y[0];if(!t||(t.event.minimumStateRevision??0)>this.#_)return;if(!t.announced){let i=this.#b+t.subscribers.length;if(!Number.isSafeInteger(i)){this.#B("logic_protocol_error");return}t.requestIds=t.subscribers.map(()=>(this.#b+=1,String(this.#b))),t.announced=!0,t.event.dispatchId!==void 0&&this.#v({kind:"event.dispatched",payload:{dispatchId:t.event.dispatchId,eventId:t.event.id,handlers:t.subscribers.map((s,r)=>({requestId:t.requestIds[r],nodeId:s.id})),stateRevision:this.#_}})}if(t.nextSubscriber>=t.subscribers.length){this.#y.shift(),this.#ce(this.#d,t.event.causalRootId),this.#ne(t.event.causalRootId),e+=1;continue}this.#c(t,t.subscribers[t.nextSubscriber]),e+=1}!this.#F&&this.#y.length>0&&this.#I()}#c(e,t){let i=e.requestIds[e.nextSubscriber],s=this.#_,r=this.#s.nowMs();this.#v({kind:"handler.started",payload:{requestId:i,nodeId:t.id,eventId:e.event.id,baseStateRevision:s}}),this.#V(e.event,"start",{requestId:i,nodeId:t.id,stateRevision:s});let n;try{let l=Object.freeze({nowMs:this.#s.nowMs(),state:Object.freeze({get:p=>it(Ii(this.#h,p,t.params.reads))}),catalog:Object.freeze({get:p=>it(Ii(this.#O,p,t.params.catalogReads))}),random:()=>this.#R.next()});n=this.#w.get(t.id)(e.event,l)}catch{this.#v({kind:"handler.failed",payload:{requestId:i,errorCode:"logic_handler_failed"}}),this.#V(e.event,"error",{requestId:i,nodeId:t.id,stateRevision:s,code:"logic_handler_failed",durationMs:this.#W(r)}),e.nextSubscriber+=1,this.#I();return}let a,o=null;try{if(a=Ds(n,t),!a||Ia(a)){this.#v({kind:"handler.noop",payload:{requestId:i}}),this.#V(e.event,"noop",{requestId:i,nodeId:t.id,stateRevision:s,durationMs:this.#W(r)}),e.nextSubscriber+=1,this.#I();return}if(o=Bs({patches:a.patches??[],writes:t.params.writes,schema:this.#r,currentState:this.#h}).scope,this.#k.length+(a.schedule?.length??0)>x.maxPendingSchedules)throw new f("logic_schedule_invalid","Pending schedule limit would be exceeded");let p=a.emits?.length??0;if(this.#y.length+this.#K+p>x.maxAggregateQueuedEvents)throw new f("logic_queue_overflow","Emitted events would overflow the queue");let u=e.event.causalRootId;if((this.#l.get(u)??0)+(this.#j.get(u)??0)+p>x.maxEventsPerCausalRoot)throw new f("logic_queue_overflow","Emitted events would overflow the causal root");this.#K+=p,this.#j.set(u,(this.#j.get(u)??0)+p)}catch(l){let p=Ne(l,"logic_result_invalid");if(p==="logic_queue_overflow"){this.#B(p);return}this.#v({kind:"handler.failed",payload:{requestId:i,errorCode:p}}),this.#V(e.event,"error",{requestId:i,nodeId:t.id,stateRevision:s,code:p,durationMs:this.#W(r)}),e.nextSubscriber+=1,this.#I();return}let h=o==="serverMirror"||(a.catalogOps?.length??0)>0?"writeback":"commit";this.#F={requestId:i,queueEntry:e,node:t,result:a,scope:o,reservedEmittedEvents:a.emits?.length??0,startedAtMs:r,resultKind:h},this.#v({kind:o==="serverMirror"||(a.catalogOps?.length??0)>0?"writeback.request":"result.commit",payload:{requestId:i,nodeId:t.id,eventId:e.event.id,baseStateRevision:s,result:a}})}#p(e){for(let t of e.result.emits??[]){let i=this.#P(t.type,t.payload,"logic",e.queueEntry.event.causalRootId);this.#f(i)}for(let t of e.result.schedule??[]){if(this.#k.length>=x.maxPendingSchedules)throw new f("logic_schedule_invalid","Pending schedule limit exceeded");let i=e.queueEntry.event.causalRootId;this.#E+=1,this.#k.push({type:t.type,payload:t.payload,causalRootId:i,dueAtMs:this.#s.nowMs()+t.delayMs,ordinal:this.#E}),this.#C.set(i,(this.#C.get(i)??0)+1)}this.#k.sort((t,i)=>t.dueAtMs-i.dueAtMs||t.ordinal-i.ordinal),this.#Q()}#ie(e){let t=e.reservedEmittedEvents;this.#K=Math.max(0,this.#K-t);let i=e.queueEntry.event.causalRootId,s=(this.#j.get(i)??0)-t;s<=0?this.#j.delete(i):this.#j.set(i,s)}#Q(){if(this.#D||this.#U!==void 0||this.#k.length===0)return;let e=Math.max(0,this.#k[0].dueAtMs-this.#s.nowMs());this.#U=this.#o.set(e,()=>{this.#U=void 0;try{let t=this.#s.nowMs();for(;this.#k[0]&&this.#k[0].dueAtMs<=t;){let i=this.#k.shift();this.#ce(this.#C,i.causalRootId);
15let s=this.#P(i.type,i.payload,"scheduler",i.causalRootId);this.#f(s)}this.#I(),this.#Q()}catch(t){this.#B(Ne(t,"logic_queue_overflow"))}})}#ce(e,t){let i=(e.get(t)??1)-1;i<=0?e.delete(t):e.set(t,i)}#ne(e){!this.#d.has(e)&&!this.#C.has(e)&&this.#F?.queueEntry.event.causalRootId!==e&&this.#l.delete(e)}#B(e){if(this.#D)return;let t=this.#F;this.#V(t?.queueEntry.event??this.#ae("error"),"error",F(g({},t?{requestId:t.requestId,nodeId:t.node.id,durationMs:this.#W(t.startedAtMs)}:{}),{stateRevision:this.#_,code:e})),this.#v({kind:"worker.error",payload:{errorCode:e}}),this.stop()}#W(e){return Math.max(0,this.#s.nowMs()-e)}#ae(e){let t=`${this.#e}::trace:`;return{id:t,type:"runtime.",payload:null,source:"runtime",causalRootId:t,sequence:0,occurredAtMs:this.#s.nowMs()}}#V(e,t,i={}){this.#v({kind:"trace.step",payload:g({logicSessionId:this.#e,definitionRef:this.#t,lifecycleEpoch:this.#i,eventId:e.id,causalRootId:e.causalRootId,phase:t},i)})}#v(e){this.#D||this.#g(e)}};export{Er as DEFAULT_STORAGE_NAME,pr as EPHEMERAL_KEY_NAMES,Ca as HTTP_TRANSPORT_MARKER,Ma as LogicRuntimeCoreV1,Jn as SessionLogicHostAdapterV1,ga as SessionStateStore,Si as SplitModeReconciler,wi as StateReconciler,cr as TypedEmitter,xa as WorkflowSession,Ar as assertStorageEnvelopeWithinBackendCap,Fa as buildAutosaveSnapshot,Va as createHttpTransport,ur as createReconnectingReader,Mt as filterEphemeralKeys,ie as isEphemeralKey,La as mountGame,yi as parseSSEChunk};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.