lecodes-cli 2.2.9 → 2.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/index.js +7470 -14528
  2. package/package.json +8 -8
  3. package/runtime/materials/background.mat +52 -0
  4. package/runtime/sdk-types.json +1 -1
  5. package/runtime/web/VERSION.json +3 -3
  6. package/runtime/web/assets/ar-CHvaraG4.js +1 -0
  7. package/runtime/web/assets/audio-recorder-Bt-Caym7.js +1 -0
  8. package/runtime/web/assets/materials-BzTsWTWO.bin +0 -0
  9. package/runtime/web/assets/speech-DzDPVK_j.js +1 -0
  10. package/runtime/web/player.js +17 -17
  11. package/runtime/web-lite/assets/{index-BttBnvIf.js → index-By07xWGA.js} +1 -1
  12. package/runtime/web-lite/assets/{scene3d-D8LdhX0V.js → scene3d-D5R7Vq3f.js} +58 -58
  13. package/runtime/web-lite/features.json +2 -11
  14. package/runtime/web-lite/lite.js +9 -9
  15. package/runtime/web-lite/plugins/ar/index-CHvaraG4.js +1 -0
  16. package/runtime/web-lite/plugins/audio-recorder/index-Bt-Caym7.js +1 -0
  17. package/runtime/web-lite/plugins/speech/index-DzDPVK_j.js +1 -0
  18. package/runtime/web-lite/plugins.json +3 -0
  19. package/src/commands/app/templates/ios.ts +14 -15
  20. package/src/commands/init/index.ts +195 -195
  21. package/src/commands/render.ts +15 -0
  22. package/src/commands/shared.ts +79 -79
  23. package/src/commands/test.ts +2 -1
  24. package/src/commands/thumbs.ts +185 -185
  25. package/src/compile/screenEntry.ts +123 -123
  26. package/src/declarations/lecodes-headless.d.ts +2 -0
  27. package/src/dev/backendWorker.ts +3 -3
  28. package/src/plugin/contract.ts +29 -12
  29. package/src/plugin/emitKotlin.ts +33 -8
  30. package/src/plugin/emitSdk.ts +23 -9
  31. package/src/plugin/emitSwift.ts +33 -8
  32. package/src/plugin/emitWeb.ts +57 -1
  33. package/src/plugin/generate.ts +22 -1
  34. package/src/plugin/lower.ts +42 -6
  35. package/src/plugin/permissions.ts +52 -0
  36. package/src/project/ignore.ts +164 -164
  37. package/runtime/web/assets/materials-uri4FvPE.bin +0 -0
  38. package/runtime/web-lite/assets/ar-BOdQ-wV4.js +0 -1
