lecodes-cli 2.4.9 → 2.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "a484159a-2026-10-28",
3
- "commit": "a484159a",
4
- "date": "2026-10-28T07:54:48.449Z"
2
+ "version": "356d0480-2026-10-28",
3
+ "commit": "356d0480",
4
+ "date": "2026-10-28T09:19:37.383Z"
5
5
  }
@@ -10,7 +10,7 @@ var Hn=Object.defineProperty;var $n=(n,t,e)=>t in n?Hn(n,t,{enumerable:!0,config
10
10
  `)){let h=ce(l,o,e);a&&(r>0&&i.length+h.length>r?a=!1:s==="balance"?h=ns(l,o,h,e):h=rs(o,h,e));for(const u of h)i.push(u)}let c=0;for(const l of i)c=Math.max(c,e(l));return{lines:i,maxWidth:c}}function bn(n,t,e,s,r){const i=t.textWrap??"wrap",o=Nt(n,e,s,i,t.lineClamp??0),a=i==="nowrap"&&!r?1/0:e,c=ss(o.lines,t,a,s);return i!=="nowrap"||!r||t.textOverflow==="clip"||!isFinite(e)?c:c.map(l=>s(l)>e?vn(l,e,s):l)}const jt="…";function ss(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]=vn(i[r-1],e,s)),i}function vn(n,t,e){if(!isFinite(t))return n+jt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+jt)>t;)r--;return s.slice(0,r).join("").trimEnd()+jt}function is(n,t,e){const s=ae(n),r=wn(s),i=isNaN(e)?1/0:e,o=l=>t.measureText(l,r),a=bn(n.text??"",n.style,i,o,!1);let c=0;for(const l of a)c=Math.max(c,o(l));return{width:Math.ceil(c),height:Math.ceil(a.length*s.lineHeight)}}function os(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,c=Nt(o,a,l=>t.measureText(l,r));return{width:Math.ceil(c.maxWidth),height:Math.ceil(Math.max(1,c.lines.length)*i)}}function as(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(hn(r)){const l=se(r.svg);if(l)i=l.width,o=l.height;else{const h=t.getImage(t.resolveSrc(r)??"");i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}}else{const l=t.resolveSrc(r),h=l?t.getImage(l):void 0;i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),c=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*c,height:o*c}}const xn=(n,t,e,s)=>t?[n[0],n[1],n[2],n[3],n[4]+e*t[0]+s*t[2],n[5]+e*t[1]+s*t[3]]:n;function cs(n,t,e,s,r,i,o={}){t.beginFrame(s,r);for(const a of n)En(a.tree,t,e,o);t.endFrame()}function En(n,t,e,s){var h;const{style:r,rect:i}=n;t.save();const o=r.opacity!==void 0&&r.opacity<1?r.opacity:void 0,a=o!==void 0&&n.children.length>0;if(a?t.beginGroup(o):o!==void 0&&t.setAlpha(o),r.transform){const[u,d,f,g,m,x]=xn(r.transform,r.transformBox,i.width,i.height),y=r.transformOrigin,p=i.x+(y?y.xPercent?i.width*y.x/100:y.x:i.width/2),w=i.y+(y?y.yPercent?i.height*y.y/100:y.y:i.height/2);t.translate(p,w),t.transform(u,d,f,g,m,x),t.translate(-p,-w)}const c=oe(r.borderRadius,i);if(ie(r.backgroundColor)||t.fillRoundRect(i,c,r.backgroundColor),r.backgroundImage){const u=e.getImage(r.backgroundImage);u&&u.naturalWidth>0&&u.naturalHeight>0&&(t.save(),Ae(c)&&t.clipRoundRect(i,c),t.drawImage(u,null,i,{fit:ls(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let u=r.backgroundGradients.length-1;u>=0;u--){const d=r.backgroundGradients[u];d.stops.length>0&&t.fillGradient(i,c,d)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const u=n.sourceRect;t.save(),Ae(c)&&t.clipRoundRect(i,c),t.drawImage(n.image,u?{x:u[0],y:u[1],width:u[2],height:u[3]}:null,i,{fit:u?"fill":r.objectFit??"contain",tint:Vt(n.image.src)?r.tintColor:void 0,radius:c}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&us(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&ys(n,t,e,c),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,c):n.type==="video"?ds(n,t,e,c):((h=n.view)==null?void 0:h.label)!==void 0&&ms(n,n.view.name,n.view.label,t,e,c)),n.clip&&t.clipRoundRect(i,c);for(const u of n.children)u.overlay!==void 0&&!ie(u.overlay)&&t.fillRoundRect(i,void 0,u.overlay),En(u,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,c,Math.round(Math.min(1,r.dim)*255)>>>0);const l=hs(r.border);l&&t.strokeBorder(i,c,l),a&&t.endGroup(),t.restore()}function ls(n){return n==="contain"||n==="fill"?n:"cover"}function hs(n){if(!n)return null;const t={};let e=!1;for(const s of["top","right","bottom","left"]){const r=n[s];r&&r.width>0&&(r.color>>>0)%256!==0&&(t[s]=r,e=!0)}return e?t:null}const pe=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function us(n,t,e){var x,y,p;const s=n.style,r={family:pe(e,s.fontFamily),size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.color??255,o=s.lineHeight,a=s.textAlign??"start",c=e.fontMetrics(r),{rect:l,lines:h}=n,u=((x=n.padding)==null?void 0:x[0])??0,d=((y=n.padding)==null?void 0:y[1])??0,f=((p=n.padding)==null?void 0:p[2])??0,g=l.x+u,m=l.width-u-f;for(let w=0;w<h.length;w++){const E=h[w],L=l.y+d+w*o+(o-(c.ascent+c.descent))/2+c.ascent,C=e.measureText(E,r),F=a==="center"?g+(m-C)/2:a==="end"?g+m-C:g;if(t.fillText(E,F,L,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const U=Math.max(1,r.size/14),$=s.textDecoration==="underline"?L+U:L-r.size*.3;t.fillRoundRect({x:F,y:$,width:C,height:U},void 0,i)}}}function ds(n,t,e,s){const{rect:r}=n;ie(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),c=e.measureText("▶",o),l=r.x+(r.width-c)/2,h=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",l,h,o,4294967244)}}const fs=3722701567,gs=1263887359,ps=2324997119;function ms(n,t,e,s,r,i){const{rect:o}=n;s.fillRoundRect(o,i,fs);const a=pe(r,void 0),c={family:a,size:17,weight:600,italic:!1,letterSpacing:0},l={family:a,size:13,weight:400,italic:!1,letterSpacing:0},h=[];if(e&&h.push([e,c,gs]),t&&t!==e&&h.push([t,l,ps]),h.length===0)return;const u=4,d=h.map(([,g])=>{const m=r.fontMetrics(g);return m.ascent+m.descent});let f=o.y+(o.height-d.reduce((g,m)=>g+m,0)-u*(h.length-1))/2;s.save(),s.clipRoundRect(o,i),h.forEach(([g,m,x],y)=>{const p=o.x+(o.width-r.measureText(g,m))/2;s.fillText(g,p,f+r.fontMetrics(m).ascent,m,x),f+=d[y]+u}),s.restore()}function ys(n,t,e,s){var K,G,q,A,v;const r=n.style,i={family:pe(e,r.fontFamily),size:r.fontSize??14,weight:r.fontWeight??400,italic:r.fontStyle==="italic",letterSpacing:r.letterSpacing??0},o=n.value??"",a=o.length===0,c=r.inputType==="password"&&!a,l=a?r.placeholder??"":c?"•".repeat(o.length):o,h=a?r.placeholderColor??2576980479:r.color??255,{rect:u}=n,d=((K=n.padding)==null?void 0:K[0])??0,f=((G=n.padding)==null?void 0:G[1])??0,g=((q=n.padding)==null?void 0:q[2])??0,m=((A=n.padding)==null?void 0:A[3])??0,x=u.x+d,y=u.width-d-g,p=u.y+f,w=u.height-f-m,E=e.fontMetrics(i),k=r.lineHeight,L=r.textAlign??"start",C=n.type==="textarea",F=C?Nt(l,y,T=>e.measureText(T,i)).lines:[l],U=T=>L==="center"?x+(y-T)/2:L==="end"?x+y-T:x,$=T=>C?p+T*k+(k-(E.ascent+E.descent))/2+E.ascent:p+(w-(E.ascent+E.descent))/2+E.ascent;t.save(),t.clipRoundRect(u,s);for(let T=0;T<F.length;T++){const O=F[T];O.length>0&&t.fillText(O,U(e.measureText(O,i)),$(T),i,h)}if((v=n.state)!=null&&v.focused){const T=a?[""]:C?Nt(c?"•".repeat(o.length):o,y,N=>e.measureText(N,i)).lines:[l],O=T.length-1,j=e.measureText(T[O],i),J=a?U(0):U(j)+j,_=$(O),M=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:_-E.ascent,width:M,height:E.ascent+E.descent},void 0,r.color??255)}t.restore()}const ws=84,bs={display:{word:4},overflow:{word:5},scrollDirection:{word:6},borderTopWidth:{word:8},borderRightWidth:{word:9},borderBottomWidth:{word:10},borderLeftWidth:{word:11},color:{bit:12,word:16},backgroundColor:{word:17},borderTopColor:{word:19},borderRightColor:{word:20},borderBottomColor:{word:21},borderLeftColor:{word:22},placeholderColor:{bit:19,word:23},tintColor:{bit:21,word:25},overlayColor:{bit:23,word:27},backgroundImage:{word:28},backgroundSize:{word:29},backgroundGradient:{word:30},borderTopLeftRadius:{word:32},borderTopRightRadius:{word:33},borderBottomRightRadius:{word:34},borderBottomLeftRadius:{word:35},opacity:{word:36},transform:{word:37},transformOrigin:{word:50},fontSize:{word:55},fontWeight:{word:56},fontStyle:{word:57},fontFamily:{bit:39,word:58},lineHeight:{word:59},letterSpacing:{word:60},textAlign:{word:61},textDecoration:{word:62},lineClamp:{word:63},textOverflow:{word:64},textWrap:{word:65},objectFit:{word:66},placeholder:{word:67},type:{word:68},dim:{word:82}},vs={hidden:1},xs={horizontal:1},Es={italic:1},ht={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],textWrap:["wrap","nowrap","balance","pretty"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},Ss=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,_s=["farthest-corner","closest-side","closest-corner","farthest-side"],ks=52;function Ts(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Rs(n,t,e+i*ks));return r}function Rs(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],c=[];for(let l=0;l<o;l++){const h=a+l*8>>2;c.push({color:t[h]>>>0,position:n[h+1]})}if(i===1){const l=t[s+6],h={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:c};return l===4?{...h,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...h,extent:_s[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:c}}const R=bs,As=["start","center","end","start","end"];let Lt=0;function Sn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],c=F=>Ss(o,a,F),l=F=>{const U=s[i+F];return U===0?void 0:n.UTF8ToString(n._cuiStringOf(U))};e.backgroundColor=s[i+R.backgroundColor.word]>>>0,e.opacity=r[i+R.opacity.word],e.dim=r[i+R.dim.word],e.display=ht.display[s[i+R.display.word]],e.overflow=s[i+R.overflow.word]===vs.hidden?"hidden":"visible",e.scrollAxis=s[i+R.scrollDirection.word]===xs.horizontal?"x":"y",e.border={top:{width:r[i+R.borderTopWidth.word],color:s[i+R.borderTopColor.word]>>>0},right:{width:r[i+R.borderRightWidth.word],color:s[i+R.borderRightColor.word]>>>0},bottom:{width:r[i+R.borderBottomWidth.word],color:s[i+R.borderBottomColor.word]>>>0},left:{width:r[i+R.borderLeftWidth.word],color:s[i+R.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+R.borderTopLeftRadius.word],tr:r[i+R.borderTopRightRadius.word],br:r[i+R.borderBottomRightRadius.word],bl:r[i+R.borderBottomLeftRadius.word]},e.backgroundImage=l(R.backgroundImage.word),e.backgroundSize=ht.backgroundSize[s[i+R.backgroundSize.word]];const h=s[i+R.backgroundGradient.word];if(h===0)e.backgroundGradients=void 0;else{Lt===0&&(Lt=n._malloc(4));const F=n._cuiGradientOf(h,Lt),U=n.HEAPU32[Lt>>>2];e.backgroundGradients=F!==0&&U>0?Ts(n.HEAPF32,n.HEAPU32,F,U):void 0}const u=i+R.transform.word,d=r[u],f=r[u+1],g=r[u+3],m=r[u+4],x=r[u+6],y=r[u+7],p=r[u+9],w=r[u+10],E=r[u+11],k=r[u+12],L=p===0&&w===0&&E===0&&k===0;e.transform=d===1&&f===0&&g===0&&m===1&&x===0&&y===0&&L?void 0:[d,f,g,m,x,y],e.transformBox=L?void 0:[p,w,E,k];const C=i+R.transformOrigin.word;e.transformOrigin={x:r[C],y:r[C+1],xPercent:s[C+2]!==0,yPercent:s[C+3]!==0},e.color=c(R.color.bit)?s[i+R.color.word]>>>0:void 0,e.fontFamily=c(R.fontFamily.bit)?l(R.fontFamily.word):void 0,e.fontSize=r[i+R.fontSize.word],e.fontWeight=r[i+R.fontWeight.word],e.fontStyle=s[i+R.fontStyle.word]===Es.italic?"italic":"normal",e.lineHeight=r[i+R.lineHeight.word],e.letterSpacing=r[i+R.letterSpacing.word],e.textAlign=As[s[i+R.textAlign.word]]??"start",e.textDecoration=ht.textDecoration[s[i+R.textDecoration.word]],e.lineClamp=r[i+R.lineClamp.word],e.textOverflow=ht.textOverflow[s[i+R.textOverflow.word]],e.textWrap=ht.textWrap[s[i+R.textWrap.word]],e.objectFit=ht.objectFit[s[i+R.objectFit.word]],e.tintColor=c(R.tintColor.bit)?s[i+R.tintColor.word]>>>0:void 0,e.placeholder=l(R.placeholder.word),e.placeholderColor=c(R.placeholderColor.bit)?s[i+R.placeholderColor.word]>>>0:void 0,e.inputType=ht.type[s[i+R.type.word]],e.overlayColor=c(R.overlayColor.bit)?s[i+R.overlayColor.word]>>>0:void 0}function Ms(n,t){const e=n._cuiPaintOf(t);if(e===0)return!1;const s=e>>>2;return n.HEAPU32[s+2]!==0||n.HEAPU32[s+3]!==0}function Ls(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(Sn(n,s,e),!0)}function Ps(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*ws*4;t(o,c=>Sn(n,a,c))}return e}function _n(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?le(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>le(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function Os(n,t=[],e){return JSON.stringify(_n(n,t,e),null,2)}function yt(n,t){const e=10**t;return Math.round(n*e)/e}function le(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),n.view&&(r.view=n.view.name),r.rect=[yt(s.x,t),yt(s.y,t),yt(s.width,t),yt(s.height,t)],e&&(r.id=n.id);const i=Is(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:yt(n.scroll.offset,t),content:yt(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(c=>le(c,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 Is(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=mt(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=mt(n.color)),n.fontSize!==void 0&&(t.fontSize=n.fontSize),n.fontFamily!==void 0&&(t.fontFamily=n.fontFamily),n.fontWeight!==void 0&&(t.fontWeight=n.fontWeight),n.fontStyle!==void 0&&n.fontStyle!=="normal"&&(t.fontStyle=n.fontStyle),n.lineHeight!==void 0&&(t.lineHeight=n.lineHeight),n.letterSpacing&&(t.letterSpacing=n.letterSpacing),n.textAlign!==void 0&&n.textAlign!=="start"&&(t.textAlign=n.textAlign),n.textDecoration!==void 0&&n.textDecoration!=="none"&&(t.textDecoration=n.textDecoration),n.lineClamp&&(t.lineClamp=n.lineClamp,n.textOverflow==="clip"&&(t.textOverflow=n.textOverflow)),n.textWrap!==void 0&&n.textWrap!=="wrap"&&(t.textWrap=n.textWrap),n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=mt(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=mt(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:mt(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:mt(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const Fs=.32,Ns=4,Us={},Ie=new Map;function he(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Ie.get(n);return t===void 0&&(t=un(n.slice(4)),Ie.set(n,t)),t}return n}class Bs{constructor(t,e){b(this,"parent",null);b(this,"children",[]);b(this,"style",{lineHeight:14*1.2});b(this,"name");b(this,"text","");b(this,"src");b(this,"value","");b(this,"sourceRect");b(this,"viewName");b(this,"viewParams");b(this,"playerId",0);b(this,"viewId",0);b(this,"flags",0);b(this,"layoutRect",null);b(this,"scrollOffset",0);b(this,"wrapCache");b(this,"jsNode");b(this,"bgRaw");b(this,"bgSrc");this.id=t,this.type=e,this.jsNode={type:e,_id:t}}get measured(){return this.type==="text"||this.type==="image"||this.editable}get editable(){return this.type==="input"||this.type==="textarea"}get scrollable(){return this.type==="scrollable"||this.type==="scrollableScreen"||this.type==="vlist"}get scrollAxis(){return this.style.scrollAxis==="x"?"x":"y"}get interactive(){return(this.flags&Vr)!==0}get imageSrcRaw(){return this.type==="image"?he(this.src):void 0}has(t){return(this.flags&t)!==0}}class Ds{constructor(t,e,s={}){b(this,"nodes",new Map);b(this,"root",null);b(this,"leaving",null);b(this,"leavingAbove",!1);b(this,"pagerShown",new Map);b(this,"pagerLeaving",new Map);b(this,"destKind",-1);b(this,"layerRoots",[]);b(this,"width",0);b(this,"height",0);b(this,"focused",null);b(this,"safeBottom",0);b(this,"shrunkRoot",0);b(this,"shrunkInset",0);b(this,"pressed",new Set);b(this,"gestures",new Map);b(this,"vlists",new Set);b(this,"frameCache",null);b(this,"painted",null);b(this,"fontsPending",0);b(this,"lastToast",null);b(this,"dirty",!0);b(this,"onDestination",null);b(this,"onDropped",null);b(this,"placeholders");b(this,"viewNames",new Map);b(this,"nativeDest",null);b(this,"layoutPtr",0);b(this,"padPtr",0);b(this,"lastCreated",0);b(this,"hoverX",0);b(this,"hoverY",0);b(this,"hoverInside",!1);b(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s,this.placeholders=new Map(Object.entries(s.nativeViews??{}))}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,c)=>{const l=this.measure(r,i,a);return t.setFloat32(4,l.width,!0),t.setFloat32(0,l.height,!0),t.getBigUint64(0,!0)};this.M._setMeasureFunc(this.M.addFunction(e,"jiififi"))}measure(t,e,s){const r=this.nodes.get(t);if(!r)return{width:0,height:0};const i=this.M;Ms(i,t)&&(Ls(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?is(o,this.host,e):r.type==="image"?as(o,this.host,e,s):r.editable?os(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((c,l)=>c|a[l],0)),this.M._setSafePaddings(s,r,i,o,0),this.safeBottom=i,this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&(this.shrunkInset=Math.max(0,i-this.keyboardHeight()),this.M._overrideRootSafeBottom(this.shrunkRoot,this.shrunkInset)),this.dirty=!0}layoutFrame(){const t=this.M;Ps(t,(r,i)=>{const o=this.nodes.get(r);o&&(i(o.style),this.resolveBackground(o))})>0&&(this.dirty=!0);const s=t._creatorWebLayoutFrame(this.width,this.height);s>0&&this.readLayoutBatch(s);for(const r of this.vlists)if(t._vlistExists(r.id)){t._vlistUpdateLayout(r.id);for(const i of r.children)this.deliverSubtree(i)}}needsPaint(){return this.dirty||this.frameCache===null||this.frameCache!==this.painted}deliverSubtree(t){const e=this.M;if(this.layoutPtr||(this.layoutPtr=e._malloc(16)),e._getLayoutPointer(t.id,this.layoutPtr)){const s=this.layoutPtr>>2,r={x:e.HEAPF32[s],y:e.HEAPF32[s+1],width:e.HEAPF32[s+2],height:e.HEAPF32[s+3]},i=t.layoutRect,o=!i||i.x!==r.x||i.y!==r.y||i.width!==r.width||i.height!==r.height;t.layoutRect=r,o&&(this.dirty=!0),o&&t.has(Le)&&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 c=i[s+a],l=this.nodes.get(c);if(!l)continue;const h=o[r+a*4],u=o[r+a*4+1],d=o[r+a*4+2],f=o[r+a*4+3],g={x:h,y:u,width:d-h,height:f-u},m=l.layoutRect,x=!m||m.x!==g.x||m.y!==g.y||m.width!==g.width||m.height!==g.height;l.layoutRect=g,x&&(this.dirty=!0),x&&l.has(Le)&&e._creatorWebNodeLayout(c,h,u,g.width,g.height)}}frame(){if(this.frameCache&&!this.dirty)return this.frameCache;const t=[],e={x:0,y:0,width:this.width,height:this.height},s=this.nativeDest;if(s){const i={id:0,type:"native",rect:e,style:Us,children:[],view:{name:s.view,label:this.placeholders.get(s.view)}};s.name&&(i.name=s.name),t.push(this.destKind===ut?{tree:i}:{tree:i,leaving:!0})}const r=this.leaving?this.build(this.leaving,e):null;if(r&&!this.leavingAbove&&t.push({tree:r,leaving:!0}),this.root){const i=this.build(this.root,e);i&&t.push({tree:i})}r&&this.leavingAbove&&t.push({tree:r,leaving:!0});for(const i of this.layerRoots){const o=this.build(i,e);o&&t.push({tree:o,widget:!0})}return this.frameCache=t,this.dirty=!1,t}renderTree(){var t;return((t=this.frame().find(e=>!e.widget&&!e.leaving))==null?void 0:t.tree)??null}widgetTrees(){return this.frame().filter(t=>t.widget).map(t=>t.tree)}widgets(){return this.widgetTrees()}serialize(){return _n(this.renderTree(),this.widgetTrees())}toText(){return Os(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();cs(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,c)=>{var y;if(i.style.display==="none")return null;let l,h,u,d;if(c)l=e.x,h=e.y,u=e.width,d=e.height;else{const p=i.layoutRect;if(!p)return null;l=o+p.x,h=a+p.y,u=p.width,d=p.height}const f={id:i.id,type:i.type,rect:{x:l,y:h,width:u,height:d},style:i.style,children:[]};i.name&&(f.name=i.name);const g=i;if(i.type==="text"){const p=ae(g),w=wn(p);f.text=i.text;const E=this.padding(i.id);(E[0]||E[1]||E[2]||E[3])&&(f.padding=E);const k=u-E[0]-E[2],L=`${k}|${w.size}|${w.weight}|${w.italic?1:0}|${w.letterSpacing}|${w.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.style.textWrap??""}|${i.text}`;if(((y=i.wrapCache)==null?void 0:y.key)===L)f.lines=i.wrapCache.lines;else{const C=U=>this.host.measureText(U,w),F=bn(i.text,i.style,k,C,!0);i.wrapCache={key:L,lines:F},f.lines=F}f.style={...i.style,color:p.color,fontSize:p.fontSize,fontFamily:p.fontFamily,fontWeight:p.fontWeight,fontStyle:p.fontStyle,lineHeight:p.lineHeight,letterSpacing:p.letterSpacing,textAlign:p.textAlign,textDecoration:p.textDecoration}}else if(i.type==="image"){const p=this.host.resolveSrc(i.imageSrcRaw),w=p?this.host.getImage(p):void 0;f.image=w??(p?{src:p,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(f.sourceRect=i.sourceRect)}else if(i.editable){f.value=i.value;const p=this.padding(i.id);(p[0]||p[1]||p[2]||p[3])&&(f.padding=p);const w=ae(g);f.style={...i.style,color:w.color,fontSize:w.fontSize,fontFamily:w.fontFamily,fontWeight:w.fontWeight,fontStyle:w.fontStyle,lineHeight:w.lineHeight,letterSpacing:w.letterSpacing,textAlign:w.textAlign,textDecoration:w.textDecoration}}else if(i.type==="native"){const p=i.viewName??"";f.view={name:p,label:this.placeholders.get(p)}}i.type==="widget"&&i.style.overlayColor!==void 0&&(f.overlay=i.style.overlayColor),i.interactive&&(f.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(f.state={...f.state,focused:!0}),i.style.overflow==="hidden"&&(f.clip=!0);let m=l,x=h;if(i.scrollable){const p=i.scrollAxis,w=p==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);f.clip=!0,f.scroll={offset:i.scrollOffset,content:w,axis:p},p==="x"?m=l-i.scrollOffset:x=h-i.scrollOffset}if(i.type==="pager"){const p=s._creatorWebPagerSelectedIndex(i.id),w=s._creatorWebPagerStackLen(i.id,p),E=w>0?s._creatorWebPagerPageNode(i.id,p,w-1):0,k=E?this.nodes.get(E):void 0;k?this.pagerShown.set(i.id,k):this.pagerShown.delete(i.id);const L=this.pagerLeaving.get(i.id);for(const C of L&&L.page!==k?L.above?[k,L.page]:[L.page,k]:[k]){const F=C?r(C,l,h,!1):null;F&&f.children.push(F)}return f}if(i.type==="vlist"){for(const p of i.children){const w=s._getParentNode(p.id);if(!w)continue;const E=s._vlistItemOffsetOf(i.id,w);if(Number.isNaN(E))continue;const k=r(p,l,h+E-i.scrollOffset,!1);k&&f.children.push(k)}return f}for(const p of i.children){const w=r(p,m,x,!1);w&&f.children.push(w)}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*Fs):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 Bs(t,e);this.nodes.set(t,i),e==="vlist"&&this.vlists.add(i);const o=this.nodes.get(s);o&&this.link(o,i,Math.max(0,r)),this.dirty=!0}link(t,e,s){e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),e.parent=t,t.children.splice(Math.min(s,t.children.length),0,e)}insertNode(t,e,s){const r=this.nodes.get(t),i=this.nodes.get(e);r&&i&&this.link(r,i,s),this.dirty=!0}removeNode(t,e){var i;const s=this.nodes.get(t),r=this.nodes.get(e);!s||!r||(this.forget(r),s.children=s.children.filter(o=>o!==r),r.parent===s&&(r.parent=null),((i=this.pagerLeaving.get(t))==null?void 0:i.page)===r&&this.pagerLeaving.delete(t),this.pagerShown.get(t)===r&&this.pagerShown.delete(t),this.dirty=!0)}releaseNode(t){const e=this.nodes.get(t);if(!e)return;this.nodes.delete(t),this.forget(e),e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),this.root===e&&(this.root=null),this.leaving===e&&(this.leaving=null),this.pagerShown.delete(t),this.pagerLeaving.delete(t);for(const[r,i]of this.pagerLeaving)i.page===e&&this.pagerLeaving.delete(r);this.focused===e&&(this.focused=null,this.shrinkTo(0,0),this.emitKeyboard());const s=this.layerRoots.indexOf(e);s>=0&&this.layerRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),e.type==="native"&&e.viewId&&this.viewNames.delete(e.viewId),this.dirty=!0}forget(t){for(const e of this.gestures.values())e.node===t&&(e.node=null),e.scroll===t&&(e.scroll=null),e.backdrop===t&&(e.backdrop=null),e.edit===t&&(e.edit=null);for(const e of t.children)this.forget(e)}setPropertyString(t,e,s){const r=this.nodes.get(t);if(!r)return;const i=s??"";switch(e){case"text":r.text=i,r.wrapCache=void 0;break;case"value":r.value=i;break;case"name":r.name=i||void 0;break;case"src":{r.src=i||void 0;const o=this.host.resolveSrc(this.srcOf(r));o&&!this.host.getImage(o)&&this.host.loadImage(o).then(()=>{this.nodes.get(t)===r&&this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0}).catch(()=>{});break}case"sourceRect":{const o=i.split(" ").map(Number);r.sourceRect=o.length===4?[o[0],o[1],o[2],o[3]]:void 0;break}case"focus":i==="1"||i==="true"?this.focusInput(t):this.focused===r&&this.blurInput();break;case"viewName":r.viewName=i;break;case"viewParams":r.viewParams=i;break}this.dirty=!0}srcOf(t){return he(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(he(e)):void 0;const s=t.bgSrc;s&&!this.host.getImage(s)&&this.host.loadImage(s).then(()=>{this.dirty=!0}).catch(()=>{})}t.style.backgroundImage=t.bgSrc}setPropertyInt(t,e,s){const r=this.nodes.get(t);r&&(e==="playerId"?r.playerId=s:e==="viewId"&&(r.viewId=s,r.viewName!==void 0&&this.viewNames.set(s,r.viewName))),this.dirty=!0}setFlags(t,e){const s=this.nodes.get(t);s&&(s.flags=e>>>0)}leave(t){this.root&&(this.leaving=this.root,this.leavingAbove=t,this.root=null)}openView(t,e,s,r,i,o){var c;this.destKind=t;const a=t===Pe?this.nodes.get(e)??null:null;if(a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,t===ut){this.viewNames.set(s,r);let l;for(const h of this.nodes.values())if(h.type==="native"&&h.viewId===s){l=h.name;break}this.nativeDest=this.placeholders.has(r)?{id:s,view:r,name:l}:null}this.focused&&this.blurInput(),this.dirty=!0,(c=this.onDestination)==null||c.call(this,t,s)}dropView(t,e,s){var r,i;if(t===Pe){const o=this.nodes.get(e)??null;o!==null&&this.leaving===o&&(this.leaving=null),o!==null&&this.root===o&&(this.root=null)}t===ut&&((r=this.nativeDest)==null?void 0:r.id)===s&&this.destKind!==ut&&(this.nativeDest=null),this.dirty=!0,(i=this.onDropped)==null||i.call(this,t,s)}closeView(){var t;this.destKind=-1,this.leave(!0),this.dirty=!0,(t=this.onDestination)==null||t.call(this,-1,0)}isViewSupported(t){return this.placeholders.has(t)}viewVersion(t){return this.placeholders.has(t)?1:0}viewCall(t,e,s,r,i){const o=this.viewNames.get(t);i(o!==void 0&&this.placeholders.has(o)?`headless draws native views only: ${o}.${e}`:"NativeView calls are not supported on this host")}layerOpen(t){const e=this.nodes.get(t);e&&!this.layerRoots.includes(e)&&this.layerRoots.push(e),this.dirty=!0}layerClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.layerRoots.indexOf(e):-1;s>=0&&this.layerRoots.splice(s,1),this.dirty=!0}registerFont(t,e,s,r,i,o){this.fontsPending++,this.host.loadFont(e,t,{weight:s,style:r===2?"italic":"normal"}).then(()=>{this.invalidateText(),i()},a=>o(String(a))).finally(()=>{this.fontsPending--})}invalidateText(){for(const t of this.nodes.values())t.wrapCache=void 0,t.measured&&t.type!=="image"&&this.M._nodeHasMeasure(t.id)&&this.M._markNodeDirty(t.id);this.dirty=!0}showToast(t,e){var s,r;this.lastToast=t,(r=(s=this.options).onToast)==null||r.call(s,t,e)}getButtonPressed(t){return this.pressed.has(t)}getTextValue(t){var e;return((e=this.nodes.get(t))==null?void 0:e.value)??""}getBoundingRect(t){const e=this.findRect(t);return e?[e.x,e.y,e.width,e.height]:null}longPressHandler(t,e){const s=this.gestures.get(t);s&&(s.swallowClick=!0)}vlistScroll(t,e,s){const r=this.nodes.get(t);r&&(r.scrollOffset=e),this.dirty=!0}pagerCommand(t,e,s){this.pagerLeaving.delete(t),this.dirty=!0}pagerShowPage(t,e,s){const r=this.nodes.get(e),i=this.pagerShown.get(t);r&&this.pagerShown.set(t,r),i&&i!==r&&this.pagerLeaving.set(t,{page:i,above:!s}),this.dirty=!0}pagerDropPage(t,e){var s;((s=this.pagerLeaving.get(t))==null?void 0:s.page.id)===e&&this.pagerLeaving.delete(t),this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent&&e.type!=="widget";)e=e.parent;return e}emitKeyboard(){var s,r;const t=this.keyboardHeight(),e=this.keyboardDuration();(r=(s=this.options).onKeyboard)==null||r.call(s,t,e),this.M._creatorWebKeyboardEvent(t,e)}shrinkTo(t,e){this.M._creatorWebSetShrunkRoot(t,e);const s=e>0?t:0;s!==this.shrunkRoot&&(this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&this.M._overrideRootSafeBottom(this.shrunkRoot,this.safeBottom),this.shrunkRoot=s,this.shrunkInset=this.safeBottom);const r=Math.max(0,this.safeBottom-e);s&&r!==this.shrunkInset&&this.nodes.has(s)&&(this.M._overrideRootSafeBottom(s,r),this.shrunkInset=r)}keyboardDuration(){return 0}refreshKeyboard(){this.focused&&(this.shrinkTo(this.rootOf(this.focused).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}focusInput(t){const e=this.nodes.get(t);!e||!e.editable||this.focused===e||(this.focused&&this.blurInput(),this.focused=e,this.M._setNodeFocused(t,1),e.has(qr)&&this.M._creatorWebNodeEvent(t,Dr),this.shrinkTo(this.rootOf(e).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}blurInput(){const t=this.focused;t&&(this.focused=null,this.M._setNodeFocused(t.id,0),t.has(Jr)&&this.M._creatorWebNodeEvent(t.id,Wr),this.shrinkTo(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Yr)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Br,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Qr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Hr,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,Nr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(zr)&&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=bt(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i.node)return this.nodes.get(i.node.id)??null;if(i.blocker)return null}return null}setPressed(t,e){e?this.pressed.add(t.id):this.pressed.delete(t.id),this.nodes.get(t.id)===t&&this.M._setNodePressed(t.id,e?1:0),this.dirty=!0}pointerHover(t,e){this.hoverX=t,this.hoverY=e,this.hoverInside=!0,this.hoverMoved=!0}pointerLeave(){this.hoverInside&&(this.hoverInside=!1,this.hoverMoved=!0)}get hasHover(){return typeof this.M._creatorWebHover=="function"}tickHover(){if(!this.hasHover||!this.hoverMoved&&!this.dirty)return;this.hoverMoved=!1;const t=this.hoverInside?this.topInteractive(this.hoverX,this.hoverY):null;this.M._creatorWebHover((t==null?void 0:t.id)??0,this.hoverX,this.hoverY)}pointerDown(t,e,s){const r=this.M;r._creatorWeb2dSceneOpen()&&r._creatorWeb2dEmitPointer(0,t,e,s);const i={node:null,scroll:null,backdrop:null,edit:null,global:!1,dismiss:!0,lastX:e,lastY:s,acc:0,scrolling:!1,swallowClick:!1};this.gestures.set(t,i);const o=this.frame();for(let a=o.length-1;a>=0;a--){const c=bt(o[a].tree,e,s,l=>{var h;return((h=this.nodes.get(l.id))==null?void 0:h.editable)??!1});if(c.node){const l=this.nodes.get(c.node.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(c.blocker)break}for(let a=o.length-1;a>=0;a--){const c=o[a],l=bt(c.tree,e,s,d=>{var f;return((f=this.nodes.get(d.id))==null?void 0:f.interactive)??!1}),h=bt(c.tree,e,s,d=>!!d.scroll&&d.scroll.content>(d.scroll.axis==="x"?d.rect.width:d.rect.height)+.5),u=h.node?this.nodes.get(h.node.id)??null:null;if(l.node){const d=this.nodes.get(l.node.id);i.node=d,i.scroll=u,i.dismiss=d.type!=="button",this.setPressed(d,!0),r._creatorWebNodeTouchStart(d.id,t,e,s);return}if(u){i.scroll=u;return}if(l.blocker){i.backdrop=l.outside?this.nodes.get(l.blocker.id)??null:null;return}}i.global=!0,r._creatorWebSceneTouchStart(t,e,s)}pointerMove(t,e,s){const r=this.gestures.get(t);if(!r)return;const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(1,t,e,s);const o=e-r.lastX,a=s-r.lastY;if(r.lastX=e,r.lastY=s,r.acc+=Math.abs(o)+Math.abs(a),!r.edit){if(!r.scrolling&&r.scroll&&r.acc>Ns&&(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(Xr)&&i._creatorWebNodeEvent(r.scroll.id,Ur),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(Gr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Zr)&&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=bt(i[o].tree,t,e,c=>!!c.scroll&&c.scroll.content>(c.scroll.axis==="x"?c.rect.width:c.rect.height)+.5);if(a.node){const c=this.nodes.get(a.node.id);return c?this.scrollBy(c.id,c.scrollAxis==="x"?s:r):!1}if(a.blocker)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(jr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const Ws=`
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
- `,Fe=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),Hs=n=>n.type==="native"||n.type==="video",$s=[1,0,0,1,0,0],zt=(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]],Vs=(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 Ut extends Ds{constructor(e,s,r,i,o={}){super(e,s,o);b(this,"doc");b(this,"factories",new Map);b(this,"versions",new Map);b(this,"views",new Map);b(this,"wrappers",new Map);b(this,"shown",new Map);b(this,"destination",null);b(this,"field",null);b(this,"placedFor",null);b(this,"band",{root:0,height:0});b(this,"slide",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=Ws,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 c=o(a,{emit:(l,h)=>this.M.jsb.viewEvent(e,l,h)},this.doc);return c.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:c}),c}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(c=>{c===void 0?i():i(c)},c=>o(c instanceof Error?c.message:String(c)))}catch(c){o(c instanceof Error?c.message:String(c))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==ut)return;this.dropDestination();const c=this.ensureView(r,i,o);if(!c)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(c.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===ut&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==ut&&this.dropDestination()}dropDestination(){var e;(e=this.destination)==null||e.el.remove(),this.destination=null}releaseNode(e){var r,i;const s=this.get(e);((r=this.field)==null?void 0:r.id)===e&&this.unmountField(),super.releaseNode(e),(i=this.shown.get(e))==null||i.remove(),this.shown.delete(e),this.wrappers.delete(e),(s==null?void 0:s.type)==="native"&&s.viewId&&this.destroyView(s.viewId)}keyboardDuration(){return we}shrinkTo(e,s){const r=this.doc.defaultView;if(!r){super.shrinkTo(e,s);return}this.slide&&(r.cancelAnimationFrame(this.slide.raf),this.slide=null);const i=s>0?e:this.band.root,o=this.band.height;if(o===s||i===0||!this.nodes.has(i)){this.setBand(i,s);return}const a=r.performance.now(),c=()=>{const l=Math.min(1,(r.performance.now()-a)/we),h=Vn(l);this.setBand(i,l<1?Math.round(o+(s-o)*h):s),l<1?this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}:this.slide=null};this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}}setBand(e,s){this.band=s>0?{root:e,height:s}:{root:0,height:0},super.shrinkTo(this.band.root,this.band.height),this.dirty=!0}focusInput(e){var i;if(super.focusInput(e),this.focusedId()!==e||((i=this.field)==null?void 0:i.id)===e)return;this.unmountField();const s=this.get(e);if(!s)return;const r=this.doc.createElement(s.type==="textarea"?"textarea":"input");r.className="lc-field",r.setAttribute("autocomplete","off"),r.value=s.value,r.addEventListener("input",()=>{this.focusedId()===e&&this.setInputValue(e,r.value)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&r.tagName==="INPUT"&&(o.preventDefault(),this.submitInput())}),r.addEventListener("blur",()=>{var o;((o=this.field)==null?void 0:o.el)===r&&this.focusedId()===e&&this.blurInput()}),this.over.appendChild(r),this.field={id:e,el:r},this.placedFor=null,this.place(),r.focus({preventScroll:!0})}blurInput(){super.blurInput(),this.unmountField()}unmountField(){const e=this.field;e&&(this.field=null,e.el.remove(),this.placedFor=null)}setPropertyString(e,s,r){var i,o;if(super.setPropertyString(e,s,r),s==="value"&&((i=this.field)==null?void 0:i.id)===e){const a=((o=this.get(e))==null?void 0:o.value)??"";this.field.el.value!==a&&(this.field.el.value=a)}}find(){var i;const e=[],s=(i=this.field)==null?void 0:i.id,r=(o,a,c)=>{let l=a;const h=o.style.transform;if(h){const d=o.style.transformOrigin,f=o.rect.x+(d?d.xPercent?o.rect.width*d.x/100:d.x:o.rect.width/2),g=o.rect.y+(d?d.yPercent?o.rect.height*d.y/100:d.y:o.rect.height/2),m=xn(h,o.style.transformBox,o.rect.width,o.rect.height);l=zt(zt(zt(a,[1,0,0,1,f,g]),m),[1,0,0,1,-f,-g])}(Hs(o)||o.id===s)&&e.push({node:o,matrix:l,clip:c});const u=o.clip?Vs(c,o.rect):c;for(const d of o.children)r(d,l,u)};for(const o of this.frame())r(o.tree,$s,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=ge(s.playerId);return o instanceof HTMLVideoElement?o:null}if(!s.viewId)return null;const r=this.ensureView(s.viewId,s.viewName??"",s.viewParams??"");if(!r)return null;let i=this.wrappers.get(s.id);return i||(i=this.doc.createElement("div"),this.wrappers.set(s.id,i)),r.el.parentElement!==i&&i.replaceChildren(r.el),i}styleField(e,s){var u,d;const r=s.style,i=e.style,[o,a,c,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${c}px ${l}px ${o}px`,i.color=Fe(r.color,"#000000ff"),i.caretColor=i.color;const h=r.fontFamily??"Roboto";if(i.fontFamily=((d=(u=this.host).resolveFontFamily)==null?void 0:d.call(u,h))??h,i.fontSize=(r.fontSize??14)+"px",i.fontWeight=String(r.fontWeight??400),i.fontStyle=r.fontStyle??"normal",i.letterSpacing=(r.letterSpacing??0)+"px",i.lineHeight=e.tagName==="TEXTAREA"&&r.lineHeight!==void 0?r.lineHeight+"px":"normal",i.textAlign=r.textAlign==="center"?"center":r.textAlign==="end"?"right":"left",i.borderRadius="0",e.placeholder=r.placeholder??"",i.setProperty("--lc-placeholder",Fe(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),Ut.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"),Ut.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=bt(o.tree,e,s,c=>{var l,h;return c.type==="native"||(((l=this.get(c.id))==null?void 0:l.interactive)??!1)||(((h=this.get(c.id))==null?void 0:h.editable)??!1)||!!c.scroll});if(a.node)return a.node.type==="native";if(a.blocker)return!1}return this.destination!==null}dispose(){this.unmountField();for(const e of[...this.views.keys()])this.destroyView(e);this.dropDestination();for(const e of this.shown.values())e instanceof HTMLVideoElement||e.remove();this.shown.clear()}}function 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 js=500,Ne=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],zs=(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 v=e.createElement("div");return v.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;",v},o=i(),a=i();n.insertBefore(o,s),s.after(a);const c=new Er({resolveAssetUrl:v=>ln(v),canvasSurfaces:t.canvasHost}),l=new Ut(t.M,c,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onKeyboard:t.onKeyboard,onToast:(v,T)=>Gs(e,n,v,T)});let h=1,u=new Me(r,h),d=!0;const f=()=>{(d||l.needsPaint())&&(d=!1,l.paint(u,l.paintOptions())),l.place()};let g=1;const m=(v,T,O,j=1)=>{if(!(v<=0||T<=0)){O!==h&&(h=O,u=new Me(r,h)),g=j;for(const J of[o,a])Object.assign(J.style,{width:`${v}px`,height:`${T}px`,zoom:g===1?"":String(g)});d=!0,l.resize(v,T)}},x=v=>{l.setSafeArea([v.top,v.right,v.bottom,v.left],v.bars??[])},y=v=>{const T=n.getBoundingClientRect(),O=Ft(n)*g;return[(v.clientX-T.left)/O,(v.clientY-T.top)/O]},p=v=>v.target instanceof Node&&a.contains(v.target),w=v=>v.target instanceof Node&&o.contains(v.target),E=v=>{w(v)&&v.stopPropagation()},k=new Set,L=new Map,C=v=>{const T=L.get(v);T!==void 0&&(clearTimeout(T),L.delete(v))},F=v=>{if(p(v))return;const[T,O]=y(v);if(!l.surfaceAt(T,O)){E(v),k.add(v.pointerId);try{n.setPointerCapture(v.pointerId)}catch{}l.pointerDown(v.pointerId,T,O),C(v.pointerId),L.set(v.pointerId,window.setTimeout(()=>{L.delete(v.pointerId),l.longPress(v.pointerId,T,O)},js))}},U=v=>{const[T,O]=y(v);k.has(v.pointerId)&&(E(v),l.pointerMove(v.pointerId,T,O)),v.pointerType==="mouse"&&(p(v)||!k.has(v.pointerId)&&l.surfaceAt(T,O)?l.pointerLeave():l.pointerHover(T,O))},$=v=>{v.pointerType==="mouse"&&l.pointerLeave()},K=v=>{if(!k.delete(v.pointerId))return;E(v),C(v.pointerId);const[T,O]=y(v);l.pointerUp(v.pointerId,T,O)},G=v=>{k.delete(v.pointerId)&&(C(v.pointerId),l.pointerCancel(v.pointerId))},q=v=>{if(p(v))return;const[T,O]=y(v);if(l.surfaceAt(T,O))return;E(v);const j=v.deltaMode===1?16:v.deltaMode===2?l.height:1;l.wheel(T,O,v.deltaX*j,v.deltaY*j)&&v.preventDefault()},A=v=>{var J;if(p(v))return;const T="clientX"in v?v:(J=v.changedTouches)==null?void 0:J[0];if(!T)return;const[O,j]=y(T);l.surfaceAt(O,j)||(E(v),v.type==="mousedown"&&v.preventDefault())};n.addEventListener("pointerdown",F,!0),n.addEventListener("pointermove",U,!0),n.addEventListener("pointerleave",$),n.addEventListener("pointerup",K,!0),n.addEventListener("pointercancel",G,!0),n.addEventListener("wheel",q,{passive:!1,capture:!0});for(const v of Ne)n.addEventListener(v,A,!0);return{ui:l,render:f,resize:m,setSafeArea:x,destroy(){for(const v of L.keys())C(v);n.removeEventListener("pointerdown",F,!0),n.removeEventListener("pointermove",U,!0),n.removeEventListener("pointerleave",$),n.removeEventListener("pointerup",K,!0),n.removeEventListener("pointercancel",G,!0),n.removeEventListener("wheel",q,!0);for(const v of Ne)n.removeEventListener(v,A,!0);l.dispose(),o.remove(),a.remove()}}},Ks=["miter","round","bevel"],Xs=["butt","round","square"],Ys=["left","center","right","start","end"],qs=["alphabetic","top","middle","bottom","hanging","ideographic"],Ue=["nonzero","evenodd"],Js=["pad","reflect","repeat"],Kt={COLOR:0,RADIAL:2},St={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 Qs{constructor(t,e){b(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===Kt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Kt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Js[this.i()]??"pad",c=this.i(),l=[];for(let h=0;h<c;h++)l.push({offset:this.f(),color:this.color()});return t===Kt.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=Ks[this.i()]??"miter",s=Xs[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let c=0;c<o;c++)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 St.MOVE:s.push(["M",this.f(),this.f()]);break;case St.LINE:s.push(["L",this.f(),this.f()]);break;case St.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case St.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case St.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 Zs=(n,t)=>{const e=new Qs(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=Ue[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Ue[e.i()]??"nonzero",c=e.paint();s.push({cmd:"fillPath",rule:a,paint:c,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),c=e.paint();s.push({cmd:"strokePath",stroke:a,paint:c,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),c=e.f(),l=e.f(),h=e.f(),u=e.font(),d=Ys[e.i()]??"start",f=qs[e.i()]??"alphabetic",g=e.f();if(r===X.STROKE_TEXT){const m=e.stroke();s.push({cmd:"strokeText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,stroke:m,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),c=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:c,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},ti=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),kn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,Tn=(n,t=n.family)=>{const e=ti.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Pt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],ei=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,Xt=(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}},Be=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,kn(e.color))},Ot=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=kn(t.color),s();return}const r=t.matrix;if(ei(r)){let o;if(t.kind==="linear"){const[a,c]=Pt(r,0,0),[l,h]=Pt(r,1,0);o=n.createLinearGradient(a,c,l,h)}else{const a=Math.hypot(r[0],r[1]),[c,l]=Pt(r,0,0),[h,u]=Pt(r,t.fx,t.fy);o=n.createRadialGradient(h,u,t.r0*a,c,l,a)}Be(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);Be(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},De=(n,t)=>{n.lineWidth=t.width,n.lineJoin=t.join,n.lineCap=t.cap,n.miterLimit=t.miterLimit,n.setLineDash(t.dash),n.lineDashOffset=t.dashOffset},We=(n,t,e)=>{n.font=Tn(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`)},ni=(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":Xt(n,i.path),n.clip(i.rule);break;case"fillPath":Xt(n,i.path),Ot(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":Xt(n,i.path),De(n,i.stroke),Ot(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":We(n,i,e),Ot(n,i.paint,"fill",()=>i.maxWidth>0?n.fillText(i.text,i.x,i.y,i.maxWidth):n.fillText(i.text,i.x,i.y));break;case"strokeText":We(n,i,e),De(n,i.stroke),Ot(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()}},ri=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,h,u)=>{if(!t)return null;let d=e.get(l);return d?(d.width!==h||d.height!==u)&&(d.width=h,d.height=u):(d=new OffscreenCanvas(h,u),e.set(l,d)),d},i={paint:(l,h,u,d,f,g)=>{const m=r(l,Math.max(1,h),Math.max(1,u)),x=m==null?void 0:m.getContext("2d");!m||!x||(x.setTransform(1,0,0,1,0,0),x.clearRect(0,0,m.width,m.height),ni(x,Zs(f,g),{image:y=>e.get(y)??null,fontFamily:n}))},measureText:(l,h,u,d,f,g)=>{if(g[0]=0,g[1]=0,g[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=Tn({family:h,size:u,weight:d,italic:f},h);const m=s.measureText(l);g[0]=m.width,g[1]=m.fontBoundingBoxAscent??m.actualBoundingBoxAscent,g[2]=m.fontBoundingBoxDescent??m.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,h)=>{const u=o(l);return u?(h[0]=u.width,h[1]=u.height,new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const h=e.get(l),u=h==null?void 0:h.getContext("2d");return!h||!u?null:{data:u.getImageData(0,0,h.width,h.height).data,width:h.width,height:h.height}};return{table:i,readSurface:o,getSurface:l=>{const h=e.get(l);return h?{canvas:h,width:h.width,height:h.height}:null},surfaceToDataUrl:l=>{var d;const h=e.get(l);if(!h||typeof document>"u")return null;const u=document.createElement("canvas");return u.width=h.width,u.height=h.height,(d=u.getContext("2d"))==null||d.drawImage(h,0,0),u.toDataURL()}}},si=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,ii=(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},oi=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))])},Rn="Roboto",ai=[`400 14px ${Rn}`],He="data-lecodes-fonts",ci=async(n=ai,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${He}]`)){const s=new URL(si,document.baseURI).href,r=e.createElement("style");r.setAttribute(He,""),r.textContent=`@font-face{font-family:"${Rn}";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{}}},$e="2.4.9",Yt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},li=(n,t)=>Yt(n)!==null&&Yt(n)===Yt(t),hi=()=>({setMatrix(){},setVisible(){},setCameraMatrix(){},setProjection(){},clearProjection(){},setBackground(){},createExternalTexture:()=>null,onFrame:()=>()=>{},readPixels:(n,t)=>t(null,0,0),viewport:()=>({width:0,height:0,rotation:0})}),ui=n=>{var s,r;const t=((r=(s=n.screen)==null?void 0:s.orientation)==null?void 0:r.angle)??n.orientation??0;return(Math.round(t/90)%4+4)%4*90},di=(n,t)=>({width:(n==null?void 0:n.clientWidth)??0,height:(n==null?void 0:n.clientHeight)??0,rotation:ui(t)}),fi=[1,0,0,0,1,0],gi=(n,t,e)=>{const s=t*4,r=new Uint8Array(s);for(let i=0,o=e-1;i<o;i++,o--)r.set(n.subarray(i*s,i*s+s)),n.copyWithin(i*s,o*s,o*s+s),n.set(r,o*s);return n},pi=[171,75,84,88,32,50,48,187,13,10,26,10],mi=n=>n.length>=12&&pi.every((t,e)=>n[e]===t),yi=(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=[],c=()=>{const u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),u},l=u=>{var g;u._creatorWebSetViewport(s.width,s.height);const{width:d,height:f}=n.size();d>0&&f>0&&((g=u._setDensityGL)==null||g.call(u,s.width/d,s.height/f))},h=(u,d,f,g)=>{const m=u.GL.getNewId(u.GL.textures);return u.GL.textures[m]=d,u._importTexture(m,f,g)>>>0};return{canvas:s,context:r,options:e,table(u){return i=u,{engineCreated(){a.length=0,u._createSwapChainHeadless(s.width,s.height),l(u),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(d,f,g,m){const x=et(d);if(!x){m(`createTexture: no buffer behind id ${d}`);return}const y=new Uint8Array(x);if(mi(y)){const p=u._malloc(y.length);u.HEAPU8.set(y,p);const w=u._createTextureFromKtx2(p,y.length)>>>0;if(u._free(p),w===4294967295){m("KTX2 transcode failed");return}g(w,u._getTextureWidth(w),u._getTextureHeight(w));return}createImageBitmap($t(d)).then(p=>{const w=c();r.texStorage2D(r.TEXTURE_2D,1,f&1?r.RGBA8:r.SRGB8_ALPHA8,p.width,p.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,p.width,p.height,r.RGBA,r.UNSIGNED_BYTE,p),g(h(u,w,p.width,p.height),p.width,p.height)},p=>m(p instanceof Error?p.message:String(p)))},createMediaPlayerTexture(d){const f=ge(d);if(!f)return 0;const g=c(),m=h(u,g,0,0);return a.push({video:f,texture:g,id:m,lastTime:0}),m}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&l(i)},frame(){for(const u of a)u.video.readyState<2||u.video.currentTime===u.lastTime||(u.lastTime=u.video.currentTime,r.bindTexture(r.TEXTURE_2D,u.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,u.video))},videoTexture(u){const d=a.find(m=>m.video===u);if(d)return d.id;if(!i||!o)return;const f=c(),g=h(i,f,0,0);return a.push({video:u,texture:f,id:g,lastTime:0}),g},readPixels(){const u=r.drawingBufferWidth,d=r.drawingBufferHeight;if(!o||u===0||d===0)return null;const f=new Uint8Array(u*d*4),g=r.getParameter(r.READ_FRAMEBUFFER_BINDING);return r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.readPixels(0,0,u,d,r.RGBA,r.UNSIGNED_BYTE,f),r.bindFramebuffer(r.READ_FRAMEBUFFER,g),{rgba:gi(f,u,d),width:u,height:d}},destroy(){var u;a.length=0,(u=r.getExtension("WEBGL_lose_context"))==null||u.loseContext()}}},wi=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")},c=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:c}},show:a,hide:c,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},Ve=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)},Ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",An={};for(let n=0;n<Ge.length;n++)An[Ge[n]]=n;const bi=n=>{const t=[];let e=0,s=0;for(const r of n){const i=An[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 vi{constructor(t){b(this,"sources");b(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 c of i.split(",")){const l=bi(c);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 xi=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 vi(JSON.parse(e))}catch{return null}};let wt=null;const Ei=()=>{if(wt!==null)return wt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return wt=e?parseInt(e[1],10)-1:2,wt}return wt=2,wt},qt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=Ei(),r=[];for(const i of e.split(`
13
+ `,Fe=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),Hs=n=>n.type==="native"||n.type==="video",$s=[1,0,0,1,0,0],zt=(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]],Vs=(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 Ut extends Ds{constructor(e,s,r,i,o={}){super(e,s,o);b(this,"doc");b(this,"factories",new Map);b(this,"versions",new Map);b(this,"views",new Map);b(this,"wrappers",new Map);b(this,"shown",new Map);b(this,"destination",null);b(this,"field",null);b(this,"placedFor",null);b(this,"band",{root:0,height:0});b(this,"slide",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=Ws,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 c=o(a,{emit:(l,h)=>this.M.jsb.viewEvent(e,l,h)},this.doc);return c.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:c}),c}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(c=>{c===void 0?i():i(c)},c=>o(c instanceof Error?c.message:String(c)))}catch(c){o(c instanceof Error?c.message:String(c))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==ut)return;this.dropDestination();const c=this.ensureView(r,i,o);if(!c)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(c.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===ut&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==ut&&this.dropDestination()}dropDestination(){var e;(e=this.destination)==null||e.el.remove(),this.destination=null}releaseNode(e){var r,i;const s=this.get(e);((r=this.field)==null?void 0:r.id)===e&&this.unmountField(),super.releaseNode(e),(i=this.shown.get(e))==null||i.remove(),this.shown.delete(e),this.wrappers.delete(e),(s==null?void 0:s.type)==="native"&&s.viewId&&this.destroyView(s.viewId)}keyboardDuration(){return we}shrinkTo(e,s){const r=this.doc.defaultView;if(!r){super.shrinkTo(e,s);return}this.slide&&(r.cancelAnimationFrame(this.slide.raf),this.slide=null);const i=s>0?e:this.band.root,o=this.band.height;if(o===s||i===0||!this.nodes.has(i)){this.setBand(i,s);return}const a=r.performance.now(),c=()=>{const l=Math.min(1,(r.performance.now()-a)/we),h=Vn(l);this.setBand(i,l<1?Math.round(o+(s-o)*h):s),l<1?this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}:this.slide=null};this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}}setBand(e,s){this.band=s>0?{root:e,height:s}:{root:0,height:0},super.shrinkTo(this.band.root,this.band.height),this.dirty=!0}focusInput(e){var i;if(super.focusInput(e),this.focusedId()!==e||((i=this.field)==null?void 0:i.id)===e)return;this.unmountField();const s=this.get(e);if(!s)return;const r=this.doc.createElement(s.type==="textarea"?"textarea":"input");r.className="lc-field",r.setAttribute("autocomplete","off"),r.value=s.value,r.addEventListener("input",()=>{this.focusedId()===e&&this.setInputValue(e,r.value)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&r.tagName==="INPUT"&&(o.preventDefault(),this.submitInput())}),r.addEventListener("blur",()=>{var o;((o=this.field)==null?void 0:o.el)===r&&this.focusedId()===e&&this.blurInput()}),this.over.appendChild(r),this.field={id:e,el:r},this.placedFor=null,this.place(),r.focus({preventScroll:!0})}blurInput(){super.blurInput(),this.unmountField()}unmountField(){const e=this.field;e&&(this.field=null,e.el.remove(),this.placedFor=null)}setPropertyString(e,s,r){var i,o;if(super.setPropertyString(e,s,r),s==="value"&&((i=this.field)==null?void 0:i.id)===e){const a=((o=this.get(e))==null?void 0:o.value)??"";this.field.el.value!==a&&(this.field.el.value=a)}}find(){var i;const e=[],s=(i=this.field)==null?void 0:i.id,r=(o,a,c)=>{let l=a;const h=o.style.transform;if(h){const d=o.style.transformOrigin,f=o.rect.x+(d?d.xPercent?o.rect.width*d.x/100:d.x:o.rect.width/2),g=o.rect.y+(d?d.yPercent?o.rect.height*d.y/100:d.y:o.rect.height/2),m=xn(h,o.style.transformBox,o.rect.width,o.rect.height);l=zt(zt(zt(a,[1,0,0,1,f,g]),m),[1,0,0,1,-f,-g])}(Hs(o)||o.id===s)&&e.push({node:o,matrix:l,clip:c});const u=o.clip?Vs(c,o.rect):c;for(const d of o.children)r(d,l,u)};for(const o of this.frame())r(o.tree,$s,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=ge(s.playerId);return o instanceof HTMLVideoElement?o:null}if(!s.viewId)return null;const r=this.ensureView(s.viewId,s.viewName??"",s.viewParams??"");if(!r)return null;let i=this.wrappers.get(s.id);return i||(i=this.doc.createElement("div"),this.wrappers.set(s.id,i)),r.el.parentElement!==i&&i.replaceChildren(r.el),i}styleField(e,s){var u,d;const r=s.style,i=e.style,[o,a,c,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${c}px ${l}px ${o}px`,i.color=Fe(r.color,"#000000ff"),i.caretColor=i.color;const h=r.fontFamily??"Roboto";if(i.fontFamily=((d=(u=this.host).resolveFontFamily)==null?void 0:d.call(u,h))??h,i.fontSize=(r.fontSize??14)+"px",i.fontWeight=String(r.fontWeight??400),i.fontStyle=r.fontStyle??"normal",i.letterSpacing=(r.letterSpacing??0)+"px",i.lineHeight=e.tagName==="TEXTAREA"&&r.lineHeight!==void 0?r.lineHeight+"px":"normal",i.textAlign=r.textAlign==="center"?"center":r.textAlign==="end"?"right":"left",i.borderRadius="0",e.placeholder=r.placeholder??"",i.setProperty("--lc-placeholder",Fe(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),Ut.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"),Ut.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=bt(o.tree,e,s,c=>{var l,h;return c.type==="native"||(((l=this.get(c.id))==null?void 0:l.interactive)??!1)||(((h=this.get(c.id))==null?void 0:h.editable)??!1)||!!c.scroll});if(a.node)return a.node.type==="native";if(a.blocker)return!1}return this.destination!==null}dispose(){this.unmountField();for(const e of[...this.views.keys()])this.destroyView(e);this.dropDestination();for(const e of this.shown.values())e instanceof HTMLVideoElement||e.remove();this.shown.clear()}}function 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 js=500,Ne=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],zs=(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 v=e.createElement("div");return v.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;",v},o=i(),a=i();n.insertBefore(o,s),s.after(a);const c=new Er({resolveAssetUrl:v=>ln(v),canvasSurfaces:t.canvasHost}),l=new Ut(t.M,c,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onKeyboard:t.onKeyboard,onToast:(v,T)=>Gs(e,n,v,T)});let h=1,u=new Me(r,h),d=!0;const f=()=>{(d||l.needsPaint())&&(d=!1,l.paint(u,l.paintOptions())),l.place()};let g=1;const m=(v,T,O,j=1)=>{if(!(v<=0||T<=0)){O!==h&&(h=O,u=new Me(r,h)),g=j;for(const J of[o,a])Object.assign(J.style,{width:`${v}px`,height:`${T}px`,zoom:g===1?"":String(g)});d=!0,l.resize(v,T)}},x=v=>{l.setSafeArea([v.top,v.right,v.bottom,v.left],v.bars??[])},y=v=>{const T=n.getBoundingClientRect(),O=Ft(n)*g;return[(v.clientX-T.left)/O,(v.clientY-T.top)/O]},p=v=>v.target instanceof Node&&a.contains(v.target),w=v=>v.target instanceof Node&&o.contains(v.target),E=v=>{w(v)&&v.stopPropagation()},k=new Set,L=new Map,C=v=>{const T=L.get(v);T!==void 0&&(clearTimeout(T),L.delete(v))},F=v=>{if(p(v))return;const[T,O]=y(v);if(!l.surfaceAt(T,O)){E(v),k.add(v.pointerId);try{n.setPointerCapture(v.pointerId)}catch{}l.pointerDown(v.pointerId,T,O),C(v.pointerId),L.set(v.pointerId,window.setTimeout(()=>{L.delete(v.pointerId),l.longPress(v.pointerId,T,O)},js))}},U=v=>{const[T,O]=y(v);k.has(v.pointerId)&&(E(v),l.pointerMove(v.pointerId,T,O)),v.pointerType==="mouse"&&(p(v)||!k.has(v.pointerId)&&l.surfaceAt(T,O)?l.pointerLeave():l.pointerHover(T,O))},$=v=>{v.pointerType==="mouse"&&l.pointerLeave()},K=v=>{if(!k.delete(v.pointerId))return;E(v),C(v.pointerId);const[T,O]=y(v);l.pointerUp(v.pointerId,T,O)},G=v=>{k.delete(v.pointerId)&&(C(v.pointerId),l.pointerCancel(v.pointerId))},q=v=>{if(p(v))return;const[T,O]=y(v);if(l.surfaceAt(T,O))return;E(v);const j=v.deltaMode===1?16:v.deltaMode===2?l.height:1;l.wheel(T,O,v.deltaX*j,v.deltaY*j)&&v.preventDefault()},A=v=>{var J;if(p(v))return;const T="clientX"in v?v:(J=v.changedTouches)==null?void 0:J[0];if(!T)return;const[O,j]=y(T);l.surfaceAt(O,j)||(E(v),v.type==="mousedown"&&v.preventDefault())};n.addEventListener("pointerdown",F,!0),n.addEventListener("pointermove",U,!0),n.addEventListener("pointerleave",$),n.addEventListener("pointerup",K,!0),n.addEventListener("pointercancel",G,!0),n.addEventListener("wheel",q,{passive:!1,capture:!0});for(const v of Ne)n.addEventListener(v,A,!0);return{ui:l,render:f,resize:m,setSafeArea:x,destroy(){for(const v of L.keys())C(v);n.removeEventListener("pointerdown",F,!0),n.removeEventListener("pointermove",U,!0),n.removeEventListener("pointerleave",$),n.removeEventListener("pointerup",K,!0),n.removeEventListener("pointercancel",G,!0),n.removeEventListener("wheel",q,!0);for(const v of Ne)n.removeEventListener(v,A,!0);l.dispose(),o.remove(),a.remove()}}},Ks=["miter","round","bevel"],Xs=["butt","round","square"],Ys=["left","center","right","start","end"],qs=["alphabetic","top","middle","bottom","hanging","ideographic"],Ue=["nonzero","evenodd"],Js=["pad","reflect","repeat"],Kt={COLOR:0,RADIAL:2},St={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 Qs{constructor(t,e){b(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===Kt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Kt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Js[this.i()]??"pad",c=this.i(),l=[];for(let h=0;h<c;h++)l.push({offset:this.f(),color:this.color()});return t===Kt.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=Ks[this.i()]??"miter",s=Xs[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let c=0;c<o;c++)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 St.MOVE:s.push(["M",this.f(),this.f()]);break;case St.LINE:s.push(["L",this.f(),this.f()]);break;case St.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case St.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case St.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 Zs=(n,t)=>{const e=new Qs(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=Ue[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Ue[e.i()]??"nonzero",c=e.paint();s.push({cmd:"fillPath",rule:a,paint:c,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),c=e.paint();s.push({cmd:"strokePath",stroke:a,paint:c,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),c=e.f(),l=e.f(),h=e.f(),u=e.font(),d=Ys[e.i()]??"start",f=qs[e.i()]??"alphabetic",g=e.f();if(r===X.STROKE_TEXT){const m=e.stroke();s.push({cmd:"strokeText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,stroke:m,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),c=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:c,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},ti=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),kn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,Tn=(n,t=n.family)=>{const e=ti.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Pt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],ei=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,Xt=(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}},Be=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,kn(e.color))},Ot=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=kn(t.color),s();return}const r=t.matrix;if(ei(r)){let o;if(t.kind==="linear"){const[a,c]=Pt(r,0,0),[l,h]=Pt(r,1,0);o=n.createLinearGradient(a,c,l,h)}else{const a=Math.hypot(r[0],r[1]),[c,l]=Pt(r,0,0),[h,u]=Pt(r,t.fx,t.fy);o=n.createRadialGradient(h,u,t.r0*a,c,l,a)}Be(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);Be(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},De=(n,t)=>{n.lineWidth=t.width,n.lineJoin=t.join,n.lineCap=t.cap,n.miterLimit=t.miterLimit,n.setLineDash(t.dash),n.lineDashOffset=t.dashOffset},We=(n,t,e)=>{n.font=Tn(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`)},ni=(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":Xt(n,i.path),n.clip(i.rule);break;case"fillPath":Xt(n,i.path),Ot(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":Xt(n,i.path),De(n,i.stroke),Ot(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":We(n,i,e),Ot(n,i.paint,"fill",()=>i.maxWidth>0?n.fillText(i.text,i.x,i.y,i.maxWidth):n.fillText(i.text,i.x,i.y));break;case"strokeText":We(n,i,e),De(n,i.stroke),Ot(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()}},ri=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,h,u)=>{if(!t)return null;let d=e.get(l);return d?(d.width!==h||d.height!==u)&&(d.width=h,d.height=u):(d=new OffscreenCanvas(h,u),e.set(l,d)),d},i={paint:(l,h,u,d,f,g)=>{const m=r(l,Math.max(1,h),Math.max(1,u)),x=m==null?void 0:m.getContext("2d");!m||!x||(x.setTransform(1,0,0,1,0,0),x.clearRect(0,0,m.width,m.height),ni(x,Zs(f,g),{image:y=>e.get(y)??null,fontFamily:n}))},measureText:(l,h,u,d,f,g)=>{if(g[0]=0,g[1]=0,g[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=Tn({family:h,size:u,weight:d,italic:f},h);const m=s.measureText(l);g[0]=m.width,g[1]=m.fontBoundingBoxAscent??m.actualBoundingBoxAscent,g[2]=m.fontBoundingBoxDescent??m.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,h)=>{const u=o(l);return u?(h[0]=u.width,h[1]=u.height,new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const h=e.get(l),u=h==null?void 0:h.getContext("2d");return!h||!u?null:{data:u.getImageData(0,0,h.width,h.height).data,width:h.width,height:h.height}};return{table:i,readSurface:o,getSurface:l=>{const h=e.get(l);return h?{canvas:h,width:h.width,height:h.height}:null},surfaceToDataUrl:l=>{var d;const h=e.get(l);if(!h||typeof document>"u")return null;const u=document.createElement("canvas");return u.width=h.width,u.height=h.height,(d=u.getContext("2d"))==null||d.drawImage(h,0,0),u.toDataURL()}}},si=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,ii=(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},oi=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))])},Rn="Roboto",ai=[`400 14px ${Rn}`],He="data-lecodes-fonts",ci=async(n=ai,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${He}]`)){const s=new URL(si,document.baseURI).href,r=e.createElement("style");r.setAttribute(He,""),r.textContent=`@font-face{font-family:"${Rn}";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{}}},$e="2.4.10",Yt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},li=(n,t)=>Yt(n)!==null&&Yt(n)===Yt(t),hi=()=>({setMatrix(){},setVisible(){},setCameraMatrix(){},setProjection(){},clearProjection(){},setBackground(){},createExternalTexture:()=>null,onFrame:()=>()=>{},readPixels:(n,t)=>t(null,0,0),viewport:()=>({width:0,height:0,rotation:0})}),ui=n=>{var s,r;const t=((r=(s=n.screen)==null?void 0:s.orientation)==null?void 0:r.angle)??n.orientation??0;return(Math.round(t/90)%4+4)%4*90},di=(n,t)=>({width:(n==null?void 0:n.clientWidth)??0,height:(n==null?void 0:n.clientHeight)??0,rotation:ui(t)}),fi=[1,0,0,0,1,0],gi=(n,t,e)=>{const s=t*4,r=new Uint8Array(s);for(let i=0,o=e-1;i<o;i++,o--)r.set(n.subarray(i*s,i*s+s)),n.copyWithin(i*s,o*s,o*s+s),n.set(r,o*s);return n},pi=[171,75,84,88,32,50,48,187,13,10,26,10],mi=n=>n.length>=12&&pi.every((t,e)=>n[e]===t),yi=(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=[],c=()=>{const u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),u},l=u=>{var g;u._creatorWebSetViewport(s.width,s.height);const{width:d,height:f}=n.size();d>0&&f>0&&((g=u._setDensityGL)==null||g.call(u,s.width/d,s.height/f))},h=(u,d,f,g)=>{const m=u.GL.getNewId(u.GL.textures);return u.GL.textures[m]=d,u._importTexture(m,f,g)>>>0};return{canvas:s,context:r,options:e,table(u){return i=u,{engineCreated(){a.length=0,u._createSwapChainHeadless(s.width,s.height),l(u),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(d,f,g,m){const x=et(d);if(!x){m(`createTexture: no buffer behind id ${d}`);return}const y=new Uint8Array(x);if(mi(y)){const p=u._malloc(y.length);u.HEAPU8.set(y,p);const w=u._createTextureFromKtx2(p,y.length)>>>0;if(u._free(p),w===4294967295){m("KTX2 transcode failed");return}g(w,u._getTextureWidth(w),u._getTextureHeight(w));return}createImageBitmap($t(d)).then(p=>{const w=c();r.texStorage2D(r.TEXTURE_2D,1,f&1?r.RGBA8:r.SRGB8_ALPHA8,p.width,p.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,p.width,p.height,r.RGBA,r.UNSIGNED_BYTE,p),g(h(u,w,p.width,p.height),p.width,p.height)},p=>m(p instanceof Error?p.message:String(p)))},createMediaPlayerTexture(d){const f=ge(d);if(!f)return 0;const g=c(),m=h(u,g,0,0);return a.push({video:f,texture:g,id:m,lastTime:0}),m}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&l(i)},frame(){for(const u of a)u.video.readyState<2||u.video.currentTime===u.lastTime||(u.lastTime=u.video.currentTime,r.bindTexture(r.TEXTURE_2D,u.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,u.video))},videoTexture(u){const d=a.find(m=>m.video===u);if(d)return d.id;if(!i||!o)return;const f=c(),g=h(i,f,0,0);return a.push({video:u,texture:f,id:g,lastTime:0}),g},readPixels(){const u=r.drawingBufferWidth,d=r.drawingBufferHeight;if(!o||u===0||d===0)return null;const f=new Uint8Array(u*d*4),g=r.getParameter(r.READ_FRAMEBUFFER_BINDING);return r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.readPixels(0,0,u,d,r.RGBA,r.UNSIGNED_BYTE,f),r.bindFramebuffer(r.READ_FRAMEBUFFER,g),{rgba:gi(f,u,d),width:u,height:d}},destroy(){var u;a.length=0,(u=r.getExtension("WEBGL_lose_context"))==null||u.loseContext()}}},wi=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")},c=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:c}},show:a,hide:c,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},Ve=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)},Ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",An={};for(let n=0;n<Ge.length;n++)An[Ge[n]]=n;const bi=n=>{const t=[];let e=0,s=0;for(const r of n){const i=An[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 vi{constructor(t){b(this,"sources");b(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 c of i.split(",")){const l=bi(c);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 xi=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 vi(JSON.parse(e))}catch{return null}};let wt=null;const Ei=()=>{if(wt!==null)return wt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return wt=e?parseInt(e[1],10)-1:2,wt}return wt=2,wt},qt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=Ei(),r=[];for(const i of e.split(`
14
14
  `)){const o=i.match(/<anonymous>:(\d+):(\d+)/);if(!o)continue;const a=parseInt(o[1],10)-s,c=parseInt(o[2],10)-1;if(a<1)continue;const l=t.originalPositionFor(a,c<0?0:c);if(!l)continue;const h=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:h?h[1]:null,source:l.source,line:l.line,column:l.column})}return r},Si=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,_i=(n,t)=>{const e=[],s=(l,h,u,d)=>{var m,x;if(u.length===0&&Ve(h)){const y=typeof h=="number"||typeof h=="bigint"?`code ${h}`:h instanceof Error?h.message||h.name:String(h),p=[d,y].filter(E=>!!E).filter((E,k,L)=>L.indexOf(E)===k).join(`
15
15
  `);console.error(`[lecodes] native engine error — ${p||y} (see the console for the engine's message)`);const w={message:"Native engine error",detail:p,frames:[],native:!0,stack:h instanceof Error?h.stack:void 0};(m=l.onError)==null||m.call(l,w),w.stack&&t&&ar(w.stack).then(E=>{var k;E.length>0&&((k=l.onError)==null||k.call(l,{...w,nativeFrames:E}))});return}const f=h instanceof Error?h.message:String(h),g=u[0];console.error(g?`[lecodes] ${f}
16
16
  at ${g.source}:${g.line}:${g.column}${g.fn?` (${g.fn})`:""}`:`[lecodes] ${f}`),(x=l.onError)==null||x.call(l,{message:f,frames:u,stack:h instanceof Error?h.stack:void 0})},r=(l,h)=>{for(let d=e.length-1;d>=0;d--){const f=e[d];if(!f.sourceMap)continue;const g=qt(l,f.sourceMap);if(g.length>0)return s(f,l,g,h)}const u=e[e.length-1];u&&Ve(l)&&s(u,l,[],h)};let i=null;const o=()=>{const l=e[e.length-1],h=i;if(i=null,!h||!l)return;const u=new Error(h.message.replace(/^Error: /,""));u.stack=h.stack.join(`
@@ -18,4 +18,4 @@ var Hn=Object.defineProperty;var $n=(n,t,e)=>t in n?Hn(n,t,{enumerable:!0,config
18
18
  `);return i={message:(u??"").replace(/^JsTask /,""),stack:d},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",c),e.length=0}}},Mn=n=>{var c,l,h,u;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const d of s[1].split(";"))e.add(d);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((c=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:c[1])??null,o=((h=(l=t.match(/^\/\/ name: (.+)$/m))==null?void 0:l[1])==null?void 0:h.trim())??null,a=new Set((((u=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:u[1])??"").split(";").map(d=>d.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:ii(t)}},ki=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",je=(n,t)=>Math.max(1,Math.round(n/t*1e3)/1e3),Ti=(n,t=1)=>{const e=n.ownerDocument,s=e.defaultView??window;let r=t>0?t:1,i=1/0;const o=(y,p)=>{const w=(s.devicePixelRatio||1)*Ft(n),E=Math.min(i,w*r),k=je(y,r),L=je(p,r);return{width:k,height:L,factor:E,scale:r,pixelWidth:Math.max(1,Math.round(k*E)),pixelHeight:Math.max(1,Math.round(L*E))}};let a=o(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const c=[],l=y=>{y.width!==a.pixelWidth&&(y.width=a.pixelWidth),y.height!==a.pixelHeight&&(y.height=a.pixelHeight)},h=()=>{const y=e.createElement("canvas");return y.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(y),l(y),c.push(y),y},u=new Set,d=y=>{if(!(y.width<=0||y.height<=0)){a=y;for(const p of c)l(p);for(const p of u)p(a)}};let f=null;const g=(y,p,w)=>{const E=o(y,p),k=w&&Math.abs(w.inlineSize-E.width*E.factor)<=1&&Math.abs(w.blockSize-E.height*E.factor)<=1;if(!w||!k){d(E);return}d({...E,pixelWidth:Math.max(1,w.inlineSize),pixelHeight:Math.max(1,w.blockSize)})},m=new ResizeObserver(([y])=>{var k;if(!y)return;const{width:p,height:w}=y.contentRect,E=((k=y.devicePixelContentBoxSize)==null?void 0:k[0])??null;f={width:p,height:w,device:E},g(p,w,E)});try{m.observe(n,{box:"device-pixel-content-box"})}catch{m.observe(n)}const x=y=>{y!==void 0&&(i=y>0?y:1/0);const p=o(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==a.pixelWidth||p.pixelHeight!==a.pixelHeight||p.factor!==a.factor||p.width!==a.width||p.height!==a.height)&&d(p)};return{root:n,doc:e,win:s,size:()=>a,scale:()=>r,newCanvas:h,remeasure:x,setScale(y){!(y>0)||y===r||(r=y,f?g(f.width,f.height,f.device):x())},onResize(y){return u.add(y),()=>{u.delete(y)}},destroy(){m.disconnect(),u.clear();for(const y of c)y.remove();c.length=0}}},Ri=n=>{const t=new Map;let e=0,s=[];const r=new Set,i=c=>{r.has(c)||(r.add(c),console.warn(`[web-host] gl.${c}: this host's engine has no such call yet (a runtime module of an older build) — ignored`))},o=c=>Float32Array.from(c);return{facade:n?{setMatrix(c,l){var h;(h=n.creator())==null||h.setWorldMatrix(c,o(l))},setVisible(c,l){var h;(h=n.creator())==null||h.setVisible(c,l)},setCameraMatrix(c,l){var u;const h=n.creator();if(h&&!h.setCameraMatrix)return i("setCameraMatrix");(u=h==null?void 0:h.setCameraMatrix)==null||u.call(h,c,o(l))},setProjection(c,l,h,u){var f;const d=n.creator();if(d&&!d.setCameraProjectionMatrix)return i("setProjection");(f=d==null?void 0:d.setCameraProjectionMatrix)==null||f.call(d,c,o(l),h,u)},clearProjection(c){var l,h;(h=(l=n.creator())==null?void 0:l.clearCameraProjectionMatrix)==null||h.call(l,c)},setBackground(c,l,h=fi){const u=n.creator();if(!u)return;if(!u.setSceneBackground||!n.surface)return i("setBackground");l&&l.nodeName!=="VIDEO"&&!r.has("setBackground(canvas)")&&(r.add("setBackground(canvas)"),console.warn("[web-host] gl.setBackground: the web player shows a video background only — a canvas is not shown (Web Lite shows it)"));const d=(l==null?void 0:l.nodeName)==="VIDEO"?l:null,f=d?n.surface.videoTexture(d):void 0;u.setSceneBackground(c,f??4294967295,Float32Array.from(h))},createExternalTexture:()=>null,onFrame(c){const l=e++;return t.set(l,c),()=>{t.delete(l)}},readPixels(c,l){if(!n.surface||n.presented()!==c){l(null,0,0);return}s.push({scene:c,then:l})},viewport:()=>di(n.view,n.view.ownerDocument.defaultView??window)}:hi(),before(){if(t.size!==0)for(const c of[...t.values()])c()},after(){if(s.length===0||!(n!=null&&n.surface))return;const c=n.presented(),l=s.filter(u=>u.scene===c);for(const u of s)u.scene!==c&&u.then(null,0,0);if(s=l,l.length===0||!n.frameRendered())return;s=[];const h=n.surface.readPixels();for(const u of l)h?u.then(h.rgba.slice(),h.width,h.height):u.then(null,0,0)},worldChanged(){t.clear();const c=s;s=[];for(const l of c)l.then(null,0,0)}}},Ai=(n,t)=>{const e=[],s=new Set;return{has:r=>s.has(r),register(r,i){s.has(r)||(s.add(r),i({registerView:(o,a,c=1)=>{e.push({id:r,version:c,kind:"view",name:o,factory:a})},registerService:(o,a,c=1)=>{e.push({id:r,version:c,kind:"service",name:o,factory:a})},putBuffer:ft,getBuffer:et,gl:t}))},allow(r){var o,a;const i=new Set(r);for(const c of e){const l=i.has(c.id);c.kind==="view"?l?(o=n.registerView)==null||o.call(n,c.name,c.factory,c.version):(a=n.unregisterView)==null||a.call(n,c.name):l?n.registerService(c.name,c.factory,c.version):n.unregisterService(c.name)}}}},Mi=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()}}},Li={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world","foliage-cards":"world"},ze="material:",Pi=n=>{const t=new Set;for(const e of n)e.startsWith(ze)&&t.add(Li[e.slice(ze.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},Oi=""+new URL("assets/materials-CJzxzdUK.bin",import.meta.url).href,Ci=""+new URL("assets/materials-world-BNQb0Z1l.bin",import.meta.url).href,Ii=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,Fi=""+new URL("assets/uberarchive-Ok2HfJvn.bin",import.meta.url).href,Ni={base:Oi,world:Ci},Ui=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},Bi=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=Pi(n).map(o=>Ni[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(Ii),t(Fi),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:Ui(i)}:{}}},Di=n=>{const t=()=>n.push(document.hidden?"pause":"resume"),e=()=>n.push("online"),s=()=>n.push("offline");return document.addEventListener("visibilitychange",t),window.addEventListener("online",e),window.addEventListener("offline",s),{table:{state:()=>document.hidden?"background":"active",isOnline:()=>navigator.onLine,openUrl(i){window.open(i,"_blank","noopener")},worldChange(){var i;(i=n.onWorldChange)==null||i.call(n)},setOrientation(i){var c,l,h,u;const o=i==="landscape"||i==="portrait"?i:"auto";if(n.onOrientation){n.onOrientation(o);return}const a=typeof screen<"u"?screen.orientation:void 0;if(a)try{o==="auto"?(c=a.unlock)==null||c.call(a):(u=(h=(l=a.lock)==null?void 0:l.call(a,o))==null?void 0:h.catch)==null||u.call(h,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},Wi=(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([ft(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ft(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)}},Ln=n=>n==="camera"?"camera":n==="microphone"||n==="speech"?"microphone":n==="location"?"geolocation":null,Pn=(n,t,e)=>{const s=Ln(n);if(!s){e(`${n}: not a permission this host asks for`);return}const r=navigator.permissions;if(!(r!=null&&r.query)){t("prompt");return}r.query({name:s}).then(i=>t(i.state),()=>t("prompt"))},Hi=(n,t,e)=>{if(!Ln(n)){e(`${n}: not a permission this host asks for`);return}const s=()=>Pn(n,t,e);if(n==="location"){if(!navigator.geolocation){t("denied");return}navigator.geolocation.getCurrentPosition(()=>t("granted"),i=>i.code===i.PERMISSION_DENIED?t("denied"):s(),{timeout:15e3,maximumAge:1/0});return}const r=navigator.mediaDevices;if(!(r!=null&&r.getUserMedia)){t("denied");return}r.getUserMedia(n==="camera"?{video:!0}:{audio:!0}).then(i=>{for(const o of i.getTracks())o.stop();t("granted")},i=>{const o=i instanceof Error?i.name:"";o==="NotAllowedError"||o==="SecurityError"?t("denied"):s()})},$i=(n,t)=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return(t==null?void 0:t())||window.devicePixelRatio||1},vibrate(){var e;try{(e=navigator.vibrate)==null||e.call(navigator,30)}catch{}},clipboardWrite(e){var s;(s=navigator.clipboard)==null||s.writeText(e).catch(()=>{})},clipboardRead(e,s){const r=navigator.clipboard;if(!(r!=null&&r.readText)){s("Clipboard is not available");return}r.readText().then(e,i=>s(i instanceof Error?i.message:"Clipboard read failed"))},share(e){const s=URL.createObjectURL($t(e)),r=document.createElement("a");r.href=s,r.download="image.png",document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},openFilePicker:(e,s,r,i)=>Wi(e,s,r,i??void 0),queryPermission:Pn,requestPermission:Hi}),Vi=(n={})=>({local:t=>gr(t),dispose:t=>hr(t),request(t,e,s,r,i,o,a,c){if(t.startsWith("id:")){const u=Number(t.slice(3));o(u,et(u)?200:404);return}const l={};for(let u=0;u+1<s.length;u+=2)l[s[u]]=s[u+1];let h;if(i.length>0){const u=new FormData;for(const d of i)d.key!==null&&(d.bufferId>0?u.append(d.key,$t(d.bufferId),d.filename??void 0):u.append(d.key,d.value??""));h=u}else r!==null&&(h=r);(async()=>{var u;try{const d=await fetch(t,{method:e,headers:l,body:h,mode:"cors",credentials:"omit"}),f=c?(u=d.body)==null?void 0:u.getReader():void 0;if(!f){o(ft(await d.arrayBuffer()),d.status);return}const g=Number(d.headers.get("content-length"))||void 0,m=[];let x=0;for(;;){const{done:w,value:E}=await f.read();if(w)break;E&&(m.push(E),x+=E.length,c({loaded:x,total:g}))}const y=new Uint8Array(x);let p=0;for(const w of m)y.set(w,p),p+=w.length;o(ft(y.buffer),d.status)}catch(d){a(d instanceof Error?d.message:String(d))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>ft(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}}),Ke=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Jt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Ct=4,Qt=16,Xe=16,Gi=.5,ji=n=>{const t=new Set;let e=null;const s=(_,M,N=-1,P=0)=>{e==null||e(_,M,N,P)},r=_=>{if(!_.code)return;const M=t.has(_.code);t.add(_.code),s(0,_.code,-1,M||_.repeat?1:0)},i=_=>{_.code&&t.delete(_.code)&&s(1,_.code)},o=()=>{for(const _ of[...t])_.startsWith("Gamepad")||(t.delete(_),s(1,_))},{root:a}=n;let c=0,l=0,h=0,u=0,d=0,f=0,g=0,m=0,x=0,y=0;const p=_=>{var P;if(_.pointerType&&_.pointerType!=="mouse")return;const M=a.getBoundingClientRect(),N=((P=n.scale)==null?void 0:P.call(n))||1;c=(_.clientX-M.left)/N,l=(_.clientY-M.top)/N,h+=(_.movementX||0)/N,u+=(_.movementY||0)/N},w=_=>{const M=Ke[_.button];M&&(t.add(M),s(0,M))},E=_=>{const M=Ke[_.button];M&&t.delete(M)&&s(1,M)},k=_=>{const M=_.deltaMode===0?.01:1;d+=_.deltaX*M,f+=_.deltaY*M},L=_=>{document.pointerLockElement===a&&_.preventDefault()},C=[],F=[],U=[],$=()=>{var M,N;const _=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let P=0;P<Ct;P++){const rt=_[P]??null,Q=!!rt&&rt.connected;if(Q!==!!C[P]){if(C[P]=Q,!Q){for(const D of Jt)t.delete(D+"@"+P)&&(s(1,D,P),K(D));U[P]=[],F[P]=[0,0,0,0,0,0]}s(Q?2:3,"",P)}if(!rt||!Q)continue;const ct=rt.axes,pt=rt.buttons,Rt=((M=pt[6])==null?void 0:M.value)??0,S=((N=pt[7])==null?void 0:N.value)??0;F[P]=[ct[0]??0,ct[1]??0,ct[2]??0,ct[3]??0,Rt,S];const I=U[P]??(U[P]=[]);for(let D=0;D<Jt.length;D++){const Z=pt[D],st=!!Z&&(Z.pressed||Z.value>Gi);if(st===!!I[D])continue;I[D]=st;const At=Jt[D];st?t.add(At+"@"+P):t.delete(At+"@"+P),K(At),s(st?0:1,At,P)}}},K=_=>{let M=!1;for(let N=0;N<Ct&&!M;N++)t.has(_+"@"+N)&&(M=!0);M?t.add(_):t.delete(_)};let G=0;const q=()=>{g=h,m=u,x=d,y=f,h=u=d=f=0,$(),G=requestAnimationFrame(q)},A=n.windows.filter((_,M,N)=>_&&N.indexOf(_)===M);for(const _ of A)n.keyboard!==!1&&(_.addEventListener("keydown",r),_.addEventListener("keyup",i)),_.addEventListener("blur",o);return a.addEventListener("pointermove",p,!0),a.addEventListener("mousedown",w,!0),window.addEventListener("mouseup",E,!0),a.addEventListener("wheel",k,{passive:!0,capture:!0}),a.addEventListener("contextmenu",L,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(q)),{inputKey:(_,M)=>M>=0&&_.startsWith("Gamepad")?t.has(_+"@"+M):t.has(_),inputRead:_=>{var M;switch(_){case 0:return c;case 1:return l;case 2:return g;case 3:return m;case 4:return x;case 5:return y;case 6:return document.pointerLockElement===a?1:0;case 7:{let N=0;for(let P=0;P<Ct;P++)C[P]&&N++;return N}}if(_>=Qt){const N=Math.floor((_-Qt)/Xe),P=(_-Qt)%Xe;return N>=Ct||!C[N]?0:P===0?1:((M=F[N])==null?void 0:M[P-1])??0}return 0},inputSetPointerLock:_=>{if(!_)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const M=a.requestPointerLock({unadjustedMovement:!0});return M&&typeof M.catch=="function"&&M.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:_=>{e=_},dispose:()=>{for(const _ of A)_.removeEventListener("keydown",r),_.removeEventListener("keyup",i),_.removeEventListener("blur",o);a.removeEventListener("pointermove",p,!0),a.removeEventListener("mousedown",w,!0),window.removeEventListener("mouseup",E,!0),a.removeEventListener("wheel",k,!0),a.removeEventListener("contextmenu",L,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},zi=n=>{const t=ji(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},Ki={createVideo:Rr,createAudio:Ar,setVolume:Mr,setPlaying:Lr,setLoop:Pr,time:Or,setTime:Cr,duration:Ir,remove:Fr},Xi=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(d,f,g=1)=>{n.set(d,f),t.set(d,g)},unregisterService:d=>{n.delete(d),t.delete(d)},isServiceSupported:d=>n.has(d),serviceVersion:d=>t.get(d)??0,serviceOpen:(d,f,g)=>{const m=n.get(d);if(!m)return-1;const x=s++,y=m(f?JSON.parse(f):{},{emit:(p,w)=>{w===void 0?g(p):g(p,w)}});return e.set(x,y),x},serviceCall:(d,f,g,m,x)=>{const y=e.get(d);if(!(y!=null&&y.call)){x(`Service call "${f}": no live session or no call handler (serviceId ${d})`);return}try{Promise.resolve(y.call(f,Array.isArray(g)?g:[])).then(p=>{p===void 0?m():m(p)},p=>x(p instanceof Error?p.message:String(p)))}catch(p){x(p instanceof Error?p.message:String(p))}},serviceClose:d=>{var f,g;(g=(f=e.get(d))==null?void 0:f.close)==null||g.call(f),e.delete(d)},destroy:()=>{var d;for(const f of e.values())(d=f.close)==null||d.call(f);e.clear()}}},Yi=()=>{const n=Xi();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}},qi=()=>{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}}},Ji=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{}}}},Ye=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},Qi={fetch:lr,getBuffer:et,getBlob:$t,putBuffer:ft,putLocalBuffer:ur,hasLocalBuffer:dr,getLocalName:fr,getPlayer:ge,removePlayers:yn},Zi=(n,t)=>({nodeFactory(){},setPropertyString(){},setPropertyInt(){},setFlags(){},insertNode(){},removeNode(){},releaseNode(){},openView(e,s,r){n(e,r)},dropView(e,s,r){t(e,r)},closeView(){n(-1,0)},layerOpen(){},layerClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),to=async(n,t={})=>{var Rt;const e=t.header,s=t.profile??(e?ki(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),c=Ti(n,t.scale??1),{doc:l,win:h}=c,u=i?Promise.all([ci(void 0,l),oi((e==null?void 0:e.bootFonts)??[],l)]):null,d=o?yi(c,r.has("capture")):null,f=a?wi(c):null,g=i?c.newCanvas():null,m=_i(h,o);o&&cr();const[x,y]=await Promise.all([Xn(s,{glContext:d==null?void 0:d.context,glOptions:d==null?void 0:d.options,gl2dContext:f==null?void 0:f.context,gl2dOptions:f==null?void 0:f.options,moduleArgs:{print:S=>{m.runtimeLine(S)?console.debug(S):console.log(S)},printErr:S=>{console.error(S)}}}),o?Bi(r):Promise.resolve({})]),p=(S,I)=>{const D=x.stringToNewUTF8(S);try{return I(D)}finally{x._free(D)}};let w=null,E=-1,k=-1,L=-1;const C=(S,I)=>{k=S,L=S===Mt?I:-1,S===Mt&&(d==null||d.show()),S===Oe&&(f==null||f.show()),w&&S===Mt&&I!==E&&(E=I,w.openScene(I))},F=S=>{S!==k&&(S===Mt&&(d==null||d.hide(),w&&E>=0&&(E=-1,w.closeScene())),S===Oe&&(f==null||f.hide()))};let U=null;const $=Ri(o||t.engine3d?{creator:()=>U==null?void 0:U._creator,surface:d,presented:()=>L,frameRendered:()=>{var S;return!!((S=x._creatorWebFrameRendered)!=null&&S.call(x))},view:(d==null?void 0:d.canvas)??n}:null),K=ri();let G=t.keyboardBand??0;const A=g?zs(n,{M:x,canvas:g,canvasHost:K,keyboardHeight:()=>{const S=h.visualViewport,I=S?Math.max(0,Math.round((h.innerHeight-S.height-S.offsetTop)/(Ft(n)*c.scale()))):0;return I>0?I:G},onKeyboard:t.onKeyboard}):null;A&&(A.ui.onDestination=C,A.ui.onDropped=F);const v=Di({onOrientation:t.onOrientation,onWorldChange:()=>$.worldChanged(),push:(S,I)=>{S==="url"&&I!==void 0&&p(I,D=>x._creatorWebSetLaunchUrl(D)),p(S,D=>{I===void 0?x._creatorWebAppEvent(D,0):p(I,Z=>x._creatorWebAppEvent(D,Z))})}}),T=qi(),O=Yi(),j=zi({windows:[...new Set([h,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,scale:()=>Ft(n)*c.scale(),push:(S,I,D,Z)=>p(I,st=>x._creatorWebInputEvent(S,st,D,Z)),keyboardHeight:()=>(A==null?void 0:A.ui.keyboardHeight())??0}),J={ui:(A==null?void 0:A.ui)??Zi(C,F),app:v.table,device:$i(t.language??(()=>(h.navigator.language||"en").slice(0,2)),()=>c.size().factor),fetch:Vi(y),storage:Ji(t.project??(e==null?void 0:e.name)??"app"),socket:T.table,service:O.table,input:j.table,media:Ki,canvas:K.table,...d?{gl:d.table(x)}:{},...f?{scene2d:f.table(x)}:{}},_=Ye(),M=_.global;U=M,rr(x,{host:J,world:_,newWorld:()=>{const S=Ye();return U=S.global,S}});const N=Ai({...A?{registerView:(S,I,D)=>A.ui.registerView(S,I,D),unregisterView:S=>A.ui.unregisterView(S)}:{},registerService:O.registerService,unregisterService:O.unregisterService},$.facade);x._creatorWebInit(),t.launchUrl&&p(t.launchUrl,S=>x._creatorWebSetLaunchUrl(S)),A==null||A.ui.install(),!o&&t.engine3d&&(w=await t.engine3d({newCanvas:c.newCanvas,preloads:r,canvasHost:K,stores:Qi}),Object.defineProperty(M,"_creator",{value:w,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Rt=M._creator)==null||Rt.createEngine());const P=Mi(n);t.safeArea&&P.set(t.safeArea);const rt=S=>{var I;d==null||d.resize(),f==null||f.resize(),(I=w==null?void 0:w._onResize)==null||I.call(w,S.width,S.height,S.factor),A?(A.resize(S.width,S.height,S.factor,S.scale),A.setSafeArea(P.current())):x._creatorWebResize(S.width,S.height)};c.onResize(rt),rt(c.size());let Q=0;const ct=S=>{Q=h.requestAnimationFrame(ct),$.before(),d==null||d.frame(),x._creatorWebTick(S),$.after(),f==null||f.frame(S),A&&(A.ui.layoutFrame(),A.ui.tickHover(),A.render())};Q=h.requestAnimationFrame(ct),await u;let pt=!1;return{profile:s,M:x,world:M,ui:(A==null?void 0:A.ui)??null,engine3d:()=>w,getBuffer:S=>et(S),run(S,I={}){const D=I.header??Mn(S);if(!li(D.sdk,$e))throw new Error(`This app was built with LeCodes SDK ${D.sdk??"older than 2.0"}; this host runs SDK ${$e}. It needs a new build.`);const Z=m.track(S,I.onError);return N.allow(D.plugins),p(S,st=>x._creatorWebRun(st)),{dispose:Z.drop}},registerPlugin:(S,I)=>N.register(S,I),hasPlugin:N.has,locate:m.locate,safeArea:()=>P.current(),setSafeArea(S){P.set(S),A==null||A.setSafeArea(P.current())},setKeyboardBand(S){G=S??0,A==null||A.ui.refreshKeyboard()},remeasure:c.remeasure,setScale:c.setScale,size:c.size,emitAppEvent:v.emit,destroy(){var S;pt||(pt=!0,h.cancelAnimationFrame(Q),m.dispose(),A==null||A.destroy(),j.dispose(),T.dispose(),O.dispose(),v.dispose(),yn(),P.destroy(),(S=w==null?void 0:w._dispose)==null||S.call(w),d==null||d.destroy(),f==null||f.destroy(),c.destroy())}}},eo=(n,t,e,s)=>new Promise(r=>{const i=n.ownerDocument.defaultView??window;i.requestAnimationFrame(()=>{try{const o=[...n.querySelectorAll("canvas")].filter(h=>h.width>0&&h.height>0&&i.getComputedStyle(h).display!=="none");if(o.length===0||t<=0||e<=0){r(null);return}const a=s??Math.max(...o.map(h=>h.width))/t,c=n.ownerDocument.createElement("canvas");c.width=Math.max(1,Math.round(t*a)),c.height=Math.max(1,Math.round(e*a));const l=c.getContext("2d");if(!l){r(null);return}l.fillStyle="#000000",l.fillRect(0,0,c.width,c.height);for(const h of o)l.drawImage(h,0,0,h.width,h.height,0,0,c.width,c.height);r(c.toDataURL("image/png"))}catch{r(null)}})}),no=n=>{if(typeof n=="string")return n;if(n instanceof Error)return n.stack?`${String(n)}
19
19
  ${n.stack}`:String(n);try{return JSON.stringify(n)}catch{return String(n)}},ro=(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 c={};try{c=JSON.parse(String(a.data))}catch{return}c.type==="reload"&&typeof c.v=="number"&&t(c.v)},o.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:o=>`${n}/bundle.js?t=web&v=${o}`,versionOf(o,a){const c=Number(o.headers.get("x-lecodes-v"));return o.headers.has("x-lecodes-v")&&Number.isFinite(c)?c:a},ran(o){s=o},log:(o,a)=>e({type:"log",level:o,text:a.map(no).join(" ")}),error:o=>e({type:"error",text:o})}},so={ar:()=>W(()=>import("./assets/ar-mVXX3kRQ.js"),[],import.meta.url).then(n=>t=>n.register(t,()=>W(()=>import("./assets/ar-D6oDL4pw.js"),[],import.meta.url).then(e=>e.resources))),"audio-recorder":()=>W(()=>import("./assets/audio-recorder-Bt-Caym7.js"),[],import.meta.url).then(n=>t=>n.register(t)),browser:()=>W(()=>import("./assets/browser-BpFb50ko.js"),[],import.meta.url).then(n=>t=>n.register(t)),camera:()=>W(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>W(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>W(()=>import("./assets/map-8PhtP3jn.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>W(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>W(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t)),speech:()=>W(()=>import("./assets/speech-DzDPVK_j.js"),[],import.meta.url).then(n=>t=>n.register(t)),webrtc:()=>W(()=>import("./assets/webrtc-CbCltXvl.js"),[],import.meta.url).then(n=>t=>n.register(t))},io=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=so[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)}`)}}))},me=n=>typeof n=="object"&&n!==null,at=n=>typeof n=="number"&&Number.isFinite(n),oo=n=>{if(!me(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return at(n.x)&&at(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return at(n.node)?{ask:"node",node:n.node}:null;default:return null}},On=n=>{if(!me(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}:{}}},ao=n=>{const t=Number(n.get("keyboard-band"));return Number.isFinite(t)&&t>0?t:null},Cn=n=>at(n)&&n>0?Math.min(4,n):null,co=n=>Cn(Number(n.get("scale"))),lo=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return On({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},ho=n=>{if(!me(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:On(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:keyboard-band":return{type:"lecodes:keyboard-band",height:at(n.height)&&n.height>0?n.height:null};case"lecodes:scale":{const t=Cn(n.scale);return t===null?null:{type:"lecodes:scale",scale:t}}case"lecodes:inspect":{const t=oo(n.question);return t&&at(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!at(n.request))return null;const t=at(n.pixelRatio)&&n.pixelRatio>0?Math.min(4,n.pixelRatio):void 0;return{type:"lecodes:capture",request:n.request,...t!==void 0?{pixelRatio:t}:{}}}default:return null}},uo=(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}},fo=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=ho(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)}}},Tt=window.lecodesPlayerConfig??{},xt=document.getElementById("app"),Zt=document.getElementById("loader"),qe=document.getElementById("error"),nt=new URLSearchParams(location.search),In=n=>Zt==null?void 0:Zt.classList.toggle("on",n),Fn=n=>{qe&&(qe.textContent=window.parent===window?n:"")};let ue=Tt.language||nt.get("lang")||(navigator.language||"en").slice(0,2),Bt=Tt.safeArea??lo(nt),Dt=Tt.keyboardBand??ao(nt),tt=Tt.scale??co(nt)??1,B=null;const Je=()=>{var n;return(n=B==null?void 0:B.world)==null?void 0:n._creatorTree},Wt=nt.has("test")?{ready:!1,dump:()=>{var n;return((n=Je())==null?void 0:n.debugDump())??'{"roots":[]}'},rect:n=>{var s;const t=(s=Je())==null?void 0:s.getBoundingClientRect(n);if(!t)return null;const e=xt.getBoundingClientRect();return[e.left+t[0]*tt,e.top+t[1]*tt,t[2]*tt,t[3]*tt]}}:null;Wt&&(window.lecodesTest=Wt);const go=nt.has("inspect"),de=go?W(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url):null;let vt=null;const po=async(n,t)=>{const{createInspector:e}=await(de??W(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url));B&&vt===null&&(vt=e(B)),Y.post({type:"lecodes:inspected",request:n,answer:(vt==null?void 0:vt.answer(t))??null})},Qe=nt.has("dev")?new URL(nt.get("dev")||"..",location.href).href.replace(/\/$/,""):null,Ze=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}`},Nn=n=>{Fn(Ze(n)),Y.post({type:"lecodes:error",error:n}),z==null||z.error(Ze(n))},Un=n=>Nn({message:n,frames:[]});let dt=null,te=!1,ee=null;const mo=async n=>{In(!0),Fn(""),B==null||B.destroy(),B=null,vt=null,xt.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=Mn(e);B=await to(xt,{header:s,language:()=>ue,launchUrl:location.href,...Bt?{safeArea:Bt}:{},...Dt?{keyboardBand:Dt}:{},scale:tt,...Y.embedded?{onKeyboard:(r,i)=>Y.post({type:"lecodes:keyboard",height:r,duration:i})}:{},...Y.embedded?{onOrientation:r=>Y.post({type:"lecodes:orientation",mode:r})}:{}}),await io(B,s.plugins),de&&(await de).recordSites(B),B.run(e,{onError:Nn}),Wt&&(Wt.ready=!0),z&&n.version!==void 0&&(Ht=z.versionOf(t,n.version),z.ran(Ht)),Y.post({type:"lecodes:ready",src:n.src})},gt=n=>{if(te){ee=n;return}te=!0,dt=n,mo(n).catch(t=>Un(t instanceof Error?t.message:String(t))).finally(()=>{In(!1),te=!1;const t=ee;ee=null,t&&gt(t)})},ye=n=>{const t=uo(n,location.href);t?gt({src:t}):Un(`The player runs bundles of its own origin only: ${n}`)},Bn=n=>{Bt=n,B==null||B.setSafeArea(Bt)},yo=n=>{Dt=n,B==null||B.setKeyboardBand(Dt)},Dn=n=>{tt=n,B==null||B.setScale(tt)},Wn=async n=>{const t=B==null?void 0:B.size(),[e,s]=t?[t.width,t.height]:[Math.round(xt.clientWidth/tt),Math.round(xt.clientHeight/tt)];return{image:B?await eo(xt,e,s,n):null,width:e,height:s}},Y=fo(window,n=>{switch(n.type){case"lecodes:run":ye(n.src);break;case"lecodes:reload":dt&&gt(dt);break;case"lecodes:safe-area":Bn(n.insets);break;case"lecodes:keyboard-band":yo(n.height);break;case"lecodes:scale":Dn(n.scale);break;case"lecodes:inspect":po(n.request,n.question);break;case"lecodes:capture":Wn(n.pixelRatio).then(t=>Y.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===ue)break;ue=n.language,dt&&gt(dt);break}});let Ht=-1;const z=Qe?ro(Qe,n=>{Ht>=0&&n!==Ht&&gt({src:z.bundleUrl(n),version:n})}):null;if(z||Y.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{z==null||z.log(t,s),Y.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:"a484159a-2026-10-28",get host(){return B},run:ye,reload(){dt&&gt(dt)},setSafeArea:Bn,setScale:Dn,capture:async n=>(await Wn(n)).image};const tn=Tt.src??nt.get("src");z?gt({src:z.bundleUrl(0),version:0}):tn&&ye(tn);export{W as _};
21
+ in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},Nn=n=>{Fn(Ze(n)),Y.post({type:"lecodes:error",error:n}),z==null||z.error(Ze(n))},Un=n=>Nn({message:n,frames:[]});let dt=null,te=!1,ee=null;const mo=async n=>{In(!0),Fn(""),B==null||B.destroy(),B=null,vt=null,xt.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=Mn(e);B=await to(xt,{header:s,language:()=>ue,launchUrl:location.href,...Bt?{safeArea:Bt}:{},...Dt?{keyboardBand:Dt}:{},scale:tt,...Y.embedded?{onKeyboard:(r,i)=>Y.post({type:"lecodes:keyboard",height:r,duration:i})}:{},...Y.embedded?{onOrientation:r=>Y.post({type:"lecodes:orientation",mode:r})}:{}}),await io(B,s.plugins),de&&(await de).recordSites(B),B.run(e,{onError:Nn}),Wt&&(Wt.ready=!0),z&&n.version!==void 0&&(Ht=z.versionOf(t,n.version),z.ran(Ht)),Y.post({type:"lecodes:ready",src:n.src})},gt=n=>{if(te){ee=n;return}te=!0,dt=n,mo(n).catch(t=>Un(t instanceof Error?t.message:String(t))).finally(()=>{In(!1),te=!1;const t=ee;ee=null,t&&gt(t)})},ye=n=>{const t=uo(n,location.href);t?gt({src:t}):Un(`The player runs bundles of its own origin only: ${n}`)},Bn=n=>{Bt=n,B==null||B.setSafeArea(Bt)},yo=n=>{Dt=n,B==null||B.setKeyboardBand(Dt)},Dn=n=>{tt=n,B==null||B.setScale(tt)},Wn=async n=>{const t=B==null?void 0:B.size(),[e,s]=t?[t.width,t.height]:[Math.round(xt.clientWidth/tt),Math.round(xt.clientHeight/tt)];return{image:B?await eo(xt,e,s,n):null,width:e,height:s}},Y=fo(window,n=>{switch(n.type){case"lecodes:run":ye(n.src);break;case"lecodes:reload":dt&&gt(dt);break;case"lecodes:safe-area":Bn(n.insets);break;case"lecodes:keyboard-band":yo(n.height);break;case"lecodes:scale":Dn(n.scale);break;case"lecodes:inspect":po(n.request,n.question);break;case"lecodes:capture":Wn(n.pixelRatio).then(t=>Y.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===ue)break;ue=n.language,dt&&gt(dt);break}});let Ht=-1;const z=Qe?ro(Qe,n=>{Ht>=0&&n!==Ht&&gt({src:z.bundleUrl(n),version:n})}):null;if(z||Y.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{z==null||z.log(t,s),Y.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:"356d0480-2026-10-28",get host(){return B},run:ye,reload(){dt&&gt(dt)},setSafeArea:Bn,setScale:Dn,capture:async n=>(await Wn(n)).image};const tn=Tt.src??nt.get("src");z?gt({src:z.bundleUrl(0),version:0}):tn&&ye(tn);export{W as _};
@@ -1,5 +1,5 @@
1
1
  var Zn=Object.defineProperty;var er=(e,t,n)=>t in e?Zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qe=(e,t,n)=>er(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();const tr=e=>{if(typeof e=="string")return e;if(e instanceof Error)return e.stack?`${String(e)}
2
- ${e.stack}`:String(e);try{return JSON.stringify(e)}catch{return String(e)}},nr=(e,t)=>{const n=s=>{fetch(`${e}/log`,{method:"POST",body:JSON.stringify(s),headers:{"content-type":"application/json"},keepalive:!0}).catch(()=>{})};let r=-1;const o=async()=>{try{const{v:s}=await(await fetch(`${e}/version`,{cache:"no-store"})).json();typeof s=="number"&&t(s)}catch{}setTimeout(o,2500)};setTimeout(o,2500);const i=()=>{let s;try{s=new WebSocket(e.replace(/^http/,"ws")+"/ws")}catch{return}s.onopen=()=>s.send(JSON.stringify({type:"hello",v:r})),s.onmessage=l=>{let d={};try{d=JSON.parse(String(l.data))}catch{return}d.type==="reload"&&typeof d.v=="number"&&t(d.v)},s.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:s=>`${e}/bundle.js?t=web&v=${s}`,versionOf(s,l){const d=Number(s.headers.get("x-lecodes-v"));return s.headers.has("x-lecodes-v")&&Number.isFinite(d)?d:l},ran(s){r=s},log:(s,l)=>n({type:"log",level:s,text:l.map(tr).join(" ")}),error:s=>n({type:"error",text:s})}},rr=(e,t)=>{try{const n=new URL(e,t);return n.origin===new URL(t).origin&&(n.protocol==="http:"||n.protocol==="https:")?n.href:null}catch{return null}},mn=(e,t)=>{const n=[];for(const r of t){const o=r.halves[e];for(const i of typeof o=="string"?[o]:Array.isArray(o)?o:[]){if(typeof i!="string"||!i)continue;const s=new URL(i,r.url).href;n.includes(s)||n.push(s)}}return n},or="modulepreload",sr=function(e,t){return new URL(e,t).href},Tt={},fe=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let s=function(E){return Promise.all(E.map(_=>Promise.resolve(_).then(A=>({status:"fulfilled",value:A}),A=>({status:"rejected",reason:A}))))};const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),c=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=s(n.map(E=>{if(E=sr(E,r),E in Tt)return;Tt[E]=!0;const _=E.endsWith(".css"),A=_?'[rel="stylesheet"]':"";if(!!r)for(let b=l.length-1;b>=0;b--){const y=l[b];if(y.href===E&&(!_||y.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${E}"]${A}`))return;const p=document.createElement("link");if(p.rel=_?"stylesheet":or,_||(p.as="script"),p.crossOrigin="",p.href=E,c&&p.setAttribute("nonce",c),document.head.appendChild(p),_)return new Promise((b,y)=>{p.addEventListener("load",b),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${E}`)))})}))}function i(s){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=s,window.dispatchEvent(l),!l.defaultPrevented)throw s}return o.then(s=>{for(const l of s||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Lt="2.4.9",Xe=e=>{const t=e==null?void 0:e.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},ir=(e,t)=>Xe(e)!==null&&Xe(e)===Xe(t),ar=(e,t="woff2")=>{const n=/^\/\/ fonts: (.+)$/m.exec(e);if(!n)return[];const r=[];for(const o of n[1].split(";")){const i=o.indexOf("=");if(i===-1)continue;const s=/^(.+)@(\d+)(i?)$/.exec(o.slice(0,i));s&&r.push({family:s[1],weight:parseInt(s[2],10),italic:s[3]==="i",url:o.slice(i+1).replace("{fmt}",t)})}return r},lr=async(e,t,n=2e3)=>{const r=t??(typeof document>"u"?void 0:document);if(!(r!=null&&r.fonts)||e.length===0)return;const o=[];for(const i of e)try{const s=new FontFace(i.family,`url("${i.url}")`,{weight:String(i.weight),style:i.italic?"italic":"normal"});r.fonts.add(s),o.push(s.load().catch(()=>{}))}catch{}await Promise.race([Promise.all(o),new Promise(i=>setTimeout(i,n))])},cr=e=>{var d,c,E,_;const t=e.slice(0,2e3),n=new Set,r=t.match(/\/\/ preload: (.+)/);if(r)for(const A of r[1].split(";"))n.add(A);const o=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((d=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:d[1])??null,s=((E=(c=t.match(/^\/\/ name: (.+)$/m))==null?void 0:c[1])==null?void 0:E.trim())??null,l=new Set((((_=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:_[1])??"").split(";").map(A=>A.trim()).filter(Boolean));return{sdk:i,name:s,preloads:n,gl:o,is2d:t.includes("// 2d: enable"),plugins:l,bootFonts:ar(t)}},ur=1,fr=2,dr=3,pr=4,hr=5,mr=6,xt=7,gr=8,Rt=9,br=10,yr=11,vr=12,Er=13,wr=14,Sr=15,_r=16,At=17,kr=18,Tr=19,Ue=20,xi=21,Ri=22,Ai=23,Ci=24,$i=25,Lr=26,xr=27,Rr=28,Ar=29,Ct=30,$t=31,Cr=32,$r=33,Ot=34,Ut=35,Mt=36,Ie=1,Or=2,Ur=4,he=8,Mr=16,Je=32,Nr=64,Qe=128,Pr=256,Fr=512,Ir=1024,Dr=2048,Br=4096,Nt=8192,Oi=16384,Vr=32768,Wr=1<<18,zr=255,Pt=256,Ft=512,Gr=1024,te=0,jr=1,Hr=2,Kr=3,We=4,ve=255,gn=e=>{const t=e.clientWidth;if(!t)return 1;const n=e.getBoundingClientRect().width;return n>0?n/t:1},It={text:{type:"text"},password:{type:"password"},search:{type:"search"},tel:{type:"tel"},email:{type:"email"},url:{type:"url"},number:{type:"text",mode:"numeric"},decimal:{type:"text",mode:"decimal"},date:{type:"date"},time:{type:"time"}},Dt=(e,t)=>e==null?t:e===!0||e==="true"||e==="1"||typeof e=="number"&&e>.5,oe=(e,t,n)=>{n===null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)},Yr=(e,t)=>{if(e.type!=="input"&&e.type!=="textarea")return;const n=e.el,r=t("placeholder");if(oe(n,"placeholder",r==null?null:String(r)),e.type==="input"){const l=It[String(t("type")??"text")]??It.text,d=n;d.type!==l.type&&(d.type=l.type),oe(n,"inputmode",l.mode??null);const c=t("enterKey");oe(n,"enterkeyhint",c==null?null:String(c))}const o=t("autocapitalize");oe(n,"autocapitalize",o==null?null:String(o));const i=t("autocorrect");i==null?(oe(n,"autocorrect",null),oe(n,"spellcheck",null)):(oe(n,"autocorrect",Dt(i,!0)?"on":"off"),oe(n,"spellcheck",Dt(i,!0)?"true":"false"));const s=Number(t("maxLength")??0);oe(n,"maxlength",s>0?String(Math.round(s)):null)},ze={width:"layout",height:"layout",minWidth:"layout",minHeight:"layout",maxWidth:"layout",maxHeight:"layout",flexBasis:"layout",flexGrow:"layout",flexShrink:"layout",aspectRatio:"layout",gap:"layout",rowGap:"layout",columnGap:"layout",padding:"layout",paddingTop:"layout",paddingRight:"layout",paddingBottom:"layout",paddingLeft:"layout",paddingHorizontal:"layout",paddingVertical:"layout",paddingStart:"layout",paddingEnd:"layout",margin:"layout",marginTop:"layout",marginRight:"layout",marginBottom:"layout",marginLeft:"layout",marginHorizontal:"layout",marginVertical:"layout",marginStart:"layout",marginEnd:"layout",left:"layout",right:"layout",top:"layout",bottom:"layout",start:"layout",end:"layout",inset:"layout",flexDirection:"enum",justifyContent:"enum",alignItems:"enum",alignSelf:"enum",position:"enum",flexWrap:"enum",boxSizing:"enum",display:"enum",overflow:"enum",scrollDirection:"enum",borderWidth:"len",borderTopWidth:"len",borderRightWidth:"len",borderBottomWidth:"len",borderLeftWidth:"len",borderHorizontalWidth:"len",borderVerticalWidth:"len",borderStartWidth:"len",borderEndWidth:"len",color:"color",backgroundColor:"color",borderColor:"color",borderTopColor:"color",borderRightColor:"color",borderBottomColor:"color",borderLeftColor:"color",placeholderColor:"color",refreshControlColor:"color",tintColor:"color",rippleColor:"color",overlayColor:"color",backgroundImage:"str",backgroundSize:"enum",backgroundGradient:"str",borderRadius:"len",borderTopLeftRadius:"len",borderTopRightRadius:"len",borderBottomRightRadius:"len",borderBottomLeftRadius:"len",opacity:"num",transform:"str",transformOrigin:"str",pointerEvents:"enum",fontSize:"len",fontWeight:"num",fontStyle:"enum",fontFamily:"str",lineHeight:"len",letterSpacing:"len",textAlign:"enum",textDecoration:"enum",lineClamp:"num",textOverflow:"enum",textWrap:"enum",objectFit:"enum",placeholder:"str",type:"enum",enterKey:"enum",autocapitalize:"enum",autocorrect:"num",maxLength:"num",keyboardShrink:"num",keyboardDismiss:"num",showScrollbar:"num",overscrollMode:"enum",keyboardDismissMode:"enum",snap:"enum",sheetDetents:"str",sheetDetent:"num",sheetDismissible:"num",dim:"num"},qr={p:"padding",pt:"paddingTop",pr:"paddingRight",pb:"paddingBottom",pl:"paddingLeft",px:"paddingHorizontal",py:"paddingVertical",m:"margin",mt:"marginTop",mr:"marginRight",mb:"marginBottom",ml:"marginLeft",mx:"marginHorizontal",my:"marginVertical",bgColor:"backgroundColor",bgImage:"backgroundImage",bgSize:"backgroundSize",bgGradient:"backgroundGradient"},Xr=["placeholderColor","refreshControlColor","tintColor","rippleColor","overlayColor","backgroundGradient"],Jr={display:"flex",overflow:"visible",scrollDirection:"vertical",borderWidth:0,borderTopWidth:0,borderRightWidth:0,borderBottomWidth:0,borderLeftWidth:0,borderHorizontalWidth:0,borderVerticalWidth:0,borderStartWidth:0,borderEndWidth:0,backgroundColor:0,borderColor:0,borderTopColor:0,borderRightColor:0,borderBottomColor:0,borderLeftColor:0,backgroundImage:"",backgroundSize:"cover",borderRadius:0,borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,opacity:1,transform:"identity",transformOrigin:"50% 50%",pointerEvents:"all",fontSize:14,fontWeight:400,fontStyle:"normal",lineHeight:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none",lineClamp:0,textOverflow:"ellipsis",textWrap:"wrap",objectFit:"cover",placeholder:"",type:"text",enterKey:"done",autocapitalize:"sentences",autocorrect:1,maxLength:0,keyboardShrink:1,keyboardDismiss:1,showScrollbar:1,overscrollMode:"default",keyboardDismissMode:"interactive",snap:"none",sheetDetents:"",sheetDetent:0,sheetDismissible:1,dim:0},Qr=["duration","delay","layer","commit","loop","loopMode","name"];function bn(e){let t=e.trim();/\sxmlns\s*=/.test(t)||(t=t.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"'));const n=new TextEncoder().encode(t);let r="";for(const o of n)r+=String.fromCharCode(o);return`data:image/svg+xml;base64,${btoa(r)}`}function Zr(e){const t=e.match(/viewBox\s*=\s*["']([^"']+)["']/);return t?t[1]:null}const eo=/\b(?:calc|min|max|clamp)\(/,to=e=>{if(!eo.test(e))return e;let t="";for(let n=0;n<e.length;n++){if(e.startsWith("var(",n)){let o=0;const i=n;for(;n<e.length;n++)if(e[n]==="(")o++;else if(e[n]===")"&&--o===0)break;t+=e.slice(i,Math.min(n+1,e.length));continue}const r=e[n];if(r==="+"||r==="-"){const o=t[t.length-1]??"";if(!(r==="-"&&(o==="e"&&"btlr".includes(e[n+1]??"")||e.slice(Math.max(0,n-7),n)==="comfort"))&&/[\w%.)]/.test(o)){for(t=t.trimEnd()+" "+r+" ";e[n+1]===" ";)n++;continue}}t+=r}return t.replace(/\d*\.\d+|\d+/g,(n,r,o)=>{const i=o.slice(0,r).trimEnd(),s=o.slice(r+n.length).trimStart();return/[\w.%]$/.test(i)||/^[\w.%]/.test(s)||/[*/]$/.test(i)||/^[*/]/.test(s)?n:n+"px"})},no={top:"12px",bottom:"4px",left:"16px",right:"16px"},yn=e=>`max(var(--safe-${e}, 0px), calc(var(--safe-${e}-bar, 0px) + var(--comfort-${e}, ${no[e]})))`,ro={vw:"cqw",vh:"cqh",vmin:"cqmin",vmax:"cqmax"},Ae=e=>to(e).replace(new RegExp("(?<![-\\w])comfort-(top|bottom|left|right)\\b","g"),(t,n)=>yn(n)).replace(new RegExp("(?<![-\\w])safe-(top|bottom|left|right)\\b","g"),(t,n)=>`var(--safe-${n}, 0px)`).replace(/(\d)(vmin|vmax|vw|vh)\b/g,(t,n,r)=>n+ro[r]),yt=/^-?\d*\.?\d+$/,se=e=>{if(typeof e=="number")return e+"px";const t=String(e).trim();return yt.test(t)?t+"px":Ae(t)},Ce=e=>{if(typeof e=="number")return"#"+(e>>>0).toString(16).padStart(e<=16777215?6:8,"0");const t=String(e);return t==="clear"?"transparent":t},oo=/^(rotate|skew)/,so=/^translate/,io=e=>{const t=String(e).trim();return t===""||t==="identity"?"none":t.replace(/([a-zA-Z0-9]+)\s*\(([^)]*)\)/g,(n,r,o)=>{const i=so.test(r)?"px":oo.test(r)?"deg":null;return i===null?n:`${r}(${o.split(",").map(s=>{const l=s.trim();return yt.test(l)?l+i:Ae(l)}).join(", ")})`})},vn=e=>typeof e=="number"?e+"px":String(e).trim().split(/\s+/).map(t=>yt.test(t)?t+"px":Ae(t)).join(" "),ee=0,re=1,ke=2,De=["top","right","bottom","left"],ao=(e,t)=>e==="safe-all"?`var(--safe-${t}, 0px)`:e==="comfort-all"||e==="comfort-x"||e==="comfort-y"?yn(t):se(e),ft=(e,t)=>{const n=(o,i)=>({rank:i,to:s=>o.map(l=>[t(l),ao(s,l)])}),r=o=>({rank:re,to:i=>[[t(o),se(i)]]});return{[e]:n(De,ee),[`${e}Horizontal`]:n(["left","right"],re),[`${e}Vertical`]:n(["top","bottom"],re),[`${e}Start`]:r("inline-start"),[`${e}End`]:r("inline-end"),[`${e}Top`]:n(["top"],ke),[`${e}Right`]:n(["right"],ke),[`${e}Bottom`]:n(["bottom"],ke),[`${e}Left`]:n(["left"],ke)}},lo=()=>{const e=ft("border",n=>`border-${n}-width`),t={};for(const n of Object.keys(e))t[`${n}Width`]=e[n];return t},vt=e=>{const t=[];let n=0,r="";for(const o of e.trim()){if(o==="("&&n++,o===")"&&n--,/\s/.test(o)&&n===0){r&&t.push(r),r="";continue}r+=o}return r&&t.push(r),t},co=new Set(["none","solid","dashed","dotted","double","hidden"]),uo=/^-?\d*\.?\d+([a-z%]*)$|^(calc|min|max|clamp)\(/,Se=(e,t)=>({rank:t,to:n=>{let r=null,o=null,i=null;if(typeof n=="number")r=n+"px";else for(const l of vt(String(n)))co.has(l)?i=l:uo.test(l)?r=se(l):o=Ce(l);const s=[];for(const l of e)s.push([`border-${l}-width`,r??(o?"1px":"0px")]),s.push([`border-${l}-color`,o??"transparent"]),i&&s.push([`border-${l}-style`,i]);return s}}),fo=e=>{const t=String(e).trim(),n=(i,s,l)=>[["flex-grow",i],["flex-shrink",s],["flex-basis",l]];if(t==="none")return n("0","0","auto");if(t==="auto")return n("1","1","auto");if(t==="initial")return n("0","1","auto");const r=vt(t),o=i=>i!==void 0&&/^-?\d*\.?\d+$/.test(i);return o(r[0])?r.length===1?n(r[0],"1","0%"):o(r[1])?n(r[0],r[1],r[2]!==void 0?se(r[2]):"0%"):n(r[0],"1",se(r[1])):n("1","1",se(r[0]??"auto"))},En=e=>{var t;return typeof e=="object"&&e!==null&&"_h"in e&&typeof((t=e._h)==null?void 0:t.id)=="number"},po=e=>e.replace(/<svg\b[^>]*>/,t=>t.replace(/\spreserveAspectRatio\s*=\s*("[^"]*"|'[^']*')/,"").replace(/^<svg\b/,'<svg preserveAspectRatio="none"')),wn=(e,t)=>{if(En(e))return`url("${t.bufferUrl(e._h.id)}")`;const n=String(e??"");return n===""?"none":n.startsWith("id:")?`url("${t.bufferUrl(Number(n.slice(3)))}")`:n.startsWith("svg:")?`url("${bn(po(n.slice(4)))}")`:`url("${n.replace(/["\\\n]/g,r=>"\\"+r)}")`},ho=/^\s*(repeating-)?(linear|radial|conic)-gradient\(/,Sn=e=>{const t=String(e??"").trim();return t===""?"none":Ae(t)},mo=(e,t)=>{const n=typeof e=="string"&&ho.test(e),r=En(e)||typeof e=="string"&&/^(id:|https?:|data:|blob:|\.{0,2}\/)/.test(e);return[["--lc-bg-grad",n?Sn(e):"none"],["--lc-bg-img",r?wn(e,t):"none"],["background-color",n||r?"transparent":Ce(e)]]},go=e=>{const t=typeof e=="number"?[e+"px"]:vt(String(e)).map(s=>vn(s)),[n,r=n,o=n,i=r]=t;return[["border-top-left-radius",n??"0px"],["border-top-right-radius",r??"0px"],["border-bottom-right-radius",o??"0px"],["border-bottom-left-radius",i??"0px"]]},bo=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-monospace","ui-sans-serif","ui-serif","inherit"]),yo=e=>{const t=String(e).trim();return t==="monospaced"?"monospace":t.startsWith("var(")||t.includes(",")||/^["']/.test(t)||bo.has(t)?t:`"${t.replace(/"/g,'\\"')}"`},vo=e=>e===!0||e==="true"||typeof e=="number"&&e>.5||e==="1",Eo=e=>t=>e[String(t)]??String(t),$e={width:{css:"width",as:"len"},height:{css:"height",as:"len"},minWidth:{css:"min-width",as:"len"},minHeight:{css:"min-height",as:"len"},maxWidth:{css:"max-width",as:"len"},maxHeight:{css:"max-height",as:"len"},flexBasis:{css:"flex-basis",as:"len"},flexGrow:{css:"flex-grow",as:"num"},flexShrink:{css:"flex-shrink",as:"num"},aspectRatio:{css:"aspect-ratio",as:"num"},gap:{css:["row-gap","column-gap"],as:"len",rank:ee},rowGap:{css:"row-gap",as:"len"},columnGap:{css:"column-gap",as:"len"},...ft("padding",e=>`padding-${e}`),...ft("margin",e=>`margin-${e}`),inset:{css:De,as:"len",rank:ee},top:{css:"top",as:"len"},right:{css:"right",as:"len"},bottom:{css:"bottom",as:"len"},left:{css:"left",as:"len"},start:{css:"inset-inline-start",as:"len",rank:re},end:{css:"inset-inline-end",as:"len",rank:re},flexDirection:{css:"flex-direction",as:"raw"},justifyContent:{css:"justify-content",as:"raw"},alignItems:{css:"align-items",as:"raw"},alignSelf:{css:"align-self",as:"raw"},position:{css:"position",as:"raw"},flexWrap:{css:"flex-wrap",as:"raw"},boxSizing:{css:"box-sizing",as:"raw"},display:{css:"display",as:"raw"},overflow:{rank:ee,to:e=>{const t=e==="scroll"?"auto":String(e);return[["overflow-x",t],["overflow-y",t]]}},scrollDirection:{to:e=>e==="horizontal"?[["overflow-x","auto"],["overflow-y","hidden"],["flex-direction","row"]]:e==="all"?[["overflow-x","auto"],["overflow-y","auto"]]:[["overflow-x","hidden"],["overflow-y","auto"],["flex-direction","column"]],rank:re},...lo(),color:{css:"color"},backgroundColor:{css:"background-color"},borderColor:{css:De.map(e=>`border-${e}-color`),rank:ee},borderTopColor:{css:"border-top-color"},borderRightColor:{css:"border-right-color"},borderBottomColor:{css:"border-bottom-color"},borderLeftColor:{css:"border-left-color"},placeholderColor:{css:"--lc-placeholder"},refreshControlColor:{css:"--lc-refresh"},tintColor:{css:"--lc-tint"},overlayColor:{css:"--lc-overlay"},rippleColor:{none:"a browser has no ripple: the press feedback of a page is `$pressed`"},backgroundImage:{to:(e,t)=>[["--lc-bg-img",wn(e,t)]]},backgroundGradient:{to:e=>[["--lc-bg-grad",Sn(e)]]},backgroundSize:{to:e=>e==="tile"?[["background-size","auto"],["background-repeat","repeat"],["background-position","0 0"]]:[["background-size",e==="fill"?"100% 100%":String(e)],["background-repeat","no-repeat"],["background-position","center"]]},borderRadius:{to:go,rank:ee},borderTopLeftRadius:{css:"border-top-left-radius"},borderTopRightRadius:{css:"border-top-right-radius"},borderBottomRightRadius:{css:"border-bottom-right-radius"},borderBottomLeftRadius:{css:"border-bottom-left-radius"},opacity:{css:"opacity"},transform:{to:e=>[["transform",io(e)]]},transformOrigin:{css:"transform-origin",as:"lens"},pointerEvents:{to:e=>[["pointer-events",e==="none"?"none":"auto"]]},dim:{css:"--lc-dim"},fontSize:{css:"font-size"},fontWeight:{css:"font-weight",as:"raw"},fontStyle:{to:e=>[["font-style",e===2?"italic":e===0?"normal":String(e)]]},fontFamily:{to:e=>[["font-family",yo(e)]]},lineHeight:{to:e=>[["line-height",e==="normal"?"1.2":se(e)]]},letterSpacing:{css:"letter-spacing"},textAlign:{css:"text-align"},textDecoration:{css:"text-decoration-line"},lineClamp:{rank:ee,to:e=>Number(e)>0?[["display","-webkit-box"],["-webkit-box-orient","vertical"],["-webkit-line-clamp",String(Math.round(Number(e)))],["overflow-x","hidden"],["overflow-y","hidden"]]:[["-webkit-line-clamp","none"]]},textOverflow:{css:"text-overflow"},textWrap:{rank:ee,to:e=>e==="nowrap"?[["white-space","pre"],["max-width","none"],["overflow-x","hidden"],["overflow-y","hidden"],["text-overflow","ellipsis"]]:[["white-space","pre-wrap"],["max-width","100%"],["text-wrap",String(e)]]},objectFit:{to:e=>[["object-fit",String(e)],["--lc-fit",e==="fill"?"100% 100%":String(e)]]},placeholder:{attr:!0},type:{attr:!0},enterKey:{attr:!0},autocapitalize:{attr:!0},autocorrect:{attr:!0},maxLength:{attr:!0},keyboardShrink:{attr:!0},keyboardDismiss:{attr:!0},showScrollbar:{to:e=>[["scrollbar-width",vo(e)?"thin":"none"]]},overscrollMode:{to:e=>[["overscroll-behavior",Eo({default:"auto",none:"none",absorb:"contain"})(e)]]},keyboardDismissMode:{attr:!0},snap:{to:e=>e==="none"?[["scroll-snap-type","none"],["--lc-snap","none"]]:[["scroll-snap-type","both mandatory"],["--lc-snap",String(e)]]},sheetDetents:{attr:!0},sheetDetent:{attr:!0},sheetDismissible:{attr:!0},background:{to:mo,rank:ee},border:Se(De,ee),borderTop:Se(["top"],re),borderRight:Se(["right"],re),borderBottom:Se(["bottom"],re),borderLeft:Se(["left"],re),flex:{to:fo,rank:ee}},Ze=e=>qr[e]??e,wo=e=>e in $e,_n=e=>{const t=$e[e];return!!t&&"attr"in t},So={overflow:"overflow-x",pointerEvents:"pointer-events",fontFamily:"font-family",fontStyle:"font-style",lineHeight:"line-height",objectFit:"object-fit",transform:"transform",borderRadius:"border-top-left-radius",borderWidth:"border-top-width",borderColor:"border-top-color",backgroundImage:"--lc-bg-img",backgroundGradient:"--lc-bg-grad",backgroundSize:"background-size",showScrollbar:"scrollbar-width",overscrollMode:"overscroll-behavior",snap:"--lc-snap",lineClamp:"-webkit-line-clamp",textWrap:"text-wrap",borderTopWidth:"border-top-width",borderRightWidth:"border-right-width",borderBottomWidth:"border-bottom-width",borderLeftWidth:"border-left-width",borderHorizontalWidth:"border-left-width",borderVerticalWidth:"border-top-width",borderStartWidth:"border-inline-start-width",borderEndWidth:"border-inline-end-width"},_o=e=>{const t=$e[e];return t&&"css"in t&&typeof t.css=="string"?t.css:So[e]??null},ko={len:se,lens:vn,num:e=>String(e),raw:e=>String(e),color:Ce},To={color:"color",len:"len",enum:"raw",num:"num",str:"raw",layout:"raw"},Bt=e=>{const t=$e[e];return t&&"rank"in t&&t.rank!==void 0?t.rank:ke},et=(e,t,n)=>{const r=[...e].filter(([,i])=>i!=null);r.sort((i,s)=>Bt(i[0])-Bt(s[0]));const o=new Map;for(const[i,s]of r){const l=$e[i];if(!l){n==null||n(i);continue}if("attr"in l||"none"in l)continue;if("to"in l){for(const[E,_]of l.to(s,t))o.set(E,_);continue}const d=ko[l.as??To[ze[i]??"layout"]],c=d(s);if(typeof l.css=="string")o.set(l.css,c);else for(const E of l.css)o.set(E,c)}return o},Vt=e=>[...e].sort((t,n)=>t[0]<n[0]?-1:t[0]>n[0]?1:0).map(([t,n])=>`${t}:${n}`).join(";"),kn=0,Tn=1,Le=2,xe=3,Ln=4,be=65,Ge=1.70158,Me=Ge*1.525,Wt=Ge+1,zt=2*Math.PI/3,Gt=2*Math.PI/4.5,Ne=e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,dt=[["linear",e=>e],["inSine",e=>1-Math.cos(e*Math.PI/2)],["outSine",e=>Math.sin(e*Math.PI/2)],["inOutSine",e=>-(Math.cos(Math.PI*e)-1)/2],["inQuad",e=>e*e],["outQuad",e=>1-(1-e)*(1-e)],["inOutQuad",e=>e<.5?2*e*e:1-(-2*e+2)**2/2],["inCubic",e=>e*e*e],["outCubic",e=>1-(1-e)**3],["inOutCubic",e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2],["inQuart",e=>e**4],["outQuart",e=>1-(1-e)**4],["inOutQuart",e=>e<.5?8*e**4:1-(-2*e+2)**4/2],["inExpo",e=>e===0?0:2**(10*e-10)],["outExpo",e=>e===1?1:1-2**(-10*e)],["inOutExpo",e=>e===0?0:e===1?1:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2],["inCirc",e=>1-Math.sqrt(1-e*e)],["outCirc",e=>Math.sqrt(1-(e-1)**2)],["inOutCirc",e=>e<.5?(1-Math.sqrt(1-(2*e)**2))/2:(Math.sqrt(1-(-2*e+2)**2)+1)/2],["inBack",e=>Wt*e*e*e-Ge*e*e],["outBack",e=>1+Wt*(e-1)**3+Ge*(e-1)**2],["inOutBack",e=>e<.5?(2*e)**2*((Me+1)*2*e-Me)/2:((2*e-2)**2*((Me+1)*(e*2-2)+Me)+2)/2],["inElastic",e=>e===0?0:e===1?1:-(2**(10*e-10))*Math.sin((e*10-10.75)*zt)],["outElastic",e=>e===0?0:e===1?1:2**(-10*e)*Math.sin((e*10-.75)*zt)+1],["inOutElastic",e=>e===0?0:e===1?1:e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*Gt))/2:2**(-20*e+10)*Math.sin((20*e-11.125)*Gt)/2+1],["inBounce",e=>1-Ne(1-e)],["outBounce",Ne],["inOutBounce",e=>e<.5?(1-Ne(1-2*e))/2:(1+Ne(2*e-1))/2],["smoothstep",e=>e*e*(3-2*e)]],Lo={in:"inQuad",out:"outQuad",inOut:"inOutQuad",easeIn:"inQuad",easeOut:"outQuad",easeInOut:"inOutQuad","ease-in":"inQuad","ease-out":"outQuad","ease-in-out":"inOutQuad"},xo=e=>{const t=Lo[e]??e;for(let n=0;n<dt.length;n++)if(dt[n][0]===t)return n;return-1},Ro=[.25,.1,.25,1],Pe={kind:kn,p:[0,0,0,0]},Ao=e=>{const t=new Float32Array(be);for(let n=0;n<be;n++)t[n]=e(n/(be-1));return t[0]=0,t[be-1]=1,t},Co=e=>{if(e===void 0)return Pe;if(typeof e=="function")return{kind:Ln,p:[0,0,0,0],table:Ao(e)};if(Array.isArray(e)){const[o,i,s,l]=e;return{kind:Le,p:[o,i,s,l]}}const t=e.trim();if(t==="linear")return Pe;if(t==="ease")return{kind:Le,p:Ro};if(t==="steps")return{kind:xe,p:[1,0,0,0]};let n=/^steps\(\s*(\d+)\s*(?:,\s*(start|end|jump-start|jump-end)\s*)?\)$/.exec(t);if(n)return{kind:xe,p:[Math.max(1,parseInt(n[1],10)),n[2]==="start"||n[2]==="jump-start"?1:0,0,0]};if(n=/^cubic-bezier\(\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*\)$/.exec(t),n)return{kind:Le,p:[parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]),parseFloat(n[4])]};const r=xo(t);return r===0?Pe:r>0?{kind:Tn,p:[r,0,0,0]}:(console.warn(`[tween] unknown easing "${t}" — using linear`),Pe)},$o=(e,t,n,r,o)=>{const i=1-3*r+3*t,s=3*r-6*t,l=3*t,d=1-3*o+3*n,c=3*o-6*n,E=3*n;let _=e;for(let A=0;A<8;A++){const g=((i*_+s)*_+l)*_-e,p=(3*i*_+2*s)*_+l;if(Math.abs(g)<1e-6||Math.abs(p)<1e-6)break;_-=g/p}return _=Math.min(1,Math.max(0,_)),((d*_+c)*_+E)*_},Oo=(e,t)=>{if(t<=0)return e.kind===xe&&e.p[1]===1?1/e.p[0]:0;if(t>=1)return 1;switch(e.kind){case Tn:return dt[e.p[0]][1](t);case Le:return $o(t,e.p[0],e.p[1],e.p[2],e.p[3]);case xe:{const n=e.p[0];return e.p[1]===1?Math.min(1,Math.ceil(t*n)/n):Math.floor(t*n)/n}case Ln:{const n=e.table,r=t*(be-1),o=Math.floor(r),i=n[o],s=n[Math.min(o+1,be-1)];return i+(s-i)*(r-o)}default:return t}},jt=24,Ht=e=>String(Math.round(e*1e4)/1e4),Uo="cubic-bezier(0.3333, 0, 0.6667, 1)",Mo=e=>{switch(e.kind){case kn:return"linear";case Le:return`cubic-bezier(${e.p.map(Ht).join(", ")})`;case xe:return`steps(${e.p[0]}, ${e.p[1]===1?"jump-start":"jump-end"})`}const t=[];for(let n=0;n<=jt;n++)t.push(Ht(Oo(e,n/jt)));return`linear(${t.join(", ")})`},No=e=>e===void 0||e==="smoothstep"?Uo:Mo(Co(e)),xn=["lc-base","lc-bag","lc-own","lc-orient","lc-class","lc-hover","lc-press","lc-focus"],Po=["--lc-bg-grad","--lc-bg-img","--lc-tint","--lc-overlay","--lc-refresh","--lc-fit","--lc-src","--lc-src-tint","--lc-iw","--lc-ih","--lc-ir","--lc-crop-size","--lc-crop-pos"],Rn="lc-app",Fo=`
2
+ ${e.stack}`:String(e);try{return JSON.stringify(e)}catch{return String(e)}},nr=(e,t)=>{const n=s=>{fetch(`${e}/log`,{method:"POST",body:JSON.stringify(s),headers:{"content-type":"application/json"},keepalive:!0}).catch(()=>{})};let r=-1;const o=async()=>{try{const{v:s}=await(await fetch(`${e}/version`,{cache:"no-store"})).json();typeof s=="number"&&t(s)}catch{}setTimeout(o,2500)};setTimeout(o,2500);const i=()=>{let s;try{s=new WebSocket(e.replace(/^http/,"ws")+"/ws")}catch{return}s.onopen=()=>s.send(JSON.stringify({type:"hello",v:r})),s.onmessage=l=>{let d={};try{d=JSON.parse(String(l.data))}catch{return}d.type==="reload"&&typeof d.v=="number"&&t(d.v)},s.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:s=>`${e}/bundle.js?t=web&v=${s}`,versionOf(s,l){const d=Number(s.headers.get("x-lecodes-v"));return s.headers.has("x-lecodes-v")&&Number.isFinite(d)?d:l},ran(s){r=s},log:(s,l)=>n({type:"log",level:s,text:l.map(tr).join(" ")}),error:s=>n({type:"error",text:s})}},rr=(e,t)=>{try{const n=new URL(e,t);return n.origin===new URL(t).origin&&(n.protocol==="http:"||n.protocol==="https:")?n.href:null}catch{return null}},mn=(e,t)=>{const n=[];for(const r of t){const o=r.halves[e];for(const i of typeof o=="string"?[o]:Array.isArray(o)?o:[]){if(typeof i!="string"||!i)continue;const s=new URL(i,r.url).href;n.includes(s)||n.push(s)}}return n},or="modulepreload",sr=function(e,t){return new URL(e,t).href},Tt={},fe=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let s=function(E){return Promise.all(E.map(_=>Promise.resolve(_).then(A=>({status:"fulfilled",value:A}),A=>({status:"rejected",reason:A}))))};const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),c=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=s(n.map(E=>{if(E=sr(E,r),E in Tt)return;Tt[E]=!0;const _=E.endsWith(".css"),A=_?'[rel="stylesheet"]':"";if(!!r)for(let b=l.length-1;b>=0;b--){const y=l[b];if(y.href===E&&(!_||y.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${E}"]${A}`))return;const p=document.createElement("link");if(p.rel=_?"stylesheet":or,_||(p.as="script"),p.crossOrigin="",p.href=E,c&&p.setAttribute("nonce",c),document.head.appendChild(p),_)return new Promise((b,y)=>{p.addEventListener("load",b),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${E}`)))})}))}function i(s){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=s,window.dispatchEvent(l),!l.defaultPrevented)throw s}return o.then(s=>{for(const l of s||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Lt="2.4.10",Xe=e=>{const t=e==null?void 0:e.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},ir=(e,t)=>Xe(e)!==null&&Xe(e)===Xe(t),ar=(e,t="woff2")=>{const n=/^\/\/ fonts: (.+)$/m.exec(e);if(!n)return[];const r=[];for(const o of n[1].split(";")){const i=o.indexOf("=");if(i===-1)continue;const s=/^(.+)@(\d+)(i?)$/.exec(o.slice(0,i));s&&r.push({family:s[1],weight:parseInt(s[2],10),italic:s[3]==="i",url:o.slice(i+1).replace("{fmt}",t)})}return r},lr=async(e,t,n=2e3)=>{const r=t??(typeof document>"u"?void 0:document);if(!(r!=null&&r.fonts)||e.length===0)return;const o=[];for(const i of e)try{const s=new FontFace(i.family,`url("${i.url}")`,{weight:String(i.weight),style:i.italic?"italic":"normal"});r.fonts.add(s),o.push(s.load().catch(()=>{}))}catch{}await Promise.race([Promise.all(o),new Promise(i=>setTimeout(i,n))])},cr=e=>{var d,c,E,_;const t=e.slice(0,2e3),n=new Set,r=t.match(/\/\/ preload: (.+)/);if(r)for(const A of r[1].split(";"))n.add(A);const o=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((d=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:d[1])??null,s=((E=(c=t.match(/^\/\/ name: (.+)$/m))==null?void 0:c[1])==null?void 0:E.trim())??null,l=new Set((((_=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:_[1])??"").split(";").map(A=>A.trim()).filter(Boolean));return{sdk:i,name:s,preloads:n,gl:o,is2d:t.includes("// 2d: enable"),plugins:l,bootFonts:ar(t)}},ur=1,fr=2,dr=3,pr=4,hr=5,mr=6,xt=7,gr=8,Rt=9,br=10,yr=11,vr=12,Er=13,wr=14,Sr=15,_r=16,At=17,kr=18,Tr=19,Ue=20,xi=21,Ri=22,Ai=23,Ci=24,$i=25,Lr=26,xr=27,Rr=28,Ar=29,Ct=30,$t=31,Cr=32,$r=33,Ot=34,Ut=35,Mt=36,Ie=1,Or=2,Ur=4,he=8,Mr=16,Je=32,Nr=64,Qe=128,Pr=256,Fr=512,Ir=1024,Dr=2048,Br=4096,Nt=8192,Oi=16384,Vr=32768,Wr=1<<18,zr=255,Pt=256,Ft=512,Gr=1024,te=0,jr=1,Hr=2,Kr=3,We=4,ve=255,gn=e=>{const t=e.clientWidth;if(!t)return 1;const n=e.getBoundingClientRect().width;return n>0?n/t:1},It={text:{type:"text"},password:{type:"password"},search:{type:"search"},tel:{type:"tel"},email:{type:"email"},url:{type:"url"},number:{type:"text",mode:"numeric"},decimal:{type:"text",mode:"decimal"},date:{type:"date"},time:{type:"time"}},Dt=(e,t)=>e==null?t:e===!0||e==="true"||e==="1"||typeof e=="number"&&e>.5,oe=(e,t,n)=>{n===null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)},Yr=(e,t)=>{if(e.type!=="input"&&e.type!=="textarea")return;const n=e.el,r=t("placeholder");if(oe(n,"placeholder",r==null?null:String(r)),e.type==="input"){const l=It[String(t("type")??"text")]??It.text,d=n;d.type!==l.type&&(d.type=l.type),oe(n,"inputmode",l.mode??null);const c=t("enterKey");oe(n,"enterkeyhint",c==null?null:String(c))}const o=t("autocapitalize");oe(n,"autocapitalize",o==null?null:String(o));const i=t("autocorrect");i==null?(oe(n,"autocorrect",null),oe(n,"spellcheck",null)):(oe(n,"autocorrect",Dt(i,!0)?"on":"off"),oe(n,"spellcheck",Dt(i,!0)?"true":"false"));const s=Number(t("maxLength")??0);oe(n,"maxlength",s>0?String(Math.round(s)):null)},ze={width:"layout",height:"layout",minWidth:"layout",minHeight:"layout",maxWidth:"layout",maxHeight:"layout",flexBasis:"layout",flexGrow:"layout",flexShrink:"layout",aspectRatio:"layout",gap:"layout",rowGap:"layout",columnGap:"layout",padding:"layout",paddingTop:"layout",paddingRight:"layout",paddingBottom:"layout",paddingLeft:"layout",paddingHorizontal:"layout",paddingVertical:"layout",paddingStart:"layout",paddingEnd:"layout",margin:"layout",marginTop:"layout",marginRight:"layout",marginBottom:"layout",marginLeft:"layout",marginHorizontal:"layout",marginVertical:"layout",marginStart:"layout",marginEnd:"layout",left:"layout",right:"layout",top:"layout",bottom:"layout",start:"layout",end:"layout",inset:"layout",flexDirection:"enum",justifyContent:"enum",alignItems:"enum",alignSelf:"enum",position:"enum",flexWrap:"enum",boxSizing:"enum",display:"enum",overflow:"enum",scrollDirection:"enum",borderWidth:"len",borderTopWidth:"len",borderRightWidth:"len",borderBottomWidth:"len",borderLeftWidth:"len",borderHorizontalWidth:"len",borderVerticalWidth:"len",borderStartWidth:"len",borderEndWidth:"len",color:"color",backgroundColor:"color",borderColor:"color",borderTopColor:"color",borderRightColor:"color",borderBottomColor:"color",borderLeftColor:"color",placeholderColor:"color",refreshControlColor:"color",tintColor:"color",rippleColor:"color",overlayColor:"color",backgroundImage:"str",backgroundSize:"enum",backgroundGradient:"str",borderRadius:"len",borderTopLeftRadius:"len",borderTopRightRadius:"len",borderBottomRightRadius:"len",borderBottomLeftRadius:"len",opacity:"num",transform:"str",transformOrigin:"str",pointerEvents:"enum",fontSize:"len",fontWeight:"num",fontStyle:"enum",fontFamily:"str",lineHeight:"len",letterSpacing:"len",textAlign:"enum",textDecoration:"enum",lineClamp:"num",textOverflow:"enum",textWrap:"enum",objectFit:"enum",placeholder:"str",type:"enum",enterKey:"enum",autocapitalize:"enum",autocorrect:"num",maxLength:"num",keyboardShrink:"num",keyboardDismiss:"num",showScrollbar:"num",overscrollMode:"enum",keyboardDismissMode:"enum",snap:"enum",sheetDetents:"str",sheetDetent:"num",sheetDismissible:"num",dim:"num"},qr={p:"padding",pt:"paddingTop",pr:"paddingRight",pb:"paddingBottom",pl:"paddingLeft",px:"paddingHorizontal",py:"paddingVertical",m:"margin",mt:"marginTop",mr:"marginRight",mb:"marginBottom",ml:"marginLeft",mx:"marginHorizontal",my:"marginVertical",bgColor:"backgroundColor",bgImage:"backgroundImage",bgSize:"backgroundSize",bgGradient:"backgroundGradient"},Xr=["placeholderColor","refreshControlColor","tintColor","rippleColor","overlayColor","backgroundGradient"],Jr={display:"flex",overflow:"visible",scrollDirection:"vertical",borderWidth:0,borderTopWidth:0,borderRightWidth:0,borderBottomWidth:0,borderLeftWidth:0,borderHorizontalWidth:0,borderVerticalWidth:0,borderStartWidth:0,borderEndWidth:0,backgroundColor:0,borderColor:0,borderTopColor:0,borderRightColor:0,borderBottomColor:0,borderLeftColor:0,backgroundImage:"",backgroundSize:"cover",borderRadius:0,borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,opacity:1,transform:"identity",transformOrigin:"50% 50%",pointerEvents:"all",fontSize:14,fontWeight:400,fontStyle:"normal",lineHeight:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none",lineClamp:0,textOverflow:"ellipsis",textWrap:"wrap",objectFit:"cover",placeholder:"",type:"text",enterKey:"done",autocapitalize:"sentences",autocorrect:1,maxLength:0,keyboardShrink:1,keyboardDismiss:1,showScrollbar:1,overscrollMode:"default",keyboardDismissMode:"interactive",snap:"none",sheetDetents:"",sheetDetent:0,sheetDismissible:1,dim:0},Qr=["duration","delay","layer","commit","loop","loopMode","name"];function bn(e){let t=e.trim();/\sxmlns\s*=/.test(t)||(t=t.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"'));const n=new TextEncoder().encode(t);let r="";for(const o of n)r+=String.fromCharCode(o);return`data:image/svg+xml;base64,${btoa(r)}`}function Zr(e){const t=e.match(/viewBox\s*=\s*["']([^"']+)["']/);return t?t[1]:null}const eo=/\b(?:calc|min|max|clamp)\(/,to=e=>{if(!eo.test(e))return e;let t="";for(let n=0;n<e.length;n++){if(e.startsWith("var(",n)){let o=0;const i=n;for(;n<e.length;n++)if(e[n]==="(")o++;else if(e[n]===")"&&--o===0)break;t+=e.slice(i,Math.min(n+1,e.length));continue}const r=e[n];if(r==="+"||r==="-"){const o=t[t.length-1]??"";if(!(r==="-"&&(o==="e"&&"btlr".includes(e[n+1]??"")||e.slice(Math.max(0,n-7),n)==="comfort"))&&/[\w%.)]/.test(o)){for(t=t.trimEnd()+" "+r+" ";e[n+1]===" ";)n++;continue}}t+=r}return t.replace(/\d*\.\d+|\d+/g,(n,r,o)=>{const i=o.slice(0,r).trimEnd(),s=o.slice(r+n.length).trimStart();return/[\w.%]$/.test(i)||/^[\w.%]/.test(s)||/[*/]$/.test(i)||/^[*/]/.test(s)?n:n+"px"})},no={top:"12px",bottom:"4px",left:"16px",right:"16px"},yn=e=>`max(var(--safe-${e}, 0px), calc(var(--safe-${e}-bar, 0px) + var(--comfort-${e}, ${no[e]})))`,ro={vw:"cqw",vh:"cqh",vmin:"cqmin",vmax:"cqmax"},Ae=e=>to(e).replace(new RegExp("(?<![-\\w])comfort-(top|bottom|left|right)\\b","g"),(t,n)=>yn(n)).replace(new RegExp("(?<![-\\w])safe-(top|bottom|left|right)\\b","g"),(t,n)=>`var(--safe-${n}, 0px)`).replace(/(\d)(vmin|vmax|vw|vh)\b/g,(t,n,r)=>n+ro[r]),yt=/^-?\d*\.?\d+$/,se=e=>{if(typeof e=="number")return e+"px";const t=String(e).trim();return yt.test(t)?t+"px":Ae(t)},Ce=e=>{if(typeof e=="number")return"#"+(e>>>0).toString(16).padStart(e<=16777215?6:8,"0");const t=String(e);return t==="clear"?"transparent":t},oo=/^(rotate|skew)/,so=/^translate/,io=e=>{const t=String(e).trim();return t===""||t==="identity"?"none":t.replace(/([a-zA-Z0-9]+)\s*\(([^)]*)\)/g,(n,r,o)=>{const i=so.test(r)?"px":oo.test(r)?"deg":null;return i===null?n:`${r}(${o.split(",").map(s=>{const l=s.trim();return yt.test(l)?l+i:Ae(l)}).join(", ")})`})},vn=e=>typeof e=="number"?e+"px":String(e).trim().split(/\s+/).map(t=>yt.test(t)?t+"px":Ae(t)).join(" "),ee=0,re=1,ke=2,De=["top","right","bottom","left"],ao=(e,t)=>e==="safe-all"?`var(--safe-${t}, 0px)`:e==="comfort-all"||e==="comfort-x"||e==="comfort-y"?yn(t):se(e),ft=(e,t)=>{const n=(o,i)=>({rank:i,to:s=>o.map(l=>[t(l),ao(s,l)])}),r=o=>({rank:re,to:i=>[[t(o),se(i)]]});return{[e]:n(De,ee),[`${e}Horizontal`]:n(["left","right"],re),[`${e}Vertical`]:n(["top","bottom"],re),[`${e}Start`]:r("inline-start"),[`${e}End`]:r("inline-end"),[`${e}Top`]:n(["top"],ke),[`${e}Right`]:n(["right"],ke),[`${e}Bottom`]:n(["bottom"],ke),[`${e}Left`]:n(["left"],ke)}},lo=()=>{const e=ft("border",n=>`border-${n}-width`),t={};for(const n of Object.keys(e))t[`${n}Width`]=e[n];return t},vt=e=>{const t=[];let n=0,r="";for(const o of e.trim()){if(o==="("&&n++,o===")"&&n--,/\s/.test(o)&&n===0){r&&t.push(r),r="";continue}r+=o}return r&&t.push(r),t},co=new Set(["none","solid","dashed","dotted","double","hidden"]),uo=/^-?\d*\.?\d+([a-z%]*)$|^(calc|min|max|clamp)\(/,Se=(e,t)=>({rank:t,to:n=>{let r=null,o=null,i=null;if(typeof n=="number")r=n+"px";else for(const l of vt(String(n)))co.has(l)?i=l:uo.test(l)?r=se(l):o=Ce(l);const s=[];for(const l of e)s.push([`border-${l}-width`,r??(o?"1px":"0px")]),s.push([`border-${l}-color`,o??"transparent"]),i&&s.push([`border-${l}-style`,i]);return s}}),fo=e=>{const t=String(e).trim(),n=(i,s,l)=>[["flex-grow",i],["flex-shrink",s],["flex-basis",l]];if(t==="none")return n("0","0","auto");if(t==="auto")return n("1","1","auto");if(t==="initial")return n("0","1","auto");const r=vt(t),o=i=>i!==void 0&&/^-?\d*\.?\d+$/.test(i);return o(r[0])?r.length===1?n(r[0],"1","0%"):o(r[1])?n(r[0],r[1],r[2]!==void 0?se(r[2]):"0%"):n(r[0],"1",se(r[1])):n("1","1",se(r[0]??"auto"))},En=e=>{var t;return typeof e=="object"&&e!==null&&"_h"in e&&typeof((t=e._h)==null?void 0:t.id)=="number"},po=e=>e.replace(/<svg\b[^>]*>/,t=>t.replace(/\spreserveAspectRatio\s*=\s*("[^"]*"|'[^']*')/,"").replace(/^<svg\b/,'<svg preserveAspectRatio="none"')),wn=(e,t)=>{if(En(e))return`url("${t.bufferUrl(e._h.id)}")`;const n=String(e??"");return n===""?"none":n.startsWith("id:")?`url("${t.bufferUrl(Number(n.slice(3)))}")`:n.startsWith("svg:")?`url("${bn(po(n.slice(4)))}")`:`url("${n.replace(/["\\\n]/g,r=>"\\"+r)}")`},ho=/^\s*(repeating-)?(linear|radial|conic)-gradient\(/,Sn=e=>{const t=String(e??"").trim();return t===""?"none":Ae(t)},mo=(e,t)=>{const n=typeof e=="string"&&ho.test(e),r=En(e)||typeof e=="string"&&/^(id:|https?:|data:|blob:|\.{0,2}\/)/.test(e);return[["--lc-bg-grad",n?Sn(e):"none"],["--lc-bg-img",r?wn(e,t):"none"],["background-color",n||r?"transparent":Ce(e)]]},go=e=>{const t=typeof e=="number"?[e+"px"]:vt(String(e)).map(s=>vn(s)),[n,r=n,o=n,i=r]=t;return[["border-top-left-radius",n??"0px"],["border-top-right-radius",r??"0px"],["border-bottom-right-radius",o??"0px"],["border-bottom-left-radius",i??"0px"]]},bo=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-monospace","ui-sans-serif","ui-serif","inherit"]),yo=e=>{const t=String(e).trim();return t==="monospaced"?"monospace":t.startsWith("var(")||t.includes(",")||/^["']/.test(t)||bo.has(t)?t:`"${t.replace(/"/g,'\\"')}"`},vo=e=>e===!0||e==="true"||typeof e=="number"&&e>.5||e==="1",Eo=e=>t=>e[String(t)]??String(t),$e={width:{css:"width",as:"len"},height:{css:"height",as:"len"},minWidth:{css:"min-width",as:"len"},minHeight:{css:"min-height",as:"len"},maxWidth:{css:"max-width",as:"len"},maxHeight:{css:"max-height",as:"len"},flexBasis:{css:"flex-basis",as:"len"},flexGrow:{css:"flex-grow",as:"num"},flexShrink:{css:"flex-shrink",as:"num"},aspectRatio:{css:"aspect-ratio",as:"num"},gap:{css:["row-gap","column-gap"],as:"len",rank:ee},rowGap:{css:"row-gap",as:"len"},columnGap:{css:"column-gap",as:"len"},...ft("padding",e=>`padding-${e}`),...ft("margin",e=>`margin-${e}`),inset:{css:De,as:"len",rank:ee},top:{css:"top",as:"len"},right:{css:"right",as:"len"},bottom:{css:"bottom",as:"len"},left:{css:"left",as:"len"},start:{css:"inset-inline-start",as:"len",rank:re},end:{css:"inset-inline-end",as:"len",rank:re},flexDirection:{css:"flex-direction",as:"raw"},justifyContent:{css:"justify-content",as:"raw"},alignItems:{css:"align-items",as:"raw"},alignSelf:{css:"align-self",as:"raw"},position:{css:"position",as:"raw"},flexWrap:{css:"flex-wrap",as:"raw"},boxSizing:{css:"box-sizing",as:"raw"},display:{css:"display",as:"raw"},overflow:{rank:ee,to:e=>{const t=e==="scroll"?"auto":String(e);return[["overflow-x",t],["overflow-y",t]]}},scrollDirection:{to:e=>e==="horizontal"?[["overflow-x","auto"],["overflow-y","hidden"],["flex-direction","row"]]:e==="all"?[["overflow-x","auto"],["overflow-y","auto"]]:[["overflow-x","hidden"],["overflow-y","auto"],["flex-direction","column"]],rank:re},...lo(),color:{css:"color"},backgroundColor:{css:"background-color"},borderColor:{css:De.map(e=>`border-${e}-color`),rank:ee},borderTopColor:{css:"border-top-color"},borderRightColor:{css:"border-right-color"},borderBottomColor:{css:"border-bottom-color"},borderLeftColor:{css:"border-left-color"},placeholderColor:{css:"--lc-placeholder"},refreshControlColor:{css:"--lc-refresh"},tintColor:{css:"--lc-tint"},overlayColor:{css:"--lc-overlay"},rippleColor:{none:"a browser has no ripple: the press feedback of a page is `$pressed`"},backgroundImage:{to:(e,t)=>[["--lc-bg-img",wn(e,t)]]},backgroundGradient:{to:e=>[["--lc-bg-grad",Sn(e)]]},backgroundSize:{to:e=>e==="tile"?[["background-size","auto"],["background-repeat","repeat"],["background-position","0 0"]]:[["background-size",e==="fill"?"100% 100%":String(e)],["background-repeat","no-repeat"],["background-position","center"]]},borderRadius:{to:go,rank:ee},borderTopLeftRadius:{css:"border-top-left-radius"},borderTopRightRadius:{css:"border-top-right-radius"},borderBottomRightRadius:{css:"border-bottom-right-radius"},borderBottomLeftRadius:{css:"border-bottom-left-radius"},opacity:{css:"opacity"},transform:{to:e=>[["transform",io(e)]]},transformOrigin:{css:"transform-origin",as:"lens"},pointerEvents:{to:e=>[["pointer-events",e==="none"?"none":"auto"]]},dim:{css:"--lc-dim"},fontSize:{css:"font-size"},fontWeight:{css:"font-weight",as:"raw"},fontStyle:{to:e=>[["font-style",e===2?"italic":e===0?"normal":String(e)]]},fontFamily:{to:e=>[["font-family",yo(e)]]},lineHeight:{to:e=>[["line-height",e==="normal"?"1.2":se(e)]]},letterSpacing:{css:"letter-spacing"},textAlign:{css:"text-align"},textDecoration:{css:"text-decoration-line"},lineClamp:{rank:ee,to:e=>Number(e)>0?[["display","-webkit-box"],["-webkit-box-orient","vertical"],["-webkit-line-clamp",String(Math.round(Number(e)))],["overflow-x","hidden"],["overflow-y","hidden"]]:[["-webkit-line-clamp","none"]]},textOverflow:{css:"text-overflow"},textWrap:{rank:ee,to:e=>e==="nowrap"?[["white-space","pre"],["max-width","none"],["overflow-x","hidden"],["overflow-y","hidden"],["text-overflow","ellipsis"]]:[["white-space","pre-wrap"],["max-width","100%"],["text-wrap",String(e)]]},objectFit:{to:e=>[["object-fit",String(e)],["--lc-fit",e==="fill"?"100% 100%":String(e)]]},placeholder:{attr:!0},type:{attr:!0},enterKey:{attr:!0},autocapitalize:{attr:!0},autocorrect:{attr:!0},maxLength:{attr:!0},keyboardShrink:{attr:!0},keyboardDismiss:{attr:!0},showScrollbar:{to:e=>[["scrollbar-width",vo(e)?"thin":"none"]]},overscrollMode:{to:e=>[["overscroll-behavior",Eo({default:"auto",none:"none",absorb:"contain"})(e)]]},keyboardDismissMode:{attr:!0},snap:{to:e=>e==="none"?[["scroll-snap-type","none"],["--lc-snap","none"]]:[["scroll-snap-type","both mandatory"],["--lc-snap",String(e)]]},sheetDetents:{attr:!0},sheetDetent:{attr:!0},sheetDismissible:{attr:!0},background:{to:mo,rank:ee},border:Se(De,ee),borderTop:Se(["top"],re),borderRight:Se(["right"],re),borderBottom:Se(["bottom"],re),borderLeft:Se(["left"],re),flex:{to:fo,rank:ee}},Ze=e=>qr[e]??e,wo=e=>e in $e,_n=e=>{const t=$e[e];return!!t&&"attr"in t},So={overflow:"overflow-x",pointerEvents:"pointer-events",fontFamily:"font-family",fontStyle:"font-style",lineHeight:"line-height",objectFit:"object-fit",transform:"transform",borderRadius:"border-top-left-radius",borderWidth:"border-top-width",borderColor:"border-top-color",backgroundImage:"--lc-bg-img",backgroundGradient:"--lc-bg-grad",backgroundSize:"background-size",showScrollbar:"scrollbar-width",overscrollMode:"overscroll-behavior",snap:"--lc-snap",lineClamp:"-webkit-line-clamp",textWrap:"text-wrap",borderTopWidth:"border-top-width",borderRightWidth:"border-right-width",borderBottomWidth:"border-bottom-width",borderLeftWidth:"border-left-width",borderHorizontalWidth:"border-left-width",borderVerticalWidth:"border-top-width",borderStartWidth:"border-inline-start-width",borderEndWidth:"border-inline-end-width"},_o=e=>{const t=$e[e];return t&&"css"in t&&typeof t.css=="string"?t.css:So[e]??null},ko={len:se,lens:vn,num:e=>String(e),raw:e=>String(e),color:Ce},To={color:"color",len:"len",enum:"raw",num:"num",str:"raw",layout:"raw"},Bt=e=>{const t=$e[e];return t&&"rank"in t&&t.rank!==void 0?t.rank:ke},et=(e,t,n)=>{const r=[...e].filter(([,i])=>i!=null);r.sort((i,s)=>Bt(i[0])-Bt(s[0]));const o=new Map;for(const[i,s]of r){const l=$e[i];if(!l){n==null||n(i);continue}if("attr"in l||"none"in l)continue;if("to"in l){for(const[E,_]of l.to(s,t))o.set(E,_);continue}const d=ko[l.as??To[ze[i]??"layout"]],c=d(s);if(typeof l.css=="string")o.set(l.css,c);else for(const E of l.css)o.set(E,c)}return o},Vt=e=>[...e].sort((t,n)=>t[0]<n[0]?-1:t[0]>n[0]?1:0).map(([t,n])=>`${t}:${n}`).join(";"),kn=0,Tn=1,Le=2,xe=3,Ln=4,be=65,Ge=1.70158,Me=Ge*1.525,Wt=Ge+1,zt=2*Math.PI/3,Gt=2*Math.PI/4.5,Ne=e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,dt=[["linear",e=>e],["inSine",e=>1-Math.cos(e*Math.PI/2)],["outSine",e=>Math.sin(e*Math.PI/2)],["inOutSine",e=>-(Math.cos(Math.PI*e)-1)/2],["inQuad",e=>e*e],["outQuad",e=>1-(1-e)*(1-e)],["inOutQuad",e=>e<.5?2*e*e:1-(-2*e+2)**2/2],["inCubic",e=>e*e*e],["outCubic",e=>1-(1-e)**3],["inOutCubic",e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2],["inQuart",e=>e**4],["outQuart",e=>1-(1-e)**4],["inOutQuart",e=>e<.5?8*e**4:1-(-2*e+2)**4/2],["inExpo",e=>e===0?0:2**(10*e-10)],["outExpo",e=>e===1?1:1-2**(-10*e)],["inOutExpo",e=>e===0?0:e===1?1:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2],["inCirc",e=>1-Math.sqrt(1-e*e)],["outCirc",e=>Math.sqrt(1-(e-1)**2)],["inOutCirc",e=>e<.5?(1-Math.sqrt(1-(2*e)**2))/2:(Math.sqrt(1-(-2*e+2)**2)+1)/2],["inBack",e=>Wt*e*e*e-Ge*e*e],["outBack",e=>1+Wt*(e-1)**3+Ge*(e-1)**2],["inOutBack",e=>e<.5?(2*e)**2*((Me+1)*2*e-Me)/2:((2*e-2)**2*((Me+1)*(e*2-2)+Me)+2)/2],["inElastic",e=>e===0?0:e===1?1:-(2**(10*e-10))*Math.sin((e*10-10.75)*zt)],["outElastic",e=>e===0?0:e===1?1:2**(-10*e)*Math.sin((e*10-.75)*zt)+1],["inOutElastic",e=>e===0?0:e===1?1:e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*Gt))/2:2**(-20*e+10)*Math.sin((20*e-11.125)*Gt)/2+1],["inBounce",e=>1-Ne(1-e)],["outBounce",Ne],["inOutBounce",e=>e<.5?(1-Ne(1-2*e))/2:(1+Ne(2*e-1))/2],["smoothstep",e=>e*e*(3-2*e)]],Lo={in:"inQuad",out:"outQuad",inOut:"inOutQuad",easeIn:"inQuad",easeOut:"outQuad",easeInOut:"inOutQuad","ease-in":"inQuad","ease-out":"outQuad","ease-in-out":"inOutQuad"},xo=e=>{const t=Lo[e]??e;for(let n=0;n<dt.length;n++)if(dt[n][0]===t)return n;return-1},Ro=[.25,.1,.25,1],Pe={kind:kn,p:[0,0,0,0]},Ao=e=>{const t=new Float32Array(be);for(let n=0;n<be;n++)t[n]=e(n/(be-1));return t[0]=0,t[be-1]=1,t},Co=e=>{if(e===void 0)return Pe;if(typeof e=="function")return{kind:Ln,p:[0,0,0,0],table:Ao(e)};if(Array.isArray(e)){const[o,i,s,l]=e;return{kind:Le,p:[o,i,s,l]}}const t=e.trim();if(t==="linear")return Pe;if(t==="ease")return{kind:Le,p:Ro};if(t==="steps")return{kind:xe,p:[1,0,0,0]};let n=/^steps\(\s*(\d+)\s*(?:,\s*(start|end|jump-start|jump-end)\s*)?\)$/.exec(t);if(n)return{kind:xe,p:[Math.max(1,parseInt(n[1],10)),n[2]==="start"||n[2]==="jump-start"?1:0,0,0]};if(n=/^cubic-bezier\(\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*\)$/.exec(t),n)return{kind:Le,p:[parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]),parseFloat(n[4])]};const r=xo(t);return r===0?Pe:r>0?{kind:Tn,p:[r,0,0,0]}:(console.warn(`[tween] unknown easing "${t}" — using linear`),Pe)},$o=(e,t,n,r,o)=>{const i=1-3*r+3*t,s=3*r-6*t,l=3*t,d=1-3*o+3*n,c=3*o-6*n,E=3*n;let _=e;for(let A=0;A<8;A++){const g=((i*_+s)*_+l)*_-e,p=(3*i*_+2*s)*_+l;if(Math.abs(g)<1e-6||Math.abs(p)<1e-6)break;_-=g/p}return _=Math.min(1,Math.max(0,_)),((d*_+c)*_+E)*_},Oo=(e,t)=>{if(t<=0)return e.kind===xe&&e.p[1]===1?1/e.p[0]:0;if(t>=1)return 1;switch(e.kind){case Tn:return dt[e.p[0]][1](t);case Le:return $o(t,e.p[0],e.p[1],e.p[2],e.p[3]);case xe:{const n=e.p[0];return e.p[1]===1?Math.min(1,Math.ceil(t*n)/n):Math.floor(t*n)/n}case Ln:{const n=e.table,r=t*(be-1),o=Math.floor(r),i=n[o],s=n[Math.min(o+1,be-1)];return i+(s-i)*(r-o)}default:return t}},jt=24,Ht=e=>String(Math.round(e*1e4)/1e4),Uo="cubic-bezier(0.3333, 0, 0.6667, 1)",Mo=e=>{switch(e.kind){case kn:return"linear";case Le:return`cubic-bezier(${e.p.map(Ht).join(", ")})`;case xe:return`steps(${e.p[0]}, ${e.p[1]===1?"jump-start":"jump-end"})`}const t=[];for(let n=0;n<=jt;n++)t.push(Ht(Oo(e,n/jt)));return`linear(${t.join(", ")})`},No=e=>e===void 0||e==="smoothstep"?Uo:Mo(Co(e)),xn=["lc-base","lc-bag","lc-own","lc-orient","lc-class","lc-hover","lc-press","lc-focus"],Po=["--lc-bg-grad","--lc-bg-img","--lc-tint","--lc-overlay","--lc-refresh","--lc-fit","--lc-src","--lc-src-tint","--lc-iw","--lc-ih","--lc-ir","--lc-crop-size","--lc-crop-pos"],Rn="lc-app",Fo=`
3
3
  @layer ${xn.join(", ")};
4
4
 
5
5
  @layer lc-base {
@@ -172,6 +172,9 @@ const unwrapReferenced = async (js: string, resources: BundleResource[], root: s
172
172
  if (raw.length === 0) { note(`Lightmap uvs: the ${glbs.length} GLB(s) the app references carry them`); return }
173
173
  note(`Unwrapping ${raw.length} of the ${glbs.length} GLB(s) the app references — no lightmap uvs; written in place (--no-unwrap skips)…`)
174
174
  const assets = await loadPeer<typeof import("lecodes-assets/cli")>("lecodes-assets", "cli", { for: "lecodes lightmap bake (lightmap uvs)" })
175
+ if (typeof assets.unwrapGlbFiles !== "function") {
176
+ throw new CliError("The lecodes-assets this CLI loaded has no unwrapGlbFiles (it predates the bake's unwrap) — `lecodes update` moves it forward; --no-unwrap bakes the GLBs as they are.")
177
+ }
175
178
  const t0 = performance.now()
176
179
  const rel = (f: string): string => relative(root, f).replace(/\\/g, "/")
177
180
  const reports = await assets.unwrapGlbFiles(raw, {
@@ -3,7 +3,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
3
3
  import { join } from "node:path"
4
4
  import { pathToFileURL } from "node:url"
5
5
  import pkg from "../../package.json"
6
- import { peerDirInPrefix, peersDir, peerVersionGlobal } from "./peers"
6
+ import { peerDirInPrefix, peersDir, peerVersionGlobal, peerVersionPrefix } from "./peers"
7
+ import { semverNewer } from "./releases"
7
8
  import { archiveSpec } from "./archives"
8
9
  import { commandLine, installGlobalArgv, installIntoArgv, ownManager, pickManager } from "./packageManager"
9
10
  import { CliError, c, confirm, log, note } from "../cli"
@@ -124,6 +125,13 @@ const resolveEntry = (pkgDir: string, subpath?: string): string => {
124
125
  return join(pkgDir, rel)
125
126
  }
126
127
 
128
+ /** The runtime set's peers that are npm's: the CLI calls their API (lightmap bake's unwrapGlbFiles), so one
129
+ * OLDER than this CLI is a "not a function" deep inside a command — re-installed at this CLI's range, never
130
+ * loaded. (The set's archive, lecodes-headless, is installed by its url at exactly this version.) */
131
+ const SET_ON_NPM = new Set(["lecodes-assets"])
132
+ const olderThanCli = (name: string, version: string | null): boolean =>
133
+ SET_ON_NPM.has(name) && version !== null && semverNewer(version, pkg.version) > 0
134
+
127
135
  const isNotFound = (e: unknown, spec: string): boolean => {
128
136
  const code = (e as { code?: string })?.code
129
137
  const msg = e instanceof Error ? e.message : String(e)
@@ -146,17 +154,25 @@ export async function loadPeer<T>(name: string, subpath: string | undefined, opt
146
154
  export async function loadPeer<T>(name: string, subpath: string | undefined, opts: LoadPeerOptions & { install: false }): Promise<T | null>
147
155
  export async function loadPeer<T>(name: string, subpath: string | undefined, opts: LoadPeerOptions): Promise<T | null> {
148
156
  const spec = subpath ? `${name}/${subpath}` : name
157
+ // what the user installed by hand wins — unless it is older than the API this CLI calls
158
+ const byHand = peerVersionGlobal(name, spec)
159
+ if (olderThanCli(name, byHand)) {
160
+ throw new CliError(`${name} ${byHand} (installed by hand) is older than this CLI (${pkg.version}) needs — update it: ${commandLine(ownManager(), installGlobalArgv(ownManager(), [await peerSpec(name)]))}`)
161
+ }
149
162
  try {
150
163
  return (await import(spec)) as T
151
164
  } catch (e) {
152
165
  if (!isNotFound(e, spec)) throw e
153
166
  }
154
167
  const dir = peerDirInPrefix(name)
155
- if (!existsSync(join(dir, "package.json"))) {
168
+ const installed = peerVersionPrefix(name)
169
+ const stale = olderThanCli(name, installed)
170
+ if (installed === null || stale) {
156
171
  if (opts.install === false) return null
157
172
  // A global install of a DIFFERENT version than the probe expects would have resolved above; here
158
173
  // the peer is nowhere. (Globally installed but broken → the error above was not "not found".)
159
- if (peerVersionGlobal(name, spec) !== null) throw new CliError(`${name} is installed but "${spec}" can't be loaded from it — reinstall it: ${commandLine(ownManager(), installGlobalArgv(ownManager(), [await peerSpec(name)]))}`)
174
+ if (installed === null && peerVersionGlobal(name, spec) !== null) throw new CliError(`${name} is installed but "${spec}" can't be loaded from it — reinstall it: ${commandLine(ownManager(), installGlobalArgv(ownManager(), [await peerSpec(name)]))}`)
175
+ if (stale) note(`${name} ${installed} in ${peersDir()} is older than this CLI (${pkg.version}) — installing the one it needs`)
160
176
  await installPeers(companions(name), opts.for)
161
177
  }
162
178
  return (await import(pathToFileURL(resolveEntry(dir, subpath)).href)) as T