lecodes-web-player 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/VERSION.json +3 -3
- package/dist/assets/{inspect-C7x78PNs.js → inspect-DdJ50Kun.js} +2 -2
- package/dist/player.js +17 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ window.addEventListener("message", (e) => {
|
|
|
47
47
|
| `lecodes:reload` | run the current bundle again, fetched again |
|
|
48
48
|
| `lecodes:safe-area` `{ insets }` | `{ top, right, bottom, left, bars? }` in px — what the page drew over the player's edges; `null` = the browser's own insets |
|
|
49
49
|
| `lecodes:language` `{ language }` | `device.language`; the bundle runs again in it |
|
|
50
|
+
| `lecodes:inspect` `{ request, question }` | a question about the app's UI: `{ ask: "tree" }`, `{ ask: "text" }`, `{ ask: "at", x, y }`, `{ ask: "node", node }` |
|
|
51
|
+
| `lecodes:capture` `{ request, pixelRatio? }` | the app's picture |
|
|
50
52
|
|
|
51
53
|
| from the player | |
|
|
52
54
|
|---|---|
|
|
@@ -54,9 +56,30 @@ window.addEventListener("message", (e) => {
|
|
|
54
56
|
| `lecodes:error` `{ error }` | the bundle could not start, or threw — mapped to its source |
|
|
55
57
|
| `lecodes:log` `{ level, text }` | the console |
|
|
56
58
|
| `lecodes:orientation` `{ mode }` | the app called `app.setOrientation` |
|
|
59
|
+
| `lecodes:inspected` `{ request, answer }` | the answer to a question |
|
|
60
|
+
| `lecodes:captured` `{ request, image, width, height }` | the picture as a `data:image/png` url (`null`: nothing painted, or not readable), its size in logical px |
|
|
57
61
|
|
|
58
62
|
A message is accepted from the parent frame only.
|
|
59
63
|
|
|
64
|
+
## In a page of your own
|
|
65
|
+
|
|
66
|
+
A page that IS the app — a published link opened on a phone — loads the player's module into
|
|
67
|
+
itself: no frame, no `<iframe>`. The page has the elements the player fills (`#app`, and
|
|
68
|
+
optionally `#loader`, `#error`), says what to run before the module does, and drives it through
|
|
69
|
+
`window.lecodesPlayer`:
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<div id="app"></div>
|
|
73
|
+
<script>window.lecodesPlayerConfig = { src: "/apps/demo/app.js", language: "en", safeArea: { top: 48, right: 0, bottom: 0, left: 0 } }</script>
|
|
74
|
+
<script type="module" src="/player/player.js"></script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
lecodesPlayer.setSafeArea({ top: 0, right: 0, bottom: 0, left: 0 }) // the page's banner went away
|
|
79
|
+
lecodesPlayer.run("/apps/other/app.js")
|
|
80
|
+
const png = await lecodesPlayer.capture()
|
|
81
|
+
```
|
|
82
|
+
|
|
60
83
|
## Trust
|
|
61
84
|
|
|
62
85
|
A bundle runs in the page's own realm: it reaches `window`, `localStorage` and the cookies of the
|
package/dist/VERSION.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const h=new Map,
|
|
2
|
-
`):t.text??t.value;return n?n.length>200?n.slice(0,200)+"…":n:void 0},S=t=>({x:a(t.rect.x),y:a(t.rect.y),width:a(t.rect.width),height:a(t.rect.height)}),$=t=>({id:t.id,type:t.type,rect:S(t),...t.name?{name:t.name}:{},...x(t)?{text:x(t).slice(0,40)}:{},children:t.children.map($)}),D=t=>{const n=t.ui;if(!n)return null;const i=()=>n.frame().filter(e=>!e.leaving),f=e=>{const r=(l,u)=>{const s=[...u,l];if(l.id===e)return s;for(const b of l.children){const d=r(b,s);if(d)return d}return null};for(const l of i()){const u=r(l.tree,[]);if(u)return u}return null},c=(e,r)=>{const l=s=>e>=s.rect.x&&e<s.rect.x+s.rect.width&&r>=s.rect.y&&r<s.rect.y+s.rect.height,u=i();for(let s=u.length-1;s>=0;s--){let b=null;const d=y=>{const m=l(y);if(m&&(b=y),!(y.clip&&!m))for(const g of y.children)d(g)};if(d(u[s].tree),b)return b;if(u[s].backdrop)return u[s].tree}return null},o=e=>{const r=e==null?void 0:e[e.length-1];if(!e||!r)return null;const[l,u,s,b]=n.paddingOf(r.id).map(a),d=h.get(r.id),y=d?t.locate(d.site).find(p=>!p.source.includes("__sdk")):void 0,m=k(d==null?void 0:d.element.deref()),g=r.state?Object.entries(r.state).filter(([,p])=>p===!0).map(([p])=>p):[];return{id:r.id,type:r.type,rect:S(r),...r.name?{name:r.name}:{},...x(r)!==void 0?{text:x(r)}:{},padding:{top:u,right:s,bottom:b,left:l},...m?{set:m}:{},style:
|
|
1
|
+
const h=new Map,P=t=>{h.clear();const n=t.ui;globalThis.__lecodesCaptureSites=n?(i,f,c)=>{h.set(n.lastCreated,{site:f,element:new WeakRef(c)})}:void 0},j=(t,n=0)=>{var i;return typeof t=="function"?"ƒ":t===null||typeof t!="object"?t:Array.isArray(t)?n<3?t.map(f=>j(f,n+1)):"[…]":Object.getPrototypeOf(t)!==Object.prototype?`${((i=t.constructor)==null?void 0:i.name)??"object"}`:n>=3?"{…}":Object.fromEntries(Object.entries(t).filter(([,f])=>f!==void 0).map(([f,c])=>[f,j(c,n+1)]))},k=t=>{const n=t==null?void 0:t._style;if(!n||typeof n!="object")return;const i=j(n);return Object.keys(i).length>0?i:void 0},w=t=>"#"+(t>>>0).toString(16).padStart(8,"0"),a=t=>Math.round(t*100)/100,A={opacity:1,dim:0,overflow:"visible",scrollAxis:"y",letterSpacing:0,lineClamp:0,textDecoration:"none",fontStyle:"normal",textAlign:"start",textOverflow:"ellipsis",backgroundSize:"cover",objectFit:"cover",inputType:"text"},_=new Set(["color","fontSize","fontFamily","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","textDecoration","lineClamp","textOverflow"]),C=new Set(["placeholder","placeholderColor","inputType"]),F=t=>{const n=t;return n.x===50&&n.y===50&&n.xPercent&&n.yPercent},O=t=>Array.isArray(t)?t.map(n=>typeof n=="object"&&n!==null?O(n):String(n)).join(" "):typeof t=="object"&&t!==null?Object.entries(t).map(([n,i])=>`${n}: ${typeof i=="object"&&i!==null?O(i):String(i)}`).join(", "):String(t),T=(t,n)=>{const i={},f=t==="text"||t==="input"||t==="textarea";for(const[c,o]of Object.entries(n))if(!(o==null||o==="")&&A[c]!==o&&!(_.has(c)&&!f)&&!(C.has(c)&&t!=="input"&&t!=="textarea")&&!(c==="objectFit"&&t!=="image"&&t!=="video")&&!(c==="transformOrigin"&&F(o))&&!(typeof o=="number"&&/color$/i.test(c)&&(o&255)===0))if(typeof o=="number"&&/color$/i.test(c))i[c]=w(o);else if(c==="border"&&typeof o=="object"){const e=Object.entries(o).filter(([,r])=>r&&r.width>0).map(([r,l])=>[r,`${a(l.width)}px ${w(l.color)}`]);if(e.length===4&&e.every(([,r])=>r===e[0][1]))i.border=e[0][1];else for(const[r,l]of e)i[`border${r[0].toUpperCase()}${r.slice(1)}`]=l}else if(c==="borderRadius"&&typeof o=="object"){const e=o;(e.tl||e.tr||e.br||e.bl)&&(i[c]=e.tl===e.tr&&e.tr===e.br&&e.br===e.bl?e.tl:[e.tl,e.tr,e.br,e.bl].map(a).join(" "))}else if(c==="backgroundGradients")Array.isArray(o)&&o.length>0&&(i[c]=`${o.length} gradient${o.length>1?"s":""}`);else if(c==="transform"&&Array.isArray(o))i[c]=`matrix(${o.map(e=>a(Number(e))).join(", ")})`;else if(c==="transformOrigin"&&typeof o=="object"){const e=o;i[c]=`${a(e.x)}${e.xPercent?"%":"px"} ${a(e.y)}${e.yPercent?"%":"px"}`}else typeof o=="object"?i[c]=O(o):i[c]=o;return i},x=t=>{const n=t.lines?t.lines.join(`
|
|
2
|
+
`):t.text??t.value;return n?n.length>200?n.slice(0,200)+"…":n:void 0},S=t=>({x:a(t.rect.x),y:a(t.rect.y),width:a(t.rect.width),height:a(t.rect.height)}),$=t=>({id:t.id,type:t.type,rect:S(t),...t.name?{name:t.name}:{},...x(t)?{text:x(t).slice(0,40)}:{},children:t.children.map($)}),D=t=>{const n=t.ui;if(!n)return null;const i=()=>n.frame().filter(e=>!e.leaving),f=e=>{const r=(l,u)=>{const s=[...u,l];if(l.id===e)return s;for(const b of l.children){const d=r(b,s);if(d)return d}return null};for(const l of i()){const u=r(l.tree,[]);if(u)return u}return null},c=(e,r)=>{const l=s=>e>=s.rect.x&&e<s.rect.x+s.rect.width&&r>=s.rect.y&&r<s.rect.y+s.rect.height,u=i();for(let s=u.length-1;s>=0;s--){let b=null;const d=y=>{const m=l(y);if(m&&(b=y),!(y.clip&&!m))for(const g of y.children)d(g)};if(d(u[s].tree),b)return b;if(u[s].backdrop)return u[s].tree}return null},o=e=>{const r=e==null?void 0:e[e.length-1];if(!e||!r)return null;const[l,u,s,b]=n.paddingOf(r.id).map(a),d=h.get(r.id),y=d?t.locate(d.site).find(p=>!p.source.includes("__sdk")):void 0,m=k(d==null?void 0:d.element.deref()),g=r.state?Object.entries(r.state).filter(([,p])=>p===!0).map(([p])=>p):[];return{id:r.id,type:r.type,rect:S(r),...r.name?{name:r.name}:{},...x(r)!==void 0?{text:x(r)}:{},padding:{top:u,right:s,bottom:b,left:l},...m?{set:m}:{},style:T(r.type,r.style),...g.length>0?{state:g}:{},...r.scroll?{scroll:{axis:r.scroll.axis,offset:a(r.scroll.offset),content:a(r.scroll.content)}}:{},...y?{source:{file:y.source.replace(/^\//,""),line:y.line,column:y.column}}:{},path:e.map(p=>({id:p.id,type:p.type,...p.name?{name:p.name}:{}}))}};return{answer(e){switch(e.ask){case"tree":return{ask:"tree",layers:i().map(r=>({kind:r.widget?"widget":"screen",tree:$(r.tree)}))};case"text":return{ask:"text",text:n.toText()};case"at":{const r=c(e.x,e.y);return{ask:"at",node:r?o(f(r.id)):null}}case"node":return{ask:"node",node:o(f(e.node))}}}}};export{D as createInspector,P as recordSites};
|
package/dist/player.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Sn=Object.defineProperty;var _n=(n,t,e)=>t in n?Sn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var w=(n,t,e)=>_n(n,typeof t!="symbol"?t+"":t,e);(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 Tn="modulepreload",kn=function(n,t){return new URL(n,t).href},ue={},q=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=kn(c,s),c in ue)return;ue[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!s)for(let b=a.length-1;b>=0;b--){const y=a[b];if(y.href===c&&(!d||y.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${u}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":Tn,d||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),d)return new Promise((b,y)=>{p.addEventListener("load",b),p.addEventListener("error",()=>y(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)})},Rn={full:()=>q(()=>import("./assets/creator-full-BBXzQlhq.js"),[],import.meta.url),"2d":()=>q(()=>import("./assets/creator-2d-D9WKYM6h.js"),[],import.meta.url),ui:()=>q(()=>import("./assets/creator-ui-_1Z_AX2M.js"),[],import.meta.url)},An={full:()=>new URL(""+new URL("assets/creator-full-D2dSDdDj.wasm",import.meta.url).href,import.meta.url).href,"2d":()=>new URL(""+new URL("assets/creator-2d-ukvEmNEp.wasm",import.meta.url).href,import.meta.url).href,ui:()=>new URL(""+new URL("assets/creator-ui-DIc92ion.wasm",import.meta.url).href,import.meta.url).href},Ln=async(n,t={})=>{const e=(await Rn[n]()).default,s=An[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,Ve=2,ze=3,de=4,Mn=5,Pn=6,Cn=7,fe=8,Yt=15,Xe=4293918720,xt=n=>(Xe|n<<16)>>>0,On=xt(je),In=xt(Ve),Fn=xt(ze),Nn=xt(Yt),pe=n=>(n&4293918720)>>>0===Xe?n>>>16&15:0,ge=64*1024;class Un{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(ge),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=On:e===null?i=In:typeof e=="boolean"?(i=Fn,r=e?1:0):(r=o=this.alloc(e),i=xt(typeof e=="function"?Mn:typeof e=="string"?Pn:Array.isArray(e)?Cn:typeof e=="object"?de:fe)),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]=Nn}decode(t,e){switch(pe(e)){case 0:return this.scratch.setUint32(0,t,!0),this.scratch.setUint32(4,e,!0),this.scratch.getFloat64(0,!0);case je:case Yt:return;case Ve: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=pe(s);if(r===Yt)return{value:void 0,threw:!0};const i=this.decode(e,s);return r>=de&&r<=fe&&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
|
|
4
|
-
`+
|
|
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))),
|
|
6
|
-
`).map(r=>{if(tt.lastIndex=0,!tt.test(r))return r;const i=
|
|
7
|
-
`):null}
|
|
8
|
-
`))if(
|
|
9
|
-
`+e)})};let pe=!1;const Hn=()=>{pe||(pe=!0,addEventListener("error",n=>fe(n.error)),addEventListener("unhandledrejection",n=>fe(n.reason)))},H=[null];new TextDecoder("utf-8");const Bn=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[v,y,E]of t.body._entries)typeof y=="object"?p.append(v,new Blob([et(y._id)]),E):p.append(v,y);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 l=Number(i.headers.get("content-length"))||void 0;let h=0;const c=[];for(;;){const{done:p,value:v}=await a.read();if(p)break;v&&(c.push(v),h+=v.length,o({loaded:h,total:l}))}const d=new Uint8Array(h);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)},$n=n=>{const t=new Blob([H[n]]);return URL.createObjectURL(t)},Pt=n=>new Blob([H[n]]),et=n=>H[n],Gn=n=>{H[n]=null},st=n=>(H.push(n),H.length-1),ne=new Map,jn=(n,t)=>{ne.set(n,t);const e=Rt.get(n);e!==void 0&&(H[e]=t)},Vn=n=>ne.has(n),Rt=new Map,zn=n=>{for(const[t,e]of Rt)if(e===n)return t},Xn=n=>{const t=Rt.get(n);if(t!==void 0)return t;const e=ne.get(n);if(!e)return-1;H.push(e);const s=H.length-1;return Rt.set(n,s),s},re=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function Ke(n){return typeof n=="object"&&n!==null&&"svg"in n}function Yn(n){return typeof n=="object"&&n!==null&&"_id"in n}function Kn(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const Yt="lecodes-canvas://";function qn(n){return n.startsWith(Yt)?Number(n.slice(Yt.length)):void 0}function Jn(n){return typeof File<"u"&&n instanceof File}function qe(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 se(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function Kt(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]),h=parseFloat(e[2]);if(l>0&&h>0)return{width:l,height:h}}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 Qn(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 Zn(n,t){if(!se(n))return null;const e=Qn(n);if(e)return Kt(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?Kt(s):null}function tr(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 Ke(s)?i=qe(s.svg):Kn(s)?i=Yt+s.canvasSurface:Yn(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):Jn(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function ge(n,t){if(!t)return;const e=qn(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 Je=n=>n==="monospaced"?"monospace":n;function me(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${Je(n.family)}`}class er{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=tr({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return Je(t)}measureText(t,e){return this.ctx.font=me(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=me(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 ge(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=ge(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(se(t)){const c=await Zn(t,d=>fetch(d).then(u=>u.ok?u.text():null));c&&(a=c.width,l=c.height)}const h={src:t,naturalWidth:a,naturalHeight:l,handle:o};return this.images.set(t,h),this.pending.delete(t),h})();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 nr(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function ot(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function rt(n){const{r:t,g:e,b:s,a:r}=nr(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function Qe(n){return n===void 0||(n>>>0&255)===0}function qt(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 ye(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function rr(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),h=e.width/l,c=e.height/l;return{src:{x:(n-h)/2,y:(t-c)/2,width:h,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 sr(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 ir(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,v=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:p,ry:v}}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),h=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(l,c);break;case"farthest-side":p=Math.max(h,d);break;case"closest-corner":p=Math.hypot(l,c);break;default:p=Math.hypot(h,d);break}u=f=p}else switch(n.extent){case"closest-side":u=l,f=c;break;case"farthest-side":u=h,f=d;break;case"closest-corner":u=l*Math.SQRT2,f=c*Math.SQRT2;break;default:u=h*Math.SQRT2,f=d*Math.SQRT2;break}return{cx:e,cy:s,rx:u,ry:f}}class we{constructor(t,e=1){w(this,"ctx");w(this,"dpr");w(this,"groups",[]);w(this,"scratch");w(this,"scratchCtx");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=rt(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}=sr(s.angle,t),l=this.ctx.createLinearGradient(r,i,o,a);for(const h of s.stops)l.addColorStop(Math.max(0,Math.min(1,h.position)),rt(h.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}=ir(s,t),l=this.ctx,h=o||1e-6,c=a||1e-6;l.save(),this.path(t,e),l.clip(),l.translate(r,i),l.scale(h,c);const d=l.createRadialGradient(0,0,0,0,0,1);for(const y of s.stops)d.addColorStop(Math.max(0,Math.min(1,y.position)),rt(y.color));l.fillStyle=d;const u=(t.x-r)/h,f=(t.x+t.width-r)/h,p=(t.y-i)/c,v=(t.y+t.height-i)/c;l.fillRect(u,p,f-u,v-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=qt(e,t);r.beginPath(),this.addRectPath(t,l);const h={x:t.x+a,y:t.y+a,width:t.width-2*a,height:t.height-2*a};if(h.width>0&&h.height>0){const c=l&&qt({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)},h);this.addRectPath(h,c||void 0)}r.fillStyle=rt(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:l,color:h}=s[a];r.fillStyle=rt(h),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}drawImage(t,e,s,r){if(!t.handle)return;const{src:i,dst:o}=e?{src:e,dst:s}:rr(t.naturalWidth,t.naturalHeight,s,r.fit),a=Math.max(1,Math.ceil(o.width*this.dpr)),l=Math.max(1,Math.ceil(o.height*this.dpr)),h=t.rasterize?t.rasterize(a,l):t.handle,c=!e&&r.fit!=="cover";if(r.tint===void 0){c?this.ctx.drawImage(h,o.x,o.y,o.width,o.height):this.ctx.drawImage(h,i.x,i.y,i.width,i.height,o.x,o.y,o.width,o.height);return}const d=this.getScratch(a,l);d.clearRect(0,0,a,l),d.globalCompositeOperation="source-over",c?d.drawImage(h,0,0,a,l):d.drawImage(h,i.x,i.y,i.width,i.height,0,0,a,l),d.globalCompositeOperation="source-in",d.fillStyle=rt(r.tint),d.fillRect(0,0,a,l),d.globalCompositeOperation="source-over",this.ctx.drawImage(d.canvas,0,0,a,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=rt(i),o.fillText(t,e,s)}}const $=[null],pt=[!1],Ze=(n,t,e)=>{n.addEventListener("ended",()=>{e(),pt[t]&&(n.currentTime=0,n.play())})},or=(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=$.length;return $.push(e),pt.push(!1),Ze(e,s,t),s},ar=(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=$.length;return $.push(e),pt.push(!1),Ze(e,s,t),s},cr=(n,t)=>{const e=$[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},lr=(n,t)=>{const e=$[n];e&&(t?e.play():e.pause())},hr=(n,t)=>{pt[n]=t},ur=n=>{var t;return((t=$[n])==null?void 0:t.currentTime)??0},dr=(n,t)=>{const e=$[n];e&&(e.currentTime=t)},fr=n=>{var e;const t=((e=$[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},ie=n=>$[n],tn=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},pr=n=>{const t=$[n];t&&(tn(t),$[n]=null,pt[n]=!1)},en=()=>{for(let n of $)n&&tn(n);$.length=1,pt.length=1},gr=9,mr=10,yr=12,wr=13,br=14,vr=15,xr=16,Er=1,Sr=2,_r=4,be=8,Tr=16,kr=32,Rr=64,Ar=256,Lr=512,Mr=1024,Pr=2048,Cr=4096,ve=0,It=1,xe=2,Ft=3;function Or(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 ht(n,t,e,s){let r=null;const i=o=>{const a=Or(o,t,e);if(a&&s(o)&&(r=o),!(o.clip&&!a))for(const l of o.children)i(l)};return i(n),r}const Ir=78,Fr={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:46},fontSize:{word:51},fontWeight:{word:52},fontStyle:{word:53},fontFamily:{bit:39,word:54},lineHeight:{word:55},letterSpacing:{word:56},textAlign:{word:57},textDecoration:{word:58},lineClamp:{word:59},textOverflow:{word:60},objectFit:{word:61},placeholder:{word:62},type:{word:63},dim:{word:77}},Nr={hidden:1},Ur={horizontal:1},Wr={italic:1},at={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},Dr=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,Hr=["farthest-corner","closest-side","closest-corner","farthest-side"],Br=52;function $r(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Gr(n,t,e+i*Br));return r}function Gr(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 h=0;h<o;h++){const c=a+h*8>>2;l.push({color:t[c]>>>0,position:n[c+1]})}if(i===1){const h=t[s+6],c={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:l};return h===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:Hr[h]??"farthest-corner"}}return{type:"linear",angle:r,stops:l}}const T=Fr,jr=["start","center","end","start","end"];let Et=0;function nn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],l=b=>Dr(o,a,b),h=b=>{const _=s[i+b];return _===0?void 0:n.UTF8ToString(n._cuiStringOf(_))};e.backgroundColor=s[i+T.backgroundColor.word]>>>0,e.opacity=r[i+T.opacity.word],e.dim=r[i+T.dim.word],e.display=at.display[s[i+T.display.word]],e.overflow=s[i+T.overflow.word]===Nr.hidden?"hidden":"visible",e.scrollAxis=s[i+T.scrollDirection.word]===Ur.horizontal?"x":"y",e.border={top:{width:r[i+T.borderTopWidth.word],color:s[i+T.borderTopColor.word]>>>0},right:{width:r[i+T.borderRightWidth.word],color:s[i+T.borderRightColor.word]>>>0},bottom:{width:r[i+T.borderBottomWidth.word],color:s[i+T.borderBottomColor.word]>>>0},left:{width:r[i+T.borderLeftWidth.word],color:s[i+T.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+T.borderTopLeftRadius.word],tr:r[i+T.borderTopRightRadius.word],br:r[i+T.borderBottomRightRadius.word],bl:r[i+T.borderBottomLeftRadius.word]},e.backgroundImage=h(T.backgroundImage.word),e.backgroundSize=at.backgroundSize[s[i+T.backgroundSize.word]];const c=s[i+T.backgroundGradient.word];if(c===0)e.backgroundGradients=void 0;else{Et===0&&(Et=n._malloc(4));const b=n._cuiGradientOf(c,Et),_=n.HEAPU32[Et>>>2];e.backgroundGradients=b!==0&&_>0?$r(n.HEAPF32,n.HEAPU32,b,_):void 0}const d=i+T.transform.word,u=r[d],f=r[d+1],p=r[d+3],v=r[d+4],y=r[d+6],E=r[d+7];e.transform=u===1&&f===0&&p===0&&v===1&&y===0&&E===0?void 0:[u,f,p,v,y,E];const g=i+T.transformOrigin.word;e.transformOrigin={x:r[g],y:r[g+1],xPercent:s[g+2]!==0,yPercent:s[g+3]!==0},e.color=l(T.color.bit)?s[i+T.color.word]>>>0:void 0,e.fontFamily=l(T.fontFamily.bit)?h(T.fontFamily.word):void 0,e.fontSize=r[i+T.fontSize.word],e.fontWeight=r[i+T.fontWeight.word],e.fontStyle=s[i+T.fontStyle.word]===Wr.italic?"italic":"normal",e.lineHeight=r[i+T.lineHeight.word],e.letterSpacing=r[i+T.letterSpacing.word],e.textAlign=jr[s[i+T.textAlign.word]]??"start",e.textDecoration=at.textDecoration[s[i+T.textDecoration.word]],e.lineClamp=r[i+T.lineClamp.word],e.textOverflow=at.textOverflow[s[i+T.textOverflow.word]],e.objectFit=at.objectFit[s[i+T.objectFit.word]],e.tintColor=l(T.tintColor.bit)?s[i+T.tintColor.word]>>>0:void 0,e.placeholder=h(T.placeholder.word),e.placeholderColor=l(T.placeholderColor.bit)?s[i+T.placeholderColor.word]>>>0:void 0,e.inputType=at.type[s[i+T.type.word]],e.overlayColor=l(T.overlayColor.bit)?s[i+T.overlayColor.word]>>>0:void 0}function Vr(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 zr(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(nn(n,s,e),!0)}function Xr(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*Ir*4;t(o,l=>nn(n,a,l))}return e}const Z={color:255,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function Jt(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:l,textAlign:h,textDecoration:c}=t,d=s??Z.fontSize;return{color:e??Z.color,fontSize:d,fontFamily:r??Z.fontFamily,fontWeight:i??Z.fontWeight,fontStyle:o??Z.fontStyle,lineHeight:a,letterSpacing:l??Z.letterSpacing,textAlign:h??Z.textAlign,textDecoration:c??Z.textDecoration}}function rn(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}function wt(n,t,e){const s=[];let r=0;for(const i of n.split(`
|
|
10
|
-
`)){if(i.length===0){s.push("");continue}let o=i;for(;o;){if(e(o)<=t){s.push(o),r=Math.max(r,e(o));break}let a=0,l=-1,h=0;for(;(h=o.indexOf(" ",h+1))!==-1&&!(e(o.substring(0,h))>t);)l=h;if(l>0)a=l;else{let d=o.indexOf(" ");d===-1&&(d=o.length);const u=o.substring(0,d);if(e(u)>t){for(let f=1;f<=u.length;f++)if(e(u.substring(0,f))>t){a=f-1;break}}else for(let f=d+1;f<=o.length;f++)if(e(o.substring(0,f))>t){a=f-1;break}}a<=0&&(a=1);const c=o.substring(0,a);s.push(c),r=Math.max(r,e(c)),o=o.substring(a+(l>0?1:0))}}return{lines:s,maxWidth:r}}const Nt="…";function sn(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]=Yr(i[r-1],e,s)),i}function Yr(n,t,e){if(!isFinite(t))return n+Nt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+Nt)>t;)r--;return s.slice(0,r).join("").trimEnd()+Nt}function Kr(n,t,e){const s=Jt(n),r=rn(s),i=isNaN(e)?1/0:e,o=c=>t.measureText(c,r),a=wt(n.text??"",i,o),l=sn(a.lines,n.style,i,o);let h=a.maxWidth;if(l!==a.lines){h=0;for(const c of l)h=Math.max(h,o(c))}return{width:Math.ceil(h),height:Math.ceil(l.length*s.lineHeight)}}function qr(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=wt(o,a,h=>t.measureText(h,r));return{width:Math.ceil(l.maxWidth),height:Math.ceil(Math.max(1,l.lines.length)*i)}}function Jr(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(Ke(r)){const h=Kt(r.svg);if(h)i=h.width,o=h.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 h=t.resolveSrc(r),c=h?t.getImage(h):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),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}}function Qr(n,t,e,s,r,i,o={}){t.beginFrame(s,r);const a=n.filter(l=>l.widget);for(const l of n)l.widget||Qt(l.tree,t,e,o);for(const l of a)l.backdrop&&t.fillRoundRect({x:0,y:0,width:s,height:r},void 0,l.backdrop.color);for(const l of a)Qt(l.tree,t,e,o);t.endFrame()}function Qt(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,v]=r.transform,y=r.transformOrigin,E=i.x+(y?y.xPercent?i.width*y.x/100:y.x:i.width/2),g=i.y+(y?y.yPercent?i.height*y.y/100:y.y:i.height/2);t.translate(E,g),t.transform(c,d,u,f,p,v),t.translate(-E,-g)}const l=qt(r.borderRadius,i);if(Qe(r.backgroundColor)||t.fillRoundRect(i,l,r.backgroundColor),r.backgroundImage){const c=e.getImage(r.backgroundImage);c&&c.naturalWidth>0&&c.naturalHeight>0&&(t.save(),ye(l)&&t.clipRoundRect(i,l),t.drawImage(c,null,i,{fit:Zr(r.backgroundSize)}),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,l,d)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const c=n.sourceRect;t.save(),ye(l)&&t.clipRoundRect(i,l),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:se(n.image.src)?r.tintColor:void 0,radius:l}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&es(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&rs(n,t,e,l),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,l):n.type==="video"&&ns(n,t,e,l)),n.clip&&t.clipRoundRect(i,l);for(const c of n.children)Qt(c,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,l,Math.round(Math.min(1,r.dim)*255)>>>0);const h=ts(r.border);h&&t.strokeBorder(i,l,h),a&&t.endGroup(),t.restore()}function Zr(n){return n==="contain"?"contain":"cover"}function ts(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 on=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function es(n,t,e){var y,E,g;const s=n.style,r={family:on(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:h,lines:c}=n,d=((y=n.padding)==null?void 0:y[0])??0,u=((E=n.padding)==null?void 0:E[1])??0,f=((g=n.padding)==null?void 0:g[2])??0,p=h.x+d,v=h.width-d-f;for(let b=0;b<c.length;b++){const _=c[b],P=h.y+u+b*o+(o-(l.ascent+l.descent))/2+l.ascent,I=e.measureText(_,r),F=a==="center"?p+(v-I)/2:a==="end"?p+v-I:p;if(t.fillText(_,F,P,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const W=Math.max(1,r.size/14),R=s.textDecoration==="underline"?P+W:P-r.size*.3;t.fillRoundRect({x:F,y:R,width:I,height:W},void 0,i)}}}function ns(n,t,e,s){const{rect:r}=n;Qe(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),h=r.x+(r.width-l)/2,c=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",h,c,o,4294967244)}}function rs(n,t,e,s){var z,G,j,m,M;const r=n.style,i={family:on(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,h=a?r.placeholder??"":l?"•".repeat(o.length):o,c=a?r.placeholderColor??2576980479:r.color??255,{rect:d}=n,u=((z=n.padding)==null?void 0:z[0])??0,f=((G=n.padding)==null?void 0:G[1])??0,p=((j=n.padding)==null?void 0:j[2])??0,v=((m=n.padding)==null?void 0:m[3])??0,y=d.x+u,E=d.width-u-p,g=d.y+f,b=d.height-f-v,_=e.fontMetrics(i),L=r.lineHeight,P=r.textAlign??"start",I=n.type==="textarea",F=I?wt(h,E,A=>e.measureText(A,i)).lines:[h],W=A=>P==="center"?y+(E-A)/2:P==="end"?y+E-A:y,R=A=>I?g+A*L+(L-(_.ascent+_.descent))/2+_.ascent:g+(b-(_.ascent+_.descent))/2+_.ascent;t.save(),t.clipRoundRect(d,s);for(let A=0;A<F.length;A++){const D=F[A];D.length>0&&t.fillText(D,W(e.measureText(D,i)),R(A),i,c)}if((M=n.state)!=null&&M.focused){const A=a?[""]:I?wt(l?"•".repeat(o.length):o,E,N=>e.measureText(N,i)).lines:[h],D=A.length-1,Y=e.measureText(A[D],i),J=a?W(0):W(Y)+Y,x=R(D),k=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:x-_.ascent,width:k,height:_.ascent+_.descent},void 0,r.color??255)}t.restore()}function an(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?Zt(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>Zt(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function ss(n,t=[],e){return JSON.stringify(an(n,t,e),null,2)}function ct(n,t){const e=10**t;return Math.round(n*e)/e}function Zt(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),r.rect=[ct(s.x,t),ct(s.y,t),ct(s.width,t),ct(s.height,t)],e&&(r.id=n.id);const i=os(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:ct(n.scroll.offset,t),content:ct(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(l=>Zt(l,t,e))),r}function is(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 os(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=ot(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=ot(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.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=ot(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=ot(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:ot(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=is(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:ot(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const as=.32,cs=4,Ee=new Map;function cn(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Ee.get(n);return t===void 0&&(t=qe(n.slice(4)),Ee.set(n,t)),t}return n}class ls{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");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&Er)!==0}get imageSrcRaw(){return this.type==="image"?cn(this.src):void 0}has(t){return(this.flags&t)!==0}}class hs{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,"widgetRoots",[]);w(this,"width",0);w(this,"height",0);w(this,"focused",null);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,"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}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,l)=>{const h=this.measure(r,i,a);return t.setFloat32(4,h.width,!0),t.setFloat32(0,h.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;Vr(i,t)&&zr(i,t,r.style);const o=r;return r.type==="text"?Kr(o,this.host,e):r.type==="image"?Jr(o,this.host,e,s):r.editable?qr(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,h)=>l|a[h],0)),this.M._setSafePaddings(s,r,i,o,0),this.dirty=!0}layoutFrame(){const t=this.M;Xr(t,(r,i)=>{const o=this.nodes.get(r);o&&i(o.style)})>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(be)&&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],h=this.nodes.get(l);if(!h)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},v=h.layoutRect,y=!v||v.x!==p.x||v.y!==p.y||v.width!==p.width||v.height!==p.height;h.layoutRect=p,y&&(this.dirty=!0),y&&h.has(be)&&e._creatorWebNodeLayout(l,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.widgetRoots){const i=r.layoutRect??{x:0,y:0,width:this.width,height:this.height},o=this.build(r,i);if(!o)continue;const a=o.style.overlayColor;t.push({tree:o,widget:!0,backdrop:a!==void 0?{color:a,jsNode:r.jsNode}:void 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 an(this.renderTree(),this.widgetTrees())}toText(){return ss(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();Qr(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 E;if(i.style.display==="none")return null;let h,c,d,u;if(l)h=e.x,c=e.y,d=e.width,u=e.height;else{const g=i.layoutRect;if(!g)return null;h=o+g.x,c=a+g.y,d=g.width,u=g.height}const f={id:i.id,type:i.type,rect:{x:h,y:c,width:d,height:u},style:i.style,children:[]};i.name&&(f.name=i.name);const p=i;if(i.type==="text"){const g=Jt(p),b=rn(g);f.text=i.text;const _=this.padding(i.id);(_[0]||_[1]||_[2]||_[3])&&(f.padding=_);const L=d-_[0]-_[2],P=`${L}|${b.size}|${b.weight}|${b.italic?1:0}|${b.letterSpacing}|${b.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.text}`;if(((E=i.wrapCache)==null?void 0:E.key)===P)f.lines=i.wrapCache.lines;else{const I=W=>this.host.measureText(W,b),F=sn(wt(i.text,L,I).lines,i.style,L,I);i.wrapCache={key:P,lines:F},f.lines=F}f.style={...i.style,color:g.color,fontSize:g.fontSize,fontFamily:g.fontFamily,fontWeight:g.fontWeight,fontStyle:g.fontStyle,lineHeight:g.lineHeight,letterSpacing:g.letterSpacing,textAlign:g.textAlign,textDecoration:g.textDecoration}}else if(i.type==="image"){const g=this.host.resolveSrc(i.imageSrcRaw),b=g?this.host.getImage(g):void 0;f.image=b??(g?{src:g,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(f.sourceRect=i.sourceRect)}else if(i.editable){f.value=i.value;const g=this.padding(i.id);(g[0]||g[1]||g[2]||g[3])&&(f.padding=g);const b=Jt(p);f.style={...i.style,color:b.color,fontSize:b.fontSize,fontFamily:b.fontFamily,fontWeight:b.fontWeight,fontStyle:b.fontStyle,lineHeight:b.lineHeight,letterSpacing:b.letterSpacing,textAlign:b.textAlign,textDecoration:b.textDecoration}}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 v=h,y=c;if(i.scrollable){const g=i.scrollAxis,b=g==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);f.clip=!0,f.scroll={offset:i.scrollOffset,content:b,axis:g},g==="x"?v=h-i.scrollOffset:y=c-i.scrollOffset}if(i.type==="pager"){const g=s._creatorWebPagerSelectedIndex(i.id),b=s._creatorWebPagerStackLen(i.id,g),_=b>0?s._creatorWebPagerPageNode(i.id,g,b-1):0,L=_?this.nodes.get(_):void 0;L?this.pagerShown.set(i.id,L):this.pagerShown.delete(i.id);const P=this.pagerLeaving.get(i.id);for(const I of P&&P.page!==L?P.above?[L,P.page]:[P.page,L]:[L]){const F=I?r(I,h,c,!1):null;F&&f.children.push(F)}return f}if(i.type==="vlist"){for(const g of i.children){const b=s._getParentNode(g.id);if(!b)continue;const _=s._vlistItemOffsetOf(i.id,b);if(Number.isNaN(_))continue;const L=g.layoutRect??{x:0,y:0},P=r(g,h-L.x,c+_-i.scrollOffset-L.y,!1);P&&f.children.push(P)}return f}for(const g of i.children){const b=r(g,v,y,!1);b&&f.children.push(b)}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*as):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 ls(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.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard());const s=this.widgetRoots.indexOf(e);s>=0&&this.widgetRoots.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 cn(t.src)}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 l;this.destKind=t;const a=t===ve?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,(l=this.onDestination)==null||l.call(this,t,s)}dropView(t,e,s){var r;if(t===ve){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)}widgetOpen(t,e,s,r){const i=this.nodes.get(t);i&&!this.widgetRoots.includes(i)&&this.widgetRoots.push(i),this.dirty=!0}widgetClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.widgetRoots.indexOf(e):-1;s>=0&&this.widgetRoots.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}pagerPageMounted(t,e){this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent;)e=e.parent;return e}emitKeyboard(){var e,s;const t=this.keyboardHeight();(s=(e=this.options).onKeyboard)==null||s.call(e,t),this.M._creatorWebKeyboardEvent(t,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(Lr)&&this.M._creatorWebNodeEvent(t,wr),this.M._creatorWebSetShrunkRoot(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(Mr)&&this.M._creatorWebNodeEvent(t.id,br),this.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Ar)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,yr,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Pr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,vr,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(kr)&&this.M._creatorWebNodeEventNum(t,gr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(Tr)&&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=ht(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i)return this.nodes.get(i.id)??null;if(s[r].backdrop)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=ht(o[a].tree,e,s,h=>{var c;return((c=this.nodes.get(h.id))==null?void 0:c.editable)??!1});if(l){const h=this.nodes.get(l.id);this.focusInput(h.id),i.edit=h,i.dismiss=!1;return}if(o[a].backdrop)break}for(let a=o.length-1;a>=0;a--){const l=o[a],h=ht(l.tree,e,s,u=>{var f;return((f=this.nodes.get(u.id))==null?void 0:f.interactive)??!1}),c=ht(l.tree,e,s,u=>!!u.scroll&&u.scroll.content>(u.scroll.axis==="x"?u.rect.width:u.rect.height)+.5),d=c?this.nodes.get(c.id)??null:null;if(h){const u=this.nodes.get(h.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.backdrop){const u=l.tree.rect,f=e>=u.x&&e<u.x+u.width&&s>=u.y&&s<u.y+u.height;i.backdrop=f?null:this.nodes.get(l.tree.id)??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(Rr)&&i._creatorWebNodeEvent(r.scroll.id,mr),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(Sr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Cr)&&i._creatorWebNodeEvent(r.backdrop.id,xr):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=ht(i[o].tree,t,e,l=>!!l.scroll&&l.scroll.content>(l.scroll.axis==="x"?l.rect.width:l.rect.height)+.5);if(a){const l=this.nodes.get(a.id);return l?this.scrollBy(l.id,l.scrollAxis==="x"?s:r):!1}if(i[o].backdrop)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(_r)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const us=`
|
|
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+ge?(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 Wn=(n,t)=>{const e=new Un(n,t);return n.jsb=e,e},Dn=""+new URL("assets/creator-full.js-BYswGsqR.symbols",import.meta.url).href,tt=/wasm-function\[(\d+)\]/g;let It=null;const Ye=()=>(It||(It=fetch(Dn).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))),It),Ke=n=>n.replace(/\\([0-9a-fA-F]{2})/g,(t,e)=>String.fromCharCode(parseInt(e,16))),Hn=/([\w.-]+)\.wasm(?=[^\w-]|$)/g,qe=n=>{const t=[...n.matchAll(Hn)].map(e=>e[1]);return t.length===0?null:t.some(e=>e.includes("creator-gl"))?"ours":"other"},Bn=async n=>{if(tt.lastIndex=0,!tt.test(n))return null;const t=await Ye();if(!t)return null;let e=!1;const s=n.split(`
|
|
6
|
+
`).map(r=>{if(tt.lastIndex=0,!tt.test(r))return r;const i=qe(r);return i==="other"?r:r.replace(tt,(o,a)=>{const h=t.get(Number(a));return h===void 0?o:(e=!0,`${i===null?"?":""}${Ke(h)} (${o})`)})});return e?s.join(`
|
|
7
|
+
`):null},$n=async n=>{if(tt.lastIndex=0,!tt.test(n))return[];const t=await Ye();if(!t)return[];const e=[];for(const s of n.split(`
|
|
8
|
+
`))if(qe(s)!=="other")for(const r of s.matchAll(tt)){const i=t.get(Number(r[1]));i!==void 0&&e.push(Ke(i).replaceAll("std::__2::","std::"))}return e},me=n=>{const t=n==null?void 0:n.stack;typeof t=="string"&&Bn(t).then(e=>{e&&console.error(`[creator-gl] decoded wasm stack (via creator-gl.js.symbols):
|
|
9
|
+
`+e)})};let ye=!1;const Gn=()=>{ye||(ye=!0,addEventListener("error",n=>me(n.error)),addEventListener("unhandledrejection",n=>me(n.reason)))},B=[null];new TextDecoder("utf-8");const jn=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,y,x]of t.body._entries)typeof y=="object"?p.append(b,new Blob([et(y._id)]),x):p.append(b,y);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();B.push(p),e(B.length-1,i.status);return}const a=(f=i.body)==null?void 0:f.getReader();if(!a){const p=await i.arrayBuffer();B.push(p),e(B.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;B.push(d.buffer),e(B.length-1,i.status)},Vn=n=>{const t=new Blob([B[n]]);return URL.createObjectURL(t)},Ct=n=>new Blob([B[n]]),et=n=>B[n],zn=n=>{B[n]=null},ot=n=>(B.push(n),B.length-1),re=new Map,Xn=(n,t)=>{re.set(n,t);const e=At.get(n);e!==void 0&&(B[e]=t)},Yn=n=>re.has(n),At=new Map,Kn=n=>{for(const[t,e]of At)if(e===n)return t},qn=n=>{const t=At.get(n);if(t!==void 0)return t;const e=re.get(n);if(!e)return-1;B.push(e);const s=B.length-1;return At.set(n,s),s},se=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function Je(n){return typeof n=="object"&&n!==null&&"svg"in n}function Jn(n){return typeof n=="object"&&n!==null&&"_id"in n}function Qn(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const Kt="lecodes-canvas://";function Zn(n){return n.startsWith(Kt)?Number(n.slice(Kt.length)):void 0}function tr(n){return typeof File<"u"&&n instanceof File}function Qe(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 ie(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function qt(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 er(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 nr(n,t){if(!ie(n))return null;const e=er(n);if(e)return qt(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?qt(s):null}function rr(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 Je(s)?i=Qe(s.svg):Qn(s)?i=Kt+s.canvasSurface:Jn(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):tr(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function we(n,t){if(!t)return;const e=Zn(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 Ze=n=>n==="monospaced"?"monospace":n;function be(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${Ze(n.family)}`}class sr{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=rr({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return Ze(t)}measureText(t,e){return this.ctx.font=be(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=be(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 we(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=we(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(ie(t)){const c=await nr(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 ir(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function ct(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function st(n){const{r:t,g:e,b:s,a:r}=ir(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function tn(n){return n===void 0||(n>>>0&255)===0}function Jt(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 ve(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function or(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 ar(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 cr(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 xe{constructor(t,e=1){w(this,"ctx");w(this,"dpr");w(this,"groups",[]);w(this,"scratch");w(this,"scratchCtx");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=st(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}=ar(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)),st(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}=cr(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 y of s.stops)d.addColorStop(Math.max(0,Math.min(1,y.position)),st(y.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=Jt(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&&Jt({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=st(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:h,color:l}=s[a];r.fillStyle=st(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}drawImage(t,e,s,r){if(!t.handle)return;const i=e?{src:e,dst:s}:or(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 y=p/t.naturalWidth,x=b/t.naturalHeight;a={x:a.x*y,y:a.y*x,width:a.width*y,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=st(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=st(i),o.fillText(t,e,s)}}const $=[null],mt=[!1],en=(n,t,e)=>{n.addEventListener("ended",()=>{e(),mt[t]&&(n.currentTime=0,n.play())})},lr=(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=$.length;return $.push(e),mt.push(!1),en(e,s,t),s},hr=(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=$.length;return $.push(e),mt.push(!1),en(e,s,t),s},ur=(n,t)=>{const e=$[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},dr=(n,t)=>{const e=$[n];e&&(t?e.play():e.pause())},fr=(n,t)=>{mt[n]=t},pr=n=>{var t;return((t=$[n])==null?void 0:t.currentTime)??0},gr=(n,t)=>{const e=$[n];e&&(e.currentTime=t)},mr=n=>{var e;const t=((e=$[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},oe=n=>$[n],nn=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},yr=n=>{const t=$[n];t&&(nn(t),$[n]=null,mt[n]=!1)},rn=()=>{for(let n of $)n&&nn(n);$.length=1,mt.length=1},wr=9,br=10,vr=12,xr=13,Er=14,Sr=15,_r=16,Tr=1,kr=2,Rr=4,Ee=8,Ar=16,Lr=32,Mr=64,Pr=256,Cr=512,Or=1024,Ir=2048,Fr=4096,Se=0,Ft=1,_e=2,Nt=3;function Nr(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 dt(n,t,e,s){let r=null;const i=o=>{const a=Nr(o,t,e);if(a&&s(o)&&(r=o),!(o.clip&&!a))for(const h of o.children)i(h)};return i(n),r}const Ur=78,Wr={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:46},fontSize:{word:51},fontWeight:{word:52},fontStyle:{word:53},fontFamily:{bit:39,word:54},lineHeight:{word:55},letterSpacing:{word:56},textAlign:{word:57},textDecoration:{word:58},lineClamp:{word:59},textOverflow:{word:60},objectFit:{word:61},placeholder:{word:62},type:{word:63},dim:{word:77}},Dr={hidden:1},Hr={horizontal:1},Br={italic:1},lt={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},$r=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,Gr=["farthest-corner","closest-side","closest-corner","farthest-side"],jr=52;function Vr(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(zr(n,t,e+i*jr));return r}function zr(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:Gr[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:h}}const T=Wr,Xr=["start","center","end","start","end"];let _t=0;function sn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],h=v=>$r(o,a,v),l=v=>{const _=s[i+v];return _===0?void 0:n.UTF8ToString(n._cuiStringOf(_))};e.backgroundColor=s[i+T.backgroundColor.word]>>>0,e.opacity=r[i+T.opacity.word],e.dim=r[i+T.dim.word],e.display=lt.display[s[i+T.display.word]],e.overflow=s[i+T.overflow.word]===Dr.hidden?"hidden":"visible",e.scrollAxis=s[i+T.scrollDirection.word]===Hr.horizontal?"x":"y",e.border={top:{width:r[i+T.borderTopWidth.word],color:s[i+T.borderTopColor.word]>>>0},right:{width:r[i+T.borderRightWidth.word],color:s[i+T.borderRightColor.word]>>>0},bottom:{width:r[i+T.borderBottomWidth.word],color:s[i+T.borderBottomColor.word]>>>0},left:{width:r[i+T.borderLeftWidth.word],color:s[i+T.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+T.borderTopLeftRadius.word],tr:r[i+T.borderTopRightRadius.word],br:r[i+T.borderBottomRightRadius.word],bl:r[i+T.borderBottomLeftRadius.word]},e.backgroundImage=l(T.backgroundImage.word),e.backgroundSize=lt.backgroundSize[s[i+T.backgroundSize.word]];const c=s[i+T.backgroundGradient.word];if(c===0)e.backgroundGradients=void 0;else{_t===0&&(_t=n._malloc(4));const v=n._cuiGradientOf(c,_t),_=n.HEAPU32[_t>>>2];e.backgroundGradients=v!==0&&_>0?Vr(n.HEAPF32,n.HEAPU32,v,_):void 0}const d=i+T.transform.word,u=r[d],f=r[d+1],p=r[d+3],b=r[d+4],y=r[d+6],x=r[d+7];e.transform=u===1&&f===0&&p===0&&b===1&&y===0&&x===0?void 0:[u,f,p,b,y,x];const g=i+T.transformOrigin.word;e.transformOrigin={x:r[g],y:r[g+1],xPercent:s[g+2]!==0,yPercent:s[g+3]!==0},e.color=h(T.color.bit)?s[i+T.color.word]>>>0:void 0,e.fontFamily=h(T.fontFamily.bit)?l(T.fontFamily.word):void 0,e.fontSize=r[i+T.fontSize.word],e.fontWeight=r[i+T.fontWeight.word],e.fontStyle=s[i+T.fontStyle.word]===Br.italic?"italic":"normal",e.lineHeight=r[i+T.lineHeight.word],e.letterSpacing=r[i+T.letterSpacing.word],e.textAlign=Xr[s[i+T.textAlign.word]]??"start",e.textDecoration=lt.textDecoration[s[i+T.textDecoration.word]],e.lineClamp=r[i+T.lineClamp.word],e.textOverflow=lt.textOverflow[s[i+T.textOverflow.word]],e.objectFit=lt.objectFit[s[i+T.objectFit.word]],e.tintColor=h(T.tintColor.bit)?s[i+T.tintColor.word]>>>0:void 0,e.placeholder=l(T.placeholder.word),e.placeholderColor=h(T.placeholderColor.bit)?s[i+T.placeholderColor.word]>>>0:void 0,e.inputType=lt.type[s[i+T.type.word]],e.overlayColor=h(T.overlayColor.bit)?s[i+T.overlayColor.word]>>>0:void 0}function Yr(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 Kr(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(sn(n,s,e),!0)}function qr(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*Ur*4;t(o,h=>sn(n,a,h))}return e}const Z={color:255,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function Qt(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??Z.fontSize;return{color:e??Z.color,fontSize:d,fontFamily:r??Z.fontFamily,fontWeight:i??Z.fontWeight,fontStyle:o??Z.fontStyle,lineHeight:a,letterSpacing:h??Z.letterSpacing,textAlign:l??Z.textAlign,textDecoration:c??Z.textDecoration}}function on(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}function vt(n,t,e){const s=[];let r=0;for(const i of n.split(`
|
|
10
|
+
`)){if(i.length===0){s.push("");continue}let o=i;for(;o;){if(e(o)<=t){s.push(o),r=Math.max(r,e(o));break}let a=0,h=-1,l=0;for(;(l=o.indexOf(" ",l+1))!==-1&&!(e(o.substring(0,l))>t);)h=l;if(h>0)a=h;else{let d=o.indexOf(" ");d===-1&&(d=o.length);const u=o.substring(0,d);if(e(u)>t){for(let f=1;f<=u.length;f++)if(e(u.substring(0,f))>t){a=f-1;break}}else for(let f=d+1;f<=o.length;f++)if(e(o.substring(0,f))>t){a=f-1;break}}a<=0&&(a=1);const c=o.substring(0,a);s.push(c),r=Math.max(r,e(c)),o=o.substring(a+(h>0?1:0))}}return{lines:s,maxWidth:r}}const Ut="…";function an(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]=Jr(i[r-1],e,s)),i}function Jr(n,t,e){if(!isFinite(t))return n+Ut;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+Ut)>t;)r--;return s.slice(0,r).join("").trimEnd()+Ut}function Qr(n,t,e){const s=Qt(n),r=on(s),i=isNaN(e)?1/0:e,o=c=>t.measureText(c,r),a=vt(n.text??"",i,o),h=an(a.lines,n.style,i,o);let l=a.maxWidth;if(h!==a.lines){l=0;for(const c of h)l=Math.max(l,o(c))}return{width:Math.ceil(l),height:Math.ceil(h.length*s.lineHeight)}}function Zr(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=vt(o,a,l=>t.measureText(l,r));return{width:Math.ceil(h.maxWidth),height:Math.ceil(Math.max(1,h.lines.length)*i)}}function ts(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(Je(r)){const l=qt(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}}function es(n,t,e,s,r,i,o={}){t.beginFrame(s,r);const a=n.filter(h=>h.widget);for(const h of n)h.widget||Zt(h.tree,t,e,o);for(const h of a)h.backdrop&&t.fillRoundRect({x:0,y:0,width:s,height:r},void 0,h.backdrop.color);for(const h of a)Zt(h.tree,t,e,o);t.endFrame()}function Zt(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]=r.transform,y=r.transformOrigin,x=i.x+(y?y.xPercent?i.width*y.x/100:y.x:i.width/2),g=i.y+(y?y.yPercent?i.height*y.y/100:y.y:i.height/2);t.translate(x,g),t.transform(c,d,u,f,p,b),t.translate(-x,-g)}const h=Jt(r.borderRadius,i);if(tn(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(),ve(h)&&t.clipRoundRect(i,h),t.drawImage(c,null,i,{fit:ns(r.backgroundSize)}),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(),ve(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:ie(n.image.src)?r.tintColor:void 0,radius:h}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&ss(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&os(n,t,e,h),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,h):n.type==="video"&&is(n,t,e,h)),n.clip&&t.clipRoundRect(i,h);for(const c of n.children)Zt(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=rs(r.border);l&&t.strokeBorder(i,h,l),a&&t.endGroup(),t.restore()}function ns(n){return n==="contain"?"contain":"cover"}function rs(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 cn=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function ss(n,t,e){var y,x,g;const s=n.style,r={family:cn(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=((y=n.padding)==null?void 0:y[0])??0,u=((x=n.padding)==null?void 0:x[1])??0,f=((g=n.padding)==null?void 0:g[2])??0,p=l.x+d,b=l.width-d-f;for(let v=0;v<c.length;v++){const _=c[v],P=l.y+u+v*o+(o-(h.ascent+h.descent))/2+h.ascent,I=e.measureText(_,r),F=a==="center"?p+(b-I)/2:a==="end"?p+b-I:p;if(t.fillText(_,F,P,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const W=Math.max(1,r.size/14),R=s.textDecoration==="underline"?P+W:P-r.size*.3;t.fillRoundRect({x:F,y:R,width:I,height:W},void 0,i)}}}function is(n,t,e,s){const{rect:r}=n;tn(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 os(n,t,e,s){var z,G,j,m,M;const r=n.style,i={family:cn(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=((z=n.padding)==null?void 0:z[0])??0,f=((G=n.padding)==null?void 0:G[1])??0,p=((j=n.padding)==null?void 0:j[2])??0,b=((m=n.padding)==null?void 0:m[3])??0,y=d.x+u,x=d.width-u-p,g=d.y+f,v=d.height-f-b,_=e.fontMetrics(i),L=r.lineHeight,P=r.textAlign??"start",I=n.type==="textarea",F=I?vt(l,x,A=>e.measureText(A,i)).lines:[l],W=A=>P==="center"?y+(x-A)/2:P==="end"?y+x-A:y,R=A=>I?g+A*L+(L-(_.ascent+_.descent))/2+_.ascent:g+(v-(_.ascent+_.descent))/2+_.ascent;t.save(),t.clipRoundRect(d,s);for(let A=0;A<F.length;A++){const D=F[A];D.length>0&&t.fillText(D,W(e.measureText(D,i)),R(A),i,c)}if((M=n.state)!=null&&M.focused){const A=a?[""]:I?vt(h?"•".repeat(o.length):o,x,N=>e.measureText(N,i)).lines:[l],D=A.length-1,Y=e.measureText(A[D],i),J=a?W(0):W(Y)+Y,E=R(D),k=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:E-_.ascent,width:k,height:_.ascent+_.descent},void 0,r.color??255)}t.restore()}function ln(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?te(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>te(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function as(n,t=[],e){return JSON.stringify(ln(n,t,e),null,2)}function ht(n,t){const e=10**t;return Math.round(n*e)/e}function te(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),r.rect=[ht(s.x,t),ht(s.y,t),ht(s.width,t),ht(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:ht(n.scroll.offset,t),content:ht(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(h=>te(h,t,e))),r}function cs(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=ct(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=ct(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.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=ct(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=ct(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:ct(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=cs(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:ct(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const hs=.32,us=4,Te=new Map;function hn(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Te.get(n);return t===void 0&&(t=Qe(n.slice(4)),Te.set(n,t)),t}return n}class ds{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");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&Tr)!==0}get imageSrcRaw(){return this.type==="image"?hn(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,"widgetRoots",[]);w(this,"width",0);w(this,"height",0);w(this,"focused",null);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,"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}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;Yr(i,t)&&Kr(i,t,r.style);const o=r;return r.type==="text"?Qr(o,this.host,e):r.type==="image"?ts(o,this.host,e,s):r.editable?Zr(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.dirty=!0}layoutFrame(){const t=this.M;qr(t,(r,i)=>{const o=this.nodes.get(r);o&&i(o.style)})>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(Ee)&&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,y=!b||b.x!==p.x||b.y!==p.y||b.width!==p.width||b.height!==p.height;l.layoutRect=p,y&&(this.dirty=!0),y&&l.has(Ee)&&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.widgetRoots){const i=r.layoutRect??{x:0,y:0,width:this.width,height:this.height},o=this.build(r,i);if(!o)continue;const a=o.style.overlayColor;t.push({tree:o,widget:!0,backdrop:a!==void 0?{color:a,jsNode:r.jsNode}:void 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 ln(this.renderTree(),this.widgetTrees())}toText(){return as(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();es(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 g=i.layoutRect;if(!g)return null;l=o+g.x,c=a+g.y,d=g.width,u=g.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 g=Qt(p),v=on(g);f.text=i.text;const _=this.padding(i.id);(_[0]||_[1]||_[2]||_[3])&&(f.padding=_);const L=d-_[0]-_[2],P=`${L}|${v.size}|${v.weight}|${v.italic?1:0}|${v.letterSpacing}|${v.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.text}`;if(((x=i.wrapCache)==null?void 0:x.key)===P)f.lines=i.wrapCache.lines;else{const I=W=>this.host.measureText(W,v),F=an(vt(i.text,L,I).lines,i.style,L,I);i.wrapCache={key:P,lines:F},f.lines=F}f.style={...i.style,color:g.color,fontSize:g.fontSize,fontFamily:g.fontFamily,fontWeight:g.fontWeight,fontStyle:g.fontStyle,lineHeight:g.lineHeight,letterSpacing:g.letterSpacing,textAlign:g.textAlign,textDecoration:g.textDecoration}}else if(i.type==="image"){const g=this.host.resolveSrc(i.imageSrcRaw),v=g?this.host.getImage(g):void 0;f.image=v??(g?{src:g,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(f.sourceRect=i.sourceRect)}else if(i.editable){f.value=i.value;const g=this.padding(i.id);(g[0]||g[1]||g[2]||g[3])&&(f.padding=g);const v=Qt(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.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,y=c;if(i.scrollable){const g=i.scrollAxis,v=g==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);f.clip=!0,f.scroll={offset:i.scrollOffset,content:v,axis:g},g==="x"?b=l-i.scrollOffset:y=c-i.scrollOffset}if(i.type==="pager"){const g=s._creatorWebPagerSelectedIndex(i.id),v=s._creatorWebPagerStackLen(i.id,g),_=v>0?s._creatorWebPagerPageNode(i.id,g,v-1):0,L=_?this.nodes.get(_):void 0;L?this.pagerShown.set(i.id,L):this.pagerShown.delete(i.id);const P=this.pagerLeaving.get(i.id);for(const I of P&&P.page!==L?P.above?[L,P.page]:[P.page,L]:[L]){const F=I?r(I,l,c,!1):null;F&&f.children.push(F)}return f}if(i.type==="vlist"){for(const g of i.children){const v=s._getParentNode(g.id);if(!v)continue;const _=s._vlistItemOffsetOf(i.id,v);if(Number.isNaN(_))continue;const L=g.layoutRect??{x:0,y:0},P=r(g,l-L.x,c+_-i.scrollOffset-L.y,!1);P&&f.children.push(P)}return f}for(const g of i.children){const v=r(g,b,y,!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*hs):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 ds(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.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard());const s=this.widgetRoots.indexOf(e);s>=0&&this.widgetRoots.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 hn(t.src)}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===Se?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===Se){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)}widgetOpen(t,e,s,r){const i=this.nodes.get(t);i&&!this.widgetRoots.includes(i)&&this.widgetRoots.push(i),this.dirty=!0}widgetClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.widgetRoots.indexOf(e):-1;s>=0&&this.widgetRoots.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}pagerPageMounted(t,e){this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent;)e=e.parent;return e}emitKeyboard(){var e,s;const t=this.keyboardHeight();(s=(e=this.options).onKeyboard)==null||s.call(e,t),this.M._creatorWebKeyboardEvent(t,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(Cr)&&this.M._creatorWebNodeEvent(t,xr),this.M._creatorWebSetShrunkRoot(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(Or)&&this.M._creatorWebNodeEvent(t.id,Er),this.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Pr)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,vr,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Ir)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Sr,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(Lr)&&this.M._creatorWebNodeEventNum(t,wr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(Ar)&&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=dt(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i)return this.nodes.get(i.id)??null;if(s[r].backdrop)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=dt(o[a].tree,e,s,l=>{var c;return((c=this.nodes.get(l.id))==null?void 0:c.editable)??!1});if(h){const l=this.nodes.get(h.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(o[a].backdrop)break}for(let a=o.length-1;a>=0;a--){const h=o[a],l=dt(h.tree,e,s,u=>{var f;return((f=this.nodes.get(u.id))==null?void 0:f.interactive)??!1}),c=dt(h.tree,e,s,u=>!!u.scroll&&u.scroll.content>(u.scroll.axis==="x"?u.rect.width:u.rect.height)+.5),d=c?this.nodes.get(c.id)??null:null;if(l){const u=this.nodes.get(l.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(h.backdrop){const u=h.tree.rect,f=e>=u.x&&e<u.x+u.width&&s>=u.y&&s<u.y+u.height;i.backdrop=f?null:this.nodes.get(h.tree.id)??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>us&&(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(Mr)&&i._creatorWebNodeEvent(r.scroll.id,br),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(kr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Fr)&&i._creatorWebNodeEvent(r.backdrop.id,_r):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=dt(i[o].tree,t,e,h=>!!h.scroll&&h.scroll.content>(h.scroll.axis==="x"?h.rect.width:h.rect.height)+.5);if(a){const h=this.nodes.get(a.id);return h?this.scrollBy(h.id,h.scrollAxis==="x"?s:r):!1}if(i[o].backdrop)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(Rr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const ps=`
|
|
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
|
-
`,Se=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),ds=n=>n.type==="native"||n.type==="video",fs=[1,0,0,1,0,0],Ut=(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]],ps=(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 At extends hs{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);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=us,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:(h,c)=>this.M.jsb.viewEvent(e,h,c)},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!==Ft)return;this.dropDestination();const l=this.ensureView(r,i,o);if(!l)return;const h=this.doc.createElement("div");h.style.cssText="position:absolute;inset:0;pointer-events:auto;",h.appendChild(l.el),this.under.prepend(h),this.destination={viewId:r,el:h}}dropView(e,s,r){var i;super.dropView(e,s,r),e===Ft&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==Ft&&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)}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 h=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);h=Ut(Ut(Ut(a,[1,0,0,1,f,p]),c),[1,0,0,1,-f,-p])}(ds(o)||o.id===s)&&e.push({node:o,matrix:h,clip:l});const d=o.clip?ps(l,o.rect):l;for(const u of o.children)r(u,h,d)};for(const o of this.frame())r(o.tree,fs,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=ie(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,l,h]=s.padding??[0,0,0,0];i.padding=`${a}px ${l}px ${h}px ${o}px`,i.color=Se(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",Se(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),At.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"),At.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=ht(o.tree,e,s,l=>{var h,c;return l.type==="native"||(((h=this.get(l.id))==null?void 0:h.interactive)??!1)||(((c=this.get(l.id))==null?void 0:c.editable)??!1)||!!l.scroll});if(a)return a.type==="native";if(o.backdrop)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 gs(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 ms=500,_e=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],ys=(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 m=e.createElement("div");return m.style.cssText="position:absolute;inset:0;overflow:hidden;pointer-events:none;",m},o=i(),a=i();n.insertBefore(o,s),s.after(a);const l=new er({resolveAssetUrl:m=>$n(m),canvasSurfaces:t.canvasHost}),h=new At(t.M,l,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onToast:(m,M)=>gs(e,n,m,M)});let c=1,d=new we(r,c),u=!0;const f=()=>{(u||h.needsPaint())&&(u=!1,h.paint(d,h.paintOptions())),h.place()},p=(m,M,A)=>{m<=0||M<=0||(A!==c&&(c=A,d=new we(r,c)),u=!0,h.resize(m,M))},v=m=>{h.setSafeArea([m.top,m.right,m.bottom,m.left],m.bars??[])},y=m=>{const M=n.getBoundingClientRect(),A=re(n);return[(m.clientX-M.left)/A,(m.clientY-M.top)/A]},E=m=>m.target instanceof Node&&a.contains(m.target),g=m=>m.target instanceof Node&&o.contains(m.target),b=m=>{g(m)&&m.stopPropagation()},_=new Set,L=new Map,P=m=>{const M=L.get(m);M!==void 0&&(clearTimeout(M),L.delete(m))},I=m=>{if(E(m))return;const[M,A]=y(m);if(!h.surfaceAt(M,A)){b(m),_.add(m.pointerId);try{n.setPointerCapture(m.pointerId)}catch{}h.pointerDown(m.pointerId,M,A),P(m.pointerId),L.set(m.pointerId,window.setTimeout(()=>{L.delete(m.pointerId),h.longPress(m.pointerId,M,A)},ms))}},F=m=>{const[M,A]=y(m);_.has(m.pointerId)&&(b(m),h.pointerMove(m.pointerId,M,A)),m.pointerType==="mouse"&&(E(m)||!_.has(m.pointerId)&&h.surfaceAt(M,A)?h.pointerLeave():h.pointerHover(M,A))},W=m=>{m.pointerType==="mouse"&&h.pointerLeave()},R=m=>{if(!_.delete(m.pointerId))return;b(m),P(m.pointerId);const[M,A]=y(m);h.pointerUp(m.pointerId,M,A)},z=m=>{_.delete(m.pointerId)&&(P(m.pointerId),h.pointerCancel(m.pointerId))},G=m=>{if(E(m))return;const[M,A]=y(m);if(h.surfaceAt(M,A))return;b(m);const D=m.deltaMode===1?16:m.deltaMode===2?h.height:1;h.wheel(M,A,m.deltaX*D,m.deltaY*D)&&m.preventDefault()},j=m=>{var Y;if(E(m))return;const M="clientX"in m?m:(Y=m.changedTouches)==null?void 0:Y[0];if(!M)return;const[A,D]=y(M);h.surfaceAt(A,D)||(b(m),m.type==="mousedown"&&m.preventDefault())};n.addEventListener("pointerdown",I,!0),n.addEventListener("pointermove",F,!0),n.addEventListener("pointerleave",W),n.addEventListener("pointerup",R,!0),n.addEventListener("pointercancel",z,!0),n.addEventListener("wheel",G,{passive:!1,capture:!0});for(const m of _e)n.addEventListener(m,j,!0);return{ui:h,render:f,resize:p,setSafeArea:v,destroy(){for(const m of L.keys())P(m);n.removeEventListener("pointerdown",I,!0),n.removeEventListener("pointermove",F,!0),n.removeEventListener("pointerleave",W),n.removeEventListener("pointerup",R,!0),n.removeEventListener("pointercancel",z,!0),n.removeEventListener("wheel",G,!0);for(const m of _e)n.removeEventListener(m,j,!0);h.dispose(),o.remove(),a.remove()}}},ws=["miter","round","bevel"],bs=["butt","round","square"],vs=["left","center","right","start","end"],xs=["alphabetic","top","middle","bottom","hanging","ideographic"],Te=["nonzero","evenodd"],Es=["pad","reflect","repeat"],Wt={COLOR:0,RADIAL:2},mt={MOVE:0,LINE:1,QUAD:2,CUBIC:3,CLOSE:4},X={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 Ss{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===Wt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Wt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Es[this.i()]??"pad",l=this.i(),h=[];for(let c=0;c<l;c++)h.push({offset:this.f(),color:this.color()});return t===Wt.RADIAL?{kind:"radial",alpha:e,matrix:s,fx:r,fy:i,r0:o,spread:a,stops:h}:{kind:"linear",alpha:e,matrix:s,spread:a,stops:h}}stroke(){const t=this.f(),e=ws[this.i()]??"miter",s=bs[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 mt.MOVE:s.push(["M",this.f(),this.f()]);break;case mt.LINE:s.push(["L",this.f(),this.f()]);break;case mt.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case mt.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case mt.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 _s=(n,t)=>{const e=new Ss(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 X.SET_TRANSFORM:s.push({cmd:"setTransform",matrix:e.matrix()});break;case X.SAVE:s.push({cmd:"save"});break;case X.RESTORE:s.push({cmd:"restore"});break;case X.CLIP:{const a=Te[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Te[e.i()]??"nonzero",l=e.paint();s.push({cmd:"fillPath",rule:a,paint:l,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),l=e.paint();s.push({cmd:"strokePath",stroke:a,paint:l,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),l=e.f(),h=e.f(),c=e.f(),d=e.font(),u=vs[e.i()]??"start",f=xs[e.i()]??"alphabetic",p=e.f();if(r===X.STROKE_TEXT){const v=e.stroke();s.push({cmd:"strokeText",text:a,x:l,y:h,maxWidth:c,font:d,align:u,baseline:f,letterSpacing:p,stroke:v,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:l,y:h,maxWidth:c,font:d,align:u,baseline:f,letterSpacing:p,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),l=e.rect4(),h=e.rect4();s.push({cmd:"drawImage",surface:a,src:l,dst:h,alpha:e.f()});break}case X.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},Ts=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),ln=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,hn=(n,t=n.family)=>{const e=Ts.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},St=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],ks=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,Dt=(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}},ke=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,ln(e.color))},_t=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=ln(t.color),s();return}const r=t.matrix;if(ks(r)){let o;if(t.kind==="linear"){const[a,l]=St(r,0,0),[h,c]=St(r,1,0);o=n.createLinearGradient(a,l,h,c)}else{const a=Math.hypot(r[0],r[1]),[l,h]=St(r,0,0),[c,d]=St(r,t.fx,t.fy);o=n.createRadialGradient(c,d,t.r0*a,l,h,a)}ke(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);ke(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},Re=(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},Ae=(n,t,e)=>{n.font=hn(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`)},Rs=(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":Dt(n,i.path),n.clip(i.rule);break;case"fillPath":Dt(n,i.path),_t(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":Dt(n,i.path),Re(n,i.stroke),_t(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":Ae(n,i,e),_t(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":Ae(n,i,e),Re(n,i.stroke),_t(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()}},As=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(h,c,d)=>{if(!t)return null;let u=e.get(h);return u?(u.width!==c||u.height!==d)&&(u.width=c,u.height=d):(u=new OffscreenCanvas(c,d),e.set(h,u)),u},i={paint:(h,c,d,u,f,p)=>{const v=r(h,Math.max(1,c),Math.max(1,d)),y=v==null?void 0:v.getContext("2d");!v||!y||(y.setTransform(1,0,0,1,0,0),y.clearRect(0,0,v.width,v.height),Rs(y,_s(f,p),{image:E=>e.get(E)??null,fontFamily:n}))},measureText:(h,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=hn({family:c,size:d,weight:u,italic:f},c);const v=s.measureText(h);p[0]=v.width,p[1]=v.fontBoundingBoxAscent??v.actualBoundingBoxAscent,p[2]=v.fontBoundingBoxDescent??v.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(h,c)=>{const d=o(h);return d?(c[0]=d.width,c[1]=d.height,new Uint8Array(d.data.buffer,d.data.byteOffset,d.data.byteLength)):null},releaseSurface:h=>{e.delete(h)}},o=h=>{const c=e.get(h),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:h=>{const c=e.get(h);return c?{canvas:c,width:c.width,height:c.height}:null},surfaceToDataUrl:h=>{var u;const c=e.get(h);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()}}},Ls=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,un="Roboto",Ms=[`400 14px ${un}`],Le="data-lecodes-fonts",Ps=async(n=Ms,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${Le}]`)){const s=new URL(Ls,document.baseURI).href,r=e.createElement("style");r.setAttribute(Le,""),r.textContent=`@font-face{font-family:"${un}";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{}}},Cs=(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},Os=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))])},Me="2.0.2",Ht=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},Is=(n,t)=>Ht(n)!==null&&Ht(n)===Ht(t),Fs=[171,75,84,88,32,50,48,187,13,10,26,10],Ns=n=>n.length>=12&&Fs.every((t,e)=>n[e]===t),Us=(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 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},h=(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 v=et(d);if(!v){p(`createTexture: no buffer behind id ${d}`);return}const y=new Uint8Array(v);if(Ns(y)){const E=c._malloc(y.length);c.HEAPU8.set(y,E);const g=c._createTextureFromKtx2(E,y.length)>>>0;if(c._free(E),g===4294967295){p("KTX2 transcode failed");return}f(g,c._getTextureWidth(g),c._getTextureHeight(g));return}createImageBitmap(Pt(d)).then(E=>{const g=l();r.texStorage2D(r.TEXTURE_2D,1,u&1?r.RGBA8:r.SRGB8_ALPHA8,E.width,E.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,E.width,E.height,r.RGBA,r.UNSIGNED_BYTE,E),f(h(c,g,E.width,E.height),E.width,E.height)},E=>p(E instanceof Error?E.message:String(E)))},createMediaPlayerTexture(d){const u=ie(d);if(!u)return 0;const f=l();return a.push({player:u,texture:f,lastTime:0}),h(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()}}},Ws=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(h){return r=h,{open2DScene:a,close2DScene:l}},show:a,hide:l,resize:o,frame(h){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(h)},destroy(){var h;(h=s.getExtension("WEBGL_lose_context"))==null||h.loseContext()}}},Pe=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)},Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dn={};for(let n=0;n<Ce.length;n++)dn[Ce[n]]=n;const Ds=n=>{const t=[];let e=0,s=0;for(const r of n){const i=dn[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 Hs{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 h=Ds(l);h.length!==0&&(a+=h[0],h.length>=4&&(e+=h[1],s+=h[2],r+=h[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 Bs=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 Hs(JSON.parse(e))}catch{return null}};let lt=null;const $s=()=>{if(lt!==null)return lt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return lt=e?parseInt(e[1],10)-1:2,lt}return lt=2,lt},Bt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=$s(),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,
|
|
15
|
-
`);console.error(`[lecodes] native engine error — ${g||
|
|
16
|
-
at ${p.source}:${p.line}:${p.column}${p.fn?` (${p.fn})`:""}`:`[lecodes] ${f}`),(y=
|
|
17
|
-
`),s(
|
|
18
|
-
`);return i={message:(d??"").replace(/^JsTask /,""),stack:u},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",l),e.length=0}}},fn=n=>{var l,h,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=((l=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:l[1])??null,o=((c=(h=t.match(/^\/\/ name: (.+)$/m))==null?void 0:h[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:Cs(t)}},Vs=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",zs=n=>{const t=n.ownerDocument,e=t.defaultView??window,s=(d,u)=>{const f=(e.devicePixelRatio||1)*re(n);return{width:d,height:u,factor:f,pixelWidth:Math.max(1,Math.round(d*f)),pixelHeight:Math.max(1,Math.round(u*f))}};let r=s(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const i=[],o=d=>{d.width!==r.pixelWidth&&(d.width=r.pixelWidth),d.height!==r.pixelHeight&&(d.height=r.pixelHeight)},a=()=>{const d=t.createElement("canvas");return d.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(d),o(d),i.push(d),d},l=new Set,h=d=>{if(!(d.width<=0||d.height<=0)){r=d;for(const u of i)o(u);for(const u of l)u(r)}},c=new ResizeObserver(([d])=>{var E;if(!d)return;const{width:u,height:f}=d.contentRect,p=(E=d.devicePixelContentBoxSize)==null?void 0:E[0],v=s(u,f),y=p&&Math.abs(p.inlineSize-u*v.factor)<=1&&Math.abs(p.blockSize-f*v.factor)<=1;if(!p||!y){h(v);return}h({width:u,height:f,pixelWidth:Math.max(1,p.inlineSize),pixelHeight:Math.max(1,p.blockSize),factor:v.factor})});try{c.observe(n,{box:"device-pixel-content-box"})}catch{c.observe(n)}return{root:n,doc:t,win:e,size:()=>r,newCanvas:a,onResize(d){return l.add(d),()=>{l.delete(d)}},destroy(){c.disconnect(),l.clear();for(const d of i)d.remove();i.length=0}}},Xs=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:st,getBuffer:et}))},allow(s){var i,o;const r=new Set(s);for(const a of t){const l=r.has(a.id);a.kind==="view"?l?(i=n.registerView)==null||i.call(n,a.name,a.factory,a.version):(o=n.unregisterView)==null||o.call(n,a.name):l?n.registerService(a.name,a.factory,a.version):n.unregisterService(a.name)}}}},Ys=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()}}},Ks={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world"},Oe="material:",qs=n=>{const t=new Set;for(const e of n)e.startsWith(Oe)&&t.add(Ks[e.slice(Oe.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},Js=""+new URL("assets/materials-uri4FvPE.bin",import.meta.url).href,Qs=""+new URL("assets/materials-world-CQWt8TAm.bin",import.meta.url).href,Zs=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,ti=""+new URL("assets/uberarchive-DLH-kBhM.bin",import.meta.url).href,ei={base:Js,world:Qs},ni=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},ri=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=qs(n).map(o=>ei[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(Zs),t(ti),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:ni(i)}:{}}},si=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 l,h,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"?(l=a.unlock)==null||l.call(a):(d=(c=(h=a.lock)==null?void 0:h.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)}}},ii=(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([st(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[st(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)}},oi=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(Pt(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)=>ii(t,e,s,r??void 0),requestCamera(t){t()}}),ai=(n={})=>({local:t=>Xn(t),dispose:t=>Gn(t),request(t,e,s,r,i,o,a,l){if(t.startsWith("id:")){const d=Number(t.slice(3));o(d,et(d)?200:404);return}const h={};for(let d=0;d+1<s.length;d+=2)h[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,Pt(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:h,body:c,mode:"cors",credentials:"omit"}),f=l?(d=u.body)==null?void 0:d.getReader():void 0;if(!f){o(st(await u.arrayBuffer()),u.status);return}const p=Number(u.headers.get("content-length"))||void 0,v=[];let y=0;for(;;){const{done:b,value:_}=await f.read();if(b)break;_&&(v.push(_),y+=_.length,l({loaded:y,total:p}))}const E=new Uint8Array(y);let g=0;for(const b of v)E.set(b,g),g+=b.length;o(st(E.buffer),u.status)}catch(u){a(u instanceof Error?u.message:String(u))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>st(t.slice().buffer),bufferSlice(t,e,s){const r=et(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}}),Ie=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],$t=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Tt=4,Gt=16,Fe=16,ci=.5,li=n=>{const t=new Set;let e=null;const s=(x,k,N=-1,C=0)=>{e==null||e(x,k,N,C)},r=x=>{if(!x.code)return;const k=t.has(x.code);t.add(x.code),s(0,x.code,-1,k||x.repeat?1:0)},i=x=>{x.code&&t.delete(x.code)&&s(1,x.code)},o=()=>{for(const x of[...t])x.startsWith("Gamepad")||(t.delete(x),s(1,x))},{root:a}=n;let l=0,h=0,c=0,d=0,u=0,f=0,p=0,v=0,y=0,E=0;const g=x=>{if(x.pointerType&&x.pointerType!=="mouse")return;const k=a.getBoundingClientRect();l=x.clientX-k.left,h=x.clientY-k.top,c+=x.movementX||0,d+=x.movementY||0},b=x=>{const k=Ie[x.button];k&&(t.add(k),s(0,k))},_=x=>{const k=Ie[x.button];k&&t.delete(k)&&s(1,k)},L=x=>{const k=x.deltaMode===0?.01:1;u+=x.deltaX*k,f+=x.deltaY*k},P=x=>{document.pointerLockElement===a&&x.preventDefault()},I=[],F=[],W=[],R=()=>{var k,N;const x=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let C=0;C<Tt;C++){const Q=x[C]??null,S=!!Q&&Q.connected;if(S!==!!I[C]){if(I[C]=S,!S){for(const K of $t)t.delete(K+"@"+C)&&(s(1,K,C),z(K));W[C]=[],F[C]=[0,0,0,0,0,0]}s(S?2:3,"",C)}if(!Q||!S)continue;const O=Q.axes,U=Q.buttons,nt=((k=U[6])==null?void 0:k.value)??0,gt=((N=U[7])==null?void 0:N.value)??0;F[C]=[O[0]??0,O[1]??0,O[2]??0,O[3]??0,nt,gt];const ae=W[C]??(W[C]=[]);for(let K=0;K<$t.length;K++){const Ct=U[K],vt=!!Ct&&(Ct.pressed||Ct.value>ci);if(vt===!!ae[K])continue;ae[K]=vt;const xt=$t[K];vt?t.add(xt+"@"+C):t.delete(xt+"@"+C),z(xt),s(vt?0:1,xt,C)}}},z=x=>{let k=!1;for(let N=0;N<Tt&&!k;N++)t.has(x+"@"+N)&&(k=!0);k?t.add(x):t.delete(x)};let G=0;const j=()=>{p=c,v=d,y=u,E=f,c=d=u=f=0,R(),G=requestAnimationFrame(j)},m=n.windows.filter((x,k,N)=>x&&N.indexOf(x)===k);for(const x of m)n.keyboard!==!1&&(x.addEventListener("keydown",r),x.addEventListener("keyup",i)),x.addEventListener("blur",o);return a.addEventListener("pointermove",g,!0),a.addEventListener("mousedown",b,!0),window.addEventListener("mouseup",_,!0),a.addEventListener("wheel",L,{passive:!0,capture:!0}),a.addEventListener("contextmenu",P,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(j)),{inputKey:(x,k)=>k>=0&&x.startsWith("Gamepad")?t.has(x+"@"+k):t.has(x),inputRead:x=>{var k;switch(x){case 0:return l;case 1:return h;case 2:return p;case 3:return v;case 4:return y;case 5:return E;case 6:return document.pointerLockElement===a?1:0;case 7:{let N=0;for(let C=0;C<Tt;C++)I[C]&&N++;return N}}if(x>=Gt){const N=Math.floor((x-Gt)/Fe),C=(x-Gt)%Fe;return N>=Tt||!I[N]?0:C===0?1:((k=F[N])==null?void 0:k[C-1])??0}return 0},inputSetPointerLock:x=>{if(!x)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const k=a.requestPointerLock({unadjustedMovement:!0});return k&&typeof k.catch=="function"&&k.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:x=>{e=x},dispose:()=>{for(const x of m)x.removeEventListener("keydown",r),x.removeEventListener("keyup",i),x.removeEventListener("blur",o);a.removeEventListener("pointermove",g,!0),a.removeEventListener("mousedown",b,!0),window.removeEventListener("mouseup",_,!0),a.removeEventListener("wheel",L,!0),a.removeEventListener("contextmenu",P,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},hi=n=>{const t=li(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},ui={createVideo:or,createAudio:ar,setVolume:cr,setPlaying:lr,setLoop:hr,time:ur,setTime:dr,duration:fr,remove:pr},di=()=>{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 v=n.get(u);if(!v)return-1;const y=s++,E=v(f?JSON.parse(f):{},{emit:(g,b)=>{b===void 0?p(g):p(g,b)}});return e.set(y,E),y},serviceCall:(u,f,p,v,y)=>{const E=e.get(u);if(!(E!=null&&E.call)){y(`Service call "${f}": no live session or no call handler (serviceId ${u})`);return}try{Promise.resolve(E.call(f,Array.isArray(p)?p:[])).then(g=>{g===void 0?v():v(g)},g=>y(g instanceof Error?g.message:String(g)))}catch(g){y(g instanceof Error?g.message:String(g))}},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()}}},fi=()=>{const n=di();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}},pi=()=>{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}}},gi=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{}}}},Ne=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},mi={fetch:Bn,getBuffer:et,getBlob:Pt,putBuffer:st,putLocalBuffer:jn,hasLocalBuffer:Vn,getLocalName:zn,getPlayer:ie,removePlayers:en},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)},widgetOpen(){},widgetClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),wi=async(n,t={})=>{var Q;const e=t.header,s=t.profile??(e?Vs(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=zs(n),{doc:h,win:c}=l,d=i?Promise.all([Ps(void 0,h),Os((e==null?void 0:e.bootFonts)??[],h)]):null,u=o?Us(l,r.has("capture")):null,f=a?Ws(l):null,p=i?l.newCanvas():null,v=js(c,o);o&&Hn();const[y,E]=await Promise.all([kn(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=>{v.runtimeLine(S)?console.debug(S):console.log(S)},printErr:S=>{console.error(S)}}}),o?ri(r):Promise.resolve({})]),g=(S,O)=>{const U=y.stringToNewUTF8(S);try{return O(U)}finally{y._free(U)}};let b=null,_=-1,L=-1;const P=(S,O)=>{L=S,S===It&&(u==null||u.show()),S===xe&&(f==null||f.show()),b&&S===It&&O!==_&&(_=O,b.openScene(O))},I=S=>{S!==L&&(S===It&&(u==null||u.hide(),b&&_>=0&&(_=-1,b.closeScene())),S===xe&&(f==null||f.hide()))},F=As(),R=p?ys(n,{M:y,canvas:p,canvasHost:F,keyboardHeight:()=>{const S=c.visualViewport;return S?Math.max(0,Math.round((c.innerHeight-S.height-S.offsetTop)/re(n))):0}}):null;R&&(R.ui.onDestination=P,R.ui.onDropped=I);const z=si({onOrientation:t.onOrientation,push:(S,O)=>{S==="url"&&O!==void 0&&g(O,U=>y._creatorWebSetLaunchUrl(U)),g(S,U=>{O===void 0?y._creatorWebAppEvent(U,0):g(O,nt=>y._creatorWebAppEvent(U,nt))})}}),G=pi(),j=fi(),m=hi({windows:[...new Set([c,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,push:(S,O,U,nt)=>g(O,gt=>y._creatorWebInputEvent(S,gt,U,nt)),keyboardHeight:()=>(R==null?void 0:R.ui.keyboardHeight())??0}),M={ui:(R==null?void 0:R.ui)??yi(P,I),app:z.table,device:oi(t.language??(()=>(c.navigator.language||"en").slice(0,2))),fetch:ai(E),storage:gi(t.project??(e==null?void 0:e.name)??"app"),socket:G.table,service:j.table,input:m.table,media:ui,canvas:F.table,...u?{gl:u.table(y)}:{},...f?{scene2d:f.table(y)}:{}},A=Ne(),D=A.global;Fn(y,{host:M,world:A,newWorld:Ne});const Y=Xs({...R?{registerView:(S,O,U)=>R.ui.registerView(S,O,U),unregisterView:S=>R.ui.unregisterView(S)}:{},registerService:j.registerService,unregisterService:j.unregisterService});y._creatorWebInit(),t.launchUrl&&g(t.launchUrl,S=>y._creatorWebSetLaunchUrl(S)),R==null||R.ui.install(),!o&&t.engine3d&&(b=await t.engine3d({newCanvas:l.newCanvas,preloads:r,canvasHost:F,stores:mi}),Object.defineProperty(D,"_creator",{value:b,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Q=D._creator)==null||Q.createEngine());const J=Ys(n);t.safeArea&&J.set(t.safeArea);const x=S=>{var O;u==null||u.resize(),f==null||f.resize(),(O=b==null?void 0:b._onResize)==null||O.call(b,S.width,S.height,S.factor),R?(R.resize(S.width,S.height,S.factor),R.setSafeArea(J.current())):y._creatorWebResize(S.width,S.height)};l.onResize(x),x(l.size());let k=0;const N=S=>{k=c.requestAnimationFrame(N),u==null||u.frame(),y._creatorWebTick(S),f==null||f.frame(S),R&&(R.ui.layoutFrame(),R.ui.tickHover(),R.render())};k=c.requestAnimationFrame(N),await d;let C=!1;return{profile:s,M:y,world:D,ui:(R==null?void 0:R.ui)??null,engine3d:()=>b,getBuffer:S=>et(S),run(S,O={}){const U=O.header??fn(S);if(!Is(U.sdk,Me))throw new Error(`This app was built with LeCodes SDK ${U.sdk??"older than 2.0"}; this host runs SDK ${Me}. It needs a new build.`);const nt=v.track(S,O.onError);return Y.allow(U.plugins),g(S,gt=>y._creatorWebRun(gt)),{dispose:nt.drop}},registerPlugin:(S,O)=>Y.register(S,O),hasPlugin:Y.has,locate:v.locate,safeArea:()=>J.current(),setSafeArea(S){J.set(S),R==null||R.setSafeArea(J.current())},emitAppEvent:z.emit,destroy(){var S;C||(C=!0,c.cancelAnimationFrame(k),v.dispose(),R==null||R.destroy(),m.dispose(),G.dispose(),j.dispose(),z.dispose(),en(),J.destroy(),(S=b==null?void 0:b._dispose)==null||S.call(b),u==null||u.destroy(),f==null||f.destroy(),l.destroy())}}},bi=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)}},
|
|
13
|
+
`,ke=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),gs=n=>n.type==="native"||n.type==="video",ms=[1,0,0,1,0,0],Wt=(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]],ys=(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 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);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=ps,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!==Nt)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===Nt&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==Nt&&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)}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);l=Wt(Wt(Wt(a,[1,0,0,1,f,p]),c),[1,0,0,1,-f,-p])}(gs(o)||o.id===s)&&e.push({node:o,matrix:l,clip:h});const d=o.clip?ys(h,o.rect):h;for(const u of o.children)r(u,l,d)};for(const o of this.frame())r(o.tree,ms,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=oe(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=ke(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",ke(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=dt(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)return a.type==="native";if(o.backdrop)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 ws(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 bs=500,Re=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],vs=(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 m=e.createElement("div");return m.style.cssText="position:absolute;inset:0;overflow:hidden;pointer-events:none;",m},o=i(),a=i();n.insertBefore(o,s),s.after(a);const h=new sr({resolveAssetUrl:m=>Vn(m),canvasSurfaces:t.canvasHost}),l=new Lt(t.M,h,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onToast:(m,M)=>ws(e,n,m,M)});let c=1,d=new xe(r,c),u=!0;const f=()=>{(u||l.needsPaint())&&(u=!1,l.paint(d,l.paintOptions())),l.place()},p=(m,M,A)=>{m<=0||M<=0||(A!==c&&(c=A,d=new xe(r,c)),u=!0,l.resize(m,M))},b=m=>{l.setSafeArea([m.top,m.right,m.bottom,m.left],m.bars??[])},y=m=>{const M=n.getBoundingClientRect(),A=se(n);return[(m.clientX-M.left)/A,(m.clientY-M.top)/A]},x=m=>m.target instanceof Node&&a.contains(m.target),g=m=>m.target instanceof Node&&o.contains(m.target),v=m=>{g(m)&&m.stopPropagation()},_=new Set,L=new Map,P=m=>{const M=L.get(m);M!==void 0&&(clearTimeout(M),L.delete(m))},I=m=>{if(x(m))return;const[M,A]=y(m);if(!l.surfaceAt(M,A)){v(m),_.add(m.pointerId);try{n.setPointerCapture(m.pointerId)}catch{}l.pointerDown(m.pointerId,M,A),P(m.pointerId),L.set(m.pointerId,window.setTimeout(()=>{L.delete(m.pointerId),l.longPress(m.pointerId,M,A)},bs))}},F=m=>{const[M,A]=y(m);_.has(m.pointerId)&&(v(m),l.pointerMove(m.pointerId,M,A)),m.pointerType==="mouse"&&(x(m)||!_.has(m.pointerId)&&l.surfaceAt(M,A)?l.pointerLeave():l.pointerHover(M,A))},W=m=>{m.pointerType==="mouse"&&l.pointerLeave()},R=m=>{if(!_.delete(m.pointerId))return;v(m),P(m.pointerId);const[M,A]=y(m);l.pointerUp(m.pointerId,M,A)},z=m=>{_.delete(m.pointerId)&&(P(m.pointerId),l.pointerCancel(m.pointerId))},G=m=>{if(x(m))return;const[M,A]=y(m);if(l.surfaceAt(M,A))return;v(m);const D=m.deltaMode===1?16:m.deltaMode===2?l.height:1;l.wheel(M,A,m.deltaX*D,m.deltaY*D)&&m.preventDefault()},j=m=>{var Y;if(x(m))return;const M="clientX"in m?m:(Y=m.changedTouches)==null?void 0:Y[0];if(!M)return;const[A,D]=y(M);l.surfaceAt(A,D)||(v(m),m.type==="mousedown"&&m.preventDefault())};n.addEventListener("pointerdown",I,!0),n.addEventListener("pointermove",F,!0),n.addEventListener("pointerleave",W),n.addEventListener("pointerup",R,!0),n.addEventListener("pointercancel",z,!0),n.addEventListener("wheel",G,{passive:!1,capture:!0});for(const m of Re)n.addEventListener(m,j,!0);return{ui:l,render:f,resize:p,setSafeArea:b,destroy(){for(const m of L.keys())P(m);n.removeEventListener("pointerdown",I,!0),n.removeEventListener("pointermove",F,!0),n.removeEventListener("pointerleave",W),n.removeEventListener("pointerup",R,!0),n.removeEventListener("pointercancel",z,!0),n.removeEventListener("wheel",G,!0);for(const m of Re)n.removeEventListener(m,j,!0);l.dispose(),o.remove(),a.remove()}}},xs=["miter","round","bevel"],Es=["butt","round","square"],Ss=["left","center","right","start","end"],_s=["alphabetic","top","middle","bottom","hanging","ideographic"],Ae=["nonzero","evenodd"],Ts=["pad","reflect","repeat"],Dt={COLOR:0,RADIAL:2},wt={MOVE:0,LINE:1,QUAD:2,CUBIC:3,CLOSE:4},X={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 ks{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===Dt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Dt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Ts[this.i()]??"pad",h=this.i(),l=[];for(let c=0;c<h;c++)l.push({offset:this.f(),color:this.color()});return t===Dt.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=xs[this.i()]??"miter",s=Es[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 wt.MOVE:s.push(["M",this.f(),this.f()]);break;case wt.LINE:s.push(["L",this.f(),this.f()]);break;case wt.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case wt.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case wt.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 Rs=(n,t)=>{const e=new ks(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 X.SET_TRANSFORM:s.push({cmd:"setTransform",matrix:e.matrix()});break;case X.SAVE:s.push({cmd:"save"});break;case X.RESTORE:s.push({cmd:"restore"});break;case X.CLIP:{const a=Ae[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Ae[e.i()]??"nonzero",h=e.paint();s.push({cmd:"fillPath",rule:a,paint:h,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),h=e.paint();s.push({cmd:"strokePath",stroke:a,paint:h,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),h=e.f(),l=e.f(),c=e.f(),d=e.font(),u=Ss[e.i()]??"start",f=_s[e.i()]??"alphabetic",p=e.f();if(r===X.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 X.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 X.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},As=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),un=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,dn=(n,t=n.family)=>{const e=As.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Tt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],Ls=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,Ht=(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}},Le=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,un(e.color))},kt=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=un(t.color),s();return}const r=t.matrix;if(Ls(r)){let o;if(t.kind==="linear"){const[a,h]=Tt(r,0,0),[l,c]=Tt(r,1,0);o=n.createLinearGradient(a,h,l,c)}else{const a=Math.hypot(r[0],r[1]),[h,l]=Tt(r,0,0),[c,d]=Tt(r,t.fx,t.fy);o=n.createRadialGradient(c,d,t.r0*a,h,l,a)}Le(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);Le(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},Me=(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},Pe=(n,t,e)=>{n.font=dn(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`)},Ms=(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":Ht(n,i.path),n.clip(i.rule);break;case"fillPath":Ht(n,i.path),kt(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":Ht(n,i.path),Me(n,i.stroke),kt(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":Pe(n,i,e),kt(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":Pe(n,i,e),Me(n,i.stroke),kt(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()}},Ps=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)),y=b==null?void 0:b.getContext("2d");!b||!y||(y.setTransform(1,0,0,1,0,0),y.clearRect(0,0,b.width,b.height),Ms(y,Rs(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=dn({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()}}},Cs=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,fn="Roboto",Os=[`400 14px ${fn}`],Ce="data-lecodes-fonts",Is=async(n=Os,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${Ce}]`)){const s=new URL(Cs,document.baseURI).href,r=e.createElement("style");r.setAttribute(Ce,""),r.textContent=`@font-face{font-family:"${fn}";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{}}},Fs=(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},Ns=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))])},Oe="2.0.3",Bt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},Us=(n,t)=>Bt(n)!==null&&Bt(n)===Bt(t),Ws=[171,75,84,88,32,50,48,187,13,10,26,10],Ds=n=>n.length>=12&&Ws.every((t,e)=>n[e]===t),Hs=(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=et(d);if(!b){p(`createTexture: no buffer behind id ${d}`);return}const y=new Uint8Array(b);if(Ds(y)){const x=c._malloc(y.length);c.HEAPU8.set(y,x);const g=c._createTextureFromKtx2(x,y.length)>>>0;if(c._free(x),g===4294967295){p("KTX2 transcode failed");return}f(g,c._getTextureWidth(g),c._getTextureHeight(g));return}createImageBitmap(Ct(d)).then(x=>{const g=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,g,x.width,x.height),x.width,x.height)},x=>p(x instanceof Error?x.message:String(x)))},createMediaPlayerTexture(d){const u=oe(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()}}},Bs=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()}}},Ie=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)},Fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pn={};for(let n=0;n<Fe.length;n++)pn[Fe[n]]=n;const $s=n=>{const t=[];let e=0,s=0;for(const r of n){const i=pn[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 Gs{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 h of i.split(",")){const l=$s(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 js=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 Gs(JSON.parse(e))}catch{return null}};let ut=null;const Vs=()=>{if(ut!==null)return ut;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return ut=e?parseInt(e[1],10)-1:2,ut}return ut=2,ut},$t=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=Vs(),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},zs=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,Xs=(n,t)=>{const e=[],s=(l,c,d,u)=>{var b,y;if(d.length===0&&Ie(c)){const x=typeof c=="number"||typeof c=="bigint"?`code ${c}`:c instanceof Error?c.message||c.name:String(c),g=[u,x].filter(_=>!!_).filter((_,L,P)=>P.indexOf(_)===L).join(`
|
|
15
|
+
`);console.error(`[lecodes] native engine error — ${g||x} (see the console for the engine's message)`);const v={message:"Native engine error",detail:g,frames:[],native:!0,stack:c instanceof Error?c.stack:void 0};(b=l.onError)==null||b.call(l,v),v.stack&&t&&$n(v.stack).then(_=>{var L;_.length>0&&((L=l.onError)==null||L.call(l,{...v,nativeFrames:_}))});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}`),(y=l.onError)==null||y.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=$t(l,f.sourceMap);if(p.length>0)return s(f,l,p,c)}const d=e[e.length-1];d&&Ie(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?$t(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:js(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?$t(l,c):[]},runtimeLine(l){if(i&&/^\s+at /.test(l))return i.stack.push(l),!0;const c=zs.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}}},gn=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:Fs(t)}},Ys=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",Ks=n=>{const t=n.ownerDocument,e=t.defaultView??window,s=(d,u)=>{const f=(e.devicePixelRatio||1)*se(n);return{width:d,height:u,factor:f,pixelWidth:Math.max(1,Math.round(d*f)),pixelHeight:Math.max(1,Math.round(u*f))}};let r=s(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const i=[],o=d=>{d.width!==r.pixelWidth&&(d.width=r.pixelWidth),d.height!==r.pixelHeight&&(d.height=r.pixelHeight)},a=()=>{const d=t.createElement("canvas");return d.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(d),o(d),i.push(d),d},h=new Set,l=d=>{if(!(d.width<=0||d.height<=0)){r=d;for(const u of i)o(u);for(const u of h)u(r)}},c=new ResizeObserver(([d])=>{var x;if(!d)return;const{width:u,height:f}=d.contentRect,p=(x=d.devicePixelContentBoxSize)==null?void 0:x[0],b=s(u,f),y=p&&Math.abs(p.inlineSize-u*b.factor)<=1&&Math.abs(p.blockSize-f*b.factor)<=1;if(!p||!y){l(b);return}l({width:u,height:f,pixelWidth:Math.max(1,p.inlineSize),pixelHeight:Math.max(1,p.blockSize),factor:b.factor})});try{c.observe(n,{box:"device-pixel-content-box"})}catch{c.observe(n)}return{root:n,doc:t,win:e,size:()=>r,newCanvas:a,onResize(d){return h.add(d),()=>{h.delete(d)}},destroy(){c.disconnect(),h.clear();for(const d of i)d.remove();i.length=0}}},qs=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:ot,getBuffer:et}))},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)}}}},Js=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()}}},Qs={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world"},Ne="material:",Zs=n=>{const t=new Set;for(const e of n)e.startsWith(Ne)&&t.add(Qs[e.slice(Ne.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},ti=""+new URL("assets/materials-uri4FvPE.bin",import.meta.url).href,ei=""+new URL("assets/materials-world-CQWt8TAm.bin",import.meta.url).href,ni=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,ri=""+new URL("assets/uberarchive-DLH-kBhM.bin",import.meta.url).href,si={base:ti,world:ei},ii=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},oi=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=Zs(n).map(o=>si[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(ni),t(ri),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:ii(i)}:{}}},ai=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)}}},ci=(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([ot(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ot(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)}},li=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(Ct(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)=>ci(t,e,s,r??void 0),requestCamera(t){t()}}),hi=(n={})=>({local:t=>qn(t),dispose:t=>zn(t),request(t,e,s,r,i,o,a,h){if(t.startsWith("id:")){const d=Number(t.slice(3));o(d,et(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,Ct(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(ot(await u.arrayBuffer()),u.status);return}const p=Number(u.headers.get("content-length"))||void 0,b=[];let y=0;for(;;){const{done:v,value:_}=await f.read();if(v)break;_&&(b.push(_),y+=_.length,h({loaded:y,total:p}))}const x=new Uint8Array(y);let g=0;for(const v of b)x.set(v,g),g+=v.length;o(ot(x.buffer),u.status)}catch(u){a(u instanceof Error?u.message:String(u))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>ot(t.slice().buffer),bufferSlice(t,e,s){const r=et(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}}),Ue=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Gt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Rt=4,jt=16,We=16,ui=.5,di=n=>{const t=new Set;let e=null;const s=(E,k,N=-1,C=0)=>{e==null||e(E,k,N,C)},r=E=>{if(!E.code)return;const k=t.has(E.code);t.add(E.code),s(0,E.code,-1,k||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,y=0,x=0;const g=E=>{if(E.pointerType&&E.pointerType!=="mouse")return;const k=a.getBoundingClientRect();h=E.clientX-k.left,l=E.clientY-k.top,c+=E.movementX||0,d+=E.movementY||0},v=E=>{const k=Ue[E.button];k&&(t.add(k),s(0,k))},_=E=>{const k=Ue[E.button];k&&t.delete(k)&&s(1,k)},L=E=>{const k=E.deltaMode===0?.01:1;u+=E.deltaX*k,f+=E.deltaY*k},P=E=>{document.pointerLockElement===a&&E.preventDefault()},I=[],F=[],W=[],R=()=>{var k,N;const E=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let C=0;C<Rt;C++){const Q=E[C]??null,S=!!Q&&Q.connected;if(S!==!!I[C]){if(I[C]=S,!S){for(const K of Gt)t.delete(K+"@"+C)&&(s(1,K,C),z(K));W[C]=[],F[C]=[0,0,0,0,0,0]}s(S?2:3,"",C)}if(!Q||!S)continue;const O=Q.axes,U=Q.buttons,rt=((k=U[6])==null?void 0:k.value)??0,yt=((N=U[7])==null?void 0:N.value)??0;F[C]=[O[0]??0,O[1]??0,O[2]??0,O[3]??0,rt,yt];const he=W[C]??(W[C]=[]);for(let K=0;K<Gt.length;K++){const Ot=U[K],Et=!!Ot&&(Ot.pressed||Ot.value>ui);if(Et===!!he[K])continue;he[K]=Et;const St=Gt[K];Et?t.add(St+"@"+C):t.delete(St+"@"+C),z(St),s(Et?0:1,St,C)}}},z=E=>{let k=!1;for(let N=0;N<Rt&&!k;N++)t.has(E+"@"+N)&&(k=!0);k?t.add(E):t.delete(E)};let G=0;const j=()=>{p=c,b=d,y=u,x=f,c=d=u=f=0,R(),G=requestAnimationFrame(j)},m=n.windows.filter((E,k,N)=>E&&N.indexOf(E)===k);for(const E of m)n.keyboard!==!1&&(E.addEventListener("keydown",r),E.addEventListener("keyup",i)),E.addEventListener("blur",o);return a.addEventListener("pointermove",g,!0),a.addEventListener("mousedown",v,!0),window.addEventListener("mouseup",_,!0),a.addEventListener("wheel",L,{passive:!0,capture:!0}),a.addEventListener("contextmenu",P,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(j)),{inputKey:(E,k)=>k>=0&&E.startsWith("Gamepad")?t.has(E+"@"+k):t.has(E),inputRead:E=>{var k;switch(E){case 0:return h;case 1:return l;case 2:return p;case 3:return b;case 4:return y;case 5:return x;case 6:return document.pointerLockElement===a?1:0;case 7:{let N=0;for(let C=0;C<Rt;C++)I[C]&&N++;return N}}if(E>=jt){const N=Math.floor((E-jt)/We),C=(E-jt)%We;return N>=Rt||!I[N]?0:C===0?1:((k=F[N])==null?void 0:k[C-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 k=a.requestPointerLock({unadjustedMovement:!0});return k&&typeof k.catch=="function"&&k.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:E=>{e=E},dispose:()=>{for(const E of m)E.removeEventListener("keydown",r),E.removeEventListener("keyup",i),E.removeEventListener("blur",o);a.removeEventListener("pointermove",g,!0),a.removeEventListener("mousedown",v,!0),window.removeEventListener("mouseup",_,!0),a.removeEventListener("wheel",L,!0),a.removeEventListener("contextmenu",P,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},fi=n=>{const t=di(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},pi={createVideo:lr,createAudio:hr,setVolume:ur,setPlaying:dr,setLoop:fr,time:pr,setTime:gr,duration:mr,remove:yr},gi=()=>{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 y=s++,x=b(f?JSON.parse(f):{},{emit:(g,v)=>{v===void 0?p(g):p(g,v)}});return e.set(y,x),y},serviceCall:(u,f,p,b,y)=>{const x=e.get(u);if(!(x!=null&&x.call)){y(`Service call "${f}": no live session or no call handler (serviceId ${u})`);return}try{Promise.resolve(x.call(f,Array.isArray(p)?p:[])).then(g=>{g===void 0?b():b(g)},g=>y(g instanceof Error?g.message:String(g)))}catch(g){y(g instanceof Error?g.message:String(g))}},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()}}},mi=()=>{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}},yi=()=>{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}}},wi=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{}}}},De=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},bi={fetch:jn,getBuffer:et,getBlob:Ct,putBuffer:ot,putLocalBuffer:Xn,hasLocalBuffer:Yn,getLocalName:Kn,getPlayer:oe,removePlayers:rn},vi=(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)},widgetOpen(){},widgetClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),xi=async(n,t={})=>{var Q;const e=t.header,s=t.profile??(e?Ys(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=Ks(n),{doc:l,win:c}=h,d=i?Promise.all([Is(void 0,l),Ns((e==null?void 0:e.bootFonts)??[],l)]):null,u=o?Hs(h,r.has("capture")):null,f=a?Bs(h):null,p=i?h.newCanvas():null,b=Xs(c,o);o&&Gn();const[y,x]=await Promise.all([Ln(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?oi(r):Promise.resolve({})]),g=(S,O)=>{const U=y.stringToNewUTF8(S);try{return O(U)}finally{y._free(U)}};let v=null,_=-1,L=-1;const P=(S,O)=>{L=S,S===Ft&&(u==null||u.show()),S===_e&&(f==null||f.show()),v&&S===Ft&&O!==_&&(_=O,v.openScene(O))},I=S=>{S!==L&&(S===Ft&&(u==null||u.hide(),v&&_>=0&&(_=-1,v.closeScene())),S===_e&&(f==null||f.hide()))},F=Ps(),R=p?vs(n,{M:y,canvas:p,canvasHost:F,keyboardHeight:()=>{const S=c.visualViewport;return S?Math.max(0,Math.round((c.innerHeight-S.height-S.offsetTop)/se(n))):0}}):null;R&&(R.ui.onDestination=P,R.ui.onDropped=I);const z=ai({onOrientation:t.onOrientation,push:(S,O)=>{S==="url"&&O!==void 0&&g(O,U=>y._creatorWebSetLaunchUrl(U)),g(S,U=>{O===void 0?y._creatorWebAppEvent(U,0):g(O,rt=>y._creatorWebAppEvent(U,rt))})}}),G=yi(),j=mi(),m=fi({windows:[...new Set([c,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,push:(S,O,U,rt)=>g(O,yt=>y._creatorWebInputEvent(S,yt,U,rt)),keyboardHeight:()=>(R==null?void 0:R.ui.keyboardHeight())??0}),M={ui:(R==null?void 0:R.ui)??vi(P,I),app:z.table,device:li(t.language??(()=>(c.navigator.language||"en").slice(0,2))),fetch:hi(x),storage:wi(t.project??(e==null?void 0:e.name)??"app"),socket:G.table,service:j.table,input:m.table,media:pi,canvas:F.table,...u?{gl:u.table(y)}:{},...f?{scene2d:f.table(y)}:{}},A=De(),D=A.global;Wn(y,{host:M,world:A,newWorld:De});const Y=qs({...R?{registerView:(S,O,U)=>R.ui.registerView(S,O,U),unregisterView:S=>R.ui.unregisterView(S)}:{},registerService:j.registerService,unregisterService:j.unregisterService});y._creatorWebInit(),t.launchUrl&&g(t.launchUrl,S=>y._creatorWebSetLaunchUrl(S)),R==null||R.ui.install(),!o&&t.engine3d&&(v=await t.engine3d({newCanvas:h.newCanvas,preloads:r,canvasHost:F,stores:bi}),Object.defineProperty(D,"_creator",{value:v,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Q=D._creator)==null||Q.createEngine());const J=Js(n);t.safeArea&&J.set(t.safeArea);const E=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),R?(R.resize(S.width,S.height,S.factor),R.setSafeArea(J.current())):y._creatorWebResize(S.width,S.height)};h.onResize(E),E(h.size());let k=0;const N=S=>{k=c.requestAnimationFrame(N),u==null||u.frame(),y._creatorWebTick(S),f==null||f.frame(S),R&&(R.ui.layoutFrame(),R.ui.tickHover(),R.render())};k=c.requestAnimationFrame(N),await d;let C=!1;return{profile:s,M:y,world:D,ui:(R==null?void 0:R.ui)??null,engine3d:()=>v,getBuffer:S=>et(S),run(S,O={}){const U=O.header??gn(S);if(!Us(U.sdk,Oe))throw new Error(`This app was built with LeCodes SDK ${U.sdk??"older than 2.0"}; this host runs SDK ${Oe}. It needs a new build.`);const rt=b.track(S,O.onError);return Y.allow(U.plugins),g(S,yt=>y._creatorWebRun(yt)),{dispose:rt.drop}},registerPlugin:(S,O)=>Y.register(S,O),hasPlugin:Y.has,locate:b.locate,safeArea:()=>J.current(),setSafeArea(S){J.set(S),R==null||R.setSafeArea(J.current())},emitAppEvent:z.emit,destroy(){var S;C||(C=!0,c.cancelAnimationFrame(k),b.dispose(),R==null||R.destroy(),m.dispose(),G.dispose(),j.dispose(),z.dispose(),rn(),J.destroy(),(S=v==null?void 0:v._dispose)==null||S.call(v),u==null||u.destroy(),f==null||f.destroy(),h.destroy())}}},Ei=(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)}})}),Si=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)}},_i=(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(Si).join(" ")}),error:o=>e({type:"error",text:o})}},Ti={camera:()=>q(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>q(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>q(()=>import("./assets/map-XzoOFt0E.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>q(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>q(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t))},ki=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=Ti[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)}`)}}))},ae=n=>typeof n=="object"&&n!==null,pt=n=>typeof n=="number"&&Number.isFinite(n),Ri=n=>{if(!ae(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return pt(n.x)&&pt(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return pt(n.node)?{ask:"node",node:n.node}:null;default:return null}},mn=n=>{if(!ae(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}:{}}},Ai=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return mn({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},Li=n=>{if(!ae(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:mn(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:inspect":{const t=Ri(n.question);return t&&pt(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!pt(n.request))return null;const t=pt(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}},Mi=(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}},Pi=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=Li(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)}}},ce=window.lecodesPlayerConfig??{},bt=document.getElementById("app"),Vt=document.getElementById("loader"),He=document.getElementById("error"),gt=new URLSearchParams(location.search),yn=n=>Vt==null?void 0:Vt.classList.toggle("on",n),wn=n=>{He&&(He.textContent=window.parent===window?n:"")};let ee=ce.language||gt.get("lang")||(navigator.language||"en").slice(0,2),Mt=ce.safeArea??Ai(gt),H=null;const Ci=gt.has("inspect"),ne=Ci?q(()=>import("./assets/inspect-DdJ50Kun.js"),[],import.meta.url):null;let ft=null;const Oi=async(n,t)=>{const{createInspector:e}=await(ne??q(()=>import("./assets/inspect-DdJ50Kun.js"),[],import.meta.url));H&&ft===null&&(ft=e(H)),nt.post({type:"lecodes:inspected",request:n,answer:(ft==null?void 0:ft.answer(t))??null})},Be=gt.has("dev")?new URL(gt.get("dev")||"..",location.href).href.replace(/\/$/,""):null,$e=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}`},
|
|
21
|
+
in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},bn=n=>{wn($e(n)),nt.post({type:"lecodes:error",error:n}),V==null||V.error($e(n))},vn=n=>bn({message:n,frames:[]});let it=null,zt=!1,Xt=null;const Ii=async n=>{yn(!0),wn(""),H==null||H.destroy(),H=null,ft=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=gn(e);H=await xi(bt,{header:s,language:()=>ee,launchUrl:location.href,...Mt?{safeArea:Mt}:{},...nt.embedded?{onOrientation:r=>nt.post({type:"lecodes:orientation",mode:r})}:{}}),await ki(H,s.plugins),ne&&(await ne).recordSites(H),H.run(e,{onError:bn}),V&&n.version!==void 0&&(Pt=V.versionOf(t,n.version),V.ran(Pt)),nt.post({type:"lecodes:ready",src:n.src})},at=n=>{if(zt){Xt=n;return}zt=!0,it=n,Ii(n).catch(t=>vn(t instanceof Error?t.message:String(t))).finally(()=>{yn(!1),zt=!1;const t=Xt;Xt=null,t&&at(t)})},le=n=>{const t=Mi(n,location.href);t?at({src:t}):vn(`The player runs bundles of its own origin only: ${n}`)},xn=n=>{Mt=n,H==null||H.setSafeArea(Mt)},En=async n=>({image:H?await Ei(bt,n):null,width:bt.clientWidth,height:bt.clientHeight}),nt=Pi(window,n=>{switch(n.type){case"lecodes:run":le(n.src);break;case"lecodes:reload":it&&at(it);break;case"lecodes:safe-area":xn(n.insets);break;case"lecodes:inspect":Oi(n.request,n.question);break;case"lecodes:capture":En(n.pixelRatio).then(t=>nt.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===ee)break;ee=n.language,it&&at(it);break}});let Pt=-1;const V=Be?_i(Be,n=>{Pt>=0&&n!==Pt&&at({src:V.bundleUrl(n),version:n})}):null;if(V||nt.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),nt.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:"fb958fa-2026-09-29",get host(){return H},run:le,reload(){it&&at(it)},setSafeArea:xn,capture:async n=>(await En(n)).image};const Ge=ce.src??gt.get("src");V?at({src:V.bundleUrl(0),version:0}):Ge&&le(Ge);export{q as _};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lecodes-web-player",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "The web player of LeCodes: a page that runs a compiled app in the browser (Filament, creator-2d, the tree UI) — a static folder, driven by its url and by messages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"prepublishOnly": "bun run build"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"lecodes-web-host": "2.0.
|
|
20
|
+
"lecodes-web-host": "2.0.3",
|
|
21
21
|
"maplibre-gl": "^6.7.0",
|
|
22
22
|
"@types/geojson": "^7946.0.16",
|
|
23
23
|
"pngjs": "^7.0.0",
|