@@ -1,21 +1,21 @@
1
- var Pn=Object.defineProperty;var Cn=(n,t,e)=>t in n?Pn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var m=(n,t,e)=>Cn(n,typeof t!="symbol"?t+"":t,e);import{K as ge,k as On}from"./assets/keyboardMotion-C2Bk5H0n.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=e(r);fetch(r.href,i)}})();const In="modulepreload",Fn=function(n,t){return new URL(n,t).href},me={},j=function(t,e,s){let r=Promise.resolve();if(e&&e.length>0){let o=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const a=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),l=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));r=o(e.map(c=>{if(c=Fn(c,s),c in me)return;me[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!s)for(let b=a.length-1;b>=0;b--){const g=a[b];if(g.href===c&&(!d||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${u}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":In,d||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),d)return new Promise((b,g)=>{p.addEventListener("load",b),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},Nn={full:()=>j(()=>import("./assets/creator-full-B13Tbmyv.js"),[],import.meta.url),"2d":()=>j(()=>import("./assets/creator-2d-CP3Nfpma.js"),[],import.meta.url),ui:()=>j(()=>import("./assets/creator-ui-CQghF7sw.js"),[],import.meta.url)},Un={full:()=>new URL(""+new URL("assets/creator-full-D1sSItG6.wasm",import.meta.url).href,import.meta.url).href,"2d":()=>new URL(""+new URL("assets/creator-2d-DLtO_8eE.wasm",import.meta.url).href,import.meta.url).href,ui:()=>new URL(""+new URL("assets/creator-ui-ByVRKvqF.wasm",import.meta.url).href,import.meta.url).href},Wn=async(n,t={})=>{const e=(await Nn[n]()).default,s=Un[n](),r={locateFile:o=>o.endsWith(".wasm")?s:o,...t.glContext?{filament_glContext:t.glContext,filament_glOptions:t.glOptions??{}}:{},...t.gl2dContext?{creator2d_glContext:t.gl2dContext,creator2d_glOptions:t.gl2dOptions??{}}:{},...t.moduleArgs},i=await e(r);if(typeof i._creatorWebVersion!="function")throw new Error(`creator-web: ${n} is not a creator-web profile module`);return i},Je=1,Qe=2,Ze=3,ye=4,Bn=5,Dn=6,Hn=7,we=8,Zt=15,tn=4293918720,xt=n=>(tn|n<<16)>>>0,$n=xt(Je),Gn=xt(Qe),Vn=xt(Ze),jn=xt(Zt),be=n=>(n&4293918720)>>>0===tn?n>>>16&15:0,ve=64*1024;class zn{constructor(t,e){m(this,"M");m(this,"host");m(this,"out",0);m(this,"table",[void 0]);m(this,"refs",[0]);m(this,"freeSlots",[]);m(this,"objIndex",new WeakMap);m(this,"pending");m(this,"hasPending",!1);m(this,"worlds",new Map);m(this,"nextWorld",2);m(this,"newWorld");m(this,"argBase",0);m(this,"argSp",0);m(this,"scratch",new DataView(new ArrayBuffer(8)));m(this,"classRegistry");m(this,"tracked",new Map);m(this,"fnRegistry");m(this,"opaques",new WeakMap);this.M=t,this.host=e.host,this.worlds.set(1,e.world),this.newWorld=e.newWorld,this.argBase=t._malloc(ve),this.argSp=this.argBase,this.classRegistry=new FinalizationRegistry(s=>{this.tracked.delete(s)&&this.M._jsbFinalize(s.cls,s.opaque)}),this.fnRegistry=new FinalizationRegistry(s=>{this.M._jsbFunctionGone(s)})}_init(t){this.out=t}write(t,e){const s=this.M;if(typeof e=="number")return s.HEAPF64[t>>3]=e!==e?NaN:e,0;let r=0,i,o=0;return e===void 0?i=$n:e===null?i=Gn:typeof e=="boolean"?(i=Vn,r=e?1:0):(r=o=this.alloc(e),i=xt(typeof e=="function"?Bn:typeof e=="string"?Dn:Array.isArray(e)?Hn:typeof e=="object"?ye:we)),s.HEAPU32[t>>2]=r,s.HEAPU32[(t>>2)+1]=i,o}writeOut(t){this.write(this.out,t)}writeOutException(){const t=this.M;t.HEAPU32[this.out>>2]=0,t.HEAPU32[(this.out>>2)+1]=jn}decode(t,e){switch(be(e)){case 0:return this.scratch.setUint32(0,t,!0),this.scratch.setUint32(4,e,!0),this.scratch.getFloat64(0,!0);case Je:case Zt:return;case Qe:return null;case Ze:return t!==0;default:return this.table[t]}}readAt(t){const e=this.M;return this.decode(e.HEAPU32[t>>2],e.HEAPU32[(t>>2)+1])}valueAt(t){return t?this.readAt(t):void 0}takeOut(){const t=this.M,e=t.HEAPU32[this.out>>2],s=t.HEAPU32[(this.out>>2)+1],r=be(s);if(r===Zt)return{value:void 0,threw:!0};const i=this.decode(e,s);return r>=ye&&r<=we&&this.release(e),{value:i,threw:!1}}args(t,e){const s=new Array(t);for(let r=0;r<t;r++)s[r]=this.readAt(e+r*8);return s}alloc(t){const e=typeof t=="object"||typeof t=="function";if(e){const r=this.objIndex.get(t);if(r!==void 0)return this.refs[r]++,r}let s;return this.freeSlots.length>0?(s=this.freeSlots.pop(),this.table[s]=t,this.refs[s]=1):(s=this.table.length,this.table.push(t),this.refs.push(1)),e&&this.objIndex.set(t,s),s}dup(t){t>0&&this.refs[t]++}release(t){var s;if(t<=0)return;if(this.refs[t]<=0){console.warn(`[jsb] release of a dead handle ${t} (${typeof this.table[t]})`,(s=new Error().stack)==null?void 0:s.split(`
1
+ var Un=Object.defineProperty;var Bn=(n,t,e)=>t in n?Un(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var w=(n,t,e)=>Bn(n,typeof t!="symbol"?t+"":t,e);import{K as ye,k as Wn}from"./assets/keyboardMotion-C2Bk5H0n.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=e(r);fetch(r.href,i)}})();const Dn="modulepreload",Hn=function(n,t){return new URL(n,t).href},we={},D=function(t,e,s){let r=Promise.resolve();if(e&&e.length>0){let o=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const a=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=o(e.map(h=>{if(h=Hn(h,s),h in we)return;we[h]=!0;const u=h.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(!!s)for(let y=a.length-1;y>=0;y--){const b=a[y];if(b.href===h&&(!u||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${f}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":Dn,u||(p.as="script"),p.crossOrigin="",p.href=h,c&&p.setAttribute("nonce",c),document.head.appendChild(p),u)return new Promise((y,b)=>{p.addEventListener("load",y),p.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},$n={full:()=>D(()=>import("./assets/creator-full-B13Tbmyv.js"),[],import.meta.url),"2d":()=>D(()=>import("./assets/creator-2d-CP3Nfpma.js"),[],import.meta.url),ui:()=>D(()=>import("./assets/creator-ui-CQghF7sw.js"),[],import.meta.url)},Vn={full:()=>new URL(""+new URL("assets/creator-full-D1sSItG6.wasm",import.meta.url).href,import.meta.url).href,"2d":()=>new URL(""+new URL("assets/creator-2d-DLtO_8eE.wasm",import.meta.url).href,import.meta.url).href,ui:()=>new URL(""+new URL("assets/creator-ui-ByVRKvqF.wasm",import.meta.url).href,import.meta.url).href},Gn=async(n,t={})=>{const e=(await $n[n]()).default,s=Vn[n](),r={locateFile:o=>o.endsWith(".wasm")?s:o,...t.glContext?{filament_glContext:t.glContext,filament_glOptions:t.glOptions??{}}:{},...t.gl2dContext?{creator2d_glContext:t.gl2dContext,creator2d_glOptions:t.gl2dOptions??{}}:{},...t.moduleArgs},i=await e(r);if(typeof i._creatorWebVersion!="function")throw new Error(`creator-web: ${n} is not a creator-web profile module`);return i},Ze=1,tn=2,en=3,be=4,jn=5,zn=6,Kn=7,ve=8,te=15,nn=4293918720,St=n=>(nn|n<<16)>>>0,Xn=St(Ze),Yn=St(tn),qn=St(en),Jn=St(te),xe=n=>(n&4293918720)>>>0===nn?n>>>16&15:0,Ee=64*1024;class Qn{constructor(t,e){w(this,"M");w(this,"host");w(this,"out",0);w(this,"table",[void 0]);w(this,"refs",[0]);w(this,"freeSlots",[]);w(this,"objIndex",new WeakMap);w(this,"pending");w(this,"hasPending",!1);w(this,"worlds",new Map);w(this,"nextWorld",2);w(this,"newWorld");w(this,"argBase",0);w(this,"argSp",0);w(this,"scratch",new DataView(new ArrayBuffer(8)));w(this,"classRegistry");w(this,"tracked",new Map);w(this,"fnRegistry");w(this,"opaques",new WeakMap);this.M=t,this.host=e.host,this.worlds.set(1,e.world),this.newWorld=e.newWorld,this.argBase=t._malloc(Ee),this.argSp=this.argBase,this.classRegistry=new FinalizationRegistry(s=>{this.tracked.delete(s)&&this.M._jsbFinalize(s.cls,s.opaque)}),this.fnRegistry=new FinalizationRegistry(s=>{this.M._jsbFunctionGone(s)})}_init(t){this.out=t}write(t,e){const s=this.M;if(typeof e=="number")return s.HEAPF64[t>>3]=e!==e?NaN:e,0;let r=0,i,o=0;return e===void 0?i=Xn:e===null?i=Yn:typeof e=="boolean"?(i=qn,r=e?1:0):(r=o=this.alloc(e),i=St(typeof e=="function"?jn:typeof e=="string"?zn:Array.isArray(e)?Kn:typeof e=="object"?be:ve)),s.HEAPU32[t>>2]=r,s.HEAPU32[(t>>2)+1]=i,o}writeOut(t){this.write(this.out,t)}writeOutException(){const t=this.M;t.HEAPU32[this.out>>2]=0,t.HEAPU32[(this.out>>2)+1]=Jn}decode(t,e){switch(xe(e)){case 0:return this.scratch.setUint32(0,t,!0),this.scratch.setUint32(4,e,!0),this.scratch.getFloat64(0,!0);case Ze:case te:return;case tn:return null;case en:return t!==0;default:return this.table[t]}}readAt(t){const e=this.M;return this.decode(e.HEAPU32[t>>2],e.HEAPU32[(t>>2)+1])}valueAt(t){return t?this.readAt(t):void 0}takeOut(){const t=this.M,e=t.HEAPU32[this.out>>2],s=t.HEAPU32[(this.out>>2)+1],r=xe(s);if(r===te)return{value:void 0,threw:!0};const i=this.decode(e,s);return r>=be&&r<=ve&&this.release(e),{value:i,threw:!1}}args(t,e){const s=new Array(t);for(let r=0;r<t;r++)s[r]=this.readAt(e+r*8);return s}alloc(t){const e=typeof t=="object"||typeof t=="function";if(e){const r=this.objIndex.get(t);if(r!==void 0)return this.refs[r]++,r}let s;return this.freeSlots.length>0?(s=this.freeSlots.pop(),this.table[s]=t,this.refs[s]=1):(s=this.table.length,this.table.push(t),this.refs.push(1)),e&&this.objIndex.set(t,s),s}dup(t){t>0&&this.refs[t]++}release(t){var s;if(t<=0)return;if(this.refs[t]<=0){console.warn(`[jsb] release of a dead handle ${t} (${typeof this.table[t]})`,(s=new Error().stack)==null?void 0:s.split(`
2
2
  `).slice(2,6).join(`
3
- `));return}if(--this.refs[t]>0)return;const e=this.table[t];(typeof e=="object"||typeof e=="function")&&this.objIndex.delete(e),this.table[t]=void 0,this.freeSlots.push(t)}liveHandles(){return this.table.length-1-this.freeSlots.length}global(t){var e;this.writeOut(((e=this.worlds.get(t))==null?void 0:e.global)??this.worlds.get(1).global)}newContext(){if(!this.newWorld)return 1;const t=this.nextWorld++;return this.worlds.set(t,this.newWorld()),t}freeContext(t){t!==1&&this.worlds.delete(t)}eval(t,e,s){const r=this.worlds.get(t)??this.worlds.get(1);try{this.writeOut(r.evaluate(e,s))}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}get(t,e,s){const r=this.decode(t,e);if(r==null){this.writeOut(void 0);return}try{this.writeOut(r[s])}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}getIndex(t,e,s){const r=this.decode(t,e);if(r==null){this.writeOut(void 0);return}try{this.writeOut(r[s])}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}has(t,e,s){const r=this.decode(t,e);return(typeof r=="object"||typeof r=="function")&&r!==null&&s in r}set(t,e,s,r){const i=this.table[t];i!=null&&(i[e]=this.decode(s,r))}setIndex(t,e,s,r){const i=this.table[t];i!=null&&(i[e]=this.decode(s,r))}keys(t,e,s){const r=this.M,i=this.decode(t,e),o=(typeof i=="object"||typeof i=="function")&&i!==null?Object.keys(i):[];let a=1;for(const c of o)a+=r.lengthBytesUTF8(c)+1;const h=r._malloc(a);let l=h;for(const c of o){const d=r.lengthBytesUTF8(c)+1;r.stringToUTF8(c,l,d),l+=d}return r.HEAPU32[s>>2]=o.length,h}newObject(t,e){const s={};if(t>0){this.opaques.set(s,{cls:t,opaque:e});const r={ref:new WeakRef(s),cls:t,opaque:e};this.tracked.set(r,r),this.classRegistry.register(s,r,r)}this.writeOut(s)}newArray(){this.writeOut([])}opaqueOf(t,e){const s=this.table[t];if(typeof s!="object"||s===null)return 0;const r=this.opaques.get(s);return r&&r.cls===e?r.opaque:0}json(t,e){let s;try{s=JSON.stringify(this.decode(t,e))}catch{s=void 0}this.writeOut(s)}parseJson(t){try{this.writeOut(JSON.parse(t))}catch(e){this.pending=e,this.hasPending=!0,this.writeOutException()}}newString(t){this.writeOut(t)}str(t,e,s){const r=this.M,i=this.decode(t,e);let o;try{o=typeof i=="string"?i:String(i)}catch{return 0}const a=r.lengthBytesUTF8(o),h=r._malloc(a+1);return r.stringToUTF8(o,h,a+1),r.HEAPU32[s>>2]=a,h}logString(t,e){const s=this.M,r=this.decode(t,e);let i;try{i=String(r)}catch{i=""}if(r instanceof Error&&typeof r.stack=="string"&&r.stack.length>0){const h=r.stack.startsWith(i)?r.stack.slice(i.length).replace(/^\n/,""):r.stack;h.trim().length>0&&(i+=`
4
- `+h.replace(/[\r\n]+$/,""))}const o=s.lengthBytesUTF8(i),a=s._malloc(o+1);return s.stringToUTF8(i,a,o+1),a}toNumber(t){try{return Number(this.table[t])}catch{return NaN}}truthy(t){return!!this.table[t]}newError(t){this.writeOut(new Error(t))}throwNew(t,e){this.pending=t===1?new TypeError(e):new Error(e),this.hasPending=!0}takeException(){const t=this.hasPending?this.pending:void 0;this.pending=void 0,this.hasPending=!1,this.writeOut(t)}throwPending(){const t=this.hasPending?this.pending:new Error("native handler failed");throw this.pending=void 0,this.hasPending=!1,t}call(t,e,s,r,i,o){const a=this.table[e],h=this.decode(s,r),l=this.args(i,o);try{this.writeOut(a.apply(h,l))}catch(c){this.pending=c,this.hasPending=!0,this.writeOutException()}}construct(t,e,s){const r=this.table[t],i=this.args(e,s);try{this.writeOut(Reflect.construct(r,i))}catch(o){this.pending=o,this.hasPending=!0,this.writeOutException()}}typedArray(t,e,s){const i=this.M.HEAPU8.slice(e,e+s).buffer,o=[null,Uint8Array,Uint16Array,Uint32Array,Int32Array,Float32Array,Float64Array,Int16Array,Int8Array,Uint8ClampedArray];if(t===0){this.writeOut(i);return}const a=o[t];this.writeOut(a?new a(i):void 0)}arrayIn(t,e,s,r){const i=this.M,o=this.table[t];let a=null,h=0;if(s===2){if(!(o instanceof ArrayBuffer))return 0;a=new Uint8Array(o),h=a.byteLength}else{if(!ArrayBuffer.isView(o)||o instanceof DataView)return 0;const c=o,d=c.BYTES_PER_ELEMENT;if(s===0&&d!==e)return 0;a=new Uint8Array(c.buffer,c.byteOffset,c.byteLength),h=s===0?c.length:c.byteLength}const l=i._malloc(Math.max(a.byteLength,1));return a.byteLength>0&&i.HEAPU8.set(a,l),i.HEAPU32[r>>2]=h,l}arrayOut(t,e,s){const r=this.table[t];let i;if(r instanceof ArrayBuffer)i=new Uint8Array(r);else if(ArrayBuffer.isView(r))i=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);else return;const o=Math.min(s,i.byteLength);o>0&&i.set(this.M.HEAPU8.subarray(e,e+o))}invoke(t,e){const s=e.length,r=this.argSp;let i=r,o=0;r+s*8>this.argBase+ve?(o=this.M._malloc(Math.max(s*8,8)),i=o):this.argSp=r+s*8;const a=[];for(let l=0;l<s;l++){const c=this.write(i+l*8,e[l]);c&&a.push(c)}let h;try{t(s,i),h=this.takeOut()}finally{for(const l of a)this.release(l);this.argSp=r,o&&this.M._free(o)}return h.threw&&this.throwPending(),h.value}defineMethod(t,e,s,r,i,o){const a=this.table[e];if(o){Object.defineProperty(a,s,{configurable:!0,enumerable:!1,get:()=>this.invoke(()=>this.M._jsbInvokeGetter(r),[])});return}const h=this.M,l=(...c)=>this.invoke((d,u)=>h._jsbInvoke(t,r,d,u),c);Object.defineProperty(l,"name",{value:s}),Object.defineProperty(l,"length",{value:i}),Object.defineProperty(a,s,{configurable:!0,enumerable:!1,writable:!0,value:l})}makeFunction(t,e,s,r){const i=this.M,o=(...a)=>this.invoke((h,l)=>i._jsbInvokeData(t,e,h,l),a);s&&Object.defineProperty(o,"name",{value:s}),Object.defineProperty(o,"length",{value:r}),this.fnRegistry.register(o,e),this.writeOut(o)}callback(t,e){return t?(...s)=>{if(e){if(e.done){console.warn("[jsb] a settled host callback was called again");return}e.done=!0}const r=this.M,i=s.length,o=e?e.ptrs.length:0,a=r._malloc(Math.max(i*8+o*4,8)),h=[];for(let c=0;c<i;c++){const d=this.write(a+c*8,s[c]);d&&h.push(d)}const l=a+i*8;for(let c=0;c<o;c++)r.HEAPU32[(l>>2)+c]=e.ptrs[c];r._jsbHostCall(t,i,a,l,o);for(const c of h)this.release(c);r._free(a)}:()=>{}}viewEvent(t,e,s){const r=this.M,i=r.stringToNewUTF8(e);if(s===void 0){r._jsbViewEvent(t,i,0),r._free(i);return}const o=r._malloc(8),a=this.write(o,s);r._jsbViewEvent(t,i,o),a&&this.release(a),r._free(o),r._free(i)}group(...t){return{ptrs:t.filter(e=>e!==0),done:!1}}strings(t,e){const s=this.M,r=new Array(e);for(let i=0;i<e;i++){const o=s.HEAPU32[(t>>2)+i];r[i]=o?s.UTF8ToString(o):""}return r}bytesOut(t,e){const s=this.M;let r=null;if(t instanceof Uint8Array?r=t:t instanceof ArrayBuffer?r=new Uint8Array(t):ArrayBuffer.isView(t)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),!r||r.byteLength===0)return e&&(s.HEAPU32[e>>2]=0),0;const i=s._malloc(r.byteLength+1);return s.HEAPU8.set(r,i),s.HEAPU8[i+r.byteLength]=0,e&&(s.HEAPU32[e>>2]=r.byteLength),i}gc(){const t=globalThis.gc,e=globalThis.Bun;for(let s=0;s<2;s++){if(e!=null&&e.gc)e.gc(!0);else if(typeof t=="function")t();else return;this.sweep()}}sweep(){for(const t of[...this.tracked.keys()])t.ref.deref()===void 0&&(this.tracked.delete(t),this.classRegistry.unregister(t),this.M._jsbFinalize(t.cls,t.opaque))}}const Kn=(n,t)=>{const e=new zn(n,t);return n.jsb=e,e},Xn=""+new URL("assets/creator-full.js-CZ3EVfR2.symbols",import.meta.url).href,et=/wasm-function\[(\d+)\]/g;let Bt=null;const en=()=>(Bt||(Bt=fetch(Xn).then(n=>{if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return n.text()}).then(n=>{const t=new Map;for(const e of n.split(`
5
- `)){const s=e.indexOf(":");s>0&&t.set(Number(e.slice(0,s)),e.slice(s+1))}return t}).catch(n=>(console.warn("[creator-gl] creator-gl.js.symbols unavailable, wasm frames stay anonymous:",n),null))),Bt),nn=n=>n.replace(/\\([0-9a-fA-F]{2})/g,(t,e)=>String.fromCharCode(parseInt(e,16))),Yn=/([\w.-]+)\.wasm(?=[^\w-]|$)/g,rn=n=>{const t=[...n.matchAll(Yn)].map(e=>e[1]);return t.length===0?null:t.some(e=>e.includes("creator-gl"))?"ours":"other"},qn=async n=>{if(et.lastIndex=0,!et.test(n))return null;const t=await en();if(!t)return null;let e=!1;const s=n.split(`
6
- `).map(r=>{if(et.lastIndex=0,!et.test(r))return r;const i=rn(r);return i==="other"?r:r.replace(et,(o,a)=>{const h=t.get(Number(a));return h===void 0?o:(e=!0,`${i===null?"?":""}${nn(h)} (${o})`)})});return e?s.join(`
7
- `):null},Jn=async n=>{if(et.lastIndex=0,!et.test(n))return[];const t=await en();if(!t)return[];const e=[];for(const s of n.split(`
8
- `))if(rn(s)!=="other")for(const r of s.matchAll(et)){const i=t.get(Number(r[1]));i!==void 0&&e.push(nn(i).replaceAll("std::__2::","std::"))}return e},xe=n=>{const t=n==null?void 0:n.stack;typeof t=="string"&&qn(t).then(e=>{e&&console.error(`[creator-gl] decoded wasm stack (via creator-gl.js.symbols):
9
- `+e)})};let Ee=!1;const Qn=()=>{Ee||(Ee=!0,addEventListener("error",n=>xe(n.error)),addEventListener("unhandledrejection",n=>xe(n.reason)))},H=[null];new TextDecoder("utf-8");const Zn=async(n,t,e,s)=>{var f;let r;if(t.body)if(typeof t.body=="object"&&Array.isArray(t.body._entries)){const p=new FormData;for(let[b,g,x]of t.body._entries)typeof g=="object"?p.append(b,new Blob([nt(g._id)]),x):p.append(b,g);r=p}else typeof t.body=="string"?r=t.body:s(new Error("Invalid body"));const i=await fetch(n,{method:t.method,body:r,headers:t.headers,mode:"cors",credentials:"omit"}),o=typeof t.onProgress=="function"?t.onProgress:null;if(!o){const p=await i.arrayBuffer();H.push(p),e(H.length-1,i.status);return}const a=(f=i.body)==null?void 0:f.getReader();if(!a){const p=await i.arrayBuffer();H.push(p),e(H.length-1,i.status);return}const h=Number(i.headers.get("content-length"))||void 0;let l=0;const c=[];for(;;){const{done:p,value:b}=await a.read();if(p)break;b&&(c.push(b),l+=b.length,o({loaded:l,total:h}))}const d=new Uint8Array(l);let u=0;for(const p of c)d.set(p,u),u+=p.length;H.push(d.buffer),e(H.length-1,i.status)},tr=n=>{const t=new Blob([H[n]]);return URL.createObjectURL(t)},Ft=n=>new Blob([H[n]]),nt=n=>H[n],er=n=>{H[n]=null},lt=n=>(H.push(n),H.length-1),he=new Map,nr=(n,t)=>{he.set(n,t);const e=At.get(n);e!==void 0&&(H[e]=t)},rr=n=>he.has(n),At=new Map,sr=n=>{for(const[t,e]of At)if(e===n)return t},ir=n=>{const t=At.get(n);if(t!==void 0)return t;const e=he.get(n);if(!e)return-1;H.push(e);const s=H.length-1;return At.set(n,s),s},ue=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function sn(n){return typeof n=="object"&&n!==null&&"svg"in n}function or(n){return typeof n=="object"&&n!==null&&"_id"in n}function ar(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const te="lecodes-canvas://";function cr(n){return n.startsWith(te)?Number(n.slice(te.length)):void 0}function lr(n){return typeof File<"u"&&n instanceof File}function on(n){let t=n.trim();/\sxmlns\s*=/.test(t)||(t=t.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"'));const e=new TextEncoder().encode(t);let s="";for(const r of e)s+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(s)}`}function Nt(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function ee(n){var i,o,a;const t=((i=n.match(/<svg\b[^>]*>/i))==null?void 0:i[0])??"",e=t.match(/viewBox\s*=\s*["']\s*[\d.+-]+\s+[\d.+-]+\s+([\d.+-]+)\s+([\d.+-]+)\s*["']/i);if(e){const h=parseFloat(e[1]),l=parseFloat(e[2]);if(h>0&&l>0)return{width:h,height:l}}const s=parseFloat(((o=t.match(/\bwidth\s*=\s*["']?([\d.]+)/i))==null?void 0:o[1])??""),r=parseFloat(((a=t.match(/\bheight\s*=\s*["']?([\d.]+)/i))==null?void 0:a[1])??"");return s>0&&r>0?{width:s,height:r}:null}function hr(n){const t=/^data:image\/svg\+xml(;[^,]*)?,([\s\S]*)$/.exec(n);if(!t)return null;const e=t[2];try{if(/;base64/i.test(t[1]??"")){const s=atob(e),r=new Uint8Array(s.length);for(let i=0;i<s.length;i++)r[i]=s.charCodeAt(i);return new TextDecoder().decode(r)}return decodeURIComponent(e)}catch{return null}}async function ur(n,t){if(!Nt(n))return null;const e=hr(n);if(e)return ee(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?ee(s):null}function dr(n={}){const t=new WeakMap;return e=>{var o,a;if(e==null)return;if(typeof e=="string")return e;if(typeof e!="object")return;const s=e,r=t.get(s);if(r!==void 0)return r;let i;return sn(s)?i=on(s.svg):ar(s)?i=te+s.canvasSurface:or(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):lr(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function Se(n,t){if(!t)return;const e=cr(n);if(e===void 0)return;const s=t.getSurface(e);if(s)return{src:n,naturalWidth:s.width,naturalHeight:s.height,handle:s.canvas}}const an=n=>n==="monospaced"?"monospace":n;function ke(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${an(n.family)}`}class fr{constructor(t={}){m(this,"ctx");m(this,"images",new Map);m(this,"pending",new Map);m(this,"resolver");m(this,"canvasSurfaces");m(this,"fontFormat","woff2");const e=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(8,8);this.ctx=e.getContext("2d"),this.canvasSurfaces=t.canvasSurfaces,this.resolver=dr({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return an(t)}measureText(t,e){return this.ctx.font=ke(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=ke(t);const e=this.ctx.measureText("Mg"),s=e.fontBoundingBoxAscent||e.actualBoundingBoxAscent||t.size*.8,r=e.fontBoundingBoxDescent||e.actualBoundingBoxDescent||t.size*.2;return{ascent:s,descent:r}}getImage(t){return Se(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=Se(t,this.canvasSurfaces);if(e)return Promise.resolve(e);const s=this.images.get(t);if(s)return Promise.resolve(s);const r=this.pending.get(t);if(r)return r;const i=(async()=>{const o=await this.decode(t);let a=o.naturalWidth,h=o.naturalHeight;if(Nt(t)){const c=await ur(t,d=>fetch(d).then(u=>u.ok?u.text():null));c&&(a=c.width,h=c.height)}const l={src:t,naturalWidth:a,naturalHeight:h,handle:o};return this.images.set(t,l),this.pending.delete(t),l})();return this.pending.set(t,i),i.catch(()=>this.pending.delete(t)),i}decode(t){return new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=i=>s(i),r.src=t})}async loadFont(t,e,s){if(typeof globalThis.FontFace>"u")return;const r=new FontFace(t,`url(${e})`,s);document.fonts.add(r),await r.load()}}function pr(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function ft(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function it(n){const{r:t,g:e,b:s,a:r}=pr(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function ne(n){return n===void 0||(n>>>0&255)===0}function re(n,t){if(!n)return;const e=Math.min(t.width,t.height)/2;return{tl:Math.min(n.tl,e),tr:Math.min(n.tr,e),br:Math.min(n.br,e),bl:Math.min(n.bl,e)}}function _e(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function gr(n,t,e,s){const r={x:0,y:0,width:n,height:t};if(s==="fill"||n===0||t===0)return{src:r,dst:e};if(s==="cover"){const h=Math.max(e.width/n,e.height/t),l=e.width/h,c=e.height/h;return{src:{x:(n-l)/2,y:(t-c)/2,width:l,height:c},dst:e}}const i=Math.min(e.width/n,e.height/t),o=n*i,a=t*i;return{src:r,dst:{x:e.x+(e.width-o)/2,y:e.y+(e.height-a)/2,width:o,height:a}}}function mr(n,t){const e=n*Math.PI/180,s=Math.sin(e),r=-Math.cos(e),i=t.x+t.width/2,o=t.y+t.height/2,a=(Math.abs(t.width*s)+Math.abs(t.height*r))/2;return{x0:i-s*a,y0:o-r*a,x1:i+s*a,y1:o+r*a}}function yr(n,t){const e=t.x+n.cx*t.width,s=t.y+n.cy*t.height;if(n.extent==="explicit"){const p=n.rxUnit==="fraction"?(n.rx??0)*t.width:n.rx??0,b=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:p,ry:b}}const r=n.cx*t.width,i=(1-n.cx)*t.width,o=n.cy*t.height,a=(1-n.cy)*t.height,h=Math.min(r,i),l=Math.max(r,i),c=Math.min(o,a),d=Math.max(o,a);let u,f;if(n.shape==="circle"){let p;switch(n.extent){case"closest-side":p=Math.min(h,c);break;case"farthest-side":p=Math.max(l,d);break;case"closest-corner":p=Math.hypot(h,c);break;default:p=Math.hypot(l,d);break}u=f=p}else switch(n.extent){case"closest-side":u=h,f=c;break;case"farthest-side":u=l,f=d;break;case"closest-corner":u=h*Math.SQRT2,f=c*Math.SQRT2;break;default:u=l*Math.SQRT2,f=d*Math.SQRT2;break}return{cx:e,cy:s,rx:u,ry:f}}class Te{constructor(t,e=1){m(this,"ctx");m(this,"dpr");m(this,"groups",[]);m(this,"scratch");m(this,"scratchCtx");m(this,"tileCells",new WeakMap);this.ctx=t,this.dpr=e}beginGroup(t){const e=this.ctx,s=e.canvas.width,r=e.canvas.height;let i;typeof OffscreenCanvas<"u"?i=new OffscreenCanvas(s,r):(i=document.createElement("canvas"),i.width=s,i.height=r);const o=i.getContext("2d");o.setTransform(e.getTransform()),this.groups.push({parent:e,layer:i,alpha:t}),this.ctx=o}endGroup(){const t=this.groups.pop();t&&(this.ctx=t.parent,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.globalAlpha*=t.alpha,this.ctx.drawImage(t.layer,0,0),this.ctx.restore())}beginFrame(t,e){const{ctx:s,dpr:r}=this;s.setTransform(r,0,0,r,0,0),s.clearRect(0,0,t,e),s.globalAlpha=1}endFrame(){}save(){this.ctx.save()}restore(){this.ctx.restore()}setAlpha(t){this.ctx.globalAlpha*=t}translate(t,e){this.ctx.translate(t,e)}scale(t,e){this.ctx.scale(t,e)}transform(t,e,s,r,i,o){this.ctx.transform(t,e,s,r,i,o)}addRectPath(t,e){const s=this.ctx;e&&(e.tl||e.tr||e.br||e.bl)?s.roundRect(t.x,t.y,t.width,t.height,[e.tl,e.tr,e.br,e.bl]):s.rect(t.x,t.y,t.width,t.height)}path(t,e){this.ctx.beginPath(),this.addRectPath(t,e)}clipRoundRect(t,e){this.path(t,e),this.ctx.clip()}fillRoundRect(t,e,s){this.path(t,e),this.ctx.fillStyle=it(s),this.ctx.fill()}clearRoundRect(t,e){const s=this.ctx;s.save(),s.globalCompositeOperation="destination-out",s.globalAlpha=1,this.path(t,e),s.fillStyle="#000",s.fill(),s.restore()}fillGradient(t,e,s){if(s.type==="radial"){this.fillRadial(t,e,s);return}const{x0:r,y0:i,x1:o,y1:a}=mr(s.angle,t),h=this.ctx.createLinearGradient(r,i,o,a);for(const l of s.stops)h.addColorStop(Math.max(0,Math.min(1,l.position)),it(l.color));this.path(t,e),this.ctx.fillStyle=h,this.ctx.fill()}fillRadial(t,e,s){const{cx:r,cy:i,rx:o,ry:a}=yr(s,t),h=this.ctx,l=o||1e-6,c=a||1e-6;h.save(),this.path(t,e),h.clip(),h.translate(r,i),h.scale(l,c);const d=h.createRadialGradient(0,0,0,0,0,1);for(const g of s.stops)d.addColorStop(Math.max(0,Math.min(1,g.position)),it(g.color));h.fillStyle=d;const u=(t.x-r)/l,f=(t.x+t.width-r)/l,p=(t.y-i)/c,b=(t.y+t.height-i)/c;h.fillRect(u,p,f-u,b-p),h.restore()}strokeBorder(t,e,s){const r=this.ctx,i=["top","right","bottom","left"].filter(a=>s[a]);if(i.length===4&&i.every(a=>s[a].width===s.top.width&&s[a].color===s.top.color)){const a=s.top.width,h=re(e,t);r.beginPath(),this.addRectPath(t,h);const l={x:t.x+a,y:t.y+a,width:t.width-2*a,height:t.height-2*a};if(l.width>0&&l.height>0){const c=h&&re({tl:Math.max(0,h.tl-a),tr:Math.max(0,h.tr-a),br:Math.max(0,h.br-a),bl:Math.max(0,h.bl-a)},l);this.addRectPath(l,c||void 0)}r.fillStyle=it(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:h,color:l}=s[a];r.fillStyle=it(l),a==="top"?r.fillRect(t.x,t.y,t.width,h):a==="bottom"?r.fillRect(t.x,t.y+t.height-h,t.width,h):a==="left"?r.fillRect(t.x,t.y,h,t.height):r.fillRect(t.x+t.width-h,t.y,h,t.height)}}getScratch(t,e){return this.scratch||(this.scratch=typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):document.createElement("canvas"),this.scratchCtx=this.scratch.getContext("2d")),(this.scratch.width<t||this.scratch.height<e)&&(this.scratch.width=Math.max(this.scratch.width,t),this.scratch.height=Math.max(this.scratch.height,e)),this.scratchCtx}tileCell(t,e,s){const r=t.handle,i=this.tileCells.get(r);if(i&&i.pw===e&&i.ph===s)return i.canvas;const o=t.rasterize?t.rasterize(e,s):t.handle,a=typeof OffscreenCanvas<"u"?new OffscreenCanvas(e,s):Object.assign(document.createElement("canvas"),{width:e,height:s});return a.getContext("2d").drawImage(o,0,0,e,s),this.tileCells.set(r,{pw:e,ph:s,canvas:a}),a}drawImage(t,e,s,r){if(!t.handle)return;if(r.tile){const f=t.naturalWidth,p=t.naturalHeight;if(f<=0||p<=0)return;const b=Math.max(1,Math.ceil(f*this.dpr)),g=Math.max(1,Math.ceil(p*this.dpr)),x=t.rasterize!==void 0||Nt(t.src),w=x?this.tileCell(t,b,g):t.handle,v=x?f/b:1,k=x?p/g:1,A=this.ctx.createPattern(w,"repeat");if(!A)return;this.ctx.save(),this.ctx.translate(s.x,s.y),this.ctx.scale(v,k),this.ctx.fillStyle=A,this.ctx.fillRect(0,0,s.width/v,s.height/k),this.ctx.restore();return}const i=e?{src:e,dst:s}:gr(t.naturalWidth,t.naturalHeight,s,r.fit),o=i.dst;let a=i.src;const h=Math.max(1,Math.ceil(o.width*this.dpr)),l=Math.max(1,Math.ceil(o.height*this.dpr)),c=!e&&r.fit!=="cover";let d=t.handle;if(t.rasterize)if(c)d=t.rasterize(h,l);else{const f=Math.max(h/a.width,l/a.height),p=Math.max(1,Math.ceil(t.naturalWidth*f)),b=Math.max(1,Math.ceil(t.naturalHeight*f));d=t.rasterize(p,b);const g=p/t.naturalWidth,x=b/t.naturalHeight;a={x:a.x*g,y:a.y*x,width:a.width*g,height:a.height*x}}if(r.tint===void 0){c?this.ctx.drawImage(d,o.x,o.y,o.width,o.height):this.ctx.drawImage(d,a.x,a.y,a.width,a.height,o.x,o.y,o.width,o.height);return}const u=this.getScratch(h,l);u.clearRect(0,0,h,l),u.globalCompositeOperation="source-over",c?u.drawImage(d,0,0,h,l):u.drawImage(d,a.x,a.y,a.width,a.height,0,0,h,l),u.globalCompositeOperation="source-in",u.fillStyle=it(r.tint),u.fillRect(0,0,h,l),u.globalCompositeOperation="source-over",this.ctx.drawImage(u.canvas,0,0,h,l,o.x,o.y,o.width,o.height)}fillText(t,e,s,r,i){const o=this.ctx;o.font=`${r.italic?"italic ":""}${r.weight} ${r.size}px ${r.family}`,o.textBaseline="alphabetic",o.textAlign="left","letterSpacing"in o&&(o.letterSpacing=`${r.letterSpacing}px`),o.fillStyle=it(i),o.fillText(t,e,s)}}const G=[null],bt=[!1],cn=(n,t,e)=>{n.addEventListener("ended",()=>{e(),bt[t]&&(n.currentTime=0,n.play())})},wr=(n,t)=>{const e=document.createElement("video");document.body.appendChild(e),e.crossOrigin="anonymous",e.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",e.src=n,e.playsInline=!0,e.controls=!1;const s=G.length;return G.push(e),bt.push(!1),cn(e,s,t),s},br=(n,t)=>{const e=document.createElement("audio");document.body.appendChild(e),e.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",e.src=n;const s=G.length;return G.push(e),bt.push(!1),cn(e,s,t),s},vr=(n,t)=>{const e=G[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},xr=(n,t)=>{const e=G[n];e&&(t?e.play():e.pause())},Er=(n,t)=>{bt[n]=t},Sr=n=>{var t;return((t=G[n])==null?void 0:t.currentTime)??0},kr=(n,t)=>{const e=G[n];e&&(e.currentTime=t)},_r=n=>{var e;const t=((e=G[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},de=n=>G[n],ln=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},Tr=n=>{const t=G[n];t&&(ln(t),G[n]=null,bt[n]=!1)},hn=()=>{for(let n of G)n&&ln(n);G.length=1,bt.length=1},Rr=9,Ar=10,Mr=12,Lr=13,Pr=14,Cr=15,Or=16,Ir=1,Fr=2,Nr=4,Re=8,Ur=16,Wr=32,Br=64,Dr=256,Hr=512,$r=1024,Gr=2048,Vr=4096,Ae=0,Dt=1,Me=2,Ht=3;function Le(n,t,e){const s=n.rect;return t>=s.x&&t<s.x+s.width&&e>=s.y&&e<s.y+s.height}function mt(n,t,e,s){let r=null,i=null,o=!1;const a=h=>{const l=Le(h,t,e);if(l&&s(h)&&(r=h),!(h.clip&&!l))for(const c of h.children)c.overlay!==void 0&&(r=null,i=c,o=!Le(c,t,e)),a(c)};return a(n),{node:r,blocker:r?null:i,outside:o}}const jr=255,tt={color:4294967295,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function se(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:h,textAlign:l,textDecoration:c}=t,d=s??tt.fontSize;return{color:e??(n.type==="input"||n.type==="textarea"?jr:tt.color),fontSize:d,fontFamily:r??tt.fontFamily,fontWeight:i??tt.fontWeight,fontStyle:o??tt.fontStyle,lineHeight:a,letterSpacing:h??tt.letterSpacing,textAlign:l??tt.textAlign,textDecoration:c??tt.textDecoration}}function un(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}const zr=10;function ie(n,t,e){const s=[];if(n.length===0)return[""];let r=n;for(;r;){if(e(r)<=t){s.push(r);break}let i=0,o=-1,a=0;for(;(a=r.indexOf(" ",a+1))!==-1&&!(e(r.substring(0,a))>t);)o=a;if(o>0)i=o;else{let h=r.indexOf(" ");h===-1&&(h=r.length);const l=r.substring(0,h);if(e(l)>t){for(let c=1;c<=l.length;c++)if(e(l.substring(0,c))>t){i=c-1;break}}else for(let c=h+1;c<=r.length;c++)if(e(r.substring(0,c))>t){i=c-1;break}}i<=0&&(i=1),s.push(r.substring(0,i)),r=r.substring(i+(o>0?1:0))}return s}function Kr(n,t,e,s){const r=e.length;if(r<2||r>zr||!isFinite(t))return e;const i=h=>ie(n,h,s).length;let o=Math.floor(t);if(i(o)!==r)return e;let a=0;for(const h of n.split(" "))a=Math.max(a,Math.ceil(s(h)));if(a>=o)return e;if(i(a)===r)o=a;else for(;o-a>1;){const h=a+o>>1;i(h)===r?o=h:a=h}return ie(n,o,s)}function Xr(n,t,e){const s=t.length;if(s<2)return t;const r=t[s-1].trim();if(r.length===0||r.includes(" "))return t;const i=t[s-2].trimEnd(),o=i.lastIndexOf(" ");if(o<=0)return t;const a=i.slice(o+1)+" "+r;return e(a)>n?t:[...t.slice(0,s-2),i.slice(0,o),a]}function Mt(n,t,e,s="wrap",r=0){const i=[],o=s==="nowrap"?1/0:t;let a=s==="balance"||s==="pretty";for(const l of n.split(`
10
- `)){let c=ie(l,o,e);a&&(r>0&&i.length+c.length>r?a=!1:s==="balance"?c=Kr(l,o,c,e):c=Xr(o,c,e));for(const d of c)i.push(d)}let h=0;for(const l of i)h=Math.max(h,e(l));return{lines:i,maxWidth:h}}function dn(n,t,e,s,r){const i=t.textWrap??"wrap",o=Mt(n,e,s,i,t.lineClamp??0),a=i==="nowrap"&&!r?1/0:e,h=Yr(o.lines,t,a,s);return i!=="nowrap"||!r||t.textOverflow==="clip"||!isFinite(e)?h:h.map(l=>s(l)>e?fn(l,e,s):l)}const $t="…";function Yr(n,t,e,s){const r=t.lineClamp??0;if(r<=0||n.length<=r)return n;const i=n.slice(0,r);return t.textOverflow==="clip"||(i[r-1]=fn(i[r-1],e,s)),i}function fn(n,t,e){if(!isFinite(t))return n+$t;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+$t)>t;)r--;return s.slice(0,r).join("").trimEnd()+$t}function qr(n,t,e){const s=se(n),r=un(s),i=isNaN(e)?1/0:e,o=l=>t.measureText(l,r),a=dn(n.text??"",n.style,i,o,!1);let h=0;for(const l of a)h=Math.max(h,o(l));return{width:Math.ceil(h),height:Math.ceil(a.length*s.lineHeight)}}function Jr(n,t,e){const s=n.style,r={family:s.fontFamily??"Roboto",size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.lineHeight,o=n.value??"";if(n.type==="input")return{width:Math.ceil(t.measureText(o,r)),height:Math.ceil(i)};const a=isNaN(e)?1/0:e,h=Mt(o,a,l=>t.measureText(l,r));return{width:Math.ceil(h.maxWidth),height:Math.ceil(Math.max(1,h.lines.length)*i)}}function Qr(n,t,e,s){const r=n.imageSrcRaw;let i=0,o=0;if(n.sourceRect)i=n.sourceRect[2],o=n.sourceRect[3];else if(sn(r)){const l=ee(r.svg);if(l)i=l.width,o=l.height;else{const c=t.getImage(t.resolveSrc(r)??"");i=(c==null?void 0:c.naturalWidth)??0,o=(c==null?void 0:c.naturalHeight)??0}}else{const l=t.resolveSrc(r),c=l?t.getImage(l):void 0;i=(c==null?void 0:c.naturalWidth)??0,o=(c==null?void 0:c.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),h=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*h,height:o*h}}const pn=(n,t,e,s)=>t?[n[0],n[1],n[2],n[3],n[4]+e*t[0]+s*t[2],n[5]+e*t[1]+s*t[3]]:n;function Zr(n,t,e,s,r,i,o={}){t.beginFrame(s,r);for(const a of n)gn(a.tree,t,e,o);t.endFrame()}function gn(n,t,e,s){const{style:r,rect:i}=n;t.save();const o=r.opacity!==void 0&&r.opacity<1?r.opacity:void 0,a=o!==void 0&&n.children.length>0;if(a?t.beginGroup(o):o!==void 0&&t.setAlpha(o),r.transform){const[c,d,u,f,p,b]=pn(r.transform,r.transformBox,i.width,i.height),g=r.transformOrigin,x=i.x+(g?g.xPercent?i.width*g.x/100:g.x:i.width/2),w=i.y+(g?g.yPercent?i.height*g.y/100:g.y:i.height/2);t.translate(x,w),t.transform(c,d,u,f,p,b),t.translate(-x,-w)}const h=re(r.borderRadius,i);if(ne(r.backgroundColor)||t.fillRoundRect(i,h,r.backgroundColor),r.backgroundImage){const c=e.getImage(r.backgroundImage);c&&c.naturalWidth>0&&c.naturalHeight>0&&(t.save(),_e(h)&&t.clipRoundRect(i,h),t.drawImage(c,null,i,{fit:ts(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let c=r.backgroundGradients.length-1;c>=0;c--){const d=r.backgroundGradients[c];d.stops.length>0&&t.fillGradient(i,h,d)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const c=n.sourceRect;t.save(),_e(h)&&t.clipRoundRect(i,h),t.drawImage(n.image,c?{x:c[0],y:c[1],width:c[2],height:c[3]}:null,i,{fit:c?"fill":r.objectFit??"contain",tint:Nt(n.image.src)?r.tintColor:void 0,radius:h}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&ns(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&ss(n,t,e,h),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,h):n.type==="video"&&rs(n,t,e,h)),n.clip&&t.clipRoundRect(i,h);for(const c of n.children)c.overlay!==void 0&&!ne(c.overlay)&&t.fillRoundRect(i,void 0,c.overlay),gn(c,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,h,Math.round(Math.min(1,r.dim)*255)>>>0);const l=es(r.border);l&&t.strokeBorder(i,h,l),a&&t.endGroup(),t.restore()}function ts(n){return n==="contain"||n==="fill"?n:"cover"}function es(n){if(!n)return null;const t={};let e=!1;for(const s of["top","right","bottom","left"]){const r=n[s];r&&r.width>0&&(r.color>>>0)%256!==0&&(t[s]=r,e=!0)}return e?t:null}const mn=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function ns(n,t,e){var g,x,w;const s=n.style,r={family:mn(e,s.fontFamily),size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.color??255,o=s.lineHeight,a=s.textAlign??"start",h=e.fontMetrics(r),{rect:l,lines:c}=n,d=((g=n.padding)==null?void 0:g[0])??0,u=((x=n.padding)==null?void 0:x[1])??0,f=((w=n.padding)==null?void 0:w[2])??0,p=l.x+d,b=l.width-d-f;for(let v=0;v<c.length;v++){const k=c[v],P=l.y+u+v*o+(o-(h.ascent+h.descent))/2+h.ascent,I=e.measureText(k,r),C=a==="center"?p+(b-I)/2:a==="end"?p+b-I:p;if(t.fillText(k,C,P,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const N=Math.max(1,r.size/14),X=s.textDecoration==="underline"?P+N:P-r.size*.3;t.fillRoundRect({x:C,y:X,width:I,height:N},void 0,i)}}}function rs(n,t,e,s){const{rect:r}=n;ne(n.style.backgroundColor)&&t.fillRoundRect(r,s,286463999);const i=Math.min(r.width,r.height)*.3;if(i>=6){const o={family:"Roboto",size:i,weight:400,italic:!1,letterSpacing:0},a=e.fontMetrics(o),h=e.measureText("▶",o),l=r.x+(r.width-h)/2,c=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",l,c,o,4294967244)}}function ss(n,t,e,s){var T,$,z,y,L;const r=n.style,i={family:mn(e,r.fontFamily),size:r.fontSize??14,weight:r.fontWeight??400,italic:r.fontStyle==="italic",letterSpacing:r.letterSpacing??0},o=n.value??"",a=o.length===0,h=r.inputType==="password"&&!a,l=a?r.placeholder??"":h?"•".repeat(o.length):o,c=a?r.placeholderColor??2576980479:r.color??255,{rect:d}=n,u=((T=n.padding)==null?void 0:T[0])??0,f=(($=n.padding)==null?void 0:$[1])??0,p=((z=n.padding)==null?void 0:z[2])??0,b=((y=n.padding)==null?void 0:y[3])??0,g=d.x+u,x=d.width-u-p,w=d.y+f,v=d.height-f-b,k=e.fontMetrics(i),A=r.lineHeight,P=r.textAlign??"start",I=n.type==="textarea",C=I?Mt(l,x,M=>e.measureText(M,i)).lines:[l],N=M=>P==="center"?g+(x-M)/2:P==="end"?g+x-M:g,X=M=>I?w+M*A+(A-(k.ascent+k.descent))/2+k.ascent:w+(v-(k.ascent+k.descent))/2+k.ascent;t.save(),t.clipRoundRect(d,s);for(let M=0;M<C.length;M++){const D=C[M];D.length>0&&t.fillText(D,N(e.measureText(D,i)),X(M),i,c)}if((L=n.state)!=null&&L.focused){const M=a?[""]:I?Mt(h?"•".repeat(o.length):o,x,U=>e.measureText(U,i)).lines:[l],D=M.length-1,Y=e.measureText(M[D],i),ut=a?N(0):N(Y)+Y,E=X(D),R=Math.max(1,i.size/14);t.fillRoundRect({x:ut,y:E-k.ascent,width:R,height:k.ascent+k.descent},void 0,r.color??255)}t.restore()}const is=84,os={display:{word:4},overflow:{word:5},scrollDirection:{word:6},borderTopWidth:{word:8},borderRightWidth:{word:9},borderBottomWidth:{word:10},borderLeftWidth:{word:11},color:{bit:12,word:16},backgroundColor:{word:17},borderTopColor:{word:19},borderRightColor:{word:20},borderBottomColor:{word:21},borderLeftColor:{word:22},placeholderColor:{bit:19,word:23},tintColor:{bit:21,word:25},overlayColor:{bit:23,word:27},backgroundImage:{word:28},backgroundSize:{word:29},backgroundGradient:{word:30},borderTopLeftRadius:{word:32},borderTopRightRadius:{word:33},borderBottomRightRadius:{word:34},borderBottomLeftRadius:{word:35},opacity:{word:36},transform:{word:37},transformOrigin:{word:50},fontSize:{word:55},fontWeight:{word:56},fontStyle:{word:57},fontFamily:{bit:39,word:58},lineHeight:{word:59},letterSpacing:{word:60},textAlign:{word:61},textDecoration:{word:62},lineClamp:{word:63},textOverflow:{word:64},textWrap:{word:65},objectFit:{word:66},placeholder:{word:67},type:{word:68},dim:{word:82}},as={hidden:1},cs={horizontal:1},ls={italic:1},ot={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],textWrap:["wrap","nowrap","balance","pretty"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},hs=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,us=["farthest-corner","closest-side","closest-corner","farthest-side"],ds=52;function fs(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(ps(n,t,e+i*ds));return r}function ps(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],h=[];for(let l=0;l<o;l++){const c=a+l*8>>2;h.push({color:t[c]>>>0,position:n[c+1]})}if(i===1){const l=t[s+6],c={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:h};return l===4?{...c,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...c,extent:us[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:h}}const _=os,gs=["start","center","end","start","end"];let kt=0;function yn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],h=C=>hs(o,a,C),l=C=>{const N=s[i+C];return N===0?void 0:n.UTF8ToString(n._cuiStringOf(N))};e.backgroundColor=s[i+_.backgroundColor.word]>>>0,e.opacity=r[i+_.opacity.word],e.dim=r[i+_.dim.word],e.display=ot.display[s[i+_.display.word]],e.overflow=s[i+_.overflow.word]===as.hidden?"hidden":"visible",e.scrollAxis=s[i+_.scrollDirection.word]===cs.horizontal?"x":"y",e.border={top:{width:r[i+_.borderTopWidth.word],color:s[i+_.borderTopColor.word]>>>0},right:{width:r[i+_.borderRightWidth.word],color:s[i+_.borderRightColor.word]>>>0},bottom:{width:r[i+_.borderBottomWidth.word],color:s[i+_.borderBottomColor.word]>>>0},left:{width:r[i+_.borderLeftWidth.word],color:s[i+_.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+_.borderTopLeftRadius.word],tr:r[i+_.borderTopRightRadius.word],br:r[i+_.borderBottomRightRadius.word],bl:r[i+_.borderBottomLeftRadius.word]},e.backgroundImage=l(_.backgroundImage.word),e.backgroundSize=ot.backgroundSize[s[i+_.backgroundSize.word]];const c=s[i+_.backgroundGradient.word];if(c===0)e.backgroundGradients=void 0;else{kt===0&&(kt=n._malloc(4));const C=n._cuiGradientOf(c,kt),N=n.HEAPU32[kt>>>2];e.backgroundGradients=C!==0&&N>0?fs(n.HEAPF32,n.HEAPU32,C,N):void 0}const d=i+_.transform.word,u=r[d],f=r[d+1],p=r[d+3],b=r[d+4],g=r[d+6],x=r[d+7],w=r[d+9],v=r[d+10],k=r[d+11],A=r[d+12],P=w===0&&v===0&&k===0&&A===0;e.transform=u===1&&f===0&&p===0&&b===1&&g===0&&x===0&&P?void 0:[u,f,p,b,g,x],e.transformBox=P?void 0:[w,v,k,A];const I=i+_.transformOrigin.word;e.transformOrigin={x:r[I],y:r[I+1],xPercent:s[I+2]!==0,yPercent:s[I+3]!==0},e.color=h(_.color.bit)?s[i+_.color.word]>>>0:void 0,e.fontFamily=h(_.fontFamily.bit)?l(_.fontFamily.word):void 0,e.fontSize=r[i+_.fontSize.word],e.fontWeight=r[i+_.fontWeight.word],e.fontStyle=s[i+_.fontStyle.word]===ls.italic?"italic":"normal",e.lineHeight=r[i+_.lineHeight.word],e.letterSpacing=r[i+_.letterSpacing.word],e.textAlign=gs[s[i+_.textAlign.word]]??"start",e.textDecoration=ot.textDecoration[s[i+_.textDecoration.word]],e.lineClamp=r[i+_.lineClamp.word],e.textOverflow=ot.textOverflow[s[i+_.textOverflow.word]],e.textWrap=ot.textWrap[s[i+_.textWrap.word]],e.objectFit=ot.objectFit[s[i+_.objectFit.word]],e.tintColor=h(_.tintColor.bit)?s[i+_.tintColor.word]>>>0:void 0,e.placeholder=l(_.placeholder.word),e.placeholderColor=h(_.placeholderColor.bit)?s[i+_.placeholderColor.word]>>>0:void 0,e.inputType=ot.type[s[i+_.type.word]],e.overlayColor=h(_.overlayColor.bit)?s[i+_.overlayColor.word]>>>0:void 0}function ms(n,t){const e=n._cuiPaintOf(t);if(e===0)return!1;const s=e>>>2;return n.HEAPU32[s+2]!==0||n.HEAPU32[s+3]!==0}function ys(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(yn(n,s,e),!0)}function ws(n,t){const e=n._paintCollect();if(e===0)return 0;const s=n._paintNodes()>>>2,r=n._paintRecords();for(let i=0;i<e;i++){const o=n.HEAPU32[s+i],a=r+i*is*4;t(o,h=>yn(n,a,h))}return e}function wn(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?oe(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>oe(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function bs(n,t=[],e){return JSON.stringify(wn(n,t,e),null,2)}function pt(n,t){const e=10**t;return Math.round(n*e)/e}function oe(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),r.rect=[pt(s.x,t),pt(s.y,t),pt(s.width,t),pt(s.height,t)],e&&(r.id=n.id);const i=xs(n.style);return i&&(r.style=i),n.text!==void 0&&(r.text=n.text),n.lines&&(n.lines.length!==1||n.lines[0]!==n.text)&&(r.lines=n.lines),n.value!==void 0&&n.value!==""&&(r.value=n.value),n.style.placeholder!==void 0&&(r.placeholder=n.style.placeholder),n.image&&(r.image={src:n.image.src,natural:[n.image.naturalWidth,n.image.naturalHeight]}),n.sourceRect&&(r.sourceRect=n.sourceRect),n.state&&(n.state.pressed||(o=n.state.classes)!=null&&o.length)&&(r.state={...n.state.pressed?{pressed:!0}:{},...(a=n.state.classes)!=null&&a.length?{classes:n.state.classes}:{}}),n.scroll&&(r.scroll={offset:pt(n.scroll.offset,t),content:pt(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(h=>oe(h,t,e))),r}function vs(n){return n.tl===n.tr&&n.tr===n.br&&n.br===n.bl?n.tl:[n.tl,n.tr,n.br,n.bl]}function xs(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=ft(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=ft(n.color)),n.fontSize!==void 0&&(t.fontSize=n.fontSize),n.fontFamily!==void 0&&(t.fontFamily=n.fontFamily),n.fontWeight!==void 0&&(t.fontWeight=n.fontWeight),n.fontStyle!==void 0&&n.fontStyle!=="normal"&&(t.fontStyle=n.fontStyle),n.lineHeight!==void 0&&(t.lineHeight=n.lineHeight),n.letterSpacing&&(t.letterSpacing=n.letterSpacing),n.textAlign!==void 0&&n.textAlign!=="start"&&(t.textAlign=n.textAlign),n.textDecoration!==void 0&&n.textDecoration!=="none"&&(t.textDecoration=n.textDecoration),n.lineClamp&&(t.lineClamp=n.lineClamp,n.textOverflow==="clip"&&(t.textOverflow=n.textOverflow)),n.textWrap!==void 0&&n.textWrap!=="wrap"&&(t.textWrap=n.textWrap),n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=ft(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=ft(n.overlayColor)),n.backgroundImage!==void 0&&(t.backgroundImage=n.backgroundImage),n.backgroundSize!==void 0&&(t.backgroundSize=n.backgroundSize),n.backgroundGradients!==void 0&&n.backgroundGradients.length>0&&(t.backgroundGradients=n.backgroundGradients.map(e=>{const s=e.stops.map(r=>({color:ft(r.color),position:r.position}));if(e.type==="radial"){const r={type:"radial",shape:e.shape,extent:e.extent,cx:e.cx,cy:e.cy,stops:s};return e.extent==="explicit"&&(r.rx=e.rx,r.ry=e.ry,r.rxUnit=e.rxUnit,r.ryUnit=e.ryUnit),r}return{angle:e.angle,stops:s}})),n.borderRadius&&(n.borderRadius.tl||n.borderRadius.tr||n.borderRadius.br||n.borderRadius.bl)&&(t.borderRadius=vs(n.borderRadius)),n.border){const e={};for(const s of["top","right","bottom","left"]){const r=n.border[s];r&&r.width>0&&(e[s]={width:r.width,color:ft(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const Es=.32,Ss=4,Pe=new Map;function ae(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Pe.get(n);return t===void 0&&(t=on(n.slice(4)),Pe.set(n,t)),t}return n}class ks{constructor(t,e){m(this,"parent",null);m(this,"children",[]);m(this,"style",{lineHeight:14*1.2});m(this,"name");m(this,"text","");m(this,"src");m(this,"value","");m(this,"sourceRect");m(this,"viewName");m(this,"viewParams");m(this,"playerId",0);m(this,"viewId",0);m(this,"flags",0);m(this,"layoutRect",null);m(this,"scrollOffset",0);m(this,"wrapCache");m(this,"jsNode");m(this,"bgRaw");m(this,"bgSrc");this.id=t,this.type=e,this.jsNode={type:e,_id:t}}get measured(){return this.type==="text"||this.type==="image"||this.editable}get editable(){return this.type==="input"||this.type==="textarea"}get scrollable(){return this.type==="scrollable"||this.type==="scrollableScreen"||this.type==="vlist"}get scrollAxis(){return this.style.scrollAxis==="x"?"x":"y"}get interactive(){return(this.flags&Ir)!==0}get imageSrcRaw(){return this.type==="image"?ae(this.src):void 0}has(t){return(this.flags&t)!==0}}class _s{constructor(t,e,s={}){m(this,"nodes",new Map);m(this,"root",null);m(this,"leaving",null);m(this,"leavingAbove",!1);m(this,"pagerShown",new Map);m(this,"pagerLeaving",new Map);m(this,"destKind",-1);m(this,"layerRoots",[]);m(this,"width",0);m(this,"height",0);m(this,"focused",null);m(this,"safeBottom",0);m(this,"shrunkRoot",0);m(this,"shrunkInset",0);m(this,"pressed",new Set);m(this,"gestures",new Map);m(this,"vlists",new Set);m(this,"frameCache",null);m(this,"painted",null);m(this,"fontsPending",0);m(this,"lastToast",null);m(this,"dirty",!0);m(this,"onDestination",null);m(this,"onDropped",null);m(this,"layoutPtr",0);m(this,"padPtr",0);m(this,"lastCreated",0);m(this,"hoverX",0);m(this,"hoverY",0);m(this,"hoverInside",!1);m(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,h)=>{const l=this.measure(r,i,a);return t.setFloat32(4,l.width,!0),t.setFloat32(0,l.height,!0),t.getBigUint64(0,!0)};this.M._setMeasureFunc(this.M.addFunction(e,"jiififi"))}measure(t,e,s){const r=this.nodes.get(t);if(!r)return{width:0,height:0};const i=this.M;ms(i,t)&&(ys(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?qr(o,this.host,e):r.type==="image"?Qr(o,this.host,e,s):r.editable?Jr(o,this.host,e):{width:0,height:0}}resize(t,e){this.width=t,this.height=e,this.M._creatorWebResize(t,e),this.M._setConditionValue(t,e),this.dirty=!0}setSafeArea(t,e=[]){const[s,r,i,o]=t??(this.width>this.height?[0,8,0,20]:[20,0,8,0]),a={top:1,right:2,bottom:4,left:8};this.M._setSafeAreaBars(e.reduce((h,l)=>h|a[l],0)),this.M._setSafePaddings(s,r,i,o,0),this.safeBottom=i,this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&(this.shrunkInset=Math.max(0,i-this.keyboardHeight()),this.M._overrideRootSafeBottom(this.shrunkRoot,this.shrunkInset)),this.dirty=!0}layoutFrame(){const t=this.M;ws(t,(r,i)=>{const o=this.nodes.get(r);o&&(i(o.style),this.resolveBackground(o))})>0&&(this.dirty=!0);const s=t._creatorWebLayoutFrame(this.width,this.height);s>0&&this.readLayoutBatch(s);for(const r of this.vlists)if(t._vlistExists(r.id)){t._vlistUpdateLayout(r.id);for(const i of r.children)this.deliverSubtree(i)}}needsPaint(){return this.dirty||this.frameCache===null||this.frameCache!==this.painted}deliverSubtree(t){const e=this.M;if(this.layoutPtr||(this.layoutPtr=e._malloc(16)),e._getLayoutPointer(t.id,this.layoutPtr)){const s=this.layoutPtr>>2,r={x:e.HEAPF32[s],y:e.HEAPF32[s+1],width:e.HEAPF32[s+2],height:e.HEAPF32[s+3]},i=t.layoutRect,o=!i||i.x!==r.x||i.y!==r.y||i.width!==r.width||i.height!==r.height;t.layoutRect=r,o&&(this.dirty=!0),o&&t.has(Re)&&e._creatorWebNodeLayout(t.id,r.x,r.y,r.width,r.height)}for(const s of t.children)this.deliverSubtree(s)}readLayoutBatch(t){const e=this.M,s=e._collectNodes()>>>2,r=e._collectRects()>>>2,i=e.HEAPU32,o=e.HEAPF32;for(let a=0;a<t;a++){const h=i[s+a],l=this.nodes.get(h);if(!l)continue;const c=o[r+a*4],d=o[r+a*4+1],u=o[r+a*4+2],f=o[r+a*4+3],p={x:c,y:d,width:u-c,height:f-d},b=l.layoutRect,g=!b||b.x!==p.x||b.y!==p.y||b.width!==p.width||b.height!==p.height;l.layoutRect=p,g&&(this.dirty=!0),g&&l.has(Re)&&e._creatorWebNodeLayout(h,c,d,p.width,p.height)}}frame(){if(this.frameCache&&!this.dirty)return this.frameCache;const t=[],e={x:0,y:0,width:this.width,height:this.height},s=this.leaving?this.build(this.leaving,e):null;if(s&&!this.leavingAbove&&t.push({tree:s,leaving:!0}),this.root){const r=this.build(this.root,e);r&&t.push({tree:r})}s&&this.leavingAbove&&t.push({tree:s,leaving:!0});for(const r of this.layerRoots){const i=this.build(r,e);i&&t.push({tree:i,widget:!0})}return this.frameCache=t,this.dirty=!1,t}renderTree(){var t;return((t=this.frame().find(e=>!e.widget&&!e.leaving))==null?void 0:t.tree)??null}widgetTrees(){return this.frame().filter(t=>t.widget).map(t=>t.tree)}widgets(){return this.widgetTrees()}serialize(){return wn(this.renderTree(),this.widgetTrees())}toText(){return bs(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();Zr(s,t,this.host,this.width,this.height,void 0,e),this.painted=s}build(t,e){const s=this.M,r=(i,o,a,h)=>{var x;if(i.style.display==="none")return null;let l,c,d,u;if(h)l=e.x,c=e.y,d=e.width,u=e.height;else{const w=i.layoutRect;if(!w)return null;l=o+w.x,c=a+w.y,d=w.width,u=w.height}const f={id:i.id,type:i.type,rect:{x:l,y:c,width:d,height:u},style:i.style,children:[]};i.name&&(f.name=i.name);const p=i;if(i.type==="text"){const w=se(p),v=un(w);f.text=i.text;const k=this.padding(i.id);(k[0]||k[1]||k[2]||k[3])&&(f.padding=k);const A=d-k[0]-k[2],P=`${A}|${v.size}|${v.weight}|${v.italic?1:0}|${v.letterSpacing}|${v.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.style.textWrap??""}|${i.text}`;if(((x=i.wrapCache)==null?void 0:x.key)===P)f.lines=i.wrapCache.lines;else{const I=N=>this.host.measureText(N,v),C=dn(i.text,i.style,A,I,!0);i.wrapCache={key:P,lines:C},f.lines=C}f.style={...i.style,color:w.color,fontSize:w.fontSize,fontFamily:w.fontFamily,fontWeight:w.fontWeight,fontStyle:w.fontStyle,lineHeight:w.lineHeight,letterSpacing:w.letterSpacing,textAlign:w.textAlign,textDecoration:w.textDecoration}}else if(i.type==="image"){const w=this.host.resolveSrc(i.imageSrcRaw),v=w?this.host.getImage(w):void 0;f.image=v??(w?{src:w,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(f.sourceRect=i.sourceRect)}else if(i.editable){f.value=i.value;const w=this.padding(i.id);(w[0]||w[1]||w[2]||w[3])&&(f.padding=w);const v=se(p);f.style={...i.style,color:v.color,fontSize:v.fontSize,fontFamily:v.fontFamily,fontWeight:v.fontWeight,fontStyle:v.fontStyle,lineHeight:v.lineHeight,letterSpacing:v.letterSpacing,textAlign:v.textAlign,textDecoration:v.textDecoration}}i.type==="widget"&&i.style.overlayColor!==void 0&&(f.overlay=i.style.overlayColor),i.interactive&&(f.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(f.state={...f.state,focused:!0}),i.style.overflow==="hidden"&&(f.clip=!0);let b=l,g=c;if(i.scrollable){const w=i.scrollAxis,v=w==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);f.clip=!0,f.scroll={offset:i.scrollOffset,content:v,axis:w},w==="x"?b=l-i.scrollOffset:g=c-i.scrollOffset}if(i.type==="pager"){const w=s._creatorWebPagerSelectedIndex(i.id),v=s._creatorWebPagerStackLen(i.id,w),k=v>0?s._creatorWebPagerPageNode(i.id,w,v-1):0,A=k?this.nodes.get(k):void 0;A?this.pagerShown.set(i.id,A):this.pagerShown.delete(i.id);const P=this.pagerLeaving.get(i.id);for(const I of P&&P.page!==A?P.above?[A,P.page]:[P.page,A]:[A]){const C=I?r(I,l,c,!1):null;C&&f.children.push(C)}return f}if(i.type==="vlist"){for(const w of i.children){const v=s._getParentNode(w.id);if(!v)continue;const k=s._vlistItemOffsetOf(i.id,v);if(Number.isNaN(k))continue;const A=r(w,l,c+k-i.scrollOffset,!1);A&&f.children.push(A)}return f}for(const w of i.children){const v=r(w,b,g,!1);v&&f.children.push(v)}return f};return r(t,0,0,!0)}paddingOf(t){return this.padding(t)}padding(t){const e=this.M;this.padPtr||(this.padPtr=e._malloc(16)),e._getPaddingPointer(t,this.padPtr);const s=this.padPtr>>2;return[e.HEAPF32[s],e.HEAPF32[s+1],e.HEAPF32[s+2],e.HEAPF32[s+3]]}withStr(t,e){const s=this.M.stringToNewUTF8(t);try{return e(s)}finally{this.M._free(s)}}get(t){return this.nodes.get(t)}findAll(t){const e=[],s=r=>{r.name===t&&e.push(r);for(const i of r.children)s(i)};for(const r of this.frame())s(r.tree);return e}findRect(t){const e=s=>{if(s.id===t)return s.rect;for(const r of s.children){const i=e(r);if(i)return i}return null};for(const s of this.frame()){const r=e(s.tree);if(r)return r}return null}toast(){return this.lastToast}pendingFonts(){return this.fontsPending}keyboardHeight(){return this.focused?this.options.keyboardHeight?this.options.keyboardHeight():Math.round(this.height*Es):0}focusedId(){var t;return((t=this.focused)==null?void 0:t.id)??0}nodeFactory(t,e,s,r){this.lastCreated=t;const i=new ks(t,e);this.nodes.set(t,i),e==="vlist"&&this.vlists.add(i);const o=this.nodes.get(s);o&&this.link(o,i,Math.max(0,r)),this.dirty=!0}link(t,e,s){e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),e.parent=t,t.children.splice(Math.min(s,t.children.length),0,e)}insertNode(t,e,s){const r=this.nodes.get(t),i=this.nodes.get(e);r&&i&&this.link(r,i,s),this.dirty=!0}removeNode(t,e){var i;const s=this.nodes.get(t),r=this.nodes.get(e);!s||!r||(this.forget(r),s.children=s.children.filter(o=>o!==r),r.parent===s&&(r.parent=null),((i=this.pagerLeaving.get(t))==null?void 0:i.page)===r&&this.pagerLeaving.delete(t),this.pagerShown.get(t)===r&&this.pagerShown.delete(t),this.dirty=!0)}releaseNode(t){const e=this.nodes.get(t);if(!e)return;this.nodes.delete(t),this.forget(e),e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),this.root===e&&(this.root=null),this.leaving===e&&(this.leaving=null),this.pagerShown.delete(t),this.pagerLeaving.delete(t);for(const[r,i]of this.pagerLeaving)i.page===e&&this.pagerLeaving.delete(r);this.focused===e&&(this.focused=null,this.shrinkTo(0,0),this.emitKeyboard());const s=this.layerRoots.indexOf(e);s>=0&&this.layerRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),this.dirty=!0}forget(t){for(const e of this.gestures.values())e.node===t&&(e.node=null),e.scroll===t&&(e.scroll=null),e.backdrop===t&&(e.backdrop=null),e.edit===t&&(e.edit=null);for(const e of t.children)this.forget(e)}setPropertyString(t,e,s){const r=this.nodes.get(t);if(!r)return;const i=s??"";switch(e){case"text":r.text=i,r.wrapCache=void 0;break;case"value":r.value=i;break;case"name":r.name=i||void 0;break;case"src":{r.src=i||void 0;const o=this.host.resolveSrc(this.srcOf(r));o&&!this.host.getImage(o)&&this.host.loadImage(o).then(()=>{this.nodes.get(t)===r&&this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0}).catch(()=>{});break}case"sourceRect":{const o=i.split(" ").map(Number);r.sourceRect=o.length===4?[o[0],o[1],o[2],o[3]]:void 0;break}case"focus":i==="1"||i==="true"?this.focusInput(t):this.focused===r&&this.blurInput();break;case"viewName":r.viewName=i;break;case"viewParams":r.viewParams=i;break}this.dirty=!0}srcOf(t){return ae(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(ae(e)):void 0;const s=t.bgSrc;s&&!this.host.getImage(s)&&this.host.loadImage(s).then(()=>{this.dirty=!0}).catch(()=>{})}t.style.backgroundImage=t.bgSrc}setPropertyInt(t,e,s){const r=this.nodes.get(t);r&&(e==="playerId"?r.playerId=s:e==="viewId"&&(r.viewId=s)),this.dirty=!0}setFlags(t,e){const s=this.nodes.get(t);s&&(s.flags=e>>>0)}leave(t){this.root&&(this.leaving=this.root,this.leavingAbove=t,this.root=null)}openView(t,e,s,r,i,o){var h;this.destKind=t;const a=t===Ae?this.nodes.get(e)??null:null;a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,this.focused&&this.blurInput(),this.dirty=!0,(h=this.onDestination)==null||h.call(this,t,s)}dropView(t,e,s){var r;if(t===Ae){const i=this.nodes.get(e)??null;i!==null&&this.leaving===i&&(this.leaving=null),i!==null&&this.root===i&&(this.root=null)}this.dirty=!0,(r=this.onDropped)==null||r.call(this,t,s)}closeView(){var t;this.destKind=-1,this.leave(!0),this.dirty=!0,(t=this.onDestination)==null||t.call(this,-1,0)}layerOpen(t){const e=this.nodes.get(t);e&&!this.layerRoots.includes(e)&&this.layerRoots.push(e),this.dirty=!0}layerClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.layerRoots.indexOf(e):-1;s>=0&&this.layerRoots.splice(s,1),this.dirty=!0}registerFont(t,e,s,r,i,o){this.fontsPending++,this.host.loadFont(e,t,{weight:s,style:r===2?"italic":"normal"}).then(()=>{this.invalidateText(),i()},a=>o(String(a))).finally(()=>{this.fontsPending--})}invalidateText(){for(const t of this.nodes.values())t.wrapCache=void 0,t.measured&&t.type!=="image"&&this.M._nodeHasMeasure(t.id)&&this.M._markNodeDirty(t.id);this.dirty=!0}showToast(t,e){var s,r;this.lastToast=t,(r=(s=this.options).onToast)==null||r.call(s,t,e)}getButtonPressed(t){return this.pressed.has(t)}getTextValue(t){var e;return((e=this.nodes.get(t))==null?void 0:e.value)??""}getBoundingRect(t){const e=this.findRect(t);return e?[e.x,e.y,e.width,e.height]:null}longPressHandler(t,e){const s=this.gestures.get(t);s&&(s.swallowClick=!0)}vlistScroll(t,e,s){const r=this.nodes.get(t);r&&(r.scrollOffset=e),this.dirty=!0}pagerCommand(t,e,s){this.pagerLeaving.delete(t),this.dirty=!0}pagerShowPage(t,e,s){const r=this.nodes.get(e),i=this.pagerShown.get(t);r&&this.pagerShown.set(t,r),i&&i!==r&&this.pagerLeaving.set(t,{page:i,above:!s}),this.dirty=!0}pagerDropPage(t,e){var s;((s=this.pagerLeaving.get(t))==null?void 0:s.page.id)===e&&this.pagerLeaving.delete(t),this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent&&e.type!=="widget";)e=e.parent;return e}emitKeyboard(){var s,r;const t=this.keyboardHeight(),e=this.keyboardDuration();(r=(s=this.options).onKeyboard)==null||r.call(s,t,e),this.M._creatorWebKeyboardEvent(t,e)}shrinkTo(t,e){this.M._creatorWebSetShrunkRoot(t,e);const s=e>0?t:0;s!==this.shrunkRoot&&(this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&this.M._overrideRootSafeBottom(this.shrunkRoot,this.safeBottom),this.shrunkRoot=s,this.shrunkInset=this.safeBottom);const r=Math.max(0,this.safeBottom-e);s&&r!==this.shrunkInset&&this.nodes.has(s)&&(this.M._overrideRootSafeBottom(s,r),this.shrunkInset=r)}keyboardDuration(){return 0}refreshKeyboard(){this.focused&&(this.shrinkTo(this.rootOf(this.focused).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}focusInput(t){const e=this.nodes.get(t);!e||!e.editable||this.focused===e||(this.focused&&this.blurInput(),this.focused=e,this.M._setNodeFocused(t,1),e.has(Hr)&&this.M._creatorWebNodeEvent(t,Lr),this.shrinkTo(this.rootOf(e).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}blurInput(){const t=this.focused;t&&(this.focused=null,this.M._setNodeFocused(t.id,0),t.has($r)&&this.M._creatorWebNodeEvent(t.id,Pr),this.shrinkTo(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Dr)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Mr,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Gr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Cr,e)),this.focused===t&&this.blurInput(),!0):!1}scrollMax(t){const e=this.findRect(t.id)??t.layoutRect??{width:0,height:0},s=t.scrollAxis==="x"?e.width:e.height,r=t.scrollAxis==="x"?this.M._getContentWidth(t.id):this.M._getContentHeight(t.id);return Math.max(0,r-s)}scrollBy(t,e){const s=this.nodes.get(t);if(!s||!s.scrollable)return!1;const r=this.scrollMax(s),i=s.scrollOffset+e,o=Math.min(r,Math.max(0,i)),a=i<0?i:i>r?i-r:0;return a!==0&&s.has(Wr)&&this.M._creatorWebNodeEventNum(t,Rr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(Ur)&&this.M._creatorWebNodeScroll(t,o),this.dirty=!0,!0)}topInteractive(t,e){const s=this.frame();for(let r=s.length-1;r>=0;r--){const i=mt(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i.node)return this.nodes.get(i.node.id)??null;if(i.blocker)return null}return null}setPressed(t,e){e?this.pressed.add(t.id):this.pressed.delete(t.id),this.nodes.get(t.id)===t&&this.M._setNodePressed(t.id,e?1:0),this.dirty=!0}pointerHover(t,e){this.hoverX=t,this.hoverY=e,this.hoverInside=!0,this.hoverMoved=!0}pointerLeave(){this.hoverInside&&(this.hoverInside=!1,this.hoverMoved=!0)}get hasHover(){return typeof this.M._creatorWebHover=="function"}tickHover(){if(!this.hasHover||!this.hoverMoved&&!this.dirty)return;this.hoverMoved=!1;const t=this.hoverInside?this.topInteractive(this.hoverX,this.hoverY):null;this.M._creatorWebHover((t==null?void 0:t.id)??0,this.hoverX,this.hoverY)}pointerDown(t,e,s){const r=this.M;r._creatorWeb2dSceneOpen()&&r._creatorWeb2dEmitPointer(0,t,e,s);const i={node:null,scroll:null,backdrop:null,edit:null,global:!1,dismiss:!0,lastX:e,lastY:s,acc:0,scrolling:!1,swallowClick:!1};this.gestures.set(t,i);const o=this.frame();for(let a=o.length-1;a>=0;a--){const h=mt(o[a].tree,e,s,l=>{var c;return((c=this.nodes.get(l.id))==null?void 0:c.editable)??!1});if(h.node){const l=this.nodes.get(h.node.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(h.blocker)break}for(let a=o.length-1;a>=0;a--){const h=o[a],l=mt(h.tree,e,s,u=>{var f;return((f=this.nodes.get(u.id))==null?void 0:f.interactive)??!1}),c=mt(h.tree,e,s,u=>!!u.scroll&&u.scroll.content>(u.scroll.axis==="x"?u.rect.width:u.rect.height)+.5),d=c.node?this.nodes.get(c.node.id)??null:null;if(l.node){const u=this.nodes.get(l.node.id);i.node=u,i.scroll=d,i.dismiss=u.type!=="button",this.setPressed(u,!0),r._creatorWebNodeTouchStart(u.id,t,e,s);return}if(d){i.scroll=d;return}if(l.blocker){i.backdrop=l.outside?this.nodes.get(l.blocker.id)??null:null;return}}i.global=!0,r._creatorWebSceneTouchStart(t,e,s)}pointerMove(t,e,s){const r=this.gestures.get(t);if(!r)return;const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(1,t,e,s);const o=e-r.lastX,a=s-r.lastY;if(r.lastX=e,r.lastY=s,r.acc+=Math.abs(o)+Math.abs(a),!r.edit){if(!r.scrolling&&r.scroll&&r.acc>Ss&&(r.scrolling=!0,r.node&&this.setPressed(r.node,!1)),r.scrolling&&r.scroll){this.scrollBy(r.scroll.id,r.scroll.scrollAxis==="x"?-o:-a);return}i._creatorWebTouchMove(t,e,s,o,a)}}pointerUp(t,e,s){const r=this.gestures.get(t);if(!r)return;this.gestures.delete(t);const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(2,t,e,s);const o=e-r.lastX,a=s-r.lastY;i._creatorWebTouchEnd(t,e,s,o,a),!r.edit&&(r.scrolling&&r.scroll&&r.scroll.has(Br)&&i._creatorWebNodeEvent(r.scroll.id,Ar),r.dismiss&&!r.scrolling&&this.focused&&this.blurInput(),r.node?(this.setPressed(r.node,!1),!r.scrolling&&!r.swallowClick&&this.topInteractive(e,s)===r.node&&r.node.has(Fr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Vr)&&i._creatorWebNodeEvent(r.backdrop.id,Or):r.global&&(r.scrolling||i._creatorWebSceneTouchClick(t,e,s)))}pointerCancel(t){const e=this.gestures.get(t);if(!e)return;this.gestures.delete(t);const s=this.M;s._creatorWeb2dSceneOpen()&&s._creatorWeb2dEmitPointer(3,t,e.lastX,e.lastY),e.node&&this.setPressed(e.node,!1),s._creatorWebTouchCancel(t)}wheel(t,e,s,r){const i=this.frame();for(let o=i.length-1;o>=0;o--){const a=mt(i[o].tree,t,e,h=>!!h.scroll&&h.scroll.content>(h.scroll.axis==="x"?h.rect.width:h.rect.height)+.5);if(a.node){const h=this.nodes.get(a.node.id);return h?this.scrollBy(h.id,h.scrollAxis==="x"?s:r):!1}if(a.blocker)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(Nr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const Ts=`
3
+ `));return}if(--this.refs[t]>0)return;const e=this.table[t];(typeof e=="object"||typeof e=="function")&&this.objIndex.delete(e),this.table[t]=void 0,this.freeSlots.push(t)}liveHandles(){return this.table.length-1-this.freeSlots.length}global(t){var e;this.writeOut(((e=this.worlds.get(t))==null?void 0:e.global)??this.worlds.get(1).global)}newContext(){if(!this.newWorld)return 1;const t=this.nextWorld++;return this.worlds.set(t,this.newWorld()),t}freeContext(t){t!==1&&this.worlds.delete(t)}eval(t,e,s){const r=this.worlds.get(t)??this.worlds.get(1);try{this.writeOut(r.evaluate(e,s))}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}get(t,e,s){const r=this.decode(t,e);if(r==null){this.writeOut(void 0);return}try{this.writeOut(r[s])}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}getIndex(t,e,s){const r=this.decode(t,e);if(r==null){this.writeOut(void 0);return}try{this.writeOut(r[s])}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}has(t,e,s){const r=this.decode(t,e);return(typeof r=="object"||typeof r=="function")&&r!==null&&s in r}set(t,e,s,r){const i=this.table[t];i!=null&&(i[e]=this.decode(s,r))}setIndex(t,e,s,r){const i=this.table[t];i!=null&&(i[e]=this.decode(s,r))}keys(t,e,s){const r=this.M,i=this.decode(t,e),o=(typeof i=="object"||typeof i=="function")&&i!==null?Object.keys(i):[];let a=1;for(const h of o)a+=r.lengthBytesUTF8(h)+1;const l=r._malloc(a);let c=l;for(const h of o){const u=r.lengthBytesUTF8(h)+1;r.stringToUTF8(h,c,u),c+=u}return r.HEAPU32[s>>2]=o.length,l}newObject(t,e){const s={};if(t>0){this.opaques.set(s,{cls:t,opaque:e});const r={ref:new WeakRef(s),cls:t,opaque:e};this.tracked.set(r,r),this.classRegistry.register(s,r,r)}this.writeOut(s)}newArray(){this.writeOut([])}opaqueOf(t,e){const s=this.table[t];if(typeof s!="object"||s===null)return 0;const r=this.opaques.get(s);return r&&r.cls===e?r.opaque:0}json(t,e){let s;try{s=JSON.stringify(this.decode(t,e))}catch{s=void 0}this.writeOut(s)}parseJson(t){try{this.writeOut(JSON.parse(t))}catch(e){this.pending=e,this.hasPending=!0,this.writeOutException()}}newString(t){this.writeOut(t)}str(t,e,s){const r=this.M,i=this.decode(t,e);let o;try{o=typeof i=="string"?i:String(i)}catch{return 0}const a=r.lengthBytesUTF8(o),l=r._malloc(a+1);return r.stringToUTF8(o,l,a+1),r.HEAPU32[s>>2]=a,l}logString(t,e){const s=this.M,r=this.decode(t,e);let i;try{i=String(r)}catch{i=""}if(r instanceof Error&&typeof r.stack=="string"&&r.stack.length>0){const l=r.stack.startsWith(i)?r.stack.slice(i.length).replace(/^\n/,""):r.stack;l.trim().length>0&&(i+=`
4
+ `+l.replace(/[\r\n]+$/,""))}const o=s.lengthBytesUTF8(i),a=s._malloc(o+1);return s.stringToUTF8(i,a,o+1),a}toNumber(t){try{return Number(this.table[t])}catch{return NaN}}truthy(t){return!!this.table[t]}newError(t){this.writeOut(new Error(t))}throwNew(t,e){this.pending=t===1?new TypeError(e):new Error(e),this.hasPending=!0}takeException(){const t=this.hasPending?this.pending:void 0;this.pending=void 0,this.hasPending=!1,this.writeOut(t)}throwPending(){const t=this.hasPending?this.pending:new Error("native handler failed");throw this.pending=void 0,this.hasPending=!1,t}call(t,e,s,r,i,o){const a=this.table[e],l=this.decode(s,r),c=this.args(i,o);try{this.writeOut(a.apply(l,c))}catch(h){this.pending=h,this.hasPending=!0,this.writeOutException()}}construct(t,e,s){const r=this.table[t],i=this.args(e,s);try{this.writeOut(Reflect.construct(r,i))}catch(o){this.pending=o,this.hasPending=!0,this.writeOutException()}}typedArray(t,e,s){const i=this.M.HEAPU8.slice(e,e+s).buffer,o=[null,Uint8Array,Uint16Array,Uint32Array,Int32Array,Float32Array,Float64Array,Int16Array,Int8Array,Uint8ClampedArray];if(t===0){this.writeOut(i);return}const a=o[t];this.writeOut(a?new a(i):void 0)}arrayIn(t,e,s,r){const i=this.M,o=this.table[t];let a=null,l=0;if(s===2){if(!(o instanceof ArrayBuffer))return 0;a=new Uint8Array(o),l=a.byteLength}else{if(!ArrayBuffer.isView(o)||o instanceof DataView)return 0;const h=o,u=h.BYTES_PER_ELEMENT;if(s===0&&u!==e)return 0;a=new Uint8Array(h.buffer,h.byteOffset,h.byteLength),l=s===0?h.length:h.byteLength}const c=i._malloc(Math.max(a.byteLength,1));return a.byteLength>0&&i.HEAPU8.set(a,c),i.HEAPU32[r>>2]=l,c}arrayOut(t,e,s){const r=this.table[t];let i;if(r instanceof ArrayBuffer)i=new Uint8Array(r);else if(ArrayBuffer.isView(r))i=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);else return;const o=Math.min(s,i.byteLength);o>0&&i.set(this.M.HEAPU8.subarray(e,e+o))}invoke(t,e){const s=e.length,r=this.argSp;let i=r,o=0;r+s*8>this.argBase+Ee?(o=this.M._malloc(Math.max(s*8,8)),i=o):this.argSp=r+s*8;const a=[];for(let c=0;c<s;c++){const h=this.write(i+c*8,e[c]);h&&a.push(h)}let l;try{t(s,i),l=this.takeOut()}finally{for(const c of a)this.release(c);this.argSp=r,o&&this.M._free(o)}return l.threw&&this.throwPending(),l.value}defineMethod(t,e,s,r,i,o){const a=this.table[e];if(o){Object.defineProperty(a,s,{configurable:!0,enumerable:!1,get:()=>this.invoke(()=>this.M._jsbInvokeGetter(r),[])});return}const l=this.M,c=(...h)=>this.invoke((u,f)=>l._jsbInvoke(t,r,u,f),h);Object.defineProperty(c,"name",{value:s}),Object.defineProperty(c,"length",{value:i}),Object.defineProperty(a,s,{configurable:!0,enumerable:!1,writable:!0,value:c})}makeFunction(t,e,s,r){const i=this.M,o=(...a)=>this.invoke((l,c)=>i._jsbInvokeData(t,e,l,c),a);s&&Object.defineProperty(o,"name",{value:s}),Object.defineProperty(o,"length",{value:r}),this.fnRegistry.register(o,e),this.writeOut(o)}callback(t,e){return t?(...s)=>{if(e){if(e.done){console.warn("[jsb] a settled host callback was called again");return}e.done=!0}const r=this.M,i=s.length,o=e?e.ptrs.length:0,a=r._malloc(Math.max(i*8+o*4,8)),l=[];for(let h=0;h<i;h++){const u=this.write(a+h*8,s[h]);u&&l.push(u)}const c=a+i*8;for(let h=0;h<o;h++)r.HEAPU32[(c>>2)+h]=e.ptrs[h];r._jsbHostCall(t,i,a,c,o);for(const h of l)this.release(h);r._free(a)}:()=>{}}viewEvent(t,e,s){const r=this.M,i=r.stringToNewUTF8(e);if(s===void 0){r._jsbViewEvent(t,i,0),r._free(i);return}const o=r._malloc(8),a=this.write(o,s);r._jsbViewEvent(t,i,o),a&&this.release(a),r._free(o),r._free(i)}group(...t){return{ptrs:t.filter(e=>e!==0),done:!1}}strings(t,e){const s=this.M,r=new Array(e);for(let i=0;i<e;i++){const o=s.HEAPU32[(t>>2)+i];r[i]=o?s.UTF8ToString(o):""}return r}bytesOut(t,e){const s=this.M;let r=null;if(t instanceof Uint8Array?r=t:t instanceof ArrayBuffer?r=new Uint8Array(t):ArrayBuffer.isView(t)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),!r||r.byteLength===0)return e&&(s.HEAPU32[e>>2]=0),0;const i=s._malloc(r.byteLength+1);return s.HEAPU8.set(r,i),s.HEAPU8[i+r.byteLength]=0,e&&(s.HEAPU32[e>>2]=r.byteLength),i}gc(){const t=globalThis.gc,e=globalThis.Bun;for(let s=0;s<2;s++){if(e!=null&&e.gc)e.gc(!0);else if(typeof t=="function")t();else return;this.sweep()}}sweep(){for(const t of[...this.tracked.keys()])t.ref.deref()===void 0&&(this.tracked.delete(t),this.classRegistry.unregister(t),this.M._jsbFinalize(t.cls,t.opaque))}}const Zn=(n,t)=>{const e=new Qn(n,t);return n.jsb=e,e},tr=""+new URL("assets/creator-full.js-CZ3EVfR2.symbols",import.meta.url).href,rt=/wasm-function\[(\d+)\]/g;let $t=null;const rn=()=>($t||($t=fetch(tr).then(n=>{if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return n.text()}).then(n=>{const t=new Map;for(const e of n.split(`
5
+ `)){const s=e.indexOf(":");s>0&&t.set(Number(e.slice(0,s)),e.slice(s+1))}return t}).catch(n=>(console.warn("[creator-gl] creator-gl.js.symbols unavailable, wasm frames stay anonymous:",n),null))),$t),sn=n=>n.replace(/\\([0-9a-fA-F]{2})/g,(t,e)=>String.fromCharCode(parseInt(e,16))),er=/([\w.-]+)\.wasm(?=[^\w-]|$)/g,on=n=>{const t=[...n.matchAll(er)].map(e=>e[1]);return t.length===0?null:t.some(e=>e.includes("creator-gl"))?"ours":"other"},nr=async n=>{if(rt.lastIndex=0,!rt.test(n))return null;const t=await rn();if(!t)return null;let e=!1;const s=n.split(`
6
+ `).map(r=>{if(rt.lastIndex=0,!rt.test(r))return r;const i=on(r);return i==="other"?r:r.replace(rt,(o,a)=>{const l=t.get(Number(a));return l===void 0?o:(e=!0,`${i===null?"?":""}${sn(l)} (${o})`)})});return e?s.join(`
7
+ `):null},rr=async n=>{if(rt.lastIndex=0,!rt.test(n))return[];const t=await rn();if(!t)return[];const e=[];for(const s of n.split(`
8
+ `))if(on(s)!=="other")for(const r of s.matchAll(rt)){const i=t.get(Number(r[1]));i!==void 0&&e.push(sn(i).replaceAll("std::__2::","std::"))}return e},Se=n=>{const t=n==null?void 0:n.stack;typeof t=="string"&&nr(t).then(e=>{e&&console.error(`[creator-gl] decoded wasm stack (via creator-gl.js.symbols):
9
+ `+e)})};let _e=!1;const sr=()=>{_e||(_e=!0,addEventListener("error",n=>Se(n.error)),addEventListener("unhandledrejection",n=>Se(n.reason)))},H=[null];new TextDecoder("utf-8");const ir=async(n,t,e,s)=>{var d;let r;if(t.body)if(typeof t.body=="object"&&Array.isArray(t.body._entries)){const p=new FormData;for(let[y,b,x]of t.body._entries)typeof b=="object"?p.append(y,new Blob([Z(b._id)]),x):p.append(y,b);r=p}else typeof t.body=="string"?r=t.body:s(new Error("Invalid body"));const i=await fetch(n,{method:t.method,body:r,headers:t.headers,mode:"cors",credentials:"omit"}),o=typeof t.onProgress=="function"?t.onProgress:null;if(!o){const p=await i.arrayBuffer();H.push(p),e(H.length-1,i.status);return}const a=(d=i.body)==null?void 0:d.getReader();if(!a){const p=await i.arrayBuffer();H.push(p),e(H.length-1,i.status);return}const l=Number(i.headers.get("content-length"))||void 0;let c=0;const h=[];for(;;){const{done:p,value:y}=await a.read();if(p)break;y&&(h.push(y),c+=y.length,o({loaded:c,total:l}))}const u=new Uint8Array(c);let f=0;for(const p of h)u.set(p,f),f+=p.length;H.push(u.buffer),e(H.length-1,i.status)},an=n=>{const t=new Blob([H[n]]);return URL.createObjectURL(t)},Wt=n=>new Blob([H[n]]),Z=n=>H[n],or=n=>{H[n]=null},ut=n=>(H.push(n),H.length-1),ue=new Map,ar=(n,t)=>{ue.set(n,t);const e=Ct.get(n);e!==void 0&&(H[e]=t)},cr=n=>ue.has(n),Ct=new Map,lr=n=>{for(const[t,e]of Ct)if(e===n)return t},hr=n=>{const t=Ct.get(n);if(t!==void 0)return t;const e=ue.get(n);if(!e)return-1;H.push(e);const s=H.length-1;return Ct.set(n,s),s},fe=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function cn(n){return typeof n=="object"&&n!==null&&"svg"in n}function ur(n){return typeof n=="object"&&n!==null&&"_id"in n}function fr(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const ee="lecodes-canvas://";function dr(n){return n.startsWith(ee)?Number(n.slice(ee.length)):void 0}function pr(n){return typeof File<"u"&&n instanceof File}function ln(n){let t=n.trim();/\sxmlns\s*=/.test(t)||(t=t.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"'));const e=new TextEncoder().encode(t);let s="";for(const r of e)s+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(s)}`}function Dt(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function ne(n){var i,o,a;const t=((i=n.match(/<svg\b[^>]*>/i))==null?void 0:i[0])??"",e=t.match(/viewBox\s*=\s*["']\s*[\d.+-]+\s+[\d.+-]+\s+([\d.+-]+)\s+([\d.+-]+)\s*["']/i);if(e){const l=parseFloat(e[1]),c=parseFloat(e[2]);if(l>0&&c>0)return{width:l,height:c}}const s=parseFloat(((o=t.match(/\bwidth\s*=\s*["']?([\d.]+)/i))==null?void 0:o[1])??""),r=parseFloat(((a=t.match(/\bheight\s*=\s*["']?([\d.]+)/i))==null?void 0:a[1])??"");return s>0&&r>0?{width:s,height:r}:null}function gr(n){const t=/^data:image\/svg\+xml(;[^,]*)?,([\s\S]*)$/.exec(n);if(!t)return null;const e=t[2];try{if(/;base64/i.test(t[1]??"")){const s=atob(e),r=new Uint8Array(s.length);for(let i=0;i<s.length;i++)r[i]=s.charCodeAt(i);return new TextDecoder().decode(r)}return decodeURIComponent(e)}catch{return null}}async function mr(n,t){if(!Dt(n))return null;const e=gr(n);if(e)return ne(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?ne(s):null}function yr(n={}){const t=new WeakMap;return e=>{var o,a;if(e==null)return;if(typeof e=="string")return e;if(typeof e!="object")return;const s=e,r=t.get(s);if(r!==void 0)return r;let i;return cn(s)?i=ln(s.svg):fr(s)?i=ee+s.canvasSurface:ur(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):pr(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function ke(n,t){if(!t)return;const e=dr(n);if(e===void 0)return;const s=t.getSurface(e);if(s)return{src:n,naturalWidth:s.width,naturalHeight:s.height,handle:s.canvas}}const hn=n=>n==="monospaced"?"monospace":n;function Re(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${hn(n.family)}`}class wr{constructor(t={}){w(this,"ctx");w(this,"images",new Map);w(this,"pending",new Map);w(this,"resolver");w(this,"canvasSurfaces");w(this,"fontFormat","woff2");const e=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(8,8);this.ctx=e.getContext("2d"),this.canvasSurfaces=t.canvasSurfaces,this.resolver=yr({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return hn(t)}measureText(t,e){return this.ctx.font=Re(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=Re(t);const e=this.ctx.measureText("Mg"),s=e.fontBoundingBoxAscent||e.actualBoundingBoxAscent||t.size*.8,r=e.fontBoundingBoxDescent||e.actualBoundingBoxDescent||t.size*.2;return{ascent:s,descent:r}}getImage(t){return ke(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=ke(t,this.canvasSurfaces);if(e)return Promise.resolve(e);const s=this.images.get(t);if(s)return Promise.resolve(s);const r=this.pending.get(t);if(r)return r;const i=(async()=>{const o=await this.decode(t);let a=o.naturalWidth,l=o.naturalHeight;if(Dt(t)){const h=await mr(t,u=>fetch(u).then(f=>f.ok?f.text():null));h&&(a=h.width,l=h.height)}const c={src:t,naturalWidth:a,naturalHeight:l,handle:o};return this.images.set(t,c),this.pending.delete(t),c})();return this.pending.set(t,i),i.catch(()=>this.pending.delete(t)),i}decode(t){return new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=i=>s(i),r.src=t})}async loadFont(t,e,s){if(typeof globalThis.FontFace>"u")return;const r=new FontFace(t,`url(${e})`,s);document.fonts.add(r),await r.load()}}function br(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function pt(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function ot(n){const{r:t,g:e,b:s,a:r}=br(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function re(n){return n===void 0||(n>>>0&255)===0}function se(n,t){if(!n)return;const e=Math.min(t.width,t.height)/2;return{tl:Math.min(n.tl,e),tr:Math.min(n.tr,e),br:Math.min(n.br,e),bl:Math.min(n.bl,e)}}function Te(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function vr(n,t,e,s){const r={x:0,y:0,width:n,height:t};if(s==="fill"||n===0||t===0)return{src:r,dst:e};if(s==="cover"){const l=Math.max(e.width/n,e.height/t),c=e.width/l,h=e.height/l;return{src:{x:(n-c)/2,y:(t-h)/2,width:c,height:h},dst:e}}const i=Math.min(e.width/n,e.height/t),o=n*i,a=t*i;return{src:r,dst:{x:e.x+(e.width-o)/2,y:e.y+(e.height-a)/2,width:o,height:a}}}function xr(n,t){const e=n*Math.PI/180,s=Math.sin(e),r=-Math.cos(e),i=t.x+t.width/2,o=t.y+t.height/2,a=(Math.abs(t.width*s)+Math.abs(t.height*r))/2;return{x0:i-s*a,y0:o-r*a,x1:i+s*a,y1:o+r*a}}function Er(n,t){const e=t.x+n.cx*t.width,s=t.y+n.cy*t.height;if(n.extent==="explicit"){const p=n.rxUnit==="fraction"?(n.rx??0)*t.width:n.rx??0,y=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:p,ry:y}}const r=n.cx*t.width,i=(1-n.cx)*t.width,o=n.cy*t.height,a=(1-n.cy)*t.height,l=Math.min(r,i),c=Math.max(r,i),h=Math.min(o,a),u=Math.max(o,a);let f,d;if(n.shape==="circle"){let p;switch(n.extent){case"closest-side":p=Math.min(l,h);break;case"farthest-side":p=Math.max(c,u);break;case"closest-corner":p=Math.hypot(l,h);break;default:p=Math.hypot(c,u);break}f=d=p}else switch(n.extent){case"closest-side":f=l,d=h;break;case"farthest-side":f=c,d=u;break;case"closest-corner":f=l*Math.SQRT2,d=h*Math.SQRT2;break;default:f=c*Math.SQRT2,d=u*Math.SQRT2;break}return{cx:e,cy:s,rx:f,ry:d}}class Ae{constructor(t,e=1){w(this,"ctx");w(this,"dpr");w(this,"groups",[]);w(this,"scratch");w(this,"scratchCtx");w(this,"tileCells",new WeakMap);this.ctx=t,this.dpr=e}beginGroup(t){const e=this.ctx,s=e.canvas.width,r=e.canvas.height;let i;typeof OffscreenCanvas<"u"?i=new OffscreenCanvas(s,r):(i=document.createElement("canvas"),i.width=s,i.height=r);const o=i.getContext("2d");o.setTransform(e.getTransform()),this.groups.push({parent:e,layer:i,alpha:t}),this.ctx=o}endGroup(){const t=this.groups.pop();t&&(this.ctx=t.parent,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.globalAlpha*=t.alpha,this.ctx.drawImage(t.layer,0,0),this.ctx.restore())}beginFrame(t,e){const{ctx:s,dpr:r}=this;s.setTransform(r,0,0,r,0,0),s.clearRect(0,0,t,e),s.globalAlpha=1}endFrame(){}save(){this.ctx.save()}restore(){this.ctx.restore()}setAlpha(t){this.ctx.globalAlpha*=t}translate(t,e){this.ctx.translate(t,e)}scale(t,e){this.ctx.scale(t,e)}transform(t,e,s,r,i,o){this.ctx.transform(t,e,s,r,i,o)}addRectPath(t,e){const s=this.ctx;e&&(e.tl||e.tr||e.br||e.bl)?s.roundRect(t.x,t.y,t.width,t.height,[e.tl,e.tr,e.br,e.bl]):s.rect(t.x,t.y,t.width,t.height)}path(t,e){this.ctx.beginPath(),this.addRectPath(t,e)}clipRoundRect(t,e){this.path(t,e),this.ctx.clip()}fillRoundRect(t,e,s){this.path(t,e),this.ctx.fillStyle=ot(s),this.ctx.fill()}clearRoundRect(t,e){const s=this.ctx;s.save(),s.globalCompositeOperation="destination-out",s.globalAlpha=1,this.path(t,e),s.fillStyle="#000",s.fill(),s.restore()}fillGradient(t,e,s){if(s.type==="radial"){this.fillRadial(t,e,s);return}const{x0:r,y0:i,x1:o,y1:a}=xr(s.angle,t),l=this.ctx.createLinearGradient(r,i,o,a);for(const c of s.stops)l.addColorStop(Math.max(0,Math.min(1,c.position)),ot(c.color));this.path(t,e),this.ctx.fillStyle=l,this.ctx.fill()}fillRadial(t,e,s){const{cx:r,cy:i,rx:o,ry:a}=Er(s,t),l=this.ctx,c=o||1e-6,h=a||1e-6;l.save(),this.path(t,e),l.clip(),l.translate(r,i),l.scale(c,h);const u=l.createRadialGradient(0,0,0,0,0,1);for(const b of s.stops)u.addColorStop(Math.max(0,Math.min(1,b.position)),ot(b.color));l.fillStyle=u;const f=(t.x-r)/c,d=(t.x+t.width-r)/c,p=(t.y-i)/h,y=(t.y+t.height-i)/h;l.fillRect(f,p,d-f,y-p),l.restore()}strokeBorder(t,e,s){const r=this.ctx,i=["top","right","bottom","left"].filter(a=>s[a]);if(i.length===4&&i.every(a=>s[a].width===s.top.width&&s[a].color===s.top.color)){const a=s.top.width,l=se(e,t);r.beginPath(),this.addRectPath(t,l);const c={x:t.x+a,y:t.y+a,width:t.width-2*a,height:t.height-2*a};if(c.width>0&&c.height>0){const h=l&&se({tl:Math.max(0,l.tl-a),tr:Math.max(0,l.tr-a),br:Math.max(0,l.br-a),bl:Math.max(0,l.bl-a)},c);this.addRectPath(c,h||void 0)}r.fillStyle=ot(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:l,color:c}=s[a];r.fillStyle=ot(c),a==="top"?r.fillRect(t.x,t.y,t.width,l):a==="bottom"?r.fillRect(t.x,t.y+t.height-l,t.width,l):a==="left"?r.fillRect(t.x,t.y,l,t.height):r.fillRect(t.x+t.width-l,t.y,l,t.height)}}getScratch(t,e){return this.scratch||(this.scratch=typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):document.createElement("canvas"),this.scratchCtx=this.scratch.getContext("2d")),(this.scratch.width<t||this.scratch.height<e)&&(this.scratch.width=Math.max(this.scratch.width,t),this.scratch.height=Math.max(this.scratch.height,e)),this.scratchCtx}tileCell(t,e,s){const r=t.handle,i=this.tileCells.get(r);if(i&&i.pw===e&&i.ph===s)return i.canvas;const o=t.rasterize?t.rasterize(e,s):t.handle,a=typeof OffscreenCanvas<"u"?new OffscreenCanvas(e,s):Object.assign(document.createElement("canvas"),{width:e,height:s});return a.getContext("2d").drawImage(o,0,0,e,s),this.tileCells.set(r,{pw:e,ph:s,canvas:a}),a}drawImage(t,e,s,r){if(!t.handle)return;if(r.tile){const d=t.naturalWidth,p=t.naturalHeight;if(d<=0||p<=0)return;const y=Math.max(1,Math.ceil(d*this.dpr)),b=Math.max(1,Math.ceil(p*this.dpr)),x=t.rasterize!==void 0||Dt(t.src),m=x?this.tileCell(t,y,b):t.handle,v=x?d/y:1,_=x?p/b:1,T=this.ctx.createPattern(m,"repeat");if(!T)return;this.ctx.save(),this.ctx.translate(s.x,s.y),this.ctx.scale(v,_),this.ctx.fillStyle=T,this.ctx.fillRect(0,0,s.width/v,s.height/_),this.ctx.restore();return}const i=e?{src:e,dst:s}:vr(t.naturalWidth,t.naturalHeight,s,r.fit),o=i.dst;let a=i.src;const l=Math.max(1,Math.ceil(o.width*this.dpr)),c=Math.max(1,Math.ceil(o.height*this.dpr)),h=!e&&r.fit!=="cover";let u=t.handle;if(t.rasterize)if(h)u=t.rasterize(l,c);else{const d=Math.max(l/a.width,c/a.height),p=Math.max(1,Math.ceil(t.naturalWidth*d)),y=Math.max(1,Math.ceil(t.naturalHeight*d));u=t.rasterize(p,y);const b=p/t.naturalWidth,x=y/t.naturalHeight;a={x:a.x*b,y:a.y*x,width:a.width*b,height:a.height*x}}if(r.tint===void 0){h?this.ctx.drawImage(u,o.x,o.y,o.width,o.height):this.ctx.drawImage(u,a.x,a.y,a.width,a.height,o.x,o.y,o.width,o.height);return}const f=this.getScratch(l,c);f.clearRect(0,0,l,c),f.globalCompositeOperation="source-over",h?f.drawImage(u,0,0,l,c):f.drawImage(u,a.x,a.y,a.width,a.height,0,0,l,c),f.globalCompositeOperation="source-in",f.fillStyle=ot(r.tint),f.fillRect(0,0,l,c),f.globalCompositeOperation="source-over",this.ctx.drawImage(f.canvas,0,0,l,c,o.x,o.y,o.width,o.height)}fillText(t,e,s,r,i){const o=this.ctx;o.font=`${r.italic?"italic ":""}${r.weight} ${r.size}px ${r.family}`,o.textBaseline="alphabetic",o.textAlign="left","letterSpacing"in o&&(o.letterSpacing=`${r.letterSpacing}px`),o.fillStyle=ot(i),o.fillText(t,e,s)}}const V=[null],Et=new Map,un=n=>{if(!n.startsWith("id:"))return n;const t=Number(n.slice(3));return Z(t)?an(t):null},fn=n=>{const t=Et.get(n);t!==void 0&&(URL.revokeObjectURL(t),Et.delete(n))},vt=[!1],dn=(n,t,e)=>{n.addEventListener("ended",()=>{e(),vt[t]&&(n.currentTime=0,n.play())})},Sr=(n,t)=>{const e=un(n);if(e===null)return-1;const s=document.createElement("video");document.body.appendChild(s),s.crossOrigin="anonymous",s.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",s.src=e,s.playsInline=!0,s.controls=!1;const r=V.length;return e!==n&&Et.set(r,e),V.push(s),vt.push(!1),dn(s,r,t),r},_r=(n,t)=>{const e=un(n);if(e===null)return-1;const s=document.createElement("audio");document.body.appendChild(s),s.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",s.src=e;const r=V.length;return e!==n&&Et.set(r,e),V.push(s),vt.push(!1),dn(s,r,t),r},kr=(n,t)=>{const e=V[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},Rr=(n,t)=>{const e=V[n];e&&(t?e.play():e.pause())},Tr=(n,t)=>{vt[n]=t},Ar=n=>{var t;return((t=V[n])==null?void 0:t.currentTime)??0},Mr=(n,t)=>{const e=V[n];e&&(e.currentTime=t)},Lr=n=>{var e;const t=((e=V[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},de=n=>V[n],pn=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},Pr=n=>{const t=V[n];t&&(pn(t),fn(n),V[n]=null,vt[n]=!1)},gn=()=>{for(let n of V)n&&pn(n);for(const n of[...Et.keys()])fn(n);V.length=1,vt.length=1},Cr=9,Or=10,Ir=12,Fr=13,Nr=14,Ur=15,Br=16,Wr=1,Dr=2,Hr=4,Me=8,$r=16,Vr=32,Gr=64,jr=256,zr=512,Kr=1024,Xr=2048,Yr=4096,Le=0,Tt=1,Pe=2,ct=3;function Ce(n,t,e){const s=n.rect;return t>=s.x&&t<s.x+s.width&&e>=s.y&&e<s.y+s.height}function yt(n,t,e,s){let r=null,i=null,o=!1;const a=l=>{const c=Ce(l,t,e);if(c&&s(l)&&(r=l),!(l.clip&&!c))for(const h of l.children)h.overlay!==void 0&&(r=null,i=h,o=!Ce(h,t,e)),a(h)};return a(n),{node:r,blocker:r?null:i,outside:o}}const qr=255,nt={color:4294967295,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function ie(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:l,textAlign:c,textDecoration:h}=t,u=s??nt.fontSize;return{color:e??(n.type==="input"||n.type==="textarea"?qr:nt.color),fontSize:u,fontFamily:r??nt.fontFamily,fontWeight:i??nt.fontWeight,fontStyle:o??nt.fontStyle,lineHeight:a,letterSpacing:l??nt.letterSpacing,textAlign:c??nt.textAlign,textDecoration:h??nt.textDecoration}}function mn(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}const Jr=10;function oe(n,t,e){const s=[];if(n.length===0)return[""];let r=n;for(;r;){if(e(r)<=t){s.push(r);break}let i=0,o=-1,a=0;for(;(a=r.indexOf(" ",a+1))!==-1&&!(e(r.substring(0,a))>t);)o=a;if(o>0)i=o;else{let l=r.indexOf(" ");l===-1&&(l=r.length);const c=r.substring(0,l);if(e(c)>t){for(let h=1;h<=c.length;h++)if(e(c.substring(0,h))>t){i=h-1;break}}else for(let h=l+1;h<=r.length;h++)if(e(r.substring(0,h))>t){i=h-1;break}}i<=0&&(i=1),s.push(r.substring(0,i)),r=r.substring(i+(o>0?1:0))}return s}function Qr(n,t,e,s){const r=e.length;if(r<2||r>Jr||!isFinite(t))return e;const i=l=>oe(n,l,s).length;let o=Math.floor(t);if(i(o)!==r)return e;let a=0;for(const l of n.split(" "))a=Math.max(a,Math.ceil(s(l)));if(a>=o)return e;if(i(a)===r)o=a;else for(;o-a>1;){const l=a+o>>1;i(l)===r?o=l:a=l}return oe(n,o,s)}function Zr(n,t,e){const s=t.length;if(s<2)return t;const r=t[s-1].trim();if(r.length===0||r.includes(" "))return t;const i=t[s-2].trimEnd(),o=i.lastIndexOf(" ");if(o<=0)return t;const a=i.slice(o+1)+" "+r;return e(a)>n?t:[...t.slice(0,s-2),i.slice(0,o),a]}function Ot(n,t,e,s="wrap",r=0){const i=[],o=s==="nowrap"?1/0:t;let a=s==="balance"||s==="pretty";for(const c of n.split(`
10
+ `)){let h=oe(c,o,e);a&&(r>0&&i.length+h.length>r?a=!1:s==="balance"?h=Qr(c,o,h,e):h=Zr(o,h,e));for(const u of h)i.push(u)}let l=0;for(const c of i)l=Math.max(l,e(c));return{lines:i,maxWidth:l}}function yn(n,t,e,s,r){const i=t.textWrap??"wrap",o=Ot(n,e,s,i,t.lineClamp??0),a=i==="nowrap"&&!r?1/0:e,l=ts(o.lines,t,a,s);return i!=="nowrap"||!r||t.textOverflow==="clip"||!isFinite(e)?l:l.map(c=>s(c)>e?wn(c,e,s):c)}const Vt="…";function ts(n,t,e,s){const r=t.lineClamp??0;if(r<=0||n.length<=r)return n;const i=n.slice(0,r);return t.textOverflow==="clip"||(i[r-1]=wn(i[r-1],e,s)),i}function wn(n,t,e){if(!isFinite(t))return n+Vt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+Vt)>t;)r--;return s.slice(0,r).join("").trimEnd()+Vt}function es(n,t,e){const s=ie(n),r=mn(s),i=isNaN(e)?1/0:e,o=c=>t.measureText(c,r),a=yn(n.text??"",n.style,i,o,!1);let l=0;for(const c of a)l=Math.max(l,o(c));return{width:Math.ceil(l),height:Math.ceil(a.length*s.lineHeight)}}function ns(n,t,e){const s=n.style,r={family:s.fontFamily??"Roboto",size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.lineHeight,o=n.value??"";if(n.type==="input")return{width:Math.ceil(t.measureText(o,r)),height:Math.ceil(i)};const a=isNaN(e)?1/0:e,l=Ot(o,a,c=>t.measureText(c,r));return{width:Math.ceil(l.maxWidth),height:Math.ceil(Math.max(1,l.lines.length)*i)}}function rs(n,t,e,s){const r=n.imageSrcRaw;let i=0,o=0;if(n.sourceRect)i=n.sourceRect[2],o=n.sourceRect[3];else if(cn(r)){const c=ne(r.svg);if(c)i=c.width,o=c.height;else{const h=t.getImage(t.resolveSrc(r)??"");i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}}else{const c=t.resolveSrc(r),h=c?t.getImage(c):void 0;i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),l=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*l,height:o*l}}const bn=(n,t,e,s)=>t?[n[0],n[1],n[2],n[3],n[4]+e*t[0]+s*t[2],n[5]+e*t[1]+s*t[3]]:n;function ss(n,t,e,s,r,i,o={}){t.beginFrame(s,r);for(const a of n)vn(a.tree,t,e,o);t.endFrame()}function vn(n,t,e,s){var h;const{style:r,rect:i}=n;t.save();const o=r.opacity!==void 0&&r.opacity<1?r.opacity:void 0,a=o!==void 0&&n.children.length>0;if(a?t.beginGroup(o):o!==void 0&&t.setAlpha(o),r.transform){const[u,f,d,p,y,b]=bn(r.transform,r.transformBox,i.width,i.height),x=r.transformOrigin,m=i.x+(x?x.xPercent?i.width*x.x/100:x.x:i.width/2),v=i.y+(x?x.yPercent?i.height*x.y/100:x.y:i.height/2);t.translate(m,v),t.transform(u,f,d,p,y,b),t.translate(-m,-v)}const l=se(r.borderRadius,i);if(re(r.backgroundColor)||t.fillRoundRect(i,l,r.backgroundColor),r.backgroundImage){const u=e.getImage(r.backgroundImage);u&&u.naturalWidth>0&&u.naturalHeight>0&&(t.save(),Te(l)&&t.clipRoundRect(i,l),t.drawImage(u,null,i,{fit:is(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let u=r.backgroundGradients.length-1;u>=0;u--){const f=r.backgroundGradients[u];f.stops.length>0&&t.fillGradient(i,l,f)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const u=n.sourceRect;t.save(),Te(l)&&t.clipRoundRect(i,l),t.drawImage(n.image,u?{x:u[0],y:u[1],width:u[2],height:u[3]}:null,i,{fit:u?"fill":r.objectFit??"contain",tint:Dt(n.image.src)?r.tintColor:void 0,radius:l}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&as(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&ds(n,t,e,l),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,l):n.type==="video"?cs(n,t,e,l):((h=n.view)==null?void 0:h.label)!==void 0&&fs(n,n.view.name,n.view.label,t,e,l)),n.clip&&t.clipRoundRect(i,l);for(const u of n.children)u.overlay!==void 0&&!re(u.overlay)&&t.fillRoundRect(i,void 0,u.overlay),vn(u,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,l,Math.round(Math.min(1,r.dim)*255)>>>0);const c=os(r.border);c&&t.strokeBorder(i,l,c),a&&t.endGroup(),t.restore()}function is(n){return n==="contain"||n==="fill"?n:"cover"}function os(n){if(!n)return null;const t={};let e=!1;for(const s of["top","right","bottom","left"]){const r=n[s];r&&r.width>0&&(r.color>>>0)%256!==0&&(t[s]=r,e=!0)}return e?t:null}const pe=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function as(n,t,e){var b,x,m;const s=n.style,r={family:pe(e,s.fontFamily),size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.color??255,o=s.lineHeight,a=s.textAlign??"start",l=e.fontMetrics(r),{rect:c,lines:h}=n,u=((b=n.padding)==null?void 0:b[0])??0,f=((x=n.padding)==null?void 0:x[1])??0,d=((m=n.padding)==null?void 0:m[2])??0,p=c.x+u,y=c.width-u-d;for(let v=0;v<h.length;v++){const _=h[v],P=c.y+f+v*o+(o-(l.ascent+l.descent))/2+l.ascent,O=e.measureText(_,r),I=a==="center"?p+(y-O)/2:a==="end"?p+y-O:p;if(t.fillText(_,I,P,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const F=Math.max(1,r.size/14),$=s.textDecoration==="underline"?P+F:P-r.size*.3;t.fillRoundRect({x:I,y:$,width:O,height:F},void 0,i)}}}function cs(n,t,e,s){const{rect:r}=n;re(n.style.backgroundColor)&&t.fillRoundRect(r,s,286463999);const i=Math.min(r.width,r.height)*.3;if(i>=6){const o={family:"Roboto",size:i,weight:400,italic:!1,letterSpacing:0},a=e.fontMetrics(o),l=e.measureText("▶",o),c=r.x+(r.width-l)/2,h=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",c,h,o,4294967244)}}const ls=3722701567,hs=1263887359,us=2324997119;function fs(n,t,e,s,r,i){const{rect:o}=n;s.fillRoundRect(o,i,ls);const a=pe(r,void 0),l={family:a,size:17,weight:600,italic:!1,letterSpacing:0},c={family:a,size:13,weight:400,italic:!1,letterSpacing:0},h=[];if(e&&h.push([e,l,hs]),t&&t!==e&&h.push([t,c,us]),h.length===0)return;const u=4,f=h.map(([,p])=>{const y=r.fontMetrics(p);return y.ascent+y.descent});let d=o.y+(o.height-f.reduce((p,y)=>p+y,0)-u*(h.length-1))/2;s.save(),s.clipRoundRect(o,i),h.forEach(([p,y,b],x)=>{const m=o.x+(o.width-r.measureText(p,y))/2;s.fillText(p,m,d+r.fontMetrics(y).ascent,y,b),d+=f[x]+u}),s.restore()}function ds(n,t,e,s){var z,G,Y,g,M;const r=n.style,i={family:pe(e,r.fontFamily),size:r.fontSize??14,weight:r.fontWeight??400,italic:r.fontStyle==="italic",letterSpacing:r.letterSpacing??0},o=n.value??"",a=o.length===0,l=r.inputType==="password"&&!a,c=a?r.placeholder??"":l?"•".repeat(o.length):o,h=a?r.placeholderColor??2576980479:r.color??255,{rect:u}=n,f=((z=n.padding)==null?void 0:z[0])??0,d=((G=n.padding)==null?void 0:G[1])??0,p=((Y=n.padding)==null?void 0:Y[2])??0,y=((g=n.padding)==null?void 0:g[3])??0,b=u.x+f,x=u.width-f-p,m=u.y+d,v=u.height-d-y,_=e.fontMetrics(i),T=r.lineHeight,P=r.textAlign??"start",O=n.type==="textarea",I=O?Ot(c,x,A=>e.measureText(A,i)).lines:[c],F=A=>P==="center"?b+(x-A)/2:P==="end"?b+x-A:b,$=A=>O?m+A*T+(T-(_.ascent+_.descent))/2+_.ascent:m+(v-(_.ascent+_.descent))/2+_.ascent;t.save(),t.clipRoundRect(u,s);for(let A=0;A<I.length;A++){const W=I[A];W.length>0&&t.fillText(W,F(e.measureText(W,i)),$(A),i,h)}if((M=n.state)!=null&&M.focused){const A=a?[""]:O?Ot(l?"•".repeat(o.length):o,x,U=>e.measureText(U,i)).lines:[c],W=A.length-1,q=e.measureText(A[W],i),_t=a?F(0):F(q)+q,E=$(W),R=Math.max(1,i.size/14);t.fillRoundRect({x:_t,y:E-_.ascent,width:R,height:_.ascent+_.descent},void 0,r.color??255)}t.restore()}const ps=84,gs={display:{word:4},overflow:{word:5},scrollDirection:{word:6},borderTopWidth:{word:8},borderRightWidth:{word:9},borderBottomWidth:{word:10},borderLeftWidth:{word:11},color:{bit:12,word:16},backgroundColor:{word:17},borderTopColor:{word:19},borderRightColor:{word:20},borderBottomColor:{word:21},borderLeftColor:{word:22},placeholderColor:{bit:19,word:23},tintColor:{bit:21,word:25},overlayColor:{bit:23,word:27},backgroundImage:{word:28},backgroundSize:{word:29},backgroundGradient:{word:30},borderTopLeftRadius:{word:32},borderTopRightRadius:{word:33},borderBottomRightRadius:{word:34},borderBottomLeftRadius:{word:35},opacity:{word:36},transform:{word:37},transformOrigin:{word:50},fontSize:{word:55},fontWeight:{word:56},fontStyle:{word:57},fontFamily:{bit:39,word:58},lineHeight:{word:59},letterSpacing:{word:60},textAlign:{word:61},textDecoration:{word:62},lineClamp:{word:63},textOverflow:{word:64},textWrap:{word:65},objectFit:{word:66},placeholder:{word:67},type:{word:68},dim:{word:82}},ms={hidden:1},ys={horizontal:1},ws={italic:1},at={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],textWrap:["wrap","nowrap","balance","pretty"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},bs=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,vs=["farthest-corner","closest-side","closest-corner","farthest-side"],xs=52;function Es(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Ss(n,t,e+i*xs));return r}function Ss(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],l=[];for(let c=0;c<o;c++){const h=a+c*8>>2;l.push({color:t[h]>>>0,position:n[h+1]})}if(i===1){const c=t[s+6],h={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:l};return c===4?{...h,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...h,extent:vs[c]??"farthest-corner"}}return{type:"linear",angle:r,stops:l}}const k=gs,_s=["start","center","end","start","end"];let At=0;function xn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],l=I=>bs(o,a,I),c=I=>{const F=s[i+I];return F===0?void 0:n.UTF8ToString(n._cuiStringOf(F))};e.backgroundColor=s[i+k.backgroundColor.word]>>>0,e.opacity=r[i+k.opacity.word],e.dim=r[i+k.dim.word],e.display=at.display[s[i+k.display.word]],e.overflow=s[i+k.overflow.word]===ms.hidden?"hidden":"visible",e.scrollAxis=s[i+k.scrollDirection.word]===ys.horizontal?"x":"y",e.border={top:{width:r[i+k.borderTopWidth.word],color:s[i+k.borderTopColor.word]>>>0},right:{width:r[i+k.borderRightWidth.word],color:s[i+k.borderRightColor.word]>>>0},bottom:{width:r[i+k.borderBottomWidth.word],color:s[i+k.borderBottomColor.word]>>>0},left:{width:r[i+k.borderLeftWidth.word],color:s[i+k.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+k.borderTopLeftRadius.word],tr:r[i+k.borderTopRightRadius.word],br:r[i+k.borderBottomRightRadius.word],bl:r[i+k.borderBottomLeftRadius.word]},e.backgroundImage=c(k.backgroundImage.word),e.backgroundSize=at.backgroundSize[s[i+k.backgroundSize.word]];const h=s[i+k.backgroundGradient.word];if(h===0)e.backgroundGradients=void 0;else{At===0&&(At=n._malloc(4));const I=n._cuiGradientOf(h,At),F=n.HEAPU32[At>>>2];e.backgroundGradients=I!==0&&F>0?Es(n.HEAPF32,n.HEAPU32,I,F):void 0}const u=i+k.transform.word,f=r[u],d=r[u+1],p=r[u+3],y=r[u+4],b=r[u+6],x=r[u+7],m=r[u+9],v=r[u+10],_=r[u+11],T=r[u+12],P=m===0&&v===0&&_===0&&T===0;e.transform=f===1&&d===0&&p===0&&y===1&&b===0&&x===0&&P?void 0:[f,d,p,y,b,x],e.transformBox=P?void 0:[m,v,_,T];const O=i+k.transformOrigin.word;e.transformOrigin={x:r[O],y:r[O+1],xPercent:s[O+2]!==0,yPercent:s[O+3]!==0},e.color=l(k.color.bit)?s[i+k.color.word]>>>0:void 0,e.fontFamily=l(k.fontFamily.bit)?c(k.fontFamily.word):void 0,e.fontSize=r[i+k.fontSize.word],e.fontWeight=r[i+k.fontWeight.word],e.fontStyle=s[i+k.fontStyle.word]===ws.italic?"italic":"normal",e.lineHeight=r[i+k.lineHeight.word],e.letterSpacing=r[i+k.letterSpacing.word],e.textAlign=_s[s[i+k.textAlign.word]]??"start",e.textDecoration=at.textDecoration[s[i+k.textDecoration.word]],e.lineClamp=r[i+k.lineClamp.word],e.textOverflow=at.textOverflow[s[i+k.textOverflow.word]],e.textWrap=at.textWrap[s[i+k.textWrap.word]],e.objectFit=at.objectFit[s[i+k.objectFit.word]],e.tintColor=l(k.tintColor.bit)?s[i+k.tintColor.word]>>>0:void 0,e.placeholder=c(k.placeholder.word),e.placeholderColor=l(k.placeholderColor.bit)?s[i+k.placeholderColor.word]>>>0:void 0,e.inputType=at.type[s[i+k.type.word]],e.overlayColor=l(k.overlayColor.bit)?s[i+k.overlayColor.word]>>>0:void 0}function ks(n,t){const e=n._cuiPaintOf(t);if(e===0)return!1;const s=e>>>2;return n.HEAPU32[s+2]!==0||n.HEAPU32[s+3]!==0}function Rs(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(xn(n,s,e),!0)}function Ts(n,t){const e=n._paintCollect();if(e===0)return 0;const s=n._paintNodes()>>>2,r=n._paintRecords();for(let i=0;i<e;i++){const o=n.HEAPU32[s+i],a=r+i*ps*4;t(o,l=>xn(n,a,l))}return e}function En(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?ae(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>ae(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function As(n,t=[],e){return JSON.stringify(En(n,t,e),null,2)}function gt(n,t){const e=10**t;return Math.round(n*e)/e}function ae(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),n.view&&(r.view=n.view.name),r.rect=[gt(s.x,t),gt(s.y,t),gt(s.width,t),gt(s.height,t)],e&&(r.id=n.id);const i=Ls(n.style);return i&&(r.style=i),n.text!==void 0&&(r.text=n.text),n.lines&&(n.lines.length!==1||n.lines[0]!==n.text)&&(r.lines=n.lines),n.value!==void 0&&n.value!==""&&(r.value=n.value),n.style.placeholder!==void 0&&(r.placeholder=n.style.placeholder),n.image&&(r.image={src:n.image.src,natural:[n.image.naturalWidth,n.image.naturalHeight]}),n.sourceRect&&(r.sourceRect=n.sourceRect),n.state&&(n.state.pressed||(o=n.state.classes)!=null&&o.length)&&(r.state={...n.state.pressed?{pressed:!0}:{},...(a=n.state.classes)!=null&&a.length?{classes:n.state.classes}:{}}),n.scroll&&(r.scroll={offset:gt(n.scroll.offset,t),content:gt(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(l=>ae(l,t,e))),r}function Ms(n){return n.tl===n.tr&&n.tr===n.br&&n.br===n.bl?n.tl:[n.tl,n.tr,n.br,n.bl]}function Ls(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=pt(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=pt(n.color)),n.fontSize!==void 0&&(t.fontSize=n.fontSize),n.fontFamily!==void 0&&(t.fontFamily=n.fontFamily),n.fontWeight!==void 0&&(t.fontWeight=n.fontWeight),n.fontStyle!==void 0&&n.fontStyle!=="normal"&&(t.fontStyle=n.fontStyle),n.lineHeight!==void 0&&(t.lineHeight=n.lineHeight),n.letterSpacing&&(t.letterSpacing=n.letterSpacing),n.textAlign!==void 0&&n.textAlign!=="start"&&(t.textAlign=n.textAlign),n.textDecoration!==void 0&&n.textDecoration!=="none"&&(t.textDecoration=n.textDecoration),n.lineClamp&&(t.lineClamp=n.lineClamp,n.textOverflow==="clip"&&(t.textOverflow=n.textOverflow)),n.textWrap!==void 0&&n.textWrap!=="wrap"&&(t.textWrap=n.textWrap),n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=pt(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=pt(n.overlayColor)),n.backgroundImage!==void 0&&(t.backgroundImage=n.backgroundImage),n.backgroundSize!==void 0&&(t.backgroundSize=n.backgroundSize),n.backgroundGradients!==void 0&&n.backgroundGradients.length>0&&(t.backgroundGradients=n.backgroundGradients.map(e=>{const s=e.stops.map(r=>({color:pt(r.color),position:r.position}));if(e.type==="radial"){const r={type:"radial",shape:e.shape,extent:e.extent,cx:e.cx,cy:e.cy,stops:s};return e.extent==="explicit"&&(r.rx=e.rx,r.ry=e.ry,r.rxUnit=e.rxUnit,r.ryUnit=e.ryUnit),r}return{angle:e.angle,stops:s}})),n.borderRadius&&(n.borderRadius.tl||n.borderRadius.tr||n.borderRadius.br||n.borderRadius.bl)&&(t.borderRadius=Ms(n.borderRadius)),n.border){const e={};for(const s of["top","right","bottom","left"]){const r=n.border[s];r&&r.width>0&&(e[s]={width:r.width,color:pt(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const Ps=.32,Cs=4,Os={},Oe=new Map;function ce(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Oe.get(n);return t===void 0&&(t=ln(n.slice(4)),Oe.set(n,t)),t}return n}class Is{constructor(t,e){w(this,"parent",null);w(this,"children",[]);w(this,"style",{lineHeight:14*1.2});w(this,"name");w(this,"text","");w(this,"src");w(this,"value","");w(this,"sourceRect");w(this,"viewName");w(this,"viewParams");w(this,"playerId",0);w(this,"viewId",0);w(this,"flags",0);w(this,"layoutRect",null);w(this,"scrollOffset",0);w(this,"wrapCache");w(this,"jsNode");w(this,"bgRaw");w(this,"bgSrc");this.id=t,this.type=e,this.jsNode={type:e,_id:t}}get measured(){return this.type==="text"||this.type==="image"||this.editable}get editable(){return this.type==="input"||this.type==="textarea"}get scrollable(){return this.type==="scrollable"||this.type==="scrollableScreen"||this.type==="vlist"}get scrollAxis(){return this.style.scrollAxis==="x"?"x":"y"}get interactive(){return(this.flags&Wr)!==0}get imageSrcRaw(){return this.type==="image"?ce(this.src):void 0}has(t){return(this.flags&t)!==0}}class Fs{constructor(t,e,s={}){w(this,"nodes",new Map);w(this,"root",null);w(this,"leaving",null);w(this,"leavingAbove",!1);w(this,"pagerShown",new Map);w(this,"pagerLeaving",new Map);w(this,"destKind",-1);w(this,"layerRoots",[]);w(this,"width",0);w(this,"height",0);w(this,"focused",null);w(this,"safeBottom",0);w(this,"shrunkRoot",0);w(this,"shrunkInset",0);w(this,"pressed",new Set);w(this,"gestures",new Map);w(this,"vlists",new Set);w(this,"frameCache",null);w(this,"painted",null);w(this,"fontsPending",0);w(this,"lastToast",null);w(this,"dirty",!0);w(this,"onDestination",null);w(this,"onDropped",null);w(this,"placeholders");w(this,"viewNames",new Map);w(this,"nativeDest",null);w(this,"layoutPtr",0);w(this,"padPtr",0);w(this,"lastCreated",0);w(this,"hoverX",0);w(this,"hoverY",0);w(this,"hoverInside",!1);w(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s,this.placeholders=new Map(Object.entries(s.nativeViews??{}))}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,l)=>{const c=this.measure(r,i,a);return t.setFloat32(4,c.width,!0),t.setFloat32(0,c.height,!0),t.getBigUint64(0,!0)};this.M._setMeasureFunc(this.M.addFunction(e,"jiififi"))}measure(t,e,s){const r=this.nodes.get(t);if(!r)return{width:0,height:0};const i=this.M;ks(i,t)&&(Rs(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?es(o,this.host,e):r.type==="image"?rs(o,this.host,e,s):r.editable?ns(o,this.host,e):{width:0,height:0}}resize(t,e){this.width=t,this.height=e,this.M._creatorWebResize(t,e),this.M._setConditionValue(t,e),this.dirty=!0}setSafeArea(t,e=[]){const[s,r,i,o]=t??(this.width>this.height?[0,8,0,20]:[20,0,8,0]),a={top:1,right:2,bottom:4,left:8};this.M._setSafeAreaBars(e.reduce((l,c)=>l|a[c],0)),this.M._setSafePaddings(s,r,i,o,0),this.safeBottom=i,this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&(this.shrunkInset=Math.max(0,i-this.keyboardHeight()),this.M._overrideRootSafeBottom(this.shrunkRoot,this.shrunkInset)),this.dirty=!0}layoutFrame(){const t=this.M;Ts(t,(r,i)=>{const o=this.nodes.get(r);o&&(i(o.style),this.resolveBackground(o))})>0&&(this.dirty=!0);const s=t._creatorWebLayoutFrame(this.width,this.height);s>0&&this.readLayoutBatch(s);for(const r of this.vlists)if(t._vlistExists(r.id)){t._vlistUpdateLayout(r.id);for(const i of r.children)this.deliverSubtree(i)}}needsPaint(){return this.dirty||this.frameCache===null||this.frameCache!==this.painted}deliverSubtree(t){const e=this.M;if(this.layoutPtr||(this.layoutPtr=e._malloc(16)),e._getLayoutPointer(t.id,this.layoutPtr)){const s=this.layoutPtr>>2,r={x:e.HEAPF32[s],y:e.HEAPF32[s+1],width:e.HEAPF32[s+2],height:e.HEAPF32[s+3]},i=t.layoutRect,o=!i||i.x!==r.x||i.y!==r.y||i.width!==r.width||i.height!==r.height;t.layoutRect=r,o&&(this.dirty=!0),o&&t.has(Me)&&e._creatorWebNodeLayout(t.id,r.x,r.y,r.width,r.height)}for(const s of t.children)this.deliverSubtree(s)}readLayoutBatch(t){const e=this.M,s=e._collectNodes()>>>2,r=e._collectRects()>>>2,i=e.HEAPU32,o=e.HEAPF32;for(let a=0;a<t;a++){const l=i[s+a],c=this.nodes.get(l);if(!c)continue;const h=o[r+a*4],u=o[r+a*4+1],f=o[r+a*4+2],d=o[r+a*4+3],p={x:h,y:u,width:f-h,height:d-u},y=c.layoutRect,b=!y||y.x!==p.x||y.y!==p.y||y.width!==p.width||y.height!==p.height;c.layoutRect=p,b&&(this.dirty=!0),b&&c.has(Me)&&e._creatorWebNodeLayout(l,h,u,p.width,p.height)}}frame(){if(this.frameCache&&!this.dirty)return this.frameCache;const t=[],e={x:0,y:0,width:this.width,height:this.height},s=this.nativeDest;if(s){const i={id:0,type:"native",rect:e,style:Os,children:[],view:{name:s.view,label:this.placeholders.get(s.view)}};s.name&&(i.name=s.name),t.push(this.destKind===ct?{tree:i}:{tree:i,leaving:!0})}const r=this.leaving?this.build(this.leaving,e):null;if(r&&!this.leavingAbove&&t.push({tree:r,leaving:!0}),this.root){const i=this.build(this.root,e);i&&t.push({tree:i})}r&&this.leavingAbove&&t.push({tree:r,leaving:!0});for(const i of this.layerRoots){const o=this.build(i,e);o&&t.push({tree:o,widget:!0})}return this.frameCache=t,this.dirty=!1,t}renderTree(){var t;return((t=this.frame().find(e=>!e.widget&&!e.leaving))==null?void 0:t.tree)??null}widgetTrees(){return this.frame().filter(t=>t.widget).map(t=>t.tree)}widgets(){return this.widgetTrees()}serialize(){return En(this.renderTree(),this.widgetTrees())}toText(){return As(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();ss(s,t,this.host,this.width,this.height,void 0,e),this.painted=s}build(t,e){const s=this.M,r=(i,o,a,l)=>{var x;if(i.style.display==="none")return null;let c,h,u,f;if(l)c=e.x,h=e.y,u=e.width,f=e.height;else{const m=i.layoutRect;if(!m)return null;c=o+m.x,h=a+m.y,u=m.width,f=m.height}const d={id:i.id,type:i.type,rect:{x:c,y:h,width:u,height:f},style:i.style,children:[]};i.name&&(d.name=i.name);const p=i;if(i.type==="text"){const m=ie(p),v=mn(m);d.text=i.text;const _=this.padding(i.id);(_[0]||_[1]||_[2]||_[3])&&(d.padding=_);const T=u-_[0]-_[2],P=`${T}|${v.size}|${v.weight}|${v.italic?1:0}|${v.letterSpacing}|${v.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.style.textWrap??""}|${i.text}`;if(((x=i.wrapCache)==null?void 0:x.key)===P)d.lines=i.wrapCache.lines;else{const O=F=>this.host.measureText(F,v),I=yn(i.text,i.style,T,O,!0);i.wrapCache={key:P,lines:I},d.lines=I}d.style={...i.style,color:m.color,fontSize:m.fontSize,fontFamily:m.fontFamily,fontWeight:m.fontWeight,fontStyle:m.fontStyle,lineHeight:m.lineHeight,letterSpacing:m.letterSpacing,textAlign:m.textAlign,textDecoration:m.textDecoration}}else if(i.type==="image"){const m=this.host.resolveSrc(i.imageSrcRaw),v=m?this.host.getImage(m):void 0;d.image=v??(m?{src:m,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(d.sourceRect=i.sourceRect)}else if(i.editable){d.value=i.value;const m=this.padding(i.id);(m[0]||m[1]||m[2]||m[3])&&(d.padding=m);const v=ie(p);d.style={...i.style,color:v.color,fontSize:v.fontSize,fontFamily:v.fontFamily,fontWeight:v.fontWeight,fontStyle:v.fontStyle,lineHeight:v.lineHeight,letterSpacing:v.letterSpacing,textAlign:v.textAlign,textDecoration:v.textDecoration}}else if(i.type==="native"){const m=i.viewName??"";d.view={name:m,label:this.placeholders.get(m)}}i.type==="widget"&&i.style.overlayColor!==void 0&&(d.overlay=i.style.overlayColor),i.interactive&&(d.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(d.state={...d.state,focused:!0}),i.style.overflow==="hidden"&&(d.clip=!0);let y=c,b=h;if(i.scrollable){const m=i.scrollAxis,v=m==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);d.clip=!0,d.scroll={offset:i.scrollOffset,content:v,axis:m},m==="x"?y=c-i.scrollOffset:b=h-i.scrollOffset}if(i.type==="pager"){const m=s._creatorWebPagerSelectedIndex(i.id),v=s._creatorWebPagerStackLen(i.id,m),_=v>0?s._creatorWebPagerPageNode(i.id,m,v-1):0,T=_?this.nodes.get(_):void 0;T?this.pagerShown.set(i.id,T):this.pagerShown.delete(i.id);const P=this.pagerLeaving.get(i.id);for(const O of P&&P.page!==T?P.above?[T,P.page]:[P.page,T]:[T]){const I=O?r(O,c,h,!1):null;I&&d.children.push(I)}return d}if(i.type==="vlist"){for(const m of i.children){const v=s._getParentNode(m.id);if(!v)continue;const _=s._vlistItemOffsetOf(i.id,v);if(Number.isNaN(_))continue;const T=r(m,c,h+_-i.scrollOffset,!1);T&&d.children.push(T)}return d}for(const m of i.children){const v=r(m,y,b,!1);v&&d.children.push(v)}return d};return r(t,0,0,!0)}paddingOf(t){return this.padding(t)}padding(t){const e=this.M;this.padPtr||(this.padPtr=e._malloc(16)),e._getPaddingPointer(t,this.padPtr);const s=this.padPtr>>2;return[e.HEAPF32[s],e.HEAPF32[s+1],e.HEAPF32[s+2],e.HEAPF32[s+3]]}withStr(t,e){const s=this.M.stringToNewUTF8(t);try{return e(s)}finally{this.M._free(s)}}get(t){return this.nodes.get(t)}findAll(t){const e=[],s=r=>{r.name===t&&e.push(r);for(const i of r.children)s(i)};for(const r of this.frame())s(r.tree);return e}findRect(t){const e=s=>{if(s.id===t)return s.rect;for(const r of s.children){const i=e(r);if(i)return i}return null};for(const s of this.frame()){const r=e(s.tree);if(r)return r}return null}toast(){return this.lastToast}pendingFonts(){return this.fontsPending}keyboardHeight(){return this.focused?this.options.keyboardHeight?this.options.keyboardHeight():Math.round(this.height*Ps):0}focusedId(){var t;return((t=this.focused)==null?void 0:t.id)??0}nodeFactory(t,e,s,r){this.lastCreated=t;const i=new Is(t,e);this.nodes.set(t,i),e==="vlist"&&this.vlists.add(i);const o=this.nodes.get(s);o&&this.link(o,i,Math.max(0,r)),this.dirty=!0}link(t,e,s){e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),e.parent=t,t.children.splice(Math.min(s,t.children.length),0,e)}insertNode(t,e,s){const r=this.nodes.get(t),i=this.nodes.get(e);r&&i&&this.link(r,i,s),this.dirty=!0}removeNode(t,e){var i;const s=this.nodes.get(t),r=this.nodes.get(e);!s||!r||(this.forget(r),s.children=s.children.filter(o=>o!==r),r.parent===s&&(r.parent=null),((i=this.pagerLeaving.get(t))==null?void 0:i.page)===r&&this.pagerLeaving.delete(t),this.pagerShown.get(t)===r&&this.pagerShown.delete(t),this.dirty=!0)}releaseNode(t){const e=this.nodes.get(t);if(!e)return;this.nodes.delete(t),this.forget(e),e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),this.root===e&&(this.root=null),this.leaving===e&&(this.leaving=null),this.pagerShown.delete(t),this.pagerLeaving.delete(t);for(const[r,i]of this.pagerLeaving)i.page===e&&this.pagerLeaving.delete(r);this.focused===e&&(this.focused=null,this.shrinkTo(0,0),this.emitKeyboard());const s=this.layerRoots.indexOf(e);s>=0&&this.layerRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),e.type==="native"&&e.viewId&&this.viewNames.delete(e.viewId),this.dirty=!0}forget(t){for(const e of this.gestures.values())e.node===t&&(e.node=null),e.scroll===t&&(e.scroll=null),e.backdrop===t&&(e.backdrop=null),e.edit===t&&(e.edit=null);for(const e of t.children)this.forget(e)}setPropertyString(t,e,s){const r=this.nodes.get(t);if(!r)return;const i=s??"";switch(e){case"text":r.text=i,r.wrapCache=void 0;break;case"value":r.value=i;break;case"name":r.name=i||void 0;break;case"src":{r.src=i||void 0;const o=this.host.resolveSrc(this.srcOf(r));o&&!this.host.getImage(o)&&this.host.loadImage(o).then(()=>{this.nodes.get(t)===r&&this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0}).catch(()=>{});break}case"sourceRect":{const o=i.split(" ").map(Number);r.sourceRect=o.length===4?[o[0],o[1],o[2],o[3]]:void 0;break}case"focus":i==="1"||i==="true"?this.focusInput(t):this.focused===r&&this.blurInput();break;case"viewName":r.viewName=i;break;case"viewParams":r.viewParams=i;break}this.dirty=!0}srcOf(t){return ce(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(ce(e)):void 0;const s=t.bgSrc;s&&!this.host.getImage(s)&&this.host.loadImage(s).then(()=>{this.dirty=!0}).catch(()=>{})}t.style.backgroundImage=t.bgSrc}setPropertyInt(t,e,s){const r=this.nodes.get(t);r&&(e==="playerId"?r.playerId=s:e==="viewId"&&(r.viewId=s,r.viewName!==void 0&&this.viewNames.set(s,r.viewName))),this.dirty=!0}setFlags(t,e){const s=this.nodes.get(t);s&&(s.flags=e>>>0)}leave(t){this.root&&(this.leaving=this.root,this.leavingAbove=t,this.root=null)}openView(t,e,s,r,i,o){var l;this.destKind=t;const a=t===Le?this.nodes.get(e)??null:null;if(a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,t===ct){this.viewNames.set(s,r);let c;for(const h of this.nodes.values())if(h.type==="native"&&h.viewId===s){c=h.name;break}this.nativeDest=this.placeholders.has(r)?{id:s,view:r,name:c}:null}this.focused&&this.blurInput(),this.dirty=!0,(l=this.onDestination)==null||l.call(this,t,s)}dropView(t,e,s){var r,i;if(t===Le){const o=this.nodes.get(e)??null;o!==null&&this.leaving===o&&(this.leaving=null),o!==null&&this.root===o&&(this.root=null)}t===ct&&((r=this.nativeDest)==null?void 0:r.id)===s&&this.destKind!==ct&&(this.nativeDest=null),this.dirty=!0,(i=this.onDropped)==null||i.call(this,t,s)}closeView(){var t;this.destKind=-1,this.leave(!0),this.dirty=!0,(t=this.onDestination)==null||t.call(this,-1,0)}isViewSupported(t){return this.placeholders.has(t)}viewVersion(t){return this.placeholders.has(t)?1:0}viewCall(t,e,s,r,i){const o=this.viewNames.get(t);i(o!==void 0&&this.placeholders.has(o)?`headless draws native views only: ${o}.${e}`:"NativeView calls are not supported on this host")}layerOpen(t){const e=this.nodes.get(t);e&&!this.layerRoots.includes(e)&&this.layerRoots.push(e),this.dirty=!0}layerClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.layerRoots.indexOf(e):-1;s>=0&&this.layerRoots.splice(s,1),this.dirty=!0}registerFont(t,e,s,r,i,o){this.fontsPending++,this.host.loadFont(e,t,{weight:s,style:r===2?"italic":"normal"}).then(()=>{this.invalidateText(),i()},a=>o(String(a))).finally(()=>{this.fontsPending--})}invalidateText(){for(const t of this.nodes.values())t.wrapCache=void 0,t.measured&&t.type!=="image"&&this.M._nodeHasMeasure(t.id)&&this.M._markNodeDirty(t.id);this.dirty=!0}showToast(t,e){var s,r;this.lastToast=t,(r=(s=this.options).onToast)==null||r.call(s,t,e)}getButtonPressed(t){return this.pressed.has(t)}getTextValue(t){var e;return((e=this.nodes.get(t))==null?void 0:e.value)??""}getBoundingRect(t){const e=this.findRect(t);return e?[e.x,e.y,e.width,e.height]:null}longPressHandler(t,e){const s=this.gestures.get(t);s&&(s.swallowClick=!0)}vlistScroll(t,e,s){const r=this.nodes.get(t);r&&(r.scrollOffset=e),this.dirty=!0}pagerCommand(t,e,s){this.pagerLeaving.delete(t),this.dirty=!0}pagerShowPage(t,e,s){const r=this.nodes.get(e),i=this.pagerShown.get(t);r&&this.pagerShown.set(t,r),i&&i!==r&&this.pagerLeaving.set(t,{page:i,above:!s}),this.dirty=!0}pagerDropPage(t,e){var s;((s=this.pagerLeaving.get(t))==null?void 0:s.page.id)===e&&this.pagerLeaving.delete(t),this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent&&e.type!=="widget";)e=e.parent;return e}emitKeyboard(){var s,r;const t=this.keyboardHeight(),e=this.keyboardDuration();(r=(s=this.options).onKeyboard)==null||r.call(s,t,e),this.M._creatorWebKeyboardEvent(t,e)}shrinkTo(t,e){this.M._creatorWebSetShrunkRoot(t,e);const s=e>0?t:0;s!==this.shrunkRoot&&(this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&this.M._overrideRootSafeBottom(this.shrunkRoot,this.safeBottom),this.shrunkRoot=s,this.shrunkInset=this.safeBottom);const r=Math.max(0,this.safeBottom-e);s&&r!==this.shrunkInset&&this.nodes.has(s)&&(this.M._overrideRootSafeBottom(s,r),this.shrunkInset=r)}keyboardDuration(){return 0}refreshKeyboard(){this.focused&&(this.shrinkTo(this.rootOf(this.focused).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}focusInput(t){const e=this.nodes.get(t);!e||!e.editable||this.focused===e||(this.focused&&this.blurInput(),this.focused=e,this.M._setNodeFocused(t,1),e.has(zr)&&this.M._creatorWebNodeEvent(t,Fr),this.shrinkTo(this.rootOf(e).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}blurInput(){const t=this.focused;t&&(this.focused=null,this.M._setNodeFocused(t.id,0),t.has(Kr)&&this.M._creatorWebNodeEvent(t.id,Nr),this.shrinkTo(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(jr)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Ir,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Xr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Ur,e)),this.focused===t&&this.blurInput(),!0):!1}scrollMax(t){const e=this.findRect(t.id)??t.layoutRect??{width:0,height:0},s=t.scrollAxis==="x"?e.width:e.height,r=t.scrollAxis==="x"?this.M._getContentWidth(t.id):this.M._getContentHeight(t.id);return Math.max(0,r-s)}scrollBy(t,e){const s=this.nodes.get(t);if(!s||!s.scrollable)return!1;const r=this.scrollMax(s),i=s.scrollOffset+e,o=Math.min(r,Math.max(0,i)),a=i<0?i:i>r?i-r:0;return a!==0&&s.has(Vr)&&this.M._creatorWebNodeEventNum(t,Cr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has($r)&&this.M._creatorWebNodeScroll(t,o),this.dirty=!0,!0)}topInteractive(t,e){const s=this.frame();for(let r=s.length-1;r>=0;r--){const i=yt(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i.node)return this.nodes.get(i.node.id)??null;if(i.blocker)return null}return null}setPressed(t,e){e?this.pressed.add(t.id):this.pressed.delete(t.id),this.nodes.get(t.id)===t&&this.M._setNodePressed(t.id,e?1:0),this.dirty=!0}pointerHover(t,e){this.hoverX=t,this.hoverY=e,this.hoverInside=!0,this.hoverMoved=!0}pointerLeave(){this.hoverInside&&(this.hoverInside=!1,this.hoverMoved=!0)}get hasHover(){return typeof this.M._creatorWebHover=="function"}tickHover(){if(!this.hasHover||!this.hoverMoved&&!this.dirty)return;this.hoverMoved=!1;const t=this.hoverInside?this.topInteractive(this.hoverX,this.hoverY):null;this.M._creatorWebHover((t==null?void 0:t.id)??0,this.hoverX,this.hoverY)}pointerDown(t,e,s){const r=this.M;r._creatorWeb2dSceneOpen()&&r._creatorWeb2dEmitPointer(0,t,e,s);const i={node:null,scroll:null,backdrop:null,edit:null,global:!1,dismiss:!0,lastX:e,lastY:s,acc:0,scrolling:!1,swallowClick:!1};this.gestures.set(t,i);const o=this.frame();for(let a=o.length-1;a>=0;a--){const l=yt(o[a].tree,e,s,c=>{var h;return((h=this.nodes.get(c.id))==null?void 0:h.editable)??!1});if(l.node){const c=this.nodes.get(l.node.id);this.focusInput(c.id),i.edit=c,i.dismiss=!1;return}if(l.blocker)break}for(let a=o.length-1;a>=0;a--){const l=o[a],c=yt(l.tree,e,s,f=>{var d;return((d=this.nodes.get(f.id))==null?void 0:d.interactive)??!1}),h=yt(l.tree,e,s,f=>!!f.scroll&&f.scroll.content>(f.scroll.axis==="x"?f.rect.width:f.rect.height)+.5),u=h.node?this.nodes.get(h.node.id)??null:null;if(c.node){const f=this.nodes.get(c.node.id);i.node=f,i.scroll=u,i.dismiss=f.type!=="button",this.setPressed(f,!0),r._creatorWebNodeTouchStart(f.id,t,e,s);return}if(u){i.scroll=u;return}if(c.blocker){i.backdrop=c.outside?this.nodes.get(c.blocker.id)??null:null;return}}i.global=!0,r._creatorWebSceneTouchStart(t,e,s)}pointerMove(t,e,s){const r=this.gestures.get(t);if(!r)return;const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(1,t,e,s);const o=e-r.lastX,a=s-r.lastY;if(r.lastX=e,r.lastY=s,r.acc+=Math.abs(o)+Math.abs(a),!r.edit){if(!r.scrolling&&r.scroll&&r.acc>Cs&&(r.scrolling=!0,r.node&&this.setPressed(r.node,!1)),r.scrolling&&r.scroll){this.scrollBy(r.scroll.id,r.scroll.scrollAxis==="x"?-o:-a);return}i._creatorWebTouchMove(t,e,s,o,a)}}pointerUp(t,e,s){const r=this.gestures.get(t);if(!r)return;this.gestures.delete(t);const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(2,t,e,s);const o=e-r.lastX,a=s-r.lastY;i._creatorWebTouchEnd(t,e,s,o,a),!r.edit&&(r.scrolling&&r.scroll&&r.scroll.has(Gr)&&i._creatorWebNodeEvent(r.scroll.id,Or),r.dismiss&&!r.scrolling&&this.focused&&this.blurInput(),r.node?(this.setPressed(r.node,!1),!r.scrolling&&!r.swallowClick&&this.topInteractive(e,s)===r.node&&r.node.has(Dr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Yr)&&i._creatorWebNodeEvent(r.backdrop.id,Br):r.global&&(r.scrolling||i._creatorWebSceneTouchClick(t,e,s)))}pointerCancel(t){const e=this.gestures.get(t);if(!e)return;this.gestures.delete(t);const s=this.M;s._creatorWeb2dSceneOpen()&&s._creatorWeb2dEmitPointer(3,t,e.lastX,e.lastY),e.node&&this.setPressed(e.node,!1),s._creatorWebTouchCancel(t)}wheel(t,e,s,r){const i=this.frame();for(let o=i.length-1;o>=0;o--){const a=yt(i[o].tree,t,e,l=>!!l.scroll&&l.scroll.content>(l.scroll.axis==="x"?l.rect.width:l.rect.height)+.5);if(a.node){const l=this.nodes.get(a.node.id);return l?this.scrollBy(l.id,l.scrollAxis==="x"?s:r):!1}if(a.blocker)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(Hr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const Ns=`
11
11
  .lc-field { position: absolute; left: 0; top: 0; margin: 0; border: none; outline: none; background: none; resize: none; box-sizing: border-box; transform-origin: 0 0; pointer-events: auto; overflow: hidden; -webkit-appearance: none; appearance: none; }
12
12
  .lc-field::placeholder { color: var(--lc-placeholder, #999); opacity: 1; }
13
- `,Ce=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),Rs=n=>n.type==="native"||n.type==="video",As=[1,0,0,1,0,0],Gt=(n,t)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]],Ms=(n,t)=>{if(!n)return t;const e=Math.max(n.x,t.x),s=Math.max(n.y,t.y);return{x:e,y:s,width:Math.max(0,Math.min(n.x+n.width,t.x+t.width)-e),height:Math.max(0,Math.min(n.y+n.height,t.y+t.height)-s)}};class Lt extends _s{constructor(e,s,r,i,o={}){super(e,s,o);m(this,"doc");m(this,"factories",new Map);m(this,"versions",new Map);m(this,"views",new Map);m(this,"wrappers",new Map);m(this,"shown",new Map);m(this,"destination",null);m(this,"field",null);m(this,"placedFor",null);m(this,"band",{root:0,height:0});m(this,"slide",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=Ts,i.appendChild(a)}paintOptions(){var e;return{surfaces:!0,editing:(e=this.field)==null?void 0:e.id}}registerView(e,s,r=1){this.factories.set(e,s),this.versions.set(e,r)}unregisterView(e){this.factories.delete(e),this.versions.delete(e)}isViewSupported(e){return this.factories.has(e)}viewVersion(e){return this.versions.get(e)??0}ensureView(e,s,r){const i=this.views.get(e);if(i&&(i.name!==s||i.params!==r))this.destroyView(e);else if(i)return i.handle;const o=this.factories.get(s);if(!o)return null;let a={};try{a=r?JSON.parse(r):{}}catch{}const h=o(a,{emit:(l,c)=>this.M.jsb.viewEvent(e,l,c)},this.doc);return h.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:h}),h}destroyView(e){var r,i;const s=this.views.get(e);s&&(this.views.delete(e),(i=(r=s.handle).destroy)==null||i.call(r),s.handle.el.remove())}viewCall(e,s,r,i,o){const a=this.views.get(e);if(!(a!=null&&a.handle.call)){o(`NativeView call "${s}": no live instance or no call handler (viewId ${e})`);return}try{Promise.resolve(a.handle.call(s,Array.isArray(r)?r:[])).then(h=>{h===void 0?i():i(h)},h=>o(h instanceof Error?h.message:String(h)))}catch(h){o(h instanceof Error?h.message:String(h))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==Ht)return;this.dropDestination();const h=this.ensureView(r,i,o);if(!h)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(h.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===Ht&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==Ht&&this.dropDestination()}dropDestination(){var e;(e=this.destination)==null||e.el.remove(),this.destination=null}releaseNode(e){var r,i;const s=this.get(e);((r=this.field)==null?void 0:r.id)===e&&this.unmountField(),super.releaseNode(e),(i=this.shown.get(e))==null||i.remove(),this.shown.delete(e),this.wrappers.delete(e),(s==null?void 0:s.type)==="native"&&s.viewId&&this.destroyView(s.viewId)}keyboardDuration(){return ge}shrinkTo(e,s){const r=this.doc.defaultView;if(!r){super.shrinkTo(e,s);return}this.slide&&(r.cancelAnimationFrame(this.slide.raf),this.slide=null);const i=s>0?e:this.band.root,o=this.band.height;if(o===s||i===0||!this.nodes.has(i)){this.setBand(i,s);return}const a=r.performance.now(),h=()=>{const l=Math.min(1,(r.performance.now()-a)/ge),c=On(l);this.setBand(i,l<1?Math.round(o+(s-o)*c):s),l<1?this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(h)}:this.slide=null};this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(h)}}setBand(e,s){this.band=s>0?{root:e,height:s}:{root:0,height:0},super.shrinkTo(this.band.root,this.band.height),this.dirty=!0}focusInput(e){var i;if(super.focusInput(e),this.focusedId()!==e||((i=this.field)==null?void 0:i.id)===e)return;this.unmountField();const s=this.get(e);if(!s)return;const r=this.doc.createElement(s.type==="textarea"?"textarea":"input");r.className="lc-field",r.setAttribute("autocomplete","off"),r.value=s.value,r.addEventListener("input",()=>{this.focusedId()===e&&this.setInputValue(e,r.value)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&r.tagName==="INPUT"&&(o.preventDefault(),this.submitInput())}),r.addEventListener("blur",()=>{var o;((o=this.field)==null?void 0:o.el)===r&&this.focusedId()===e&&this.blurInput()}),this.over.appendChild(r),this.field={id:e,el:r},this.placedFor=null,this.place(),r.focus({preventScroll:!0})}blurInput(){super.blurInput(),this.unmountField()}unmountField(){const e=this.field;e&&(this.field=null,e.el.remove(),this.placedFor=null)}setPropertyString(e,s,r){var i,o;if(super.setPropertyString(e,s,r),s==="value"&&((i=this.field)==null?void 0:i.id)===e){const a=((o=this.get(e))==null?void 0:o.value)??"";this.field.el.value!==a&&(this.field.el.value=a)}}find(){var i;const e=[],s=(i=this.field)==null?void 0:i.id,r=(o,a,h)=>{let l=a;const c=o.style.transform;if(c){const u=o.style.transformOrigin,f=o.rect.x+(u?u.xPercent?o.rect.width*u.x/100:u.x:o.rect.width/2),p=o.rect.y+(u?u.yPercent?o.rect.height*u.y/100:u.y:o.rect.height/2),b=pn(c,o.style.transformBox,o.rect.width,o.rect.height);l=Gt(Gt(Gt(a,[1,0,0,1,f,p]),b),[1,0,0,1,-f,-p])}(Rs(o)||o.id===s)&&e.push({node:o,matrix:l,clip:h});const d=o.clip?Ms(h,o.rect):h;for(const u of o.children)r(u,l,d)};for(const o of this.frame())r(o.tree,As,null);return e}static put(e,s){const{rect:r}=s.node,i=e.style;i.position="absolute",i.left="0",i.top="0",i.width=r.width+"px",i.height=r.height+"px",i.transformOrigin="0 0",i.transform=`matrix(${s.matrix.join(",")}) translate(${r.x}px,${r.y}px)`;const o=s.clip;i.clipPath=o?`inset(${Math.max(0,o.y-r.y)}px ${Math.max(0,r.x+r.width-(o.x+o.width))}px ${Math.max(0,r.y+r.height-(o.y+o.height))}px ${Math.max(0,o.x-r.x)}px)`:""}surfaceElement(e){const s=this.get(e.id);if(!s)return null;if(s.type==="video"){const o=de(s.playerId);return o instanceof HTMLVideoElement?o:null}if(!s.viewId)return null;const r=this.ensureView(s.viewId,s.viewName??"",s.viewParams??"");if(!r)return null;let i=this.wrappers.get(s.id);return i||(i=this.doc.createElement("div"),this.wrappers.set(s.id,i)),r.el.parentElement!==i&&i.replaceChildren(r.el),i}styleField(e,s){var d,u;const r=s.style,i=e.style,[o,a,h,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${h}px ${l}px ${o}px`,i.color=Ce(r.color,"#000000ff"),i.caretColor=i.color;const c=r.fontFamily??"Roboto";if(i.fontFamily=((u=(d=this.host).resolveFontFamily)==null?void 0:u.call(d,c))??c,i.fontSize=(r.fontSize??14)+"px",i.fontWeight=String(r.fontWeight??400),i.fontStyle=r.fontStyle??"normal",i.letterSpacing=(r.letterSpacing??0)+"px",i.lineHeight=e.tagName==="TEXTAREA"&&r.lineHeight!==void 0?r.lineHeight+"px":"normal",i.textAlign=r.textAlign==="center"?"center":r.textAlign==="end"?"right":"left",i.borderRadius="0",e.placeholder=r.placeholder??"",i.setProperty("--lc-placeholder",Ce(r.placeholderColor,"#999999ff")),e instanceof HTMLInputElement){const f=r.inputType??"text";e.type!==f&&(e.type=f)}}place(){var r;const e=this.frame();if(e===this.placedFor)return;this.placedFor=e;const s=new Set;for(const i of this.find()){const{node:o}=i;if(o.id===((r=this.field)==null?void 0:r.id)){this.styleField(this.field.el,o),Lt.put(this.field.el,i);continue}const a=this.surfaceElement(o);a&&(s.add(o.id),a.parentElement!==this.under&&this.under.appendChild(a),a.style.display="block",a.style.opacity="",a.style.pointerEvents="auto",a instanceof HTMLVideoElement&&(a.style.objectFit=o.style.objectFit??"contain"),Lt.put(a,i),this.shown.set(o.id,a))}for(const[i,o]of this.shown)s.has(i)||(o.style.display="none",this.shown.delete(i))}surfaceAt(e,s){const r=this.frame();for(let i=r.length-1;i>=0;i--){const o=r[i];if(o.leaving)continue;const a=mt(o.tree,e,s,h=>{var l,c;return h.type==="native"||(((l=this.get(h.id))==null?void 0:l.interactive)??!1)||(((c=this.get(h.id))==null?void 0:c.editable)??!1)||!!h.scroll});if(a.node)return a.node.type==="native";if(a.blocker)return!1}return this.destination!==null}dispose(){this.unmountField();for(const e of[...this.views.keys()])this.destroyView(e);this.dropDestination();for(const e of this.shown.values())e instanceof HTMLVideoElement||e.remove();this.shown.clear()}}function Ls(n,t,e,s){const r=n.createElement("div");r.textContent=e,r.style.cssText="position:absolute;left:50%;bottom:48px;transform:translateX(-50%);max-width:80%;padding:10px 16px;border-radius:8px;background:rgba(30,30,30,0.92);color:#fff;font:13px/1.4 system-ui,sans-serif;z-index:30;pointer-events:none;",t.appendChild(r),setTimeout(()=>r.remove(),s>0?s:2e3)}const Ps=500,Oe=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],Cs=(n,t)=>{const e=n.ownerDocument,{canvas:s}=t;s.style.display="block",s.style.pointerEvents="none",n.style.touchAction="none";const r=s.getContext("2d"),i=()=>{const y=e.createElement("div");return y.style.cssText="position:absolute;inset:0;overflow:hidden;pointer-events:none;",y},o=i(),a=i();n.insertBefore(o,s),s.after(a);const h=new fr({resolveAssetUrl:y=>tr(y),canvasSurfaces:t.canvasHost}),l=new Lt(t.M,h,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onKeyboard:t.onKeyboard,onToast:(y,L)=>Ls(e,n,y,L)});let c=1,d=new Te(r,c),u=!0;const f=()=>{(u||l.needsPaint())&&(u=!1,l.paint(d,l.paintOptions())),l.place()},p=(y,L,M)=>{y<=0||L<=0||(M!==c&&(c=M,d=new Te(r,c)),u=!0,l.resize(y,L))},b=y=>{l.setSafeArea([y.top,y.right,y.bottom,y.left],y.bars??[])},g=y=>{const L=n.getBoundingClientRect(),M=ue(n);return[(y.clientX-L.left)/M,(y.clientY-L.top)/M]},x=y=>y.target instanceof Node&&a.contains(y.target),w=y=>y.target instanceof Node&&o.contains(y.target),v=y=>{w(y)&&y.stopPropagation()},k=new Set,A=new Map,P=y=>{const L=A.get(y);L!==void 0&&(clearTimeout(L),A.delete(y))},I=y=>{if(x(y))return;const[L,M]=g(y);if(!l.surfaceAt(L,M)){v(y),k.add(y.pointerId);try{n.setPointerCapture(y.pointerId)}catch{}l.pointerDown(y.pointerId,L,M),P(y.pointerId),A.set(y.pointerId,window.setTimeout(()=>{A.delete(y.pointerId),l.longPress(y.pointerId,L,M)},Ps))}},C=y=>{const[L,M]=g(y);k.has(y.pointerId)&&(v(y),l.pointerMove(y.pointerId,L,M)),y.pointerType==="mouse"&&(x(y)||!k.has(y.pointerId)&&l.surfaceAt(L,M)?l.pointerLeave():l.pointerHover(L,M))},N=y=>{y.pointerType==="mouse"&&l.pointerLeave()},X=y=>{if(!k.delete(y.pointerId))return;v(y),P(y.pointerId);const[L,M]=g(y);l.pointerUp(y.pointerId,L,M)},T=y=>{k.delete(y.pointerId)&&(P(y.pointerId),l.pointerCancel(y.pointerId))},$=y=>{if(x(y))return;const[L,M]=g(y);if(l.surfaceAt(L,M))return;v(y);const D=y.deltaMode===1?16:y.deltaMode===2?l.height:1;l.wheel(L,M,y.deltaX*D,y.deltaY*D)&&y.preventDefault()},z=y=>{var Y;if(x(y))return;const L="clientX"in y?y:(Y=y.changedTouches)==null?void 0:Y[0];if(!L)return;const[M,D]=g(L);l.surfaceAt(M,D)||(v(y),y.type==="mousedown"&&y.preventDefault())};n.addEventListener("pointerdown",I,!0),n.addEventListener("pointermove",C,!0),n.addEventListener("pointerleave",N),n.addEventListener("pointerup",X,!0),n.addEventListener("pointercancel",T,!0),n.addEventListener("wheel",$,{passive:!1,capture:!0});for(const y of Oe)n.addEventListener(y,z,!0);return{ui:l,render:f,resize:p,setSafeArea:b,destroy(){for(const y of A.keys())P(y);n.removeEventListener("pointerdown",I,!0),n.removeEventListener("pointermove",C,!0),n.removeEventListener("pointerleave",N),n.removeEventListener("pointerup",X,!0),n.removeEventListener("pointercancel",T,!0),n.removeEventListener("wheel",$,!0);for(const y of Oe)n.removeEventListener(y,z,!0);l.dispose(),o.remove(),a.remove()}}},Os=["miter","round","bevel"],Is=["butt","round","square"],Fs=["left","center","right","start","end"],Ns=["alphabetic","top","middle","bottom","hanging","ideographic"],Ie=["nonzero","evenodd"],Us=["pad","reflect","repeat"],Vt={COLOR:0,RADIAL:2},vt={MOVE:0,LINE:1,QUAD:2,CUBIC:3,CLOSE:4},K={SET_TRANSFORM:0,SAVE:1,RESTORE:2,CLIP:3,FILL_PATH:4,STROKE_PATH:5,FILL_TEXT:6,STROKE_TEXT:7,DRAW_IMAGE:8,CLEAR_RECT:9};class Ws{constructor(t,e){m(this,"pos",0);this.w=t,this.strings=e}f(){if(this.pos>=this.w.length)throw new Error("draw list: truncated");return this.w[this.pos++]}i(){return this.f()|0}str(){const t=this.i();if(t<0||t>=this.strings.length)throw new Error(`draw list: bad string index ${t}`);return this.strings[t]}color(){return[this.f(),this.f(),this.f(),this.f()]}matrix(){return[this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]}paint(){const t=this.i(),e=this.f();if(t===Vt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Vt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Us[this.i()]??"pad",h=this.i(),l=[];for(let c=0;c<h;c++)l.push({offset:this.f(),color:this.color()});return t===Vt.RADIAL?{kind:"radial",alpha:e,matrix:s,fx:r,fy:i,r0:o,spread:a,stops:l}:{kind:"linear",alpha:e,matrix:s,spread:a,stops:l}}stroke(){const t=this.f(),e=Os[this.i()]??"miter",s=Is[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let h=0;h<o;h++)a.push(this.f());return{width:t,join:e,cap:s,miterLimit:r,dashOffset:i,dash:a}}font(){return{family:this.str(),size:this.f(),weight:this.i(),italic:this.i()!==0}}path(){const t=this.i(),e=this.pos+t;if(e>this.w.length)throw new Error("draw list: truncated path");const s=[];for(;this.pos<e;)switch(this.i()){case vt.MOVE:s.push(["M",this.f(),this.f()]);break;case vt.LINE:s.push(["L",this.f(),this.f()]);break;case vt.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case vt.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case vt.CLOSE:s.push(["Z"]);break;default:throw new Error("draw list: bad path verb")}return s}rect4(){return[this.f(),this.f(),this.f(),this.f()]}}const Bs=(n,t)=>{const e=new Ws(n,t),s=[];for(;e.pos+2<=n.length;){const r=e.i(),i=e.i(),o=e.pos+i;if(i<0||o>n.length)throw new Error("draw list: truncated command");switch(r){case K.SET_TRANSFORM:s.push({cmd:"setTransform",matrix:e.matrix()});break;case K.SAVE:s.push({cmd:"save"});break;case K.RESTORE:s.push({cmd:"restore"});break;case K.CLIP:{const a=Ie[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case K.FILL_PATH:{const a=Ie[e.i()]??"nonzero",h=e.paint();s.push({cmd:"fillPath",rule:a,paint:h,path:e.path()});break}case K.STROKE_PATH:{const a=e.stroke(),h=e.paint();s.push({cmd:"strokePath",stroke:a,paint:h,path:e.path()});break}case K.FILL_TEXT:case K.STROKE_TEXT:{const a=e.str(),h=e.f(),l=e.f(),c=e.f(),d=e.font(),u=Fs[e.i()]??"start",f=Ns[e.i()]??"alphabetic",p=e.f();if(r===K.STROKE_TEXT){const b=e.stroke();s.push({cmd:"strokeText",text:a,x:h,y:l,maxWidth:c,font:d,align:u,baseline:f,letterSpacing:p,stroke:b,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:h,y:l,maxWidth:c,font:d,align:u,baseline:f,letterSpacing:p,paint:e.paint()});break}case K.DRAW_IMAGE:{const a=e.i(),h=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:h,dst:l,alpha:e.f()});break}case K.CLEAR_RECT:s.push({cmd:"clearRect",rect:e.rect4()});break}if(e.pos!==o){if(e.pos>o)throw new Error(`draw list: command ${r} overran its length`);e.pos=o}}return s},Ds=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),bn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,vn=(n,t=n.family)=>{const e=Ds.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},_t=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],Hs=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,jt=(n,t)=>{n.beginPath();for(const e of t)switch(e[0]){case"M":n.moveTo(e[1],e[2]);break;case"L":n.lineTo(e[1],e[2]);break;case"Q":n.quadraticCurveTo(e[1],e[2],e[3],e[4]);break;case"C":n.bezierCurveTo(e[1],e[2],e[3],e[4],e[5],e[6]);break;case"Z":n.closePath();break}},Fe=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,bn(e.color))},Tt=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=bn(t.color),s();return}const r=t.matrix;if(Hs(r)){let o;if(t.kind==="linear"){const[a,h]=_t(r,0,0),[l,c]=_t(r,1,0);o=n.createLinearGradient(a,h,l,c)}else{const a=Math.hypot(r[0],r[1]),[h,l]=_t(r,0,0),[c,d]=_t(r,t.fx,t.fy);o=n.createRadialGradient(c,d,t.r0*a,h,l,a)}Fe(o,t),n[e==="fill"?"fillStyle":"strokeStyle"]=o,s();return}n.save(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5]);const i=t.kind==="linear"?n.createLinearGradient(0,0,1,0):n.createRadialGradient(t.fx,t.fy,t.r0,0,0,1);Fe(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},Ne=(n,t)=>{n.lineWidth=t.width,n.lineJoin=t.join,n.lineCap=t.cap,n.miterLimit=t.miterLimit,n.setLineDash(t.dash),n.lineDashOffset=t.dashOffset},Ue=(n,t,e)=>{n.font=vn(t.font,e.fontFamily?e.fontFamily(t.font.family):t.font.family),n.textAlign=t.align,n.textBaseline=t.baseline,"letterSpacing"in n&&(n.letterSpacing=`${t.letterSpacing}px`)},$s=(n,t,e={})=>{var r;n.save();let s=0;try{n.setTransform(1,0,0,1,0,0),n.globalAlpha=1;for(const i of t)switch(i.cmd){case"setTransform":n.setTransform(i.matrix[0],i.matrix[1],i.matrix[2],i.matrix[3],i.matrix[4],i.matrix[5]);break;case"save":n.save(),s++;break;case"restore":s>0&&(n.restore(),s--);break;case"clip":jt(n,i.path),n.clip(i.rule);break;case"fillPath":jt(n,i.path),Tt(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":jt(n,i.path),Ne(n,i.stroke),Tt(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":Ue(n,i,e),Tt(n,i.paint,"fill",()=>i.maxWidth>0?n.fillText(i.text,i.x,i.y,i.maxWidth):n.fillText(i.text,i.x,i.y));break;case"strokeText":Ue(n,i,e),Ne(n,i.stroke),Tt(n,i.paint,"stroke",()=>i.maxWidth>0?n.strokeText(i.text,i.x,i.y,i.maxWidth):n.strokeText(i.text,i.x,i.y));break;case"drawImage":{const o=(r=e.image)==null?void 0:r.call(e,i.surface);if(!o)break;n.globalAlpha=i.alpha,n.drawImage(o,i.src[0],i.src[1],i.src[2],i.src[3],i.dst[0],i.dst[1],i.dst[2],i.dst[3]);break}case"clearRect":n.clearRect(i.rect[0],i.rect[1],i.rect[2],i.rect[3]);break;default:{const o=i;throw new Error(`unhandled draw command ${o.cmd}`)}}}finally{for(;s>0;s--)n.restore();n.restore()}},Gs=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,c,d)=>{if(!t)return null;let u=e.get(l);return u?(u.width!==c||u.height!==d)&&(u.width=c,u.height=d):(u=new OffscreenCanvas(c,d),e.set(l,u)),u},i={paint:(l,c,d,u,f,p)=>{const b=r(l,Math.max(1,c),Math.max(1,d)),g=b==null?void 0:b.getContext("2d");!b||!g||(g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,b.width,b.height),$s(g,Bs(f,p),{image:x=>e.get(x)??null,fontFamily:n}))},measureText:(l,c,d,u,f,p)=>{if(p[0]=0,p[1]=0,p[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=vn({family:c,size:d,weight:u,italic:f},c);const b=s.measureText(l);p[0]=b.width,p[1]=b.fontBoundingBoxAscent??b.actualBoundingBoxAscent,p[2]=b.fontBoundingBoxDescent??b.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,c)=>{const d=o(l);return d?(c[0]=d.width,c[1]=d.height,new Uint8Array(d.data.buffer,d.data.byteOffset,d.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const c=e.get(l),d=c==null?void 0:c.getContext("2d");return!c||!d?null:{data:d.getImageData(0,0,c.width,c.height).data,width:c.width,height:c.height}};return{table:i,readSurface:o,getSurface:l=>{const c=e.get(l);return c?{canvas:c,width:c.width,height:c.height}:null},surfaceToDataUrl:l=>{var u;const c=e.get(l);if(!c||typeof document>"u")return null;const d=document.createElement("canvas");return d.width=c.width,d.height=c.height,(u=d.getContext("2d"))==null||u.drawImage(c,0,0),d.toDataURL()}}},Vs=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,js=(n,t="woff2")=>{const e=/^\/\/ fonts: (.+)$/m.exec(n);if(!e)return[];const s=[];for(const r of e[1].split(";")){const i=r.indexOf("=");if(i===-1)continue;const o=/^(.+)@(\d+)(i?)$/.exec(r.slice(0,i));o&&s.push({family:o[1],weight:parseInt(o[2],10),italic:o[3]==="i",url:r.slice(i+1).replace("{fmt}",t)})}return s},zs=async(n,t,e=2e3)=>{const s=t??(typeof document>"u"?void 0:document);if(!(s!=null&&s.fonts)||n.length===0)return;const r=[];for(const i of n)try{const o=new FontFace(i.family,`url("${i.url}")`,{weight:String(i.weight),style:i.italic?"italic":"normal"});s.fonts.add(o),r.push(o.load().catch(()=>{}))}catch{}await Promise.race([Promise.all(r),new Promise(i=>setTimeout(i,e))])},xn="Roboto",Ks=[`400 14px ${xn}`],We="data-lecodes-fonts",Xs=async(n=Ks,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${We}]`)){const s=new URL(Vs,document.baseURI).href,r=e.createElement("style");r.setAttribute(We,""),r.textContent=`@font-face{font-family:"${xn}";src:url("${s}") format("woff2");font-weight:100 900;font-display:swap}`,e.head.appendChild(r)}try{await Promise.all(n.map(s=>e.fonts.load(s)))}catch{}}},Be="2.2.9",zt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},Ys=(n,t)=>zt(n)!==null&&zt(n)===zt(t),qs=[171,75,84,88,32,50,48,187,13,10,26,10],Js=n=>n.length>=12&&qs.every((t,e)=>n[e]===t),Qs=(n,t)=>{const e={antialias:!1,depth:!0,alpha:!1,stencil:!1,desynchronized:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"high-performance",premultipliedAlpha:!0,preserveDrawingBuffer:t},s=n.newCanvas(),r=s.getContext("webgl2",e);if(!r)throw new Error("WebGL2 is not available");let i=null,o=!1;const a=[],h=()=>{const c=r.createTexture();return r.bindTexture(r.TEXTURE_2D,c),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),c},l=(c,d,u,f)=>{const p=c.GL.getNewId(c.GL.textures);return c.GL.textures[p]=d,c._importTexture(p,u,f)>>>0};return{canvas:s,context:r,options:e,table(c){return i=c,{engineCreated(){c._createSwapChainHeadless(s.width,s.height),c._creatorWebSetViewport(s.width,s.height),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(d,u,f,p){const b=nt(d);if(!b){p(`createTexture: no buffer behind id ${d}`);return}const g=new Uint8Array(b);if(Js(g)){const x=c._malloc(g.length);c.HEAPU8.set(g,x);const w=c._createTextureFromKtx2(x,g.length)>>>0;if(c._free(x),w===4294967295){p("KTX2 transcode failed");return}f(w,c._getTextureWidth(w),c._getTextureHeight(w));return}createImageBitmap(Ft(d)).then(x=>{const w=h();r.texStorage2D(r.TEXTURE_2D,1,u&1?r.RGBA8:r.SRGB8_ALPHA8,x.width,x.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,x.width,x.height,r.RGBA,r.UNSIGNED_BYTE,x),f(l(c,w,x.width,x.height),x.width,x.height)},x=>p(x instanceof Error?x.message:String(x)))},createMediaPlayerTexture(d){const u=de(d);if(!u)return 0;const f=h();return a.push({player:u,texture:f,lastTime:0}),l(c,f,0,0)}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&i._creatorWebSetViewport(s.width,s.height)},frame(){for(const c of a)c.player.readyState<2||c.player.currentTime===c.lastTime||(c.lastTime=c.player.currentTime,r.bindTexture(r.TEXTURE_2D,c.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,c.player))},destroy(){var c;a.length=0,(c=r.getExtension("WEBGL_lose_context"))==null||c.loseContext()}}},Zs=n=>{const t={alpha:!1,depth:!0,stencil:!0,antialias:!1,premultipliedAlpha:!1,desynchronized:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1},e=n.newCanvas(),s=e.getContext("webgl2",t);if(!s)throw new Error("WebGL2 is not available");let r=null,i=!1;const o=()=>{!r||!i||(r._c2dSetViewport(e.width,e.height),r._c2dSetDensity(n.size().factor))},a=()=>{r&&(r._creatorWeb2dEnsureInited(),i=!0,o(),e.style.display="block")},h=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:h}},show:a,hide:h,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},De=n=>{if(typeof n=="number"||typeof n=="bigint"||typeof WebAssembly<"u"&&n instanceof WebAssembly.RuntimeError)return!0;const t=n instanceof Error?n.stack??"":"";return/\bwasm\b|wasm-function|\.wasm/i.test(t)},He="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",En={};for(let n=0;n<He.length;n++)En[He[n]]=n;const ti=n=>{const t=[];let e=0,s=0;for(const r of n){const i=En[r];if(i===void 0)break;const o=i&32;if(s+=(i&31)<<e,o)e+=5;else{const a=s&1;s>>=1,t.push(a?-s:s),s=0,e=0}}return t};class ei{constructor(t){m(this,"sources");m(this,"lines");this.sources=t.sources,this.lines=[];let e=0,s=0,r=0;for(const i of t.mappings.split(";")){const o=[];let a=0;if(i)for(const h of i.split(",")){const l=ti(h);l.length!==0&&(a+=l[0],l.length>=4&&(e+=l[1],s+=l[2],r+=l[3],o.push([a,e,s,r])))}this.lines.push(o)}}originalPositionFor(t,e){const s=this.lines[t-1];if(!s||s.length===0)return null;let r=null;for(const o of s)if(o[0]<=e)r=o;else break;r??(r=s[0]);const i=this.sources[r[1]];return i===void 0?null:{source:i,line:r[2]+1,column:r[3]}}}const ni=n=>{const t=n.match(/\/\/# lecodesMap=data:application\/json;(?:charset=[^;]+;)?base64,([A-Za-z0-9+/=]+)\s*$/);if(!t)return null;try{const e=typeof atob=="function"?atob(t[1]):Buffer.from(t[1],"base64").toString("utf8");return new ei(JSON.parse(e))}catch{return null}};let gt=null;const ri=()=>{if(gt!==null)return gt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return gt=e?parseInt(e[1],10)-1:2,gt}return gt=2,gt},Kt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=ri(),r=[];for(const i of e.split(`
14
- `)){const o=i.match(/<anonymous>:(\d+):(\d+)/);if(!o)continue;const a=parseInt(o[1],10)-s,h=parseInt(o[2],10)-1;if(a<1)continue;const l=t.originalPositionFor(a,h<0?0:h);if(!l)continue;const c=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:c?c[1]:null,source:l.source,line:l.line,column:l.column})}return r},si=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,ii=(n,t)=>{const e=[],s=(l,c,d,u)=>{var b,g;if(d.length===0&&De(c)){const x=typeof c=="number"||typeof c=="bigint"?`code ${c}`:c instanceof Error?c.message||c.name:String(c),w=[u,x].filter(k=>!!k).filter((k,A,P)=>P.indexOf(k)===A).join(`
15
- `);console.error(`[lecodes] native engine error — ${w||x} (see the console for the engine's message)`);const v={message:"Native engine error",detail:w,frames:[],native:!0,stack:c instanceof Error?c.stack:void 0};(b=l.onError)==null||b.call(l,v),v.stack&&t&&Jn(v.stack).then(k=>{var A;k.length>0&&((A=l.onError)==null||A.call(l,{...v,nativeFrames:k}))});return}const f=c instanceof Error?c.message:String(c),p=d[0];console.error(p?`[lecodes] ${f}
16
- at ${p.source}:${p.line}:${p.column}${p.fn?` (${p.fn})`:""}`:`[lecodes] ${f}`),(g=l.onError)==null||g.call(l,{message:f,frames:d,stack:c instanceof Error?c.stack:void 0})},r=(l,c)=>{for(let u=e.length-1;u>=0;u--){const f=e[u];if(!f.sourceMap)continue;const p=Kt(l,f.sourceMap);if(p.length>0)return s(f,l,p,c)}const d=e[e.length-1];d&&De(l)&&s(d,l,[],c)};let i=null;const o=()=>{const l=e[e.length-1],c=i;if(i=null,!c||!l)return;const d=new Error(c.message.replace(/^Error: /,""));d.stack=c.stack.join(`
17
- `),s(l,d,l.sourceMap?Kt(d,l.sourceMap):[])},a=l=>r(l.error??l.message,l.message),h=l=>r(l.reason);return n.addEventListener("error",a),n.addEventListener("unhandledrejection",h),{track(l,c){const d={sourceMap:ni(l),onError:c};return e.push(d),{drop(){const u=e.indexOf(d);u>=0&&e.splice(u,1)}}},locate(l){var d;const c=(d=e[e.length-1])==null?void 0:d.sourceMap;return c?Kt(l,c):[]},runtimeLine(l){if(i&&/^\s+at /.test(l))return i.stack.push(l),!0;const c=si.exec(l);if(!c||e.length===0)return!1;o();const[d,...u]=c[2].split(`
18
- `);return i={message:(d??"").replace(/^JsTask /,""),stack:u},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",h),e.length=0}}},Sn=n=>{var h,l,c,d;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const u of s[1].split(";"))e.add(u);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((h=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:h[1])??null,o=((c=(l=t.match(/^\/\/ name: (.+)$/m))==null?void 0:l[1])==null?void 0:c.trim())??null,a=new Set((((d=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:d[1])??"").split(";").map(u=>u.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:js(t)}},oi=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",ai=n=>{const t=n.ownerDocument,e=t.defaultView??window;let s=1/0;const r=(f,p)=>{const b=Math.min(s,(e.devicePixelRatio||1)*ue(n));return{width:f,height:p,factor:b,pixelWidth:Math.max(1,Math.round(f*b)),pixelHeight:Math.max(1,Math.round(p*b))}};let i=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const o=[],a=f=>{f.width!==i.pixelWidth&&(f.width=i.pixelWidth),f.height!==i.pixelHeight&&(f.height=i.pixelHeight)},h=()=>{const f=t.createElement("canvas");return f.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(f),a(f),o.push(f),f},l=new Set,c=f=>{if(!(f.width<=0||f.height<=0)){i=f;for(const p of o)a(p);for(const p of l)p(i)}},d=new ResizeObserver(([f])=>{var v;if(!f)return;const{width:p,height:b}=f.contentRect,g=(v=f.devicePixelContentBoxSize)==null?void 0:v[0],x=r(p,b),w=g&&Math.abs(g.inlineSize-p*x.factor)<=1&&Math.abs(g.blockSize-b*x.factor)<=1;if(!g||!w){c(x);return}c({width:p,height:b,pixelWidth:Math.max(1,g.inlineSize),pixelHeight:Math.max(1,g.blockSize),factor:x.factor})});try{d.observe(n,{box:"device-pixel-content-box"})}catch{d.observe(n)}return{root:n,doc:t,win:e,size:()=>i,newCanvas:h,remeasure:f=>{f!==void 0&&(s=f>0?f:1/0);const p=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==i.pixelWidth||p.pixelHeight!==i.pixelHeight||p.factor!==i.factor)&&c(p)},onResize(f){return l.add(f),()=>{l.delete(f)}},destroy(){d.disconnect(),l.clear();for(const f of o)f.remove();o.length=0}}},ci=n=>{const t=[],e=new Set;return{has:s=>e.has(s),register(s,r){e.has(s)||(e.add(s),r({registerView:(i,o,a=1)=>{t.push({id:s,version:a,kind:"view",name:i,factory:o})},registerService:(i,o,a=1)=>{t.push({id:s,version:a,kind:"service",name:i,factory:o})},putBuffer:lt,getBuffer:nt}))},allow(s){var i,o;const r=new Set(s);for(const a of t){const h=r.has(a.id);a.kind==="view"?h?(i=n.registerView)==null||i.call(n,a.name,a.factory,a.version):(o=n.unregisterView)==null||o.call(n,a.name):h?n.registerService(a.name,a.factory,a.version):n.unregisterService(a.name)}}}},li=n=>{const t=n.ownerDocument.createElement("div");t.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);",n.appendChild(t);const e=i=>Math.round(parseFloat(i)||0),s=()=>{const i=getComputedStyle(t);return{top:e(i.paddingTop),right:e(i.paddingRight),bottom:e(i.paddingBottom),left:e(i.paddingLeft)}};let r=null;return{set(i){r=i},current:()=>r??s(),destroy(){t.remove()}}},hi={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world"},$e="material:",ui=n=>{const t=new Set;for(const e of n)e.startsWith($e)&&t.add(hi[e.slice($e.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},di=""+new URL("assets/materials-uri4FvPE.bin",import.meta.url).href,fi=""+new URL("assets/materials-world-CQWt8TAm.bin",import.meta.url).href,pi=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,gi=""+new URL("assets/uberarchive-Ok2HfJvn.bin",import.meta.url).href,mi={base:di,world:fi},yi=n=>{const t=new Uint8Array(n.reduce((s,r)=>s+r.byteLength,0));let e=0;for(const s of n)t.set(new Uint8Array(s),e),e+=s.byteLength;return t.buffer},wi=async n=>{const t=async o=>{const a=await fetch(o);if(!a.ok)throw new Error(`${o} → HTTP ${a.status}`);return a.arrayBuffer()},e=ui(n).map(o=>mi[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(pi),t(gi),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:yi(i)}:{}}},bi=n=>{const t=()=>n.push(document.hidden?"pause":"resume"),e=()=>n.push("online"),s=()=>n.push("offline");return document.addEventListener("visibilitychange",t),window.addEventListener("online",e),window.addEventListener("offline",s),{table:{state:()=>document.hidden?"background":"active",isOnline:()=>navigator.onLine,openUrl(i){window.open(i,"_blank","noopener")},setOrientation(i){var h,l,c,d;const o=i==="landscape"||i==="portrait"?i:"auto";if(n.onOrientation){n.onOrientation(o);return}const a=typeof screen<"u"?screen.orientation:void 0;if(a)try{o==="auto"?(h=a.unlock)==null||h.call(a):(d=(c=(l=a.lock)==null?void 0:l.call(a,o))==null?void 0:c.catch)==null||d.call(c,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},vi=(n,t,e,s)=>{try{const r=document.createElement("input");r.type="file",r.multiple=e,s&&(r.accept=s),r.onchange=async()=>{const{files:i}=r;if(e){const o=[];if(!i)return n([]);for(let a of i)o.push([lt(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[lt(await i[0].arrayBuffer()),i[0].name,i[0].size]])}},window.addEventListener("focus",()=>{setTimeout(()=>{(!r.files||r.files.length===0)&&n(e?[]:null)},300)},{once:!0}),r.click()}catch(r){t(r)}},xi=n=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return window.devicePixelRatio||1},vibrate(){var t;try{(t=navigator.vibrate)==null||t.call(navigator,30)}catch{}},clipboardWrite(t){var e;(e=navigator.clipboard)==null||e.writeText(t).catch(()=>{})},clipboardRead(t,e){const s=navigator.clipboard;if(!(s!=null&&s.readText)){e("Clipboard is not available");return}s.readText().then(t,r=>e(r instanceof Error?r.message:"Clipboard read failed"))},share(t){const e=URL.createObjectURL(Ft(t)),s=document.createElement("a");s.href=e,s.download="image.png",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(e)},openFilePicker:(t,e,s,r)=>vi(t,e,s,r??void 0),requestCamera(t){t()}}),Ei=(n={})=>({local:t=>ir(t),dispose:t=>er(t),request(t,e,s,r,i,o,a,h){if(t.startsWith("id:")){const d=Number(t.slice(3));o(d,nt(d)?200:404);return}const l={};for(let d=0;d+1<s.length;d+=2)l[s[d]]=s[d+1];let c;if(i.length>0){const d=new FormData;for(const u of i)u.key!==null&&(u.bufferId>0?d.append(u.key,Ft(u.bufferId),u.filename??void 0):d.append(u.key,u.value??""));c=d}else r!==null&&(c=r);(async()=>{var d;try{const u=await fetch(t,{method:e,headers:l,body:c,mode:"cors",credentials:"omit"}),f=h?(d=u.body)==null?void 0:d.getReader():void 0;if(!f){o(lt(await u.arrayBuffer()),u.status);return}const p=Number(u.headers.get("content-length"))||void 0,b=[];let g=0;for(;;){const{done:v,value:k}=await f.read();if(v)break;k&&(b.push(k),g+=k.length,h({loaded:g,total:p}))}const x=new Uint8Array(g);let w=0;for(const v of b)x.set(v,w),w+=v.length;o(lt(x.buffer),u.status)}catch(u){a(u instanceof Error?u.message:String(u))}})()},buffer:t=>{const e=nt(t);return e?new Uint8Array(e):null},putBuffer:t=>lt(t.slice().buffer),bufferSlice(t,e,s){const r=nt(t);if(!r)return null;const i=Math.max(0,Math.min(e,r.byteLength)),o=Math.max(i,Math.min(s,r.byteLength));return new Uint8Array(r,i,o-i)},systemBuffer:t=>{const e=n[t];return e?new Uint8Array(e):null}}),Ge=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Xt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Rt=4,Yt=16,Ve=16,Si=.5,ki=n=>{const t=new Set;let e=null;const s=(E,R,U=-1,F=0)=>{e==null||e(E,R,U,F)},r=E=>{if(!E.code)return;const R=t.has(E.code);t.add(E.code),s(0,E.code,-1,R||E.repeat?1:0)},i=E=>{E.code&&t.delete(E.code)&&s(1,E.code)},o=()=>{for(const E of[...t])E.startsWith("Gamepad")||(t.delete(E),s(1,E))},{root:a}=n;let h=0,l=0,c=0,d=0,u=0,f=0,p=0,b=0,g=0,x=0;const w=E=>{if(E.pointerType&&E.pointerType!=="mouse")return;const R=a.getBoundingClientRect();h=E.clientX-R.left,l=E.clientY-R.top,c+=E.movementX||0,d+=E.movementY||0},v=E=>{const R=Ge[E.button];R&&(t.add(R),s(0,R))},k=E=>{const R=Ge[E.button];R&&t.delete(R)&&s(1,R)},A=E=>{const R=E.deltaMode===0?.01:1;u+=E.deltaX*R,f+=E.deltaY*R},P=E=>{document.pointerLockElement===a&&E.preventDefault()},I=[],C=[],N=[],X=()=>{var R,U;const E=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let F=0;F<Rt;F++){const Q=E[F]??null,Z=!!Q&&Q.connected;if(Z!==!!I[F]){if(I[F]=Z,!Z){for(const q of Xt)t.delete(q+"@"+F)&&(s(1,q,F),T(q));N[F]=[],C[F]=[0,0,0,0,0,0]}s(Z?2:3,"",F)}if(!Q||!Z)continue;const S=Q.axes,O=Q.buttons,B=((R=O[6])==null?void 0:R.value)??0,st=((U=O[7])==null?void 0:U.value)??0;C[F]=[S[0]??0,S[1]??0,S[2]??0,S[3]??0,B,st];const dt=N[F]??(N[F]=[]);for(let q=0;q<Xt.length;q++){const Wt=O[q],Et=!!Wt&&(Wt.pressed||Wt.value>Si);if(Et===!!dt[q])continue;dt[q]=Et;const St=Xt[q];Et?t.add(St+"@"+F):t.delete(St+"@"+F),T(St),s(Et?0:1,St,F)}}},T=E=>{let R=!1;for(let U=0;U<Rt&&!R;U++)t.has(E+"@"+U)&&(R=!0);R?t.add(E):t.delete(E)};let $=0;const z=()=>{p=c,b=d,g=u,x=f,c=d=u=f=0,X(),$=requestAnimationFrame(z)},y=n.windows.filter((E,R,U)=>E&&U.indexOf(E)===R);for(const E of y)n.keyboard!==!1&&(E.addEventListener("keydown",r),E.addEventListener("keyup",i)),E.addEventListener("blur",o);return a.addEventListener("pointermove",w,!0),a.addEventListener("mousedown",v,!0),window.addEventListener("mouseup",k,!0),a.addEventListener("wheel",A,{passive:!0,capture:!0}),a.addEventListener("contextmenu",P,!0),typeof requestAnimationFrame=="function"&&($=requestAnimationFrame(z)),{inputKey:(E,R)=>R>=0&&E.startsWith("Gamepad")?t.has(E+"@"+R):t.has(E),inputRead:E=>{var R;switch(E){case 0:return h;case 1:return l;case 2:return p;case 3:return b;case 4:return g;case 5:return x;case 6:return document.pointerLockElement===a?1:0;case 7:{let U=0;for(let F=0;F<Rt;F++)I[F]&&U++;return U}}if(E>=Yt){const U=Math.floor((E-Yt)/Ve),F=(E-Yt)%Ve;return U>=Rt||!I[U]?0:F===0?1:((R=C[U])==null?void 0:R[F-1])??0}return 0},inputSetPointerLock:E=>{if(!E)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const R=a.requestPointerLock({unadjustedMovement:!0});return R&&typeof R.catch=="function"&&R.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:E=>{e=E},dispose:()=>{for(const E of y)E.removeEventListener("keydown",r),E.removeEventListener("keyup",i),E.removeEventListener("blur",o);a.removeEventListener("pointermove",w,!0),a.removeEventListener("mousedown",v,!0),window.removeEventListener("mouseup",k,!0),a.removeEventListener("wheel",A,!0),a.removeEventListener("contextmenu",P,!0),$&&cancelAnimationFrame($),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},_i=n=>{const t=ki(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},Ti={createVideo:wr,createAudio:br,setVolume:vr,setPlaying:xr,setLoop:Er,time:Sr,setTime:kr,duration:_r,remove:Tr},Ri=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(u,f,p=1)=>{n.set(u,f),t.set(u,p)},unregisterService:u=>{n.delete(u),t.delete(u)},isServiceSupported:u=>n.has(u),serviceVersion:u=>t.get(u)??0,serviceOpen:(u,f,p)=>{const b=n.get(u);if(!b)return-1;const g=s++,x=b(f?JSON.parse(f):{},{emit:(w,v)=>{v===void 0?p(w):p(w,v)}});return e.set(g,x),g},serviceCall:(u,f,p,b,g)=>{const x=e.get(u);if(!(x!=null&&x.call)){g(`Service call "${f}": no live session or no call handler (serviceId ${u})`);return}try{Promise.resolve(x.call(f,Array.isArray(p)?p:[])).then(w=>{w===void 0?b():b(w)},w=>g(w instanceof Error?w.message:String(w)))}catch(w){g(w instanceof Error?w.message:String(w))}},serviceClose:u=>{var f,p;(p=(f=e.get(u))==null?void 0:f.close)==null||p.call(f),e.delete(u)},destroy:()=>{var u;for(const f of e.values())(u=f.close)==null||u.call(f);e.clear()}}},Ai=()=>{const n=Ri();return{table:{supported:n.isServiceSupported,version:n.serviceVersion,open:n.serviceOpen,call:n.serviceCall,close:n.serviceClose},registerService:n.registerService,unregisterService:n.unregisterService,dispose:n.destroy}},Mi=()=>{const n=[];return{table:{open(e,s){const r=new WebSocket(e);return r.addEventListener("open",()=>s("open")),r.addEventListener("message",i=>s("message",i.data)),r.addEventListener("close",i=>s("close",i.code)),r.addEventListener("error",()=>s("error")),n.push(r),n.length-1},send(e,s){var r;(r=n[e])==null||r.send(s)},close(e){var s;(s=n[e])==null||s.close()}},dispose(){for(const e of n)e.readyState===WebSocket.OPEN&&e.close();n.length=0}}},Li=n=>{const t=e=>`lecodes:${n}:${e}`;return{load(e){try{return window.localStorage.getItem(t(e))}catch{return null}},save(e,s){try{window.localStorage.setItem(t(e),s)}catch{}}}},je=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},Pi={fetch:Zn,getBuffer:nt,getBlob:Ft,putBuffer:lt,putLocalBuffer:nr,hasLocalBuffer:rr,getLocalName:sr,getPlayer:de,removePlayers:hn},Ci=(n,t)=>({nodeFactory(){},setPropertyString(){},setPropertyInt(){},setFlags(){},insertNode(){},removeNode(){},releaseNode(){},openView(e,s,r){n(e,r)},dropView(e,s,r){t(e,r)},closeView(){n(-1,0)},layerOpen(){},layerClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),Oi=async(n,t={})=>{var Z;const e=t.header,s=t.profile??(e?oi(e):"full"),r=(e==null?void 0:e.preloads)??new Set,i=t.ui!==!1,o=s==="full",a=s==="2d"||s==="full"&&!!(e!=null&&e.is2d),h=ai(n),{doc:l,win:c}=h,d=i?Promise.all([Xs(void 0,l),zs((e==null?void 0:e.bootFonts)??[],l)]):null,u=o?Qs(h,r.has("capture")):null,f=a?Zs(h):null,p=i?h.newCanvas():null,b=ii(c,o);o&&Qn();const[g,x]=await Promise.all([Wn(s,{glContext:u==null?void 0:u.context,glOptions:u==null?void 0:u.options,gl2dContext:f==null?void 0:f.context,gl2dOptions:f==null?void 0:f.options,moduleArgs:{print:S=>{b.runtimeLine(S)?console.debug(S):console.log(S)},printErr:S=>{console.error(S)}}}),o?wi(r):Promise.resolve({})]),w=(S,O)=>{const B=g.stringToNewUTF8(S);try{return O(B)}finally{g._free(B)}};let v=null,k=-1,A=-1;const P=(S,O)=>{A=S,S===Dt&&(u==null||u.show()),S===Me&&(f==null||f.show()),v&&S===Dt&&O!==k&&(k=O,v.openScene(O))},I=S=>{S!==A&&(S===Dt&&(u==null||u.hide(),v&&k>=0&&(k=-1,v.closeScene())),S===Me&&(f==null||f.hide()))},C=Gs();let N=t.keyboardBand??0;const T=p?Cs(n,{M:g,canvas:p,canvasHost:C,keyboardHeight:()=>{const S=c.visualViewport,O=S?Math.max(0,Math.round((c.innerHeight-S.height-S.offsetTop)/ue(n))):0;return O>0?O:N},onKeyboard:t.onKeyboard}):null;T&&(T.ui.onDestination=P,T.ui.onDropped=I);const $=bi({onOrientation:t.onOrientation,push:(S,O)=>{S==="url"&&O!==void 0&&w(O,B=>g._creatorWebSetLaunchUrl(B)),w(S,B=>{O===void 0?g._creatorWebAppEvent(B,0):w(O,st=>g._creatorWebAppEvent(B,st))})}}),z=Mi(),y=Ai(),L=_i({windows:[...new Set([c,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,push:(S,O,B,st)=>w(O,dt=>g._creatorWebInputEvent(S,dt,B,st)),keyboardHeight:()=>(T==null?void 0:T.ui.keyboardHeight())??0}),M={ui:(T==null?void 0:T.ui)??Ci(P,I),app:$.table,device:xi(t.language??(()=>(c.navigator.language||"en").slice(0,2))),fetch:Ei(x),storage:Li(t.project??(e==null?void 0:e.name)??"app"),socket:z.table,service:y.table,input:L.table,media:Ti,canvas:C.table,...u?{gl:u.table(g)}:{},...f?{scene2d:f.table(g)}:{}},D=je(),Y=D.global;Kn(g,{host:M,world:D,newWorld:je});const ut=ci({...T?{registerView:(S,O,B)=>T.ui.registerView(S,O,B),unregisterView:S=>T.ui.unregisterView(S)}:{},registerService:y.registerService,unregisterService:y.unregisterService});g._creatorWebInit(),t.launchUrl&&w(t.launchUrl,S=>g._creatorWebSetLaunchUrl(S)),T==null||T.ui.install(),!o&&t.engine3d&&(v=await t.engine3d({newCanvas:h.newCanvas,preloads:r,canvasHost:C,stores:Pi}),Object.defineProperty(Y,"_creator",{value:v,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Z=Y._creator)==null||Z.createEngine());const E=li(n);t.safeArea&&E.set(t.safeArea);const R=S=>{var O;u==null||u.resize(),f==null||f.resize(),(O=v==null?void 0:v._onResize)==null||O.call(v,S.width,S.height,S.factor),T?(T.resize(S.width,S.height,S.factor),T.setSafeArea(E.current())):g._creatorWebResize(S.width,S.height)};h.onResize(R),R(h.size());let U=0;const F=S=>{U=c.requestAnimationFrame(F),u==null||u.frame(),g._creatorWebTick(S),f==null||f.frame(S),T&&(T.ui.layoutFrame(),T.ui.tickHover(),T.render())};U=c.requestAnimationFrame(F),await d;let Q=!1;return{profile:s,M:g,world:Y,ui:(T==null?void 0:T.ui)??null,engine3d:()=>v,getBuffer:S=>nt(S),run(S,O={}){const B=O.header??Sn(S);if(!Ys(B.sdk,Be))throw new Error(`This app was built with LeCodes SDK ${B.sdk??"older than 2.0"}; this host runs SDK ${Be}. It needs a new build.`);const st=b.track(S,O.onError);return ut.allow(B.plugins),w(S,dt=>g._creatorWebRun(dt)),{dispose:st.drop}},registerPlugin:(S,O)=>ut.register(S,O),hasPlugin:ut.has,locate:b.locate,safeArea:()=>E.current(),setSafeArea(S){E.set(S),T==null||T.setSafeArea(E.current())},setKeyboardBand(S){N=S??0,T==null||T.ui.refreshKeyboard()},remeasure:h.remeasure,emitAppEvent:$.emit,destroy(){var S;Q||(Q=!0,c.cancelAnimationFrame(U),b.dispose(),T==null||T.destroy(),L.dispose(),z.dispose(),y.dispose(),$.dispose(),hn(),E.destroy(),(S=v==null?void 0:v._dispose)==null||S.call(v),u==null||u.destroy(),f==null||f.destroy(),h.destroy())}}},Ii=(n,t)=>new Promise(e=>{const s=n.ownerDocument.defaultView??window;s.requestAnimationFrame(()=>{try{const r=[...n.querySelectorAll("canvas")].filter(l=>l.width>0&&l.height>0&&s.getComputedStyle(l).display!=="none");if(r.length===0){e(null);return}const i=n.getBoundingClientRect(),o=t??Math.max(...r.map(l=>l.width))/Math.max(1,i.width),a=n.ownerDocument.createElement("canvas");a.width=Math.max(1,Math.round(i.width*o)),a.height=Math.max(1,Math.round(i.height*o));const h=a.getContext("2d");if(!h){e(null);return}h.fillStyle="#000000",h.fillRect(0,0,a.width,a.height);for(const l of r)h.drawImage(l,0,0,l.width,l.height,0,0,a.width,a.height);e(a.toDataURL("image/png"))}catch{e(null)}})}),Fi=n=>{if(typeof n=="string")return n;if(n instanceof Error)return n.stack?`${String(n)}
19
- ${n.stack}`:String(n);try{return JSON.stringify(n)}catch{return String(n)}},Ni=(n,t)=>{const e=o=>{fetch(`${n}/log`,{method:"POST",body:JSON.stringify(o),headers:{"content-type":"application/json"},keepalive:!0}).catch(()=>{})};let s=-1;const r=async()=>{try{const{v:o}=await(await fetch(`${n}/version`,{cache:"no-store"})).json();typeof o=="number"&&t(o)}catch{}setTimeout(r,2500)};setTimeout(r,2500);const i=()=>{let o;try{o=new WebSocket(n.replace(/^http/,"ws")+"/ws")}catch{return}o.onopen=()=>o.send(JSON.stringify({type:"hello",v:s})),o.onmessage=a=>{let h={};try{h=JSON.parse(String(a.data))}catch{return}h.type==="reload"&&typeof h.v=="number"&&t(h.v)},o.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:o=>`${n}/bundle.js?t=web&v=${o}`,versionOf(o,a){const h=Number(o.headers.get("x-lecodes-v"));return o.headers.has("x-lecodes-v")&&Number.isFinite(h)?h:a},ran(o){s=o},log:(o,a)=>e({type:"log",level:o,text:a.map(Fi).join(" ")}),error:o=>e({type:"error",text:o})}},Ui={browser:()=>j(()=>import("./assets/browser-BpFb50ko.js"),[],import.meta.url).then(n=>t=>n.register(t)),camera:()=>j(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>j(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>j(()=>import("./assets/map-8PhtP3jn.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>j(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>j(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t)),webrtc:()=>j(()=>import("./assets/webrtc-CbCltXvl.js"),[],import.meta.url).then(n=>t=>n.register(t))},Wi=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=Ui[e];if(!(!s||n.hasPlugin(e)))try{n.registerPlugin(e,await s())}catch(r){console.warn(`[lecodes] the "${e}" plugin failed to load: ${r instanceof Error?r.message:String(r)}`)}}))},fe=n=>typeof n=="object"&&n!==null,at=n=>typeof n=="number"&&Number.isFinite(n),Bi=n=>{if(!fe(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return at(n.x)&&at(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return at(n.node)?{ask:"node",node:n.node}:null;default:return null}},kn=n=>{if(!fe(n))return null;const t=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0?Math.round(s):0,e=Array.isArray(n.bars)?n.bars.filter(s=>s==="top"||s==="right"||s==="bottom"||s==="left"):void 0;return{top:t(n.top),right:t(n.right),bottom:t(n.bottom),left:t(n.left),...e?{bars:e}:{}}},Di=n=>{const t=Number(n.get("keyboard-band"));return Number.isFinite(t)&&t>0?t:null},Hi=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return kn({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},$i=n=>{if(!fe(n))return null;switch(n.type){case"lecodes:run":return typeof n.src=="string"?{type:"lecodes:run",src:n.src}:null;case"lecodes:reload":return{type:"lecodes:reload"};case"lecodes:safe-area":return{type:"lecodes:safe-area",insets:kn(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:keyboard-band":return{type:"lecodes:keyboard-band",height:at(n.height)&&n.height>0?n.height:null};case"lecodes:inspect":{const t=Bi(n.question);return t&&at(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!at(n.request))return null;const t=at(n.pixelRatio)&&n.pixelRatio>0?Math.min(4,n.pixelRatio):void 0;return{type:"lecodes:capture",request:n.request,...t!==void 0?{pixelRatio:t}:{}}}default:return null}},Gi=(n,t)=>{try{const e=new URL(n,t);return e.origin===new URL(t).origin&&(e.protocol==="http:"||e.protocol==="https:")?e.href:null}catch{return null}},Vi=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=$i(r.data);i&&t(i)};return n.addEventListener("message",s),{embedded:e!==null,post(r){e==null||e.postMessage(r,"*")},close(){n.removeEventListener("message",s)}}},Ut=window.lecodesPlayerConfig??{},wt=document.getElementById("app"),qt=document.getElementById("loader"),ze=document.getElementById("error"),rt=new URLSearchParams(location.search),_n=n=>qt==null?void 0:qt.classList.toggle("on",n),Tn=n=>{ze&&(ze.textContent=window.parent===window?n:"")};let ce=Ut.language||rt.get("lang")||(navigator.language||"en").slice(0,2),Pt=Ut.safeArea??Hi(rt),Ct=Ut.keyboardBand??Di(rt),W=null;const Ke=()=>{var n;return(n=W==null?void 0:W.world)==null?void 0:n._creatorTree},Ot=rt.has("test")?{ready:!1,dump:()=>{var n;return((n=Ke())==null?void 0:n.debugDump())??'{"roots":[]}'},rect:n=>{var s;const t=(s=Ke())==null?void 0:s.getBoundingClientRect(n);if(!t)return null;const e=wt.getBoundingClientRect();return[e.left+t[0],e.top+t[1],t[2],t[3]]}}:null;Ot&&(window.lecodesTest=Ot);const ji=rt.has("inspect"),le=ji?j(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url):null;let yt=null;const zi=async(n,t)=>{const{createInspector:e}=await(le??j(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url));W&&yt===null&&(yt=e(W)),J.post({type:"lecodes:inspected",request:n,answer:(yt==null?void 0:yt.answer(t))??null})},Xe=rt.has("dev")?new URL(rt.get("dev")||"..",location.href).href.replace(/\/$/,""):null,Ye=n=>{var s;const t=n.frames[0],e=t?`
13
+ `,Ie=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),Us=n=>n.type==="native"||n.type==="video",Bs=[1,0,0,1,0,0],Gt=(n,t)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]],Ws=(n,t)=>{if(!n)return t;const e=Math.max(n.x,t.x),s=Math.max(n.y,t.y);return{x:e,y:s,width:Math.max(0,Math.min(n.x+n.width,t.x+t.width)-e),height:Math.max(0,Math.min(n.y+n.height,t.y+t.height)-s)}};class It extends Fs{constructor(e,s,r,i,o={}){super(e,s,o);w(this,"doc");w(this,"factories",new Map);w(this,"versions",new Map);w(this,"views",new Map);w(this,"wrappers",new Map);w(this,"shown",new Map);w(this,"destination",null);w(this,"field",null);w(this,"placedFor",null);w(this,"band",{root:0,height:0});w(this,"slide",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=Ns,i.appendChild(a)}paintOptions(){var e;return{surfaces:!0,editing:(e=this.field)==null?void 0:e.id}}registerView(e,s,r=1){this.factories.set(e,s),this.versions.set(e,r)}unregisterView(e){this.factories.delete(e),this.versions.delete(e)}isViewSupported(e){return this.factories.has(e)}viewVersion(e){return this.versions.get(e)??0}ensureView(e,s,r){const i=this.views.get(e);if(i&&(i.name!==s||i.params!==r))this.destroyView(e);else if(i)return i.handle;const o=this.factories.get(s);if(!o)return null;let a={};try{a=r?JSON.parse(r):{}}catch{}const l=o(a,{emit:(c,h)=>this.M.jsb.viewEvent(e,c,h)},this.doc);return l.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:l}),l}destroyView(e){var r,i;const s=this.views.get(e);s&&(this.views.delete(e),(i=(r=s.handle).destroy)==null||i.call(r),s.handle.el.remove())}viewCall(e,s,r,i,o){const a=this.views.get(e);if(!(a!=null&&a.handle.call)){o(`NativeView call "${s}": no live instance or no call handler (viewId ${e})`);return}try{Promise.resolve(a.handle.call(s,Array.isArray(r)?r:[])).then(l=>{l===void 0?i():i(l)},l=>o(l instanceof Error?l.message:String(l)))}catch(l){o(l instanceof Error?l.message:String(l))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==ct)return;this.dropDestination();const l=this.ensureView(r,i,o);if(!l)return;const c=this.doc.createElement("div");c.style.cssText="position:absolute;inset:0;pointer-events:auto;",c.appendChild(l.el),this.under.prepend(c),this.destination={viewId:r,el:c}}dropView(e,s,r){var i;super.dropView(e,s,r),e===ct&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==ct&&this.dropDestination()}dropDestination(){var e;(e=this.destination)==null||e.el.remove(),this.destination=null}releaseNode(e){var r,i;const s=this.get(e);((r=this.field)==null?void 0:r.id)===e&&this.unmountField(),super.releaseNode(e),(i=this.shown.get(e))==null||i.remove(),this.shown.delete(e),this.wrappers.delete(e),(s==null?void 0:s.type)==="native"&&s.viewId&&this.destroyView(s.viewId)}keyboardDuration(){return ye}shrinkTo(e,s){const r=this.doc.defaultView;if(!r){super.shrinkTo(e,s);return}this.slide&&(r.cancelAnimationFrame(this.slide.raf),this.slide=null);const i=s>0?e:this.band.root,o=this.band.height;if(o===s||i===0||!this.nodes.has(i)){this.setBand(i,s);return}const a=r.performance.now(),l=()=>{const c=Math.min(1,(r.performance.now()-a)/ye),h=Wn(c);this.setBand(i,c<1?Math.round(o+(s-o)*h):s),c<1?this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(l)}:this.slide=null};this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(l)}}setBand(e,s){this.band=s>0?{root:e,height:s}:{root:0,height:0},super.shrinkTo(this.band.root,this.band.height),this.dirty=!0}focusInput(e){var i;if(super.focusInput(e),this.focusedId()!==e||((i=this.field)==null?void 0:i.id)===e)return;this.unmountField();const s=this.get(e);if(!s)return;const r=this.doc.createElement(s.type==="textarea"?"textarea":"input");r.className="lc-field",r.setAttribute("autocomplete","off"),r.value=s.value,r.addEventListener("input",()=>{this.focusedId()===e&&this.setInputValue(e,r.value)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&r.tagName==="INPUT"&&(o.preventDefault(),this.submitInput())}),r.addEventListener("blur",()=>{var o;((o=this.field)==null?void 0:o.el)===r&&this.focusedId()===e&&this.blurInput()}),this.over.appendChild(r),this.field={id:e,el:r},this.placedFor=null,this.place(),r.focus({preventScroll:!0})}blurInput(){super.blurInput(),this.unmountField()}unmountField(){const e=this.field;e&&(this.field=null,e.el.remove(),this.placedFor=null)}setPropertyString(e,s,r){var i,o;if(super.setPropertyString(e,s,r),s==="value"&&((i=this.field)==null?void 0:i.id)===e){const a=((o=this.get(e))==null?void 0:o.value)??"";this.field.el.value!==a&&(this.field.el.value=a)}}find(){var i;const e=[],s=(i=this.field)==null?void 0:i.id,r=(o,a,l)=>{let c=a;const h=o.style.transform;if(h){const f=o.style.transformOrigin,d=o.rect.x+(f?f.xPercent?o.rect.width*f.x/100:f.x:o.rect.width/2),p=o.rect.y+(f?f.yPercent?o.rect.height*f.y/100:f.y:o.rect.height/2),y=bn(h,o.style.transformBox,o.rect.width,o.rect.height);c=Gt(Gt(Gt(a,[1,0,0,1,d,p]),y),[1,0,0,1,-d,-p])}(Us(o)||o.id===s)&&e.push({node:o,matrix:c,clip:l});const u=o.clip?Ws(l,o.rect):l;for(const f of o.children)r(f,c,u)};for(const o of this.frame())r(o.tree,Bs,null);return e}static put(e,s){const{rect:r}=s.node,i=e.style;i.position="absolute",i.left="0",i.top="0",i.width=r.width+"px",i.height=r.height+"px",i.transformOrigin="0 0",i.transform=`matrix(${s.matrix.join(",")}) translate(${r.x}px,${r.y}px)`;const o=s.clip;i.clipPath=o?`inset(${Math.max(0,o.y-r.y)}px ${Math.max(0,r.x+r.width-(o.x+o.width))}px ${Math.max(0,r.y+r.height-(o.y+o.height))}px ${Math.max(0,o.x-r.x)}px)`:""}surfaceElement(e){const s=this.get(e.id);if(!s)return null;if(s.type==="video"){const o=de(s.playerId);return o instanceof HTMLVideoElement?o:null}if(!s.viewId)return null;const r=this.ensureView(s.viewId,s.viewName??"",s.viewParams??"");if(!r)return null;let i=this.wrappers.get(s.id);return i||(i=this.doc.createElement("div"),this.wrappers.set(s.id,i)),r.el.parentElement!==i&&i.replaceChildren(r.el),i}styleField(e,s){var u,f;const r=s.style,i=e.style,[o,a,l,c]=s.padding??[0,0,0,0];i.padding=`${a}px ${l}px ${c}px ${o}px`,i.color=Ie(r.color,"#000000ff"),i.caretColor=i.color;const h=r.fontFamily??"Roboto";if(i.fontFamily=((f=(u=this.host).resolveFontFamily)==null?void 0:f.call(u,h))??h,i.fontSize=(r.fontSize??14)+"px",i.fontWeight=String(r.fontWeight??400),i.fontStyle=r.fontStyle??"normal",i.letterSpacing=(r.letterSpacing??0)+"px",i.lineHeight=e.tagName==="TEXTAREA"&&r.lineHeight!==void 0?r.lineHeight+"px":"normal",i.textAlign=r.textAlign==="center"?"center":r.textAlign==="end"?"right":"left",i.borderRadius="0",e.placeholder=r.placeholder??"",i.setProperty("--lc-placeholder",Ie(r.placeholderColor,"#999999ff")),e instanceof HTMLInputElement){const d=r.inputType??"text";e.type!==d&&(e.type=d)}}place(){var r;const e=this.frame();if(e===this.placedFor)return;this.placedFor=e;const s=new Set;for(const i of this.find()){const{node:o}=i;if(o.id===((r=this.field)==null?void 0:r.id)){this.styleField(this.field.el,o),It.put(this.field.el,i);continue}const a=this.surfaceElement(o);a&&(s.add(o.id),a.parentElement!==this.under&&this.under.appendChild(a),a.style.display="block",a.style.opacity="",a.style.pointerEvents="auto",a instanceof HTMLVideoElement&&(a.style.objectFit=o.style.objectFit??"contain"),It.put(a,i),this.shown.set(o.id,a))}for(const[i,o]of this.shown)s.has(i)||(o.style.display="none",this.shown.delete(i))}surfaceAt(e,s){const r=this.frame();for(let i=r.length-1;i>=0;i--){const o=r[i];if(o.leaving)continue;const a=yt(o.tree,e,s,l=>{var c,h;return l.type==="native"||(((c=this.get(l.id))==null?void 0:c.interactive)??!1)||(((h=this.get(l.id))==null?void 0:h.editable)??!1)||!!l.scroll});if(a.node)return a.node.type==="native";if(a.blocker)return!1}return this.destination!==null}dispose(){this.unmountField();for(const e of[...this.views.keys()])this.destroyView(e);this.dropDestination();for(const e of this.shown.values())e instanceof HTMLVideoElement||e.remove();this.shown.clear()}}function Ds(n,t,e,s){const r=n.createElement("div");r.textContent=e,r.style.cssText="position:absolute;left:50%;bottom:48px;transform:translateX(-50%);max-width:80%;padding:10px 16px;border-radius:8px;background:rgba(30,30,30,0.92);color:#fff;font:13px/1.4 system-ui,sans-serif;z-index:30;pointer-events:none;",t.appendChild(r),setTimeout(()=>r.remove(),s>0?s:2e3)}const Hs=500,Fe=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],$s=(n,t)=>{const e=n.ownerDocument,{canvas:s}=t;s.style.display="block",s.style.pointerEvents="none",n.style.touchAction="none";const r=s.getContext("2d"),i=()=>{const g=e.createElement("div");return g.style.cssText="position:absolute;inset:0;overflow:hidden;pointer-events:none;",g},o=i(),a=i();n.insertBefore(o,s),s.after(a);const l=new wr({resolveAssetUrl:g=>an(g),canvasSurfaces:t.canvasHost}),c=new It(t.M,l,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onKeyboard:t.onKeyboard,onToast:(g,M)=>Ds(e,n,g,M)});let h=1,u=new Ae(r,h),f=!0;const d=()=>{(f||c.needsPaint())&&(f=!1,c.paint(u,c.paintOptions())),c.place()},p=(g,M,A)=>{g<=0||M<=0||(A!==h&&(h=A,u=new Ae(r,h)),f=!0,c.resize(g,M))},y=g=>{c.setSafeArea([g.top,g.right,g.bottom,g.left],g.bars??[])},b=g=>{const M=n.getBoundingClientRect(),A=fe(n);return[(g.clientX-M.left)/A,(g.clientY-M.top)/A]},x=g=>g.target instanceof Node&&a.contains(g.target),m=g=>g.target instanceof Node&&o.contains(g.target),v=g=>{m(g)&&g.stopPropagation()},_=new Set,T=new Map,P=g=>{const M=T.get(g);M!==void 0&&(clearTimeout(M),T.delete(g))},O=g=>{if(x(g))return;const[M,A]=b(g);if(!c.surfaceAt(M,A)){v(g),_.add(g.pointerId);try{n.setPointerCapture(g.pointerId)}catch{}c.pointerDown(g.pointerId,M,A),P(g.pointerId),T.set(g.pointerId,window.setTimeout(()=>{T.delete(g.pointerId),c.longPress(g.pointerId,M,A)},Hs))}},I=g=>{const[M,A]=b(g);_.has(g.pointerId)&&(v(g),c.pointerMove(g.pointerId,M,A)),g.pointerType==="mouse"&&(x(g)||!_.has(g.pointerId)&&c.surfaceAt(M,A)?c.pointerLeave():c.pointerHover(M,A))},F=g=>{g.pointerType==="mouse"&&c.pointerLeave()},$=g=>{if(!_.delete(g.pointerId))return;v(g),P(g.pointerId);const[M,A]=b(g);c.pointerUp(g.pointerId,M,A)},z=g=>{_.delete(g.pointerId)&&(P(g.pointerId),c.pointerCancel(g.pointerId))},G=g=>{if(x(g))return;const[M,A]=b(g);if(c.surfaceAt(M,A))return;v(g);const W=g.deltaMode===1?16:g.deltaMode===2?c.height:1;c.wheel(M,A,g.deltaX*W,g.deltaY*W)&&g.preventDefault()},Y=g=>{var q;if(x(g))return;const M="clientX"in g?g:(q=g.changedTouches)==null?void 0:q[0];if(!M)return;const[A,W]=b(M);c.surfaceAt(A,W)||(v(g),g.type==="mousedown"&&g.preventDefault())};n.addEventListener("pointerdown",O,!0),n.addEventListener("pointermove",I,!0),n.addEventListener("pointerleave",F),n.addEventListener("pointerup",$,!0),n.addEventListener("pointercancel",z,!0),n.addEventListener("wheel",G,{passive:!1,capture:!0});for(const g of Fe)n.addEventListener(g,Y,!0);return{ui:c,render:d,resize:p,setSafeArea:y,destroy(){for(const g of T.keys())P(g);n.removeEventListener("pointerdown",O,!0),n.removeEventListener("pointermove",I,!0),n.removeEventListener("pointerleave",F),n.removeEventListener("pointerup",$,!0),n.removeEventListener("pointercancel",z,!0),n.removeEventListener("wheel",G,!0);for(const g of Fe)n.removeEventListener(g,Y,!0);c.dispose(),o.remove(),a.remove()}}},Vs=["miter","round","bevel"],Gs=["butt","round","square"],js=["left","center","right","start","end"],zs=["alphabetic","top","middle","bottom","hanging","ideographic"],Ne=["nonzero","evenodd"],Ks=["pad","reflect","repeat"],jt={COLOR:0,RADIAL:2},xt={MOVE:0,LINE:1,QUAD:2,CUBIC:3,CLOSE:4},K={SET_TRANSFORM:0,SAVE:1,RESTORE:2,CLIP:3,FILL_PATH:4,STROKE_PATH:5,FILL_TEXT:6,STROKE_TEXT:7,DRAW_IMAGE:8,CLEAR_RECT:9};class Xs{constructor(t,e){w(this,"pos",0);this.w=t,this.strings=e}f(){if(this.pos>=this.w.length)throw new Error("draw list: truncated");return this.w[this.pos++]}i(){return this.f()|0}str(){const t=this.i();if(t<0||t>=this.strings.length)throw new Error(`draw list: bad string index ${t}`);return this.strings[t]}color(){return[this.f(),this.f(),this.f(),this.f()]}matrix(){return[this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]}paint(){const t=this.i(),e=this.f();if(t===jt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===jt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Ks[this.i()]??"pad",l=this.i(),c=[];for(let h=0;h<l;h++)c.push({offset:this.f(),color:this.color()});return t===jt.RADIAL?{kind:"radial",alpha:e,matrix:s,fx:r,fy:i,r0:o,spread:a,stops:c}:{kind:"linear",alpha:e,matrix:s,spread:a,stops:c}}stroke(){const t=this.f(),e=Vs[this.i()]??"miter",s=Gs[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let l=0;l<o;l++)a.push(this.f());return{width:t,join:e,cap:s,miterLimit:r,dashOffset:i,dash:a}}font(){return{family:this.str(),size:this.f(),weight:this.i(),italic:this.i()!==0}}path(){const t=this.i(),e=this.pos+t;if(e>this.w.length)throw new Error("draw list: truncated path");const s=[];for(;this.pos<e;)switch(this.i()){case xt.MOVE:s.push(["M",this.f(),this.f()]);break;case xt.LINE:s.push(["L",this.f(),this.f()]);break;case xt.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case xt.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case xt.CLOSE:s.push(["Z"]);break;default:throw new Error("draw list: bad path verb")}return s}rect4(){return[this.f(),this.f(),this.f(),this.f()]}}const Ys=(n,t)=>{const e=new Xs(n,t),s=[];for(;e.pos+2<=n.length;){const r=e.i(),i=e.i(),o=e.pos+i;if(i<0||o>n.length)throw new Error("draw list: truncated command");switch(r){case K.SET_TRANSFORM:s.push({cmd:"setTransform",matrix:e.matrix()});break;case K.SAVE:s.push({cmd:"save"});break;case K.RESTORE:s.push({cmd:"restore"});break;case K.CLIP:{const a=Ne[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case K.FILL_PATH:{const a=Ne[e.i()]??"nonzero",l=e.paint();s.push({cmd:"fillPath",rule:a,paint:l,path:e.path()});break}case K.STROKE_PATH:{const a=e.stroke(),l=e.paint();s.push({cmd:"strokePath",stroke:a,paint:l,path:e.path()});break}case K.FILL_TEXT:case K.STROKE_TEXT:{const a=e.str(),l=e.f(),c=e.f(),h=e.f(),u=e.font(),f=js[e.i()]??"start",d=zs[e.i()]??"alphabetic",p=e.f();if(r===K.STROKE_TEXT){const y=e.stroke();s.push({cmd:"strokeText",text:a,x:l,y:c,maxWidth:h,font:u,align:f,baseline:d,letterSpacing:p,stroke:y,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:l,y:c,maxWidth:h,font:u,align:f,baseline:d,letterSpacing:p,paint:e.paint()});break}case K.DRAW_IMAGE:{const a=e.i(),l=e.rect4(),c=e.rect4();s.push({cmd:"drawImage",surface:a,src:l,dst:c,alpha:e.f()});break}case K.CLEAR_RECT:s.push({cmd:"clearRect",rect:e.rect4()});break}if(e.pos!==o){if(e.pos>o)throw new Error(`draw list: command ${r} overran its length`);e.pos=o}}return s},qs=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),Sn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,_n=(n,t=n.family)=>{const e=qs.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Mt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],Js=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,zt=(n,t)=>{n.beginPath();for(const e of t)switch(e[0]){case"M":n.moveTo(e[1],e[2]);break;case"L":n.lineTo(e[1],e[2]);break;case"Q":n.quadraticCurveTo(e[1],e[2],e[3],e[4]);break;case"C":n.bezierCurveTo(e[1],e[2],e[3],e[4],e[5],e[6]);break;case"Z":n.closePath();break}},Ue=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,Sn(e.color))},Lt=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=Sn(t.color),s();return}const r=t.matrix;if(Js(r)){let o;if(t.kind==="linear"){const[a,l]=Mt(r,0,0),[c,h]=Mt(r,1,0);o=n.createLinearGradient(a,l,c,h)}else{const a=Math.hypot(r[0],r[1]),[l,c]=Mt(r,0,0),[h,u]=Mt(r,t.fx,t.fy);o=n.createRadialGradient(h,u,t.r0*a,l,c,a)}Ue(o,t),n[e==="fill"?"fillStyle":"strokeStyle"]=o,s();return}n.save(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5]);const i=t.kind==="linear"?n.createLinearGradient(0,0,1,0):n.createRadialGradient(t.fx,t.fy,t.r0,0,0,1);Ue(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},Be=(n,t)=>{n.lineWidth=t.width,n.lineJoin=t.join,n.lineCap=t.cap,n.miterLimit=t.miterLimit,n.setLineDash(t.dash),n.lineDashOffset=t.dashOffset},We=(n,t,e)=>{n.font=_n(t.font,e.fontFamily?e.fontFamily(t.font.family):t.font.family),n.textAlign=t.align,n.textBaseline=t.baseline,"letterSpacing"in n&&(n.letterSpacing=`${t.letterSpacing}px`)},Qs=(n,t,e={})=>{var r;n.save();let s=0;try{n.setTransform(1,0,0,1,0,0),n.globalAlpha=1;for(const i of t)switch(i.cmd){case"setTransform":n.setTransform(i.matrix[0],i.matrix[1],i.matrix[2],i.matrix[3],i.matrix[4],i.matrix[5]);break;case"save":n.save(),s++;break;case"restore":s>0&&(n.restore(),s--);break;case"clip":zt(n,i.path),n.clip(i.rule);break;case"fillPath":zt(n,i.path),Lt(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":zt(n,i.path),Be(n,i.stroke),Lt(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":We(n,i,e),Lt(n,i.paint,"fill",()=>i.maxWidth>0?n.fillText(i.text,i.x,i.y,i.maxWidth):n.fillText(i.text,i.x,i.y));break;case"strokeText":We(n,i,e),Be(n,i.stroke),Lt(n,i.paint,"stroke",()=>i.maxWidth>0?n.strokeText(i.text,i.x,i.y,i.maxWidth):n.strokeText(i.text,i.x,i.y));break;case"drawImage":{const o=(r=e.image)==null?void 0:r.call(e,i.surface);if(!o)break;n.globalAlpha=i.alpha,n.drawImage(o,i.src[0],i.src[1],i.src[2],i.src[3],i.dst[0],i.dst[1],i.dst[2],i.dst[3]);break}case"clearRect":n.clearRect(i.rect[0],i.rect[1],i.rect[2],i.rect[3]);break;default:{const o=i;throw new Error(`unhandled draw command ${o.cmd}`)}}}finally{for(;s>0;s--)n.restore();n.restore()}},Zs=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(c,h,u)=>{if(!t)return null;let f=e.get(c);return f?(f.width!==h||f.height!==u)&&(f.width=h,f.height=u):(f=new OffscreenCanvas(h,u),e.set(c,f)),f},i={paint:(c,h,u,f,d,p)=>{const y=r(c,Math.max(1,h),Math.max(1,u)),b=y==null?void 0:y.getContext("2d");!y||!b||(b.setTransform(1,0,0,1,0,0),b.clearRect(0,0,y.width,y.height),Qs(b,Ys(d,p),{image:x=>e.get(x)??null,fontFamily:n}))},measureText:(c,h,u,f,d,p)=>{if(p[0]=0,p[1]=0,p[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=_n({family:h,size:u,weight:f,italic:d},h);const y=s.measureText(c);p[0]=y.width,p[1]=y.fontBoundingBoxAscent??y.actualBoundingBoxAscent,p[2]=y.fontBoundingBoxDescent??y.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(c,h)=>{const u=o(c);return u?(h[0]=u.width,h[1]=u.height,new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.byteLength)):null},releaseSurface:c=>{e.delete(c)}},o=c=>{const h=e.get(c),u=h==null?void 0:h.getContext("2d");return!h||!u?null:{data:u.getImageData(0,0,h.width,h.height).data,width:h.width,height:h.height}};return{table:i,readSurface:o,getSurface:c=>{const h=e.get(c);return h?{canvas:h,width:h.width,height:h.height}:null},surfaceToDataUrl:c=>{var f;const h=e.get(c);if(!h||typeof document>"u")return null;const u=document.createElement("canvas");return u.width=h.width,u.height=h.height,(f=u.getContext("2d"))==null||f.drawImage(h,0,0),u.toDataURL()}}},ti=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,ei=(n,t="woff2")=>{const e=/^\/\/ fonts: (.+)$/m.exec(n);if(!e)return[];const s=[];for(const r of e[1].split(";")){const i=r.indexOf("=");if(i===-1)continue;const o=/^(.+)@(\d+)(i?)$/.exec(r.slice(0,i));o&&s.push({family:o[1],weight:parseInt(o[2],10),italic:o[3]==="i",url:r.slice(i+1).replace("{fmt}",t)})}return s},ni=async(n,t,e=2e3)=>{const s=t??(typeof document>"u"?void 0:document);if(!(s!=null&&s.fonts)||n.length===0)return;const r=[];for(const i of n)try{const o=new FontFace(i.family,`url("${i.url}")`,{weight:String(i.weight),style:i.italic?"italic":"normal"});s.fonts.add(o),r.push(o.load().catch(()=>{}))}catch{}await Promise.race([Promise.all(r),new Promise(i=>setTimeout(i,e))])},kn="Roboto",ri=[`400 14px ${kn}`],De="data-lecodes-fonts",si=async(n=ri,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${De}]`)){const s=new URL(ti,document.baseURI).href,r=e.createElement("style");r.setAttribute(De,""),r.textContent=`@font-face{font-family:"${kn}";src:url("${s}") format("woff2");font-weight:100 900;font-display:swap}`,e.head.appendChild(r)}try{await Promise.all(n.map(s=>e.fonts.load(s)))}catch{}}},He="2.2.11",Kt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},ii=(n,t)=>Kt(n)!==null&&Kt(n)===Kt(t),oi=()=>({setMatrix(){},setVisible(){},setCameraMatrix(){},setProjection(){},clearProjection(){},setBackground(){},createExternalTexture:()=>null,onFrame:()=>()=>{},readPixels:(n,t)=>t(null,0,0),viewport:()=>({width:0,height:0,rotation:0})}),ai=n=>{var s,r;const t=((r=(s=n.screen)==null?void 0:s.orientation)==null?void 0:r.angle)??n.orientation??0;return(Math.round(t/90)%4+4)%4*90},ci=(n,t)=>({width:(n==null?void 0:n.clientWidth)??0,height:(n==null?void 0:n.clientHeight)??0,rotation:ai(t)}),li=[1,0,0,0,1,0],hi=(n,t,e)=>{const s=t*4,r=new Uint8Array(s);for(let i=0,o=e-1;i<o;i++,o--)r.set(n.subarray(i*s,i*s+s)),n.copyWithin(i*s,o*s,o*s+s),n.set(r,o*s);return n},ui=[171,75,84,88,32,50,48,187,13,10,26,10],fi=n=>n.length>=12&&ui.every((t,e)=>n[e]===t),di=(n,t)=>{const e={antialias:!1,depth:!0,alpha:!1,stencil:!1,desynchronized:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"high-performance",premultipliedAlpha:!0,preserveDrawingBuffer:t},s=n.newCanvas(),r=s.getContext("webgl2",e);if(!r)throw new Error("WebGL2 is not available");let i=null,o=!1;const a=[],l=()=>{const u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),u},c=u=>{var p;u._creatorWebSetViewport(s.width,s.height);const{width:f,height:d}=n.size();f>0&&d>0&&((p=u._setDensityGL)==null||p.call(u,s.width/f,s.height/d))},h=(u,f,d,p)=>{const y=u.GL.getNewId(u.GL.textures);return u.GL.textures[y]=f,u._importTexture(y,d,p)>>>0};return{canvas:s,context:r,options:e,table(u){return i=u,{engineCreated(){a.length=0,u._createSwapChainHeadless(s.width,s.height),c(u),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(f,d,p,y){const b=Z(f);if(!b){y(`createTexture: no buffer behind id ${f}`);return}const x=new Uint8Array(b);if(fi(x)){const m=u._malloc(x.length);u.HEAPU8.set(x,m);const v=u._createTextureFromKtx2(m,x.length)>>>0;if(u._free(m),v===4294967295){y("KTX2 transcode failed");return}p(v,u._getTextureWidth(v),u._getTextureHeight(v));return}createImageBitmap(Wt(f)).then(m=>{const v=l();r.texStorage2D(r.TEXTURE_2D,1,d&1?r.RGBA8:r.SRGB8_ALPHA8,m.width,m.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,m.width,m.height,r.RGBA,r.UNSIGNED_BYTE,m),p(h(u,v,m.width,m.height),m.width,m.height)},m=>y(m instanceof Error?m.message:String(m)))},createMediaPlayerTexture(f){const d=de(f);if(!d)return 0;const p=l(),y=h(u,p,0,0);return a.push({video:d,texture:p,id:y,lastTime:0}),y}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&c(i)},frame(){for(const u of a)u.video.readyState<2||u.video.currentTime===u.lastTime||(u.lastTime=u.video.currentTime,r.bindTexture(r.TEXTURE_2D,u.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,u.video))},videoTexture(u){const f=a.find(y=>y.video===u);if(f)return f.id;if(!i||!o)return;const d=l(),p=h(i,d,0,0);return a.push({video:u,texture:d,id:p,lastTime:0}),p},readPixels(){const u=r.drawingBufferWidth,f=r.drawingBufferHeight;if(!o||u===0||f===0)return null;const d=new Uint8Array(u*f*4),p=r.getParameter(r.READ_FRAMEBUFFER_BINDING);return r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.readPixels(0,0,u,f,r.RGBA,r.UNSIGNED_BYTE,d),r.bindFramebuffer(r.READ_FRAMEBUFFER,p),{rgba:hi(d,u,f),width:u,height:f}},destroy(){var u;a.length=0,(u=r.getExtension("WEBGL_lose_context"))==null||u.loseContext()}}},pi=n=>{const t={alpha:!1,depth:!0,stencil:!0,antialias:!1,premultipliedAlpha:!1,desynchronized:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1},e=n.newCanvas(),s=e.getContext("webgl2",t);if(!s)throw new Error("WebGL2 is not available");let r=null,i=!1;const o=()=>{!r||!i||(r._c2dSetViewport(e.width,e.height),r._c2dSetDensity(n.size().factor))},a=()=>{r&&(r._creatorWeb2dEnsureInited(),i=!0,o(),e.style.display="block")},l=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(c){return r=c,{open2DScene:a,close2DScene:l}},show:a,hide:l,resize:o,frame(c){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(c)},destroy(){var c;(c=s.getExtension("WEBGL_lose_context"))==null||c.loseContext()}}},$e=n=>{if(typeof n=="number"||typeof n=="bigint"||typeof WebAssembly<"u"&&n instanceof WebAssembly.RuntimeError)return!0;const t=n instanceof Error?n.stack??"":"";return/\bwasm\b|wasm-function|\.wasm/i.test(t)},Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rn={};for(let n=0;n<Ve.length;n++)Rn[Ve[n]]=n;const gi=n=>{const t=[];let e=0,s=0;for(const r of n){const i=Rn[r];if(i===void 0)break;const o=i&32;if(s+=(i&31)<<e,o)e+=5;else{const a=s&1;s>>=1,t.push(a?-s:s),s=0,e=0}}return t};class mi{constructor(t){w(this,"sources");w(this,"lines");this.sources=t.sources,this.lines=[];let e=0,s=0,r=0;for(const i of t.mappings.split(";")){const o=[];let a=0;if(i)for(const l of i.split(",")){const c=gi(l);c.length!==0&&(a+=c[0],c.length>=4&&(e+=c[1],s+=c[2],r+=c[3],o.push([a,e,s,r])))}this.lines.push(o)}}originalPositionFor(t,e){const s=this.lines[t-1];if(!s||s.length===0)return null;let r=null;for(const o of s)if(o[0]<=e)r=o;else break;r??(r=s[0]);const i=this.sources[r[1]];return i===void 0?null:{source:i,line:r[2]+1,column:r[3]}}}const yi=n=>{const t=n.match(/\/\/# lecodesMap=data:application\/json;(?:charset=[^;]+;)?base64,([A-Za-z0-9+/=]+)\s*$/);if(!t)return null;try{const e=typeof atob=="function"?atob(t[1]):Buffer.from(t[1],"base64").toString("utf8");return new mi(JSON.parse(e))}catch{return null}};let mt=null;const wi=()=>{if(mt!==null)return mt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return mt=e?parseInt(e[1],10)-1:2,mt}return mt=2,mt},Xt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=wi(),r=[];for(const i of e.split(`
14
+ `)){const o=i.match(/<anonymous>:(\d+):(\d+)/);if(!o)continue;const a=parseInt(o[1],10)-s,l=parseInt(o[2],10)-1;if(a<1)continue;const c=t.originalPositionFor(a,l<0?0:l);if(!c)continue;const h=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:h?h[1]:null,source:c.source,line:c.line,column:c.column})}return r},bi=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,vi=(n,t)=>{const e=[],s=(c,h,u,f)=>{var y,b;if(u.length===0&&$e(h)){const x=typeof h=="number"||typeof h=="bigint"?`code ${h}`:h instanceof Error?h.message||h.name:String(h),m=[f,x].filter(_=>!!_).filter((_,T,P)=>P.indexOf(_)===T).join(`
15
+ `);console.error(`[lecodes] native engine error — ${m||x} (see the console for the engine's message)`);const v={message:"Native engine error",detail:m,frames:[],native:!0,stack:h instanceof Error?h.stack:void 0};(y=c.onError)==null||y.call(c,v),v.stack&&t&&rr(v.stack).then(_=>{var T;_.length>0&&((T=c.onError)==null||T.call(c,{...v,nativeFrames:_}))});return}const d=h instanceof Error?h.message:String(h),p=u[0];console.error(p?`[lecodes] ${d}
16
+ at ${p.source}:${p.line}:${p.column}${p.fn?` (${p.fn})`:""}`:`[lecodes] ${d}`),(b=c.onError)==null||b.call(c,{message:d,frames:u,stack:h instanceof Error?h.stack:void 0})},r=(c,h)=>{for(let f=e.length-1;f>=0;f--){const d=e[f];if(!d.sourceMap)continue;const p=Xt(c,d.sourceMap);if(p.length>0)return s(d,c,p,h)}const u=e[e.length-1];u&&$e(c)&&s(u,c,[],h)};let i=null;const o=()=>{const c=e[e.length-1],h=i;if(i=null,!h||!c)return;const u=new Error(h.message.replace(/^Error: /,""));u.stack=h.stack.join(`
17
+ `),s(c,u,c.sourceMap?Xt(u,c.sourceMap):[])},a=c=>r(c.error??c.message,c.message),l=c=>r(c.reason);return n.addEventListener("error",a),n.addEventListener("unhandledrejection",l),{track(c,h){const u={sourceMap:yi(c),onError:h};return e.push(u),{drop(){const f=e.indexOf(u);f>=0&&e.splice(f,1)}}},locate(c){var u;const h=(u=e[e.length-1])==null?void 0:u.sourceMap;return h?Xt(c,h):[]},runtimeLine(c){if(i&&/^\s+at /.test(c))return i.stack.push(c),!0;const h=bi.exec(c);if(!h||e.length===0)return!1;o();const[u,...f]=h[2].split(`
18
+ `);return i={message:(u??"").replace(/^JsTask /,""),stack:f},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",l),e.length=0}}},Tn=n=>{var l,c,h,u;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const f of s[1].split(";"))e.add(f);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((l=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:l[1])??null,o=((h=(c=t.match(/^\/\/ name: (.+)$/m))==null?void 0:c[1])==null?void 0:h.trim())??null,a=new Set((((u=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:u[1])??"").split(";").map(f=>f.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:ei(t)}},xi=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",Ei=n=>{const t=n.ownerDocument,e=t.defaultView??window;let s=1/0;const r=(d,p)=>{const y=Math.min(s,(e.devicePixelRatio||1)*fe(n));return{width:d,height:p,factor:y,pixelWidth:Math.max(1,Math.round(d*y)),pixelHeight:Math.max(1,Math.round(p*y))}};let i=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const o=[],a=d=>{d.width!==i.pixelWidth&&(d.width=i.pixelWidth),d.height!==i.pixelHeight&&(d.height=i.pixelHeight)},l=()=>{const d=t.createElement("canvas");return d.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(d),a(d),o.push(d),d},c=new Set,h=d=>{if(!(d.width<=0||d.height<=0)){i=d;for(const p of o)a(p);for(const p of c)p(i)}},u=new ResizeObserver(([d])=>{var v;if(!d)return;const{width:p,height:y}=d.contentRect,b=(v=d.devicePixelContentBoxSize)==null?void 0:v[0],x=r(p,y),m=b&&Math.abs(b.inlineSize-p*x.factor)<=1&&Math.abs(b.blockSize-y*x.factor)<=1;if(!b||!m){h(x);return}h({width:p,height:y,pixelWidth:Math.max(1,b.inlineSize),pixelHeight:Math.max(1,b.blockSize),factor:x.factor})});try{u.observe(n,{box:"device-pixel-content-box"})}catch{u.observe(n)}return{root:n,doc:t,win:e,size:()=>i,newCanvas:l,remeasure:d=>{d!==void 0&&(s=d>0?d:1/0);const p=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==i.pixelWidth||p.pixelHeight!==i.pixelHeight||p.factor!==i.factor)&&h(p)},onResize(d){return c.add(d),()=>{c.delete(d)}},destroy(){u.disconnect(),c.clear();for(const d of o)d.remove();o.length=0}}},Si=n=>{const t=new Map;let e=0,s=[];const r=new Set,i=l=>{r.has(l)||(r.add(l),console.warn(`[web-host] gl.${l}: this host's engine has no such call yet (a runtime module of an older build) — ignored`))},o=l=>Float32Array.from(l);return{facade:n?{setMatrix(l,c){var h;(h=n.creator())==null||h.setWorldMatrix(l,o(c))},setVisible(l,c){var h;(h=n.creator())==null||h.setVisible(l,c)},setCameraMatrix(l,c){var u;const h=n.creator();if(h&&!h.setCameraMatrix)return i("setCameraMatrix");(u=h==null?void 0:h.setCameraMatrix)==null||u.call(h,l,o(c))},setProjection(l,c,h,u){var d;const f=n.creator();if(f&&!f.setCameraProjectionMatrix)return i("setProjection");(d=f==null?void 0:f.setCameraProjectionMatrix)==null||d.call(f,l,o(c),h,u)},clearProjection(l){var c,h;(h=(c=n.creator())==null?void 0:c.clearCameraProjectionMatrix)==null||h.call(c,l)},setBackground(l,c,h=li){const u=n.creator();if(!u)return;if(!u.setSceneBackground||!n.surface)return i("setBackground");const f=c?n.surface.videoTexture(c):void 0;u.setSceneBackground(l,f??4294967295,Float32Array.from(h))},createExternalTexture:()=>null,onFrame(l){const c=e++;return t.set(c,l),()=>{t.delete(c)}},readPixels(l,c){if(!n.surface||n.presented()!==l){c(null,0,0);return}s.push({scene:l,then:c})},viewport:()=>ci(n.view,n.view.ownerDocument.defaultView??window)}:oi(),before(){if(t.size!==0)for(const l of[...t.values()])l()},after(){if(s.length===0||!(n!=null&&n.surface))return;const l=n.presented(),c=s.filter(u=>u.scene===l);for(const u of s)u.scene!==l&&u.then(null,0,0);if(s=c,c.length===0||!n.frameRendered())return;s=[];const h=n.surface.readPixels();for(const u of c)h?u.then(h.rgba.slice(),h.width,h.height):u.then(null,0,0)},worldChanged(){t.clear();const l=s;s=[];for(const c of l)c.then(null,0,0)}}},_i=(n,t)=>{const e=[],s=new Set;return{has:r=>s.has(r),register(r,i){s.has(r)||(s.add(r),i({registerView:(o,a,l=1)=>{e.push({id:r,version:l,kind:"view",name:o,factory:a})},registerService:(o,a,l=1)=>{e.push({id:r,version:l,kind:"service",name:o,factory:a})},putBuffer:ut,getBuffer:Z,gl:t}))},allow(r){var o,a;const i=new Set(r);for(const l of e){const c=i.has(l.id);l.kind==="view"?c?(o=n.registerView)==null||o.call(n,l.name,l.factory,l.version):(a=n.unregisterView)==null||a.call(n,l.name):c?n.registerService(l.name,l.factory,l.version):n.unregisterService(l.name)}}}},ki=n=>{const t=n.ownerDocument.createElement("div");t.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);",n.appendChild(t);const e=i=>Math.round(parseFloat(i)||0),s=()=>{const i=getComputedStyle(t);return{top:e(i.paddingTop),right:e(i.paddingRight),bottom:e(i.paddingBottom),left:e(i.paddingLeft)}};let r=null;return{set(i){r=i},current:()=>r??s(),destroy(){t.remove()}}},Ri={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world"},Ge="material:",Ti=n=>{const t=new Set;for(const e of n)e.startsWith(Ge)&&t.add(Ri[e.slice(Ge.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},Ai=""+new URL("assets/materials-BzTsWTWO.bin",import.meta.url).href,Mi=""+new URL("assets/materials-world-CQWt8TAm.bin",import.meta.url).href,Li=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,Pi=""+new URL("assets/uberarchive-Ok2HfJvn.bin",import.meta.url).href,Ci={base:Ai,world:Mi},Oi=n=>{const t=new Uint8Array(n.reduce((s,r)=>s+r.byteLength,0));let e=0;for(const s of n)t.set(new Uint8Array(s),e),e+=s.byteLength;return t.buffer},Ii=async n=>{const t=async o=>{const a=await fetch(o);if(!a.ok)throw new Error(`${o} → HTTP ${a.status}`);return a.arrayBuffer()},e=Ti(n).map(o=>Ci[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(Li),t(Pi),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:Oi(i)}:{}}},Fi=n=>{const t=()=>n.push(document.hidden?"pause":"resume"),e=()=>n.push("online"),s=()=>n.push("offline");return document.addEventListener("visibilitychange",t),window.addEventListener("online",e),window.addEventListener("offline",s),{table:{state:()=>document.hidden?"background":"active",isOnline:()=>navigator.onLine,openUrl(i){window.open(i,"_blank","noopener")},worldChange(){var i;(i=n.onWorldChange)==null||i.call(n)},setOrientation(i){var l,c,h,u;const o=i==="landscape"||i==="portrait"?i:"auto";if(n.onOrientation){n.onOrientation(o);return}const a=typeof screen<"u"?screen.orientation:void 0;if(a)try{o==="auto"?(l=a.unlock)==null||l.call(a):(u=(h=(c=a.lock)==null?void 0:c.call(a,o))==null?void 0:h.catch)==null||u.call(h,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},Ni=(n,t,e,s)=>{try{const r=document.createElement("input");r.type="file",r.multiple=e,s&&(r.accept=s),r.onchange=async()=>{const{files:i}=r;if(e){const o=[];if(!i)return n([]);for(let a of i)o.push([ut(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ut(await i[0].arrayBuffer()),i[0].name,i[0].size]])}},window.addEventListener("focus",()=>{setTimeout(()=>{(!r.files||r.files.length===0)&&n(e?[]:null)},300)},{once:!0}),r.click()}catch(r){t(r)}},An=n=>n==="camera"?"camera":n==="microphone"||n==="speech"?"microphone":n==="location"?"geolocation":null,Mn=(n,t,e)=>{const s=An(n);if(!s){e(`${n}: not a permission this host asks for`);return}const r=navigator.permissions;if(!(r!=null&&r.query)){t("prompt");return}r.query({name:s}).then(i=>t(i.state),()=>t("prompt"))},Ui=(n,t,e)=>{if(!An(n)){e(`${n}: not a permission this host asks for`);return}const s=()=>Mn(n,t,e);if(n==="location"){if(!navigator.geolocation){t("denied");return}navigator.geolocation.getCurrentPosition(()=>t("granted"),i=>i.code===i.PERMISSION_DENIED?t("denied"):s(),{timeout:15e3,maximumAge:1/0});return}const r=navigator.mediaDevices;if(!(r!=null&&r.getUserMedia)){t("denied");return}r.getUserMedia(n==="camera"?{video:!0}:{audio:!0}).then(i=>{for(const o of i.getTracks())o.stop();t("granted")},i=>{const o=i instanceof Error?i.name:"";o==="NotAllowedError"||o==="SecurityError"?t("denied"):s()})},Bi=n=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return window.devicePixelRatio||1},vibrate(){var t;try{(t=navigator.vibrate)==null||t.call(navigator,30)}catch{}},clipboardWrite(t){var e;(e=navigator.clipboard)==null||e.writeText(t).catch(()=>{})},clipboardRead(t,e){const s=navigator.clipboard;if(!(s!=null&&s.readText)){e("Clipboard is not available");return}s.readText().then(t,r=>e(r instanceof Error?r.message:"Clipboard read failed"))},share(t){const e=URL.createObjectURL(Wt(t)),s=document.createElement("a");s.href=e,s.download="image.png",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(e)},openFilePicker:(t,e,s,r)=>Ni(t,e,s,r??void 0),queryPermission:Mn,requestPermission:Ui}),Wi=(n={})=>({local:t=>hr(t),dispose:t=>or(t),request(t,e,s,r,i,o,a,l){if(t.startsWith("id:")){const u=Number(t.slice(3));o(u,Z(u)?200:404);return}const c={};for(let u=0;u+1<s.length;u+=2)c[s[u]]=s[u+1];let h;if(i.length>0){const u=new FormData;for(const f of i)f.key!==null&&(f.bufferId>0?u.append(f.key,Wt(f.bufferId),f.filename??void 0):u.append(f.key,f.value??""));h=u}else r!==null&&(h=r);(async()=>{var u;try{const f=await fetch(t,{method:e,headers:c,body:h,mode:"cors",credentials:"omit"}),d=l?(u=f.body)==null?void 0:u.getReader():void 0;if(!d){o(ut(await f.arrayBuffer()),f.status);return}const p=Number(f.headers.get("content-length"))||void 0,y=[];let b=0;for(;;){const{done:v,value:_}=await d.read();if(v)break;_&&(y.push(_),b+=_.length,l({loaded:b,total:p}))}const x=new Uint8Array(b);let m=0;for(const v of y)x.set(v,m),m+=v.length;o(ut(x.buffer),f.status)}catch(f){a(f instanceof Error?f.message:String(f))}})()},buffer:t=>{const e=Z(t);return e?new Uint8Array(e):null},putBuffer:t=>ut(t.slice().buffer),bufferSlice(t,e,s){const r=Z(t);if(!r)return null;const i=Math.max(0,Math.min(e,r.byteLength)),o=Math.max(i,Math.min(s,r.byteLength));return new Uint8Array(r,i,o-i)},systemBuffer:t=>{const e=n[t];return e?new Uint8Array(e):null}}),je=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Yt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Pt=4,qt=16,ze=16,Di=.5,Hi=n=>{const t=new Set;let e=null;const s=(E,R,U=-1,L=0)=>{e==null||e(E,R,U,L)},r=E=>{if(!E.code)return;const R=t.has(E.code);t.add(E.code),s(0,E.code,-1,R||E.repeat?1:0)},i=E=>{E.code&&t.delete(E.code)&&s(1,E.code)},o=()=>{for(const E of[...t])E.startsWith("Gamepad")||(t.delete(E),s(1,E))},{root:a}=n;let l=0,c=0,h=0,u=0,f=0,d=0,p=0,y=0,b=0,x=0;const m=E=>{if(E.pointerType&&E.pointerType!=="mouse")return;const R=a.getBoundingClientRect();l=E.clientX-R.left,c=E.clientY-R.top,h+=E.movementX||0,u+=E.movementY||0},v=E=>{const R=je[E.button];R&&(t.add(R),s(0,R))},_=E=>{const R=je[E.button];R&&t.delete(R)&&s(1,R)},T=E=>{const R=E.deltaMode===0?.01:1;f+=E.deltaX*R,d+=E.deltaY*R},P=E=>{document.pointerLockElement===a&&E.preventDefault()},O=[],I=[],F=[],$=()=>{var R,U;const E=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let L=0;L<Pt;L++){const tt=E[L]??null,J=!!tt&&tt.connected;if(J!==!!O[L]){if(O[L]=J,!J){for(const N of Yt)t.delete(N+"@"+L)&&(s(1,N,L),z(N));F[L]=[],I[L]=[0,0,0,0,0,0]}s(J?2:3,"",L)}if(!tt||!J)continue;const it=tt.axes,dt=tt.buttons,kt=((R=dt[6])==null?void 0:R.value)??0,S=((U=dt[7])==null?void 0:U.value)??0;I[L]=[it[0]??0,it[1]??0,it[2]??0,it[3]??0,kt,S];const C=F[L]??(F[L]=[]);for(let N=0;N<Yt.length;N++){const Q=dt[N],et=!!Q&&(Q.pressed||Q.value>Di);if(et===!!C[N])continue;C[N]=et;const Rt=Yt[N];et?t.add(Rt+"@"+L):t.delete(Rt+"@"+L),z(Rt),s(et?0:1,Rt,L)}}},z=E=>{let R=!1;for(let U=0;U<Pt&&!R;U++)t.has(E+"@"+U)&&(R=!0);R?t.add(E):t.delete(E)};let G=0;const Y=()=>{p=h,y=u,b=f,x=d,h=u=f=d=0,$(),G=requestAnimationFrame(Y)},g=n.windows.filter((E,R,U)=>E&&U.indexOf(E)===R);for(const E of g)n.keyboard!==!1&&(E.addEventListener("keydown",r),E.addEventListener("keyup",i)),E.addEventListener("blur",o);return a.addEventListener("pointermove",m,!0),a.addEventListener("mousedown",v,!0),window.addEventListener("mouseup",_,!0),a.addEventListener("wheel",T,{passive:!0,capture:!0}),a.addEventListener("contextmenu",P,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(Y)),{inputKey:(E,R)=>R>=0&&E.startsWith("Gamepad")?t.has(E+"@"+R):t.has(E),inputRead:E=>{var R;switch(E){case 0:return l;case 1:return c;case 2:return p;case 3:return y;case 4:return b;case 5:return x;case 6:return document.pointerLockElement===a?1:0;case 7:{let U=0;for(let L=0;L<Pt;L++)O[L]&&U++;return U}}if(E>=qt){const U=Math.floor((E-qt)/ze),L=(E-qt)%ze;return U>=Pt||!O[U]?0:L===0?1:((R=I[U])==null?void 0:R[L-1])??0}return 0},inputSetPointerLock:E=>{if(!E)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const R=a.requestPointerLock({unadjustedMovement:!0});return R&&typeof R.catch=="function"&&R.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:E=>{e=E},dispose:()=>{for(const E of g)E.removeEventListener("keydown",r),E.removeEventListener("keyup",i),E.removeEventListener("blur",o);a.removeEventListener("pointermove",m,!0),a.removeEventListener("mousedown",v,!0),window.removeEventListener("mouseup",_,!0),a.removeEventListener("wheel",T,!0),a.removeEventListener("contextmenu",P,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},$i=n=>{const t=Hi(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},Vi={createVideo:Sr,createAudio:_r,setVolume:kr,setPlaying:Rr,setLoop:Tr,time:Ar,setTime:Mr,duration:Lr,remove:Pr},Gi=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(f,d,p=1)=>{n.set(f,d),t.set(f,p)},unregisterService:f=>{n.delete(f),t.delete(f)},isServiceSupported:f=>n.has(f),serviceVersion:f=>t.get(f)??0,serviceOpen:(f,d,p)=>{const y=n.get(f);if(!y)return-1;const b=s++,x=y(d?JSON.parse(d):{},{emit:(m,v)=>{v===void 0?p(m):p(m,v)}});return e.set(b,x),b},serviceCall:(f,d,p,y,b)=>{const x=e.get(f);if(!(x!=null&&x.call)){b(`Service call "${d}": no live session or no call handler (serviceId ${f})`);return}try{Promise.resolve(x.call(d,Array.isArray(p)?p:[])).then(m=>{m===void 0?y():y(m)},m=>b(m instanceof Error?m.message:String(m)))}catch(m){b(m instanceof Error?m.message:String(m))}},serviceClose:f=>{var d,p;(p=(d=e.get(f))==null?void 0:d.close)==null||p.call(d),e.delete(f)},destroy:()=>{var f;for(const d of e.values())(f=d.close)==null||f.call(d);e.clear()}}},ji=()=>{const n=Gi();return{table:{supported:n.isServiceSupported,version:n.serviceVersion,open:n.serviceOpen,call:n.serviceCall,close:n.serviceClose},registerService:n.registerService,unregisterService:n.unregisterService,dispose:n.destroy}},zi=()=>{const n=[];return{table:{open(e,s){const r=new WebSocket(e);return r.addEventListener("open",()=>s("open")),r.addEventListener("message",i=>s("message",i.data)),r.addEventListener("close",i=>s("close",i.code)),r.addEventListener("error",()=>s("error")),n.push(r),n.length-1},send(e,s){var r;(r=n[e])==null||r.send(s)},close(e){var s;(s=n[e])==null||s.close()}},dispose(){for(const e of n)e.readyState===WebSocket.OPEN&&e.close();n.length=0}}},Ki=n=>{const t=e=>`lecodes:${n}:${e}`;return{load(e){try{return window.localStorage.getItem(t(e))}catch{return null}},save(e,s){try{window.localStorage.setItem(t(e),s)}catch{}}}},Ke=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},Xi={fetch:ir,getBuffer:Z,getBlob:Wt,putBuffer:ut,putLocalBuffer:ar,hasLocalBuffer:cr,getLocalName:lr,getPlayer:de,removePlayers:gn},Yi=(n,t)=>({nodeFactory(){},setPropertyString(){},setPropertyInt(){},setFlags(){},insertNode(){},removeNode(){},releaseNode(){},openView(e,s,r){n(e,r)},dropView(e,s,r){t(e,r)},closeView(){n(-1,0)},layerOpen(){},layerClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),qi=async(n,t={})=>{var kt;const e=t.header,s=t.profile??(e?xi(e):"full"),r=(e==null?void 0:e.preloads)??new Set,i=t.ui!==!1,o=s==="full",a=s==="2d"||s==="full"&&!!(e!=null&&e.is2d),l=Ei(n),{doc:c,win:h}=l,u=i?Promise.all([si(void 0,c),ni((e==null?void 0:e.bootFonts)??[],c)]):null,f=o?di(l,r.has("capture")):null,d=a?pi(l):null,p=i?l.newCanvas():null,y=vi(h,o);o&&sr();const[b,x]=await Promise.all([Gn(s,{glContext:f==null?void 0:f.context,glOptions:f==null?void 0:f.options,gl2dContext:d==null?void 0:d.context,gl2dOptions:d==null?void 0:d.options,moduleArgs:{print:S=>{y.runtimeLine(S)?console.debug(S):console.log(S)},printErr:S=>{console.error(S)}}}),o?Ii(r):Promise.resolve({})]),m=(S,C)=>{const N=b.stringToNewUTF8(S);try{return C(N)}finally{b._free(N)}};let v=null,_=-1,T=-1,P=-1;const O=(S,C)=>{T=S,P=S===Tt?C:-1,S===Tt&&(f==null||f.show()),S===Pe&&(d==null||d.show()),v&&S===Tt&&C!==_&&(_=C,v.openScene(C))},I=S=>{S!==T&&(S===Tt&&(f==null||f.hide(),v&&_>=0&&(_=-1,v.closeScene())),S===Pe&&(d==null||d.hide()))};let F=null;const $=Si(o||t.engine3d?{creator:()=>F==null?void 0:F._creator,surface:f,presented:()=>P,frameRendered:()=>{var S;return!!((S=b._creatorWebFrameRendered)!=null&&S.call(b))},view:(f==null?void 0:f.canvas)??n}:null),z=Zs();let G=t.keyboardBand??0;const g=p?$s(n,{M:b,canvas:p,canvasHost:z,keyboardHeight:()=>{const S=h.visualViewport,C=S?Math.max(0,Math.round((h.innerHeight-S.height-S.offsetTop)/fe(n))):0;return C>0?C:G},onKeyboard:t.onKeyboard}):null;g&&(g.ui.onDestination=O,g.ui.onDropped=I);const M=Fi({onOrientation:t.onOrientation,onWorldChange:()=>$.worldChanged(),push:(S,C)=>{S==="url"&&C!==void 0&&m(C,N=>b._creatorWebSetLaunchUrl(N)),m(S,N=>{C===void 0?b._creatorWebAppEvent(N,0):m(C,Q=>b._creatorWebAppEvent(N,Q))})}}),A=zi(),W=ji(),q=$i({windows:[...new Set([h,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,push:(S,C,N,Q)=>m(C,et=>b._creatorWebInputEvent(S,et,N,Q)),keyboardHeight:()=>(g==null?void 0:g.ui.keyboardHeight())??0}),_t={ui:(g==null?void 0:g.ui)??Yi(O,I),app:M.table,device:Bi(t.language??(()=>(h.navigator.language||"en").slice(0,2))),fetch:Wi(x),storage:Ki(t.project??(e==null?void 0:e.name)??"app"),socket:A.table,service:W.table,input:q.table,media:Vi,canvas:z.table,...f?{gl:f.table(b)}:{},...d?{scene2d:d.table(b)}:{}},E=Ke(),R=E.global;F=R,Zn(b,{host:_t,world:E,newWorld:()=>{const S=Ke();return F=S.global,S}});const U=_i({...g?{registerView:(S,C,N)=>g.ui.registerView(S,C,N),unregisterView:S=>g.ui.unregisterView(S)}:{},registerService:W.registerService,unregisterService:W.unregisterService},$.facade);b._creatorWebInit(),t.launchUrl&&m(t.launchUrl,S=>b._creatorWebSetLaunchUrl(S)),g==null||g.ui.install(),!o&&t.engine3d&&(v=await t.engine3d({newCanvas:l.newCanvas,preloads:r,canvasHost:z,stores:Xi}),Object.defineProperty(R,"_creator",{value:v,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((kt=R._creator)==null||kt.createEngine());const L=ki(n);t.safeArea&&L.set(t.safeArea);const tt=S=>{var C;f==null||f.resize(),d==null||d.resize(),(C=v==null?void 0:v._onResize)==null||C.call(v,S.width,S.height,S.factor),g?(g.resize(S.width,S.height,S.factor),g.setSafeArea(L.current())):b._creatorWebResize(S.width,S.height)};l.onResize(tt),tt(l.size());let J=0;const it=S=>{J=h.requestAnimationFrame(it),$.before(),f==null||f.frame(),b._creatorWebTick(S),$.after(),d==null||d.frame(S),g&&(g.ui.layoutFrame(),g.ui.tickHover(),g.render())};J=h.requestAnimationFrame(it),await u;let dt=!1;return{profile:s,M:b,world:R,ui:(g==null?void 0:g.ui)??null,engine3d:()=>v,getBuffer:S=>Z(S),run(S,C={}){const N=C.header??Tn(S);if(!ii(N.sdk,He))throw new Error(`This app was built with LeCodes SDK ${N.sdk??"older than 2.0"}; this host runs SDK ${He}. It needs a new build.`);const Q=y.track(S,C.onError);return U.allow(N.plugins),m(S,et=>b._creatorWebRun(et)),{dispose:Q.drop}},registerPlugin:(S,C)=>U.register(S,C),hasPlugin:U.has,locate:y.locate,safeArea:()=>L.current(),setSafeArea(S){L.set(S),g==null||g.setSafeArea(L.current())},setKeyboardBand(S){G=S??0,g==null||g.ui.refreshKeyboard()},remeasure:l.remeasure,emitAppEvent:M.emit,destroy(){var S;dt||(dt=!0,h.cancelAnimationFrame(J),y.dispose(),g==null||g.destroy(),q.dispose(),A.dispose(),W.dispose(),M.dispose(),gn(),L.destroy(),(S=v==null?void 0:v._dispose)==null||S.call(v),f==null||f.destroy(),d==null||d.destroy(),l.destroy())}}},Ji=(n,t)=>new Promise(e=>{const s=n.ownerDocument.defaultView??window;s.requestAnimationFrame(()=>{try{const r=[...n.querySelectorAll("canvas")].filter(c=>c.width>0&&c.height>0&&s.getComputedStyle(c).display!=="none");if(r.length===0){e(null);return}const i=n.getBoundingClientRect(),o=t??Math.max(...r.map(c=>c.width))/Math.max(1,i.width),a=n.ownerDocument.createElement("canvas");a.width=Math.max(1,Math.round(i.width*o)),a.height=Math.max(1,Math.round(i.height*o));const l=a.getContext("2d");if(!l){e(null);return}l.fillStyle="#000000",l.fillRect(0,0,a.width,a.height);for(const c of r)l.drawImage(c,0,0,c.width,c.height,0,0,a.width,a.height);e(a.toDataURL("image/png"))}catch{e(null)}})}),Qi=n=>{if(typeof n=="string")return n;if(n instanceof Error)return n.stack?`${String(n)}
19
+ ${n.stack}`:String(n);try{return JSON.stringify(n)}catch{return String(n)}},Zi=(n,t)=>{const e=o=>{fetch(`${n}/log`,{method:"POST",body:JSON.stringify(o),headers:{"content-type":"application/json"},keepalive:!0}).catch(()=>{})};let s=-1;const r=async()=>{try{const{v:o}=await(await fetch(`${n}/version`,{cache:"no-store"})).json();typeof o=="number"&&t(o)}catch{}setTimeout(r,2500)};setTimeout(r,2500);const i=()=>{let o;try{o=new WebSocket(n.replace(/^http/,"ws")+"/ws")}catch{return}o.onopen=()=>o.send(JSON.stringify({type:"hello",v:s})),o.onmessage=a=>{let l={};try{l=JSON.parse(String(a.data))}catch{return}l.type==="reload"&&typeof l.v=="number"&&t(l.v)},o.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:o=>`${n}/bundle.js?t=web&v=${o}`,versionOf(o,a){const l=Number(o.headers.get("x-lecodes-v"));return o.headers.has("x-lecodes-v")&&Number.isFinite(l)?l:a},ran(o){s=o},log:(o,a)=>e({type:"log",level:o,text:a.map(Qi).join(" ")}),error:o=>e({type:"error",text:o})}},to={ar:()=>D(()=>import("./assets/ar-CHvaraG4.js"),[],import.meta.url).then(n=>t=>n.register(t)),"audio-recorder":()=>D(()=>import("./assets/audio-recorder-Bt-Caym7.js"),[],import.meta.url).then(n=>t=>n.register(t)),browser:()=>D(()=>import("./assets/browser-BpFb50ko.js"),[],import.meta.url).then(n=>t=>n.register(t)),camera:()=>D(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>D(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>D(()=>import("./assets/map-8PhtP3jn.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>D(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>D(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t)),speech:()=>D(()=>import("./assets/speech-DzDPVK_j.js"),[],import.meta.url).then(n=>t=>n.register(t)),webrtc:()=>D(()=>import("./assets/webrtc-CbCltXvl.js"),[],import.meta.url).then(n=>t=>n.register(t))},eo=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=to[e];if(!(!s||n.hasPlugin(e)))try{n.registerPlugin(e,await s())}catch(r){console.warn(`[lecodes] the "${e}" plugin failed to load: ${r instanceof Error?r.message:String(r)}`)}}))},ge=n=>typeof n=="object"&&n!==null,lt=n=>typeof n=="number"&&Number.isFinite(n),no=n=>{if(!ge(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return lt(n.x)&&lt(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return lt(n.node)?{ask:"node",node:n.node}:null;default:return null}},Ln=n=>{if(!ge(n))return null;const t=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0?Math.round(s):0,e=Array.isArray(n.bars)?n.bars.filter(s=>s==="top"||s==="right"||s==="bottom"||s==="left"):void 0;return{top:t(n.top),right:t(n.right),bottom:t(n.bottom),left:t(n.left),...e?{bars:e}:{}}},ro=n=>{const t=Number(n.get("keyboard-band"));return Number.isFinite(t)&&t>0?t:null},so=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return Ln({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},io=n=>{if(!ge(n))return null;switch(n.type){case"lecodes:run":return typeof n.src=="string"?{type:"lecodes:run",src:n.src}:null;case"lecodes:reload":return{type:"lecodes:reload"};case"lecodes:safe-area":return{type:"lecodes:safe-area",insets:Ln(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:keyboard-band":return{type:"lecodes:keyboard-band",height:lt(n.height)&&n.height>0?n.height:null};case"lecodes:inspect":{const t=no(n.question);return t&&lt(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!lt(n.request))return null;const t=lt(n.pixelRatio)&&n.pixelRatio>0?Math.min(4,n.pixelRatio):void 0;return{type:"lecodes:capture",request:n.request,...t!==void 0?{pixelRatio:t}:{}}}default:return null}},oo=(n,t)=>{try{const e=new URL(n,t);return e.origin===new URL(t).origin&&(e.protocol==="http:"||e.protocol==="https:")?e.href:null}catch{return null}},ao=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=io(r.data);i&&t(i)};return n.addEventListener("message",s),{embedded:e!==null,post(r){e==null||e.postMessage(r,"*")},close(){n.removeEventListener("message",s)}}},Ht=window.lecodesPlayerConfig??{},bt=document.getElementById("app"),Jt=document.getElementById("loader"),Xe=document.getElementById("error"),st=new URLSearchParams(location.search),Pn=n=>Jt==null?void 0:Jt.classList.toggle("on",n),Cn=n=>{Xe&&(Xe.textContent=window.parent===window?n:"")};let le=Ht.language||st.get("lang")||(navigator.language||"en").slice(0,2),Ft=Ht.safeArea??so(st),Nt=Ht.keyboardBand??ro(st),B=null;const Ye=()=>{var n;return(n=B==null?void 0:B.world)==null?void 0:n._creatorTree},Ut=st.has("test")?{ready:!1,dump:()=>{var n;return((n=Ye())==null?void 0:n.debugDump())??'{"roots":[]}'},rect:n=>{var s;const t=(s=Ye())==null?void 0:s.getBoundingClientRect(n);if(!t)return null;const e=bt.getBoundingClientRect();return[e.left+t[0],e.top+t[1],t[2],t[3]]}}:null;Ut&&(window.lecodesTest=Ut);const co=st.has("inspect"),he=co?D(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url):null;let wt=null;const lo=async(n,t)=>{const{createInspector:e}=await(he??D(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url));B&&wt===null&&(wt=e(B)),X.post({type:"lecodes:inspected",request:n,answer:(wt==null?void 0:wt.answer(t))??null})},qe=st.has("dev")?new URL(st.get("dev")||"..",location.href).href.replace(/\/$/,""):null,Je=n=>{var s;const t=n.frames[0],e=t?`
20
20
  at ${t.source}:${t.line}:${t.column}${t.fn?` (${t.fn})`:""}`:(s=n.nativeFrames)!=null&&s.length?`
21
- in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},Rn=n=>{Tn(Ye(n)),J.post({type:"lecodes:error",error:n}),V==null||V.error(Ye(n))},An=n=>Rn({message:n,frames:[]});let ct=null,Jt=!1,Qt=null;const Ki=async n=>{_n(!0),Tn(""),W==null||W.destroy(),W=null,yt=null,wt.replaceChildren();const t=await fetch(n.src,{cache:"no-store"});if(!t.ok)throw new Error(t.status===503?"No successful compile yet — check the terminal.":`${n.src} → HTTP ${t.status}`);const e=await t.text(),s=Sn(e);W=await Oi(wt,{header:s,language:()=>ce,launchUrl:location.href,...Pt?{safeArea:Pt}:{},...Ct?{keyboardBand:Ct}:{},...J.embedded?{onKeyboard:(r,i)=>J.post({type:"lecodes:keyboard",height:r,duration:i})}:{},...J.embedded?{onOrientation:r=>J.post({type:"lecodes:orientation",mode:r})}:{}}),await Wi(W,s.plugins),le&&(await le).recordSites(W),W.run(e,{onError:Rn}),Ot&&(Ot.ready=!0),V&&n.version!==void 0&&(It=V.versionOf(t,n.version),V.ran(It)),J.post({type:"lecodes:ready",src:n.src})},ht=n=>{if(Jt){Qt=n;return}Jt=!0,ct=n,Ki(n).catch(t=>An(t instanceof Error?t.message:String(t))).finally(()=>{_n(!1),Jt=!1;const t=Qt;Qt=null,t&&ht(t)})},pe=n=>{const t=Gi(n,location.href);t?ht({src:t}):An(`The player runs bundles of its own origin only: ${n}`)},Mn=n=>{Pt=n,W==null||W.setSafeArea(Pt)},Xi=n=>{Ct=n,W==null||W.setKeyboardBand(Ct)},Ln=async n=>({image:W?await Ii(wt,n):null,width:wt.clientWidth,height:wt.clientHeight}),J=Vi(window,n=>{switch(n.type){case"lecodes:run":pe(n.src);break;case"lecodes:reload":ct&&ht(ct);break;case"lecodes:safe-area":Mn(n.insets);break;case"lecodes:keyboard-band":Xi(n.height);break;case"lecodes:inspect":zi(n.request,n.question);break;case"lecodes:capture":Ln(n.pixelRatio).then(t=>J.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===ce)break;ce=n.language,ct&&ht(ct);break}});let It=-1;const V=Xe?Ni(Xe,n=>{It>=0&&n!==It&&ht({src:V.bundleUrl(n),version:n})}):null;if(V||J.embedded){let n=!1;for(const t of["log","warn","error"]){const e=console[t];console[t]=(...s)=>{if(e.apply(console,s),!(n||typeof s[0]=="string"&&s[0].startsWith("[lecodes] "))){n=!0;try{V==null||V.log(t,s),J.post({type:"lecodes:log",level:t,text:s.map(r=>typeof r=="string"?r:r instanceof Error?String(r):(()=>{try{return JSON.stringify(r)}catch{return String(r)}})()).join(" ")})}finally{n=!1}}}}}window.lecodesPlayer={version:"68d8e91-2026-10-13",get host(){return W},run:pe,reload(){ct&&ht(ct)},setSafeArea:Mn,capture:async n=>(await Ln(n)).image};const qe=Ut.src??rt.get("src");V?ht({src:V.bundleUrl(0),version:0}):qe&&pe(qe);export{j as _};
21
+ in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},On=n=>{Cn(Je(n)),X.post({type:"lecodes:error",error:n}),j==null||j.error(Je(n))},In=n=>On({message:n,frames:[]});let ht=null,Qt=!1,Zt=null;const ho=async n=>{Pn(!0),Cn(""),B==null||B.destroy(),B=null,wt=null,bt.replaceChildren();const t=await fetch(n.src,{cache:"no-store"});if(!t.ok)throw new Error(t.status===503?"No successful compile yet — check the terminal.":`${n.src} → HTTP ${t.status}`);const e=await t.text(),s=Tn(e);B=await qi(bt,{header:s,language:()=>le,launchUrl:location.href,...Ft?{safeArea:Ft}:{},...Nt?{keyboardBand:Nt}:{},...X.embedded?{onKeyboard:(r,i)=>X.post({type:"lecodes:keyboard",height:r,duration:i})}:{},...X.embedded?{onOrientation:r=>X.post({type:"lecodes:orientation",mode:r})}:{}}),await eo(B,s.plugins),he&&(await he).recordSites(B),B.run(e,{onError:On}),Ut&&(Ut.ready=!0),j&&n.version!==void 0&&(Bt=j.versionOf(t,n.version),j.ran(Bt)),X.post({type:"lecodes:ready",src:n.src})},ft=n=>{if(Qt){Zt=n;return}Qt=!0,ht=n,ho(n).catch(t=>In(t instanceof Error?t.message:String(t))).finally(()=>{Pn(!1),Qt=!1;const t=Zt;Zt=null,t&&ft(t)})},me=n=>{const t=oo(n,location.href);t?ft({src:t}):In(`The player runs bundles of its own origin only: ${n}`)},Fn=n=>{Ft=n,B==null||B.setSafeArea(Ft)},uo=n=>{Nt=n,B==null||B.setKeyboardBand(Nt)},Nn=async n=>({image:B?await Ji(bt,n):null,width:bt.clientWidth,height:bt.clientHeight}),X=ao(window,n=>{switch(n.type){case"lecodes:run":me(n.src);break;case"lecodes:reload":ht&&ft(ht);break;case"lecodes:safe-area":Fn(n.insets);break;case"lecodes:keyboard-band":uo(n.height);break;case"lecodes:inspect":lo(n.request,n.question);break;case"lecodes:capture":Nn(n.pixelRatio).then(t=>X.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===le)break;le=n.language,ht&&ft(ht);break}});let Bt=-1;const j=qe?Zi(qe,n=>{Bt>=0&&n!==Bt&&ft({src:j.bundleUrl(n),version:n})}):null;if(j||X.embedded){let n=!1;for(const t of["log","warn","error"]){const e=console[t];console[t]=(...s)=>{if(e.apply(console,s),!(n||typeof s[0]=="string"&&s[0].startsWith("[lecodes] "))){n=!0;try{j==null||j.log(t,s),X.post({type:"lecodes:log",level:t,text:s.map(r=>typeof r=="string"?r:r instanceof Error?String(r):(()=>{try{return JSON.stringify(r)}catch{return String(r)}})()).join(" ")})}finally{n=!1}}}}}window.lecodesPlayer={version:"bff3248-2026-10-14",get host(){return B},run:me,reload(){ht&&ft(ht)},setSafeArea:Fn,capture:async n=>(await Nn(n)).image};const Qe=Ht.src??st.get("src");j?ft({src:j.bundleUrl(0),version:0}):Qe&&me(Qe);export{D as _};