dsh-plugin-beyond-simulator 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dsh-plugin/dist/client.js +4 -4
- package/dsh-plugin/dist/index.js +14 -12
- package/dsh-plugin/dist/worker.js +12 -10
- package/dsh-plugin/skill.md +2 -1
- package/package.json +1 -1
package/dsh-plugin/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as va,readFileSync as Ln}from"node:fs";import{basename as Ou}from"node:path";import{Worker as pu}from"node:worker_threads";import{mkdirSync as mu,readFileSync as gu,writeFileSync as yu}from"node:fs";import{basename as bu,dirname as vu}from"node:path";import{existsSync as Jt,readFileSync as Pl}from"node:fs";import{basename as Ct,dirname as Tl,isAbsolute as Rl,join as Go,resolve as Vo}from"node:path";var te=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),K=Object.freeze({"pc-16-9":{id:"pc-16-9",device:"pc",platform:"KEYBOARD",width:1600,height:900,ratio:"16:9",luaDevice:"KeyboardAndMouse",label:"PC 1600\xD7900"},"pc-21-9":{id:"pc-21-9",device:"pc",platform:"KEYBOARD",width:2100,height:900,ratio:"21:9",luaDevice:"KeyboardAndMouse",label:"PC 2100\xD7900"},"mobile-16-9":{id:"mobile-16-9",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:720,ratio:"16:9",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7720"},"mobile-19.5-9":{id:"mobile-19.5-9",device:"mobile",platform:"TOUCHSCREEN",width:1560,height:720,ratio:"19.5:9",luaDevice:"Mobile",label:"\u624B\u673A 1560\xD7720"},"mobile-4-3":{id:"mobile-4-3",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:960,ratio:"4:3",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7960"}}),ti="pc-16-9",ce=2,dt=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),ht=Object.freeze({"server-container":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",container:"\u5BB9\u5668\u8282\u70B9",textbox:"\u6587\u672C\u6846",image:"\u56FE\u7247",button:"\u9884\u8BBE\u6309\u94AE",cursor:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF",grid:"\u7F51\u683C\u89C6\u7A97",reference:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6",textwindow:"\u6587\u672C\u89C6\u7A97",keyhint:"\u6309\u952E\u63D0\u793A",animation:"\u754C\u9762\u52A8\u6548",fullscreen:"\u5168\u5C4F\u52A8\u6548"}),ii=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),Jn=Object.freeze({"server-container":null,container:[150,150],textbox:[100,40],image:[80,80],button:[150,50],cursor:[150,50],grid:[80,80],reference:[80,80],textwindow:[100,40],keyhint:[40,40],animation:[100,100],fullscreen:null}),pt=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"}),Zn=50888,Ot=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function mt(e,t="$",i=new Set){if(e===void 0)throw new Error(`undefined at ${t}`);if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`non-finite number at ${t}`);if(typeof e=="bigint"||typeof e=="function"||typeof e=="symbol")throw new Error(`non-JSON value at ${t}`);if(!(e===null||typeof e!="object")){if(i.has(e))throw new Error(`circular value at ${t}`);if(i.add(e),Array.isArray(e))e.forEach((n,r)=>mt(n,`${t}[${r}]`,i));else for(let[n,r]of Object.entries(e))mt(r,`${t}.${n}`,i);i.delete(e)}}function D(e){return mt(e),JSON.parse(JSON.stringify(e))}function Qn(e,t="$"){mt(e,t)}function er(e){return K[e]||K[ti]}function Ft(e,t=0,i=0){return!e||typeof e!="object"?{x:t,y:i}:{x:Number(e.x??t),y:Number(e.y??i)}}function za(e){return!e||typeof e!="object"?{x:1,y:1,z:1}:{x:Number(e.x??1),y:Number(e.y??1),z:Number(e.z??1)}}function Ga(e){return!e||typeof e!="object"?{x:0,y:0,z:0}:{x:Number(e.x??0),y:Number(e.y??0),z:Number(e.z??0)}}function ni({layout:e="center",size:t=[100,40],offset:i=[0,0]}={}){return e==="stretch"?{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:0,y:0},anchorMax:{x:1,y:1},offset:{x:0,y:0},size:{x:0,y:0},pivot:{x:.5,y:.5}}:{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:.5,y:.5},anchorMax:{x:.5,y:.5},offset:{x:Number(i[0]??0),y:Number(i[1]??0)},size:{x:Number(t[0]??0),y:Number(t[1]??0)},pivot:{x:.5,y:.5}}}function Ce(e){let t=e||ni();return{scale:za(t.scale),rotation:Ga(t.rotation),anchorMin:Ft(t.anchorMin??t.anchor_min,.5,.5),anchorMax:Ft(t.anchorMax??t.anchor_max,.5,.5),offset:Ft(t.offset,0,0),size:Ft(t.size,0,0),pivot:Ft(t.pivot,.5,.5)}}function fe(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ae(e,t){let i=e.width,n=e.height,r=e.left,o=e.bottom,a=t.anchorMin||{x:t.anchorMinX,y:t.anchorMinY},s=t.anchorMax||{x:t.anchorMaxX,y:t.anchorMaxY},c=t.offset||{x:t.anchoredPositionX,y:t.anchoredPositionY},l=t.size||{x:t.sizeDeltaX,y:t.sizeDeltaY},f=t.pivot||{x:t.pivotX,y:t.pivotY},h=fe(a?.x,.5)*i,p=fe(a?.y,.5)*n,m=fe(s?.x,.5)*i,g=fe(s?.y,.5)*n,I=fe(l?.x),k=fe(l?.y),E=fe(f?.x,.5),$=fe(f?.y,.5),F=m-h+I,U=g-p+k,W=r+h+fe(c?.x)-I*E,Z=o+p+fe(c?.y)-k*$;return{left:W,bottom:Z,width:F,height:U,right:W+F,top:Z+U,centerX:W+F/2,centerY:Z+U/2}}function gt(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function Va(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,tx:e.a*t.tx+e.c*t.ty+e.tx,ty:e.b*t.tx+e.d*t.ty+e.ty}}function Ke(e,t,i){return{x:e.a*t+e.c*i+e.tx,y:e.b*t+e.d*i+e.ty}}function ri(e){let t=e.a*e.d-e.b*e.c;return!Number.isFinite(t)||Math.abs(t)<1e-8?null:{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,tx:(e.c*e.ty-e.d*e.tx)/t,ty:(e.b*e.tx-e.a*e.ty)/t}}function Di(e,t){let i=t.rotation||{z:t.localRotationZ},n=t.scale||{x:t.localScaleX,y:t.localScaleY},r=t.pivot||{x:t.pivotX,y:t.pivotY},o=fe(i?.z)*Math.PI/180,a=Math.cos(o),s=Math.sin(o),c=fe(n?.x,1),l=fe(n?.y,1),f=e.left+e.width*fe(r?.x,.5),h=e.bottom+e.height*fe(r?.y,.5),p=a*c,m=s*c,g=-s*l,I=a*l;return{a:p,b:m,c:g,d:I,tx:f-p*f-g*h,ty:h-m*f-I*h}}function $t(e,t,i){return Va(e||gt(),Di(t,i))}function tr(e,t){let i=Ke(t,e.centerX,e.centerY),n=Math.abs(e.width*Math.hypot(t.a,t.b)),r=Math.abs(e.height*Math.hypot(t.c,t.d));return{left:i.x-n/2,bottom:i.y-r/2,width:n,height:r,centerX:i.x,centerY:i.y,rotationZ:Math.atan2(t.b,t.a)*180/Math.PI}}function de(e){let t=typeof e=="string"?er(e):e;return{left:0,bottom:0,width:t.width,height:t.height,right:t.width,top:t.height,centerX:t.width/2,centerY:t.height/2}}function zi(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function Le(e,t,i){let n=Ce(t),r=e.width,o=e.height,a=n.anchorMin.x*r,s=n.anchorMin.y*o,c=n.anchorMax.x*r,l=n.anchorMax.y*o,f=Number(i.width),h=Number(i.height),p=Number(i.posX),m=Number(i.posY),g=p-f/2,I=m-h/2;return n.size={x:f-(c-a),y:h-(l-s)},n.offset={x:g-e.left-a+n.size.x*n.pivot.x,y:I-e.bottom-s+n.size.y*n.pivot.y},n}function ir(e,t){let i=Ce(e),r={"bottom-left":[[0,0],[0,0],[0,0]],bottom:[[.5,0],[.5,0],[.5,0]],"bottom-right":[[1,0],[1,0],[1,0]],left:[[0,.5],[0,.5],[0,.5]],center:[[.5,.5],[.5,.5],[.5,.5]],right:[[1,.5],[1,.5],[1,.5]],"top-left":[[0,1],[0,1],[0,1]],top:[[.5,1],[.5,1],[.5,1]],"top-right":[[1,1],[1,1],[1,1]],stretch:[[0,0],[1,1],[.5,.5]],"stretch-horizontal":[[0,.5],[1,.5],[.5,.5]],"stretch-vertical":[[.5,0],[.5,1],[.5,.5]]}[t];return r&&(i.anchorMin={x:r[0][0],y:r[0][1]},i.anchorMax={x:r[1][0],y:r[1][1]},i.pivot={x:r[2][0],y:r[2][1]}),i}function nr(e){let t=Ce(e),i=(n,r)=>Math.abs(n-r)<1e-4;if(i(t.anchorMin.x,0)&&i(t.anchorMin.y,0)&&i(t.anchorMax.x,1)&&i(t.anchorMax.y,1))return"stretch";if(i(t.anchorMin.x,t.anchorMax.x)&&i(t.anchorMin.y,t.anchorMax.y)){let n=t.anchorMin.x,r=t.anchorMin.y,o=[[0,0,"bottom-left"],[.5,0,"bottom"],[1,0,"bottom-right"],[0,.5,"left"],[.5,.5,"center"],[1,.5,"right"],[0,1,"top-left"],[.5,1,"top"],[1,1,"top-right"]];for(let a of o)if(i(n,a[0])&&i(r,a[1]))return a[2]}return"custom"}function We(e){return er(e).platform}function rr(e){let t={};for(let i of te)t[i]=e(i);return t}var Ya={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function or(e,t){for(let[i,n]of Object.entries(Ya))for(let r of n)if(!Number.isFinite(e?.[i]?.[r]))throw new Error(`${t}.${i}.${r} must be a finite number`)}function Oe(e,t="transformByPlatform"){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: \u9700\u8981\u5B8C\u6574\u7684\u56DB\u5E73\u53F0\u5E03\u5C40`);for(let i of Object.keys(e))if(!te.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of te)or(e[i],`${t}.${i}`)}function qe(e){if(Object.hasOwn(e,"transformByCanvas"))throw new Error(`${e.name||e.id||"\u63A7\u4EF6"}: \u4E0D\u518D\u652F\u6301 transformByCanvas\uFF1B\u8BF7\u4F7F\u7528\u56DB\u5E73\u53F0 transformByPlatform \u5E03\u5C40`);Oe(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function je(e,t){if(!te.includes(t))throw new Error(`unknown platform ${t}`);return or(e?.[t],`transformByPlatform.${t}`),Ce(e[t])}var Ba=Object.freeze([{key:"genericField501",label:"\u901A\u7528\u69FD field501",type:"number",defaultValue:0,wire:"GenericSlot.field501"},{key:"footerField505",label:"\u5C3E\u90E8\u69FD field505",type:"number",defaultValue:0,wire:"FooterSlot.field505"}]),Ua=Object.freeze({container:[{key:"containerNodeSlot",label:"\u5BB9\u5668\u8282\u70B9\u69FD",type:"string",defaultValue:"",wire:"Details.containerNodeSlot"}],textbox:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]}],textwindow:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]},{key:"textField511",label:"\u6587\u672C\u89C6\u7A97 field511",type:"number",defaultValue:1,wire:"TextConfig.field511"},{key:"textViewField502",label:"\u89C6\u7A97\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field502"},{key:"textViewField503",label:"\u89C6\u7A97\u6807\u8BB0 field503",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field503"}],cursor:[{key:"cursorField501",label:"\u5149\u6807\u68C0\u6D4B field501",type:"number",defaultValue:1,wire:"CursorConfig.field501"}],reference:[{key:"templateRefSlot",label:"\u6A21\u677F\u5F15\u7528\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.templateRefSlot"}],grid:[{key:"gridField501",label:"\u7F51\u683C\u6807\u8BB0 field501",type:"number",defaultValue:1,wire:"GridViewConfig.field501"},{key:"gridField507",label:"\u7F51\u683C\u6807\u8BB0 field507",type:"number",defaultValue:1,wire:"GridViewConfig.field507"},{key:"gridField508",label:"\u7F51\u683C\u6807\u8BB0 field508",type:"number",defaultValue:1,wire:"GridViewConfig.field508"},{key:"gridField509",label:"\u7F51\u683C\u6807\u8BB0 field509",type:"number",defaultValue:1,wire:"GridViewConfig.field509"},{key:"gridField511",label:"\u7F51\u683C\u6807\u8BB0 field511",type:"number",defaultValue:5,wire:"GridViewConfig.field511"},{key:"gridField512",label:"\u7F51\u683C\u6807\u8BB0 field512",type:"number",defaultValue:1,wire:"GridViewConfig.field512"}],keyhint:[{key:"keyHintField501",label:"\u6309\u952E\u63D0\u793A field501",type:"number",defaultValue:1,wire:"KeyHintConfig.field501"},{key:"keyHintField502",label:"\u952E\u9F20\u952E\u4F4D\u539F\u59CB\u503C",type:"number",defaultValue:1,wire:"KeyHintConfig.field502"}],image:[{key:"imageField502",label:"\u56FE\u7247\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"ImageConfig.field502"},{key:"imageField504",label:"\u56FE\u7247\u6807\u8BB0 field504",type:"number",defaultValue:1,wire:"ImageConfig.field504"},{key:"imageField505",label:"\u56FE\u7247\u6807\u8BB0 field505",type:"number",defaultValue:1,wire:"ImageConfig.field505"},{key:"imageField507",label:"\u56FE\u7247\u6807\u8BB0 field507",type:"number",defaultValue:2,wire:"ImageConfig.field507"},{key:"imageFillType",label:"\u586B\u5145\u5F62\u72B6\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:1,wire:"ImageConfig.fillType",options:[{value:1,label:"1 \xB7 \u6A2A\u5411"},{value:2,label:"2 \xB7 \u7EB5\u5411"},{value:3,label:"3 \xB7 90\u5EA6\u73AF\u7ED5"},{value:4,label:"4 \xB7 180\u5EA6\u73AF\u7ED5"},{value:5,label:"5 \xB7 360\u5EA6\u73AF\u7ED5"}]}],animation:[{key:"effectSlot",label:"\u754C\u9762\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.effectSlot"}],fullscreen:[{key:"fullscreenEffectSlot",label:"\u5168\u5C4F\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.fullscreenEffectSlot"}]});function ar(e){return[...Ba,...Ua[e]||[]]}function sr(e,t){return ar(e).find(i=>i.key===t)||null}function Gi(e,t){if(!e)throw new Error("unknown raw GIA field");if(e.type==="string")return String(t??"");let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e.wire} must be a finite number`);return Math.trunc(i)}function lr(e,t={}){let i={};for(let n of ar(e)){let r=Object.hasOwn(t||{},n.key)?t[n.key]:n.defaultValue;i[n.key]=Gi(n,r)}return i}function ke(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Vi(e,t){if(e){t(e);for(let i of e.children||[])Vi(i,t)}}function yt(e,t=new Set,{skipServerContainer:i=!1}={}){return Vi(e,n=>{i&&n.kind==="server-container"||ke(n.guid)&&t.add(Number(n.guid))}),t}function Fe(e,t=1073741850){let i=Number.isSafeInteger(t)&&t>0?t:1073741850;i<1073741850&&(i=1073741850);for(let n of e)ke(n)&&n>=i&&(i=Number(n)+1);for(;e.has(i);)i+=1;if(i>2147483647)throw new Error("GUID space exhausted");return i}function ur(e,t=new Set,{skipServerContainer:i=!1}={}){let n=[];Vi(e,r=>{if(i&&r.kind==="server-container")return;let o=Number(r.guid);if(ke(o)&&!t.has(o)){t.add(o),r.guid=o;return}n.push(r)});for(let r of n){let o=Fe(t);r.guid=o,t.add(o)}return t}var Yi=1;function Bi(e="n"){let t=`${e}${Yi}`;return Yi+=1,t}function oi(e=1){Yi=e}function Ui(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return ni({layout:"stretch"});let i=Jn[e]||[80,80];return ni({layout:"center",size:i})}function Ha(e,t){return rr(()=>Ui(e,t))}function Xa(e){Oe(e);let t={};for(let i of te)t[i]=je(e,i);return t}function B(e,t={}){if(!ht[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&&qe(t);let i=t.isRootContainer===!0,n=t.id||Bi(e==="server-container"?"sc":"n"),r=Object.hasOwn(t,"transformByPlatform")?Xa(t.transformByPlatform):Ha(e,{isRootContainer:i}),o={id:n,kind:e,name:t.name||ht[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[],...Number.isSafeInteger(Number(t.giaInfoIndex))&&Number(t.giaInfoIndex)>0?{giaInfoIndex:Number(t.giaInfoIndex)}:{},active:t.active!==!1,visible:t.visible!==!1,canControllerFocus:t.canControllerFocus===!0,syncAllDevices:t.syncAllDevices!==!1,giaRaw:lr(e,t.giaRaw),transformByPlatform:r,children:[],scriptMappingIds:Array.isArray(t.scriptMappingIds)?t.scriptMappingIds.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[]};if(e==="container"&&(o.isolateNavigation=t.isolateNavigation===!0,o.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,o.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,o.showCursor=t.showCursor===!0),(e==="textbox"||e==="textwindow")&&(o.fontSize=t.fontSize??20,o.adaptiveFontSize=t.adaptiveFontSize===!0,o.minimumFontSize=t.minimumFontSize??20,o.fontColor=t.fontColor??Ot.font,o.bgColor=t.bgColor??Ot.bg,o.enableOutline=t.enableOutline!==!1,o.outlineColor=t.outlineColor??Ot.outline,o.horizontalAlignment=t.horizontalAlignment||"Left",o.verticalAlignment=t.verticalAlignment||"Top",o.text=t.text??"",Object.hasOwn(t.giaRaw||{},"textAlign")||(o.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o.horizontalAlignment]??o.giaRaw.textAlign),e==="textwindow"&&(o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1)),e==="image"&&(o.imageSource=t.imageSource||"StaticReference",o.imageId=t.imageId??100001,o.imageColor=t.imageColor??Ot.image,o.enableMask=t.enableMask===!0,o.enableSoftEdge=t.enableSoftEdge===!0,o.softEdgeMode=t.softEdgeMode||"Percentage",o.softEdgeWidthX=t.softEdgeWidthX??8,o.softEdgeWidthY=t.softEdgeWidthY??8,o.horizontalSoftRange=t.horizontalSoftRange??85,o.verticalSoftRange=t.verticalSoftRange??85,o.enableFill=t.enableFill===!0,o.fillType=t.fillType||"Horizontal",o.fillHorizontalType=t.fillHorizontalType||"Left",o.fillVerticalType=t.fillVerticalType||"Bottom",o.fillRadial90Type=t.fillRadial90Type||"BottomLeft",o.fillRadialType=t.fillRadialType||"Bottom",o.fillAmount=t.fillAmount??1,o.reverseMaskArea=t.reverseMaskArea===!0||t.reverseMask===!0,Object.hasOwn(t.giaRaw||{},"imageFillType")||(o.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o.fillType]??o.giaRaw.imageFillType)),e==="button"&&(o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.clickAudioId=t.clickAudioId??Zn,o.unavailableChildId=t.unavailableChildId??null,o.hoverChildId=t.hoverChildId??null,o.pressedChildId=t.pressedChildId??null,o.selectedChildId=t.selectedChildId??null),e==="cursor"&&(o.raycastTarget=t.raycastTarget!==!1),e==="reference"&&(o.referencedPrefabId=t.referencedPrefabId??t.giaRaw?.templateRefSlot??null,Object.hasOwn(t.giaRaw||{},"templateRefSlot")||(o.giaRaw.templateRefSlot=String(o.referencedPrefabId??""))),e==="grid"&&(o.itemPrefabId=t.itemPrefabId??null,o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1,o.scrollDirection=t.scrollDirection||"Vertical",o.layoutConstraint=t.layoutConstraint||"AutoWrap",o.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,o.cellSizeX=t.cellSizeX??50,o.cellSizeY=t.cellSizeY??50,o.spacingX=t.spacingX??8,o.spacingY=t.spacingY??8,o.padding1X=t.padding1X??20,o.padding1Y=t.padding1Y??20,o.padding2X=t.padding2X??20,o.padding2Y=t.padding2Y??20,o.previewCount=t.previewCount??t.giaRaw?.gridField511??5,Object.hasOwn(t.giaRaw||{},"gridField511")||(o.giaRaw.gridField511=Math.trunc(o.previewCount))),e==="keyhint"&&(o.keyboardKeyCode=t.keyboardKeyCode??t.giaRaw?.keyHintField502??null,o.controllerKeyCode=t.controllerKeyCode??t.giaRaw?.keyHintField501??null,Object.hasOwn(t.giaRaw||{},"keyHintField502")||(o.giaRaw.keyHintField502=Math.trunc(o.keyboardKeyCode??1)),Object.hasOwn(t.giaRaw||{},"keyHintField501")||(o.giaRaw.keyHintField501=Math.trunc(o.controllerKeyCode??1))),e==="animation"||e==="fullscreen"){let a=e==="animation"?t.giaRaw?.effectSlot:t.giaRaw?.fullscreenEffectSlot;o.animationId=t.animationId??a??null,o.playSoundEffect=t.playSoundEffect??null,e==="animation"&&(o.layer=t.layer??null);let s=e==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(t.giaRaw||{},s)||(o.giaRaw[s]=String(o.animationId??""))}if(t.children)for(let a of t.children)o.children.push(a);return o}function De(){oi(1);let e=B("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),t=B("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=B("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),n=B("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),r=B("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),o=B("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),a=B("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),s=B("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),c=B("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),l=B("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),f=B("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),h=B("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),p=(m,g,I)=>{for(let k of Object.values(m.transformByPlatform))k.offset={x:g,y:I}};return p(i,-300,250),p(n,-300,140),p(r,-300,30),p(o,-300,-100),p(a,0,0),p(s,300,250),p(c,300,140),p(l,300,30),p(f,300,-100),t.children.push(i,n,r,o,a,s,c,l,f,h),e.children.push(t),oi(12),ur(e),{version:1,layoutSchemaVersion:ce,meta:{name:"\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"authoring",sourceFile:""},canvasId:"pc-16-9",selectedId:"n2",root:e}}function Je(){oi(1);let e=B("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),t=B("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=B("textbox",{id:"n2",guid:1073742101,name:"\u6A21\u677F\u6807\u9898",text:"\u5BA2\u6237\u7AEF\u6A21\u677F\u5DF2\u5B9E\u4F8B\u5316",fontSize:28,horizontalAlignment:"Middle"}),n=B("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),r=B("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),o=B("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),a=(c,l,f)=>{for(let h of Object.values(c.transformByPlatform))h.offset={x:l,y:f}};return((c,l,f)=>{for(let h of Object.values(c.transformByPlatform))h.size={x:l,y:f}})(t,520,320),a(i,0,110),a(n,0,0),a(r,0,-110),r.children.push(o),t.children.push(i,n,r),e.children.push(t),oi(6),{version:1,layoutSchemaVersion:ce,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:"7.0.50",giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:e}}function J(e,t,i=null){t(e,i);for(let n of e.children||[])J(n,t,e)}function le(e,t){let i=null;return J(e,n=>{n.id===t&&(i=n)}),i}function Hi(e,t="n"){let i=Bi(t);for(;le(e,i);)i=Bi(t);return i}function $e(e,t){let i=null;return J(e,(n,r)=>{n.id===t&&(i=r)}),i}function Xi(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function Dt(e){if(e.meta?.assetType!=="client-control-template")return Xi(e);let t=le(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=$e(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=$e(e.root,t.id);return t}function Ki(e){qe(e);let t={id:e.id,name:e.name,guid:e.guid,giaRelatedGuids:e.giaRelatedGuids,giaInfoIndex:e.giaInfoIndex,scriptMappingIds:e.scriptMappingIds,giaRaw:e.giaRaw,active:e.active,visible:e.visible,canControllerFocus:e.canControllerFocus,syncAllDevices:e.syncAllDevices,transformByPlatform:e.transformByPlatform};e.kind==="container"&&(t.isolateNavigation=e.isolateNavigation,t.disableKeyEventPassthrough=e.disableKeyEventPassthrough,t.disableCursorEventPassthrough=e.disableCursorEventPassthrough,t.showCursor=e.showCursor),(e.kind==="textbox"||e.kind==="textwindow")&&(t.fontSize=e.fontSize,t.adaptiveFontSize=e.adaptiveFontSize,t.minimumFontSize=e.minimumFontSize,t.fontColor=e.fontColor,t.bgColor=e.bgColor,t.enableOutline=e.enableOutline,t.outlineColor=e.outlineColor,t.horizontalAlignment=e.horizontalAlignment,t.verticalAlignment=e.verticalAlignment,t.text=e.text??"",e.kind==="textwindow"&&(t.interactable=e.interactable,t.showScrollBar=e.showScrollBar)),e.kind==="image"&&(t.imageSource=e.imageSource,t.imageId=e.imageId,t.imageColor=e.imageColor,t.enableMask=e.enableMask,t.enableSoftEdge=e.enableSoftEdge,t.softEdgeMode=e.softEdgeMode,t.softEdgeWidthX=e.softEdgeWidthX,t.softEdgeWidthY=e.softEdgeWidthY,t.horizontalSoftRange=e.horizontalSoftRange,t.verticalSoftRange=e.verticalSoftRange,t.enableFill=e.enableFill,t.fillType=e.fillType,t.fillHorizontalType=e.fillHorizontalType,t.fillVerticalType=e.fillVerticalType,t.fillRadial90Type=e.fillRadial90Type,t.fillRadialType=e.fillRadialType,t.fillAmount=e.fillAmount,t.reverseMaskArea=e.reverseMaskArea??e.reverseMask),e.kind==="button"&&(t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.clickAudioId=e.clickAudioId,t.unavailableChildId=e.unavailableChildId??null,t.hoverChildId=e.hoverChildId??null,t.pressedChildId=e.pressedChildId??null,t.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(t.raycastTarget=e.raycastTarget),e.kind==="reference"&&(t.referencedPrefabId=e.referencedPrefabId??null),e.kind==="grid"&&(t.itemPrefabId=e.itemPrefabId??null,t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.showScrollBar=e.showScrollBar,t.scrollDirection=e.scrollDirection,t.layoutConstraint=e.layoutConstraint,t.layoutConstraintFixedCount=e.layoutConstraintFixedCount??null,t.cellSizeX=e.cellSizeX,t.cellSizeY=e.cellSizeY,t.spacingX=e.spacingX,t.spacingY=e.spacingY,t.padding1X=e.padding1X,t.padding1Y=e.padding1Y,t.padding2X=e.padding2X,t.padding2Y=e.padding2Y,t.previewCount=e.previewCount),e.kind==="keyhint"&&(t.keyboardKeyCode=e.keyboardKeyCode??null,t.controllerKeyCode=e.controllerKeyCode??null),(e.kind==="animation"||e.kind==="fullscreen")&&(t.animationId=e.animationId??null,t.playSoundEffect=e.playSoundEffect??null,e.kind==="animation"&&(t.layer=e.layer??null)),t.isRootContainer=e.kind==="container"&&Ka(e.transformByPlatform);let i=B(e.kind,t);return i.children=(e.children||[]).map(n=>Ki(n)),i}function Ka(e){let t=e&&(e.KEYBOARD||Object.values(e)[0]);return t?Math.abs(t.anchorMin?.x??.5)<1e-4&&Math.abs(t.anchorMin?.y??.5)<1e-4&&Math.abs((t.anchorMax?.x??.5)-1)<1e-4&&Math.abs((t.anchorMax?.y??.5)-1)<1e-4:!1}function cr(e,t,i={}){if(e.kind==="server-container"&&t!=="container")throw new Error("server container only accepts container nodes");let n=B(t,i);return e.children.push(n),n}function fr(e,t){if(e.id===t)throw new Error("cannot remove root");let i=$e(e,t);if(!i)return!1;let n=i.children.findIndex(r=>r.id===t);return n<0?!1:(i.children.splice(n,1),!0)}var dr=1e-4;function La(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>dr&&Math.abs(e.size[t])<=dr}function Wa(e,t,i){if(!(t.width>0)||!(t.height>0))throw new Error("source parent must have positive size");if(!(i.width>0)||!(i.height>0))throw new Error("target parent must have positive size");let n=Ae(t,e),r=(n.centerX-t.left)/t.width,o=(n.centerY-t.bottom)/t.height,a=Le(i,e,{posX:i.left+r*i.width,posY:i.bottom+o*i.height,width:n.width,height:n.height});for(let s of["x","y"])La(e,s)&&(a.offset[s]=e.offset[s],a.size[s]=e.size[s]);return a}function hr({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:n,sourceParentBox:r=de(i),targetParentBoxByPlatform:o={}}){Oe(e);let a=We(i),s={};for(let c of te)c===a?s[c]=Ce(t):n!==!1?s[c]=Wa(t,r,o[c]||de(dt[c])):s[c]=je(e,c);return Oe(s),s}function ze(e,t){return je(e,We(t))}function pr(e,t){let i=[];function n(r){t[r.id]&&i.push(t[r.id]);let o=r.children||[];for(let a=o.length-1;a>=0;a-=1)n(o[a])}return n(e),i}function Ge(e,t,i=We(t)){let n=de(t),r={};function o(a,s,c){let l=je(a.transformByPlatform,i),f=Ae(s,l),h=a.kind==="server-container"?c:$t(c,f,l),p=tr(f,h);r[a.id]={...f,...zi(f),id:a.id,kind:a.kind,name:a.name,visible:a.visible!==!1,active:a.active!==!1,rotationZ:l.rotation.z,renderLeft:p.left,renderBottom:p.bottom,renderWidth:p.width,renderHeight:p.height,renderRotationZ:p.rotationZ,renderMatrix:h,primitive:a.kind==="image"?pt[a.imageId]||"missing":null,...a.kind==="textbox"||a.kind==="textwindow"?{text:a.text??"",fontSize:a.fontSize,fontColor:a.fontColor,bgColor:a.bgColor,enableOutline:a.enableOutline!==!1,outlineColor:a.outlineColor,horizontalAlignment:a.horizontalAlignment,verticalAlignment:a.verticalAlignment}:{},...a.kind==="image"?{imageSource:a.imageSource,imageId:a.imageId,imageColor:a.imageColor,enableMask:a.enableMask===!0,enableSoftEdge:a.enableSoftEdge===!0,softEdgeMode:a.softEdgeMode,softEdgeWidthX:a.softEdgeWidthX,softEdgeWidthY:a.softEdgeWidthY,horizontalSoftRange:a.horizontalSoftRange,verticalSoftRange:a.verticalSoftRange,enableFill:a.enableFill===!0,fillType:a.fillType,fillHorizontalType:a.fillHorizontalType,fillVerticalType:a.fillVerticalType,fillRadial90Type:a.fillRadial90Type,fillRadialType:a.fillRadialType,fillAmount:a.fillAmount,reverseMaskArea:a.reverseMaskArea===!0}:{},...a.kind==="button"?{raycastTarget:a.raycastTarget!==!1,interactable:a.interactable!==!1,clickAudioId:a.clickAudioId,unavailableChildId:a.unavailableChildId??null,hoverChildId:a.hoverChildId??null,pressedChildId:a.pressedChildId??null,selectedChildId:a.selectedChildId??null}:{}};let m=a.kind==="server-container"?s:f;for(let g of a.children||[])o(g,m,h)}return o(e,n,gt()),{canvas:n,boxes:r}}function Li(e,t){let i=[];function n(r,o,a=null,s=[],c=0,l=1,f=e.id){i.push({id:r.id,guid:t?.get(r.id)??(r.guid||0),kind:r.kind,name:r.name,label:ht[r.kind]||r.kind,depth:o,parentId:a,ancestorIds:s,siblingIndex:c,siblingCount:l,templateId:f,childCount:(r.children||[]).length,incomplete:!ii.includes(r.kind)});let h=r.children||[];for(let p=0;p<h.length;p+=1)n(h[p],o+1,r.id,[...s,r.id],p,h.length,f)}return n(e,0),i}function A(e,t,i,n,r={}){return{key:e,label:t,type:i,value:n,...r}}function mr(e,t,i,n){if(!e)return null;let r=ze(e.transformByPlatform,t),o=zi(i),a=[A("name","\u540D\u79F0","string",e.name),A("active","\u521D\u59CB\u6FC0\u6D3B","bool",e.active!==!1),A("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",e.visible!==!1),A("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",e.canControllerFocus===!0),A("posX","\u4F4D\u7F6E X","number",o.posX,{computed:!0}),A("posY","\u4F4D\u7F6E Y","number",o.posY,{computed:!0}),A("width","\u5927\u5C0F W","number",o.width,{computed:!0}),A("height","\u5927\u5C0F H","number",o.height,{computed:!0}),A("rotationZ","\u65CB\u8F6C Z","number",r.rotation.z),A("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",e.syncAllDevices!==!1),A("anchorType","\u951A\u70B9\u7C7B\u578B","enum",nr(r),{options:[{value:"center",label:"\u5C45\u4E2D"},{value:"top-left",label:"\u5DE6\u4E0A"},{value:"top",label:"\u4E0A\u65B9"},{value:"top-right",label:"\u53F3\u4E0A"},{value:"left",label:"\u5DE6\u4FA7"},{value:"right",label:"\u53F3\u4FA7"},{value:"bottom-left",label:"\u5DE6\u4E0B"},{value:"bottom",label:"\u4E0B\u65B9"},{value:"bottom-right",label:"\u53F3\u4E0B"},{value:"stretch",label:"\u53CC\u5411\u62C9\u4F38"},{value:"stretch-horizontal",label:"\u6C34\u5E73\u62C9\u4F38"},{value:"stretch-vertical",label:"\u5782\u76F4\u62C9\u4F38"},{value:"custom",label:"\u81EA\u5B9A\u4E49"}]}),A("anchorMinX","\u951A\u70B9 Min X","number",r.anchorMin.x),A("anchorMinY","\u951A\u70B9 Min Y","number",r.anchorMin.y),A("anchorMaxX","\u951A\u70B9 Max X","number",r.anchorMax.x),A("anchorMaxY","\u951A\u70B9 Max Y","number",r.anchorMax.y),A("pivotX","\u4E2D\u5FC3 X","number",r.pivot.x),A("pivotY","\u4E2D\u5FC3 Y","number",r.pivot.y)];if(e.kind==="container"&&a.push(A("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",e.isolateNavigation===!0),A("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableKeyEventPassthrough===!0),A("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableCursorEventPassthrough===!0),A("showCursor","\u663E\u793A\u5E38\u9A7B\u5149\u6807","bool",e.showCursor===!0)),e.kind==="textbox"||e.kind==="textwindow"){let s=e.giaRaw?.textAlign,c=[0,1,2].includes(s)?e.horizontalAlignment||"Left":`__unrecognized:${s}`;a.push(A("fontSize","\u5B57\u53F7","number",e.fontSize),A("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",e.adaptiveFontSize===!0),A("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",e.minimumFontSize),A("fontColor","\u6587\u672C\u8272","color",e.fontColor),A("bgColor","\u80CC\u666F\u8272","color",e.bgColor),A("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",e.enableOutline!==!1),A("outlineColor","\u63CF\u8FB9\u8272","color",e.outlineColor),A("horizontalAlignment","\u6C34\u5E73\u5BF9\u9F50","enum",c,{...[0,1,2].includes(s)?{}:{unknownValue:s},options:[{value:"Left",label:"\u5DE6\u5BF9\u9F50"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Right",label:"\u53F3\u5BF9\u9F50"}]}),A("verticalAlignment","\u5782\u76F4\u5BF9\u9F50","enum",e.verticalAlignment||"Top",{options:[{value:"Top",label:"\u9876\u90E8"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Bottom",label:"\u5E95\u90E8"}]}),A("text","\u6587\u672C","text",e.text??""))}if(e.kind==="image"){let s=e.giaRaw?.imageFillType,c=[1,2,3,4,5].includes(s)?e.fillType:`__unrecognized:${s}`;a.push(A("imageSource","\u56FE\u7247\u6E90","enum",e.imageSource,{readonly:!0,evidence:"W",options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"}]}),A("imageId","imageId","number",e.imageId??0),A("imageColor","\u586B\u5145\u8272","color",e.imageColor),A("enableMask","\u5F00\u542F\u906E\u7F69","bool",e.enableMask===!0),A("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",e.enableSoftEdge===!0,{gia:"W"}),A("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",e.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),A("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",e.softEdgeWidthX),A("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",e.softEdgeWidthY),A("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",e.horizontalSoftRange),A("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",e.verticalSoftRange),A("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",e.enableFill===!0,{gia:"W"}),A("fillType","\u5F62\u72B6","enum",c,{...[1,2,3,4,5].includes(s)?{}:{unknownValue:s},options:[{value:"Horizontal",label:"\u6A2A\u5411"},{value:"Vertical",label:"\u7EB5\u5411"},{value:"Radial90",label:"90\u5EA6\u73AF\u7ED5"},{value:"Radial180",label:"180\u5EA6\u73AF\u7ED5"},{value:"Radial360",label:"360\u5EA6\u73AF\u7ED5"}]}),A("fillHorizontalType","\u65B9\u5411","enum",e.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),A("fillVerticalType","\u65B9\u5411","enum",e.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),A("fillRadial90Type","\u8D77\u70B9","enum",e.fillRadial90Type,{options:[{value:"BottomLeft",label:"\u5DE6\u4E0B"},{value:"TopLeft",label:"\u5DE6\u4E0A"},{value:"TopRight",label:"\u53F3\u4E0A"},{value:"BottomRight",label:"\u53F3\u4E0B"}]}),A("fillRadialType","\u8D77\u70B9","enum",e.fillRadialType,{options:[{value:"Bottom",label:"\u4E0B\u65B9"},{value:"Left",label:"\u5DE6\u4FA7"},{value:"Top",label:"\u4E0A\u65B9"},{value:"Right",label:"\u53F3\u4FA7"}]}),A("fillAmount","\u8FDB\u5EA6","percent",e.fillAmount),A("reverseMaskArea","\u906E\u7F69\u533A\u57DF\u53CD\u8F6C","bool",e.reverseMaskArea===!0,{gia:"W"}))}if(e.kind==="button"){let s=[{value:"",label:"\u672A\u8BBE\u7F6E"},...(e.children||[]).map(c=>({value:c.id,label:`${c.name} \xB7 ${c.id}`}))];a.push(A("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),A("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",e.interactable!==!1),A("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",e.unavailableChildId,{options:s,gia:"W"}),A("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",e.hoverChildId,{options:s,gia:"W"}),A("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",e.pressedChildId,{options:s,gia:"W"}),A("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",e.selectedChildId,{options:s,gia:"W"}),A("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",e.clickAudioId))}return e.kind==="reference"&&a.push(A("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),e.kind==="grid"&&a.push(A("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",e.cellSizeX,{evidence:"W"}),A("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",e.cellSizeY,{evidence:"W"}),A("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",e.spacingX,{evidence:"W"}),A("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",e.spacingY,{evidence:"W"}),A("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",e.padding1X,{evidence:"W"}),A("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",e.padding1Y,{evidence:"W"}),A("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",e.padding2X,{evidence:"W"}),A("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",e.padding2Y,{evidence:"W"}),A("previewCount","\u9884\u89C8\u6570\u91CF","number",e.previewCount)),e.kind==="keyhint"&&a.push(A("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",e.keyboardKeyCode??e.giaRaw?.keyHintField502??1,{gia:"W"}),A("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",e.controllerKeyCode??e.giaRaw?.keyHintField501??1)),(e.kind==="animation"||e.kind==="fullscreen")&&a.push(A("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),ii.includes(e.kind)||a.push(A("incomplete","\u5B8C\u6574\u5EA6","note","\u672C\u9636\u6BB5\u4EC5\u516C\u5171\u53D8\u6362\uFF0C\u4E1A\u52A1\u69FD\u4E0D\u5B8C\u6574")),{id:e.id,guid:n?.get(e.id)??(e.guid||0),kind:e.kind,label:ht[e.kind]||e.kind,incomplete:!ii.includes(e.kind),fields:a}}function gr(e,t,i){let n=(Array.isArray(e)?e:Object.values(e)).filter(r=>r.kind!=="server-container");for(let r=n.length-1;r>=0;r-=1){let o=n[r];if(!o.visible||!o.active)continue;let a=o.renderMatrix&&ri(o.renderMatrix),s=a&&Ke(a,t,i);if(s&&s.x>=o.left&&s.x<=o.right&&s.y>=o.bottom&&s.y<=o.top)return o.id}return null}import qa from"protobufjs";var ja=String.raw`
|
|
1
|
+
import{existsSync as wo,readFileSync as Jn,realpathSync as Iu}from"node:fs";import{basename as Cu,relative as ku}from"node:path";import{Worker as pu}from"node:worker_threads";import{mkdirSync as mu,readFileSync as gu,writeFileSync as yu}from"node:fs";import{basename as bu,dirname as vu}from"node:path";import{existsSync as Jt,readFileSync as Ml}from"node:fs";import{basename as kt,dirname as Nl,isAbsolute as Fl,join as Ya,resolve as Ba}from"node:path";var re=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),X=Object.freeze({"pc-16-9":{id:"pc-16-9",device:"pc",platform:"KEYBOARD",width:1600,height:900,ratio:"16:9",luaDevice:"KeyboardAndMouse",label:"PC 1600\xD7900"},"pc-21-9":{id:"pc-21-9",device:"pc",platform:"KEYBOARD",width:2100,height:900,ratio:"21:9",luaDevice:"KeyboardAndMouse",label:"PC 2100\xD7900"},"mobile-16-9":{id:"mobile-16-9",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:720,ratio:"16:9",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7720"},"mobile-19.5-9":{id:"mobile-19.5-9",device:"mobile",platform:"TOUCHSCREEN",width:1560,height:720,ratio:"19.5:9",luaDevice:"Mobile",label:"\u624B\u673A 1560\xD7720"},"mobile-4-3":{id:"mobile-4-3",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:960,ratio:"4:3",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7960"}}),ii="pc-16-9",fe=2,ht=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),pt=Object.freeze({"server-container":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",container:"\u5BB9\u5668\u8282\u70B9",textbox:"\u6587\u672C\u6846",image:"\u56FE\u7247",button:"\u9884\u8BBE\u6309\u94AE",cursor:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF",grid:"\u7F51\u683C\u89C6\u7A97",reference:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6",textwindow:"\u6587\u672C\u89C6\u7A97",keyhint:"\u6309\u952E\u63D0\u793A",animation:"\u754C\u9762\u52A8\u6548",fullscreen:"\u5168\u5C4F\u52A8\u6548"}),ni=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),tr=Object.freeze({"server-container":null,container:[150,150],textbox:[100,40],image:[80,80],button:[150,50],cursor:[150,50],grid:[80,80],reference:[80,80],textwindow:[100,40],keyhint:[40,40],animation:[100,100],fullscreen:null}),mt=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"}),ir=50888,Ft=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function gt(e,t="$",i=new Set){if(e===void 0)throw new Error(`undefined at ${t}`);if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`non-finite number at ${t}`);if(typeof e=="bigint"||typeof e=="function"||typeof e=="symbol")throw new Error(`non-JSON value at ${t}`);if(!(e===null||typeof e!="object")){if(i.has(e))throw new Error(`circular value at ${t}`);if(i.add(e),Array.isArray(e))e.forEach((n,r)=>gt(n,`${t}[${r}]`,i));else for(let[n,r]of Object.entries(e))gt(r,`${t}.${n}`,i);i.delete(e)}}function D(e){return gt(e),JSON.parse(JSON.stringify(e))}function nr(e,t="$"){gt(e,t)}function rr(e){return X[e]||X[ii]}function Ot(e,t=0,i=0){return!e||typeof e!="object"?{x:t,y:i}:{x:Number(e.x??t),y:Number(e.y??i)}}function Vo(e){return!e||typeof e!="object"?{x:1,y:1,z:1}:{x:Number(e.x??1),y:Number(e.y??1),z:Number(e.z??1)}}function Yo(e){return!e||typeof e!="object"?{x:0,y:0,z:0}:{x:Number(e.x??0),y:Number(e.y??0),z:Number(e.z??0)}}function ri({layout:e="center",size:t=[100,40],offset:i=[0,0]}={}){return e==="stretch"?{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:0,y:0},anchorMax:{x:1,y:1},offset:{x:0,y:0},size:{x:0,y:0},pivot:{x:.5,y:.5}}:{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:.5,y:.5},anchorMax:{x:.5,y:.5},offset:{x:Number(i[0]??0),y:Number(i[1]??0)},size:{x:Number(t[0]??0),y:Number(t[1]??0)},pivot:{x:.5,y:.5}}}function Ie(e){let t=e||ri();return{scale:Vo(t.scale),rotation:Yo(t.rotation),anchorMin:Ot(t.anchorMin??t.anchor_min,.5,.5),anchorMax:Ot(t.anchorMax??t.anchor_max,.5,.5),offset:Ot(t.offset,0,0),size:Ot(t.size,0,0),pivot:Ot(t.pivot,.5,.5)}}function de(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ae(e,t){let i=e.width,n=e.height,r=e.left,a=e.bottom,o=t.anchorMin||{x:t.anchorMinX,y:t.anchorMinY},s=t.anchorMax||{x:t.anchorMaxX,y:t.anchorMaxY},c=t.offset||{x:t.anchoredPositionX,y:t.anchoredPositionY},l=t.size||{x:t.sizeDeltaX,y:t.sizeDeltaY},f=t.pivot||{x:t.pivotX,y:t.pivotY},h=de(o?.x,.5)*i,p=de(o?.y,.5)*n,m=de(s?.x,.5)*i,g=de(s?.y,.5)*n,I=de(l?.x),k=de(l?.y),E=de(f?.x,.5),$=de(f?.y,.5),O=m-h+I,Y=g-p+k,W=r+h+de(c?.x)-I*E,Z=a+p+de(c?.y)-k*$;return{left:W,bottom:Z,width:O,height:Y,right:W+O,top:Z+Y,centerX:W+O/2,centerY:Z+Y/2}}function yt(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function Bo(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,tx:e.a*t.tx+e.c*t.ty+e.tx,ty:e.b*t.tx+e.d*t.ty+e.ty}}function Xe(e,t,i){return{x:e.a*t+e.c*i+e.tx,y:e.b*t+e.d*i+e.ty}}function ai(e){let t=e.a*e.d-e.b*e.c;return!Number.isFinite(t)||Math.abs(t)<1e-8?null:{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,tx:(e.c*e.ty-e.d*e.tx)/t,ty:(e.b*e.tx-e.a*e.ty)/t}}function zi(e,t){let i=t.rotation||{z:t.localRotationZ},n=t.scale||{x:t.localScaleX,y:t.localScaleY},r=t.pivot||{x:t.pivotX,y:t.pivotY},a=de(i?.z)*Math.PI/180,o=Math.cos(a),s=Math.sin(a),c=de(n?.x,1),l=de(n?.y,1),f=e.left+e.width*de(r?.x,.5),h=e.bottom+e.height*de(r?.y,.5),p=o*c,m=s*c,g=-s*l,I=o*l;return{a:p,b:m,c:g,d:I,tx:f-p*f-g*h,ty:h-m*f-I*h}}function $t(e,t,i){return Bo(e||yt(),zi(t,i))}function ar(e,t){let i=Xe(t,e.centerX,e.centerY),n=Math.abs(e.width*Math.hypot(t.a,t.b)),r=Math.abs(e.height*Math.hypot(t.c,t.d));return{left:i.x-n/2,bottom:i.y-r/2,width:n,height:r,centerX:i.x,centerY:i.y,rotationZ:Math.atan2(t.b,t.a)*180/Math.PI}}function he(e){let t=typeof e=="string"?rr(e):e;return{left:0,bottom:0,width:t.width,height:t.height,right:t.width,top:t.height,centerX:t.width/2,centerY:t.height/2}}function Vi(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function Ke(e,t,i){let n=Ie(t),r=e.width,a=e.height,o=n.anchorMin.x*r,s=n.anchorMin.y*a,c=n.anchorMax.x*r,l=n.anchorMax.y*a,f=Number(i.width),h=Number(i.height),p=Number(i.posX),m=Number(i.posY),g=p-f/2,I=m-h/2;return n.size={x:f-(c-o),y:h-(l-s)},n.offset={x:g-e.left-o+n.size.x*n.pivot.x,y:I-e.bottom-s+n.size.y*n.pivot.y},n}function or(e,t){let i=Ie(e),r={"bottom-left":[[0,0],[0,0],[0,0]],bottom:[[.5,0],[.5,0],[.5,0]],"bottom-right":[[1,0],[1,0],[1,0]],left:[[0,.5],[0,.5],[0,.5]],center:[[.5,.5],[.5,.5],[.5,.5]],right:[[1,.5],[1,.5],[1,.5]],"top-left":[[0,1],[0,1],[0,1]],top:[[.5,1],[.5,1],[.5,1]],"top-right":[[1,1],[1,1],[1,1]],stretch:[[0,0],[1,1],[.5,.5]],"stretch-horizontal":[[0,.5],[1,.5],[.5,.5]],"stretch-vertical":[[.5,0],[.5,1],[.5,.5]]}[t];return r&&(i.anchorMin={x:r[0][0],y:r[0][1]},i.anchorMax={x:r[1][0],y:r[1][1]},i.pivot={x:r[2][0],y:r[2][1]}),i}function sr(e){let t=Ie(e),i=(n,r)=>Math.abs(n-r)<1e-4;if(i(t.anchorMin.x,0)&&i(t.anchorMin.y,0)&&i(t.anchorMax.x,1)&&i(t.anchorMax.y,1))return"stretch";if(i(t.anchorMin.x,t.anchorMax.x)&&i(t.anchorMin.y,t.anchorMax.y)){let n=t.anchorMin.x,r=t.anchorMin.y,a=[[0,0,"bottom-left"],[.5,0,"bottom"],[1,0,"bottom-right"],[0,.5,"left"],[.5,.5,"center"],[1,.5,"right"],[0,1,"top-left"],[.5,1,"top"],[1,1,"top-right"]];for(let o of a)if(i(n,o[0])&&i(r,o[1]))return o[2]}return"custom"}function We(e){return rr(e).platform}function lr(e){let t={};for(let i of re)t[i]=e(i);return t}var Uo={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function ur(e,t){for(let[i,n]of Object.entries(Uo))for(let r of n)if(!Number.isFinite(e?.[i]?.[r]))throw new Error(`${t}.${i}.${r} must be a finite number`)}function Fe(e,t="transformByPlatform"){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: \u9700\u8981\u5B8C\u6574\u7684\u56DB\u5E73\u53F0\u5E03\u5C40`);for(let i of Object.keys(e))if(!re.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of re)ur(e[i],`${t}.${i}`)}function qe(e){if(Object.hasOwn(e,"transformByCanvas"))throw new Error(`${e.name||e.id||"\u63A7\u4EF6"}: \u4E0D\u518D\u652F\u6301 transformByCanvas\uFF1B\u8BF7\u4F7F\u7528\u56DB\u5E73\u53F0 transformByPlatform \u5E03\u5C40`);Fe(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function je(e,t){if(!re.includes(t))throw new Error(`unknown platform ${t}`);return ur(e?.[t],`transformByPlatform.${t}`),Ie(e[t])}var Ho=Object.freeze([{key:"genericField501",label:"\u901A\u7528\u69FD field501",type:"number",defaultValue:0,wire:"GenericSlot.field501"},{key:"footerField505",label:"\u5C3E\u90E8\u69FD field505",type:"number",defaultValue:0,wire:"FooterSlot.field505"}]),Lo=Object.freeze({container:[],textbox:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]}],textwindow:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]},{key:"textField511",label:"\u6587\u672C\u89C6\u7A97 field511",type:"number",defaultValue:1,wire:"TextConfig.field511"},{key:"textViewField502",label:"\u89C6\u7A97\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field502"},{key:"textViewField503",label:"\u89C6\u7A97\u6807\u8BB0 field503",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field503"}],cursor:[{key:"cursorField501",label:"\u5149\u6807\u68C0\u6D4B field501",type:"number",defaultValue:1,wire:"CursorConfig.field501"}],reference:[{key:"templateRefSlot",label:"\u6A21\u677F\u5F15\u7528\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.templateRefSlot"}],grid:[{key:"gridField501",label:"\u7F51\u683C\u6807\u8BB0 field501",type:"number",defaultValue:1,wire:"GridViewConfig.field501"},{key:"gridField507",label:"\u7F51\u683C\u6807\u8BB0 field507",type:"number",defaultValue:1,wire:"GridViewConfig.field507"},{key:"gridField508",label:"\u7F51\u683C\u6807\u8BB0 field508",type:"number",defaultValue:1,wire:"GridViewConfig.field508"},{key:"gridField509",label:"\u7F51\u683C\u6807\u8BB0 field509",type:"number",defaultValue:1,wire:"GridViewConfig.field509"},{key:"gridField511",label:"\u7F51\u683C\u6807\u8BB0 field511",type:"number",defaultValue:5,wire:"GridViewConfig.field511"},{key:"gridField512",label:"\u7F51\u683C\u6807\u8BB0 field512",type:"number",defaultValue:1,wire:"GridViewConfig.field512"}],keyhint:[{key:"keyHintField501",label:"\u6309\u952E\u63D0\u793A field501",type:"number",defaultValue:1,wire:"KeyHintConfig.field501"},{key:"keyHintField502",label:"\u952E\u9F20\u952E\u4F4D\u539F\u59CB\u503C",type:"number",defaultValue:1,wire:"KeyHintConfig.field502"}],image:[{key:"imageField502",label:"\u56FE\u7247\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"ImageConfig.field502"},{key:"imageField504",label:"\u56FE\u7247\u6807\u8BB0 field504",type:"number",defaultValue:1,wire:"ImageConfig.field504"},{key:"imageField505",label:"\u56FE\u7247\u6807\u8BB0 field505",type:"number",defaultValue:1,wire:"ImageConfig.field505"},{key:"imageField507",label:"\u56FE\u7247\u6807\u8BB0 field507",type:"number",defaultValue:2,wire:"ImageConfig.field507"},{key:"imageFillType",label:"\u586B\u5145\u5F62\u72B6\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:1,wire:"ImageConfig.fillType",options:[{value:1,label:"1 \xB7 \u6A2A\u5411"},{value:2,label:"2 \xB7 \u7EB5\u5411"},{value:3,label:"3 \xB7 90\u5EA6\u73AF\u7ED5"},{value:4,label:"4 \xB7 180\u5EA6\u73AF\u7ED5"},{value:5,label:"5 \xB7 360\u5EA6\u73AF\u7ED5"}]}],animation:[{key:"effectSlot",label:"\u754C\u9762\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.effectSlot"}],fullscreen:[{key:"fullscreenEffectSlot",label:"\u5168\u5C4F\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.fullscreenEffectSlot"}]});function cr(e){return[...Ho,...Lo[e]||[]]}function fr(e,t){return cr(e).find(i=>i.key===t)||null}function Yi(e,t){if(!e)throw new Error("unknown raw GIA field");if(e.type==="string")return String(t??"");let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e.wire} must be a finite number`);return Math.trunc(i)}function dr(e,t={}){let i={};for(let n of cr(e)){let r=Object.hasOwn(t||{},n.key)?t[n.key]:n.defaultValue;i[n.key]=Yi(n,r)}return i}function Ce(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Bi(e,t){if(e){t(e);for(let i of e.children||[])Bi(i,t)}}function bt(e,t=new Set,{skipServerContainer:i=!1}={}){return Bi(e,n=>{i&&n.kind==="server-container"||Ce(n.guid)&&t.add(Number(n.guid))}),t}function Oe(e,t=1073741850){let i=Number.isSafeInteger(t)&&t>0?t:1073741850;i<1073741850&&(i=1073741850);for(let n of e)Ce(n)&&n>=i&&(i=Number(n)+1);for(;e.has(i);)i+=1;if(i>2147483647)throw new Error("GUID space exhausted");return i}function hr(e,t=new Set,{skipServerContainer:i=!1}={}){let n=[];Bi(e,r=>{if(i&&r.kind==="server-container")return;let a=Number(r.guid);if(Ce(a)&&!t.has(a)){t.add(a),r.guid=a;return}n.push(r)});for(let r of n){let a=Oe(t);r.guid=a,t.add(a)}return t}var Ui=1;function Hi(e="n"){let t=`${e}${Ui}`;return Ui+=1,t}function oi(e=1){Ui=e}function Li(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return ri({layout:"stretch"});let i=tr[e]||[80,80];return ri({layout:"center",size:i})}function Xo(e,t){return lr(()=>Li(e,t))}function Ko(e){Fe(e);let t={};for(let i of re)t[i]=je(e,i);return t}function H(e,t={}){if(!pt[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&&qe(t);let i=t.isRootContainer===!0,n=t.id||Hi(e==="server-container"?"sc":"n"),r=Object.hasOwn(t,"transformByPlatform")?Ko(t.transformByPlatform):Xo(e,{isRootContainer:i}),a={id:n,kind:e,name:t.name||pt[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(o=>Number.isSafeInteger(Number(o))&&Number(o)>0).map(Number):[],...Number.isSafeInteger(Number(t.giaInfoIndex))&&Number(t.giaInfoIndex)>0?{giaInfoIndex:Number(t.giaInfoIndex)}:{},active:t.active!==!1,visible:t.visible!==!1,canControllerFocus:t.canControllerFocus??t.giaRaw?.footerField505===1,syncAllDevices:t.syncAllDevices!==!1,giaRaw:dr(e,t.giaRaw),transformByPlatform:r,children:[],scriptMappingIds:Array.isArray(t.scriptMappingIds)?t.scriptMappingIds.filter(o=>Number.isSafeInteger(Number(o))&&Number(o)>0).map(Number):[]};if(e==="container"&&(a.isolateNavigation=t.isolateNavigation===!0,a.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,a.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,a.showCursor=t.showCursor===!0),(e==="textbox"||e==="textwindow")&&(a.fontSize=t.fontSize??20,a.adaptiveFontSize=t.adaptiveFontSize===!0,a.minimumFontSize=t.minimumFontSize??20,a.fontColor=t.fontColor??Ft.font,a.bgColor=t.bgColor??Ft.bg,a.enableOutline=t.enableOutline!==!1,a.outlineColor=t.outlineColor??Ft.outline,a.horizontalAlignment=t.horizontalAlignment||"Left",a.verticalAlignment=t.verticalAlignment||"Top",Number.isInteger(t.giaRaw?.textVerticalAlign)&&![0,1,2].includes(t.giaRaw.textVerticalAlign)&&(a.giaRaw.textVerticalAlign=t.giaRaw.textVerticalAlign),a.text=t.text??"",Object.hasOwn(t.giaRaw||{},"textAlign")||(a.giaRaw.textAlign={Left:0,Middle:1,Right:2}[a.horizontalAlignment]??a.giaRaw.textAlign),e==="textwindow"&&(a.interactable=t.interactable!==!1,a.showScrollBar=t.showScrollBar!==!1)),e==="image"&&(a.imageSource=t.imageSource||"StaticReference",a.imageId=t.imageId??100001,a.imageColor=t.imageColor??Ft.image,a.enableMask=t.enableMask===!0,a.enableSoftEdge=t.enableSoftEdge===!0,a.softEdgeMode=t.softEdgeMode||"Percentage",a.softEdgeWidthX=t.softEdgeWidthX??8,a.softEdgeWidthY=t.softEdgeWidthY??8,a.horizontalSoftRange=t.horizontalSoftRange??85,a.verticalSoftRange=t.verticalSoftRange??85,a.enableFill=t.enableFill===!0,a.fillType=t.fillType||"Horizontal",a.fillHorizontalType=t.fillHorizontalType||"Left",a.fillVerticalType=t.fillVerticalType||"Bottom",a.fillRadial90Type=t.fillRadial90Type||"BottomLeft",a.fillRadialType=t.fillRadialType||"Bottom",a.fillAmount=t.fillAmount??1,a.reverseMaskArea=t.reverseMaskArea===!0||t.reverseMask===!0,Object.hasOwn(t.giaRaw||{},"imageFillType")||(a.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[a.fillType]??a.giaRaw.imageFillType)),e==="button"&&(a.raycastTarget=t.raycastTarget!==!1,a.interactable=t.interactable!==!1,a.clickAudioId=t.clickAudioId??ir,a.unavailableChildId=t.unavailableChildId??null,a.hoverChildId=t.hoverChildId??null,a.pressedChildId=t.pressedChildId??null,a.selectedChildId=t.selectedChildId??null),e==="cursor"&&(a.raycastTarget=t.raycastTarget??t.giaRaw?.cursorField501!==0),e==="reference"&&(a.referencedPrefabId=t.referencedPrefabId??t.giaRaw?.templateRefSlot??null,Object.hasOwn(t.giaRaw||{},"templateRefSlot")||(a.giaRaw.templateRefSlot=String(a.referencedPrefabId??""))),e==="grid"&&(a.itemPrefabId=t.itemPrefabId??null,a.raycastTarget=t.raycastTarget!==!1,a.interactable=t.interactable!==!1,a.showScrollBar=t.showScrollBar!==!1,a.scrollDirection=t.scrollDirection||"Vertical",a.layoutConstraint=t.layoutConstraint||"AutoWrap",a.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,a.cellSizeX=t.cellSizeX??50,a.cellSizeY=t.cellSizeY??50,a.spacingX=t.spacingX??8,a.spacingY=t.spacingY??8,a.padding1X=t.padding1X??20,a.padding1Y=t.padding1Y??20,a.padding2X=t.padding2X??20,a.padding2Y=t.padding2Y??20,a.previewCount=t.previewCount??t.giaRaw?.gridField511??5,Object.hasOwn(t.giaRaw||{},"gridField511")||(a.giaRaw.gridField511=Math.trunc(a.previewCount))),e==="keyhint"&&(a.keyboardKeyCode=t.keyboardKeyCode??t.giaRaw?.keyHintField502??null,a.controllerKeyCode=t.controllerKeyCode??t.giaRaw?.keyHintField501??null,Object.hasOwn(t.giaRaw||{},"keyHintField502")||(a.giaRaw.keyHintField502=Math.trunc(a.keyboardKeyCode??1)),Object.hasOwn(t.giaRaw||{},"keyHintField501")||(a.giaRaw.keyHintField501=Math.trunc(a.controllerKeyCode??1))),e==="animation"||e==="fullscreen"){let o=e==="animation"?t.giaRaw?.effectSlot:t.giaRaw?.fullscreenEffectSlot;a.animationId=t.animationId??o??null,a.playSoundEffect=t.playSoundEffect??null,e==="animation"&&(a.layer=t.layer??null);let s=e==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(t.giaRaw||{},s)||(a.giaRaw[s]=String(a.animationId??""))}if(t.children)for(let o of t.children)a.children.push(o);return a}function De(){oi(1);let e=H("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),t=H("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=H("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),n=H("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),r=H("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),a=H("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),o=H("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),s=H("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),c=H("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),l=H("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),f=H("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),h=H("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),p=(m,g,I)=>{for(let k of Object.values(m.transformByPlatform))k.offset={x:g,y:I}};return p(i,-300,250),p(n,-300,140),p(r,-300,30),p(a,-300,-100),p(o,0,0),p(s,300,250),p(c,300,140),p(l,300,30),p(f,300,-100),t.children.push(i,n,r,a,o,s,c,l,f,h),e.children.push(t),oi(12),hr(e),{version:1,layoutSchemaVersion:fe,meta:{name:"\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"authoring",sourceFile:""},canvasId:"pc-16-9",selectedId:"n2",root:e}}function Je(){oi(1);let e=H("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),t=H("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=H("textbox",{id:"n2",guid:1073742101,name:"\u6A21\u677F\u6807\u9898",text:"\u5BA2\u6237\u7AEF\u6A21\u677F\u5DF2\u5B9E\u4F8B\u5316",fontSize:28,horizontalAlignment:"Middle"}),n=H("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),r=H("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),a=H("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),o=(c,l,f)=>{for(let h of Object.values(c.transformByPlatform))h.offset={x:l,y:f}};return((c,l,f)=>{for(let h of Object.values(c.transformByPlatform))h.size={x:l,y:f}})(t,520,320),o(i,0,110),o(n,0,0),o(r,0,-110),r.children.push(a),t.children.push(i,n,r),e.children.push(t),oi(6),{version:1,layoutSchemaVersion:fe,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:"7.0.50",giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:e}}function J(e,t,i=null){t(e,i);for(let n of e.children||[])J(n,t,e)}function ue(e,t){let i=null;return J(e,n=>{n.id===t&&(i=n)}),i}function Xi(e,t="n"){let i=Hi(t);for(;ue(e,i);)i=Hi(t);return i}function $e(e,t){let i=null;return J(e,(n,r)=>{n.id===t&&(i=r)}),i}function Ki(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function Dt(e){if(e.meta?.assetType!=="client-control-template")return Ki(e);let t=ue(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=$e(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=$e(e.root,t.id);return t}function Wi(e){qe(e);let t={id:e.id,name:e.name,guid:e.guid,giaRelatedGuids:e.giaRelatedGuids,giaInfoIndex:e.giaInfoIndex,scriptMappingIds:e.scriptMappingIds,giaRaw:e.giaRaw,active:e.active,visible:e.visible,canControllerFocus:e.canControllerFocus,syncAllDevices:e.syncAllDevices,transformByPlatform:e.transformByPlatform};e.kind==="container"&&(t.isolateNavigation=e.isolateNavigation,t.disableKeyEventPassthrough=e.disableKeyEventPassthrough,t.disableCursorEventPassthrough=e.disableCursorEventPassthrough,t.showCursor=e.showCursor),(e.kind==="textbox"||e.kind==="textwindow")&&(t.fontSize=e.fontSize,t.adaptiveFontSize=e.adaptiveFontSize,t.minimumFontSize=e.minimumFontSize,t.fontColor=e.fontColor,t.bgColor=e.bgColor,t.enableOutline=e.enableOutline,t.outlineColor=e.outlineColor,t.horizontalAlignment=e.horizontalAlignment,t.verticalAlignment=e.verticalAlignment,t.text=e.text??"",e.kind==="textwindow"&&(t.interactable=e.interactable,t.showScrollBar=e.showScrollBar)),e.kind==="image"&&(t.imageSource=e.imageSource,t.imageId=e.imageId,t.imageColor=e.imageColor,t.enableMask=e.enableMask,t.enableSoftEdge=e.enableSoftEdge,t.softEdgeMode=e.softEdgeMode,t.softEdgeWidthX=e.softEdgeWidthX,t.softEdgeWidthY=e.softEdgeWidthY,t.horizontalSoftRange=e.horizontalSoftRange,t.verticalSoftRange=e.verticalSoftRange,t.enableFill=e.enableFill,t.fillType=e.fillType,t.fillHorizontalType=e.fillHorizontalType,t.fillVerticalType=e.fillVerticalType,t.fillRadial90Type=e.fillRadial90Type,t.fillRadialType=e.fillRadialType,t.fillAmount=e.fillAmount,t.reverseMaskArea=e.reverseMaskArea??e.reverseMask),e.kind==="button"&&(t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.clickAudioId=e.clickAudioId,t.unavailableChildId=e.unavailableChildId??null,t.hoverChildId=e.hoverChildId??null,t.pressedChildId=e.pressedChildId??null,t.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(t.raycastTarget=e.raycastTarget),e.kind==="reference"&&(t.referencedPrefabId=e.referencedPrefabId??null),e.kind==="grid"&&(t.itemPrefabId=e.itemPrefabId??null,t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.showScrollBar=e.showScrollBar,t.scrollDirection=e.scrollDirection,t.layoutConstraint=e.layoutConstraint,t.layoutConstraintFixedCount=e.layoutConstraintFixedCount??null,t.cellSizeX=e.cellSizeX,t.cellSizeY=e.cellSizeY,t.spacingX=e.spacingX,t.spacingY=e.spacingY,t.padding1X=e.padding1X,t.padding1Y=e.padding1Y,t.padding2X=e.padding2X,t.padding2Y=e.padding2Y,t.previewCount=e.previewCount),e.kind==="keyhint"&&(t.keyboardKeyCode=e.keyboardKeyCode??null,t.controllerKeyCode=e.controllerKeyCode??null),(e.kind==="animation"||e.kind==="fullscreen")&&(t.animationId=e.animationId??null,t.playSoundEffect=e.playSoundEffect??null,e.kind==="animation"&&(t.layer=e.layer??null)),t.isRootContainer=e.kind==="container"&&Wo(e.transformByPlatform);let i=H(e.kind,t);return i.children=(e.children||[]).map(n=>Wi(n)),i}function Wo(e){let t=e&&(e.KEYBOARD||Object.values(e)[0]);return t?Math.abs(t.anchorMin?.x??.5)<1e-4&&Math.abs(t.anchorMin?.y??.5)<1e-4&&Math.abs((t.anchorMax?.x??.5)-1)<1e-4&&Math.abs((t.anchorMax?.y??.5)-1)<1e-4:!1}function pr(e,t,i={}){if(e.kind==="server-container"&&t!=="container")throw new Error("server container only accepts container nodes");let n=H(t,i);return e.children.push(n),n}function mr(e,t){if(e.id===t)throw new Error("cannot remove root");let i=$e(e,t);if(!i)return!1;let n=i.children.findIndex(r=>r.id===t);return n<0?!1:(i.children.splice(n,1),!0)}var gr=1e-4;function qo(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>gr&&Math.abs(e.size[t])<=gr}function jo(e,t,i){if(!(t.width>0)||!(t.height>0))throw new Error("source parent must have positive size");if(!(i.width>0)||!(i.height>0))throw new Error("target parent must have positive size");let n=Ae(t,e),r=(n.centerX-t.left)/t.width,a=(n.centerY-t.bottom)/t.height,o=Ke(i,e,{posX:i.left+r*i.width,posY:i.bottom+a*i.height,width:n.width,height:n.height});for(let s of["x","y"])qo(e,s)&&(o.offset[s]=e.offset[s],o.size[s]=e.size[s]);return o}function yr({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:n,sourceParentBox:r=he(i),targetParentBoxByPlatform:a={}}){Fe(e);let o=We(i),s={};for(let c of re)c===o?s[c]=Ie(t):n!==!1?s[c]=jo(t,r,a[c]||he(ht[c])):s[c]=je(e,c);return Fe(s),s}function Ge(e,t){return je(e,We(t))}function br(e,t){let i=[];function n(r){t[r.id]&&i.push(t[r.id]);let a=r.children||[];for(let o=a.length-1;o>=0;o-=1)n(a[o])}return n(e),i}function ze(e,t,i=We(t)){let n=he(t),r={};function a(o,s,c){let l=je(o.transformByPlatform,i),f=Ae(s,l),h=o.kind==="server-container"?c:$t(c,f,l),p=ar(f,h);r[o.id]={...f,...Vi(f),id:o.id,kind:o.kind,name:o.name,visible:o.visible!==!1,active:o.active!==!1,rotationZ:l.rotation.z,renderLeft:p.left,renderBottom:p.bottom,renderWidth:p.width,renderHeight:p.height,renderRotationZ:p.rotationZ,renderMatrix:h,primitive:o.kind==="image"?mt[o.imageId]||"missing":null,...o.kind==="textbox"||o.kind==="textwindow"?{text:o.text??"",fontSize:o.fontSize,fontColor:o.fontColor,bgColor:o.bgColor,enableOutline:o.enableOutline!==!1,outlineColor:o.outlineColor,horizontalAlignment:o.horizontalAlignment,verticalAlignment:o.verticalAlignment}:{},...o.kind==="image"?{imageSource:o.imageSource,imageId:o.imageId,imageColor:o.imageColor,enableMask:o.enableMask===!0,enableSoftEdge:o.enableSoftEdge===!0,softEdgeMode:o.softEdgeMode,softEdgeWidthX:o.softEdgeWidthX,softEdgeWidthY:o.softEdgeWidthY,horizontalSoftRange:o.horizontalSoftRange,verticalSoftRange:o.verticalSoftRange,enableFill:o.enableFill===!0,fillType:o.fillType,fillHorizontalType:o.fillHorizontalType,fillVerticalType:o.fillVerticalType,fillRadial90Type:o.fillRadial90Type,fillRadialType:o.fillRadialType,fillAmount:o.fillAmount,reverseMaskArea:o.reverseMaskArea===!0}:{},...o.kind==="button"?{raycastTarget:o.raycastTarget!==!1,interactable:o.interactable!==!1,clickAudioId:o.clickAudioId,unavailableChildId:o.unavailableChildId??null,hoverChildId:o.hoverChildId??null,pressedChildId:o.pressedChildId??null,selectedChildId:o.selectedChildId??null}:{}};let m=o.kind==="server-container"?s:f;for(let g of o.children||[])a(g,m,h)}return a(e,n,yt()),{canvas:n,boxes:r}}function qi(e,t){let i=[];function n(r,a,o=null,s=[],c=0,l=1,f=e.id){i.push({id:r.id,guid:t?.get(r.id)??(r.guid||0),kind:r.kind,name:r.name,label:pt[r.kind]||r.kind,depth:a,parentId:o,ancestorIds:s,siblingIndex:c,siblingCount:l,templateId:f,childCount:(r.children||[]).length,incomplete:!ni.includes(r.kind)});let h=r.children||[];for(let p=0;p<h.length;p+=1)n(h[p],a+1,r.id,[...s,r.id],p,h.length,f)}return n(e,0),i}function A(e,t,i,n,r={}){return{key:e,label:t,type:i,value:n,...r}}function vr(e,t,i,n){if(!e)return null;let r=Ge(e.transformByPlatform,t),a=Vi(i),o=[A("name","\u540D\u79F0","string",e.name),A("active","\u521D\u59CB\u6FC0\u6D3B","bool",e.active!==!1),A("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",e.visible!==!1),A("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",e.canControllerFocus===!0),A("posX","\u4F4D\u7F6E X","number",a.posX,{computed:!0}),A("posY","\u4F4D\u7F6E Y","number",a.posY,{computed:!0}),A("width","\u5927\u5C0F W","number",a.width,{computed:!0}),A("height","\u5927\u5C0F H","number",a.height,{computed:!0}),A("rotationZ","\u65CB\u8F6C Z","number",r.rotation.z),A("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",e.syncAllDevices!==!1),A("anchorType","\u951A\u70B9\u7C7B\u578B","enum",sr(r),{options:[{value:"center",label:"\u5C45\u4E2D"},{value:"top-left",label:"\u5DE6\u4E0A"},{value:"top",label:"\u4E0A\u65B9"},{value:"top-right",label:"\u53F3\u4E0A"},{value:"left",label:"\u5DE6\u4FA7"},{value:"right",label:"\u53F3\u4FA7"},{value:"bottom-left",label:"\u5DE6\u4E0B"},{value:"bottom",label:"\u4E0B\u65B9"},{value:"bottom-right",label:"\u53F3\u4E0B"},{value:"stretch",label:"\u53CC\u5411\u62C9\u4F38"},{value:"stretch-horizontal",label:"\u6C34\u5E73\u62C9\u4F38"},{value:"stretch-vertical",label:"\u5782\u76F4\u62C9\u4F38"},{value:"custom",label:"\u81EA\u5B9A\u4E49"}]}),A("anchorMinX","\u951A\u70B9 Min X","number",r.anchorMin.x),A("anchorMinY","\u951A\u70B9 Min Y","number",r.anchorMin.y),A("anchorMaxX","\u951A\u70B9 Max X","number",r.anchorMax.x),A("anchorMaxY","\u951A\u70B9 Max Y","number",r.anchorMax.y),A("pivotX","\u4E2D\u5FC3 X","number",r.pivot.x),A("pivotY","\u4E2D\u5FC3 Y","number",r.pivot.y)];if(e.kind==="container"&&o.push(A("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",e.isolateNavigation===!0),A("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableKeyEventPassthrough===!0),A("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableCursorEventPassthrough===!0),A("showCursor","\u663E\u793A\u5E38\u9A7B\u5149\u6807","bool",e.showCursor===!0)),e.kind==="textbox"||e.kind==="textwindow"){let s=e.giaRaw?.textAlign,c=[0,1,2].includes(s)?e.horizontalAlignment||"Left":`__unrecognized:${s}`;o.push(A("fontSize","\u5B57\u53F7","number",e.fontSize),A("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",e.adaptiveFontSize===!0),A("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",e.minimumFontSize),A("fontColor","\u6587\u672C\u8272","color",e.fontColor),A("bgColor","\u80CC\u666F\u8272","color",e.bgColor),A("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",e.enableOutline!==!1),A("outlineColor","\u63CF\u8FB9\u8272","color",e.outlineColor),A("horizontalAlignment","\u6C34\u5E73\u5BF9\u9F50","enum",c,{...[0,1,2].includes(s)?{}:{unknownValue:s},options:[{value:"Left",label:"\u5DE6\u5BF9\u9F50"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Right",label:"\u53F3\u5BF9\u9F50"}]}),A("verticalAlignment","\u5782\u76F4\u5BF9\u9F50","enum",e.verticalAlignment||"Top",{options:[{value:"Top",label:"\u9876\u90E8"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Bottom",label:"\u5E95\u90E8"}]}),A("text","\u6587\u672C","text",e.text??""))}if(e.kind==="image"){let s=e.giaRaw?.imageFillType,c=[1,2,3,4,5].includes(s)?e.fillType:`__unrecognized:${s}`;o.push(A("imageSource","\u56FE\u7247\u6E90","enum",e.imageSource,{readonly:!0,evidence:"W",options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"}]}),A("imageId","imageId","number",e.imageId??0),A("imageColor","\u586B\u5145\u8272","color",e.imageColor),A("enableMask","\u5F00\u542F\u906E\u7F69","bool",e.enableMask===!0),A("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",e.enableSoftEdge===!0,{gia:"W"}),A("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",e.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),A("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",e.softEdgeWidthX),A("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",e.softEdgeWidthY),A("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",e.horizontalSoftRange),A("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",e.verticalSoftRange),A("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",e.enableFill===!0,{gia:"W"}),A("fillType","\u5F62\u72B6","enum",c,{...[1,2,3,4,5].includes(s)?{}:{unknownValue:s},options:[{value:"Horizontal",label:"\u6A2A\u5411"},{value:"Vertical",label:"\u7EB5\u5411"},{value:"Radial90",label:"90\u5EA6\u73AF\u7ED5"},{value:"Radial180",label:"180\u5EA6\u73AF\u7ED5"},{value:"Radial360",label:"360\u5EA6\u73AF\u7ED5"}]}),A("fillHorizontalType","\u65B9\u5411","enum",e.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),A("fillVerticalType","\u65B9\u5411","enum",e.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),A("fillRadial90Type","\u8D77\u70B9","enum",e.fillRadial90Type,{options:[{value:"BottomLeft",label:"\u5DE6\u4E0B"},{value:"TopLeft",label:"\u5DE6\u4E0A"},{value:"TopRight",label:"\u53F3\u4E0A"},{value:"BottomRight",label:"\u53F3\u4E0B"}]}),A("fillRadialType","\u8D77\u70B9","enum",e.fillRadialType,{options:[{value:"Bottom",label:"\u4E0B\u65B9"},{value:"Left",label:"\u5DE6\u4FA7"},{value:"Top",label:"\u4E0A\u65B9"},{value:"Right",label:"\u53F3\u4FA7"}]}),A("fillAmount","\u8FDB\u5EA6","percent",e.fillAmount),A("reverseMaskArea","\u906E\u7F69\u533A\u57DF\u53CD\u8F6C","bool",e.reverseMaskArea===!0,{gia:"W"}))}if(e.kind==="button"){let s=[{value:"",label:"\u672A\u8BBE\u7F6E"},...(e.children||[]).map(c=>({value:c.id,label:`${c.name} \xB7 ${c.id}`}))];o.push(A("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),A("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",e.interactable!==!1),A("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",e.unavailableChildId,{options:s,gia:"W"}),A("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",e.hoverChildId,{options:s,gia:"W"}),A("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",e.pressedChildId,{options:s,gia:"W"}),A("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",e.selectedChildId,{options:s,gia:"W"}),A("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",e.clickAudioId))}return e.kind==="reference"&&o.push(A("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),e.kind==="grid"&&o.push(A("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",e.cellSizeX,{evidence:"W"}),A("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",e.cellSizeY,{evidence:"W"}),A("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",e.spacingX,{evidence:"W"}),A("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",e.spacingY,{evidence:"W"}),A("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",e.padding1X,{evidence:"W"}),A("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",e.padding1Y,{evidence:"W"}),A("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",e.padding2X,{evidence:"W"}),A("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",e.padding2Y,{evidence:"W"}),A("previewCount","\u9884\u89C8\u6570\u91CF","number",e.previewCount)),e.kind==="keyhint"&&o.push(A("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",e.keyboardKeyCode??e.giaRaw?.keyHintField502??1,{gia:"W"}),A("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",e.controllerKeyCode??e.giaRaw?.keyHintField501??1)),(e.kind==="animation"||e.kind==="fullscreen")&&o.push(A("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),ni.includes(e.kind)||o.push(A("incomplete","\u5B8C\u6574\u5EA6","note","\u672C\u9636\u6BB5\u4EC5\u516C\u5171\u53D8\u6362\uFF0C\u4E1A\u52A1\u69FD\u4E0D\u5B8C\u6574")),{id:e.id,guid:n?.get(e.id)??(e.guid||0),kind:e.kind,label:pt[e.kind]||e.kind,incomplete:!ni.includes(e.kind),fields:o}}function Sr(e,t,i){let n=(Array.isArray(e)?e:Object.values(e)).filter(r=>r.kind!=="server-container");for(let r=n.length-1;r>=0;r-=1){let a=n[r];if(!a.visible||!a.active)continue;let o=a.renderMatrix&&ai(a.renderMatrix),s=o&&Xe(o,t,i);if(s&&s.x>=a.left&&s.x<=a.right&&s.y>=a.bottom&&s.y<=a.top)return a.id}return null}import Jo from"protobufjs";var Zo=String.raw`
|
|
2
2
|
syntax = "proto3";
|
|
3
3
|
// Root.graph is singular in the game's canonical schema, but template-list
|
|
4
4
|
// assets legally emit field 1 more than once. Model it as repeated here so
|
|
@@ -34,7 +34,7 @@ message UiControlGroup {
|
|
|
34
34
|
oneof value {
|
|
35
35
|
Transform transform = 13; Field14 field14 = 14; RootChildRef rootChildRef = 73;
|
|
36
36
|
GenericSlot genericSlot = 74; TextConfig textConfig = 75; CursorConfig cursorConfig = 76;
|
|
37
|
-
string templateRefSlot = 77; FooterSlot footerSlot = 78;
|
|
37
|
+
string templateRefSlot = 77; FooterSlot footerSlot = 78; ContainerNodeConfig containerNodeSlot = 79;
|
|
38
38
|
GridViewConfig gridView = 80; ButtonPresetConfig buttonPreset = 81; KeyHintConfig keyHint = 83;
|
|
39
39
|
ImageSlotConfig imageSlot = 84; ImageConfig image = 85; string effectSlot = 86;
|
|
40
40
|
string fullscreenEffectSlot = 87;
|
|
@@ -48,11 +48,13 @@ message WrapperInt32 { int32 value = 501; }
|
|
|
48
48
|
message WrapperGuid { uint32 value = 501; }
|
|
49
49
|
message WrapperGuidList { repeated uint32 value = 501; }
|
|
50
50
|
message NodeRef { int32 class = 2; int32 type = 3; int32 id = 4; }
|
|
51
|
-
message Field14 { optional string empty15 = 15;
|
|
51
|
+
message Field14 { optional string empty15 = 15; ClientInitialState field17 = 17; int32 field501 = 501; bool initiallyInactive = 502; }
|
|
52
|
+
message ContainerNodeConfig { bool isolateNavigation = 501; bool disableKeyEventPassthrough = 502; bool disableCursorEventPassthrough = 503; bool showCursor = 504; }
|
|
53
|
+
message ClientInitialState { bool initiallyHidden = 503; }
|
|
52
54
|
message Vector3 { float x = 1; float y = 2; float z = 3; }
|
|
53
55
|
message RectTransform {
|
|
54
56
|
Vector3 scale = 501; Vector2 anchorMin = 502; Vector2 anchorMax = 503; Vector2 offset = 504;
|
|
55
|
-
Vector2 size = 505; Vector2 pivot = 506;
|
|
57
|
+
Vector2 size = 505; Vector2 pivot = 506; Vector3 field508 = 508;
|
|
56
58
|
message Vector2 { float x = 501; float y = 502; }
|
|
57
59
|
}
|
|
58
60
|
message Transform {
|
|
@@ -71,7 +73,7 @@ message GenericSlot {
|
|
|
71
73
|
}
|
|
72
74
|
message TextConfig {
|
|
73
75
|
int32 field501 = 501; int32 adaptive = 502; int32 field503 = 503; uint32 color = 504;
|
|
74
|
-
uint32 color2 = 505; int32 outlineOff = 506; uint32 color3 = 507; int32 align = 508;
|
|
76
|
+
uint32 color2 = 505; int32 outlineOff = 506; uint32 color3 = 507; int32 align = 508; int32 verticalAlign = 509;
|
|
75
77
|
WrapperString text = 510; int32 field511 = 511; int32 fontSize = 512; int32 minimumFontSize = 513; ViewFlags viewFlags = 62;
|
|
76
78
|
message ViewFlags { int32 field502 = 502; int32 field503 = 503; }
|
|
77
79
|
}
|
|
@@ -97,12 +99,12 @@ message ImageConfig {
|
|
|
97
99
|
message SliceVector { float field501 = 501; float field502 = 502; }
|
|
98
100
|
}
|
|
99
101
|
message FooterSlot { int32 field505 = 505; }
|
|
100
|
-
`,{root:Ja}=qa.parse(ja,{keepCase:!1}),Se=Ja.lookupType("Root"),Ve=20,Wi=4,br=806,vr=1657,zt={image:23,"server-container":24,container:25,grid:26,reference:27,button:28,animation:29,fullscreen:30,textbox:31,textwindow:32,cursor:33,keyhint:34},Sr={"server-container":1,container:2,textbox:3,cursor:4,reference:5,grid:6,button:7,textwindow:8,keyhint:9,image:10,animation:11,fullscreen:12},wr={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},Za="server-control-template",si="client-control-template";function ai(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var Qa=Object.fromEntries(Object.entries(wr).map(([e,t])=>[t,e])),Ir=Object.freeze({container:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["68/91","empty78","containerNodeSlot"],["67/90","empty77","footerSlot"]],textbox:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["64/84","empty74","textConfig"],["67/90","empty77","footerSlot"]],cursor:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["65/85","empty75","cursorConfig"],["67/90","empty77","footerSlot"]],reference:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["66/89","empty76","templateRefSlot"],["67/90","empty77","footerSlot"]],grid:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["69/92","empty79","gridView"],["67/90","empty77","footerSlot"]],button:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["70/93","empty80","buttonPreset"],["67/90","empty77","footerSlot"]],textwindow:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["71/94","empty81","textConfig"],["67/90","empty77","footerSlot"]],keyhint:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["72/95","empty82","keyHint"],["67/90","empty77","footerSlot"]],image:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["73/96","empty83","imageSlot"],["74/97","empty84","image"],["67/90","empty77","footerSlot"]],animation:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["75/98","empty85","effectSlot"],["67/90","empty77","footerSlot"]],fullscreen:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["76/99","empty86","fullscreenEffectSlot"],["67/90","empty77","footerSlot"]]}),Cr=Object.freeze({"4/23":5,"4/86":5,"1/12":4,"62/82":64,"63/83":65,"64/84":66,"65/85":67,"66/89":68,"67/90":69,"68/91":70,"69/92":71,"70/93":72,"71/94":66,"72/95":74,"73/96":75,"74/97":76,"75/98":77,"76/99":78}),es=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function qi(e){return{class:1,type:8,id:e}}function Gt(e,t,i,n){return{...n,field501:t,field502:i,field503:1,nodeRef:qi(e)}}function ts(e){let t=[],i=e.meta?.assetType==="client-control-template";return J(e.root,n=>{i&&n.kind==="server-container"||t.push(n)}),t}function Vt(e,t=new Set){let i=new Map,n=[];for(let r of ts(e)){let o=Number(r.guid);ke(o)&&!t.has(o)?(t.add(o),r.guid=o,i.set(r.id,o)):n.push(r)}for(let r of n){let o=Fe(t);t.add(o),r.guid=o,i.set(r.id,o)}return i}function is(e){return{scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},anchorMin:{x:e.anchorMin.x,y:e.anchorMin.y},anchorMax:{x:e.anchorMax.x,y:e.anchorMax.y},offset:{x:e.offset.x,y:e.offset.y},size:{x:e.size.x,y:e.size.y},pivot:{x:e.pivot.x,y:e.pivot.y},field508:""}}function ns(e,t){let n={multiPlatform:{platforms:te.map(r=>({platformType:wr[r],transform:is(e.transformByPlatform[r])})),field502:zt[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:Gt(t,4,12,{transform:n})}}function rs(e,t,i){let n=i?{empty15:"",field501:5}:{field17:"",field501:7};return[{name:{value:e.name},field501:2,field502:15},{field14:n,field501:4,field502:i?23:86,details:Gt(t,5,i?23:86,{field14:n})},ns(e,t)]}function os(e,t,i,n){let r=(l,f,h,p,m)=>({[h]:"",field501:l,field502:f,details:Gt(t,l+2,f,{[p]:m})}),o=e.giaRaw||{},a=Array.isArray(e.scriptMappingIds)&&e.scriptMappingIds.length?{field501:o.genericField501||1,field502:e.scriptMappingIds.map(l=>({field1:{id:Number(l)}}))}:{field501:o.genericField501??0},s=r(63,83,"empty73","genericSlot",a),c=r(67,90,"empty77","footerSlot",{field505:o.footerField505??0});if(e.kind==="container")return[s,r(68,91,"empty78","containerNodeSlot",o.containerNodeSlot??""),c];if(e.kind==="textbox"||e.kind==="textwindow"){e.verticalAlignment!=="Top"&&n.push(`${e.name}: \u5782\u76F4\u5BF9\u9F50\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`);let l={Left:0,Middle:1,Right:2}[e.horizontalAlignment]??0,f=Number.isFinite(o.textAlign)?Math.trunc(o.textAlign):l,h={field501:o.textField501??20,field503:o.textField503??12,color:e.fontColor>>>0,color2:e.bgColor>>>0,color3:e.outlineColor>>>0,text:{value:e.text||""},fontSize:Math.trunc(e.fontSize),minimumFontSize:Math.trunc(e.minimumFontSize),...e.adaptiveFontSize?{adaptive:1}:{},...e.enableOutline===!1?{outlineOff:1}:{},...f?{align:f}:{}};return e.kind==="textwindow"?(h.field511=o.textField511??1,h.viewFlags={field502:o.textViewField502??1,field503:o.textViewField503??1},[s,{empty81:"",field501:71,field502:94,details:Gt(t,66,94,{textConfig:h})},c]):[s,r(64,84,"empty74","textConfig",h),c]}if(e.kind==="image"){let l={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[e.fillType],f=Number.isFinite(o.imageFillType)?Math.trunc(o.imageFillType):l||1;e.enableFill&&!f&&n.push(`${e.name}: \u586B\u5145\u5F62\u72B6\u539F\u59CB\u679A\u4E3E\u4E3A 0\uFF0C\u5DF2\u5173\u95ED\u5BFC\u51FA\u6587\u4EF6\u4E2D\u7684\u8FDB\u5EA6\u586B\u5145\u3002`),e.fillType==="Horizontal"&&e.fillHorizontalType!=="Left"&&n.push(`${e.name}: \u5F53\u524D\u6A2A\u5411\u586B\u5145\u65B9\u5411\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`),e.fillType==="Radial180"&&e.fillRadialType!=="Bottom"&&n.push(`${e.name}: \u5F53\u524D 180 \u5EA6\u586B\u5145\u8D77\u70B9\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`);let h={field502:o.imageField502??1,field504:o.imageField504??1,field505:o.imageField505??1,field507:o.imageField507??2,field508:Math.round(Math.max(0,Math.min(1,Number(e.fillAmount)||0))*100),border:{field501:ai(e.softEdgeWidthX,8),field502:ai(e.softEdgeWidthY,8)},field512:ai(e.horizontalSoftRange,85),field513:ai(e.verticalSoftRange,85),fillType:f,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&f?{enableFill:1}:{},...e.reverseMaskArea?{reverseMask:1}:{}};return[s,r(73,96,"empty83","imageSlot",{field502:Number.isFinite(e.imageColor)?e.imageColor>>>0:4294967295,assetId:e.imageId>>>0}),r(74,97,"empty84","image",h),c]}if(e.kind==="button"){let l=(g,I)=>{let k=e[g];return k?(e.children||[]).some(E=>E.id===k)?i.get(k)||0:(n.push(`${e.name}: ${I}\u72B6\u6001\u8282\u70B9\u4E0D\u662F\u6309\u94AE\u7684\u76F4\u63A5\u5B50\u63A7\u4EF6\uFF0CGIA \u672A\u5199\u5165\u8BE5\u72B6\u6001\u3002`),0):0},f=l("unavailableChildId","\u4E0D\u53EF\u7528"),h=l("hoverChildId","\u60AC\u505C"),p=l("pressedChildId","\u6309\u4E0B"),m=l("selectedChildId","\u9009\u4E2D");return[s,r(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(e.clickAudioId),...f?{disabledChild:f}:{},...h?{hoverChild:h}:{},...p?{pressedChild:p}:{},...m?{selectedChild:m}:{},...e.interactable?{interactable:1}:{},...e.raycastTarget?{raycastTarget:1}:{}}),c]}return e.kind==="cursor"?[s,r(65,85,"empty75","cursorConfig",{field501:o.cursorField501??1}),c]:e.kind==="reference"?[s,r(66,89,"empty76","templateRefSlot",o.templateRefSlot??""),c]:e.kind==="grid"?[s,r(69,92,"empty79","gridView",{field501:o.gridField501??1,cellSize:{field501:e.cellSizeX,field502:e.cellSizeY},gap:{field501:e.spacingX,field502:e.spacingY},padding1:{field501:e.padding1X,field502:e.padding1Y},padding2:{field501:e.padding2X,field502:e.padding2Y},field507:o.gridField507??1,field508:o.gridField508??1,field509:o.gridField509??1,field511:o.gridField511??5,field512:o.gridField512??1}),c]:e.kind==="keyhint"?[s,r(72,95,"empty82","keyHint",{field501:Number.isFinite(o.keyHintField501)?Math.trunc(o.keyHintField501):e.controllerKeyCode??1,field502:Number.isFinite(o.keyHintField502)?Math.trunc(o.keyHintField502):e.keyboardKeyCode??1}),c]:e.kind==="animation"?[s,r(75,98,"empty85","effectSlot",o.effectSlot??""),c]:e.kind==="fullscreen"?[s,r(76,99,"empty86","fullscreenEffectSlot",o.fullscreenEffectSlot??""),c]:(n.push(`${e.name}: ${e.kind} \u4E0D\u662F\u5DF2\u77E5 GIA \u63A7\u4EF6\u7C7B\u578B\uFF0C\u5DF2\u4EC5\u5199\u516C\u5171\u53D8\u6362\u3002`),[s,c])}function as(e,t){return t?1:Number.isSafeInteger(Number(e.giaInfoIndex))&&Number(e.giaInfoIndex)>0?Number(e.giaInfoIndex):Sr[e.kind]||2}function ss(e,t,i){let n=Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(r=>Number.isSafeInteger(r)&&r>0&&r<=2147483647):[];return n.length?n:(t.push(`${e.name}: \u65B0${i}\u5199\u5165\u663E\u5F0F\u7A7A Info.related\uFF0C\u907F\u514D\u8DE8\u6C99\u7BB1\u590D\u7528\u4F34\u751F\u8D44\u6E90 GUID \u4EA7\u751F\u65E0\u6CD5\u52A0\u8F7D\u7684\u7D22\u5F15\u3002`),[])}function ji(e,t){let i=String(e.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let n=(l,f)=>Number.isSafeInteger(Number(l))&&Number(l)>0?Number(l):f,r=n(e.meta?.giaOwnerUid,114514),o=n(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),a=n(e.meta?.giaFileId,t?1073741829:1073741830),s=t?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F-\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668.gia",c=String(e.meta?.giaFileName||s).replace(/[\\/:*?"<>|]/gu,"-").replace(/\.gia$/iu,"").trim()||s.replace(/\.gia$/iu,"");return`${r}-${o}-${a}-\\${c}.gia`}function li(e,t,i,n,r,o=!1,a=!1,s=a,c=!1){let l=i.get(e.id),h=(c?[...e.children||[]].reverse():e.children||[]).map(g=>i.get(g.id)),p=o?n:h,m=rs(e,l,o);if(o){let g=e.children?.[0];g&&m.push({empty72:"",field501:62,field502:82,details:Gt(l,64,82,{rootChildRef:{guid:i.get(g.id)}})})}else m.push(...os(e,l,i,r));return{id:qi(l),relatedIds:p.map(g=>qi(g)),name:e.name,which:o?21:a?70:15,ui:{content:{guid:l,info:[{guid:{value:l},field501:1,field502:5},...o||s?[{index:{value:as(e,o)},field501:2,field502:6}]:[],...o||a?[{related:{value:ss(e,r,o?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:o?[]:h,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:m}}}}function kr(e){let t=[];return J(e.root,(i,n)=>{i.kind!=="server-container"&&t.push({node:i,parent:n})}),t}function xr(e,t){for(let{node:i}of e)for(let n of te)if(Math.abs(i.transformByPlatform[n].rotation.z)>1e-6){t.push(`${i.name}: \u65CB\u8F6C Z \u6682\u65E0 GIA RectTransform \u7EBF\u53F7\uFF0CAuthoring JSON \u5DF2\u4FDD\u7559\uFF0CGIA \u672A\u5199\u5165\u3002`);break}}function ls(e,t){let i=new Map;for(let n of e||[]){if(!n.controlId||!(t===si?n.controlAsset===si:n.controlAsset!==si))continue;let o=i.get(n.controlId)||[];o.push(n.guid),i.set(n.controlId,o)}return i}function Er(e,t,i,n){let r=ls(t,i),o=new Map;J(e.root,a=>{r.has(a.id)&&(o.set(a,a.scriptMappingIds),a.scriptMappingIds=r.get(a.id))});try{return n()}finally{for(let[a,s]of o)s===void 0?delete a.scriptMappingIds:a.scriptMappingIds=s}}function Ji(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function Ar(e,t,i,n,r=[]){let o=kr(e);xr(o,i);let a=o.filter(({parent:f})=>f?.kind==="server-container");if(!a.length)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u6A21\u677F");let s=new Set(a.map(({node:f})=>f.id)),c=o.filter(({node:f})=>!s.has(f.id)),l=o.map(({node:f})=>t.get(f.id));return Er(e,r,si,()=>({graph:a.map(({node:f,parent:h})=>li(f,h,t,l,i,!1,!0)),accessories:c.map(({node:f,parent:h})=>li(f,h,t,l,i,!1,!1,!0)),filePath:n||ji(e,!0),gameVersion:e.meta?.gameVersion||"7.0.50",...Ji(e)}))}function _r(e,t,i,n,r){let o=kr(e);xr(o,n);let a=[o[0],...o.slice(1).reverse()],s=a.map(({node:c})=>t.get(c.id));return Er(e,i.scripts,Za,()=>({graph:[li(e.root,null,t,s,n,!0,!1,!1,!0),...i.units||[]],accessories:a.map(({node:c,parent:l})=>li(c,l,t,s,n,!1,!1,!1,!0)),filePath:r||ji(e,!1),gameVersion:e.meta?.gameVersion||"7.0.50",...Ji(e)}))}function Pr(e,t){let i=Or(e),n=t(i);if(!n.valid)throw new Error(`GIA compatibility validation failed:
|
|
102
|
+
`,{root:Qo}=Jo.parse(Zo,{keepCase:!1}),Se=Qo.lookupType("Root"),Ve=20,ji=4,Ir=806,Cr=1657,Gt={image:23,"server-container":24,container:25,grid:26,reference:27,button:28,animation:29,fullscreen:30,textbox:31,textwindow:32,cursor:33,keyhint:34},kr={"server-container":1,container:2,textbox:3,cursor:4,reference:5,grid:6,button:7,textwindow:8,keyhint:9,image:10,animation:11,fullscreen:12},xr={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},es="server-control-template",li="client-control-template";function si(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var ts=Object.fromEntries(Object.entries(xr).map(([e,t])=>[t,e])),Er=Object.freeze({container:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["68/91","empty78","containerNodeSlot"],["67/90","empty77","footerSlot"]],textbox:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["64/84","empty74","textConfig"],["67/90","empty77","footerSlot"]],cursor:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["65/85","empty75","cursorConfig"],["67/90","empty77","footerSlot"]],reference:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["66/89","empty76","templateRefSlot"],["67/90","empty77","footerSlot"]],grid:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["69/92","empty79","gridView"],["67/90","empty77","footerSlot"]],button:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["70/93","empty80","buttonPreset"],["67/90","empty77","footerSlot"]],textwindow:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["71/94","empty81","textConfig"],["67/90","empty77","footerSlot"]],keyhint:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["72/95","empty82","keyHint"],["67/90","empty77","footerSlot"]],image:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["73/96","empty83","imageSlot"],["74/97","empty84","image"],["67/90","empty77","footerSlot"]],animation:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["75/98","empty85","effectSlot"],["67/90","empty77","footerSlot"]],fullscreen:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["76/99","empty86","fullscreenEffectSlot"],["67/90","empty77","footerSlot"]]}),Ar=Object.freeze({"4/23":5,"4/86":5,"1/12":4,"62/82":64,"63/83":65,"64/84":66,"65/85":67,"66/89":68,"67/90":69,"68/91":70,"69/92":71,"70/93":72,"71/94":66,"72/95":74,"73/96":75,"74/97":76,"75/98":77,"76/99":78}),is=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Ji(e){return{class:1,type:8,id:e}}function zt(e,t,i,n){return{...n,field501:t,field502:i,field503:1,nodeRef:Ji(e)}}function ns(e){let t=[],i=e.meta?.assetType==="client-control-template";return J(e.root,n=>{i&&n.kind==="server-container"||t.push(n)}),t}function Vt(e,t=new Set){let i=new Map,n=[];for(let r of ns(e)){let a=Number(r.guid);Ce(a)&&!t.has(a)?(t.add(a),r.guid=a,i.set(r.id,a)):n.push(r)}for(let r of n){let a=Oe(t);t.add(a),r.guid=a,i.set(r.id,a)}return i}function rs(e){return{scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},anchorMin:{x:e.anchorMin.x,y:e.anchorMin.y},anchorMax:{x:e.anchorMax.x,y:e.anchorMax.y},offset:{x:e.offset.x,y:e.offset.y},size:{x:e.size.x,y:e.size.y},pivot:{x:e.pivot.x,y:e.pivot.y},field508:e.rotation.z?{z:e.rotation.z}:{}}}function as(e,t){let n={multiPlatform:{platforms:re.map(r=>({platformType:xr[r],transform:rs(e.transformByPlatform[r])})),field502:Gt[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:zt(t,4,12,{transform:n})}}function os(e,t,i){let n=i?{empty15:"",field501:5}:{field17:{},field501:7},r=i?n:{...n,...e.visible===!1?{field17:{initiallyHidden:!0}}:{},...e.active===!1?{initiallyInactive:!0}:{}};return[{name:{value:e.name},field501:2,field502:15},{field14:n,field501:4,field502:i?23:86,details:zt(t,5,i?23:86,{field14:r})},as(e,t)]}function ss(e,t,i,n){let r=(l,f,h,p,m)=>({[h]:"",field501:l,field502:f,details:zt(t,l+2,f,{[p]:m})}),a=e.giaRaw||{},o=Array.isArray(e.scriptMappingIds)&&e.scriptMappingIds.length?{field501:a.genericField501||1,field502:e.scriptMappingIds.map(l=>({field1:{id:Number(l)}}))}:{field501:a.genericField501??0},s=r(63,83,"empty73","genericSlot",o),c=r(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(a.footerField505)?e.canControllerFocus?1:0:a.footerField505});if(e.kind==="container")return[s,r(68,91,"empty78","containerNodeSlot",{...e.isolateNavigation?{isolateNavigation:!0}:{},...e.disableKeyEventPassthrough?{disableKeyEventPassthrough:!0}:{},...e.disableCursorEventPassthrough?{disableCursorEventPassthrough:!0}:{},...e.showCursor?{showCursor:!0}:{}}),c];if(e.kind==="textbox"||e.kind==="textwindow"){e.verticalAlignment==="Middle"&&n.push(`${e.name}: \u5782\u76F4\u5C45\u4E2D\u6309\u63A8\u5B9A\u503C\u5BFC\u51FA\uFF0C\u5C1A\u5F85\u5B9E\u673A\u786E\u8BA4\u3002`);let l={Left:0,Middle:1,Right:2}[e.horizontalAlignment]??0,f=Number.isFinite(a.textAlign)?Math.trunc(a.textAlign):l,h={field501:a.textField501??20,field503:a.textField503??12,color:e.fontColor>>>0,color2:e.bgColor>>>0,color3:e.outlineColor>>>0,text:{value:e.text||""},fontSize:Math.trunc(e.fontSize),minimumFontSize:Math.trunc(e.minimumFontSize),...e.adaptiveFontSize?{adaptive:1}:{},...e.enableOutline===!1?{outlineOff:1}:{},...f?{align:f}:{},verticalAlign:a.textVerticalAlign??{Top:0,Middle:1,Bottom:2}[e.verticalAlignment]??0};return e.kind==="textwindow"?(h.field511=a.textField511??1,h.viewFlags={field502:a.textViewField502??1,field503:a.textViewField503??1},[s,{empty81:"",field501:71,field502:94,details:zt(t,66,94,{textConfig:h})},c]):[s,r(64,84,"empty74","textConfig",h),c]}if(e.kind==="image"){let l={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[e.fillType],f=Number.isFinite(a.imageFillType)?Math.trunc(a.imageFillType):l||1;e.enableFill&&!f&&n.push(`${e.name}: \u586B\u5145\u5F62\u72B6\u539F\u59CB\u679A\u4E3E\u4E3A 0\uFF0C\u5DF2\u5173\u95ED\u5BFC\u51FA\u6587\u4EF6\u4E2D\u7684\u8FDB\u5EA6\u586B\u5145\u3002`),e.fillType==="Horizontal"&&e.fillHorizontalType!=="Left"&&n.push(`${e.name}: \u5F53\u524D\u6A2A\u5411\u586B\u5145\u65B9\u5411\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`),e.fillType==="Radial180"&&e.fillRadialType!=="Bottom"&&n.push(`${e.name}: \u5F53\u524D 180 \u5EA6\u586B\u5145\u8D77\u70B9\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`);let h={field502:a.imageField502??1,field504:a.imageField504??1,field505:a.imageField505??1,field507:a.imageField507??2,field508:Math.round(Math.max(0,Math.min(1,Number(e.fillAmount)||0))*100),border:{field501:si(e.softEdgeWidthX,8),field502:si(e.softEdgeWidthY,8)},field512:si(e.horizontalSoftRange,85),field513:si(e.verticalSoftRange,85),fillType:f,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&f?{enableFill:1}:{},...e.reverseMaskArea?{reverseMask:1}:{}};return[s,r(73,96,"empty83","imageSlot",{field502:Number.isFinite(e.imageColor)?e.imageColor>>>0:4294967295,assetId:e.imageId>>>0}),r(74,97,"empty84","image",h),c]}if(e.kind==="button"){let l=(g,I)=>{let k=e[g];return k?(e.children||[]).some(E=>E.id===k)?i.get(k)||0:(n.push(`${e.name}: ${I}\u72B6\u6001\u8282\u70B9\u4E0D\u662F\u6309\u94AE\u7684\u76F4\u63A5\u5B50\u63A7\u4EF6\uFF0CGIA \u672A\u5199\u5165\u8BE5\u72B6\u6001\u3002`),0):0},f=l("unavailableChildId","\u4E0D\u53EF\u7528"),h=l("hoverChildId","\u60AC\u505C"),p=l("pressedChildId","\u6309\u4E0B"),m=l("selectedChildId","\u9009\u4E2D");return[s,r(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(e.clickAudioId),...f?{disabledChild:f}:{},...h?{hoverChild:h}:{},...p?{pressedChild:p}:{},...m?{selectedChild:m}:{},...e.interactable?{interactable:1}:{},...e.raycastTarget?{raycastTarget:1}:{}}),c]}return e.kind==="cursor"?[s,r(65,85,"empty75","cursorConfig",{field501:[void 0,0,1].includes(a.cursorField501)?e.raycastTarget!==!1?1:0:a.cursorField501}),c]:e.kind==="reference"?[s,r(66,89,"empty76","templateRefSlot",a.templateRefSlot??""),c]:e.kind==="grid"?[s,r(69,92,"empty79","gridView",{field501:a.gridField501??1,cellSize:{field501:e.cellSizeX,field502:e.cellSizeY},gap:{field501:e.spacingX,field502:e.spacingY},padding1:{field501:e.padding1X,field502:e.padding1Y},padding2:{field501:e.padding2X,field502:e.padding2Y},field507:a.gridField507??1,field508:a.gridField508??1,field509:a.gridField509??1,field511:a.gridField511??5,field512:a.gridField512??1}),c]:e.kind==="keyhint"?[s,r(72,95,"empty82","keyHint",{field501:Number.isFinite(a.keyHintField501)?Math.trunc(a.keyHintField501):e.controllerKeyCode??1,field502:Number.isFinite(a.keyHintField502)?Math.trunc(a.keyHintField502):e.keyboardKeyCode??1}),c]:e.kind==="animation"?[s,r(75,98,"empty85","effectSlot",a.effectSlot??""),c]:e.kind==="fullscreen"?[s,r(76,99,"empty86","fullscreenEffectSlot",a.fullscreenEffectSlot??""),c]:(n.push(`${e.name}: ${e.kind} \u4E0D\u662F\u5DF2\u77E5 GIA \u63A7\u4EF6\u7C7B\u578B\uFF0C\u5DF2\u4EC5\u5199\u516C\u5171\u53D8\u6362\u3002`),[s,c])}function ls(e,t){return t?1:Number.isSafeInteger(Number(e.giaInfoIndex))&&Number(e.giaInfoIndex)>0?Number(e.giaInfoIndex):kr[e.kind]||2}function us(e,t,i){let n=Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(r=>Number.isSafeInteger(r)&&r>0&&r<=2147483647):[];return n.length?n:(t.push(`${e.name}: \u65B0${i}\u5199\u5165\u663E\u5F0F\u7A7A Info.related\uFF0C\u907F\u514D\u8DE8\u6C99\u7BB1\u590D\u7528\u4F34\u751F\u8D44\u6E90 GUID \u4EA7\u751F\u65E0\u6CD5\u52A0\u8F7D\u7684\u7D22\u5F15\u3002`),[])}function Zi(e,t){let i=String(e.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let n=(l,f)=>Number.isSafeInteger(Number(l))&&Number(l)>0?Number(l):f,r=n(e.meta?.giaOwnerUid,114514),a=n(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),o=n(e.meta?.giaFileId,t?1073741829:1073741830),s=t?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F-\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668.gia",c=String(e.meta?.giaFileName||s).replace(/[\\/:*?"<>|]/gu,"-").replace(/\.gia$/iu,"").trim()||s.replace(/\.gia$/iu,"");return`${r}-${a}-${o}-\\${c}.gia`}function ui(e,t,i,n,r,a=!1,o=!1,s=o,c=!1){let l=i.get(e.id),h=(c?[...e.children||[]].reverse():e.children||[]).map(g=>i.get(g.id)),p=a?n:h,m=os(e,l,a);if(a){let g=e.children?.[0];g&&m.push({empty72:"",field501:62,field502:82,details:zt(l,64,82,{rootChildRef:{guid:i.get(g.id)}})})}else m.push(...ss(e,l,i,r));return{id:Ji(l),relatedIds:p.map(g=>Ji(g)),name:e.name,which:a?21:o?70:15,ui:{content:{guid:l,info:[{guid:{value:l},field501:1,field502:5},...a||s?[{index:{value:ls(e,a)},field501:2,field502:6}]:[],...a||o?[{related:{value:us(e,r,a?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:a?[]:h,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:m}}}}function _r(e){let t=[];return J(e.root,(i,n)=>{i.kind!=="server-container"&&t.push({node:i,parent:n})}),t}function cs(e,t){let i=new Map;for(let n of e||[]){if(!n.controlId||!(t===li?n.controlAsset===li:n.controlAsset!==li))continue;let a=i.get(n.controlId)||[];a.push(n.guid),i.set(n.controlId,a)}return i}function Pr(e,t,i,n){let r=cs(t,i),a=new Map;J(e.root,o=>{r.has(o.id)&&(a.set(o,o.scriptMappingIds),o.scriptMappingIds=r.get(o.id))});try{return n()}finally{for(let[o,s]of a)s===void 0?delete o.scriptMappingIds:o.scriptMappingIds=s}}function Qi(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function Rr(e,t,i,n,r=[]){let a=_r(e),o=a.filter(({parent:f})=>f?.kind==="server-container");if(!o.length)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u6A21\u677F");let s=new Set(o.map(({node:f})=>f.id)),c=a.filter(({node:f})=>!s.has(f.id)),l=a.map(({node:f})=>t.get(f.id));return Pr(e,r,li,()=>({graph:o.map(({node:f,parent:h})=>ui(f,h,t,l,i,!1,!0)),accessories:c.map(({node:f,parent:h})=>ui(f,h,t,l,i,!1,!1,!0)),filePath:n||Zi(e,!0),gameVersion:e.meta?.gameVersion||"7.0.50",...Qi(e)}))}function Tr(e,t,i,n,r){let a=_r(e),o=[a[0],...a.slice(1).reverse()],s=o.map(({node:c})=>t.get(c.id));return Pr(e,i.scripts,es,()=>({graph:[ui(e.root,null,t,s,n,!0,!1,!1,!0),...i.units||[]],accessories:o.map(({node:c,parent:l})=>ui(c,l,t,s,n,!1,!1,!1,!0)),filePath:r||Zi(e,!1),gameVersion:e.meta?.gameVersion||"7.0.50",...Qi(e)}))}function Mr(e,t){let i=Dr(e),n=t(i);if(!n.valid)throw new Error(`GIA compatibility validation failed:
|
|
101
103
|
${n.errors.join(`
|
|
102
|
-
`)}`);return i}function
|
|
104
|
+
`)}`);return i}function Nr(e,t={}){J(e.root,qe);let i=Vt(D(e)),n=[],r=e.meta?.assetType==="client-control-template",a;if(r)a=Rr(e,i,n,void 0,t.scripts||[]);else{let s=en(t.scripts||[],new Set(i.values()));n.push(...s.warnings),a=Tr(e,i,s,n)}return{buffer:Mr(a,r?Ur:nn),warnings:[...new Set(n)]}}function Fr(e,t,i={}){J(e.root,qe),t&&J(t.root,qe);let n=["\u6574\u5408\u5305\u628A\u670D\u52A1\u7AEF UIControlGroup \u4E0E\u5BA2\u6237\u7AEF UIControlTemplate \u5E76\u6392\u5199\u5165\u540C\u4E00 GIA \u7684 Root.graph\uFF1B\u5BFC\u5165\u65F6\u62C6\u56DE\u4E24\u7C7B\u8D44\u4EA7\uFF0C\u6A21\u677F\u8FB9\u754C\u3001\u811A\u672C\u6620\u5C04\u4E0E\u63A7\u4EF6\u6302\u8F7D\u5173\u7CFB\u4F1A\u4FDD\u7559\u3002"],r=t?.root?.children||[];r.length||n.push("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4E3A\u7A7A\uFF0C\u6574\u5408\u5305\u53EA\u5305\u542B\u670D\u52A1\u7AEF\u63A7\u4EF6\u4E0E\u811A\u672C\u3002");let a=new Set,o=D(e),s=t?D(t):null,c=Vt(o,a),l=en(i.scripts||[],a);n.push(...l.warnings.filter(k=>k!==$r));let f=String(i.fileName||`${o.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),h=Zi({...o,meta:{...o.meta,giaFileName:f}},!1),p=Tr(o,c,l,n,h),m={graph:[],accessories:[]};if(r.length&&s){let k=Vt({...s,meta:{...s.meta,assetType:"client-control-template"}},a);m=Rr(s,k,n,h,l.scripts)}let g={graph:[...p.graph,...m.graph],accessories:[...p.accessories,...m.accessories],filePath:h,gameVersion:e.meta?.gameVersion||t?.meta?.gameVersion||"7.0.50",...Qi(e)};return{buffer:Mr(g,nn),warnings:[...new Set(n)]}}var vt=69,Or=30,$r="\u811A\u672C\u6302\u8F7D\u5173\u7CFB\u4E0D\u8FDB\u5165 GIA\uFF1A\u5B98\u65B9 script.gia \u53EA\u542B\u6620\u5C04\uFF08ID/\u540D\u79F0/\u8DEF\u5F84/\u6E90\u7801\uFF09\uFF0C\u5BFC\u5165\u540E\u9700\u91CD\u65B0\u6302\u8F7D\u3002";function fs(e){return(String(e.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${e.id||""}`}function Dr(e){let t=Se.verify(e);if(t)throw new Error(`GIA encode validation failed: ${t}`);let i=Se.encode(Se.create(e)).finish(),n=Buffer.alloc(Ve+i.length+ji);return n.writeUInt32BE(n.length-4,0),n.writeUInt32BE(1,4),n.writeUInt32BE(Ir,8),n.writeUInt32BE(3,12),n.writeUInt32BE(i.length,16),Buffer.from(i).copy(n,Ve),n.writeUInt32BE(Cr,Ve+i.length),n}function en(e,t=new Set){let i=(e||[]).filter(o=>o.path||o.source).map(o=>({...o})),n=[];for(let o of i){let s=Number(o.guid);Ce(s)&&!t.has(s)?(t.add(s),o.guid=s):n.push(o)}for(let o of n){let s=Oe(t);t.add(s),o.guid=s}let r=[];return(e||[]).some(o=>o.controlId)&&r.push($r),{units:i.map(o=>{let s=fs(o),c=String(o.path||"").replace(/\\/g,"/"),l=/\.lua$/iu.test(c)?c:`${c||s}.lua`,f={id:o.guid,name:s,filePath:l};return String(o.source||"")&&(f.source=String(o.source)),{id:{class:Or,id:o.guid},name:s,which:vt,script:{mapping:f}}}),warnings:r,scripts:i}}function Gr(e){let t=en(e);if(!t.units.length)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let i={graph:t.units,filePath:`114514-${Math.floor(Date.now()/1e3)}-1073741832-\\script.gia`,gameVersion:"7.0.51"},n=Dr(i),r=ds(n);if(!r.valid)throw new Error(`GIA compatibility validation failed:
|
|
103
105
|
${r.errors.join(`
|
|
104
|
-
`)}`);return{buffer:n,warnings:[...new Set(t.warnings)]}}function Qi(e){return Se.toObject(Se.decode(ci(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function $r(e){try{let i=Qi(e).graph||[];return i.length>0&&i.every(n=>Number(n.which)===bt)}catch{return!1}}function Dr(e){let t=(e.graph||[]).filter(r=>Number(r.which)===bt),i=[],n=t.map((r,o)=>{let a=r.script?.mapping||{},s=Number(r.id?.id)||0;s<=0&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04\u7F3A\u5C11 GraphUnit.id.id\uFF0C\u5DF2\u6309 0 \u5904\u7406\uFF08\u5BFC\u51FA\u65F6\u4F1A\u91CD\u65B0\u5206\u914D\uFF09\u3002`);let c=Number(a.id)||0;return c&&c!==s&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04 id(${c}) \u4E0E\u5355\u5143 id(${s}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:s,path:String(a.filePath||""),source:String(a.source||"")}});for(let[r,o]of n.entries())o.path&&!/\.lua$/iu.test(o.path)&&i.push(`\u7B2C ${r+1} \u6761\u811A\u672C\u6620\u5C04 file_path \u7F3A\u5C11 .lua \u540E\u7F00\uFF08${o.path}\uFF09\uFF0C\u771F\u673A\u53EF\u80FD\u62D2\u7EDD\u5BFC\u5165\uFF1B\u6A21\u62DF\u5668\u5185\u6309\u5F52\u4E00\u5316\u8DEF\u5F84\u7167\u5E38 require\u3002`);return{scripts:n,warnings:i}}function zr(e){let t=Qi(e),i=Dr(t);if(!i.scripts.length)throw new Error("GIA \u5185\u6CA1\u6709\u811A\u672C\u6620\u5C04\u5355\u5143\uFF08which=69\uFF09");return{scripts:i.scripts,warnings:i.warnings,metadata:{assetType:"lua-script"}}}function cs(e){let t=[],i;try{i=Qi(e)}catch(r){return{valid:!1,errors:[r?.message||String(r)],scriptCount:0}}let n=i.graph||[];return n.length||t.push("Root.graph \u4E3A\u7A7A"),(i.accessories||[]).length&&t.push("script.gia \u4E0D\u5E94\u5305\u542B accessories"),n.forEach((r,o)=>{let a=`\u5355\u5143 ${o+1}`;Number(r.which)!==bt&&t.push(`${a}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${r.which}`),Number(r.id?.class)!==Mr&&t.push(`${a}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${r.id?.class}`),Number(r.id?.type??0)!==0&&t.push(`${a}: id.type \u5E94\u7F3A\u7701`);let s=r.script?.mapping;if(!s){t.push(`${a}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(r.id?.id)<=0&&t.push(`${a}: GraphUnit.id.id \u975E\u6CD5`),Number(s.id)!==Number(r.id?.id)&&t.push(`${a}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(s.name||"")!==String(r.name||"")&&t.push(`${a}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(s.filePath||"").trim()?/\.lua$/iu.test(String(s.filePath))||t.push(`${a}: file_path \u5E94\u4EE5 .lua \u7ED3\u5C3E\uFF08\u5B98\u65B9 script.gia \u6837\u672C\u5747\u4E3A \u540D\u79F0.lua\uFF0C\u771F\u673A require \u65F6\u624D\u53BB\u6269\u5C55\u540D\uFF09`):t.push(`${a}: file_path \u4E3A\u7A7A`)}),{valid:t.length===0,errors:t,scriptCount:n.length}}function ci(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Ve+Wi)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==br||t.readUInt32BE(12)!==3)throw new Error("\u4E0D\u662F\u53D7\u652F\u6301\u7684 GIA v1 \u6587\u4EF6");let i=t.readUInt32BE(16);if(i!==t.length-Ve-Wi)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Ve+i)!==vr)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(Ve,Ve+i)}function he(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function fs(e){let t=he(e,"transform")?.multiPlatform,i={};for(let r of t?.platforms||[]){let o=Qa[r.platformType||0],a=r.transform||{};i[o]={scale:a.scale?{x:a.scale.x??0,y:a.scale.y??0,z:a.scale.z??0}:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:a.anchorMin?.x??0,y:a.anchorMin?.y??0},anchorMax:{x:a.anchorMax?.x??0,y:a.anchorMax?.y??0},offset:{x:a.offset?.x??0,y:a.offset?.y??0},size:{x:a.size?.x??0,y:a.size?.y??0},pivot:a.pivot?{x:a.pivot.x??0,y:a.pivot.y??0}:{x:.5,y:.5}}}let n=i.KEYBOARD||i[Object.keys(i)[0]];if(!n)throw new Error(`GIA \u63A7\u4EF6 ${e.name||e.id?.id} \u7F3A\u5C11\u591A\u5E73\u53F0\u53D8\u6362`);for(let r of te)i[r]||(i[r]=structuredClone(n));return i}function ui(e){let t=e.ui?.content?.data||[];return t.some(i=>i.details?.textConfig)?t.some(i=>i.field501===71)?"textwindow":"textbox":t.some(i=>i.details?.cursorConfig)?"cursor":t.some(i=>Object.hasOwn(i.details||{},"templateRefSlot"))?"reference":t.some(i=>i.details?.gridView)?"grid":t.some(i=>i.details?.buttonPreset)?"button":t.some(i=>i.details?.keyHint)?"keyhint":t.some(i=>i.details?.image||i.details?.imageSlot)?"image":t.some(i=>Object.hasOwn(i.details||{},"effectSlot"))?"animation":t.some(i=>Object.hasOwn(i.details||{},"fullscreenEffectSlot"))?"fullscreen":(t.some(i=>Object.hasOwn(i.details||{},"containerNodeSlot")),"container")}function yr(e,{reverseSiblings:t=!1,idOffset:i=0}={}){if(!e.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let n=new Map(e.map((l,f)=>[l.id?.id,`n${i+f+1}`])),r=new Map,o=new Map,a=[];for(let l of e){let f=ui(l),h=he(l,"textConfig"),p=he(l,"imageSlot"),m=he(l,"image"),g=he(l,"buttonPreset"),I=he(l,"gridView"),k=he(l,"genericSlot"),E=he(l,"footerSlot"),$=he(l,"cursorConfig"),F=he(l,"keyHint"),U=he(l,"containerNodeSlot"),W=he(l,"templateRefSlot"),Z=he(l,"effectSlot"),q=he(l,"fullscreenEffectSlot"),O=B(f,{id:n.get(l.id?.id),guid:l.id?.id||0,giaInfoIndex:(l.ui?.content?.info||[]).find(b=>b.field501===2&&b.field502===6)?.index?.value,giaRelatedGuids:(l.ui?.content?.info||[]).find(b=>b.field501===4&&b.field502===4)?.related?.value||[],name:l.name||f,scriptMappingIds:(k?.field502||[]).map(b=>Number(b?.field1?.id)).filter(b=>Number.isSafeInteger(b)&&b>0),transformByPlatform:fs(l),syncAllDevices:he(l,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:k?.field501??0,footerField505:E?.field505??0,...f==="container"?{containerNodeSlot:U??""}:{},...f==="textbox"||f==="textwindow"?{textField501:h?.field501??20,textField503:h?.field503??12,textAlign:h?.align??0,...f==="textwindow"?{textField511:h?.field511??1,textViewField502:h?.viewFlags?.field502??1,textViewField503:h?.viewFlags?.field503??1}:{}}:{},...f==="cursor"?{cursorField501:$?.field501??1}:{},...f==="reference"?{templateRefSlot:W??""}:{},...f==="grid"?{gridField501:I?.field501??1,gridField507:I?.field507??1,gridField508:I?.field508??1,gridField509:I?.field509??1,gridField511:I?.field511??5,gridField512:I?.field512??1}:{},...f==="keyhint"?{keyHintField501:F?.field501??1,keyHintField502:F?.field502??1}:{},...f==="image"?{imageField502:m?.field502??1,imageField504:m?.field504??1,imageField505:m?.field505??1,imageField507:m?.field507??2,imageFillType:m?.fillType??1}:{},...f==="animation"?{effectSlot:Z??""}:{},...f==="fullscreen"?{fullscreenEffectSlot:q??""}:{}},...f==="textbox"||f==="textwindow"?{text:h?.text?.value??"",fontSize:h?.fontSize??20,minimumFontSize:h?.minimumFontSize??20,adaptiveFontSize:h?.adaptive===1,fontColor:h?.color??4294967295,bgColor:h?.color2??0,enableOutline:h?.outlineOff!==1,outlineColor:h?.color3??858993459,horizontalAlignment:h?.align===1?"Middle":h?.align===2?"Right":"Left",verticalAlignment:"Top",...f==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...f==="image"?{imageSource:"StaticReference",imageId:p?.assetId??0,imageColor:Number.isFinite(p?.field502)?p.field502>>>0:4294967295,enableMask:m?.enableMask===1,enableSoftEdge:m?.enableSoftEdge===1,enableFill:m?.enableFill===1,softEdgeMode:m?.softEdgePixel===1?"Pixel":"Percentage",softEdgeWidthX:m?.border?.field501??8,softEdgeWidthY:m?.border?.field502??8,horizontalSoftRange:m?.field512??85,verticalSoftRange:m?.field513??85,fillType:{1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[m?.fillType]||"Horizontal",fillAmount:Number.isFinite(m?.field508)?Math.max(0,Math.min(1,m.field508/100)):m?.enableFill===1?0:1,reverseMaskArea:m?.reverseMask===1}:{},...f==="button"?{interactable:g?.interactable===1,raycastTarget:g?.raycastTarget===1,clickAudioId:g?.clickAudioId??50888}:{},...f==="grid"?{cellSizeX:I?.cellSize?.field501??50,cellSizeY:I?.cellSize?.field502??50,spacingX:I?.gap?.field501??8,spacingY:I?.gap?.field502??8,padding1X:I?.padding1?.field501??20,padding1Y:I?.padding1?.field502??20,padding2X:I?.padding2?.field501??20,padding2Y:I?.padding2?.field502??20,previewCount:I?.field511??5}:{},...f==="reference"?{referencedPrefabId:W??""}:{},...f==="keyhint"?{keyboardKeyCode:F?.field502??null,controllerKeyCode:F?.field501??null}:{},...f==="animation"?{animationId:Z??""}:{},...f==="fullscreen"?{animationId:q??""}:{}});r.set(l.id?.id,O),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(h?.align)&&a.push(`${O.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${h.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),f==="image"&&![void 0,0,1,2,3,4,5].includes(m?.fillType)&&a.push(`${O.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${m.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),f==="button"&&o.set(O.id,{unavailableChildId:g?.disabledChild,hoverChildId:g?.hoverChild,pressedChildId:g?.pressedChild,selectedChildId:g?.selectedChild})}let s=[],c=new Set;for(let l of e){let f=r.get(l.id?.id),h=(l.ui?.content?.children||[]).map(p=>r.get(p)).filter(Boolean);if(h.length){f.children=t?h.slice().reverse():h;for(let p of h)c.add(p.id)}}for(let l of e){let f=r.get(l.id?.id),h=l.ui?.content?.parent||0,p=r.get(h);p?c.has(f.id)||(t?p.children.unshift(f):p.children.push(f)):s.push(f)}for(let[l,f]of o){let h=[...r.values()].find(p=>p.id===l);for(let[p,m]of Object.entries(f))h[p]=n.get(m)||null}return{nodes:r,rootCandidates:s,warnings:a}}function Gr(e){let t=ci(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[];if(!n.some(g=>g.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let r=n.find(g=>g.which===21)||null,o=n.filter(g=>Number(g.which)===70),a=i.accessories||[],s=new Set((r?.relatedIds||[]).map(g=>g.id||0)),c=r?s.size?a.filter(g=>s.has(g.id?.id||0)):a:[],l=o.length?[...o,...a.filter(g=>!s.has(g.id?.id||0))]:r?[]:[...n,...a];if(!c.length&&!l.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let f=["GIA \u5BFC\u5165\u4E3A\u5DF2\u9A8C\u8BC1 UI \u5B57\u6BB5\u7684\u8BED\u4E49\u5BFC\u5165\uFF1B\u672A\u77E5 protobuf \u5B57\u6BB5\u4E0D\u4F1A\u8FDB\u5165 Authoring JSON\u3002"],h=Dr(i);f.push(...h.warnings);let p=null,m=null;if(c.length){let g=yr(c,{reverseSiblings:!0,idOffset:0});f.push(...g.warnings);let I=g.rootCandidates.find(E=>E.kind==="container")||g.rootCandidates[0];if(!I)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let k=B("server-container",{id:"sc1",guid:r?.id?.id||0,name:r?.name||"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",giaRelatedGuids:(r?.ui?.content?.info||[]).find(E=>E.field501===4&&E.field502===4)?.related?.value||[]});k.children=[I],g.rootCandidates.length>1&&f.push(`\u68C0\u6D4B\u5230 ${g.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${I.name}\u201D\u4E3A\u6839\u7684\u6811\u3002`),p={version:1,layoutSchemaVersion:ce,meta:{name:r?.name||"\u5BFC\u5165\u7684\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:I.id,script:{controlId:I.id,path:"",source:""},root:k}}if(l.length){let g=yr(l,{reverseSiblings:!1,idOffset:1e3});if(f.push(...g.warnings),!g.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let I=B("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});I.children=g.rootCandidates,m={version:1,layoutSchemaVersion:ce,meta:{name:g.rootCandidates.length===1?g.rootCandidates[0].name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868",assetType:"client-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:g.rootCandidates[0].id,script:{controlId:g.rootCandidates[0].id,path:"",source:""},root:I},p||(p=m)}return{project:p,clientProject:m&&p!==m?m:void 0,scripts:h.scripts,warnings:f,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(r&&o.length)}}}function Vr(e){let t=ci(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[],r=i.accessories||[],o=[],a=(p,m)=>p!=null&&Object.prototype.hasOwnProperty.call(p,m),s=new Map,c=[];/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||o.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`);let l=n.filter(p=>p.which===70).map(p=>{let m=ui(p),g=p.ui?.content?.info||[],I=g.find(F=>F.field501===2&&F.field502===6)?.index?.value,k=Sr[m],E=g.find(F=>F.field501===4&&F.field502===4),$=E?.related?.value||[];return(!Number.isSafeInteger(I)||I<=0)&&o.push(`${p.name}: Info.index=${I??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),E||o.push(`${p.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:p.id?.id||0,name:p.name||"",kind:m,actualIndex:I,expectedIndex:k,relatedPresent:!!E,relatedGuids:$}});l.length||o.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let f=0,h=0;for(let p of[...n,...r]){if(!p.ui?.content)continue;let m=p.id?.id||0,g=p.ui.content,I=ui(p),k=n.includes(p)&&p.which===70,E=`${p.name||"<unnamed>"}(${m||"<missing-guid>"})`;!Number.isSafeInteger(m)||m<=0||m>2147483647?o.push(`${E}: GraphUnit GUID \u975E\u6CD5`):s.has(m)?o.push(`${E}: GUID \u4E0E ${s.get(m).name||"<unnamed>"} \u91CD\u590D`):s.set(m,p),(p.id?.class!==1||p.id?.type!==8)&&o.push(`${E}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),g.guid!==m&&o.push(`${E}: content.guid=${g.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),k&&p.which!==70&&o.push(`${E}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!k&&p.which!==15&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let $=g.info||[],F=$.find(S=>S.field501===1&&S.field502===5),U=$.find(S=>S.field501===2&&S.field502===6);F?.guid?.value!==m&&o.push(`${E}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),(!Number.isSafeInteger(U?.index?.value)||U.index.value<=0)&&o.push(`${E}: Info.index=${U?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let W=$.find(S=>S.field501===4&&S.field502===4);k&&!W&&o.push(`${E}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!k&&W&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let Z=Ir[I],q=g.data||[],O=q.map(S=>`${S.field501}/${S.field502}`),b=Z?.map(([S])=>S)||[];Z?JSON.stringify(O)!==JSON.stringify(b)&&o.push(`${E}: Data \u69FD\u4F4D\u987A\u5E8F ${O.join(",")}\uFF0C\u5E94\u4E3A ${b.join(",")}`):o.push(`${E}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${I}`);for(let S=0;S<Math.min(q.length,Z?.length||0);S+=1){let P=q[S],[z,G,ie]=Z[S];if(a(P,G)||o.push(`${E}: Data ${z} \u7F3A\u5C11 ${G} \u5206\u652F`),!ie)continue;a(P.details,ie)||o.push(`${E}: Details ${z} \u7F3A\u5C11 ${ie} \u5206\u652F`);let j=Cr[z];(P.details?.field501!==j||P.details?.field502!==P.field502||P.details?.field503!==1)&&o.push(`${E}: Details ${z} \u6807\u8BB0\u5E94\u4E3A ${j}/${P.field502}/1`);let ue=P.details?.nodeRef;(ue?.class!==1||ue?.type!==8||ue?.id!==m)&&o.push(`${E}: Details ${z} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let x=(p.ui.content.data||[]).find(S=>S.field501===4&&S.field502===86);x&&(a(x.field14,"field17")?f+=1:o.push(`${E}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),a(x.details?.field14,"field17")?f+=1:o.push(`${E}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let v=(p.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];v.length!==4&&o.push(`${E}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${v.length}\uFF0C\u5E94\u4E3A 4`);let C=v.map(S=>S.platformType||0);JSON.stringify(C)!==JSON.stringify([0,1,2,3])&&o.push(`${E}: \u5E73\u53F0\u987A\u5E8F ${C.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let M=(p.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform;M?.multiPlatform?.field502!==zt[I]&&o.push(`${E}: \u53D8\u6362 preset=${M?.multiPlatform?.field502??"<missing>"}\uFF0C${I} \u5E94\u4E3A ${zt[I]}`);for(let S of v)a(S.transform,"field508")?h+=1:o.push(`${E}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);c.push({id:m,name:p.name||"",kind:I,template:k,parent:g.parent||0,children:[...g.children||[]],relatedIds:(p.relatedIds||[]).map(S=>S.id||0),dataSignatures:O})}for(let p of c){let m=`${p.name||"<unnamed>"}(${p.id})`;if(JSON.stringify(p.relatedIds)!==JSON.stringify(p.children)&&o.push(`${m}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),p.template&&p.parent&&o.push(`${m}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!p.template){let g=s.get(p.parent);g?(g.ui?.content?.children||[]).includes(p.id)||o.push(`${m}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):o.push(`${m}: parent=${p.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let g of p.children){let I=s.get(g);I?(I.ui?.content?.parent||0)!==p.id&&o.push(`${m}: child=${g} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):o.push(`${m}: child=${g} \u4E0D\u5B58\u5728`)}}return{valid:o.length===0,errors:o,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:l.length,accessoryCount:r.length,templates:l,units:c,explicitEmpty:{field17:f,rectField508:h}}}function en(e){let t=ci(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=(i.graph||[]).filter(S=>S.ui?.content&&Number(S.which)===21),r=(i.graph||[]).filter(S=>Number(S.which)===70),o=(i.graph||[]).filter(S=>Number(S.which)===bt),a=(i.accessories||[]).filter(S=>S.ui?.content),s=[],c=(S,P)=>S!=null&&Object.prototype.hasOwnProperty.call(S,P);/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||s.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`),n.length!==1&&s.push(`\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F UIControlGroup \u6570\u91CF=${n.length}\uFF0C\u5E94\u4E3A 1`);let l=(i.graph||[]).filter(S=>{let P=Number(S.which);return P===bt||P===70||P===21?!1:!S.ui?.content});l.length&&s.push(`Root.graph \u542B ${l.length} \u4E2A\u65E0\u6CD5\u8BC6\u522B\u7684\u975E\u63A7\u4EF6/\u975E\u811A\u672C\u5355\u5143`);let f=n[0];if(!f)return{valid:!1,errors:s,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:a.length,controls:[],scriptCount:o.length,explicitEmpty:{field17:0,rectField508:0}};let h=[f,...a],p=new Map;for(let S of h){let P=S.id?.id||0,z=`${S.name||"<unnamed>"}(${P||"<missing-guid>"})`;!Number.isSafeInteger(P)||P<=0||P>2147483647?s.push(`${z}: GraphUnit GUID \u975E\u6CD5`):p.has(P)?s.push(`${z}: GUID \u91CD\u590D`):p.set(P,S),(S.id?.class!==1||S.id?.type!==8)&&s.push(`${z}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),S.ui?.content?.guid!==P&&s.push(`${z}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let m=f.id?.id||0,g=f.ui.content,I=`${f.name||"<unnamed>"}(${m})`;f.which!==21&&s.push(`${I}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let k=g.info||[];k.find(S=>S.field501===1&&S.field502===5)?.guid?.value!==m&&s.push(`${I}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),k.find(S=>S.field501===2&&S.field502===6)?.index?.value!==1&&s.push(`${I}: Info.index \u5FC5\u987B\u4E3A 1`);let E=k.find(S=>S.field501===4&&S.field502===4);E||s.push(`${I}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let $=0,F=0,U=(S,P,z,G=!1)=>{let ie=S.id?.id||0,j=`${S.name||"<unnamed>"}(${ie})`,ue=S.ui.content.data||[],Te=ue.map(X=>`${X.field501}/${X.field502}`),ae=z.map(([X])=>X);JSON.stringify(Te)!==JSON.stringify(ae)&&s.push(`${j}: Data \u69FD\u4F4D\u987A\u5E8F ${Te.join(",")}\uFF0C\u5E94\u4E3A ${ae.join(",")}`);for(let X=0;X<Math.min(ue.length,z.length);X+=1){let Ie=ue[X],[Xe,ei,Rt]=z[X];if(c(Ie,ei)||s.push(`${j}: Data ${Xe} \u7F3A\u5C11 ${ei} \u5206\u652F`),!Rt)continue;c(Ie.details,Rt)||s.push(`${j}: Details ${Xe} \u7F3A\u5C11 ${Rt} \u5206\u652F`);let Re=Cr[Xe];(Ie.details?.field501!==Re||Ie.details?.field502!==Ie.field502||Ie.details?.field503!==1)&&s.push(`${j}: Details ${Xe} \u6807\u8BB0\u5E94\u4E3A ${Re}/${Ie.field502}/1`);let Mt=Ie.details?.nodeRef;(Mt?.class!==1||Mt?.type!==8||Mt?.id!==ie)&&s.push(`${j}: Details ${Xe} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let lt=ue.find(X=>X.field501===4&&X.field502===(G?23:86)),He=G?"empty15":"field17";c(lt?.field14,He)?G||($+=1):s.push(`${j}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${He} \u7A7A\u4E32`),c(lt?.details?.field14,He)?G||($+=1):s.push(`${j}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${He} \u7A7A\u4E32`);let _t=ue.find(X=>X.details?.transform)?.details?.transform,ut=_t?.multiPlatform?.platforms||[];ut.length!==4&&s.push(`${j}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${ut.length}\uFF0C\u5E94\u4E3A 4`);let Pt=ut.map(X=>X.platformType||0);JSON.stringify(Pt)!==JSON.stringify([0,1,2,3])&&s.push(`${j}: \u5E73\u53F0\u987A\u5E8F ${Pt.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let Tt=G?zt["server-container"]:zt[P];_t?.multiPlatform?.field502!==Tt&&s.push(`${j}: \u53D8\u6362 preset=${_t?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${Tt}`);for(let X of ut)c(X.transform,"field508")?F+=1:s.push(`${j}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return Te};U(f,"server-container",es,!0);let W=(f.relatedIds||[]).map(S=>S.id||0),Z=new Set(W),q=a.filter(S=>Z.has(S.id?.id||0)),O=q.map(S=>S.id?.id||0);JSON.stringify(W)!==JSON.stringify(O)&&s.push(`${I}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let b=g.data?.find(S=>S.details?.rootChildRef)?.details?.rootChildRef?.guid||0,x=p.get(b);(!x||!q.includes(x))&&s.push(`${I}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),O[0]!==b&&s.push(`${I}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let v=[];for(let S of q){let P=S.id?.id||0,z=S.ui.content,G=`${S.name||"<unnamed>"}(${P})`,ie=ui(S);S.which!==15&&s.push(`${G}: which \u5FC5\u987B\u4E3A UIControl(15)`);let j=z.info||[];(j.length!==1||j[0]?.field501!==1||j[0]?.field502!==5||j[0]?.guid?.value!==P)&&s.push(`${G}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let ue=Ir[ie];ue||s.push(`${G}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${ie}`);let Te=ue?U(S,ie,ue):[];v.push({id:P,name:S.name||"",kind:ie,parent:z.parent||0,children:[...z.children||[]],relatedIds:(S.relatedIds||[]).map(ae=>ae.id||0),dataSignatures:Te})}let C=v.find(S=>S.id===b);C&&(C.kind!=="container"&&s.push(`${C.name}(${b}): \u6839\u63A7\u4EF6\u5FC5\u987B\u4E3A\u5BB9\u5668\u8282\u70B9`),C.parent&&s.push(`${C.name}(${b}): \u6839\u63A7\u4EF6\u4E0D\u5E94\u6709 parent`));let M=new Map(v.map(S=>[S.id,S]));for(let S of v){let P=`${S.name}(${S.id})`;if(JSON.stringify(S.relatedIds)!==JSON.stringify(S.children)&&s.push(`${P}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),S.id!==b){let z=M.get(S.parent);z?z.children.includes(S.id)||s.push(`${P}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):s.push(`${P}: parent=${S.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let z of S.children){let G=M.get(z);G?G.parent!==S.id&&s.push(`${P}: child=${z} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):s.push(`${P}: child=${z} \u4E0D\u5B58\u5728`)}}return{valid:s.length===0,errors:s,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:m,name:f.name||"",relatedGuids:E?.related?.value||[],rootGuid:b},accessoryCount:a.length,controls:v,scriptCount:o.length,explicitEmpty:{field17:$,rectField508:F}}}function Yr(e,t=[]){if(!e||e.layoutSchemaVersion===ce)return e;if(e.layoutSchemaVersion!==void 0&&e.layoutSchemaVersion!==1)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=2 \u6216\u53EF\u8FC1\u79FB\u7684\u65E7\u5E03\u5C40\uFF0C\u6536\u5230 ${e.layoutSchemaVersion}`);if(!e.root)return{...e,layoutSchemaVersion:ce};let i=structuredClone(e),n=0;return J(i.root,r=>{let o=r.transformByPlatform||{},a=r.transformByCanvas||{},s=r.name||r.id;for(let l of Object.keys(o))if(!te.includes(l))throw new Error(`${s}: unknown platform ${l}`);let c={};for(let l of te){let f=dt[l],h=K[f].platform,p=Object.keys(K).filter(k=>K[k].platform===h&&a[k]),m=a[f]?f:p[0],g=l==="CONTROLLER_CONSOLE"?c.KEYBOARD:l==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,I=o[l]??g??(m?a[m]:null);if(c[l]=I?Ce(I):Ui(r.kind),I||t.push(`${s}: ${l} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!o[l]&&!g&&m&&m!==f&&t.push(`${s}: \u7F3A\u5C11 ${f}\uFF0C\u5DF2\u91C7\u7528 ${m} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!g)for(let k of p)JSON.stringify(c[l])!==JSON.stringify(Ce(a[k]))&&t.push(`${s}: ${k} \u4E0E ${l} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[l]?"\u5DF2\u6709\u5E73\u53F0":m}\u53C2\u6570`)}Oe(c,`${s}.transformByPlatform`),r.transformByPlatform=c,delete r.transformByCanvas,n++}),i.layoutSchemaVersion=ce,t.unshift(`\u5DF2\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E03\u5C40\uFF1A${n} \u4E2A\u63A7\u4EF6\u8F6C\u6362\u4E3A\u56DB\u5E73\u53F0\u53C2\u6570\uFF1B\u518D\u6B21\u4FDD\u5B58\u5C06\u4F7F\u7528\u65B0\u7248\u683C\u5F0F`),i}function tn(e){if(![1,2,3,4].includes(e))throw new Error(`\u4EC5\u652F\u6301 version=1\u20134 \u7684\u5B58\u6863\uFF0C\u6536\u5230 ${e}`)}function rn(e,t,i,n=e.canvasId){let r=$e(e.root,t);return!r||r.kind==="server-container"?de(n):i[r.id]||de(n)}function xe(e,{warnings:t=[]}={}){if(!e)return De();if(e=Yr(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==ce)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${ce} \u7684\u56DB\u5E73\u53F0\u5E03\u5C40\uFF0C\u4E0D\u652F\u6301\u65E7\u753B\u5E03\u5E03\u5C40\u6216\u5176\u4ED6\u7248\u672C`);let i=e.meta?.assetType==="client-control-template"?"client-control-template":"server-control-template",n=i==="client-control-template"?Je():De(),r={layoutSchemaVersion:ce,version:Number.isSafeInteger(e.version)&&e.version>0?e.version:1,meta:{name:String(e.meta?.name||n.meta.name),assetType:i,sourceFormat:String(e.meta?.sourceFormat||n.meta.sourceFormat),sourceFile:String(e.meta?.sourceFile||""),...e.meta?.gameVersion?{gameVersion:String(e.meta.gameVersion)}:{},...e.meta?.giaFilePath?{giaFilePath:String(e.meta.giaFilePath)}:{},...Number.isSafeInteger(Number(e.meta?.giaOwnerUid))?{giaOwnerUid:Number(e.meta.giaOwnerUid)}:{},...Number.isSafeInteger(Number(e.meta?.giaTimestamp))?{giaTimestamp:Number(e.meta.giaTimestamp)}:{},...Number.isSafeInteger(Number(e.meta?.giaFileId))?{giaFileId:Number(e.meta.giaFileId)}:{},...e.meta?.giaFileName?{giaFileName:String(e.meta.giaFileName)}:{},...Number.isSafeInteger(Number(e.meta?.giaModeFlag))&&Number(e.meta.giaModeFlag)>=0?{giaModeFlag:Number(e.meta.giaModeFlag)}:{}},canvasId:e.canvasId&&K[e.canvasId]?e.canvasId:ti,selectedId:e.selectedId||n.selectedId,root:Ki(e.root||n.root)};return Kr(r),r}function Kr(e){let t=new Set;J(e.root,i=>{if(typeof i.id!="string"||!i.id)throw new Error("node id must be a non-empty string");if(t.has(i.id))throw new Error(`duplicate node id: ${i.id}`);t.add(i.id)}),t.has(e.selectedId)||(e.selectedId=Xi(e.root).id)}function Br(e){return Fe(yt(e))}function ds(e,t){let i=!1;return J(e,n=>{n.id===t&&(i=!0)}),i}function hs(e,t,i,n){let o=Ge(e.root,e.canvasId).boxes[t.id],a=i.children.findIndex(h=>h.id===t.id);if(a<0)throw new Error("reparent: source node is not attached");if(i.children.splice(a,1),n.children.push(t),!o)return;let s=Ge(e.root,e.canvasId),c=n.kind==="server-container"?de(e.canvasId):s.boxes[n.id]||de(e.canvasId),l=ze(t.transformByPlatform,e.canvasId),f=Le(c,l,{posX:o.centerX,posY:o.centerY,width:o.width,height:o.height});vt(e,t,f)}function ps(e,t){return e.meta.assetType!=="client-control-template"?Li(e.root,t):(e.root.children||[]).flatMap(i=>Li(i,t))}function Lr(e,t){let i=pr(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let n=Dt(e),r=new Set;return n&&n.kind!=="server-container"&&J(n,o=>r.add(o.id)),i.filter(o=>r.has(o.id))}function Wr(e){let{canvas:t,boxes:i}=Ge(e.root,e.canvasId),n=Vt(e),r=le(e.root,e.selectedId),o=r?i[r.id]:null;return D({layoutSchemaVersion:ce,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:K[e.canvasId].platform,label:K[e.canvasId].label,presets:Object.values(K).map(a=>({id:a.id,label:a.label,width:a.width,height:a.height,platform:a.platform}))},selectedId:e.selectedId,asset:{type:e.meta.assetType,label:e.meta.assetType==="client-control-template"?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F",templateCount:e.meta.assetType==="client-control-template"?e.root.children.length:1,currentTemplateId:e.meta.assetType==="client-control-template"&&Dt(e)?.id||""},tree:ps(e,n),boxes:Lr(e,i),inspector:mr(r,e.canvasId,o||t,n),root:e.root})}function vt(e,t,i){let n=Ge(e.root,e.canvasId),r=rn(e,t.id,n.boxes),o={};if(t.syncAllDevices!==!1)for(let a of te){if(a===We(e.canvasId))continue;let s=dt[a],c=Ge(e.root,s,a);o[a]=rn(e,t.id,c.boxes,s)}t.transformByPlatform=hr({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:r,targetParentBoxByPlatform:o})}var ms=new Set(["name","active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text","imageId","imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","enableFill","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount","reverseMaskArea","raycastTarget","interactable","clickAudioId","unavailableChildId","hoverChildId","pressedChildId","selectedChildId","showScrollBar","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","scrollDirection","layoutConstraint","referencedPrefabId","animationId","keyboardKeyCode","controllerKeyCode"]),gs=new Set(["posX","posY","width","height"]),ys=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function bs(e){if(typeof e=="number"&&Number.isFinite(e))return e>>>0;if(typeof e=="string"){let t=e.trim();if(t.startsWith("#")){let n=t.slice(1);if(n.length===6)return(4278190080|parseInt(n,16))>>>0;if(n.length===8)return parseInt(n,16)>>>0}let i=Number(t);if(Number.isFinite(i))return i>>>0}throw new Error("color must be an ARGB integer or #RRGGBB/#AARRGGBB string")}function _e(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function Ur(e){if(e===!0||e===1||e==="1"||e==="true")return!0;if(e===!1||e===0||e==="0"||e==="false")return!1;throw new Error("boolean field requires true or false")}var vs=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode"]),Ss=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),ws=new Set(["name","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),Hr=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),Xr={softEdgeMode:["Percentage","Pixel"],fillType:["Horizontal","Vertical","Radial90","Radial180","Radial360"],fillHorizontalType:["Left","Right"],fillVerticalType:["Bottom","Top"],fillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],fillRadialType:["Bottom","Left","Top","Right"]};function Is(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&le(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:n}=Ge(e.root,e.canvasId),r=Lr(e,n),o=gr(r,Number(t.x),Number(t.y));return o&&(e.selectedId=o),e}if(i==="setCanvas")return t.canvasId&&K[t.canvasId]&&(e.canvasId=t.canvasId),e;if(i==="setScript")throw new Error("\u811A\u672C\u7531\u5B58\u6863\u7EDF\u4E00\u7BA1\u7406\uFF0C\u8BF7\u4F7F\u7528 addScript / updateScript / removeScript \u64CD\u4F5C");if(i==="newAsset"){let n=t.assetType==="client-control-template"?Je():De();return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}if(i==="addTemplate"){if(e.meta.assetType!=="client-control-template")throw new Error("\u53EA\u6709\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B\u53EF\u4EE5\u65B0\u589E\u6A21\u677F");let n=B(t.kind,{id:Hi(e.root),guid:Br(e.root),name:t.name||`\u65B0${t.kind==="container"?"\u5BB9\u5668\u8282\u70B9":t.kind}\u6A21\u677F`});return e.root.children.push(n),e.selectedId=n.id,e}if(i==="add"){let n=le(e.root,t.parentId||e.selectedId);if(!n)throw new Error("add: parent not found");let r=cr(n,t.kind,{id:Hi(e.root),guid:Br(e.root),name:t.name});return e.selectedId=r.id,e}if(i==="reparent"){if(e.meta.assetType!=="client-control-template")throw new Error("\u5C42\u7EA7\u8C03\u6574\u4EC5\u9002\u7528\u4E8E\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B");let n=le(e.root,t.id||e.selectedId),r=n?$e(e.root,n.id):null,o=le(e.root,t.parentId);if(!n||n.kind==="server-container"||!r)throw new Error("reparent: node not found");if(!o)throw new Error("reparent: parent not found");if(o.id===n.id||ds(n,o.id))throw new Error("\u63A7\u4EF6\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u8EAB\u6216\u5176\u540E\u4EE3\u4E0B\u9762");if(o.kind==="server-container"&&r.kind==="server-container")return e;if(r.kind==="server-container"&&o.kind!=="server-container"&&e.root.children.length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u9876\u5C42\u6A21\u677F");return hs(e,n,r,o),e.selectedId=n.id,e}if(i==="moveSibling"){let n=le(e.root,t.id||e.selectedId),r=n?$e(e.root,n.id):null;if(!n||!r)throw new Error("moveSibling: node not found");let o=r.children.findIndex(c=>c.id===n.id),a=t.direction==="up"?-1:t.direction==="down"?1:0,s=o+a;return!a||s<0||s>=r.children.length||(r.children.splice(o,1),r.children.splice(s,0,n),e.selectedId=n.id),e}if(i==="remove"){let n=t.id||e.selectedId,r=$e(e.root,n);if(r?.kind==="server-container"){if(e.meta.assetType!=="client-control-template")throw new Error("\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F\u7684\u5BA2\u6237\u7AEF\u6839\u8282\u70B9\u4E0D\u80FD\u5220\u9664");if((e.root.children||[]).length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u6A21\u677F")}return fr(e.root,n)&&(J(e.root,o=>{if(o.kind==="button")for(let a of Hr)o[a]&&!le(e.root,o[a])&&(o[a]=null)}),e.selectedId=r?r.id:e.root.id),e}if(i==="set"){let n=le(e.root,t.id||e.selectedId);if(!n)throw new Error("set: node not found");let r=t.key;r==="reverseMask"&&(r="reverseMaskArea");let o=t.value;if(r.startsWith("giaRaw.")){let l=r.slice(7);if(!l||l.includes("."))throw new Error("invalid raw GIA field path");let f=sr(n.kind,l);if(!f)throw new Error(`unknown raw GIA field for ${n.kind}: ${l}`);if(n.giaRaw||={},n.giaRaw[l]=Gi(f,o),(n.kind==="textbox"||n.kind==="textwindow")&&l==="textAlign"){let h={0:"Left",1:"Middle",2:"Right"}[n.giaRaw[l]];h&&(n.horizontalAlignment=h)}if(n.kind==="image"&&l==="imageFillType"){let h={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[n.giaRaw[l]];h&&(n.fillType=h)}return n.kind==="keyhint"&&l==="keyHintField502"&&(n.keyboardKeyCode=n.giaRaw[l]),n.kind==="keyhint"&&l==="keyHintField501"&&(n.controllerKeyCode=n.giaRaw[l]),e}if(r==="syncAllDevices"){if(n.syncAllDevices=Ur(o),n.syncAllDevices){let l=ze(n.transformByPlatform,e.canvasId);vt(e,n,l)}return e}if(ms.has(r)){if(r.endsWith("Color")&&(o=bs(o)),vs.has(r)){if(o=_e(o,r),o<0)throw new Error(`${r} must not be negative`);if((r==="imageId"||r==="clickAudioId"||r==="keyboardKeyCode"||r==="controllerKeyCode")&&(o=Math.trunc(o)),r==="fillAmount"&&o>1)throw new Error("fillAmount must be between 0 and 1")}if(Ss.has(r)&&(o=Ur(o)),ws.has(r)&&(o=String(o??"")),r==="horizontalAlignment"&&!["Left","Middle","Right"].includes(o))throw new Error("invalid horizontalAlignment");if(r==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(o))throw new Error("invalid verticalAlignment");if(Xr[r]&&!Xr[r].includes(o))throw new Error(`invalid ${r}`);if(Hr.has(r))if(o===""||o===void 0||o===null)o=null;else{o=String(o);let l=le(e.root,o);if(!l||l===n||l.kind==="server-container"||!(n.children||[]).some(f=>f.id===o))throw new Error(`${r} must reference a direct child of this button`)}if(n[r]=o,(n.kind==="textbox"||n.kind==="textwindow")&&r==="horizontalAlignment"&&(n.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o]),n.kind==="image"&&r==="fillType"){let l={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o];l&&(n.giaRaw.imageFillType=l)}return n.kind==="reference"&&r==="referencedPrefabId"&&(n.giaRaw.templateRefSlot=o),n.kind==="grid"&&r==="previewCount"&&(n.giaRaw.gridField511=Math.trunc(o)),n.kind==="keyhint"&&r==="keyboardKeyCode"&&(n.giaRaw.keyHintField502=Math.trunc(o)),n.kind==="keyhint"&&r==="controllerKeyCode"&&(n.giaRaw.keyHintField501=Math.trunc(o)),(n.kind==="animation"||n.kind==="fullscreen")&&r==="animationId"&&(n.giaRaw[n.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=o),e}let{boxes:a}=Ge(e.root,e.canvasId),s=rn(e,n.id,a),c=ze(n.transformByPlatform,e.canvasId);if(r==="anchorType"){let l=nn(a[n.id]),f=ir(c,o);return f=Le(s,f,l),vt(e,n,f),e}if(r==="rotationZ"){let l={...c,rotation:{...c.rotation,z:_e(o,r)}};return vt(e,n,l),e}if(ys.has(r)){let l=nn(a[n.id]),f={...c,anchorMin:{...c.anchorMin},anchorMax:{...c.anchorMax},pivot:{...c.pivot}};return r==="anchorMinX"&&(f.anchorMin.x=_e(o,r)),r==="anchorMinY"&&(f.anchorMin.y=_e(o,r)),r==="anchorMaxX"&&(f.anchorMax.x=_e(o,r)),r==="anchorMaxY"&&(f.anchorMax.y=_e(o,r)),r==="pivotX"&&(f.pivot.x=_e(o,r)),r==="pivotY"&&(f.pivot.y=_e(o,r)),vt(e,n,Le(s,f,l)),e}if(gs.has(r)){let l=nn(a[n.id]),f=_e(o,r);if((r==="width"||r==="height")&&f<0)throw new Error(`${r} must not be negative`);return l[r]=f,vt(e,n,Le(s,c,l)),e}throw new Error(`set: unknown key ${r}`)}if(i==="replace"){let n=xe(t.project);return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}throw new Error(`unknown op ${i}`)}function on(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");if(t.expectedRevision!==void 0&&Number(t.expectedRevision)!==e.version)throw new Error(`revision conflict: expected ${t.expectedRevision}, current ${e.version}`);let i=e.version,n=JSON.parse(JSON.stringify(e));return Is(n,t),Kr(n),n.version=i+1,Object.keys(e).forEach(r=>{delete e[r]}),Object.assign(e,n),e}function nn(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import Cs from"fengari";var{lua:u,lauxlib:re,lualib:qr,to_luastring:fi,to_jsstring:ks}=Cs,xs=u.LUA_TNIL,Es=u.LUA_TBOOLEAN,As=u.LUA_TNUMBER,_s=u.LUA_TSTRING,jr=u.LUA_TTABLE,Ps=u.LUA_TFUNCTION,an=u.LUA_TUSERDATA,Ee=u.LUA_OK,Jr=new WeakMap,sn=Symbol("luaTableEntries"),ln={__scriptHostKey:!0};function _(e){return fi(String(e))}function Ze(e,t){Jr.set(e,t)}function be(e){return Jr.get(e)}function ne(e,t,i){if(i==null){u.lua_pushnil(e);return}let n=typeof i;if(n==="boolean"){u.lua_pushboolean(e,i);return}if(n==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?u.lua_pushinteger(e,i):u.lua_pushnumber(e,i);return}if(n==="string"){u.lua_pushstring(e,_(i));return}if(n==="function"){Ms(e,t,i);return}if(i&&i[sn]){let r=i[sn];u.lua_createtable(e,Array.isArray(i)?i.length:0,r.length);for(let[o,a]of r)ne(e,t,o),ne(e,t,a),u.lua_settable(e,-3);return}if(Array.isArray(i)){u.lua_createtable(e,i.length,0);for(let r=0;r<i.length;r++)ne(e,t,i[r]),u.lua_rawseti(e,-2,r+1);return}if(i&&i.__kind==="EnumItem"){t.pushEnumItem(e,i);return}if(i&&i.__kind==="CursorEventData"){t.pushCursor(e,i);return}if(i&&i.__kind==="Script"){t.pushScript(e,i);return}if(i&&i.typeofName){t.pushControl(e,i);return}if(i&&i.SetEase){t.pushTween(e,i);return}if(n==="object"){u.lua_createtable(e,0,Object.keys(i).length);for(let[r,o]of Object.entries(i))ne(e,t,o),u.lua_setfield(e,-2,_(r));return}u.lua_pushnil(e)}function L(e,t){if(u.lua_isnil(e,t)||u.lua_type(e,t)===u.LUA_TNONE)return"";if(!u.lua_isstring(e,t)&&u.lua_type(e,t)!==u.LUA_TNUMBER)return`lua_type=${u.lua_type(e,t)}`;let i=u.lua_tostring(e,t);return i==null?"":ks(i)}function Ye(e,t){t=u.lua_absindex(e,t);let i=u.lua_type(e,t);if(i===an)return be(u.lua_touserdata(e,t));if(i===jr){u.lua_pushlightuserdata(e,ln),u.lua_rawget(e,t);let n=u.lua_type(e,-1)===an?u.lua_touserdata(e,-1):null;return u.lua_pop(e,1),n?be(n):null}return null}function pe(e,t,i){i=u.lua_absindex(e,i);let n=u.lua_type(e,i);if(n===xs)return null;if(n===Es)return!!u.lua_toboolean(e,i);if(n===As)return u.lua_isinteger(e,i)?u.lua_tointeger(e,i):u.lua_tonumber(e,i);if(n===_s)return L(e,i);if(n===an){let r=u.lua_touserdata(e,i);return be(r)??r}if(n===Ps)return Ts(e,t,i);if(n===jr){let r=Ye(e,i);if(r)return r;let o=[];for(u.lua_pushnil(e);u.lua_next(e,i)!==0;){let l=pe(e,t,-2),f=pe(e,t,-1);o.push([l,f]),u.lua_pop(e,1)}let a=new Map(o.filter(([l])=>Number.isInteger(l)&&l>=1)),s=0;for(;a.has(s+1);)s+=1;let c=s>0?[]:{};for(let[l,f]of o)Array.isArray(c)&&Number.isInteger(l)&&l>=1?c[l-1]=f:(typeof l=="string"||typeof l=="number")&&(c[l]=f);return Object.defineProperty(c,sn,{value:o}),c}return null}function Ts(e,t,i){t.luaFunctions||(t.luaFunctions=new Map);let n=typeof u.lua_topointer=="function"?u.lua_topointer(e,i):null;if(n!=null&&t.luaFunctions.has(n))return t.luaFunctions.get(n);u.lua_pushvalue(e,i);let r=re.luaL_ref(e,u.LUA_REGISTRYINDEX),o=Rs(e,t,r);return n!=null&&t.luaFunctions.set(n,o),o}function Rs(e,t,i){let n=(...r)=>{let o=u.lua_gettop(e);u.lua_rawgeti(e,u.LUA_REGISTRYINDEX,i);for(let l of r)ne(e,t,l);if(u.lua_pcall(e,r.length,u.LUA_MULTRET,0)!==Ee){let l=L(e,-1);throw u.lua_settop(e,o),new Error(l)}let s=u.lua_gettop(e)-o,c=[];for(let l=1;l<=s;l++)c.push(pe(e,t,o+l));if(u.lua_settop(e,o),c.length!==0)return c.length===1?c[0]:c};return n.__luaRef=i,n.__luaState=e,n}function Zr(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&re.luaL_unref(i,u.LUA_REGISTRYINDEX,t.__luaRef),t.__luaRef=null,t.__luaState=null,e?.luaFunctions)for(let[n,r]of e.luaFunctions)r===t&&e.luaFunctions.delete(n)}function Ms(e,t,i){u.lua_pushlightuserdata(e,i),u.lua_pushlightuserdata(e,t),u.lua_pushcclosure(e,function(r){let o=u.lua_touserdata(r,u.lua_upvalueindex(1)),a=u.lua_touserdata(r,u.lua_upvalueindex(2)),s=u.lua_gettop(r),c=[];for(let l=1;l<=s;l++)c.push(pe(r,a,l));try{let l=o(...c);if(Array.isArray(l)&&l.__multi){for(let f of l)ne(r,a,f);return l.length}return l===void 0?0:(ne(r,a,l),1)}catch(l){return u.lua_pushstring(r,_(String(l&&l.message?l.message:l))),u.lua_error(r)}},2)}function Qr(e){!e||typeof u.lua_close!="function"||u.lua_close(e)}function eo(e){if(re.luaL_loadstring(e,_(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
|
|
105
|
-
`)))===Ee&&u.lua_pcall(e,0,0,0),u.lua_settop(e,0),u.lua_pushnil(e),u.lua_setglobal(e,_("_VERSION")),u.lua_getglobal(e,_("string")),!u.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])u.lua_pushnil(e),u.lua_setfield(e,-2,_(i));if(u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,_("io")),u.lua_getglobal(e,_("os")),!u.lua_isnil(e,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))u.lua_pushnil(e),u.lua_setfield(e,-2,_(i));u.lua_pop(e,1),u.lua_getglobal(e,_("debug")),u.lua_isnil(e,-1)?u.lua_pop(e,1):(u.lua_getfield(e,-1,_("traceback")),u.lua_newtable(e),u.lua_pushvalue(e,-2),u.lua_setfield(e,-2,_("traceback")),u.lua_setglobal(e,_("debug")),u.lua_pop(e,2)),u.lua_getglobal(e,_("math")),u.lua_isnil(e,-1)||(u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,Number.isNaN(n)),1}),u.lua_setfield(e,-2,_("isnan")),u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,n===1/0||n===-1/0),1}),u.lua_setfield(e,-2,_("isinf"))),u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,_("package")),u.lua_pushnil(e),u.lua_setglobal(e,_("load")),u.lua_pushnil(e),u.lua_setglobal(e,_("loadfile")),u.lua_pushnil(e),u.lua_setglobal(e,_("dofile")),u.lua_pushnil(e),u.lua_setglobal(e,_("collectgarbage")),u.lua_pushnil(e),u.lua_setglobal(e,_("coroutine")),u.lua_pushnil(e),u.lua_setglobal(e,_("fengari"))}var to={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},Ns=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],di=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),Os=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],Fs={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},$s={container:["isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor"],textbox:["text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],textwindow:["interactable","showScrollBar","text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],image:["imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","reverseMaskArea","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount"],button:["interactable","clickAudioId","raycastTarget"],cursor:["raycastTarget"],grid:["itemPrefabIndex","raycastTarget","showScrollBar","interactable","scrollProgress"],keyhint:["keyboardKeyCode","controllerKeyCode"],animation:["animationId","playSoundEffect","layer"],fullscreen:["animationId","playSoundEffect"]},Ds=["GetChildren","GetChild","FindChild","SetActive","SetVisible","GetSiblingIndex","SetSiblingIndex","SetAsFirstSibling","SetAsLastSibling","GetAnchoredPosition","SetAnchoredPosition","GetSizeDelta","SetSizeDelta","GetAnchorMin","SetAnchorMin","GetAnchorMax","SetAnchorMax","GetPivot","SetPivot","GetLocalScale","SetLocalScale","GetLocalRotation","SetLocalRotation","GetScriptByPath","GetScript","GetScripts","AddKeyEventListener","RemoveKeyEventListener","RemoveKeyEventListeners","RemoveAllKeyEventListeners","AddNavigationEventListener","RemoveNavigationEventListener","RemoveNavigationEventListeners","RemoveAllNavigationEventListeners","SetControllerNavigation","GetControllerNavigation"],io=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],zs={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:io,cursor:io,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function un(e,t){return Ns.includes(t)||(Fs[e.kind]||[]).includes(t)?"ro":Os.includes(t)||($s[e.kind]||[]).includes(t)?"rw":null}function no(e,t){return Ds.includes(t)||(zs[e.kind]||[]).includes(t)}var Gs={container:{isolateNavigation:!1,disableKeyEventPassthrough:!1,disableCursorEventPassthrough:!1,showCursor:!1},textbox:{text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},textwindow:{interactable:!0,showScrollBar:!0,text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},image:{imageSource:null,imageId:0,imageColor:4294967295,imageType:null,enableMask:!1,enableSoftEdge:!1,softEdgeMode:"Percentage",softEdgeWidthX:8,softEdgeWidthY:8,horizontalSoftRange:85,verticalSoftRange:85,enableFill:!1,fillType:"Unused",fillHorizontalType:"Left",fillVerticalType:"Bottom",fillRadial90Type:"BottomLeft",fillRadialType:"Bottom",reverseMaskArea:!1,fillAmount:1},button:{interactable:!0,clickAudioId:0,raycastTarget:!0,unavailableChildId:null,hoverChildId:null,pressedChildId:null,selectedChildId:null,pressed:!1},cursor:{raycastTarget:!0},grid:{itemCount:0,itemPrefabIndex:null,raycastTarget:!0,interactable:!0,showScrollBar:!0,scrollDirection:"Vertical",layoutConstraint:"AutoWrap",layoutConstraintFixedCount:null,scrollProgress:0,cellSizeX:50,cellSizeY:50,spacingX:8,spacingY:8,padding1X:20,padding1Y:20,padding2X:20,padding2Y:20,previewCount:5},keyhint:{keyboardKeyCode:null,controllerKeyCode:null},animation:{animationId:null,playSoundEffect:null,layer:null,raycastTarget:!1},fullscreen:{animationId:null,playSoundEffect:null,raycastTarget:!1},reference:{referencedPrefabIndex:null}},Be=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=to[this.kind]||to.container,this.alive=!0,this.Id=i.Id??t.nextControlId(),this.authoringId=i.authoringId??null,this.prefabIndex=i.prefabIndex??0,this.name=i.name??"",this.active=i.active===!0,this.visible=i.visible!==!1,this._parent=null,this.children=[],this.scripts=[],this.cursorListeners=new Map,this.keyListeners=new Map,this.navListeners=new Map,this.navConfig=new Map,this.anchoredPositionX=i.anchoredPositionX??0,this.anchoredPositionY=i.anchoredPositionY??0,this.sizeDeltaX=i.sizeDeltaX??0,this.sizeDeltaY=i.sizeDeltaY??0,this.anchorMinX=i.anchorMinX??.5,this.anchorMinY=i.anchorMinY??.5,this.anchorMaxX=i.anchorMaxX??.5,this.anchorMaxY=i.anchorMaxY??.5,this.pivotX=i.pivotX??.5,this.pivotY=i.pivotY??.5,this.localScaleX=i.localScaleX??1,this.localScaleY=i.localScaleY??1,this.localScaleZ=i.localScaleZ??1,this.localRotationX=i.localRotationX??0,this.localRotationY=i.localRotationY??0,this.localRotationZ=i.localRotationZ??0,this.canControllerFocus=i.canControllerFocus??!1,this._playDirty=!0,this._playDeepDirty=!0,this._playChildDirty=!1;let n=Gs[this.kind]||{};for(let[r,o]of Object.entries(n))this[r]===void 0&&(this[r]=i[r]!==void 0?i[r]:o);if(i.children)for(let r of i.children){let o=r instanceof e?r:new e(t,r);this.addChild(o)}}get parent(){return this._parent}set parent(t){if(this._parent===t)return;if(t!==null&&!(t instanceof e))throw new Error("parent must be a Control or nil");if(t&&t.runtime!==this.runtime)throw new Error("parent must belong to the same runtime");if(t===this)throw new Error("cannot parent a control to itself or its descendant");for(let n=t;n;n=n._parent)if(n===this)throw new Error("cannot parent a control to itself or its descendant");let i=this._parent;if(i){let n=i.children.indexOf(this);n>=0&&i.children.splice(n,1),i.markPlayDirty(!0)}else{let n=this.runtime.roots.indexOf(this);n>=0&&this.runtime.roots.splice(n,1)}this._parent=t,this.markPlayDirty(!0),t&&!t.children.includes(this)?(t.children.push(this),t.markPlayDirty(!0)):!t&&this.alive&&!this.runtime.roots.includes(this)&&this.runtime.roots.push(this)}markPlayDirty(t=!1){this._playDirty=!0,t&&(this._playDeepDirty=!0);for(let i=this._parent;i&&!i._playChildDirty;i=i._parent)i._playChildDirty=!0}get activeInHierarchy(){return this.active?this._parent?this._parent.activeInHierarchy:!0:!1}addChild(t){return t.parent=this,t}GetChildren(){return this.children.slice()}GetChild(t){return this.children.find(i=>i.name===t)||null}FindChild(t){if(!t)return null;if(!t.includes("/"))return this.GetChild(t);let i=t.split("/").filter(Boolean),n=this;for(let r of i)if(n=n.GetChild(r),!n)return null;return n}SetActive(t){let i=!!t;if(this.active!==i){if(typeof this.runtime?.onControlActiveChanging=="function"){this.runtime.onControlActiveChanging(this,i);return}this.active=i,this.markPlayDirty(!0)}}SetVisible(t){this.visible=!!t,this.markPlayDirty(!0)}GetSiblingIndex(){if(!this._parent)return-1;let t=this._parent.children,i=t.indexOf(this);return i<0?-1:t.length-1-i}SetSiblingIndex(t){if(!this._parent)return!1;let i=this._parent.children,n=i.indexOf(this);if(n<0)return!1;let r=i.length-1;return!Number.isInteger(t)||t<0||t>r?!1:(i.splice(n,1),i.splice(r-t,0,this),this._parent.markPlayDirty(!0),this.markPlayDirty(),!0)}SetAsFirstSibling(){return this.SetSiblingIndex(0)}SetAsLastSibling(){return this._parent?this.SetSiblingIndex(this._parent.children.length-1):!1}GetAnchoredPosition(){return[this.anchoredPositionX,this.anchoredPositionY]}SetAnchoredPosition(t,i){this.anchoredPositionX=t,this.anchoredPositionY=i,this.markPlayDirty()}GetSizeDelta(){return[this.sizeDeltaX,this.sizeDeltaY]}SetSizeDelta(t,i){this.sizeDeltaX=t,this.sizeDeltaY=i,this.markPlayDirty(!0)}GetAnchorMin(){return[this.anchorMinX,this.anchorMinY]}SetAnchorMin(t,i){this.anchorMinX=t,this.anchorMinY=i,this.markPlayDirty(!0)}GetAnchorMax(){return[this.anchorMaxX,this.anchorMaxY]}SetAnchorMax(t,i){this.anchorMaxX=t,this.anchorMaxY=i,this.markPlayDirty(!0)}GetPivot(){return[this.pivotX,this.pivotY]}SetPivot(t,i){this.pivotX=t,this.pivotY=i,this.markPlayDirty(!0)}GetLocalScale(){return[this.localScaleX,this.localScaleY,this.localScaleZ]}SetLocalScale(t,i,n){this.localScaleX=t,this.localScaleY=i,this.localScaleZ=n,this.markPlayDirty()}GetLocalRotation(){return[this.localRotationX,this.localRotationY,this.localRotationZ]}SetLocalRotation(t,i,n){this.localRotationX=t,this.localRotationY=i,this.localRotationZ=n,this.markPlayDirty()}GetScriptByPath(t){return this.scripts.find(i=>i.path===t)||null}GetScript(t){return this.scripts.find(i=>i.scriptMappingId===t)||null}GetScripts(){return this.scripts.slice()}_addListener(t,i,n){let r=t.get(i)||[];r.push(n),t.set(i,r)}_removeListener(t,i,n){let r=t.get(i);r&&(t.set(i,r.filter(o=>o!==n)),this.runtime.unrefLuaCallback?.(n))}_removeListeners(t,i){let n=t.get(i)||[];for(let r of n)this.runtime.unrefLuaCallback?.(r);t.delete(i)}_removeAllListeners(t){for(let i of t.values())for(let n of i)this.runtime.unrefLuaCallback?.(n);t.clear()}AddCursorEventListener(t,i){this._addListener(this.cursorListeners,t,i)}RemoveCursorEventListener(t,i){this._removeListener(this.cursorListeners,t,i)}RemoveCursorEventListeners(t){this._removeListeners(this.cursorListeners,t)}RemoveAllCursorEventListeners(){this._removeAllListeners(this.cursorListeners)}SimulateCursorClick(){let t=this.runtime.makeCursorEventData({x:0,y:0,pressX:0,pressY:0});this.emitCursor("CursorDown",t),this.emitCursor("CursorUp",t),this.emitCursor("CursorClick",t)}emitCursor(t,i){if(!this.runtime.cursorEventsEnabled(this))return;let n=this.cursorListeners.get(t)||[];for(let r of n)r(i)}AddKeyEventListener(t,i){this._addListener(this.keyListeners,t,i)}RemoveKeyEventListener(t,i){this._removeListener(this.keyListeners,t,i)}RemoveKeyEventListeners(t){this._removeListeners(this.keyListeners,t)}RemoveAllKeyEventListeners(){this._removeAllListeners(this.keyListeners)}emitKey(t){let i=this.keyListeners.get(t)||[];for(let n of i)if(n()===!0)break}AddNavigationEventListener(t,i){this._addListener(this.navListeners,t,i)}RemoveNavigationEventListener(t,i){this._removeListener(this.navListeners,t,i)}RemoveNavigationEventListeners(t){this._removeListeners(this.navListeners,t)}RemoveAllNavigationEventListeners(){this._removeAllListeners(this.navListeners)}SetControllerNavigation(t,i,n){this.navConfig.set(t,{mode:i,target:n})}GetControllerNavigation(t){let i=this.navConfig.get(t),n=i?[i.mode,i.target]:[null,null];return n.__multi=!0,n}SetImage(t,i){this.imageSource=t,this.imageId=i,this.markPlayDirty()}SetSoftEdgeWidth(t,i){this.softEdgeWidthX=t,this.softEdgeWidthY=i,this.markPlayDirty()}SetFillUnused(){this.fillType="Unused",this.markPlayDirty()}SetFillHorizontal(t,i){this.fillType="Horizontal",this.fillHorizontalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillVertical(t,i){this.fillType="Vertical",this.fillVerticalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial90(t,i){this.fillType="Radial90",this.fillRadial90Type=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial180(t,i){this.fillType="Radial180",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial360(t,i){this.fillType="Radial360",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}PlayAnimation(){}StopAnimation(){}RefreshItems(){throw new Error("ClientUIGridScrollerControl:RefreshItems not implemented")}GetItemIndex(){throw new Error("ClientUIGridScrollerControl:GetItemIndex not implemented")}GetItemSize(){throw new Error("ClientUIGridScrollerControl:GetItemSize not implemented")}GetItemSpacing(){throw new Error("ClientUIGridScrollerControl:GetItemSpacing not implemented")}GetPadding(){throw new Error("ClientUIGridScrollerControl:GetPadding not implemented")}ScrollToItemAt(){throw new Error("ClientUIGridScrollerControl:ScrollToItemAt not implemented")}GetContentLength(){throw new Error("ClientUIGridScrollerControl:GetContentLength not implemented")}};function we(e,t){t(e);for(let i of e.children)we(i,t)}function cn(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let n of e.children)cn(n,t,i+" ");return t}function hi(e){return 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}var ro={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,InQuint:e=>e**5,OutQuint:e=>1-(1-e)**5,InOutQuint:e=>e<.5?16*e**5:1-(-2*e+2)**5/2,InExpo:e=>e===0?0:2**(10*e-10),OutExpo:e=>e===1?1:1-2**(-10*e),InOutExpo:e=>e===0||e===1?e:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2,InCirc:e=>1-Math.sqrt(1-e**2),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=>(1.70158+1)*e*e*e-1.70158*e*e,OutBack:e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,InOutBack:e=>{let i=2.5949095;return e<.5?(2*e)**2*((i+1)*2*e-i)/2:((2*e-2)**2*((i+1)*(e*2-2)+i)+2)/2},InElastic:e=>e===0||e===1?e:-(2**(10*e-10))*Math.sin((e*10-10.75)*(2*Math.PI/3)),OutElastic:e=>e===0||e===1?e:2**(-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1,InOutElastic:e=>{if(e===0||e===1)return e;let t=2*Math.PI/4.5;return e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*t))/2:2**(-20*e+10)*Math.sin((20*e-11.125)*t)/2+1},InBounce:e=>1-hi(1-e),OutBounce:hi,InOutBounce:e=>e<.5?(1-hi(1-2*e))/2:(1+hi(2*e-1))/2};function oo(e,t){let i=ro[e]||ro.Linear;return t<=0?0:t>=1?1:i(t)}function St(e,t,i,n=255){let r=pi(e),o=pi(t),a=pi(i);return((n==null?255:pi(n))<<24|r<<16|o<<8|a)>>>0}function Yt(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function pi(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function ao(e,t,i){let n=Yt(e),r=Yt(t);return St(n[0]+(r[0]-n[0])*i,n[1]+(r[1]-n[1])*i,n[2]+(r[2]-n[2])*i,n[3]+(r[3]-n[3])*i)}var Vs=new Set(["fontColor","bgColor","outlineColor","imageColor"]),mi=class{constructor(t,i,n,r){this.runtime=t,this.object=i,this.data={...n},this.duration=Math.max(0,Number(r)||0),this.easeName="Linear",this.relative=!1,this.playing=!1,this.paused=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.from={},this.to={},this.initialFrom=null,this.initialTo=null,this.onComplete=null,this.onStepComplete=null,this.killed=!1}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let n=this.object[t];this.from[t]=n,this.to[t]=this.relative?Number(n)+Number(i):i}}restoreInitial(){this.initialFrom?(this.from={...this.initialFrom},this.to={...this.initialTo}):this.capture()}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this._start(!1)}_start(t){return this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to}),this.runtime.tweens.add(this),this.duration===0&&this.Complete(),this}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this._start(!0)}Complete(){this.apply(1),this.finish(!0)}Kill(t){t?this.Complete():this.finish(!1)}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){let i=oo(this.easeName,t),n=!1,r=!1;for(let o of Object.keys(this.to)){let a=this.from[o],s=this.to[o];Vs.has(o)&&typeof a=="number"&&typeof s=="number"?this.object[o]=ao(a,s,i):typeof a=="number"&&typeof s=="number"?this.object[o]=a+(s-a)*i:this.object[o]=i>=1?s:a,n=!0,di.has(o)&&(r=!0)}n&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(r)}step(t){if(!this.playing||this.paused||this.killed)return;this.elapsed+=t;let i=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);if(this.apply(i),i>=1){this.onStepComplete&&this.runtime.safeCall(this.onStepComplete);let n=this.loops<0;if(this.loopIndex++,n||this.loopIndex<this.loops){this.elapsed=Math.max(0,this.elapsed-this.duration),this.relative?this.capture():this.restoreInitial();let r=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);this.apply(r)}else this.finish(!0)}}finish(t){this.playing=!1,this.killed=!0,this.runtime.tweens.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},gi=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._built=[]}Append(t){return this.steps.push({kind:"tween",tween:t,parallel:!1}),this}AppendInterval(t){return this.steps.push({kind:"interval",duration:t}),this}AppendCallback(t){return this.steps.push({kind:"callback",fn:t}),this}Join(t){return this.steps.push({kind:"tween",tween:t,parallel:!0}),this}Insert(t,i){return this.steps.push({kind:"insert",time:t,tween:i}),this}InsertCallback(t,i){return this.steps.push({kind:"insertCb",time:t,fn:i}),this}Play(){return this.playing=!0,this.paused=!1,this.killed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this._activateDueEntries(),this.runtime.sequences.add(this),this}_schedule(){let t=0,i=0,n=!1;this._built=[];for(let r of this.steps)if(r.kind==="tween"&&r.parallel){let o=n?i:t;this._built.push({at:o,tween:r.tween}),t=Math.max(t,o+r.tween.duration)}else r.kind==="tween"?(this._built.push({at:t,tween:r.tween}),i=t,n=!0,t+=r.tween.duration):r.kind==="interval"?(i=t,n=!0,t+=r.duration):r.kind==="callback"?this._built.push({at:t,fn:r.fn}):r.kind==="insert"?(this._built.push({at:r.time,tween:r.tween}),t=Math.max(t,r.time+r.tween.duration)):r.kind==="insertCb"&&(this._built.push({at:r.time,fn:r.fn}),t=Math.max(t,r.time));this._end=t,this._fired=new Set}Pause(){this.paused=!0;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Pause()}Resume(){this.paused=!1;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Resume()}Restart(){this.Play()}Complete(){for(let t of this._built)t.tween&&(this._fired.has(t)||t.tween.Play(),t.tween.Complete()),t.fn&&!this._fired.has(t)&&this.runtime.safeCall(t.fn),this._fired.add(t);this.finish(!0)}Kill(t){if(t)this.Complete();else{for(let i of this._built)i.tween&&this._fired.has(i)&&i.tween.Kill(!1);this.finish(!1)}}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}_activateDueEntries(){for(let t of this._built)this._fired.has(t)||this.elapsed+1e-9<t.at||(this._fired.add(t),t.tween&&t.tween.Play(),t.fn&&this.runtime.safeCall(t.fn))}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._activateDueEntries(),this.elapsed>=this._end&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._schedule()):this.finish(!0)))}finish(t){this.playing=!1,this.killed=!0,this.runtime.sequences.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var yi={EaseType:["Linear","InSine","OutSine","InOutSine","InQuad","OutQuad","InOutQuad","InCubic","OutCubic","InOutCubic","InQuart","OutQuart","InOutQuart","InQuint","OutQuint","InOutQuint","InExpo","OutExpo","InOutExpo","InCirc","OutCirc","InOutCirc","InBack","OutBack","InOutBack","InElastic","OutElastic","InOutElastic","InBounce","OutBounce","InOutBounce"],CustomVariableEntityType:["Level","PlayerSelf","AvatarSelf"],Device:["KeyboardAndMouse","Mobile","Controller","MobileController"],StageMode:["Beyond","Classic"],LanguageType:["LanguageNone","LanguageEng","LanguageChs","LanguageCht","LanguageFra","LanguageDeu","LanguageSpa","LanguagePor","LanguageRus","LanguageJpn","LanguageKor","LanguageTha","LanguageVie","LanguageInd","LanguageTur","LanguageIta"],ParamType:["Entity","EntityList","Int","IntList","Bool","BoolList","Float","FloatList","String","StringList","Vector3","Vector3List","Guid","GuidList","ConfigId","PrefabId","ConfigIdList","PrefabIdList"],CursorEventType:["CursorDown","CursorUp","CursorEnter","CursorExit","CursorDrag","CursorBeginDrag","CursorEndDrag","CursorClick"],ScrollDirection:["Horizontal","Vertical"],ScrollLayoutConstraint:["AutoWrap","Fixed"],ScrollAlignType:["Bottom","Center","Top"],ControllerNavigationDir:["Up","Down","Left","Right"],ControllerNavigationEventType:["Confirm","Cancel","Focus","LostFocus","RightStickUp","RightStickDown","RightStickRight","RightStickLeft","LeftStickUp","LeftStickDown","LeftStickRight","LeftStickLeft"],ControllerNavigationMode:["None","NearestControl","Specified"],TextHorizontalAlignment:["Left","Middle","Right"],TextVerticalAlignment:["Top","Middle","Bottom"],ImageType:["Basic","Stretch"],ImageSource:["StaticReference","Item","Equipment","Skill","UnitStatus","Faction","Currency","Prefab"],ImageFillType:["Unused","Horizontal","Vertical","Radial90","Radial180","Radial360"],ImageFillHorizontalType:["Left","Right"],ImageFillVerticalType:["Bottom","Top"],ImageFillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],ImageFillRadialType:["Bottom","Left","Top","Right"],ImageMaskSoftEdgeMode:["Percentage","Pixel"],UIAnimationLayer:["AboveAllControls","BelowAllControls"]},Ys=[...Array.from({length:43},(e,t)=>`CraftspersonKey${t+1}`),"MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","None"],Bs=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function Us(){let e=[];for(let t of["Down","Up"]){for(let i=1;i<=43;i++)e.push(`KeyboardCraftspersonKey${i}${t}`);for(let i of["MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key"])e.push(`Keyboard${i}${t}`);for(let i=1;i<=14;i++)e.push(`ControllerCraftspersonKey${i}${t}`);for(let i of["SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey"])e.push(`Controller${i}${t}`)}return e}yi.KeyboardKeyCode=Ys;yi.ControllerKeyCode=Bs;yi.KeyEventType=Us();var so=new Map;function Qe(e,t){let i=`${e}\0${t}`,n=so.get(i);return n||(n={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},so.set(i,n)),n}function fn(e,t){return t==null?t:t.__kind==="EnumItem"?Qe(t.EnumType||e,t.Name):typeof t=="string"&&t?Qe(e,t):t}function dn(){let e={};for(let[t,i]of Object.entries(yi)){let n={};for(let r of i)n[r]=Qe(t,r);e[t]=n}return e}var lo={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},et=u.LUA_REGISTRYINDEX,Hs=u.LUA_MULTRET;function me(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}function Xs(e){let t=String(e).replace(/\\/g,"/").replace(/\.lua$/i,"");return t.split("/").pop()||t}var bi=class{constructor(t={}){this.canvasWidth=t.canvasWidth??1600,this.canvasHeight=t.canvasHeight??900,this.device=t.device??"KeyboardAndMouse",this.language=t.language??"LanguageChs",this.stageMode=t.stageMode??"Classic",this.testPlay=t.testPlay!==!1,this.clock={time:0,levelTime:0,paused:!1,frame:0},this.logs=[],this.mountErrors=[],this.tweens=new Set,this.sequences=new Set,this.audios=new Map,this.nextAudioId=1,this._nextControlId=1,this._playRemoved=[],this._nextScriptMappingId=1,this.lifecyclePhase="idle",this.controlsById=new Map,this.roots=[],this.templates=new Map,this.scriptFiles=new Map,this.requireAliases=new Map,this.requireCache=new Map,this.moduleBaseEnvironments=new Map,this.luaFunctions=new Map,this.mountedScripts=[],this.serverVars={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)},this.serverBridge=null,this.varHandlers=[],this.signalHandlers=[],this.cursor={x:0,y:0},this.focus=null,this.stick={left:[0,0],right:[0,0]},this.enumTree=dn(),this.luaStates=new Set,this.L=null}nextControlId(){let t=this._nextControlId;return this._nextControlId+=1,t}resolveScriptMappingId(t){let i=Number(t);if(Number.isSafeInteger(i)&&i>0)return this._nextScriptMappingId=Math.max(this._nextScriptMappingId,i+1),i;let n=this._nextScriptMappingId;return this._nextScriptMappingId+=1,n}pushPackedColor(t,i){let n=i>>>0;(n|0)===n?u.lua_pushinteger(t,n):u.lua_pushnumber(t,n)}unrefLuaCallback(t){Zr(this,t)}log(t,...i){let n=i.map(r=>r==null?"nil":typeof r=="object"&&r!==null&&r.__kind==="EnumItem"?r.Name:String(r)).join(" ");this.logs.push({level:t,text:n,time:this.clock.time})}safeCall(t,...i){try{return t(...i)}catch(n){this.log("lua-error",n&&n.message?n.message:String(n))}}scriptCanRun(t){if(!t?.alive||!t.enabled)return!1;let i=t.object;return!i||i.alive&&i.activeInHierarchy}cursorEventsEnabled(t){for(let i=t;i;i=i.parent)if(i.kind==="container"&&i.showCursor===!0)return!0;return!1}registerTemplate(t,i){this.templates.set(Number(t),i)}registerScriptFile(t,i){let n=this.normalizeRequirePath(t);this.scriptFiles.set(n,i),n.startsWith("default_import_file/")||this.requireAliases.set(`default_import_file/${n}`,n)}normalizeRequirePath(t){let i=String(t).replace(/\\/g,"/");return i.endsWith(".lua")&&(i=i.slice(0,-4)),i}addRoot(t){let i=t instanceof Be?t:new Be(this,t);return this.roots.push(i),we(i,n=>this.controlsById.set(n.Id,n)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof Be)return;let n=o=>(o.scripts?.length||0)>0||(o.children||[]).some(n);if(!t||!n(t))return;let r=this.lifecyclePhase;try{let o=(a,s)=>{for(let l of a.scripts||[])try{this.mountScript({path:l.path,source:l.source,control:s,scriptMappingId:l.scriptMappingId})}catch(f){let h=f&&f.message?f.message:String(f);this.mountErrors.push(h),this.log("lua-error",h)}let c=a.children||[];for(let l=0;l<c.length;l+=1)o(c[l],s?.children?.[l])};o(t,i)}finally{this.lifecyclePhase=r}}makeCursorEventData({x:t=0,y:i=0,pressX:n=t,pressY:r=i,deltaX:o=t-n,deltaY:a=i-r,dragging:s=!1,touchId:c=-1}={}){let l=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:s,touchId:c,x:t,y:i,pressX:n,pressY:r,GetUIPos(){return[t,i]},GetPressUIPos(){return[n,r]},GetUIPosDelta(){return[o,a]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(pe(n,i,a));return i.log("info",...o),0}),u.lua_setglobal(t,_("print")),u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(pe(n,i,a));return i.log("error",...o),0}),u.lua_setglobal(t,_("printerr")),u.lua_pushcfunction(t,n=>{if(u.lua_type(n,1)===u.LUA_TTABLE&&!Ye(n,1))return u.lua_pushstring(n,_("table")),1;let r=pe(n,i,1);return u.lua_pushstring(n,_(i.typeofOf(r))),1}),u.lua_setglobal(t,_("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),u.lua_pushcfunction(t,n=>i.luaRequire(n)),u.lua_setglobal(t,_("require"))}typeofOf(t){return t==null?"nil":t.__kind==="Script"?"Script":t.__kind==="EnumItem"?"EnumItem":t.__kind==="CursorEventData"?"CursorEventData":t.typeofName?t.typeofName:typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t}pushColorLib(t){u.lua_newtable(t),u.lua_pushcfunction(t,i=>(this.pushPackedColor(i,St(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),255)),1)),u.lua_setfield(t,-2,_("FromRGB")),u.lua_pushcfunction(t,i=>{let n=u.lua_isnoneornil(i,4)?255:u.lua_tonumber(i,4);return this.pushPackedColor(i,St(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),n)),1}),u.lua_setfield(t,-2,_("FromRGBA")),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,1)>>>0,[r,o,a,s]=Yt(n);return u.lua_pushnumber(i,r),u.lua_pushnumber(i,o),u.lua_pushnumber(i,a),u.lua_pushnumber(i,s),4}),u.lua_setfield(t,-2,_("ToRGBA")),u.lua_newtable(t),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,2),r=u.lua_tonumber(i,3),o=u.lua_tonumber(i,4),a=u.lua_isnoneornil(i,5)?255:u.lua_tonumber(i,5);return this.pushPackedColor(i,St(n,r,o,a)),1}),u.lua_setfield(t,-2,_("__call")),u.lua_setmetatable(t,-2),u.lua_setglobal(t,_("Color"))}pushEnumLib(t){u.lua_newtable(t);for(let[i,n]of Object.entries(this.enumTree)){u.lua_newtable(t);for(let[r,o]of Object.entries(n))this.pushEnumItem(t,o),u.lua_setfield(t,-2,_(r));u.lua_setfield(t,-2,_(i))}u.lua_setglobal(t,_("Enum"))}pushEnumItem(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i),re.luaL_setmetatable(t,_("EnumItem"))}pushControl(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i),re.luaL_setmetatable(t,_("Control"))}pushScript(t,i){u.lua_newtable(t),u.lua_pushlightuserdata(t,ln);let n=u.lua_newuserdata(t,0);Ze(n,i),u.lua_rawset(t,-3),re.luaL_getmetatable(t,_("Script")),u.lua_setmetatable(t,-2)}pushTween(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i);let r=i.Append?"TweenSequence":"Tween";re.luaL_setmetatable(t,_(r))}pushCursor(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i),re.luaL_setmetatable(t,_("CursorEventData"))}pushGameLib(t){let i=this;u.lua_newtable(t);let n={InstantiateClientUIControl:r=>{let o=u.lua_tointeger(r,1),a=be(u.lua_touserdata(r,2)),s=i.instantiate(o,a,i.lifecyclePhase);return s?(i.pushControl(r,s),1):(u.lua_pushnil(r),1)},DestroyClientUIControl:r=>{let o=be(u.lua_touserdata(r,1));return o&&i.destroyControl(o),0},GetClientUIControl:r=>{let o=u.lua_tointeger(r,1),a=i.controlsById.get(o);return a?i.pushControl(r,a):u.lua_pushnil(r),1},FindClientUIRoot:r=>{let o=L(r,1),a=i.roots.find(s=>s.name===o);return a?i.pushControl(r,a):u.lua_pushnil(r),1},GetClientUIRoots:r=>(u.lua_createtable(r,i.roots.length,0),i.roots.forEach((o,a)=>{i.pushControl(r,o),u.lua_rawseti(r,-2,a+1)}),1),GetUICanvasSize:r=>(u.lua_pushnumber(r,i.canvasWidth),u.lua_pushnumber(r,i.canvasHeight),2),GetCursorUIPos:r=>(u.lua_pushnumber(r,i.cursor.x),u.lua_pushnumber(r,i.cursor.y),2),GetDevice:r=>(i.pushEnumItem(r,Qe("Device",i.device)),1),SetControllerFocus:r=>(i.focus=be(u.lua_touserdata(r,1)),0),GetControllerFocus:r=>(i.focus?i.pushControl(r,i.focus):u.lua_pushnil(r),1),GetControllerLeftStickAxis:r=>(u.lua_pushnumber(r,i.stick.left[0]),u.lua_pushnumber(r,i.stick.left[1]),2),GetControllerRightStickAxis:r=>(u.lua_pushnumber(r,i.stick.right[0]),u.lua_pushnumber(r,i.stick.right[1]),2),Tween:r=>{let o=be(u.lua_touserdata(r,1))||pe(r,i,1),a=pe(r,i,2)||{},s=u.lua_tonumber(r,3),c=new mi(i,o,a,s);return i.pushTween(r,c),1},TweenSequence:r=>(i.pushTween(r,new gi(i)),1),ServerSignal:r=>{let o=L(r,1),a=i.makeServerSignal(o),s=u.lua_newuserdata(r,0);return Ze(s,a),re.luaL_setmetatable(r,_("ServerSignal")),1},GetGlobalCustomVariableValue:r=>{let o=me(pe(r,i,1)),a=L(r,2);return ne(r,i,i.getVar(o,a)),1},PauseLevelTime:r=>(i.clock.paused=!!u.lua_toboolean(r,1),0),IsLevelTimePaused:r=>(u.lua_pushboolean(r,i.clock.paused),1),PlayAudio2D:r=>{let o=i.nextAudioId++;return i.audios.set(o,{audioId:u.lua_tointeger(r,1),alive:!0}),u.lua_pushinteger(r,o),1},StopAudio:r=>{let o=u.lua_tointeger(r,1),a=i.audios.get(o);return a&&(a.alive=!1),0},IsAudioAlive:r=>{let o=i.audios.get(u.lua_tointeger(r,1));return u.lua_pushboolean(r,!!(o&&o.alive)),1},GetLanguageType:r=>(i.pushEnumItem(r,Qe("LanguageType",i.language)),1),GetStageMode:r=>(i.pushEnumItem(r,Qe("StageMode",i.stageMode)),1),IsTestPlay:r=>(u.lua_pushboolean(r,i.testPlay),1),GetText:r=>{let o=L(r,1);return u.lua_pushstring(r,_(o)),1},PrintClientUITree:r=>{for(let o of i.roots)i.log("info",cn(o).join(`
|
|
106
|
-
`));return 0}};for(let[r,o]of Object.entries(n))u.lua_pushcfunction(t,o),u.lua_setfield(t,-2,_(r));u.lua_setglobal(t,_("game"))}makeServerSignal(t){let i=[],n=this;return{__kind:"ServerSignal",name:t,AddParam(r,o){i.push({type:me(r),value:o})},AddInt(r){i.push({type:"Int",value:r})},AddIntList(r){i.push({type:"IntList",value:r})},AddFloat(r){i.push({type:"Float",value:r})},AddFloatList(r){i.push({type:"FloatList",value:r})},AddString(r){i.push({type:"String",value:r})},AddStringList(r){i.push({type:"StringList",value:r})},AddVector3(r){i.push({type:"Vector3",value:r})},AddVector3List(r){i.push({type:"Vector3List",value:r})},AddBool(r){i.push({type:"Bool",value:r})},AddBoolList(r){i.push({type:"BoolList",value:r})},AddGuid(r){i.push({type:"Guid",value:r})},AddGuidList(r){i.push({type:"GuidList",value:r})},AddEntity(r){i.push({type:"Entity",value:r})},AddEntityList(r){i.push({type:"EntityList",value:r})},AddPrefabId(r){i.push({type:"PrefabId",value:r})},AddPrefabIdList(r){i.push({type:"PrefabIdList",value:r})},AddConfigId(r){i.push({type:"ConfigId",value:r})},AddConfigIdList(r){i.push({type:"ConfigIdList",value:r})},SendSignal(){let r=i.slice();n.serverBridge&&typeof n.serverBridge.receiveFromClient=="function"&&n.serverBridge.receiveFromClient(t,r)}}}instantiate(t,i,n){if(n==="OnInit"||n==="OnDestroy")return null;let r=this.templates.get(Number(t));if(!r||!i)return null;let o=new Be(this,{...r,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(o),we(o,a=>this.controlsById.set(a.Id,a)),this.mountSpecScripts(r,o),o}destroyControl(t){if(!(!t||!t.alive)){if(t._destroying)throw new Error(`\u5BA2\u6237\u7AEF\u63A7\u4EF6\u751F\u547D\u5468\u671F\u5904\u4E8E\u521B\u5EFA\u6216\u9500\u6BC1\u65F6\uFF0C\u65E0\u6CD5\u8C03\u7528DestroyClientUIControl, ID:${t.name}`);we(t,i=>{i._destroying=!0}),this._destroyControlTree(t)}}_destroyControlTree(t){this.releaseControlListeners(t);for(let i of t.scripts.slice())this.unmountScript(i);for(let i of t.children.slice())this._destroyControlTree(i);if(t.alive=!1,this._playRemoved.push(t.Id),t.parent){let i=t.parent,n=i.children.indexOf(t);n>=0&&i.children.splice(n,1),t._parent=null,i.markPlayDirty(!0)}else{let i=this.roots.indexOf(t);i>=0&&this.roots.splice(i,1)}this.controlsById.delete(t.Id),this.focus===t&&(this.focus=null);for(let i of[...this.tweens])i.object===t&&i.Kill(!1)}releaseControlListeners(t){for(let i of t.cursorListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.keyListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.navListeners.values())for(let n of i)this.unrefLuaCallback(n);t.cursorListeners.clear(),t.keyListeners.clear(),t.navListeners.clear(),t.navConfig.clear()}onControlActiveChanging(t,i){let n=[];we(t,r=>n.push({control:r,was:r.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let r of n){let o=r.control.activeInHierarchy;if(r.was!==o)for(let a of r.control.scripts.slice())o?this.enableScript(a):this.disableScript(a)}}bindScriptEnv(t){let i=t.env;return i?(this.pushScript(i,t),u.lua_setglobal(i,_("script")),i):null}disableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="running")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnDisable"),t.lifecyclePhase="disabled",this.lifecyclePhase=i}enableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="disabled")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnEnable",t.lifecyclePhase="OnEnable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnEnable"),t.lifecyclePhase="running",this.lifecyclePhase=i}unmountScript(t){if(!t||!t.alive)return;let i=t.env,n=this.lifecyclePhase;i&&(t.lifecyclePhase==="running"&&(this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(i,"OnDisable")),this.lifecyclePhase="OnDestroy",t.lifecyclePhase="OnDestroy",this.bindScriptEnv(t),this.callGlobal(i,"OnDestroy")),t.alive=!1,t.lifecyclePhase="destroyed",this.lifecyclePhase=n,this.mountedScripts=this.mountedScripts.filter(r=>r!==t),t.object&&(t.object.scripts=t.object.scripts.filter(r=>r!==t)),this.varHandlers=this.varHandlers.filter(r=>r.script!==t),this.signalHandlers=this.signalHandlers.filter(r=>r.script!==t),i&&i!==this.L&&this.closeTrackedLuaState(i),t.env=null}installMetatables(t){this.mtEnum(t),this.mtControl(t),this.mtScript(t),this.mtTween(t),this.mtSeq(t),this.mtSignal(t),this.mtCursor(t)}mtIndexNewindex(t,i,n,r,o,a){re.luaL_newmetatable(t,_(i)),u.lua_pushcfunction(t,s=>{let c=Ye(s,1)||be(u.lua_touserdata(s,1)),l=L(s,2);if(o[l]&&(!a||a(c,l)))return u.lua_pushcfunction(s,o[l]),1;let f=n(c,l);return f===void 0?(u.lua_pushnil(s),1):(ne(s,this,f),1)}),u.lua_setfield(t,-2,_("__index")),u.lua_pushcfunction(t,s=>{try{let c=Ye(s,1)||be(u.lua_touserdata(s,1)),l=L(s,2),f=pe(s,this,3);return r(c,l,f),0}catch(c){return u.lua_pushstring(s,_(String(c.message||c))),u.lua_error(s)}}),u.lua_setfield(t,-2,_("__newindex")),u.lua_pushcfunction(t,s=>{let c=Ye(s,1)||be(u.lua_touserdata(s,1)),l=Ye(s,2)||be(u.lua_touserdata(s,2));return u.lua_pushboolean(s,c===l),1}),u.lua_setfield(t,-2,_("__eq")),u.lua_pop(t,1)}method(t){let i=this;return n=>{let r=Ye(n,1)||be(u.lua_touserdata(n,1)),o=u.lua_gettop(n),a=[];for(let s=2;s<=o;s++)a.push(pe(n,i,s));try{let s=t(r,...a);if(s===r)return u.lua_pushvalue(n,1),1;if(s===void 0)return 0;if(Array.isArray(s)&&s.__multi){for(let c of s)ne(n,i,c);return s.length}if(Array.isArray(s)&&!(s.length&&typeof s[0]=="object"&&s[0]?.typeofName)){if(s.__controls)return u.lua_createtable(n,s.length,0),s.forEach((c,l)=>{i.pushControl(n,c),u.lua_rawseti(n,-2,l+1)}),1;if(s.__scripts)return u.lua_createtable(n,s.length,0),s.forEach((c,l)=>{i.pushScript(n,c),u.lua_rawseti(n,-2,l+1)}),1;if(typeof s[0]=="number"&&s.length<=4){for(let c of s)u.lua_pushnumber(n,c);return s.length}}return ne(n,i,s),1}catch(s){return u.lua_pushstring(n,_(String(s.message||s))),u.lua_error(n)}}}mtEnum(t){let i=new Set(["Name","FullName","EnumType"]);this.mtIndexNewindex(t,"EnumItem",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{})}mtCursor(t){let i=new Set(["dragging","touchId"]);this.mtIndexNewindex(t,"CursorEventData",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{GetUIPos:this.method(n=>n.GetUIPos()),GetPressUIPos:this.method(n=>n.GetPressUIPos()),GetUIPosDelta:this.method(n=>n.GetUIPosDelta())})}mtControl(t){let i={GetChildren:this.method(n=>{let r=n.GetChildren();return r.__controls=!0,r}),GetChild:this.method((n,r)=>n.GetChild(r)),FindChild:this.method((n,r)=>n.FindChild(r)),SetActive:this.method((n,r)=>n.SetActive(r)),SetVisible:this.method((n,r)=>n.SetVisible(r)),GetSiblingIndex:this.method(n=>n.GetSiblingIndex()),SetSiblingIndex:this.method((n,r)=>n.SetSiblingIndex(r)),SetAsFirstSibling:this.method(n=>n.SetAsFirstSibling()),SetAsLastSibling:this.method(n=>n.SetAsLastSibling()),GetAnchoredPosition:this.method(n=>n.GetAnchoredPosition()),SetAnchoredPosition:this.method((n,r,o)=>n.SetAnchoredPosition(r,o)),GetSizeDelta:this.method(n=>n.GetSizeDelta()),SetSizeDelta:this.method((n,r,o)=>n.SetSizeDelta(r,o)),GetAnchorMin:this.method(n=>n.GetAnchorMin()),SetAnchorMin:this.method((n,r,o)=>n.SetAnchorMin(r,o)),GetAnchorMax:this.method(n=>n.GetAnchorMax()),SetAnchorMax:this.method((n,r,o)=>n.SetAnchorMax(r,o)),GetPivot:this.method(n=>n.GetPivot()),SetPivot:this.method((n,r,o)=>n.SetPivot(r,o)),GetLocalScale:this.method(n=>n.GetLocalScale()),SetLocalScale:this.method((n,r,o,a)=>n.SetLocalScale(r,o,a)),GetLocalRotation:this.method(n=>n.GetLocalRotation()),SetLocalRotation:this.method((n,r,o,a)=>n.SetLocalRotation(r,o,a)),GetScriptByPath:this.method((n,r)=>n.GetScriptByPath(r)),GetScript:this.method((n,r)=>n.GetScript(r)),GetScripts:this.method(n=>{let r=n.GetScripts();return r.__scripts=!0,r}),AddCursorEventListener:this.method((n,r,o)=>n.AddCursorEventListener(me(r),o)),RemoveCursorEventListener:this.method((n,r,o)=>n.RemoveCursorEventListener(me(r),o)),RemoveCursorEventListeners:this.method((n,r)=>n.RemoveCursorEventListeners(me(r))),RemoveAllCursorEventListeners:this.method(n=>n.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(n=>n.SimulateCursorClick()),AddKeyEventListener:this.method((n,r,o)=>n.AddKeyEventListener(me(r),o)),RemoveKeyEventListener:this.method((n,r,o)=>n.RemoveKeyEventListener(me(r),o)),RemoveKeyEventListeners:this.method((n,r)=>n.RemoveKeyEventListeners(me(r))),RemoveAllKeyEventListeners:this.method(n=>n.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((n,r,o)=>n.AddNavigationEventListener(me(r),o)),RemoveNavigationEventListener:this.method((n,r,o)=>n.RemoveNavigationEventListener(me(r),o)),RemoveNavigationEventListeners:this.method((n,r)=>n.RemoveNavigationEventListeners(me(r))),RemoveAllNavigationEventListeners:this.method(n=>n.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((n,r,o,a)=>n.SetControllerNavigation(me(r),o,a)),GetControllerNavigation:this.method((n,r)=>n.GetControllerNavigation(me(r))),SetImage:this.method((n,r,o)=>n.SetImage(r,o)),SetSoftEdgeWidth:this.method((n,r,o)=>n.SetSoftEdgeWidth(r,o)),SetFillUnused:this.method(n=>n.SetFillUnused()),SetFillHorizontal:this.method((n,r,o)=>n.SetFillHorizontal(r,o)),SetFillVertical:this.method((n,r,o)=>n.SetFillVertical(r,o)),SetFillRadial90:this.method((n,r,o)=>n.SetFillRadial90(r,o)),SetFillRadial180:this.method((n,r,o)=>n.SetFillRadial180(r,o)),SetFillRadial360:this.method((n,r,o)=>n.SetFillRadial360(r,o)),PlayAnimation:this.method(n=>n.PlayAnimation()),StopAnimation:this.method(n=>n.StopAnimation()),RefreshItems:this.method(n=>n.RefreshItems()),GetItemIndex:this.method(n=>n.GetItemIndex()),GetItemSize:this.method(n=>n.GetItemSize()),GetItemSpacing:this.method(n=>n.GetItemSpacing()),GetPadding:this.method(n=>n.GetPadding()),ScrollToItemAt:this.method(n=>n.ScrollToItemAt()),GetContentLength:this.method(n=>n.GetContentLength())};this.mtIndexNewindex(t,"Control",(n,r)=>{if(!un(n,r))return;let o=n[r],a=lo[r];return a?fn(a,o):o},(n,r,o)=>{if(un(n,r)==="rw"){let s=lo[r];n[r]=s?fn(s,o):o,typeof n.markPlayDirty=="function"&&n.markPlayDirty(di.has(r));return}throw new Error(`cannot set ${r}, no such field`)},i,no)}mtScript(t){let i=this,n=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(r,o)=>n.has(o)?r[o]:void 0,(r,o,a)=>{if(o==="enabled"){r.enabled=!!a;return}throw new Error(`cannot set ${o}, no such field`)},{GetParam:this.method((r,o)=>Object.prototype.hasOwnProperty.call(r.params,o)?r.params[o]:null),Invoke:this.method((r,o,...a)=>r.invoke(o,a)),EnableUpdate:this.method((r,o)=>{r.updateEnabled=!!o}),RegisterServerSignalHandler:this.method((r,o,a)=>{i.signalHandlers.push({script:r,name:o,fn:a})}),UnregisterServerSignalHandler:this.method((r,o)=>{i.signalHandlers=i.signalHandlers.filter(a=>!(a.script===r&&a.name===o))}),RegisterCustomVariableChangedHandler:this.method((r,o,a,s)=>{i.varHandlers.push({script:r,entityType:me(o),name:a,fn:s})}),UnregisterCustomVariableChangedHandler:this.method((r,o,a)=>{let s=me(o);i.varHandlers=i.varHandlers.filter(c=>!(c.script===r&&c.entityType===s&&c.name===a))})})}mtTween(t){this.mtIndexNewindex(t,"Tween",()=>{},()=>{},{SetEase:this.method((i,n)=>i.SetEase(n)),SetRelative:this.method((i,n)=>i.SetRelative(n)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSeq(t){this.mtIndexNewindex(t,"TweenSequence",()=>{},()=>{},{Append:this.method((i,n)=>i.Append(n)),AppendInterval:this.method((i,n)=>i.AppendInterval(n)),AppendCallback:this.method((i,n)=>i.AppendCallback(n)),Join:this.method((i,n)=>i.Join(n)),Insert:this.method((i,n,r)=>i.Insert(n,r)),InsertCallback:this.method((i,n,r)=>i.InsertCallback(n,r)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSignal(t){this.mtIndexNewindex(t,"ServerSignal",()=>{},()=>{},{AddParam:this.method((i,n,r)=>i.AddParam(n,r)),SendSignal:this.method(i=>i.SendSignal()),AddInt:this.method((i,n)=>i.AddInt(n)),AddIntList:this.method((i,n)=>i.AddIntList(n)),AddFloat:this.method((i,n)=>i.AddFloat(n)),AddFloatList:this.method((i,n)=>i.AddFloatList(n)),AddString:this.method((i,n)=>i.AddString(n)),AddStringList:this.method((i,n)=>i.AddStringList(n)),AddVector3:this.method((i,n)=>i.AddVector3(n)),AddVector3List:this.method((i,n)=>i.AddVector3List(n)),AddBool:this.method((i,n)=>i.AddBool(n)),AddBoolList:this.method((i,n)=>i.AddBoolList(n)),AddGuid:this.method((i,n)=>i.AddGuid(n)),AddGuidList:this.method((i,n)=>i.AddGuidList(n)),AddEntity:this.method((i,n)=>i.AddEntity(n)),AddEntityList:this.method((i,n)=>i.AddEntityList(n)),AddPrefabId:this.method((i,n)=>i.AddPrefabId(n)),AddPrefabIdList:this.method((i,n)=>i.AddPrefabIdList(n)),AddConfigId:this.method((i,n)=>i.AddConfigId(n)),AddConfigIdList:this.method((i,n)=>i.AddConfigIdList(n))})}luaRequire(t){let i=L(t,1),n=this.normalizeRequirePath(i),r=this.requireAliases.get(n)||n;u.lua_rawgeti(t,et,u.LUA_RIDX_MAINTHREAD);let o=u.lua_tothread(t,-1);u.lua_pop(t,1);let a=this.requireCache.get(o);a||(a=new Map,this.requireCache.set(o,a));let s=a.get(r);if(s?.loading)return u.lua_pushstring(t,_(`failed to load script '${n}': cyclic require`)),u.lua_error(t);if(s&&s.ref!=null)return u.lua_rawgeti(t,et,s.ref),1;let c=this.scriptFiles.get(r);if(c==null)return u.lua_pushstring(t,_(`failed to load script '${n}'`)),u.lua_error(t);let l=u.lua_gettop(t);a.set(r,{loading:!0});try{this.loadModule(t,o,r,c),u.lua_pushvalue(t,-1);let f=re.luaL_ref(t,et);return a.set(r,{ref:f}),1}catch(f){return a.delete(r),u.lua_settop(t,l),u.lua_pushstring(t,_(`failed to load script '${n}': ${f.message||f}`)),u.lua_error(t)}}newLuaThread(){let t=re.luaL_newstate();return qr.luaL_openlibs(t),eo(t),this.installMetatables(t),this.installGlobals(t),this.luaStates.add(t),u.lua_pushglobaltable(t),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.moduleBaseEnvironments.set(t,re.luaL_ref(t,et)),t}copyLuaEnvironment(t,i){let n=u.lua_absindex(t,i);u.lua_newtable(t);let r=u.lua_absindex(t,-1);for(u.lua_pushnil(t);u.lua_next(t,n)!==0;)u.lua_pushvalue(t,-2),u.lua_pushvalue(t,-2),u.lua_rawset(t,r),u.lua_pop(t,1);u.lua_pushvalue(t,r),u.lua_setfield(t,r,_("_G"))}closeTrackedLuaState(t){if(!t||!this.luaStates.has(t))return;for(let n of this.requireCache.get(t)?.values()||[])n.ref!=null&&re.luaL_unref(t,et,n.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&re.luaL_unref(t,et,i),this.moduleBaseEnvironments.delete(t),this.luaStates.delete(t),this.luaFunctions)for(let[n,r]of this.luaFunctions)r.__luaState===t&&this.luaFunctions.delete(n);Qr(t)}loadModule(t,i,n,r){let o={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:n,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},a=String(r).replace(/^\uFEFF/,""),s=fi(a);if(re.luaL_loadbuffer(t,s,s.length,_(`@${n}`))!==Ee)throw new Error(L(t,-1));let l=u.lua_absindex(t,-1);if(u.lua_rawgeti(t,et,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.pushScript(t,o),u.lua_setfield(t,-2,_("script")),u.lua_setupvalue(t,l,1),u.lua_pcall(t,0,1,0)!==Ee)throw new Error(L(t,-1))}mountScript({path:t,source:i,control:n,params:r={},scriptMappingId:o=void 0}){this.L||this.boot();let a=this.newLuaThread(),s={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(o),object:n,path:Xs(t),enabled:!0,updateEnabled:!1,params:r,env:a,lifecyclePhase:"idle"};s.invoke=(l,f)=>this.invokeOn(a,l,f),n&&n.scripts.push(s),this.mountedScripts.push(s),this.pushScript(a,s),u.lua_setglobal(a,_("script"));let c=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",s.lifecyclePhase="OnInit",this.runChunk(a,i,t);let l=this.callGlobal(a,"OnInit");l&&this.mountErrors.push(l),this.lifecyclePhase="OnEnable",s.lifecyclePhase="OnEnable";let f=this.callGlobal(a,"OnEnable");f&&this.mountErrors.push(f),this.lifecyclePhase="OnStart",s.lifecyclePhase="OnStart";let h=this.callGlobal(a,"OnStart");return h&&this.mountErrors.push(h),this.lifecyclePhase="running",s.lifecyclePhase="running",s}catch(l){throw s.alive=!1,s.lifecyclePhase="failed",this.mountedScripts=this.mountedScripts.filter(f=>f!==s),n&&(n.scripts=n.scripts.filter(f=>f!==s)),this.varHandlers=this.varHandlers.filter(f=>f.script!==s),this.signalHandlers=this.signalHandlers.filter(f=>f.script!==s),this.lifecyclePhase=c,a&&a!==this.L&&this.closeTrackedLuaState(a),s.env=null,l}}runChunk(t,i,n){let r=String(i).replace(/^\uFEFF/,""),o=fi(r),a=re.luaL_loadbuffer(t,o,o.length,_(`@${n}`));if(a!==Ee){let c=L(t,-1)||`luaL_loadbuffer status ${a}`;throw u.lua_pop(t,1),new Error(c)}let s=u.lua_pcall(t,0,0,0);if(s!==Ee){let c=L(t,-1)||`lua_pcall status ${s}`;throw u.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(u.lua_getglobal(t,_(i)),u.lua_isfunction(t,-1)){if(u.lua_pcall(t,0,0,0)!==Ee){let r=L(t,-1);u.lua_pop(t,1);let o=`${i}: ${r}`;return this.log("lua-error",o),o}}else u.lua_pop(t,1);return null}callGlobalDt(t,i,n){if(u.lua_getglobal(t,_(i)),u.lua_isfunction(t,-1)){if(u.lua_pushnumber(t,n),u.lua_pcall(t,1,0,0)!==Ee){let o=L(t,-1);u.lua_pop(t,1),this.log("lua-error",`${i}: ${o}`)}}else u.lua_pop(t,1)}invokeOn(t,i,n){let r=u.lua_gettop(t);if(u.lua_getglobal(t,_(i)),!u.lua_isfunction(t,-1)){u.lua_settop(t,r);return}for(let c of n)ne(t,this,c);if(u.lua_pcall(t,n.length,Hs,0)!==Ee){let c=L(t,-1);throw u.lua_settop(t,r),new Error(c)}let a=u.lua_gettop(t)-r;if(a<=0){u.lua_settop(t,r);return}if(a===1){let c=pe(t,this,-1);return u.lua_settop(t,r),c}let s=[];for(let c=1;c<=a;c++)s.push(pe(t,this,r+c));return u.lua_settop(t,r),s.__multi=!0,s}runScriptPhase(t,i){for(let n of this.mountedScripts){if(!this.scriptCanRun(n))continue;let r=n.env;r&&(this.pushScript(r,n),u.lua_setglobal(r,_("script")),!(t==="OnUpdate"&&!n.updateEnabled)&&this.callGlobalDt(r,t,i))}}step(t=1/30){if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new TypeError("dt must be a finite non-negative number");this.clock.frame++,this.clock.time+=t;let i=!this.clock.paused;for(let n of[...this.tweens])n.step(t);for(let n of[...this.sequences])n.step(t);this.runScriptPhase("OnUpdate",t),i&&(this.clock.levelTime+=t,this.runScriptPhase("OnLevelUpdate",t))}injectKey(t){for(let i of this.roots)we(i,n=>{n.alive&&n.activeInHierarchy&&n.keyListeners.has(t)&&n.emitKey(t)})}injectCursor(t,i,n){let r=n||this.makeCursorEventData({});Number.isFinite(r.x)&&Number.isFinite(r.y)&&(this.cursor.x=r.x,this.cursor.y=r.y),t.emitCursor(i,r)}getVar(t,i){if(this.serverBridge&&typeof this.serverBridge.getVar=="function")return this.serverBridge.getVar(t,i);let n=this.serverVars[t];return n?n[i]:void 0}notifyVarHandlers(t,i){for(let n of this.varHandlers)this.scriptCanRun(n.script)&&n.entityType===t&&n.name===i&&this.safeCall(n.fn,this.enumTree.CustomVariableEntityType[t],i)}setVar(t,i,n){if(this.serverBridge&&typeof this.serverBridge.setVar=="function"){this.serverBridge.setVar(t,i,n);return}let r=this.serverVars[t]||(this.serverVars[t]=Object.create(null));r[i]=n,this.notifyVarHandlers(t,i)}sendClientSignal(t,i){for(let n of this.signalHandlers)this.scriptCanRun(n.script)&&n.name===t&&this.safeCall(n.fn,t,i)}evalQueryScript(t,i){this.L||this.boot();let n=this.L;u.lua_createtable(n,0,5);let r=(o,a)=>{u.lua_pushcfunction(n,a),u.lua_setfield(n,-2,_(o))};return r("var",o=>(ne(o,this,i.var(L(o,1),L(o,2))),1)),r("logContains",o=>(u.lua_pushboolean(o,i.logContains(L(o,1))),1)),r("control",o=>(ne(o,this,i.control(L(o,1))),1)),r("logs",o=>(ne(o,this,i.logs()),1)),r("signals",o=>(ne(o,this,i.signals(L(o,1))),1)),r("serverLogs",o=>(ne(o,this,i.serverLogs?i.serverLogs():[]),1)),r("serverLogContains",o=>{let a=i.serverLogContains;return u.lua_pushboolean(o,a?!!a(L(o,1)):!1),1}),u.lua_setglobal(n,_("query")),this.runChunk(n,t,"autotest-assert"),!0}destroy(){for(let t of this.roots.slice())this.destroyControl(t);for(let t of this.mountedScripts.slice())this.unmountScript(t);this.lifecyclePhase="idle",this.mountedScripts=[],this.luaFunctions.clear();for(let t of[...this.luaStates])this.closeTrackedLuaState(t);this.L=null}};function Bt(e){let t=new bi(e);return t.boot(),t}var it=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),mn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),yo=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var hn=Object.freeze([...yo,...it,...mn]),bo=Object.freeze(["PlayerSelf","AllPlayers",...it]),Ks=Object.freeze(["Level","PlayerSelf",...it]),uo=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),Ls=-2147483648,Ws=2147483647,qs=new Set(["set-custom-variable","get-custom-variable","custom-variable-changed","\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF","\u83B7\u53D6\u81EA\u5B9A\u4E49\u53D8\u91CF","\u81EA\u5B9A\u4E49\u53D8\u91CF\u53D8\u5316\u65F6","send-signal","listen-signal","send-client-script-signal","\u53D1\u9001\u4FE1\u53F7","\u76D1\u542C\u4FE1\u53F7","\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7","setVar","getVar","signal","var"]);function Ut(e){return`Player${Number(e)}`}function vi(e){return`Avatar${Number(e)}`}function co(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function tt(e){if(e==null||e==="")return 1;let t=Number(e);if(!Number.isInteger(t)||t<1||t>8)throw new Error("playerCount must be an integer 1-8");return t}function Pe(e,t=8){let i=tt(t);if(e==null||e==="")return 1;let n=Number(e);if(!Number.isInteger(n)||n<1||n>i)throw new Error(`playerIndex must be an integer 1-${i}`);return n}function fo(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of it)e[t]=Object.create(null);for(let t of mn)e[t]=Object.create(null);return e}function vo(e){let t=String(e||"");if(!hn.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function js(e,t){let i=vo(e);if(!Ks.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function Ht(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function Si(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function pn(e){let t=String(e||"PlayerSelf");if(!bo.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function Xt(e){if(e==null)return"";if(typeof e=="boolean")return"Bool";if(typeof e=="string")return"String";if(typeof e=="number")return Number.isInteger(e)?"Int":"Float";if(Array.isArray(e)){if(e.length===0)return"IntList";let t=Xt(e[0]);return t&&!t.endsWith("List")&&t!=="Dict"&&t!=="Struct"?`${t}List`:"IntList"}return e&&typeof e=="object"?"x"in e||"y"in e||"z"in e?"Vector3":"Dict":""}function ye(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function ho(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?t.value:t):[]}function po(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?{type:String(t.type||""),value:t.value}:{type:Xt(t),value:t}):[]}function Js(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function wi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function So(e,t){if(!wi(e)||!Object.prototype.hasOwnProperty.call(e,"fromSignalParam"))return null;if(Object.keys(e).some(n=>n!=="fromSignalParam"))throw new Error(`${t}.fromSignalParam cannot be combined with literal fields`);let i=Number(e.fromSignalParam);if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t}.fromSignalParam must be a non-negative integer`);return{fromSignalParam:i}}function mo(e,t){return So(e,t)||ye(e)}function Zs(e,t,i){if(!wi(e))throw new Error(`serverLogic.rules[${t}].actions[${i}] must be an object`);let n=String(e.kind||e.type||""),r=`serverLogic.rules[${t}].actions[${i}]`;if(n==="setCustomVariable"){let o=js(e.entityType,r);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${r}.value is required`);return{kind:n,entityType:o,name:Ht(e.name),value:mo(e.value,`${r}.value`),...e.variableType?{variableType:String(e.variableType)}:{}}}if(n==="sendClientScriptSignal"){if(!Array.isArray(e.params))throw new Error(`${r}.params must be an array`);return{kind:n,target:pn(e.target),signalName:Si(e.signalName),params:e.params.map((o,a)=>mo(o,`${r}.params[${a}]`))}}throw new Error(`${r}.kind must be setCustomVariable or sendClientScriptSignal`)}function wt(e){if(e==null)return{version:1,rules:[]};if(!wi(e))throw new Error("serverLogic must be an object");let t=e.rules===void 0?[]:e.rules;if(!Array.isArray(t))throw new Error("serverLogic.rules must be an array");return{version:1,rules:t.map((i,n)=>{if(!wi(i))throw new Error(`serverLogic.rules[${n}] must be an object`);if(!Array.isArray(i.actions)||i.actions.length===0)throw new Error(`serverLogic.rules[${n}].actions must be a non-empty array`);return{id:String(i.id||`signal-${n+1}`),signalName:Si(i.signalName),actions:i.actions.map((r,o)=>Zs(r,n,o))}})}}function go(e,t,{typed:i=!1}={}){let n=So(e,"server logic value");if(n){let r=i?t.params:t.values;if(n.fromSignalParam>=r.length)throw new Error(`signal ${t.name} has no parameter at index ${n.fromSignalParam}`);return ye(r[n.fromSignalParam])}return ye(e)}function Qs(e){return e==="Level"?"Level":it.includes(e)?"PlayerSelf":mn.includes(e)?"AvatarSelf":e}function wo(e={}){let t=fo(),i=fo(),n=[],r=[],o=[],a=[],s=Array.from({length:9},()=>null),c=1,l=0,f=Number(e.onlineLatencyMs||0);(!Number.isFinite(f)||f<0)&&(f=0);let h=wt(e.logic),p=tt(e.playerCount),m=Pe(e.viewPlayerIndex,p);function g(b,x){a.push({source:"server",level:String(b||"engine"),text:String(x),time:l})}function I(b){let x=s[b||m],v=Number(x?.clock?.time);Number.isFinite(v)&&(l=v)}function k(b,x,v,C){t[b][x]=v,i[b][x]={type:C||Xt(v)||i[b][x]?.type||""}}function E(b,x,v){return typeof v!="number"||!Number.isInteger(v)?{ok:!0,value:v}:v>=Ls&&v<=Ws?{ok:!0,value:v}:(g("engine",`Int custom variable ${b}.${x} out of range ${v}; keeping previous legal value`),{ok:!1,value:t[b][x]})}function $(b,x){let v=vo(b),C=x||m;return v==="PlayerSelf"?Ut(C):v==="AvatarSelf"?vi(C):v}function F(b,x){let v=Qs(b);if(b==="Level"){for(let S=1;S<=p;S+=1){let P=s[S];P&&typeof P.notifyVarHandlers=="function"&&P.notifyVarHandlers("Level",x)}return}let C=co(b);if(!C)return;let M=s[C];M&&typeof M.notifyVarHandlers=="function"&&M.notifyVarHandlers(v,x)}function U(b,x){let v=pn(b);return v==="AllPlayers"?Array.from({length:p},(C,M)=>M+1):v==="PlayerSelf"?[x||m]:[co(v)]}function W(b){for(let x of h.rules)if(x.signalName===b.name)for(let v of x.actions){if(v.kind==="setCustomVariable"){let C=go(v.value,b);O.setVar(v.entityType,v.name,C,{type:v.variableType,playerIndex:b.playerIndex}),g("info",`logic ${x.id}: set ${v.entityType}.${v.name}`);continue}if(v.kind==="sendClientScriptSignal"){let C=v.params.map(M=>go(M,b,{typed:!0}));O.sendToClient(v.signalName,C,{target:v.target,playerIndex:b.playerIndex}),g("info",`logic ${x.id}: sent ${v.signalName} to ${v.target}`)}}}function Z(b,x){b&&(b.serverBridge={getVar:(v,C)=>O.getVar(v,C,{playerIndex:x}),setVar:(v,C,M)=>O.setVar(v,C,M,{playerIndex:x}),receiveFromClient:(v,C)=>O.receiveFromClient(v,C,{playerIndex:x})})}function q(b){b&&(b.serverBridge=null)}let O={ENTITY_TYPES:yo,ALL_ENTITY_TYPES:hn,CLIENT_SIGNAL_TARGETS:bo,get clock(){return l},get playerCount(){return p},get viewPlayerIndex(){return m},setClock(b){l=Number(b)||0},setPlayerCount(b){return p=tt(b),m>p&&(m=p),p},setViewPlayerIndex(b){return m=Pe(b,p),m},log(b,x){g(b,x)},defineVar(b,x,v={},{playerIndex:C}={}){let M=$(b,C),S=Ht(x);if(Object.prototype.hasOwnProperty.call(t[M],S))throw new Error(`custom variable already exists: ${M}.${S}`);let P=v.type?String(v.type):Xt(v.value??v.defaultValue);if(P&&!uo.includes(P))throw new Error(`unsupported custom variable type: ${P}`);let z=v.value!==void 0?v.value:v.defaultValue!==void 0?v.defaultValue:null;return k(M,S,z,P),O.getVar(M,S)},getVar(b,x,{playerIndex:v}={}){let C=$(b,v),M=Ht(x);if(!Object.prototype.hasOwnProperty.call(t[C],M)){g("engine",`GetGlobalCustomVariableValue missing ${C}.${M}; returning nil (simulator policy)`);return}return t[C][M]},setVar(b,x,v,{notify:C=!0,type:M,playerIndex:S}={}){let P=$(b,S),z=Ht(x),G=M||i[P][z]?.type||Xt(v);if(G&&!uo.includes(G)&&G!=="")throw new Error(`unsupported custom variable type: ${G}`);let ie=v;if(!((G==="Int"||G===""&&typeof v=="number"&&Number.isInteger(v))&&(ie=E(P,z,v).value,ie===void 0)))return k(P,z,ie,G),C&&F(P,z),ie},listVars(b){let x=b?[$(b)]:["Level",...Array.from({length:p},(C,M)=>Ut(M+1)),...Array.from({length:p},(C,M)=>vi(M+1))],v=[];for(let C of x)for(let M of Object.keys(t[C]))v.push({entityType:C,name:M,type:i[C][M]?.type||"",value:ye(t[C][M])});return v},receiveFromClient(b,x=[],{playerIndex:v}={}){let C=Pe(v||m,p);I(C);let M=Si(b),S={id:c++,direction:"inbound",name:M,params:po(x),values:ho(x),time:l,playerIndex:C,from:Ut(C)};return n.push(S),W(S),S},sendToClient(b,x=[],{target:v="PlayerSelf",playerIndex:C}={}){let M=Si(b),S=pn(v),z=U(S,C||m),G={id:c++,direction:"outbound",name:M,params:po(x),values:ho(x),time:l,target:S,players:z,deliverAt:l+f/1e3,delivered:!1};return r.push(G),f===0?O.deliver(G):o.push(G),G},getLogic(){return ye(h)},setLogic(b){return h=wt(b),O.getLogic()},deliver(b){if(!b||b.delivered)return;b.delivered=!0;let x=Array.isArray(b.players)&&b.players.length?b.players:U(b.target);for(let v of x){let C=s[v];C&&typeof C.sendClientSignal=="function"&&C.sendClientSignal(b.name,b.values)}},flush(b){b!==void 0&&(l=Number(b)||0);let x=[];for(let v=o.length-1;v>=0;v-=1)o[v].deliverAt<=l&&x.push(o.splice(v,1)[0]);x.sort((v,C)=>v.id-C.id);for(let v of x)O.deliver(v);return x},inbound(){return n.slice()},outbound(){return r.slice()},loadConfig(b){if(b!=null){if(typeof b!="object")throw new Error("server config must be an object");if(b.graph&&!Array.isArray(b.nodes))throw new Error("unsupported server node graph: v1 only accepts custom variables and signals");for(let x of b.nodes||[]){let v=Js(x);if(!qs.has(v))throw new Error(`unsupported server node: ${v||JSON.stringify(x)}. v1 only supports custom variables and signals`)}if(b.onlineLatencyMs!==void 0){let x=Number(b.onlineLatencyMs);if(!Number.isFinite(x)||x<0)throw new Error("onlineLatencyMs must be a non-negative finite number");f=x}b.playerCount!==void 0&&O.setPlayerCount(b.playerCount),b.viewPlayerIndex!==void 0&&O.setViewPlayerIndex(b.viewPlayerIndex),(b.logic!==void 0||b.serverLogic!==void 0)&&O.setLogic(b.logic??b.serverLogic);for(let x of b.vars||[]){let v=$(x.entityType),C=Ht(x.name);Object.prototype.hasOwnProperty.call(t[v],C)?O.setVar(v,C,x.value??x.defaultValue,{notify:!1,type:x.type}):O.defineVar(v,C,x)}}},attachRuntime(b,{playerIndex:x=1}={}){let v=Pe(x,8);return s[v]&&s[v]!==b&&q(s[v]),s[v]=b||null,Z(s[v],v),O},attachRuntimes(b){O.detachRuntime();let x=Array.isArray(b)?b:[];for(let v=0;v<x.length&&v<8;v+=1)s[v+1]=x[v]||null,Z(s[v+1],v+1);return O},detachRuntime(){for(let b=1;b<=8;b+=1)q(s[b]),s[b]=null},snapshot(){let b=Ut(m),x=vi(m),v={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let C of Object.keys(t.Level))v.Level[C]={type:i.Level[C]?.type||"",value:ye(t.Level[C])};for(let C of Object.keys(t[b]))v.PlayerSelf[C]={type:i[b][C]?.type||"",value:ye(t[b][C])};for(let C of Object.keys(t[x]))v.AvatarSelf[C]={type:i[x][C]?.type||"",value:ye(t[x][C])};for(let C=1;C<=p;C+=1){let M=Ut(C),S=vi(C);v[M]={},v[S]={};for(let P of Object.keys(t[M]))v[M][P]={type:i[M][P]?.type||"",value:ye(t[M][P])};for(let P of Object.keys(t[S]))v[S][P]={type:i[S][P]?.type||"",value:ye(t[S][P])}}return{clock:l,onlineLatencyMs:f,playerCount:p,viewPlayerIndex:m,logic:O.getLogic(),vars:v,inbound:n.map(C=>({id:C.id,name:C.name,params:ye(C.params),values:ye(C.values),time:C.time,playerIndex:C.playerIndex,from:C.from})),outbound:r.map(C=>({id:C.id,name:C.name,params:ye(C.params),values:ye(C.values),time:C.time,target:C.target,players:Array.isArray(C.players)?C.players.slice():[],deliverAt:C.deliverAt,delivered:!!C.delivered})),logs:a.map(C=>({source:"server",level:C.level,text:C.text,time:C.time}))}},reset(){for(let b of hn){for(let x of Object.keys(t[b]))delete t[b][x];for(let x of Object.keys(i[b]))delete i[b][x]}n.length=0,r.length=0,o.length=0,a.length=0,c=1,l=0},destroy(){O.detachRuntime(),O.reset()}};e.config&&O.loadConfig(e.config);for(let b of e.vars||[])O.defineVar(b.entityType,b.name,b);return O}var el={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function gn(e,t,i=null){let n=ze(e.transformByPlatform,t),r={authoringId:e.id,kind:el[e.kind]||"container",name:e.name,prefabIndex:e.guid||0,active:e.active!==!1,visible:e.visible!==!1,canControllerFocus:e.canControllerFocus===!0,anchoredPositionX:n.offset.x,anchoredPositionY:n.offset.y,sizeDeltaX:n.size.x,sizeDeltaY:n.size.y,anchorMinX:n.anchorMin.x,anchorMinY:n.anchorMin.y,anchorMaxX:n.anchorMax.x,anchorMaxY:n.anchorMax.y,pivotX:n.pivot.x,pivotY:n.pivot.y,localScaleX:n.scale.x,localScaleY:n.scale.y,localScaleZ:n.scale.z,localRotationX:n.rotation.x,localRotationY:n.rotation.y,localRotationZ:n.rotation.z,children:(e.children||[]).map(a=>gn(a,t,i))},o=i?.get(e.id);return o?.length&&(r.scripts=o.map(a=>{let s=Number(a.guid);return{path:a.path||a.id,source:a.source||"",...Number.isSafeInteger(s)&&s>0?{scriptMappingId:s}:{}}})),e.kind==="container"&&(r.isolateNavigation=e.isolateNavigation===!0,r.disableKeyEventPassthrough=e.disableKeyEventPassthrough===!0,r.disableCursorEventPassthrough=e.disableCursorEventPassthrough===!0,r.showCursor=e.showCursor===!0),(e.kind==="textbox"||e.kind==="textwindow")&&(r.text=e.text??"",r.fontSize=e.fontSize,r.adaptiveFontSize=e.adaptiveFontSize===!0,r.minimumFontSize=e.minimumFontSize,r.fontColor=e.fontColor,r.bgColor=e.bgColor,r.enableOutline=e.enableOutline!==!1,r.outlineColor=e.outlineColor,r.horizontalAlignment=e.horizontalAlignment||"Left",r.verticalAlignment=e.verticalAlignment||"Top",e.kind==="textwindow"&&(r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1)),e.kind==="image"&&(r.imageSource=e.imageSource,r.imageId=e.imageId??0,r.imageColor=e.imageColor,r.raycastTarget=e.raycastTarget===!0,r.enableMask=e.enableMask===!0,r.enableSoftEdge=e.enableSoftEdge===!0,r.softEdgeMode=e.softEdgeMode,r.softEdgeWidthX=e.softEdgeWidthX,r.softEdgeWidthY=e.softEdgeWidthY,r.horizontalSoftRange=e.horizontalSoftRange,r.verticalSoftRange=e.verticalSoftRange,r.enableFill=e.enableFill===!0,r.fillType=e.enableFill?e.fillType:"Unused",r.fillHorizontalType=e.fillHorizontalType,r.fillVerticalType=e.fillVerticalType,r.fillRadial90Type=e.fillRadial90Type,r.fillRadialType=e.fillRadialType,r.fillAmount=e.fillAmount,r.reverseMaskArea=e.reverseMaskArea===!0),e.kind==="button"&&(r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.clickAudioId=e.clickAudioId,r.unavailableChildId=e.unavailableChildId??null,r.hoverChildId=e.hoverChildId??null,r.pressedChildId=e.pressedChildId??null,r.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(r.raycastTarget=e.raycastTarget!==!1),e.kind==="reference"&&(r.referencedPrefabIndex=e.referencedPrefabId),e.kind==="grid"&&(r.itemPrefabIndex=e.itemPrefabId,r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1,r.scrollDirection=e.scrollDirection,r.layoutConstraint=e.layoutConstraint,r.layoutConstraintFixedCount=e.layoutConstraintFixedCount,r.cellSizeX=e.cellSizeX,r.cellSizeY=e.cellSizeY,r.spacingX=e.spacingX,r.spacingY=e.spacingY,r.padding1X=e.padding1X,r.padding1Y=e.padding1Y,r.padding2X=e.padding2X,r.padding2Y=e.padding2Y,r.previewCount=e.previewCount),e.kind==="keyhint"&&(r.keyboardKeyCode=e.keyboardKeyCode,r.controllerKeyCode=e.controllerKeyCode),(e.kind==="animation"||e.kind==="fullscreen")&&(r.raycastTarget=!1,r.animationId=e.animationId,r.playSoundEffect=e.playSoundEffect,e.kind==="animation"&&(r.layer=e.layer)),r}function yn(e,t=[],i=""){let n=i&&K[i]?i:e.canvasId,r=K[n],o=Dt(e),a=new Map;for(let c of t){if(!c.controlId)continue;let l=a.get(c.controlId)||[];l.push(c),a.set(c.controlId,l)}let s=e.meta?.assetType==="client-control-template"?(e.root.children||[]).map(c=>gn(c,n,a)):[];return{canvasId:n,platform:r.platform,device:r.luaDevice,canvasWidth:r.width,canvasHeight:r.height,root:gn(o,n,a),templates:s}}var Ii="qxqy-autotest";var nt=.03333333333333333,tl=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),il=new Set(["log","control","var","signal","tree","lua"]);function Kt(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function bn(e){return JSON.parse(JSON.stringify(e??null))}function Ci(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!tl.has(i))throw new Error(`unsupported event kind: ${i||"(empty)"}`);let n=e.payload&&typeof e.payload=="object"?{...e.payload}:{};if(i==="pointer")!n.type&&e.type&&(n.type=e.type),n.x===void 0&&(n.x=e.x),n.y===void 0&&(n.y=e.y),n.x=Kt(n.x,"pointer.x"),n.y=Kt(n.y,"pointer.y"),n.type=String(n.type||"click");else if(i==="key"){if(n.typeName=String(n.typeName||n.key||e.typeName||e.key||""),!n.typeName)throw new Error("key event requires typeName")}else if(i==="click"){if(n.name=String(n.name||e.name||""),!n.name)throw new Error("click event requires control name")}else if(i==="serverSet"){if(n.entityType=String(n.entityType||e.entityType||""),n.name=String(n.name||e.name||""),n.value===void 0&&(n.value=e.value),n.value===void 0&&(n.value=null),!n.entityType||!n.name)throw new Error("serverSet requires entityType and name")}else if(i==="serverSend"){if(n.name=String(n.name||e.name||""),n.params=Array.isArray(n.params)?n.params:Array.isArray(e.params)?e.params:[],n.target=String(n.target||e.target||"PlayerSelf"),!n.name)throw new Error("serverSend requires signal name")}else if(i==="view"&&(n.playerIndex=Number(n.playerIndex||n.viewPlayerIndex||e.playerIndex||e.viewPlayerIndex||0),!Number.isInteger(n.playerIndex)||n.playerIndex<1))throw new Error("view event requires playerIndex 1-8");return{t:Kt(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:n}}function vn(e,t){if(!e||typeof e!="object")throw new Error(`asserts[${t}] must be an object`);let i=String(e.kind||(e.check?"log":""));if(!il.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let n={kind:i};if(e.at!==void 0&&(n.at=Kt(e.at,"assert.at")),i==="log"){if(n.contains=String(e.contains||e.check||e.text||""),n.source=e.source==="server"?"server":"client",e.level&&(n.level=String(e.level)),!n.contains)throw new Error("log assert requires contains")}else if(i==="control"){if(n.id=e.id?String(e.id):"",n.name=e.name?String(e.name):"",n.field=String(e.field||""),!n.field)throw new Error("control assert requires field");if(!n.id&&!n.name)throw new Error("control assert requires id or name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("control assert requires equals");n.equals=bn(e.equals)}else if(i==="var"){if(n.entityType=String(e.entityType||""),n.name=String(e.name||""),!n.entityType||!n.name)throw new Error("var assert requires entityType and name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("var assert requires equals");n.equals=bn(e.equals)}else if(i==="signal"){if(n.direction=e.direction==="outbound"?"outbound":"inbound",n.name=String(e.name||""),!n.name)throw new Error("signal assert requires name");e.values!==void 0&&(n.values=bn(e.values))}else if(i==="tree"){if(n.name=String(e.name||""),n.exists=e.exists!==!1,!n.name)throw new Error("tree assert requires name")}else if(i==="lua"&&(n.source=String(e.source||""),!n.source.trim()))throw new Error("lua assert requires source");return n}function Io(e){let t=0,i=[],n=[];for(let r of e){if(!r||typeof r!="object")throw new Error("queue step must be an object");if(r.do!=="start"){if(r.do==="step"){t+=Kt(r.dt??nt,"step.dt");continue}if(r.do==="pointer"||r.do==="key"||r.do==="click"||r.do==="pause"||r.do==="resume"||r.do==="serverSet"||r.do==="serverSend"||r.do==="view"){i.push(Ci({...r,kind:r.do,t},i.length));continue}if(r.assert||r.check||r.kind){n.push(vn({...r.assert||r,at:r.at??t},n.length));continue}throw new Error(`unsupported queue step: ${JSON.stringify(r)}`)}}return{events:i,asserts:n,dt:nt}}function Lt(e){if(Array.isArray(e)){let n=Io(e);return{format:Ii,version:1,name:"",dt:n.dt,events:n.events,asserts:n.asserts}}if(!e||typeof e!="object")throw new Error("autotest case must be an object or step array");if(Array.isArray(e.queue)||Array.isArray(e.steps)){let n=Io(e.queue||e.steps);return{format:Ii,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):n.dt,events:n.events,asserts:n.asserts}}let t=(e.events||[]).map((n,r)=>Ci(n,r)),i=(e.asserts||[]).map((n,r)=>vn(n,r));return t.sort((n,r)=>n.t-r.t||0),{format:Ii,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):nt,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function Co(e,t={}){let i=(e||[]).map((n,r)=>Ci(n,r));return{format:Ii,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):nt,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((n,r)=>vn(n,r))}}function ko(e,t,i){if(!e)return null;let n=Ci({...t,t:t.t??i??0},e.events.length);return e.events.push(n),n}var nl=Object.freeze(Object.values(K).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function Cn(e){let t=de({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function n(r,o,a){let s=Ae(o,r);s.activeInHierarchy=a&&r.active!==!1,i.set(r.Id,s);let c=s.activeInHierarchy;for(let l of r.children)n(l,s,c)}for(let r of e.runtime.roots)n(r,t,!0);return i}function rl(e,t=Cn(e)){let i=new Map;function n(r,o){let a=t.get(r.Id);if(!a)return;let s=$t(o,a,r);i.set(r.Id,s);for(let c of r.children)n(c,s)}for(let r of e.runtime.roots)n(r,gt());return i}function Eo(e,t){let i=t.get(e.Id);return{id:e.Id,prefabId:e.prefabIndex,authoringId:e.authoringId,name:e.name,kind:e.kind,typeofName:e.typeofName,instantiated:!e.authoringId,active:!!e.active,visible:!!e.visible,activeInHierarchy:!!i?.activeInHierarchy,raycastTarget:e.raycastTarget!==!1,interactable:e.interactable!==!1,pressed:e.pressed===!0,anchoredPositionX:e.anchoredPositionX,anchoredPositionY:e.anchoredPositionY,sizeDeltaX:e.sizeDeltaX,sizeDeltaY:e.sizeDeltaY,localScaleX:e.localScaleX,localScaleY:e.localScaleY,localScaleZ:e.localScaleZ,localRotationZ:e.localRotationZ,text:e.kind==="textbox"||e.kind==="textwindow"?e.text??"":null,fontSize:e.kind==="textbox"||e.kind==="textwindow"?e.fontSize:null,fontColor:e.kind==="textbox"||e.kind==="textwindow"?e.fontColor:null,bgColor:e.kind==="textbox"||e.kind==="textwindow"?e.bgColor:null,enableOutline:e.kind==="textbox"||e.kind==="textwindow"?e.enableOutline===!0:null,outlineColor:e.kind==="textbox"||e.kind==="textwindow"?e.outlineColor:null,imageId:e.kind==="image"?e.imageId??0:null,primitive:e.kind==="image"?pt[e.imageId]||"missing":null,imageColor:e.kind==="image"?e.imageColor:null,enableMask:e.kind==="image"?e.enableMask===!0:null,enableSoftEdge:e.kind==="image"?e.enableSoftEdge===!0:null,softEdgeMode:e.kind==="image"?e.softEdgeMode:null,softEdgeWidthX:e.kind==="image"?e.softEdgeWidthX:null,softEdgeWidthY:e.kind==="image"?e.softEdgeWidthY:null,horizontalSoftRange:e.kind==="image"?e.horizontalSoftRange:null,verticalSoftRange:e.kind==="image"?e.verticalSoftRange:null,enableFill:e.kind==="image"?e.enableFill===!0:null,fillType:e.kind==="image"?e.fillType:null,fillHorizontalType:e.kind==="image"?e.fillHorizontalType:null,fillVerticalType:e.kind==="image"?e.fillVerticalType:null,fillRadial90Type:e.kind==="image"?e.fillRadial90Type:null,fillRadialType:e.kind==="image"?e.fillRadialType:null,reverseMaskArea:e.kind==="image"?e.reverseMaskArea===!0:null,fillAmount:e.kind==="image"?e.fillAmount:null,box:i?{left:i.left,bottom:i.bottom,width:i.width,height:i.height}:null,children:e.children.map(n=>Eo(n,t))}}function ol(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function al(e,t,i){let n=Bt({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device});for(let r of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(r.prefabIndex)&&r.prefabIndex>0&&n.registerTemplate(r.prefabIndex,r);for(let r of i){let o=r.path||r.id,a=r.source||"";o&&a&&n.registerScriptFile(o,a)}return n}var sl=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","hoveredControl","selectedControl","stateRestores","viewCache"];function ll(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of sl)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return e.views[e.viewPlayerIndex-1][t]},set(i){e.views[e.viewPlayerIndex-1][t]=i}})}function Ao(e,{templatesProject:t=null,scripts:i=[],sceneScripts:n=null,templateScripts:r=null,serverConfig:o=null,canvasId:a="",playerCount:s=1,viewPlayerIndex:c=1}={}){let l=n||i,f=r||i,h=yn(e,l,a),p=t?yn(t,f,a):null,m=tt(s),g=Pe(c,m),I=wo({playerCount:m,viewPlayerIndex:g});o&&I.loadConfig({...o,playerCount:m,viewPlayerIndex:g});let k=[];for(let F=0;F<m;F+=1)k.push(al(h,p,i));I.attachRuntimes(k);for(let F of k)F.addRoot(h.root);let E={runtimes:k,views:k.map(()=>ol()),playerCount:m,viewPlayerIndex:g,server:I,compiled:h,mountError:k.find(F=>F.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};ll(E);let $=E.viewPlayerIndex;for(let F=1;F<=m;F+=1)E.viewPlayerIndex=F,Sl(E);return E.viewPlayerIndex=$,E}function kn(e,t){if(!e)throw new Error("play session has not started");let i=Pe(t,e.playerCount);return i===e.viewPlayerIndex||(Ue(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function Ue(e,t){!e?.recording||!e.history||ko(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function ul(e){return e?.history?.events||[]}var xn=new Set(["image","textbox","textwindow","button"]);function cl(e,t){let i=Ke(t,e.centerX,e.centerY);return{centerX:i.x,centerY:i.y,scaleX:Math.hypot(t.a,t.b),scaleY:Math.hypot(t.c,t.d),rotationZ:Math.atan2(t.b,t.a)*180/Math.PI,matrix:{a:t.a,b:t.b,c:t.c,d:t.d,tx:i.x,ty:i.y}}}function rt(e){return typeof e=="string"?e:e?.Name}function _o(e){return{fillType:rt(e.fillType),fillHorizontalType:rt(e.fillHorizontalType),fillVerticalType:rt(e.fillVerticalType),fillAmount:e.fillAmount}}function fl(e,t,i){let n=Math.abs(t.width*i.scaleX),r=Math.abs(t.height*i.scaleY),o={id:e.Id,kind:e.kind,name:e.name,left:i.centerX-n/2,bottom:i.centerY-r/2,width:n,height:r,sourceWidth:t.width,sourceHeight:t.height,rotationZ:i.rotationZ,matrix:i.matrix,pressed:e.pressed===!0};return e.kind==="image"&&(o.primitive=pt[e.imageId]||"missing",o.imageColor=e.imageColor,o.imageId=e.imageId,Object.assign(o,_o(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(o.text=e.text??"",o.fontSize=e.fontSize,o.fontColor=e.fontColor,o.bgColor=e.bgColor,o.enableOutline=e.enableOutline===!0,o.outlineColor=e.outlineColor,o.horizontalAlignment=rt(e.horizontalAlignment),o.verticalAlignment=rt(e.verticalAlignment)),o}function dl(e,t=Cn(e)){let i=[],n=rl(e,t);function r(o){let a=t.get(o.Id);if(!a||o.visible===!1||!a.activeInHierarchy)return;let s=n.get(o.Id);if(!s)return;let c=cl(a,s);xn.has(o.kind)&&i.push(fl(o,a,c));let l=o.children||[];for(let f=l.length-1;f>=0;f-=1)r(l[f])}for(let o of e.runtime.roots)r(o);return i}function hl(e,t){let i={kind:e.kind,name:e.name,sourceWidth:t.width,sourceHeight:t.height,pressed:e.pressed===!0};return e.kind==="image"&&(i.primitive=pt[e.imageId]||"missing",i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,_o(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(i.text=e.text??"",i.fontSize=e.fontSize,i.fontColor=e.fontColor,i.bgColor=e.bgColor,i.enableOutline=e.enableOutline===!0,i.outlineColor=e.outlineColor,i.horizontalAlignment=rt(e.horizontalAlignment),i.verticalAlignment=rt(e.verticalAlignment)),i}function pl(e,t,i){let n=Di(e,t),r=Ke(n,e.centerX,e.centerY);return{a:n.a,b:n.b,c:n.c,d:n.d,tx:r.x-(i?i.centerX:0),ty:r.y-(i?i.centerY:0)}}function Po(e){let t=e.matrix;return[e.parent,e.z,e.group?1:0,t.a,t.b,t.c,t.d,t.tx,t.ty,e.kind,e.name,e.sourceWidth,e.sourceHeight,e.pressed,e.primitive,e.imageColor,e.imageId,e.fillType,e.fillHorizontalType,e.fillVerticalType,e.fillAmount,e.text,e.fontSize,e.fontColor,e.bgColor,e.enableOutline,e.outlineColor,e.horizontalAlignment,e.verticalAlignment].join(" ")}function To(e,t,i,n,r,o){return{id:e.Id,parent:t,z:r,group:o>=16,matrix:pl(n,e,i),...hl(e,n)}}function ml(e){let t=de({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,n=new Map,r=new Map;function o(c,l,f){let h=Ae(l,c);if(h.activeInHierarchy=f&&c.active!==!1,r.set(c.Id,h),c.visible===!1||!h.activeInHierarchy)return!1;let p=c.children||[],m=xn.has(c.kind),g=0;for(let I=0;I<p.length;I+=1)o(p[I],h,h.activeInHierarchy)&&(m=!0,g+=1);return m?(i.add(c.Id),n.set(c.Id,g),!0):!1}function a(c,l,f,h){if(!i.has(c.Id))return;let p=r.get(c.Id);s.push(To(c,l,f,p,h,n.get(c.Id)||0));let m=c.children||[];for(let g=0;g<m.length;g+=1)a(m[g],c.Id,p,g)}let s=[];for(let c=0;c<e.runtime.roots.length;c+=1)o(e.runtime.roots[c],t,!0),a(e.runtime.roots[c],null,null,c);return{nodes:s,childCounts:n}}function In(e){let t=e._playChildDirty===!0||e._playDeepDirty===!0;if(e._playDirty=!1,e._playChildDirty=!1,e._playDeepDirty=!1,!t)return;let i=e.children;for(let n=0;n<i.length;n+=1)In(i[n])}function gl(e,t){let i=de({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=[],r=[],o=t.count,a=e.runtime._playRemoved||[];for(let l=0;l<a.length;l+=1){let f=a[l];t.fingerprints.has(f)&&(r.push(f),t.fingerprints.delete(f),t.childCounts.delete(f),o-=1)}e.runtime._playRemoved=[];function s(l){t.fingerprints.has(l.Id)&&(r.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),o-=1);let f=l.children;for(let h=0;h<f.length;h+=1)s(f[h])}function c(l,f,h,p,m,g){let I=g||l._playDeepDirty===!0,k=I||l._playDirty===!0,E=I||l._playChildDirty===!0;if(!k&&!E)return;if(!(m&&l.active!==!1)||l.visible===!1){s(l);return}let F=Ae(f,l),U=t.childCounts.get(l.Id)||0;if(E){U=0;let x=l.children;for(let v=0;v<x.length;v+=1)c(x[v],F,l.Id,v,!0,I),t.fingerprints.has(x[v].Id)&&(U+=1)}if(!(xn.has(l.kind)||U>0)){t.fingerprints.has(l.Id)&&(r.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),o-=1);return}let Z=t.childCounts.get(l.Id);t.childCounts.set(l.Id,U);let q=U>=16!=(Z||0)>=16;if(!k&&!q&&t.fingerprints.has(l.Id))return;let O=To(l,h,f===i?null:f,F,p,U),b=Po(O);t.fingerprints.get(O.id)!==b&&(t.fingerprints.has(O.id)||(o+=1),t.fingerprints.set(O.id,b),n.push(O))}for(let l=0;l<e.runtime.roots.length;l+=1)c(e.runtime.roots[l],i,null,l,!0,!1);return t.count=o,{changed:n,removed:r,count:o}}function yl(e,t){let i=e.viewCache||(e.viewCache={rev:0,fingerprints:new Map,childCounts:new Map,count:0}),n=Number(t);if(!(Number.isFinite(n)&&n===i.rev&&i.fingerprints.size>0)){let{nodes:c,childCounts:l}=ml(e);i.rev+=1,i.fingerprints=new Map(c.map(f=>[f.id,Po(f)])),i.childCounts=l,i.count=c.length;for(let f of e.runtime.roots)In(f);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:o,removed:a,count:s}=gl(e,i);i.rev+=1;for(let c of e.runtime.roots)In(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:s,changed:o,removed:a}}function En(e,{inspect:t=!1,view:i=!1,paint:n=!1,sceneRev:r,compact:o=!1}={}){let a=e.runtime,s=e.compiled,[c,l]=[a.canvasWidth,a.canvasHeight];e.server&&e.server.setClock(a.clock.time);let f=o?a.logs.slice(-100):a.logs,h=ul(e),p=e.server?e.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};o&&(p.inbound=p.inbound.slice(-100),p.outbound=p.outbound.slice(-100),p.logs=p.logs.slice(-100));let m={canvasId:s.canvasId,platform:s.platform,device:a.device,canvasWidth:c,canvasHeight:l,canvasPresets:nl,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(g,I)=>({index:I+1,label:`\u73A9\u5BB6${I+1}`,entityType:`Player${I+1}`})),time:a.clock.time,frame:a.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!a.clock.paused,mountError:e.mountError||a.mountErrors[0]||null,logs:f.map(g=>({source:"client",level:g.level,text:g.text,time:g.time})),tree:[],paint:[],scene:null,server:p,history:(o?h.slice(-100):h).map(g=>({t:g.t,source:g.source||"user",kind:g.kind,payload:g.payload||{}}))};if(t||n){let g=Cn(e);t&&(m.tree=a.roots.map(I=>Eo(I,g))),n&&(m.paint=dl(e,g))}return i&&(m.scene=yl(e,r)),mt(m),m}function ki(e,t=1/30){let i=e.runtimes||(e.runtime?[e.runtime]:[]);for(let n of i)n.step(t);e.server&&(e.server.setClock(e.runtime.clock.time),e.server.flush())}function An(e,t){Ue(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function bl(e,t){let i=null;for(let n of e.runtime.roots)we(n,r=>{!i&&r.name===t&&(i=r)});return i}function _n(e,t){Ue(e,{kind:"click",payload:{name:String(t)}});let i=bl(e,t);i&&Pn(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function vl(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var Ro={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function Mo(e,t){let i=[];for(let[n,r]of Object.entries(Ro)){let o=t[r]?vl(t,t[r]):null;o&&i.push({state:n,child:o})}return i}function Sl(e){for(let t of e.runtime.roots)we(t,i=>{if(i.kind==="button"){for(let{child:n}of Mo(e,i))e.stateRestores.has(n.Id)||e.stateRestores.set(n.Id,{child:n,active:n.active,visible:n.visible}),n.active=!0,n.visible=!1,typeof n.markPlayDirty=="function"&&n.markPlayDirty(!0);qt(e,i)}})}function qt(e,t){if(!t||t.kind!=="button")return;let i=null;t.interactable===!1?i="unavailable":t.pressed===!0?i="pressed":e.hoveredControl===t?i="hover":e.selectedControl===t&&(i="selected");for(let n of Mo(e,t))n.child.active=!0,n.child.visible=n.state===i,typeof n.child.markPlayDirty=="function"&&n.child.markPlayDirty(!0)}function Sn(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(Ro).map(n=>t[n]).filter(Boolean).includes(e.authoringId)?t:e}function Pn(e){return e.kind==="button"?e.raycastTarget!==!1&&e.interactable!==!1:e.kind==="cursor"||e.kind==="grid"?e.raycastTarget!==!1:e.kind==="textwindow"?e.interactable!==!1:e.raycastTarget===!0}function No(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function Oo(e,t){let i=e.Id,n=t.get(i);if(n!==void 0)return n;let r=Pn(e);if(!r&&No(e)){let o=e.children;for(let a=0;a<o.length;a+=1)if(Oo(o[a],t)){r=!0;break}}return t.set(i,r),r}function wn(e,t,i){let n=de({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=new Map;function o(s,c,l,f){if(!f||s.active===!1||s.visible===!1||!Oo(s,r))return null;let h=Ae(c,s),p=$t(l,h,s),m=ri(p);if(!m)return null;let g=Ke(m,t,i);if(g.x<h.left||g.x>h.right||g.y<h.bottom||g.y>h.top)return null;if(No(s))for(let I=0;I<s.children.length;I+=1){let k=o(s.children[I],h,p,!0);if(k)return k}return Pn(s)?s:null}let a=gt();for(let s=e.runtime.roots.length-1;s>=0;s-=1){let c=o(e.runtime.roots[s],n,a,!0);if(c)return c}return null}function Wt(e,t,i,{dragging:n=!1,press:r=null,previous:o=null}={}){let a=r||{x:t,y:i},s=o||{x:t,y:i};return e.runtime.makeCursorEventData({x:t,y:i,pressX:a.x,pressY:a.y,deltaX:t-s.x,deltaY:i-s.y,dragging:n})}function xo(e,t,i){t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),qt(e,t)}function jt(e,t,i,n,r={}){let o=Number(i),a=Number(n);if(!Number.isFinite(o)||!Number.isFinite(a))throw new Error("pointer coordinates must be finite");if(e.runtime.cursor.x=o,e.runtime.cursor.y=a,r.silent||Ue(e,{kind:"pointer",payload:{type:t,x:o,y:a}}),t==="move"){let s=e.pointerLastPosition||{x:o,y:a},c=e.pointerHoverControl,l=Sn(wn(e,o,a)),f=Wt(e,o,a,{previous:s});c&&c!==l&&e.runtime.injectCursor(c,"CursorExit",f),l&&c!==l&&e.runtime.injectCursor(l,"CursorEnter",f),e.pointerHoverControl=l;let h=e.hoveredControl;e.hoveredControl=l?.kind==="button"?l:null,h&&h!==e.hoveredControl&&qt(e,h),e.hoveredControl&&qt(e,e.hoveredControl);let p=e.pointerDownControl;if(p){let m=e.pointerDownPosition||s,g=o!==s.x||a!==s.y;!e.pointerDragging&&g&&(e.runtime.injectCursor(p,"CursorBeginDrag",Wt(e,o,a,{press:m,previous:s,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&e.runtime.injectCursor(p,"CursorDrag",Wt(e,o,a,{press:m,previous:s,dragging:!0}))}return e.pointerLastPosition={x:o,y:a},l}if(t==="down"){let s=Sn(wn(e,o,a));return e.pointerDownControl=s,e.pointerDownPosition={x:o,y:a},e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,s&&(xo(e,s,!0),e.runtime.injectCursor(s,"CursorDown",Wt(e,o,a))),s}if(t==="up"){let s=e.pointerDownControl,c=Sn(wn(e,o,a));if(s){let l=Wt(e,o,a,{press:e.pointerDownPosition,previous:e.pointerLastPosition,dragging:e.pointerDragging});if(e.runtime.injectCursor(s,"CursorUp",l),e.pointerDragging)e.runtime.injectCursor(s,"CursorEndDrag",l);else if(c===s){e.runtime.injectCursor(s,"CursorClick",l);let f=e.selectedControl;e.selectedControl=s.kind==="button"?s:null,f&&f!==e.selectedControl&&qt(e,f)}xo(e,s,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,c}if(t==="click")return jt(e,"down",o,a,{silent:!0}),jt(e,"up",o,a,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function Tn(e,t,i,n){if(!e?.server)throw new Error("play session has no server");return Ue(e,{kind:"serverSet",payload:{entityType:t,name:i,value:n,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,n,{playerIndex:e.viewPlayerIndex})}function Fo(e,t,i){if(!e?.server)throw new Error("play session has no server");let n=e.server.getVar(t,i,{playerIndex:e.viewPlayerIndex});return n===void 0?null:n}function Rn(e,t,i=[],n="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return Ue(e,{kind:"serverSend",payload:{name:t,params:i,target:n,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:n,playerIndex:e.viewPlayerIndex})}function xi(e){return{snapshot:t=>En(e,t),step:t=>ki(e,t),pointer:(t,i,n)=>jt(e,t,i,n),key:t=>An(e,t),click:t=>_n(e,t),view:t=>kn(e,t),pause:()=>{Ue(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{Ue(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,n)=>Tn(e,t,i,n),serverSend:(t,i,n)=>Rn(e,t,i,n)}}function Mn(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function Nn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function $o(e,t){for(let i of e||[])t(i),i.children?.length&&$o(i.children,t)}function On(e,{id:t,name:i}){let n=null;return $o(e,r=>{n||(t&&String(r.id)===String(t)||!t&&i&&r.name===i)&&(n=r)}),n}function wl(e,t){if(e){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(e.box&&Object.prototype.hasOwnProperty.call(e.box,t))return e.box[t]}}function Il(e){return{var(t,i){return e.server?.vars?.[t]?.[i]?.value??null},logs(){return(e.logs||[]).map(t=>t.text)},logContains(t){return(e.logs||[]).some(i=>String(i.text||"").includes(String(t)))},serverLogs(){return(e.server?.logs||e.serverLogs||[]).map(t=>t.text)},serverLogContains(t){return(e.server?.logs||e.serverLogs||[]).some(i=>String(i.text||"").includes(String(t)))},control(t){let i=On(e.tree,{name:String(t)});return i?{id:i.id,name:i.name,kind:i.kind,active:i.active,visible:i.visible,pressed:i.pressed,text:i.text,interactable:i.interactable}:null},signals(t){let i=t==="outbound"?"outbound":"inbound";return(e.server?.[i]||[]).map(n=>({name:n.name,values:n.values}))}}}function Cl(e,t){if(e.kind==="log"){let i=e.source==="server"?t.server?.logs||t.serverLogs||[]:t.logs||[];return i.some(r=>e.level&&r.level!==e.level?!1:String(r.text||"").includes(e.contains))?{ok:!0,actual:e.contains}:{ok:!1,actual:i.map(r=>r.text).slice(-8),expected:e.contains}}if(e.kind==="control"){let i=On(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let n=wl(i,e.field);return Nn(n,e.equals)?{ok:!0,actual:n}:{ok:!1,actual:n,expected:e.equals}}if(e.kind==="var"){let i=t.server?.vars?.[e.entityType],r=!i||!Object.prototype.hasOwnProperty.call(i,e.name)?null:i[e.name].value;return Nn(r,e.equals)?{ok:!0,actual:r}:{ok:!1,actual:r,expected:e.equals}}if(e.kind==="signal"){let i=e.direction==="outbound"?t.server?.outbound||[]:t.server?.inbound||[],n=i.find(r=>r.name===e.name&&(e.values===void 0||Nn(r.values,e.values)));return n?{ok:!0,actual:n.values}:{ok:!1,actual:i.map(r=>({name:r.name,values:r.values})),expected:{name:e.name,values:e.values??null}}}if(e.kind==="tree"){let i=!!On(t.tree,{name:e.name});return i===e.exists?{ok:!0,actual:i}:{ok:!1,actual:i,expected:e.exists}}return{ok:!1,message:`unsupported assert kind ${e.kind}`}}function kl(e,t){let i=Bt();try{return i.evalQueryScript(e,Il(t)),{ok:!0,actual:!0}}catch(n){return{ok:!1,message:n?.message||String(n)}}finally{i.destroy()}}function Do(e,t){return e.kind==="lua"?kl(e.source,t):Cl(e,t)}function xl(e,t){let i=t>0?t:nt;return Math.round((e+i)*1e9)/1e9}function El(e,t){let i=t.payload||{};if(t.kind==="pointer")e.pointer(i.type,i.x,i.y);else if(t.kind==="key")e.key(i.typeName);else if(t.kind==="click")e.click(i.name);else if(t.kind==="pause")e.pause();else if(t.kind==="resume")e.resume();else if(t.kind==="serverSet")e.serverSet(i.entityType,i.name,i.value);else if(t.kind==="serverSend")e.serverSend(i.name,i.params,i.target);else if(t.kind==="view")e.view(i.playerIndex);else throw new Error(`unsupported event kind: ${t.kind}`)}function Al(e,t){let i=Do(e,t);return{kind:e.kind,at:Number(e.at||0),ok:!!i.ok,actual:i.actual??null,expected:i.expected??null,message:i.message||""}}function zo(e,t){let i=Lt(t),n=i.events.slice().sort((E,$)=>E.t-$.t),r=i.asserts.slice(),o=i.dt||nt,a=n.reduce((E,$)=>Math.max(E,$.t),0),s=r.reduce((E,$)=>Math.max(E,Number($.at||0)),0),c=Math.max(a,s),l=0,f=[],h=0,p=r.some(E=>E.kind==="control"||E.kind==="tree"||E.kind==="lua"),m=e.snapshot({inspect:p}),g=()=>{for(;l<n.length&&n[l].t<=h+1e-9;)El(e,n[l]),l+=1,m=e.snapshot({inspect:p})},I=()=>{for(let E of r)if(!E._done&&Number(E.at||0)<=h+1e-9){let $=Al(E,m);if(f.push($),E._done=!0,!$.ok)return{passed:!1,failedAt:h,frame:m.frame||0,results:f,snapshot:m}}return null};g();let k=I();if(k)return Fn(i,k);for(;h+1e-9<c;){e.step(o),h=xl(h,o),m=e.snapshot({inspect:p}),g();let E=I();if(E)return Fn(i,E)}return Fn(i,{passed:f.every(E=>E.ok),failedAt:null,frame:m.frame||0,results:f,snapshot:m})}function Fn(e,t){return D({format:e.format,name:e.name,passed:t.passed,failedAt:t.failedAt,frame:t.frame,results:t.results,snapshot:{time:t.snapshot?.time??0,frame:t.snapshot?.frame??0,logs:t.snapshot?.logs||[],serverLogs:t.snapshot?.serverLogs||t.snapshot?.server?.logs||[],server:t.snapshot?.server||{vars:{},inbound:[],outbound:[],logs:[]}}})}function $n(e){return Array.isArray(e)?e.slice():[]}var Ml={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(it.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function Nl(e,t=1){let i=e?.vars||{},n=[],r=Number(t)>0?Number(t):1,o=["Level","PlayerSelf","AvatarSelf"];if(r>1)for(let s=1;s<=r;s+=1)o.push(`Player${s}`,`Avatar${s}`);let a=new Set;for(let s of o){if(a.has(s)||!i[s])continue;a.add(s);let c=i[s]||{};for(let l of Object.keys(c))n.push(D({entityType:s,entityLabel:Ml[s]||s,name:l,type:c[l]?.type||"",value:c[l]?.value??null}))}return n}var at="qxqy-simulator-save",Ol="qxqy-simulator-scripts",oe="server-control-template",V="client-control-template",Yo={[oe]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[V]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function ot(e){return e===V?"client":"server"}function Fl(e){let t=[e?.guid,e?.id];for(let i of t){let n=Number(i);if(Number.isSafeInteger(n)&&n>0&&n<=2147483647)return n}return 0}function Ei(e){let t=String(e?.controlAsset||""),i=Fl(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===V||t==="client"?V:t===oe||t==="server"?oe:""}}function Bo(e){let t=[],i=(n,r="")=>{if(n&&(n.path||n.source)){let o=Ei(n);t.push(r?{...o,controlAsset:r}:o)}};if(Array.isArray(e?.assets?.scripts)){for(let n of e.assets.scripts)n&&(n.path||n.source)&&t.push(Ei(n));return t}if(i(e?.assets?.server?.script,oe),i(e?.assets?.client?.script,V),e&&e.format!==at){i(e?.script);for(let n of e?.scripts||[])i(n)}return t}function Dn(e){return xe(e===V?Je():De())}var $l="\u672A\u7ED1\u5B9A",It="\u672A\u547D\u540D\u5B58\u6863",Dl="\u672A\u547D\u540D\u754C\u9762";function zl(e){let t=e;for(let i=0;i<8;i++){if(Jt(Go(t,"simulator","studio"))&&Jt(Go(t,"lua")))return t;let n=Tl(t);if(n===t)break;t=n}return e}function Gl(e){return e?{name:Ct(e),path:e,bound:!0}:{name:$l,path:"",bound:!1}}function Vl(e,t=process.cwd()){if(Rl(e)&&Jt(e))return e;let i=t||process.cwd(),n=zl(i),r=Vo(n,e);if(Jt(r))return r;let o=Vo(i,e);if(Jt(o))return o;throw new Error("script file not found: "+e)}function Uo(e,t={}){e?.format===at&&tn(e.version);let i=[],n=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",r=e?.format===at&&e.assets,o=r?null:xe(e,{warnings:i}),a={server:r&&e.assets.server?xe(e.assets.server,{warnings:i}):Dn(oe),client:r&&e.assets.client?xe(e.assets.client,{warnings:i}):Dn(V)};o&&(a[ot(o.meta.assetType)]=o);let s=r&&e.activeAssetType===V?V:o?.meta.assetType||oe,c=r&&e.meta?.name?String(e.meta.name):"",l=()=>c||It;!e?.meta?.name&&a.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(a.server.meta.name=Dl);let f=[],h=new Set;function p(){h.clear(),yt(a.server.root,h),yt(a.client.root,h,{skipServerContainer:!0});for(let d of f)ke(d.guid)&&h.add(Number(d.guid))}function m(d=0){p();let y=ke(d)&&!h.has(Number(d))?Number(d):Fe(h);return h.add(y),y}function g(d){let y=Ei(d),w=m(y.guid);return{...y,guid:w,id:String(w)}}for(let d of Bo(e))f.push(g(d));let I=wt(e?.serverLogic),k=null,E="",$=1,F=1;function U(d){let y=String(d||"").trim();if(!y)return"";if(!K[y])throw new Error(`unknown canvas preset: ${y} (available: ${Object.keys(K).join(", ")})`);return y}let W=()=>a[ot(s)];function Z(d){if(!d)return null;for(let[y,w]of[["server",a.server],["client",a.client]]){let T=le(w.root,d);if(T&&T.kind!=="server-container")return{key:y,node:T}}return null}function q(d){if(!d.controlId)return null;let y=d.controlAsset===V?"client":d.controlAsset===oe?"server":null;if(y){let w=le(a[y].root,d.controlId);return w&&w.kind!=="server-container"?{key:y,node:w}:null}return Z(d.controlId)}function O(){for(let d of f)d.controlId&&!q(d)&&(d.controlId="",d.controlAsset="")}function b(d){if(!ke(d))return null;for(let[y,w]of[[oe,a.server],[V,a.client]]){let T="";if(J(w.root,N=>{!T&&(N.scriptMappingIds||[]).includes(Number(d))&&(T=N.id)}),T)return{controlId:T,controlAsset:y}}return null}function x(d,y,w){let T=a[ot(d.controlAsset)],N=T&&le(T.root,d.controlId);N&&(N.scriptMappingIds=(N.scriptMappingIds||[]).map(R=>Number(R)===Number(y)?Number(w):R))}O();function v(){return f.map(d=>{let y=q(d),w=y?y.key==="client"?V:oe:"";return D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||w,controlName:y?.node.name||"",assetType:w,assetLabel:y?Yo[w]:"",mounted:!!y})})}function C(){let d=[],y=(w,T)=>{J(w.root,N=>{N.kind!=="server-container"&&d.push(D({id:N.id,name:N.name,kind:N.kind,assetType:T,assetLabel:Yo[T]}))})};return y(a.server,oe),y(a.client,V),d}function M(d){let y=[];return J(d.root,w=>{w.kind!=="server-container"&&y.push(JSON.stringify({kind:w.kind,name:w.name,text:w.text??null,imageId:w.imageId??null,fontSize:w.fontSize??null,fontColor:w.fontColor??null,bgColor:w.bgColor??null,imageColor:w.imageColor??null,fillType:w.fillType??null,fillAmount:w.fillAmount??null,syncAllDevices:w.syncAllDevices!==!1,transformByPlatform:w.transformByPlatform||null}))}),y.join("/")}let S=M(Je()),P=M(De());function z(d){let y=M(d);return d.meta?.assetType===V?y===S:y===P}function G(d,y){return String(d||"").replace(/[\\/:*?"<>|]/g,"-").trim()||y}function ie(d){let y=G(l(),It),w=d.meta?.assetType===V?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${y} \xB7 ${w}`}function j(){if(!((a.server.root.children||[]).find(y=>y.kind==="container")||a.server.root.children?.[0]))throw new Error("\u6574\u5408\u5305\u9700\u8981\u670D\u52A1\u7AEF\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668\u4E0B\u81F3\u5C11\u6709\u4E00\u4E2A\u6839\u63A7\u4EF6");return Rr(a.server,a.client,{scripts:f,fileName:`${G(l(),It)} \xB7 \u6574\u5408\u5305.gia`})}function ue(){let d=y=>({type:y.meta.assetType,name:y.meta.name,sourceFile:y.meta.sourceFile||""});return{format:at,name:l(),activeAssetType:s,assets:{server:d(a.server),client:d(a.client),scripts:v()}}}function Te(){return D({format:at,version:4,meta:{name:l()},activeAssetType:s,serverLogic:I,assets:{server:a.server,client:a.client,scripts:f.map(d=>D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||""}))}})}function ae(){let d=W(),y=Wr(d);return y.workspace=Gl(n),y.save=ue(),y.scripts=v(),y.mountTargets=C(),y.serverLogic=I,y.migrationWarnings=[...i],Qn(y),y}function lt(d){let y=W();if(d.expectedRevision!==void 0&&Number(d.expectedRevision)!==y.version)throw new Error(`revision conflict: expected ${d.expectedRevision}, current ${y.version}`);return y}function He(d,y,w=""){let T=String(y||"");if(T){let N=w===V?V:w===oe?oe:"";if(!q({controlId:T,controlAsset:N}))throw new Error("\u6302\u8F7D\u76EE\u6807\u5FC5\u987B\u662F\u5B58\u6863\u5185\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F");d.controlAsset=N}else d.controlAsset="";d.controlId=T}function _t(d){let y=lt(d);if(d.op==="addScript"){let w=g({path:String(d.path||""),source:String(d.source||""),controlId:"",controlAsset:""});d.controlId!==void 0&&d.controlId!==""&&He(w,d.controlId,d.controlAsset),f.push(w)}else if(d.op==="updateScript"){let w=f.find(T=>T.id===d.id);if(!w)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`);d.controlId!==void 0&&He(w,d.controlId,d.controlAsset),d.path!==void 0&&(w.path=String(d.path)),d.source!==void 0&&(w.source=String(d.source))}else if(d.op==="removeScript"){let w=f.length;if(f=f.filter(T=>T.id!==d.id),f.length===w)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`)}return y.version+=1,ae()}function ut(d){if(!d||typeof d!="object")throw new Error("patch requires op");if(d.op==="setServerLogic"){let y=lt(d);return I=wt(d.logic),y.version+=1,ae()}if(d.op==="addScript"||d.op==="updateScript"||d.op==="removeScript")return _t(d);if(d.op==="selectAsset")return s=d.assetType===V?V:oe,ae();if(d.op==="renameSave"){let y=String(d.name||"").trim();if(!y)throw new Error("\u5B58\u6863\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");return c=y,ae()}if(d.op==="newAsset"){let y=lt(d);s=d.assetType===V?V:oe;let w=Dn(s);return w.version=y.version+1,a[ot(s)]=w,O(),ae()}return on(W(),d),O(),ae()}function Pt(d){return f.filter(y=>{let w=q(y);return!!(w&&w.key==="client"==(d===V))})}function Tt(d="json",y=""){let w=String(d).toLowerCase();if(w==="save"||w==="archive"){let R=Buffer.from(JSON.stringify(Te(),null,2),"utf8");return D({filename:`${l().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:R.toString("base64"),warnings:[]})}if(w==="save-gia"||w==="archive-gia"){let R=[],H=[],Q=(ve,Me="")=>{let ee=Tt(ve,Me);R.push(D({filename:ee.filename,mimeType:ee.mimeType,encoding:ee.encoding,data:ee.data,warnings:ee.warnings||[]})),H.push(...ee.warnings||[])},ct=(ve,Me)=>{let ee=a[ot(ve)],Ne=ve===s,ft=f.some(ge=>ge.controlAsset===ve&&ge.controlId);if(!Ne&&z(ee)&&!ft){H.push(Me);return}Q("gia",ve)};if(ct(oe,"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u6A71\u7A97\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),ct(V,"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u300CLua\u5B9E\u4F8B\u5316\u9762\u677F\u300D\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),f.some(ve=>ve.path||ve.source)&&Q("scripts-gia"),!R.length)throw new Error("\u8D44\u4EA7\u5305 GIA \u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u5DF2\u6539\u52A8\u9879\uFF1B\u8BF7\u5148\u7F16\u8F91\u5F53\u524D\u754C\u9762\uFF0C\u6216\u6539\u7528\u300C\u5F53\u524D\u754C\u9762 GIA\u300D\u3002");return D({format:"qxqy-gia-package",files:R,warnings:[...new Set(H)]})}if(w==="gia-combined"||w==="combined-gia"||w==="combined"){let R=j();return D({filename:`${G(l(),It)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:R.buffer.toString("base64"),warnings:[...new Set(R.warnings||[])]})}if(w==="scripts"){let R=D({format:Ol,version:1,scripts:f.map(Q=>D({id:Q.id,guid:Q.guid||0,path:Q.path||"",source:Q.source||"",controlId:Q.controlId||"",controlAsset:Q.controlAsset||""}))}),H=Buffer.from(JSON.stringify(R,null,2),"utf8");return D({filename:`${G(l(),It)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:H.toString("base64"),warnings:[]})}if(w==="scripts-gia"||w==="scriptsgia"){let R=Fr(f);return D({filename:`${G(l(),It)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:R.buffer.toString("base64"),warnings:R.warnings})}if(w==="lua"){let R=f.find(Q=>Q.id===y)||f.find(Q=>Q.path===y);if(!R)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let H=Ct(R.path||"")||`qxqy-script-${R.id}`;return D({filename:/\.lua$/i.test(H)?H:`${H}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(R.source||"","utf8").toString("base64"),warnings:[]})}let T=y?a[ot(y)]:W(),N=ie(T);if(w==="json"){let R=D({...T,scripts:Pt(T.meta.assetType)}),H=Buffer.from(JSON.stringify(R,null,2),"utf8");return D({filename:`${N}.json`,mimeType:"application/json",encoding:"base64",data:H.toString("base64"),warnings:[]})}if(w==="gia"){let R=Tr(T,T.meta.assetType===V?{scripts:Pt(V)}:{});return D({filename:`${N}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:R.buffer.toString("base64"),warnings:R.warnings})}throw new Error(`unsupported export format: ${d}`)}function X(d){for(let y of d){let w=Ei(y);if(!w.path&&!w.source)continue;let T=w.controlId?null:b(w.guid),N=g(T?{...w,...T}:w);T&&N.guid!==w.guid&&x(T,w.guid,N.guid),N.controlId&&!q(N)&&(N.controlId="",N.controlAsset=""),f.push(N)}}function Ie(d,y,w=""){let T=String(d||"").toLowerCase();if(typeof y!="string"||!y)throw new Error("import data is required");let N=Buffer.from(y,"base64"),R,H=[],Q={};if(T==="json"){try{R=JSON.parse(N.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(R?.project&&(R=R.project),R?.format===at&&R?.assets){tn(R.version);let ee=xe(R.assets.server||De(),{warnings:H}),Ne=xe(R.assets.client||Je(),{warnings:H}),ft=wt(R.serverLogic);return a.server=ee,a.client=Ne,i=[...H],s=R.activeAssetType===V?V:oe,c=String(R.meta?.name||Ct(w).replace(/\.json$/i,"")||c),I=ft,f=[],h.clear(),X(Bo(R)),O(),D({snapshot:ae(),warnings:H,metadata:{format:at}})}}else{if(T==="lua")return f.push(g({path:Ct(w||"imported.lua"),source:N.toString("utf8"),controlId:""})),D({snapshot:ae(),warnings:H,metadata:{assetType:"lua-script"}});if(T==="gia"){if($r(N)){let ge=zr(N);return X(ge.scripts),D({snapshot:ae(),warnings:ge.warnings,metadata:ge.metadata})}let ee=Gr(N);R=ee.project,H=ee.warnings,Q=ee.metadata,ee.clientProject&&(a.client=xe(ee.clientProject),H.push("\u6574\u5408\u5305\u5DF2\u62C6\u56DE\u300CUI\u63A7\u4EF6-\u670D\u52A1\u7AEF\u300D\u4E0E\u300CUI\u63A7\u4EF6-\u5BA2\u6237\u7AEF\u300D\uFF1B\u5BA2\u6237\u7AEF\u6A21\u677F\u8FB9\u754C\u5DF2\u4FDD\u7559\u3002"));let Ne=new Map,ft=(ge,Da)=>{ge&&J(ge.root,qn=>{for(let $i of qn.scriptMappingIds||[]){let jn=Ne.get(Number($i));if(jn){H.push(`\u811A\u672C GUID ${$i} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${jn.controlAsset===oe?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}Ne.set(Number($i),{controlId:qn.id,controlAsset:Da})}})};ft(ee.project,oe),ft(ee.clientProject,V),X((ee.scripts||[]).map(ge=>Ne.has(Number(ge.guid))?{...ge,...Ne.get(Number(ge.guid))}:ge))}else throw new Error(`unsupported import format: ${d}`)}let ct=xe(R,{warnings:H});i=[...H];let ve=ot(ct.meta.assetType);a[ve]=ct,s=ct.meta.assetType;let Me=a[ve];return w&&(Me.meta.name=Ct(w).replace(/\.(json|gia)$/i,"")||Me.meta.name,Me.meta.sourceFile=Ct(w),Me.meta.sourceFormat=T),X(R?.scripts||[]),R?.script&&(R.script.path||R.script.source)&&X([R.script]),D({snapshot:ae(),warnings:H,metadata:Q})}function Xe(d,y){return on(W(),{op:"pick",x:d,y}),ae()}function ei(d){let y=typeof d=="string"&&d?d:"";!y||y===n||(n=y)}function Rt(d){let y=d.source||"";if(!y.trim()&&d.path.trim())try{y=Pl(Vl(d.path,n),"utf8")}catch(w){throw new Error(`\u811A\u672C ${d.path} \u8BFB\u53D6\u5931\u8D25: ${w?.message||w}`)}return y}function Re(d={}){let y=U(d.canvasId);y&&(E=y),d.playerCount!==void 0&&d.playerCount!==null&&d.playerCount!==""&&($=tt(d.playerCount),F>$&&(F=1)),d.viewPlayerIndex!==void 0&&d.viewPlayerIndex!==null&&d.viewPlayerIndex!==""&&(F=Pe(d.viewPlayerIndex,$)),k&&Mn(k);let w=f.map(N=>{try{return{id:N.id,guid:N.guid||0,path:N.path||N.id,source:Rt(N),controlId:N.controlId||"",controlAsset:N.controlAsset||""}}catch(R){return{id:N.id,guid:N.guid||0,path:N.path||N.id,source:`error([==[ ${String(R.message).replace(/]=+]/g,"] =]")} ])`,controlId:N.controlId||"",controlAsset:N.controlAsset||""}}}),T=N=>w.filter(R=>{let H={controlId:R.controlId,controlAsset:R.controlAsset},Q=R.controlId?q(H):null;return!!(Q&&Q.key===N)});return k=Ao(a.server,{templatesProject:a.client,scripts:w,sceneScripts:T("server"),templateScripts:T("client"),serverConfig:{logic:I},canvasId:E,playerCount:$,viewPlayerIndex:F}),se(d)}function Mt(d,y={}){let w=U(d);if(!w)throw new Error("playSetCanvas requires canvasId");return Re({...y,canvasId:w})}function se(d={}){if(!k)return D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let y=En(k,d);return y.running=!0,y.logs=$n(y.logs),y.serverLogs=$n(y.server?.logs||[]),y.serverVars=Nl(y.server,y.playerCount||1),y}function wa(d,y={}){return k||Re(),ki(k,d),y.observe===!1?D({running:!0,time:k.runtime.clock.time,frame:k.runtime.clock.frame,paused:!!k.debugPaused,levelTimePaused:!!k.runtime.clock.paused,playerCount:k.playerCount||1,viewPlayerIndex:k.viewPlayerIndex||1}):se(y)}function Ia(d=0){Re();let y=Math.max(0,Number(d)||0);for(let w=0;w<y;w++)ki(k,1/30);return se()}function Ca(){return k&&Mn(k),k=null,E="",$=1,F=1,D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function ka(d,y={}){let w=Nt();return F=kn(w,d),y.observe===!1?null:se(y)}function xa(d,y={}){if(!k)throw new Error("play session has not started");return An(k,d),y.observe===!1?null:se(y)}function Ea(d,y={}){if(!k)throw new Error("play session has not started");return _n(k,d),y.observe===!1?null:se(y)}function Aa(d,y,w,T={}){if(!k)throw new Error("play session has not started");return jt(k,d,y,w),T.observe===!1?null:se(T)}function _a(d={}){return k&&xi(k).pause(),d.observe===!1?null:se(d)}function Pa(d={}){return k&&xi(k).resume(),d.observe===!1?null:se(d)}function Nt(){if(!k)throw new Error("play session has not started");return k}function Ta(d,y){let w=Nt();if(!d&&!y){let T=se();return D({vars:T.serverVars||[]})}return D({entityType:String(d||""),name:String(y||""),value:Fo(w,d,y)})}function Ra(d,y,w){let T=Nt();return Tn(T,d,y,w),se()}function Ma(d,y=[],w="PlayerSelf"){let T=Nt();return Rn(T,d,y,w),se()}function Na(){let d=se();return D({events:d.history||[],case:Co(d.history||[],{playerCount:d.playerCount||1})})}function Oa(d={}){let y=se(),w=Lt({name:d.name||"",dt:d.dt,playerCount:d.playerCount||y.playerCount||1,events:d.events||y.history||[],asserts:d.asserts||[]});return D(w)}function Fa(d,y={}){let w=Lt(d);Re({...y,playerCount:y.playerCount||w.playerCount||1});let T=Nt();T.recording=!1;try{return zo(xi(T),d)}finally{T.recording=!0}}function $a(){if(!k)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let d=k.runtime.clock;return{running:!0,paused:!!k.debugPaused,levelTimePaused:!!d.paused,time:d.time,frame:d.frame,playerCount:k.playerCount||1,viewPlayerIndex:k.viewPlayerIndex||1}}let Wn={get:ae,patch:ut,setWorkspace:ei,exportData:Tt,importData:Ie,pick:Xe,playStart:Re,playSetCanvas:Mt,playSetView:ka,playGet:se,playStatus:$a,playStep:wa,playRun:Ia,playStop:Ca,playKey:xa,playClick:Ea,playPointer:Aa,playPause:_a,playResume:Pa,playServerGet:Ta,playServerSet:Ra,playServerSend:Ma,playHistory:Na,playSaveCase:Oa,playRunCase:Fa,archiveData:Te};return Object.defineProperty(Wn,"_project",{enumerable:!1,get:W}),Wn}import{createRequire as Yl}from"node:module";function Ho(e,t,i){if(e.fillType!=="Horizontal"&&e.fillType!=="Vertical")return null;let n=Number(e.fillAmount??1),r=Number.isFinite(n)?Math.max(0,Math.min(1,n)):1;if(e.fillType==="Horizontal"){let a=t*r;return{x:e.fillHorizontalType==="Right"?t/2-a:-t/2,y:-i/2,width:a,height:i}}let o=i*r;return{x:-t/2,y:e.fillVerticalType==="Top"?-i/2:i/2-o,width:t,height:o}}var Bl=Yl(import.meta.url),Ul=[0,-.5,.5,.5,-.5,.5],Hl=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],Xl=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],zn=Buffer.from([137,80,78,71,13,10,26,10]),Kl=new Set(["image","textbox","textwindow","button"]),Ai={cursor:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF",reference:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6",grid:"\u7F51\u683C\u89C6\u7A97",button:"\u9884\u8BBE\u6309\u94AE",keyhint:"\u6309\u952E\u63D0\u793A",animation:"\u754C\u9762\u52A8\u6548",fullscreen:"\u5168\u5C4F\u52A8\u6548"},_i=null;function Ko(){if(_i)return _i;try{_i=Bl("@napi-rs/canvas")}catch(e){let t=e?.message||String(e);throw new Error(`Host screenshot renderer requires @napi-rs/canvas (${t})`)}return _i}function Y(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ti(e,t=4294967295){let i=Number(e??t)>>>0;return{r:i>>>16&255,g:i>>>8&255,b:i&255,a:(i>>>24&255)/255}}function st(e,t=1){return`rgba(${e.r},${e.g},${e.b},${Math.max(0,Math.min(1,e.a*t))})`}function Lo(e,t,i=1){let n=Math.max(1,Math.round(Y(e,1))),r=Math.max(1,Math.round(Y(t,1))),o=Math.max(1,Math.min(2,Y(i,1)));return{width:n,height:r,pixelWidth:Math.max(1,Math.round(n*o)),pixelHeight:Math.max(1,Math.round(r*o)),pixelRatio:o}}function Wo(e){let t=Buffer.from(e.toBuffer("image/png"));if(t.length<zn.length||!t.subarray(0,zn.length).equals(zn))throw new Error("Host screenshot renderer did not produce a PNG");return t}function Ll(e){return e==="triangle"?Ul:e==="fourstar"?Hl:Xl}function Wl(e,t,i,n,r){let o=Ll(t);e.beginPath();for(let a=0;a<o.length;a+=2){let s=o[a]*i,c=o[a+1]*n;a===0?e.moveTo(s,c):e.lineTo(s,c)}e.closePath(),e.fillStyle=st(r),e.fill()}function ql(e,t,i){let n=t?.matrix,r=n&&typeof n=="object"?[n.a,n.b,n.c,n.d,n.tx,n.ty].map(Number):null,o=t?.pressed?.98:1;if(r&&r.every(Number.isFinite)){let[a,s,c,l,f,h]=r;e.transform(a*o,-s*o,-c*o,l*o,f,i-h);return}e.translate(Y(t.left)+Y(t.width)/2,i-Y(t.bottom)-Y(t.height)/2),e.rotate(-Y(t.rotationZ)*Math.PI/180),e.scale(o,o)}function jl(e,t,i,n,r,o){if(typeof e.roundRect=="function"){e.roundRect(t,i,n,r,o);return}let a=Math.max(0,Math.min(o,n/2,r/2));e.moveTo(t+a,i),e.arcTo(t+n,i,t+n,i+r,a),e.arcTo(t+n,i+r,t,i+r,a),e.arcTo(t,i+r,t,i,a),e.arcTo(t,i,t+n,i,a),e.closePath()}function qo(e,t,i,n){let r=Ti(t.bgColor,16777215);e.fillStyle=st(r),e.fillRect(-i/2,-n/2,i,n);let o=Math.max(8,Y(t.fontSize,12)),a=Ti(t.fontColor,4294967295),s=t.horizontalAlignment==="Right"?1:t.horizontalAlignment==="Middle"?.5:0,c=t.verticalAlignment==="Bottom"?1:t.verticalAlignment==="Middle"?.5:0;if(e.save(),e.beginPath(),e.rect(-i/2,-n/2,i,n),e.clip(),e.font=`${o}px "Microsoft YaHei UI","Microsoft YaHei",sans-serif`,e.fillStyle=st(a),e.textAlign=s===1?"right":s===.5?"center":"left",e.textBaseline=c===1?"bottom":c===.5?"middle":"top",t.enableOutline){let g=Ti(t.outlineColor,4278190080);e.strokeStyle=st(g),e.lineWidth=Math.max(2,o*.12),e.lineJoin="round"}let l=s===0?-i/2+2:s===1?i/2-2:0,f=c===0?-n/2:c===1?n/2:0,h=String(t.text||"").split(`
|
|
107
|
-
`),p=o*1.2,m=c===.5?f-(h.length-1)*p/2:c===1?f-(h.length-1)*p:f;for(let g=0;g<h.length;g+=1){let I=m+g*p;t.enableOutline&&e.strokeText(h[g],l,I),e.fillText(h[g],l,I)}e.restore()}function jo(e,t,i,n){e.beginPath(),jl(e,-i/2,-n/2,i,n,6),e.fillStyle="#3268cf",e.fill(),e.strokeStyle="rgba(112,160,255,0.8)",e.lineWidth=1,e.stroke(),t.pressed&&(e.fillStyle="rgba(0,0,0,0.28)",e.fill())}function Jo(e,t,i,n){let r=Ti(t.imageColor,4294967295);if(t.primitive==="missing"){e.fillStyle="rgba(72,34,40,0.36)",e.fillRect(-i/2,-n/2,i,n),e.strokeStyle="#ff7481",e.lineWidth=1,e.strokeRect(-i/2+.5,-n/2+.5,Math.max(0,i-1),Math.max(0,n-1));return}if(t.primitive==="circle"){e.beginPath(),e.ellipse(0,0,i/2,n/2,0,0,Math.PI*2),e.fillStyle=st(r),e.fill();return}if(t.primitive==="ring"){e.beginPath(),e.ellipse(0,0,Math.max(1,i/2-3.5),Math.max(1,n/2-3.5),0,0,Math.PI*2),e.strokeStyle=st(r),e.lineWidth=7,e.stroke();return}if(t.primitive==="triangle"||t.primitive==="fourstar"||t.primitive==="fivestar"){Wl(e,t.primitive,i,n,r);return}e.fillStyle=st(r),e.fillRect(-i/2,-n/2,i,n)}function Jl(e,t,i){let n=Math.max(0,Y(t.sourceWidth,Y(t.width))),r=Math.max(0,Y(t.sourceHeight,Y(t.height)));if(e.save(),ql(e,t,i),t.kind==="textbox"||t.kind==="textwindow")qo(e,t,n,r);else if(t.kind==="button")jo(e,t,n,r);else{let o=Ho(t,n,r);o&&(e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.clip()),Jo(e,t,n,r)}e.restore()}function Zo(e,t,i,{checker:n=!1}={}){if(n){e.fillStyle="#28313e",e.fillRect(0,0,t,i);let o=16;for(let a=0;a<i;a+=o)for(let s=0;s<t;s+=o)(s/o+a/o)%2===0&&(e.fillStyle="rgba(255,255,255,0.04)",e.fillRect(s,a,o,o));e.strokeStyle="#40b8cf",e.lineWidth=1,e.strokeRect(.5,.5,t-1,i-1);return}let r=e.createRadialGradient(t/2,i*.45,8,t/2,i/2,Math.max(t,i)*.72);r.addColorStop(0,"#123a6b"),r.addColorStop(.72,"#061934"),r.addColorStop(1,"#071426"),e.fillStyle=r,e.fillRect(0,0,t,i)}function Zl(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,tx:e.a*t.tx+e.c*t.ty+e.tx,ty:e.b*t.tx+e.d*t.ty+e.ty}}function Xo(e){let t=e?.matrix;return!t||typeof t!="object"?{a:1,b:0,c:0,d:1,tx:0,ty:0}:{a:Y(t.a,1),b:Y(t.b),c:Y(t.c),d:Y(t.d,1),tx:Y(t.tx),ty:Y(t.ty)}}function Ql(e){let t=Array.isArray(e?.nodes)?e.nodes:[],i=new Map;for(let a of t){if(!a||a.id===void 0||a.id===null)continue;let s=a.parent==null?"":String(a.parent),c=i.get(s);c?c.push(a):i.set(s,[a])}for(let a of i.values())a.sort((s,c)=>Y(s.z)-Y(c.z));let n=[];function r(a,s){if(!Kl.has(a.kind))return;let c=Math.abs(Y(a.sourceWidth)*Math.hypot(s.a,s.b)),l=Math.abs(Y(a.sourceHeight)*Math.hypot(s.c,s.d));n.push({...a,left:s.tx-c/2,bottom:s.ty-l/2,width:c,height:l,rotationZ:Math.atan2(s.b,s.a)*180/Math.PI,matrix:{a:s.a,b:s.b,c:s.c,d:s.d,tx:s.tx,ty:s.ty}})}function o(a,s){let c=i.get(a)||[];for(let l=c.length-1;l>=0;l-=1){let f=c[l],h=s?Zl(s,Xo(f)):Xo(f);r(f,h),o(String(f.id),h)}}return o("",null),n}function Qo(e,t,i,n={}){return eu(Ql(e),t,i,n)}function eu(e,t,i,n={}){let{createCanvas:r}=Ko(),o=Lo(t,i,n.scale),a=r(o.pixelWidth,o.pixelHeight),s=a.getContext("2d");s.scale(o.pixelRatio,o.pixelRatio),Zo(s,o.width,o.height);let c=Array.isArray(e)?e:[];for(let l of c)!l||l.id===void 0||l.id===null||Jl(s,l,o.height);return{data:Wo(a),width:o.width,height:o.height,pixelWidth:o.pixelWidth,pixelHeight:o.pixelHeight}}function tu(e){return{kind:e.kind,left:Y(e.renderLeft,e.left),bottom:Y(e.renderBottom,e.bottom),width:Math.max(0,Y(e.renderWidth,e.width)),height:Math.max(0,Y(e.renderHeight,e.height)),rotationZ:Y(e.renderRotationZ,e.rotationZ)}}function Pi(e,t,i){let n=String(t||"");if(!n)return;e.font='10px "Microsoft YaHei UI","Microsoft YaHei",sans-serif',e.textAlign="center",e.textBaseline="middle";let r=e.measureText(n),o=Math.min(i-4,Math.max(24,r.width+8)),a=16;e.fillStyle="rgba(17,25,37,0.66)",e.fillRect(-o/2,-a/2,o,a),e.fillStyle="#e7edf5",e.fillText(n,0,0)}function iu(e,t,i,n){let r=tu(t);if(r.width<=0||r.height<=0)return;e.save(),e.translate(r.left+r.width/2,i-r.bottom-r.height/2),e.rotate(-r.rotationZ*Math.PI/180);let o=-r.width/2,a=-r.height/2;if(t.kind==="image")Jo(e,t,r.width,r.height);else if(t.kind==="textbox"||t.kind==="textwindow")qo(e,t,r.width,r.height);else if(t.kind==="button")jo(e,t,r.width,r.height),Pi(e,t.name||Ai.button,r.width);else if(t.kind==="cursor")e.setLineDash([6,4]),e.strokeStyle="rgba(74,142,181,0.7)",e.fillStyle="rgba(74,142,181,0.1)",e.fillRect(o,a,r.width,r.height),e.strokeRect(o,a,r.width,r.height),Pi(e,t.name||Ai.cursor,r.width);else if(t.kind==="grid"){e.strokeStyle="rgba(106,146,189,0.55)",e.strokeRect(o,a,r.width,r.height),e.beginPath();for(let s=20;s<r.width;s+=20)e.moveTo(o+s,a),e.lineTo(o+s,a+r.height);for(let s=20;s<r.height;s+=20)e.moveTo(o,a+s),e.lineTo(o+r.width,a+s);e.stroke(),Pi(e,t.name||Ai.grid,r.width)}else t.kind!=="container"&&t.kind!=="server-container"?(e.setLineDash(t.kind==="reference"||t.kind==="animation"||t.kind==="fullscreen"?[4,4]:[]),e.strokeStyle="rgba(203,218,237,0.55)",e.strokeRect(o,a,r.width,r.height),Pi(e,t.name||Ai[t.kind]||t.kind,r.width)):(e.strokeStyle="rgba(78,165,230,0.42)",e.strokeRect(o,a,r.width,r.height));t.id===n&&t.kind!=="container"&&t.kind!=="server-container"&&(e.setLineDash([]),e.strokeStyle="#61b9ff",e.lineWidth=2,e.strokeRect(o,a,r.width,r.height)),e.restore()}function ea(e,t={}){let{createCanvas:i}=Ko(),n=e?.canvas||{},r=Lo(n.width||1600,n.height||900,t.scale),o=i(r.pixelWidth,r.pixelHeight),a=o.getContext("2d");a.scale(r.pixelRatio,r.pixelRatio),Zo(a,r.width,r.height,{checker:!0});let s=Array.isArray(e?.boxes)?e.boxes:[],c=e?.selectedId;for(let l of s)!l||l.kind==="server-container"||l.visible===!1||iu(a,l,r.height,c);return{data:Wo(o),page:e?.asset?.type==="client-control-template"?"UI\u63A7\u4EF6-\u5BA2\u6237\u7AEF":"UI \u7F16\u8F91",width:r.width,height:r.height,pixelWidth:r.pixelWidth,pixelHeight:r.pixelHeight}}import{closeSync as nu,existsSync as Ri,openSync as ru,readdirSync as ou,readSync as au,realpathSync as kt,statSync as na}from"node:fs";import{basename as su,dirname as ta,isAbsolute as Gn,join as lu,relative as ra,resolve as Qt}from"node:path";var uu="qxqy-simulator-save",cu=new Set(["node_modules",".git","dist",".dsh","coverage"]),ia=50,fu=8*1024*1024,du=8;function Vn(e=""){let t=Qt(String(e||process.cwd()));if(!Ri(t))throw new Error(`workspace does not exist: ${t}`);if(!na(t).isDirectory())throw new Error(`workspace is not a directory: ${t}`);return kt(t)}function Zt(e,t,i=!1){let n=ra(e,t);if(!i&&!n||n.startsWith("..")||Gn(n))throw new Error("path must stay inside the configured workspace");return n}function oa(e,t){let i=String(t||"").trim();if(!i||Gn(i))throw new Error("path must be a non-empty workspace-relative path");let n=kt(Qt(e)),r=Qt(n,i);if(Zt(n,r),!Ri(r))throw new Error(`file does not exist: ${i}`);let o=kt(r);return Zt(n,o),o}function aa(e,t){let i=String(t||"").trim();if(!i||Gn(i))throw new Error("path must be a non-empty workspace-relative path");let n=kt(Qt(e)),r=Qt(n,i);Zt(n,r);let o=ta(r);for(;!Ri(o);){let a=ta(o);if(a===o)throw new Error("unable to resolve output directory");o=a}return Zt(n,kt(o),!0),Ri(r)&&Zt(n,kt(r)),r}function hu(e,t=4096){let i=Buffer.alloc(t),n=ru(e,"r");try{let r=au(n,i,0,t,0);return i.subarray(0,r).toString("utf8")}finally{nu(n)}}function sa(e,t,i,n){if(i.length>=ia||n>du)return;let r;try{r=ou(e,{withFileTypes:!0})}catch{return}for(let o of r){if(i.length>=ia)return;if(o.name.startsWith(".")||cu.has(o.name))continue;let a=lu(e,o.name);if(o.isDirectory()){sa(a,t,i,n+1);continue}if(!(!o.isFile()||!/\.json$/i.test(o.name)))try{let s=na(a);if(s.size<20||s.size>fu)continue;let c=hu(a);if(!c.includes(uu))continue;let l=c.match(/"name"\s*:\s*"([^"]+)"/)?.[1]||su(o.name,".json");i.push({path:ra(t,a).replaceAll("\\","/"),name:l,bytes:s.size,mtime:s.mtimeMs})}catch{}}}function la(e){let t=Vn(e),i=[];return sa(t,t,i,0),i.sort((n,r)=>r.mtime-n.mtime),{bound:!0,workspace:t,archives:i}}var Su=Math.max(1e3,Number(process.env.QXQY_PLAY_TIMEOUT_MS)||8e3),wu=8e3;function ua(){let e=new Error("operation aborted");return e.name="AbortError",e}var Mi=class{constructor(t=""){this.workspacePath=t?Vn(t):"",this.studio=Uo(void 0,this.workspacePath?{workspacePath:this.workspacePath}:void 0),this.worker=null,this.pending=new Map,this.sequence=1,this.lock=Promise.resolve()}async exclusive(t){let i=this.lock,n;this.lock=new Promise(r=>{n=r}),await i;try{return await t()}finally{n()}}get(){return this.studio.get()}patch(t){return this.studio.patch(t)}listArchives(){return la(this.workspacePath)}loadArchive(t){let i=this.activeWorkspacePath();if(!i)throw new Error("workspace is not bound");let n=oa(i,t),r=gu(n);return this.studio.importData("json",r.toString("base64"),bu(n))}saveArchive(t="qxqy-simulator.save.json"){let i=String(t),n=this.activeWorkspacePath();if(!n)throw new Error("workspace is not bound");let r=aa(n,i);mu(vu(r),{recursive:!0});let o=Buffer.from(JSON.stringify(this.studio.archiveData(),null,2)+`
|
|
108
|
-
`,"utf8");return yu(r,o),{path:i.replaceAll("\\","/"),bytes:o.length,revision:this.studio.get().version,name:this.studio.get().save?.name||""}}activeWorkspacePath(){let t=this.studio.get().workspace;return t?.bound&&t.path?String(t.path):this.workspacePath}createWorker(){let t=new pu(new URL("./worker.js",import.meta.url),{type:"module"});return t.on("message",i=>{let n=this.pending.get(i?.id);n&&(this.pending.delete(i.id),i.ok?n.resolve(i.value):n.reject(new Error(i.error||"play worker failed")))}),t.on("error",i=>{this.worker===t&&(this.worker=null),this.rejectPending(i)}),t.on("exit",i=>{this.worker===t&&(this.worker=null),i!==0&&this.rejectPending(new Error(`play worker exited with code ${i}`))}),this.worker=t,t}rejectPending(t){for(let i of this.pending.values())i.reject(t);this.pending.clear()}async terminateWorker(t=new Error("play worker terminated")){let i=this.worker;this.worker=null,this.rejectPending(t),i&&await i.terminate().catch(()=>{})}request(t,i,n,r=Su){let o=this.worker||this.createWorker(),a=this.sequence++;return new Promise((s,c)=>{let l=!1,f=(m,g)=>{l||(l=!0,clearTimeout(p),n?.removeEventListener("abort",h),m(g))},h=()=>{this.pending.delete(a),f(c,ua()),this.terminateWorker(ua())},p=setTimeout(()=>{this.pending.delete(a);let m=new Error(`play worker timed out after ${r}ms`);f(c,m),this.terminateWorker(m)},r);if(this.pending.set(a,{resolve:m=>f(s,m),reject:m=>f(c,m)}),n?.aborted)return h();n?.addEventListener("abort",h,{once:!0}),o.postMessage({id:a,action:t,args:i})})}async play(t,i={},n){if(t==="start")return await this.terminateWorker(),this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i},n);if(t==="device"){let r=String(i.canvasId||"").trim();if(!K[r])throw new Error(`unknown canvas preset: ${r||"(empty)"} (available: ${Object.keys(K).join(", ")})`);return await this.terminateWorker(),this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i,canvasId:r},n)}if(t==="stop"){if(!this.worker)return{running:!1,tree:[],logs:[]};try{return await this.request("stop",i,n)}finally{await this.terminateWorker()}}if(!this.worker)throw new Error("play session has not started");return this.request(t,i,n)}async playScreenshot(t){if(!this.worker)throw new Error("play session has not started");let i=await this.request("get",{view:!0},t,wu),n=Qo(i.scene,i.canvasWidth,i.canvasHeight);return{data:n.data,canvasId:String(i.canvasId||""),frame:Number.isFinite(Number(i.frame))?Number(i.frame):0,time:Number.isFinite(Number(i.time))?Number(i.time):0,width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight}}uiScreenshot(){let t=ea(this.studio.get());return{data:t.data,page:t.page,width:t.width,height:t.height,pixelWidth:t.pixelWidth,pixelHeight:t.pixelHeight}}async dispose(){await this.terminateWorker()}};import{defineTool as xt}from"@deepseek-ai/dsh-tools";import{closeSync as Iu,existsSync as da,openSync as Cu,readdirSync as ku,readSync as xu,realpathSync as ca,statSync as Eu}from"node:fs";import{basename as Au,isAbsolute as Yn,join as _u,relative as Bn,resolve as Ni}from"node:path";var Pu="qxqy-simulator-save",Tu=new Set(["node_modules",".git","dist",".dsh","coverage"]),fa=50,Ru=8*1024*1024,Mu=8;function ha(e,t){if(!e)throw new Error("\u5DE5\u4F5C\u533A\u672A\u7ED1\u5B9A\uFF0C\u65E0\u6CD5\u4ECE\u78C1\u76D8\u62C9\u53D6\u5B58\u6863");let i=String(t||"").trim();if(!i)throw new Error("path is required");let n=ca(Ni(e)),r=Yn(i)?Ni(i):Ni(n,i),o=Bn(n,r);if(!o||o.startsWith("..")||Yn(o))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");if(!da(r))throw new Error(`\u5B58\u6863\u4E0D\u5B58\u5728: ${i}`);let a=ca(r),s=Bn(n,a);if(!s||s.startsWith("..")||Yn(s))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");return a}function Nu(e,t=4096){let i=Buffer.alloc(t),n=Cu(e,"r");try{let r=xu(n,i,0,t,0);return i.subarray(0,r).toString("utf8")}finally{Iu(n)}}function pa(e,t,i,n){if(i.length>=fa||n>Mu)return;let r;try{r=ku(e,{withFileTypes:!0})}catch{return}for(let o of r){if(i.length>=fa)return;if(o.name.startsWith(".")||Tu.has(o.name))continue;let a=_u(e,o.name);if(o.isDirectory()){pa(a,t,i,n+1);continue}if(!(!o.isFile()||!/\.json$/i.test(o.name)))try{let s=Eu(a);if(s.size<20||s.size>Ru)continue;let c=Nu(a);if(!c.includes(Pu))continue;let l=c.match(/"name"\s*:\s*"([^"]+)"/)?.[1]||Au(o.name,".json");i.push({path:Bn(t,a).replaceAll("\\","/"),name:l,bytes:s.size,mtime:s.mtimeMs})}catch{}}}function ma(e){if(!e)return{bound:!1,archives:[]};let t=Ni(e);if(!da(t))return{bound:!1,archives:[]};let i=[];return pa(t,t,i,0),i.sort((n,r)=>r.mtime-n.mtime),{bound:!0,workspace:t,archives:i}}var vd="qxqy-simulator",Sd=["tools","webServer"],ga="/qxqy-simulator/api",ya="/qxqy-simulator/play",Fu="/qxqy-simulator/play-renderer.js",$u=8*1024*1024,Du=32,ba=8e3,Xn=class extends Mi{constructor(t=""){super(t),this.touchedAt=Date.now()}touch(){this.touchedAt=Date.now()}get(){return this.touch(),super.get()}patch(t){return this.touch(),super.patch(Fi(t))}exportData(t,i){return this.touch(),this.studio.exportData(t,i)}importData(t,i,n){return this.touch(),this.studio.importData(t,i,n)}listArchives(){return this.touch(),ma(this.studio.get().workspace?.path||"")}loadArchive(t){this.touch();let i=this.studio.get().workspace?.path||"",n=ha(i,t),r=Ln(n);return this.studio.importData("json",r.toString("base64"),Ou(n))}async play(t,i={},n){return this.touch(),super.play(t,Fi(i)||{},n)}async requestScreenshot(t){return{...await super.playScreenshot(t),capturedAt:new Date().toISOString()}}requestUiScreenshot(){return this.touch(),{...super.uiScreenshot(),capturedAt:new Date().toISOString()}}async dispose(){await this.terminateWorker()}};function Sa(e){let t=String(e||"").trim();if(!t||t.length>256)throw new Error("sessionId is required");return t}function Fi(e){if(e!=null){if(typeof e!="string")return e;try{let t=JSON.parse(e);return t&&typeof t=="object"?t:void 0}catch{return}}}function Et(e){return Sa(e?.agent?.id)}function Kn(e){let t=e?.cwd;return typeof t=="string"&&t?t:""}function At(e){return Kn(e?.agent?.session?.header)}async function zu(e,t={}){let i=t.sessions?.get?.(e),n=Kn(i?.header);if(n)return n;let r=t.sessionPersistence?.inspect;if(typeof r!="function")return"";try{let o=await r.call(t.sessionPersistence,e);return Kn(o?.meta)}catch{return""}}function Gu(){let e=new Map;function t(){if(e.size<Du)return;let i=[...e.entries()].sort((n,r)=>n[1].touchedAt-r[1].touchedAt)[0];i&&(e.delete(i[0]),i[1].dispose())}return{get(i,n=""){let r=Sa(i),o=e.get(r);return o?n&&o.studio.setWorkspace(n):(t(),o=new Xn(n),e.set(r,o)),o.touch(),o},async dispose(){await Promise.all([...e.values()].map(i=>i.dispose())),e.clear()}}}function Oi(e,t,i){let n=JSON.stringify(i);e.statusCode=t,e.setHeader("content-type","application/json; charset=utf-8"),e.setHeader("cache-control","no-store"),e.end(n)}function Vu(){if(!Un){let t=[new URL("./play.html",import.meta.url),new URL("../lib/play.html",import.meta.url)].find(i=>va(i));if(!t)throw new Error("standalone play page is missing");Un=Ln(t,"utf8")}return Un}var Un=null;function Yu(){if(!Hn){let t=[new URL("../dist/play-renderer.js",import.meta.url),new URL("./play-renderer.js",import.meta.url)].find(i=>va(i));if(!t)throw new Error("standalone play renderer bundle is missing; run npm run build");Hn=Ln(t,"utf8")}return Hn}var Hn=null;function Bu(e){e.webServer.register({kind:"prefix",path:ya,handler(t,i){let n=new URL(t.url,"http://localhost").pathname.replace(/\/$/,"");if(t.method!=="GET"||n!==ya){i.statusCode=t.method==="GET"?404:405,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(t.method==="GET"?"not found":"GET required");return}i.statusCode=200,i.setHeader("content-type","text/html; charset=utf-8"),i.setHeader("cache-control","no-store"),i.setHeader("x-content-type-options","nosniff"),i.end(Vu())}})}function Uu(e){e.webServer.register({kind:"exact",path:Fu,handler(t,i){if(t.method!=="GET"){i.statusCode=405,i.setHeader("content-type","text/plain; charset=utf-8"),i.end("GET required");return}try{i.statusCode=200,i.setHeader("content-type","text/javascript; charset=utf-8"),i.setHeader("cache-control","no-store"),i.setHeader("x-content-type-options","nosniff"),i.end(Yu())}catch(n){i.statusCode=500,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(n?.message||String(n))}}})}function Hu(e){return new Promise((t,i)=>{let n=0,r=[];e.on("data",o=>{if(n+=o.length,n>$u){i(new Error("request body is too large")),e.destroy();return}r.push(o)}),e.on("end",()=>{try{let o=Buffer.concat(r).toString("utf8");t(o?JSON.parse(o):{})}catch{i(new Error("invalid JSON body"))}}),e.on("error",i)})}function Xu(e,t){e.tools.register(xt({name:"qxqy_studio_get",description:"\u8BFB\u53D6\u5F53\u524D DeepSeek Harness \u4F1A\u8BDD\u7684\u5343\u661F UI \u7F16\u8F91\u5668\u65E0\u635F JSON \u5FEB\u7167\u3002",parameters:{},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!0,async execute(i,n){return t.get(Et(n),At(n)).get()}})),e.tools.register(xt({name:"qxqy_studio_play_screenshot",description:"\u83B7\u53D6\u5F53\u524D\u8BD5\u73A9 Runtime \u753B\u9762\u7684 PNG\u3002Host \u4E0E\u72EC\u7ACB\u8BD5\u73A9\u9875\u5171\u7528 Runtime scene \u6811\uFF08\u540C\u7EA7\u5148\u51FA\u73B0\u7684\u5B50\u8282\u70B9\u5728\u4E0A\uFF09\u518D\u753B\u6210 PNG\uFF0C\u4E0D\u9700\u8981\u6253\u5F00\u8BD5\u73A9\u9875\u6216\u5207\u6362\u6807\u7B7E\u3002\u4EC5\u5728\u9700\u8981\u89C2\u5BDF\u8FD0\u884C\u65F6\u753B\u9762\u3001\u52A8\u753B\u6216\u4EA4\u4E92\u7ED3\u679C\u65F6\u8C03\u7528\uFF1B\u82E5\u8981\u770B\u7F16\u8F91\u5668\u821E\u53F0\uFF0C\u8BF7\u6539\u7528 qxqy_studio_ui_screenshot\u3002\u4E0D\u4F1A\u6B65\u8FDB\u65F6\u95F4\uFF0C\u4E5F\u4E0D\u66FF\u4EE3 get {inspect:true} \u7684\u7ED3\u6784\u5316\u65AD\u8A00\u3002",parameters:{},output:{schema:{type:"json"},render:(i,n)=>{let o=[{type:"text",text:`\u8BD5\u73A9\u622A\u56FE\uFF1A${n.canvasId||"unknown"}\uFF0CFrame ${n.frame??0}\uFF0C${n.width||0}\xD7${n.height||0}`}];return n.image&&o.push({type:"image",attachment:n.image}),o}},timeoutMs:ba+1e3,isConcurrencySafe:()=>!1,async execute(i,n){let o=await t.get(Et(n),At(n)).requestScreenshot(n.signal),a=e.get?.("attachments");if(!a?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let s=await a.saveImage({data:o.data,mediaType:"image/png",name:`qxqy-play-${o.canvasId||"canvas"}-f${o.frame}.png`}),{data:c,...l}=o;return{...l,image:{attachmentId:s.attachmentId,mediaType:s.mediaType,bytes:s.bytes,width:s.width,height:s.height,...s.name===void 0?{}:{name:s.name}}}}})),e.tools.register(xt({name:"qxqy_studio_ui_screenshot",description:"\u83B7\u53D6\u5F53\u524D\u7F16\u8F91\u5668\u821E\u53F0\u7684 PNG\u3002Host \u6839\u636E boxes \u5728\u8FDB\u7A0B\u5185\u6E32\u67D3\uFF0C\u4E0D\u9700\u8981\u6253\u5F00\u6216\u4FDD\u6301\u201C\u6A21\u62DF\u5668\u201D\u6807\u7B7E\u3002\u7528\u4E8E\u68C0\u67E5\u9759\u6001 UI \u5E03\u5C40\u3001\u9009\u4E2D\u9879\u548C\u63A7\u4EF6\u56FE\u5143\uFF1B\u4E0D\u542B\u5B8C\u6574 Chrome DOM \u5DE5\u5177\u680F/\u68C0\u89C6\u5668\u3002\u82E5\u8981\u770B Lua Runtime \u8BD5\u73A9\u753B\u9762\uFF0C\u8BF7\u6539\u7528 qxqy_studio_play_screenshot\u3002",parameters:{},output:{schema:{type:"json"},render:(i,n)=>{let a=[{type:"text",text:`\u7F16\u8F91\u5668\u622A\u56FE\uFF1A${n.page||"\u6A21\u62DF\u5668"}\uFF0C${n.width||0}\xD7${n.height||0}`}];return n.image&&a.push({type:"image",attachment:n.image}),a}},timeoutMs:ba+1e3,isConcurrencySafe:()=>!1,async execute(i,n){let o=t.get(Et(n),At(n)).requestUiScreenshot(),a=e.get?.("attachments");if(!a?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let s=await a.saveImage({data:o.data,mediaType:"image/png",name:`qxqy-ui-${o.page||"editor"}.png`}),{data:c,...l}=o;return{...l,image:{attachmentId:s.attachmentId,mediaType:s.mediaType,bytes:s.bytes,width:s.width,height:s.height,...s.name===void 0?{}:{name:s.name}}}}})),e.tools.register(xt({name:"qxqy_studio_patch",description:"\u4FEE\u6539\u5F53\u524D\u4F1A\u8BDD\u7684\u5343\u661F UI \u5DE5\u7A0B\u3002op \u5FC5\u987B\u643A\u5E26 expectedRevision \u4EE5\u9632\u6B62\u9648\u65E7\u5199\u5165\u3002",parameters:{op:{type:"json",required:!0,description:"\u7F16\u8F91\u5668 patch \u5BF9\u8C61\u3002"}},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!1,async execute(i,n){let r=Fi(i.op);if(!r)throw new Error("patch requires op");return t.get(Et(n),At(n)).patch(r)}})),e.tools.register(xt({name:"qxqy_studio_play",description:"\u63A7\u5236\u5F53\u524D\u4F1A\u8BDD\u7684\u5343\u661F UI \u8BD5\u73A9 Worker\uFF1A\u542F\u52A8\u3001\u6B65\u8FDB\u3001\u8F93\u5165\u3001\u6682\u505C\u3001\u505C\u6B62\u3001\u591A\u8BBE\u5907\u753B\u5E03\u5207\u6362\u3001\u591A\u4EBA\u89C6\u89D2\u3001\u670D\u52A1\u7AEF\u53D8\u91CF/\u4FE1\u53F7\uFF0C\u4EE5\u53CA\u5F55\u5236\u56DE\u653E\u7528\u4F8B\u3002",parameters:{action:{type:"string",enum:["start","device","view","get","step","pointer","key","click","pause","resume","stop","serverGet","serverSet","serverSend","history","saveCase","runCase"],required:!0},args:{type:"json",description:"\u52A8\u4F5C\u53C2\u6570\uFF1Bpointer \u4F7F\u7528 type/x/y\uFF0Cstep \u4F7F\u7528 dt\uFF1Bget/start \u53EF\u7528 inspect:true \u62C9\u8FD0\u884C\u6811\uFF1Bstart/device \u7528 canvasId \u5207\u6362\u8BBE\u5907\u753B\u5E03\uFF08\u5982 pc-16-9 / mobile-19.5-9\uFF09\uFF1Bstart \u53EF\u7528 playerCount(1-8)\uFF1Bview \u7528 playerIndex \u5207\u6362\u5F53\u524D\u73A9\u5BB6\u89C6\u89D2\uFF1BrunCase \u53EF\u5E26 canvasId/playerCount\uFF1BserverSet \u4F7F\u7528 entityType/name/value\uFF1BrunCase \u4F7F\u7528 case\u3002"}},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:1e4,isConcurrencySafe:()=>!1,async execute(i,n){let r=Fi(i.args)||{};return t.get(Et(n),At(n)).play(i.action,r,n.signal)}})),e.tools.register(xt({name:"qxqy_studio_load",description:"\u4ECE\u5F53\u524D\u4F1A\u8BDD\u5DE5\u4F5C\u533A\u62C9\u53D6\u5343\u661F\u6A21\u62DF\u5668\u5B58\u6863\u3002\u4E0D\u4F20 path \u65F6\u5217\u51FA\u5DE5\u4F5C\u533A\u5185\u7684 qxqy-simulator-save\uFF1B\u4F20\u5165\u76F8\u5BF9\u8DEF\u5F84\u5219\u52A0\u8F7D\u8BE5\u5B58\u6863\u3002",parameters:{path:{type:"string",description:"\u5DE5\u4F5C\u533A\u5185\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 workspace/flappy-fish/flappy-fish.save.json\u3002\u7701\u7565\u5219\u53EA\u5217\u51FA\u53EF\u62C9\u53D6\u5B58\u6863\u3002"}},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:8e3,isConcurrencySafe:()=>!1,async execute(i,n){let r=t.get(Et(n),At(n));return i.path?r.loadArchive(i.path):r.listArchives()}}))}function Ku(e,t){e.webServer.register({kind:"prefix",path:ga,async handler(i,n){if(i.method!=="POST"){Oi(n,405,{ok:!1,value:null,error:"POST required"});return}let o=new URL(i.url,"http://localhost").pathname.slice(ga.length).replace(/^\/+/,"");if(o==="health"){Oi(n,200,{ok:!0,value:{status:"ok"},error:null});return}let a=new AbortController;i.once("aborted",()=>a.abort());try{let s=await Hu(i),c=await zu(s.sessionId,{sessions:e.get?.("sessions"),sessionPersistence:e.get?.("sessionPersistence")}),l=t.get(s.sessionId,c),f;if(o==="get")f=l.get();else if(o==="patch")f=l.patch(s.op);else if(o==="export")f=l.exportData(s.format,s.assetType);else if(o==="import")f=l.importData(s.format,s.data,s.filename);else if(o==="archives")f=l.listArchives();else if(o==="load-archive")f=l.loadArchive(s.path);else if(o==="play")f=await l.play(s.action,s.args||{},a.signal);else throw new Error("unknown API action");Oi(n,200,{ok:!0,value:f,error:null})}catch(s){Oi(n,400,{ok:!1,value:null,error:s?.message||String(s)})}}})}function wd(e){let t=Gu();Xu(e,t),Ku(e,t),Bu(e),Uu(e),e.effect(()=>()=>{t.dispose()},"qxqy-simulator: dispose sessions")}export{Xn as SimulatorController,wd as apply,Kn as headerWorkspace,Sd as inject,Fi as jsonParam,zu as lookupSessionWorkspace,vd as name,At as sessionWorkspace};
|
|
106
|
+
`)}`);return{buffer:n,warnings:[...new Set(t.warnings)]}}function tn(e){return Se.toObject(Se.decode(fi(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function zr(e){try{let i=tn(e).graph||[];return i.length>0&&i.every(n=>Number(n.which)===vt)}catch{return!1}}function Vr(e){let t=(e.graph||[]).filter(r=>Number(r.which)===vt),i=[],n=t.map((r,a)=>{let o=r.script?.mapping||{},s=Number(r.id?.id)||0;s<=0&&i.push(`\u7B2C ${a+1} \u6761\u811A\u672C\u6620\u5C04\u7F3A\u5C11 GraphUnit.id.id\uFF0C\u5DF2\u6309 0 \u5904\u7406\uFF08\u5BFC\u51FA\u65F6\u4F1A\u91CD\u65B0\u5206\u914D\uFF09\u3002`);let c=Number(o.id)||0;return c&&c!==s&&i.push(`\u7B2C ${a+1} \u6761\u811A\u672C\u6620\u5C04 id(${c}) \u4E0E\u5355\u5143 id(${s}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:s,path:String(o.filePath||""),source:String(o.source||"")}});for(let[r,a]of n.entries())a.path&&!/\.lua$/iu.test(a.path)&&i.push(`\u7B2C ${r+1} \u6761\u811A\u672C\u6620\u5C04 file_path \u7F3A\u5C11 .lua \u540E\u7F00\uFF08${a.path}\uFF09\uFF0C\u771F\u673A\u53EF\u80FD\u62D2\u7EDD\u5BFC\u5165\uFF1B\u6A21\u62DF\u5668\u5185\u6309\u5F52\u4E00\u5316\u8DEF\u5F84\u7167\u5E38 require\u3002`);return{scripts:n,warnings:i}}function Yr(e){let t=tn(e),i=Vr(t);if(!i.scripts.length)throw new Error("GIA \u5185\u6CA1\u6709\u811A\u672C\u6620\u5C04\u5355\u5143\uFF08which=69\uFF09");return{scripts:i.scripts,warnings:i.warnings,metadata:{assetType:"lua-script"}}}function ds(e){let t=[],i;try{i=tn(e)}catch(r){return{valid:!1,errors:[r?.message||String(r)],scriptCount:0}}let n=i.graph||[];return n.length||t.push("Root.graph \u4E3A\u7A7A"),(i.accessories||[]).length&&t.push("script.gia \u4E0D\u5E94\u5305\u542B accessories"),n.forEach((r,a)=>{let o=`\u5355\u5143 ${a+1}`;Number(r.which)!==vt&&t.push(`${o}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${r.which}`),Number(r.id?.class)!==Or&&t.push(`${o}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${r.id?.class}`),Number(r.id?.type??0)!==0&&t.push(`${o}: id.type \u5E94\u7F3A\u7701`);let s=r.script?.mapping;if(!s){t.push(`${o}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(r.id?.id)<=0&&t.push(`${o}: GraphUnit.id.id \u975E\u6CD5`),Number(s.id)!==Number(r.id?.id)&&t.push(`${o}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(s.name||"")!==String(r.name||"")&&t.push(`${o}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(s.filePath||"").trim()?/\.lua$/iu.test(String(s.filePath))||t.push(`${o}: file_path \u5E94\u4EE5 .lua \u7ED3\u5C3E\uFF08\u5B98\u65B9 script.gia \u6837\u672C\u5747\u4E3A \u540D\u79F0.lua\uFF0C\u771F\u673A require \u65F6\u624D\u53BB\u6269\u5C55\u540D\uFF09`):t.push(`${o}: file_path \u4E3A\u7A7A`)}),{valid:t.length===0,errors:t,scriptCount:n.length}}function fi(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Ve+ji)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==Ir||t.readUInt32BE(12)!==3)throw new Error("\u4E0D\u662F\u53D7\u652F\u6301\u7684 GIA v1 \u6587\u4EF6");let i=t.readUInt32BE(16);if(i!==t.length-Ve-ji)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Ve+i)!==Cr)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(Ve,Ve+i)}function le(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function hs(e){let t=le(e,"transform")?.multiPlatform,i={};for(let r of t?.platforms||[]){let a=ts[r.platformType||0],o=r.transform||{};i[a]={scale:o.scale?{x:o.scale.x??0,y:o.scale.y??0,z:o.scale.z??0}:{x:1,y:1,z:1},rotation:{x:0,y:0,z:o.field508?.z??0},anchorMin:{x:o.anchorMin?.x??0,y:o.anchorMin?.y??0},anchorMax:{x:o.anchorMax?.x??0,y:o.anchorMax?.y??0},offset:{x:o.offset?.x??0,y:o.offset?.y??0},size:{x:o.size?.x??0,y:o.size?.y??0},pivot:o.pivot?{x:o.pivot.x??0,y:o.pivot.y??0}:{x:.5,y:.5}}}let n=i.KEYBOARD||i[Object.keys(i)[0]];if(!n)throw new Error(`GIA \u63A7\u4EF6 ${e.name||e.id?.id} \u7F3A\u5C11\u591A\u5E73\u53F0\u53D8\u6362`);for(let r of re)i[r]||(i[r]=structuredClone(n));return i}function ci(e){let t=e.ui?.content?.data||[];return t.some(i=>i.details?.textConfig)?t.some(i=>i.field501===71)?"textwindow":"textbox":t.some(i=>i.details?.cursorConfig)?"cursor":t.some(i=>Object.hasOwn(i.details||{},"templateRefSlot"))?"reference":t.some(i=>i.details?.gridView)?"grid":t.some(i=>i.details?.buttonPreset)?"button":t.some(i=>i.details?.keyHint)?"keyhint":t.some(i=>i.details?.image||i.details?.imageSlot)?"image":t.some(i=>Object.hasOwn(i.details||{},"effectSlot"))?"animation":t.some(i=>Object.hasOwn(i.details||{},"fullscreenEffectSlot"))?"fullscreen":(t.some(i=>Object.hasOwn(i.details||{},"containerNodeSlot")),"container")}function wr(e,{reverseSiblings:t=!1,idOffset:i=0}={}){if(!e.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let n=new Map(e.map((l,f)=>[l.id?.id,`n${i+f+1}`])),r=new Map,a=new Map,o=[];for(let l of e){let f=ci(l),h=le(l,"textConfig"),p=le(l,"imageSlot"),m=le(l,"image"),g=le(l,"buttonPreset"),I=le(l,"gridView"),k=le(l,"genericSlot"),E=le(l,"footerSlot"),$=le(l,"cursorConfig"),O=le(l,"keyHint"),Y=le(l,"containerNodeSlot"),W=le(l,"templateRefSlot"),Z=le(l,"effectSlot"),q=le(l,"fullscreenEffectSlot"),N=H(f,{id:n.get(l.id?.id),guid:l.id?.id||0,giaInfoIndex:(l.ui?.content?.info||[]).find(b=>b.field501===2&&b.field502===6)?.index?.value,giaRelatedGuids:(l.ui?.content?.info||[]).find(b=>b.field501===4&&b.field502===4)?.related?.value||[],name:l.name||f,visible:le(l,"field14")?.field17?.initiallyHidden!==!0,active:le(l,"field14")?.initiallyInactive!==!0,canControllerFocus:E?.field505===1,scriptMappingIds:(k?.field502||[]).map(b=>Number(b?.field1?.id)).filter(b=>Number.isSafeInteger(b)&&b>0),transformByPlatform:hs(l),syncAllDevices:le(l,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:k?.field501??0,footerField505:E?.field505??0,...f==="textbox"||f==="textwindow"?{textField501:h?.field501??20,textField503:h?.field503??12,textAlign:h?.align??0,...[void 0,0,1,2].includes(h?.verticalAlign)?{}:{textVerticalAlign:h.verticalAlign},...f==="textwindow"?{textField511:h?.field511??1,textViewField502:h?.viewFlags?.field502??1,textViewField503:h?.viewFlags?.field503??1}:{}}:{},...f==="cursor"?{cursorField501:$?.field501??0}:{},...f==="reference"?{templateRefSlot:W??""}:{},...f==="grid"?{gridField501:I?.field501??1,gridField507:I?.field507??1,gridField508:I?.field508??1,gridField509:I?.field509??1,gridField511:I?.field511??5,gridField512:I?.field512??1}:{},...f==="keyhint"?{keyHintField501:O?.field501??1,keyHintField502:O?.field502??1}:{},...f==="image"?{imageField502:m?.field502??1,imageField504:m?.field504??1,imageField505:m?.field505??1,imageField507:m?.field507??2,imageFillType:m?.fillType??1}:{},...f==="animation"?{effectSlot:Z??""}:{},...f==="fullscreen"?{fullscreenEffectSlot:q??""}:{}},...f==="container"?{isolateNavigation:Y?.isolateNavigation===!0,disableKeyEventPassthrough:Y?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:Y?.disableCursorEventPassthrough===!0,showCursor:Y?.showCursor===!0}:{},...f==="cursor"?{raycastTarget:$?.field501===1}:{},...f==="textbox"||f==="textwindow"?{text:h?.text?.value??"",fontSize:h?.fontSize??20,minimumFontSize:h?.minimumFontSize??20,adaptiveFontSize:h?.adaptive===1,fontColor:h?.color??4294967295,bgColor:h?.color2??0,enableOutline:h?.outlineOff!==1,outlineColor:h?.color3??858993459,horizontalAlignment:h?.align===1?"Middle":h?.align===2?"Right":"Left",verticalAlignment:{0:"Top",1:"Middle",2:"Bottom"}[h?.verticalAlign??0]||"Top",...f==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...f==="image"?{imageSource:"StaticReference",imageId:p?.assetId??0,imageColor:Number.isFinite(p?.field502)?p.field502>>>0:4294967295,enableMask:m?.enableMask===1,enableSoftEdge:m?.enableSoftEdge===1,enableFill:m?.enableFill===1,softEdgeMode:m?.softEdgePixel===1?"Pixel":"Percentage",softEdgeWidthX:m?.border?.field501??8,softEdgeWidthY:m?.border?.field502??8,horizontalSoftRange:m?.field512??85,verticalSoftRange:m?.field513??85,fillType:{1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[m?.fillType]||"Horizontal",fillAmount:Number.isFinite(m?.field508)?Math.max(0,Math.min(1,m.field508/100)):m?.enableFill===1?0:1,reverseMaskArea:m?.reverseMask===1}:{},...f==="button"?{interactable:g?.interactable===1,raycastTarget:g?.raycastTarget===1,clickAudioId:g?.clickAudioId??50888}:{},...f==="grid"?{cellSizeX:I?.cellSize?.field501??50,cellSizeY:I?.cellSize?.field502??50,spacingX:I?.gap?.field501??8,spacingY:I?.gap?.field502??8,padding1X:I?.padding1?.field501??20,padding1Y:I?.padding1?.field502??20,padding2X:I?.padding2?.field501??20,padding2Y:I?.padding2?.field502??20,previewCount:I?.field511??5}:{},...f==="reference"?{referencedPrefabId:W??""}:{},...f==="keyhint"?{keyboardKeyCode:O?.field502??null,controllerKeyCode:O?.field501??null}:{},...f==="animation"?{animationId:Z??""}:{},...f==="fullscreen"?{animationId:q??""}:{}});r.set(l.id?.id,N),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(h?.align)&&o.push(`${N.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${h.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(h?.verticalAlign)&&o.push(`${N.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${h.verticalAlign} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),f==="image"&&![void 0,0,1,2,3,4,5].includes(m?.fillType)&&o.push(`${N.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${m.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),f==="button"&&a.set(N.id,{unavailableChildId:g?.disabledChild,hoverChildId:g?.hoverChild,pressedChildId:g?.pressedChild,selectedChildId:g?.selectedChild})}let s=[],c=new Set;for(let l of e){let f=r.get(l.id?.id),h=(l.ui?.content?.children||[]).map(p=>r.get(p)).filter(Boolean);if(h.length){f.children=t?h.slice().reverse():h;for(let p of h)c.add(p.id)}}for(let l of e){let f=r.get(l.id?.id),h=l.ui?.content?.parent||0,p=r.get(h);p?c.has(f.id)||(t?p.children.unshift(f):p.children.push(f)):s.push(f)}for(let[l,f]of a){let h=[...r.values()].find(p=>p.id===l);for(let[p,m]of Object.entries(f))h[p]=n.get(m)||null}return{nodes:r,rootCandidates:s,warnings:o}}function Br(e){let t=fi(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[];if(!n.some(g=>g.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let r=n.find(g=>g.which===21)||null,a=n.filter(g=>Number(g.which)===70),o=i.accessories||[],s=new Set((r?.relatedIds||[]).map(g=>g.id||0)),c=r?s.size?o.filter(g=>s.has(g.id?.id||0)):o:[],l=a.length?[...a,...o.filter(g=>!s.has(g.id?.id||0))]:r?[]:[...n,...o];if(!c.length&&!l.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let f=["GIA \u5BFC\u5165\u4E3A\u5DF2\u9A8C\u8BC1 UI \u5B57\u6BB5\u7684\u8BED\u4E49\u5BFC\u5165\uFF1B\u672A\u77E5 protobuf \u5B57\u6BB5\u4E0D\u4F1A\u8FDB\u5165 Authoring JSON\u3002"],h=Vr(i);f.push(...h.warnings);let p=null,m=null;if(c.length){let g=wr(c,{reverseSiblings:!0,idOffset:0});f.push(...g.warnings);let I=g.rootCandidates.find(E=>E.kind==="container")||g.rootCandidates[0];if(!I)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let k=H("server-container",{id:"sc1",guid:r?.id?.id||0,name:r?.name||"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",giaRelatedGuids:(r?.ui?.content?.info||[]).find(E=>E.field501===4&&E.field502===4)?.related?.value||[]});k.children=[I],g.rootCandidates.length>1&&f.push(`\u68C0\u6D4B\u5230 ${g.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${I.name}\u201D\u4E3A\u6839\u7684\u6811\u3002`),p={version:1,layoutSchemaVersion:fe,meta:{name:r?.name||"\u5BFC\u5165\u7684\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:I.id,script:{controlId:I.id,path:"",source:""},root:k}}if(l.length){let g=wr(l,{reverseSiblings:!1,idOffset:1e3});if(f.push(...g.warnings),!g.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let I=H("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});I.children=g.rootCandidates,m={version:1,layoutSchemaVersion:fe,meta:{name:g.rootCandidates.length===1?g.rootCandidates[0].name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868",assetType:"client-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:g.rootCandidates[0].id,script:{controlId:g.rootCandidates[0].id,path:"",source:""},root:I},p||(p=m)}return{project:p,clientProject:m&&p!==m?m:void 0,scripts:h.scripts,warnings:f,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(r&&a.length)}}}function Ur(e){let t=fi(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[],r=i.accessories||[],a=[],o=(p,m)=>p!=null&&Object.prototype.hasOwnProperty.call(p,m),s=new Map,c=[];/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||a.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`);let l=n.filter(p=>p.which===70).map(p=>{let m=ci(p),g=p.ui?.content?.info||[],I=g.find(O=>O.field501===2&&O.field502===6)?.index?.value,k=kr[m],E=g.find(O=>O.field501===4&&O.field502===4),$=E?.related?.value||[];return(!Number.isSafeInteger(I)||I<=0)&&a.push(`${p.name}: Info.index=${I??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),E||a.push(`${p.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:p.id?.id||0,name:p.name||"",kind:m,actualIndex:I,expectedIndex:k,relatedPresent:!!E,relatedGuids:$}});l.length||a.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let f=0,h=0;for(let p of[...n,...r]){if(!p.ui?.content)continue;let m=p.id?.id||0,g=p.ui.content,I=ci(p),k=n.includes(p)&&p.which===70,E=`${p.name||"<unnamed>"}(${m||"<missing-guid>"})`;!Number.isSafeInteger(m)||m<=0||m>2147483647?a.push(`${E}: GraphUnit GUID \u975E\u6CD5`):s.has(m)?a.push(`${E}: GUID \u4E0E ${s.get(m).name||"<unnamed>"} \u91CD\u590D`):s.set(m,p),(p.id?.class!==1||p.id?.type!==8)&&a.push(`${E}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),g.guid!==m&&a.push(`${E}: content.guid=${g.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),k&&p.which!==70&&a.push(`${E}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!k&&p.which!==15&&a.push(`${E}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let $=g.info||[],O=$.find(S=>S.field501===1&&S.field502===5),Y=$.find(S=>S.field501===2&&S.field502===6);O?.guid?.value!==m&&a.push(`${E}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),(!Number.isSafeInteger(Y?.index?.value)||Y.index.value<=0)&&a.push(`${E}: Info.index=${Y?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let W=$.find(S=>S.field501===4&&S.field502===4);k&&!W&&a.push(`${E}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!k&&W&&a.push(`${E}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let Z=Er[I],q=g.data||[],N=q.map(S=>`${S.field501}/${S.field502}`),b=Z?.map(([S])=>S)||[];Z?JSON.stringify(N)!==JSON.stringify(b)&&a.push(`${E}: Data \u69FD\u4F4D\u987A\u5E8F ${N.join(",")}\uFF0C\u5E94\u4E3A ${b.join(",")}`):a.push(`${E}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${I}`);for(let S=0;S<Math.min(q.length,Z?.length||0);S+=1){let P=q[S],[G,z,ne]=Z[S];if(o(P,z)||a.push(`${E}: Data ${G} \u7F3A\u5C11 ${z} \u5206\u652F`),!ne)continue;o(P.details,ne)||a.push(`${E}: Details ${G} \u7F3A\u5C11 ${ne} \u5206\u652F`);let j=Ar[G];(P.details?.field501!==j||P.details?.field502!==P.field502||P.details?.field503!==1)&&a.push(`${E}: Details ${G} \u6807\u8BB0\u5E94\u4E3A ${j}/${P.field502}/1`);let ce=P.details?.nodeRef;(ce?.class!==1||ce?.type!==8||ce?.id!==m)&&a.push(`${E}: Details ${G} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let x=(p.ui.content.data||[]).find(S=>S.field501===4&&S.field502===86);x&&(o(x.field14,"field17")?f+=1:a.push(`${E}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),o(x.details?.field14,"field17")?f+=1:a.push(`${E}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let v=(p.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];v.length!==4&&a.push(`${E}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${v.length}\uFF0C\u5E94\u4E3A 4`);let C=v.map(S=>S.platformType||0);JSON.stringify(C)!==JSON.stringify([0,1,2,3])&&a.push(`${E}: \u5E73\u53F0\u987A\u5E8F ${C.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let M=(p.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform;M?.multiPlatform?.field502!==Gt[I]&&a.push(`${E}: \u53D8\u6362 preset=${M?.multiPlatform?.field502??"<missing>"}\uFF0C${I} \u5E94\u4E3A ${Gt[I]}`);for(let S of v)o(S.transform,"field508")?h+=1:a.push(`${E}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);c.push({id:m,name:p.name||"",kind:I,template:k,parent:g.parent||0,children:[...g.children||[]],relatedIds:(p.relatedIds||[]).map(S=>S.id||0),dataSignatures:N})}for(let p of c){let m=`${p.name||"<unnamed>"}(${p.id})`;if(JSON.stringify(p.relatedIds)!==JSON.stringify(p.children)&&a.push(`${m}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),p.template&&p.parent&&a.push(`${m}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!p.template){let g=s.get(p.parent);g?(g.ui?.content?.children||[]).includes(p.id)||a.push(`${m}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):a.push(`${m}: parent=${p.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let g of p.children){let I=s.get(g);I?(I.ui?.content?.parent||0)!==p.id&&a.push(`${m}: child=${g} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):a.push(`${m}: child=${g} \u4E0D\u5B58\u5728`)}}return{valid:a.length===0,errors:a,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:l.length,accessoryCount:r.length,templates:l,units:c,explicitEmpty:{field17:f,rectField508:h}}}function nn(e){let t=fi(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=(i.graph||[]).filter(S=>S.ui?.content&&Number(S.which)===21),r=(i.graph||[]).filter(S=>Number(S.which)===70),a=(i.graph||[]).filter(S=>Number(S.which)===vt),o=(i.accessories||[]).filter(S=>S.ui?.content),s=[],c=(S,P)=>S!=null&&Object.prototype.hasOwnProperty.call(S,P);/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||s.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`),n.length!==1&&s.push(`\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F UIControlGroup \u6570\u91CF=${n.length}\uFF0C\u5E94\u4E3A 1`);let l=(i.graph||[]).filter(S=>{let P=Number(S.which);return P===vt||P===70||P===21?!1:!S.ui?.content});l.length&&s.push(`Root.graph \u542B ${l.length} \u4E2A\u65E0\u6CD5\u8BC6\u522B\u7684\u975E\u63A7\u4EF6/\u975E\u811A\u672C\u5355\u5143`);let f=n[0];if(!f)return{valid:!1,errors:s,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:o.length,controls:[],scriptCount:a.length,explicitEmpty:{field17:0,rectField508:0}};let h=[f,...o],p=new Map;for(let S of h){let P=S.id?.id||0,G=`${S.name||"<unnamed>"}(${P||"<missing-guid>"})`;!Number.isSafeInteger(P)||P<=0||P>2147483647?s.push(`${G}: GraphUnit GUID \u975E\u6CD5`):p.has(P)?s.push(`${G}: GUID \u91CD\u590D`):p.set(P,S),(S.id?.class!==1||S.id?.type!==8)&&s.push(`${G}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),S.ui?.content?.guid!==P&&s.push(`${G}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let m=f.id?.id||0,g=f.ui.content,I=`${f.name||"<unnamed>"}(${m})`;f.which!==21&&s.push(`${I}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let k=g.info||[];k.find(S=>S.field501===1&&S.field502===5)?.guid?.value!==m&&s.push(`${I}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),k.find(S=>S.field501===2&&S.field502===6)?.index?.value!==1&&s.push(`${I}: Info.index \u5FC5\u987B\u4E3A 1`);let E=k.find(S=>S.field501===4&&S.field502===4);E||s.push(`${I}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let $=0,O=0,Y=(S,P,G,z=!1)=>{let ne=S.id?.id||0,j=`${S.name||"<unnamed>"}(${ne})`,ce=S.ui.content.data||[],Re=ce.map(L=>`${L.field501}/${L.field502}`),oe=G.map(([L])=>L);JSON.stringify(Re)!==JSON.stringify(oe)&&s.push(`${j}: Data \u69FD\u4F4D\u987A\u5E8F ${Re.join(",")}\uFF0C\u5E94\u4E3A ${oe.join(",")}`);for(let L=0;L<Math.min(ce.length,G.length);L+=1){let we=ce[L],[Le,ti,Tt]=G[L];if(c(we,ti)||s.push(`${j}: Data ${Le} \u7F3A\u5C11 ${ti} \u5206\u652F`),!Tt)continue;c(we.details,Tt)||s.push(`${j}: Details ${Le} \u7F3A\u5C11 ${Tt} \u5206\u652F`);let Te=Ar[Le];(we.details?.field501!==Te||we.details?.field502!==we.field502||we.details?.field503!==1)&&s.push(`${j}: Details ${Le} \u6807\u8BB0\u5E94\u4E3A ${Te}/${we.field502}/1`);let Mt=we.details?.nodeRef;(Mt?.class!==1||Mt?.type!==8||Mt?.id!==ne)&&s.push(`${j}: Details ${Le} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let lt=ce.find(L=>L.field501===4&&L.field502===(z?23:86)),He=z?"empty15":"field17";c(lt?.field14,He)?z||($+=1):s.push(`${j}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${He} \u7A7A\u4E32`),c(lt?.details?.field14,He)?z||($+=1):s.push(`${j}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${He} \u7A7A\u4E32`);let Pt=ce.find(L=>L.details?.transform)?.details?.transform,ut=Pt?.multiPlatform?.platforms||[];ut.length!==4&&s.push(`${j}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${ut.length}\uFF0C\u5E94\u4E3A 4`);let ct=ut.map(L=>L.platformType||0);JSON.stringify(ct)!==JSON.stringify([0,1,2,3])&&s.push(`${j}: \u5E73\u53F0\u987A\u5E8F ${ct.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let Rt=z?Gt["server-container"]:Gt[P];Pt?.multiPlatform?.field502!==Rt&&s.push(`${j}: \u53D8\u6362 preset=${Pt?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${Rt}`);for(let L of ut)c(L.transform,"field508")?O+=1:s.push(`${j}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return Re};Y(f,"server-container",is,!0);let W=(f.relatedIds||[]).map(S=>S.id||0),Z=new Set(W),q=o.filter(S=>Z.has(S.id?.id||0)),N=q.map(S=>S.id?.id||0);JSON.stringify(W)!==JSON.stringify(N)&&s.push(`${I}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let b=g.data?.find(S=>S.details?.rootChildRef)?.details?.rootChildRef?.guid||0,x=p.get(b);(!x||!q.includes(x))&&s.push(`${I}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),N[0]!==b&&s.push(`${I}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let v=[];for(let S of q){let P=S.id?.id||0,G=S.ui.content,z=`${S.name||"<unnamed>"}(${P})`,ne=ci(S);S.which!==15&&s.push(`${z}: which \u5FC5\u987B\u4E3A UIControl(15)`);let j=G.info||[];(j.length!==1||j[0]?.field501!==1||j[0]?.field502!==5||j[0]?.guid?.value!==P)&&s.push(`${z}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let ce=Er[ne];ce||s.push(`${z}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${ne}`);let Re=ce?Y(S,ne,ce):[];v.push({id:P,name:S.name||"",kind:ne,parent:G.parent||0,children:[...G.children||[]],relatedIds:(S.relatedIds||[]).map(oe=>oe.id||0),dataSignatures:Re})}let C=v.find(S=>S.id===b);C&&(C.kind!=="container"&&s.push(`${C.name}(${b}): \u6839\u63A7\u4EF6\u5FC5\u987B\u4E3A\u5BB9\u5668\u8282\u70B9`),C.parent&&s.push(`${C.name}(${b}): \u6839\u63A7\u4EF6\u4E0D\u5E94\u6709 parent`));let M=new Map(v.map(S=>[S.id,S]));for(let S of v){let P=`${S.name}(${S.id})`;if(JSON.stringify(S.relatedIds)!==JSON.stringify(S.children)&&s.push(`${P}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),S.id!==b){let G=M.get(S.parent);G?G.children.includes(S.id)||s.push(`${P}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):s.push(`${P}: parent=${S.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let G of S.children){let z=M.get(G);z?z.parent!==S.id&&s.push(`${P}: child=${G} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):s.push(`${P}: child=${G} \u4E0D\u5B58\u5728`)}}return{valid:s.length===0,errors:s,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:m,name:f.name||"",relatedGuids:E?.related?.value||[],rootGuid:b},accessoryCount:o.length,controls:v,scriptCount:a.length,explicitEmpty:{field17:$,rectField508:O}}}function Hr(e,t=[]){if(!e||e.layoutSchemaVersion===fe)return e;if(e.layoutSchemaVersion!==void 0&&e.layoutSchemaVersion!==1)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=2 \u6216\u53EF\u8FC1\u79FB\u7684\u65E7\u5E03\u5C40\uFF0C\u6536\u5230 ${e.layoutSchemaVersion}`);if(!e.root)return{...e,layoutSchemaVersion:fe};let i=structuredClone(e),n=0;return J(i.root,r=>{let a=r.transformByPlatform||{},o=r.transformByCanvas||{},s=r.name||r.id;for(let l of Object.keys(a))if(!re.includes(l))throw new Error(`${s}: unknown platform ${l}`);let c={};for(let l of re){let f=ht[l],h=X[f].platform,p=Object.keys(X).filter(k=>X[k].platform===h&&o[k]),m=o[f]?f:p[0],g=l==="CONTROLLER_CONSOLE"?c.KEYBOARD:l==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,I=a[l]??g??(m?o[m]:null);if(c[l]=I?Ie(I):Li(r.kind),I||t.push(`${s}: ${l} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!a[l]&&!g&&m&&m!==f&&t.push(`${s}: \u7F3A\u5C11 ${f}\uFF0C\u5DF2\u91C7\u7528 ${m} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!g)for(let k of p)JSON.stringify(c[l])!==JSON.stringify(Ie(o[k]))&&t.push(`${s}: ${k} \u4E0E ${l} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${a[l]?"\u5DF2\u6709\u5E73\u53F0":m}\u53C2\u6570`)}Fe(c,`${s}.transformByPlatform`),r.transformByPlatform=c,delete r.transformByCanvas,n++}),i.layoutSchemaVersion=fe,t.unshift(`\u5DF2\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E03\u5C40\uFF1A${n} \u4E2A\u63A7\u4EF6\u8F6C\u6362\u4E3A\u56DB\u5E73\u53F0\u53C2\u6570\uFF1B\u518D\u6B21\u4FDD\u5B58\u5C06\u4F7F\u7528\u65B0\u7248\u683C\u5F0F`),i}function rn(e){if(![1,2,3,4].includes(e))throw new Error(`\u4EC5\u652F\u6301 version=1\u20134 \u7684\u5B58\u6863\uFF0C\u6536\u5230 ${e}`)}function on(e,t,i,n=e.canvasId){let r=$e(e.root,t);return!r||r.kind==="server-container"?he(n):i[r.id]||he(n)}function ke(e,{warnings:t=[]}={}){if(!e)return De();if(e=Hr(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==fe)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${fe} \u7684\u56DB\u5E73\u53F0\u5E03\u5C40\uFF0C\u4E0D\u652F\u6301\u65E7\u753B\u5E03\u5E03\u5C40\u6216\u5176\u4ED6\u7248\u672C`);let i=e.meta?.assetType==="client-control-template"?"client-control-template":"server-control-template",n=i==="client-control-template"?Je():De(),r={layoutSchemaVersion:fe,version:Number.isSafeInteger(e.version)&&e.version>0?e.version:1,meta:{name:String(e.meta?.name||n.meta.name),assetType:i,sourceFormat:String(e.meta?.sourceFormat||n.meta.sourceFormat),sourceFile:String(e.meta?.sourceFile||""),...e.meta?.gameVersion?{gameVersion:String(e.meta.gameVersion)}:{},...e.meta?.giaFilePath?{giaFilePath:String(e.meta.giaFilePath)}:{},...Number.isSafeInteger(Number(e.meta?.giaOwnerUid))?{giaOwnerUid:Number(e.meta.giaOwnerUid)}:{},...Number.isSafeInteger(Number(e.meta?.giaTimestamp))?{giaTimestamp:Number(e.meta.giaTimestamp)}:{},...Number.isSafeInteger(Number(e.meta?.giaFileId))?{giaFileId:Number(e.meta.giaFileId)}:{},...e.meta?.giaFileName?{giaFileName:String(e.meta.giaFileName)}:{},...Number.isSafeInteger(Number(e.meta?.giaModeFlag))&&Number(e.meta.giaModeFlag)>=0?{giaModeFlag:Number(e.meta.giaModeFlag)}:{}},canvasId:e.canvasId&&X[e.canvasId]?e.canvasId:ii,selectedId:e.selectedId||n.selectedId,root:Wi(e.root||n.root)};return qr(r),r}function qr(e){let t=new Set;J(e.root,i=>{if(typeof i.id!="string"||!i.id)throw new Error("node id must be a non-empty string");if(t.has(i.id))throw new Error(`duplicate node id: ${i.id}`);t.add(i.id)}),t.has(e.selectedId)||(e.selectedId=Ki(e.root).id)}function Lr(e){return Oe(bt(e))}function ps(e,t){let i=!1;return J(e,n=>{n.id===t&&(i=!0)}),i}function ms(e,t,i,n){let a=ze(e.root,e.canvasId).boxes[t.id],o=i.children.findIndex(h=>h.id===t.id);if(o<0)throw new Error("reparent: source node is not attached");if(i.children.splice(o,1),n.children.push(t),!a)return;let s=ze(e.root,e.canvasId),c=n.kind==="server-container"?he(e.canvasId):s.boxes[n.id]||he(e.canvasId),l=Ge(t.transformByPlatform,e.canvasId),f=Ke(c,l,{posX:a.centerX,posY:a.centerY,width:a.width,height:a.height});St(e,t,f)}function gs(e,t){return e.meta.assetType!=="client-control-template"?qi(e.root,t):(e.root.children||[]).flatMap(i=>qi(i,t))}function jr(e,t){let i=br(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let n=Dt(e),r=new Set;return n&&n.kind!=="server-container"&&J(n,a=>r.add(a.id)),i.filter(a=>r.has(a.id))}function Jr(e){let{canvas:t,boxes:i}=ze(e.root,e.canvasId),n=Vt(e),r=ue(e.root,e.selectedId),a=r?i[r.id]:null;return D({layoutSchemaVersion:fe,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:X[e.canvasId].platform,label:X[e.canvasId].label,presets:Object.values(X).map(o=>({id:o.id,label:o.label,width:o.width,height:o.height,platform:o.platform}))},selectedId:e.selectedId,asset:{type:e.meta.assetType,label:e.meta.assetType==="client-control-template"?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F",templateCount:e.meta.assetType==="client-control-template"?e.root.children.length:1,currentTemplateId:e.meta.assetType==="client-control-template"&&Dt(e)?.id||""},tree:gs(e,n),boxes:jr(e,i),inspector:vr(r,e.canvasId,a||t,n),root:e.root})}function St(e,t,i){let n=ze(e.root,e.canvasId),r=on(e,t.id,n.boxes),a={};if(t.syncAllDevices!==!1)for(let o of re){if(o===We(e.canvasId))continue;let s=ht[o],c=ze(e.root,s,o);a[o]=on(e,t.id,c.boxes,s)}t.transformByPlatform=yr({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:r,targetParentBoxByPlatform:a})}var ys=new Set(["name","active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text","imageId","imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","enableFill","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount","reverseMaskArea","raycastTarget","interactable","clickAudioId","unavailableChildId","hoverChildId","pressedChildId","selectedChildId","showScrollBar","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","scrollDirection","layoutConstraint","referencedPrefabId","animationId","keyboardKeyCode","controllerKeyCode"]),bs=new Set(["posX","posY","width","height"]),vs=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function Ss(e){if(typeof e=="number"&&Number.isFinite(e))return e>>>0;if(typeof e=="string"){let t=e.trim();if(t.startsWith("#")){let n=t.slice(1);if(n.length===6)return(4278190080|parseInt(n,16))>>>0;if(n.length===8)return parseInt(n,16)>>>0}let i=Number(t);if(Number.isFinite(i))return i>>>0}throw new Error("color must be an ARGB integer or #RRGGBB/#AARRGGBB string")}function _e(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function Xr(e){if(e===!0||e===1||e==="1"||e==="true")return!0;if(e===!1||e===0||e==="0"||e==="false")return!1;throw new Error("boolean field requires true or false")}var ws=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode"]),Is=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),Cs=new Set(["name","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),Kr=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),Wr={softEdgeMode:["Percentage","Pixel"],fillType:["Horizontal","Vertical","Radial90","Radial180","Radial360"],fillHorizontalType:["Left","Right"],fillVerticalType:["Bottom","Top"],fillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],fillRadialType:["Bottom","Left","Top","Right"]};function ks(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&ue(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:n}=ze(e.root,e.canvasId),r=jr(e,n),a=Sr(r,Number(t.x),Number(t.y));return a&&(e.selectedId=a),e}if(i==="setCanvas")return t.canvasId&&X[t.canvasId]&&(e.canvasId=t.canvasId),e;if(i==="setScript")throw new Error("\u811A\u672C\u7531\u5B58\u6863\u7EDF\u4E00\u7BA1\u7406\uFF0C\u8BF7\u4F7F\u7528 addScript / updateScript / removeScript \u64CD\u4F5C");if(i==="newAsset"){let n=t.assetType==="client-control-template"?Je():De();return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}if(i==="addTemplate"){if(e.meta.assetType!=="client-control-template")throw new Error("\u53EA\u6709\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B\u53EF\u4EE5\u65B0\u589E\u6A21\u677F");let n=H(t.kind,{id:Xi(e.root),guid:Lr(e.root),name:t.name||`\u65B0${t.kind==="container"?"\u5BB9\u5668\u8282\u70B9":t.kind}\u6A21\u677F`});return e.root.children.push(n),e.selectedId=n.id,e}if(i==="add"){let n=ue(e.root,t.parentId||e.selectedId);if(!n)throw new Error("add: parent not found");let r=pr(n,t.kind,{id:Xi(e.root),guid:Lr(e.root),name:t.name});return e.selectedId=r.id,e}if(i==="reparent"){if(e.meta.assetType!=="client-control-template")throw new Error("\u5C42\u7EA7\u8C03\u6574\u4EC5\u9002\u7528\u4E8E\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B");let n=ue(e.root,t.id||e.selectedId),r=n?$e(e.root,n.id):null,a=ue(e.root,t.parentId);if(!n||n.kind==="server-container"||!r)throw new Error("reparent: node not found");if(!a)throw new Error("reparent: parent not found");if(a.id===n.id||ps(n,a.id))throw new Error("\u63A7\u4EF6\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u8EAB\u6216\u5176\u540E\u4EE3\u4E0B\u9762");if(a.kind==="server-container"&&r.kind==="server-container")return e;if(r.kind==="server-container"&&a.kind!=="server-container"&&e.root.children.length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u9876\u5C42\u6A21\u677F");return ms(e,n,r,a),e.selectedId=n.id,e}if(i==="moveSibling"){let n=ue(e.root,t.id||e.selectedId),r=n?$e(e.root,n.id):null;if(!n||!r)throw new Error("moveSibling: node not found");let a=r.children.findIndex(c=>c.id===n.id),o=t.direction==="up"?-1:t.direction==="down"?1:0,s=a+o;return!o||s<0||s>=r.children.length||(r.children.splice(a,1),r.children.splice(s,0,n),e.selectedId=n.id),e}if(i==="remove"){let n=t.id||e.selectedId,r=$e(e.root,n);if(r?.kind==="server-container"){if(e.meta.assetType!=="client-control-template")throw new Error("\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F\u7684\u5BA2\u6237\u7AEF\u6839\u8282\u70B9\u4E0D\u80FD\u5220\u9664");if((e.root.children||[]).length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u6A21\u677F")}return mr(e.root,n)&&(J(e.root,a=>{if(a.kind==="button")for(let o of Kr)a[o]&&!ue(e.root,a[o])&&(a[o]=null)}),e.selectedId=r?r.id:e.root.id),e}if(i==="set"){let n=ue(e.root,t.id||e.selectedId);if(!n)throw new Error("set: node not found");let r=t.key;r==="reverseMask"&&(r="reverseMaskArea");let a=t.value;if(r.startsWith("giaRaw.")){let l=r.slice(7);if(!l||l.includes("."))throw new Error("invalid raw GIA field path");let f=fr(n.kind,l);if(!f)throw new Error(`unknown raw GIA field for ${n.kind}: ${l}`);if(n.giaRaw||={},n.giaRaw[l]=Yi(f,a),l==="footerField505"&&[0,1].includes(n.giaRaw[l])&&(n.canControllerFocus=n.giaRaw[l]===1),n.kind==="cursor"&&l==="cursorField501"&&[0,1].includes(n.giaRaw[l])&&(n.raycastTarget=n.giaRaw[l]===1),(n.kind==="textbox"||n.kind==="textwindow")&&l==="textAlign"){let h={0:"Left",1:"Middle",2:"Right"}[n.giaRaw[l]];h&&(n.horizontalAlignment=h)}if(n.kind==="image"&&l==="imageFillType"){let h={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[n.giaRaw[l]];h&&(n.fillType=h)}return n.kind==="keyhint"&&l==="keyHintField502"&&(n.keyboardKeyCode=n.giaRaw[l]),n.kind==="keyhint"&&l==="keyHintField501"&&(n.controllerKeyCode=n.giaRaw[l]),e}if(r==="syncAllDevices"){if(n.syncAllDevices=Xr(a),n.syncAllDevices){let l=Ge(n.transformByPlatform,e.canvasId);St(e,n,l)}return e}if(ys.has(r)){if(r.endsWith("Color")&&(a=Ss(a)),ws.has(r)){if(a=_e(a,r),a<0)throw new Error(`${r} must not be negative`);if((r==="imageId"||r==="clickAudioId"||r==="keyboardKeyCode"||r==="controllerKeyCode")&&(a=Math.trunc(a)),r==="fillAmount"&&a>1)throw new Error("fillAmount must be between 0 and 1")}if(Is.has(r)&&(a=Xr(a)),Cs.has(r)&&(a=String(a??"")),r==="horizontalAlignment"&&!["Left","Middle","Right"].includes(a))throw new Error("invalid horizontalAlignment");if(r==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(a))throw new Error("invalid verticalAlignment");if(Wr[r]&&!Wr[r].includes(a))throw new Error(`invalid ${r}`);if(Kr.has(r))if(a===""||a===void 0||a===null)a=null;else{a=String(a);let l=ue(e.root,a);if(!l||l===n||l.kind==="server-container"||!(n.children||[]).some(f=>f.id===a))throw new Error(`${r} must reference a direct child of this button`)}if(n[r]=a,r==="canControllerFocus"&&(n.giaRaw.footerField505=a?1:0),n.kind==="cursor"&&r==="raycastTarget"&&(n.giaRaw.cursorField501=a?1:0),(n.kind==="textbox"||n.kind==="textwindow")&&r==="horizontalAlignment"&&(n.giaRaw.textAlign={Left:0,Middle:1,Right:2}[a]),(n.kind==="textbox"||n.kind==="textwindow")&&r==="verticalAlignment"&&delete n.giaRaw.textVerticalAlign,n.kind==="image"&&r==="fillType"){let l={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[a];l&&(n.giaRaw.imageFillType=l)}return n.kind==="reference"&&r==="referencedPrefabId"&&(n.giaRaw.templateRefSlot=a),n.kind==="grid"&&r==="previewCount"&&(n.giaRaw.gridField511=Math.trunc(a)),n.kind==="keyhint"&&r==="keyboardKeyCode"&&(n.giaRaw.keyHintField502=Math.trunc(a)),n.kind==="keyhint"&&r==="controllerKeyCode"&&(n.giaRaw.keyHintField501=Math.trunc(a)),(n.kind==="animation"||n.kind==="fullscreen")&&r==="animationId"&&(n.giaRaw[n.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=a),e}let{boxes:o}=ze(e.root,e.canvasId),s=on(e,n.id,o),c=Ge(n.transformByPlatform,e.canvasId);if(r==="anchorType"){let l=an(o[n.id]),f=or(c,a);return f=Ke(s,f,l),St(e,n,f),e}if(r==="rotationZ"){let l={...c,rotation:{...c.rotation,z:_e(a,r)}};return St(e,n,l),e}if(vs.has(r)){let l=an(o[n.id]),f={...c,anchorMin:{...c.anchorMin},anchorMax:{...c.anchorMax},pivot:{...c.pivot}};return r==="anchorMinX"&&(f.anchorMin.x=_e(a,r)),r==="anchorMinY"&&(f.anchorMin.y=_e(a,r)),r==="anchorMaxX"&&(f.anchorMax.x=_e(a,r)),r==="anchorMaxY"&&(f.anchorMax.y=_e(a,r)),r==="pivotX"&&(f.pivot.x=_e(a,r)),r==="pivotY"&&(f.pivot.y=_e(a,r)),St(e,n,Ke(s,f,l)),e}if(bs.has(r)){let l=an(o[n.id]),f=_e(a,r);if((r==="width"||r==="height")&&f<0)throw new Error(`${r} must not be negative`);return l[r]=f,St(e,n,Ke(s,c,l)),e}throw new Error(`set: unknown key ${r}`)}if(i==="replace"){let n=ke(t.project);return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}throw new Error(`unknown op ${i}`)}function sn(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");if(t.expectedRevision!==void 0&&Number(t.expectedRevision)!==e.version)throw new Error(`revision conflict: expected ${t.expectedRevision}, current ${e.version}`);let i=e.version,n=JSON.parse(JSON.stringify(e));return ks(n,t),qr(n),n.version=i+1,Object.keys(e).forEach(r=>{delete e[r]}),Object.assign(e,n),e}function an(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import xs from"fengari";var{lua:u,lauxlib:te,lualib:Zr,to_luastring:di,to_jsstring:Es}=xs,As=u.LUA_TNIL,_s=u.LUA_TBOOLEAN,Ps=u.LUA_TNUMBER,Rs=u.LUA_TSTRING,Qr=u.LUA_TTABLE,Ts=u.LUA_TFUNCTION,ln=u.LUA_TUSERDATA,xe=u.LUA_OK,ea=new WeakMap,un=Symbol("luaTableEntries"),cn={__scriptHostKey:!0};function _(e){return di(String(e))}function Ze(e,t){ea.set(e,t)}function be(e){return ea.get(e)}function ae(e,t,i){if(i==null){u.lua_pushnil(e);return}let n=typeof i;if(n==="boolean"){u.lua_pushboolean(e,i);return}if(n==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?u.lua_pushinteger(e,i):u.lua_pushnumber(e,i);return}if(n==="string"){u.lua_pushstring(e,_(i));return}if(n==="function"){Fs(e,t,i);return}if(i&&i[un]){let r=i[un];u.lua_createtable(e,Array.isArray(i)?i.length:0,r.length);for(let[a,o]of r)ae(e,t,a),ae(e,t,o),u.lua_settable(e,-3);return}if(Array.isArray(i)){u.lua_createtable(e,i.length,0);for(let r=0;r<i.length;r++)ae(e,t,i[r]),u.lua_rawseti(e,-2,r+1);return}if(i&&i.__kind==="EnumItem"){t.pushEnumItem(e,i);return}if(i&&i.__kind==="CursorEventData"){t.pushCursor(e,i);return}if(i&&i.__kind==="Script"){t.pushScript(e,i);return}if(i&&i.typeofName){t.pushControl(e,i);return}if(i&&i.SetEase){t.pushTween(e,i);return}if(n==="object"){u.lua_createtable(e,0,Object.keys(i).length);for(let[r,a]of Object.entries(i))ae(e,t,a),u.lua_setfield(e,-2,_(r));return}u.lua_pushnil(e)}function K(e,t){if(u.lua_isnil(e,t)||u.lua_type(e,t)===u.LUA_TNONE)return"";if(!u.lua_isstring(e,t)&&u.lua_type(e,t)!==u.LUA_TNUMBER)return`lua_type=${u.lua_type(e,t)}`;let i=u.lua_tostring(e,t);return i==null?"":Es(i)}function Ye(e,t){t=u.lua_absindex(e,t);let i=u.lua_type(e,t);if(i===ln)return be(u.lua_touserdata(e,t));if(i===Qr){u.lua_pushlightuserdata(e,cn),u.lua_rawget(e,t);let n=u.lua_type(e,-1)===ln?u.lua_touserdata(e,-1):null;return u.lua_pop(e,1),n?be(n):null}return null}function pe(e,t,i){i=u.lua_absindex(e,i);let n=u.lua_type(e,i);if(n===As)return null;if(n===_s)return!!u.lua_toboolean(e,i);if(n===Ps)return u.lua_isinteger(e,i)?u.lua_tointeger(e,i):u.lua_tonumber(e,i);if(n===Rs)return K(e,i);if(n===ln){let r=u.lua_touserdata(e,i);return be(r)??r}if(n===Ts)return Ms(e,t,i);if(n===Qr){let r=Ye(e,i);if(r)return r;let a=[];for(u.lua_pushnil(e);u.lua_next(e,i)!==0;){let l=pe(e,t,-2),f=pe(e,t,-1);a.push([l,f]),u.lua_pop(e,1)}let o=new Map(a.filter(([l])=>Number.isInteger(l)&&l>=1)),s=0;for(;o.has(s+1);)s+=1;let c=s>0?[]:{};for(let[l,f]of a)Array.isArray(c)&&Number.isInteger(l)&&l>=1?c[l-1]=f:(typeof l=="string"||typeof l=="number")&&(c[l]=f);return Object.defineProperty(c,un,{value:a}),c}return null}function Ms(e,t,i){t.luaFunctions||(t.luaFunctions=new Map);let n=typeof u.lua_topointer=="function"?u.lua_topointer(e,i):null;if(n!=null&&t.luaFunctions.has(n))return t.luaFunctions.get(n);u.lua_pushvalue(e,i);let r=te.luaL_ref(e,u.LUA_REGISTRYINDEX),a=Ns(e,t,r);return n!=null&&t.luaFunctions.set(n,a),a}function Ns(e,t,i){let n=(...r)=>{let a=u.lua_gettop(e);u.lua_rawgeti(e,u.LUA_REGISTRYINDEX,i);for(let l of r)ae(e,t,l);if(u.lua_pcall(e,r.length,u.LUA_MULTRET,0)!==xe){let l=K(e,-1);throw u.lua_settop(e,a),new Error(l)}let s=u.lua_gettop(e)-a,c=[];for(let l=1;l<=s;l++)c.push(pe(e,t,a+l));if(u.lua_settop(e,a),c.length!==0)return c.length===1?c[0]:c};return n.__luaRef=i,n.__luaState=e,n}function ta(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&te.luaL_unref(i,u.LUA_REGISTRYINDEX,t.__luaRef),t.__luaRef=null,t.__luaState=null,e?.luaFunctions)for(let[n,r]of e.luaFunctions)r===t&&e.luaFunctions.delete(n)}function Fs(e,t,i){u.lua_pushlightuserdata(e,i),u.lua_pushlightuserdata(e,t),u.lua_pushcclosure(e,function(r){let a=u.lua_touserdata(r,u.lua_upvalueindex(1)),o=u.lua_touserdata(r,u.lua_upvalueindex(2)),s=u.lua_gettop(r),c=[];for(let l=1;l<=s;l++)c.push(pe(r,o,l));try{let l=a(...c);if(Array.isArray(l)&&l.__multi){for(let f of l)ae(r,o,f);return l.length}return l===void 0?0:(ae(r,o,l),1)}catch(l){return u.lua_pushstring(r,_(String(l&&l.message?l.message:l))),u.lua_error(r)}},2)}function ia(e){!e||typeof u.lua_close!="function"||u.lua_close(e)}function na(e){if(te.luaL_loadstring(e,_(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
|
|
107
|
+
`)))===xe&&u.lua_pcall(e,0,0,0),u.lua_settop(e,0),u.lua_pushnil(e),u.lua_setglobal(e,_("_VERSION")),u.lua_getglobal(e,_("string")),!u.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])u.lua_pushnil(e),u.lua_setfield(e,-2,_(i));if(u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,_("io")),u.lua_getglobal(e,_("os")),!u.lua_isnil(e,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))u.lua_pushnil(e),u.lua_setfield(e,-2,_(i));u.lua_pop(e,1),u.lua_getglobal(e,_("debug")),u.lua_isnil(e,-1)?u.lua_pop(e,1):(u.lua_getfield(e,-1,_("traceback")),u.lua_newtable(e),u.lua_pushvalue(e,-2),u.lua_setfield(e,-2,_("traceback")),u.lua_setglobal(e,_("debug")),u.lua_pop(e,2)),u.lua_getglobal(e,_("math")),u.lua_isnil(e,-1)||(u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,Number.isNaN(n)),1}),u.lua_setfield(e,-2,_("isnan")),u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,n===1/0||n===-1/0),1}),u.lua_setfield(e,-2,_("isinf"))),u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,_("package")),u.lua_pushnil(e),u.lua_setglobal(e,_("load")),u.lua_pushnil(e),u.lua_setglobal(e,_("loadfile")),u.lua_pushnil(e),u.lua_setglobal(e,_("dofile")),u.lua_pushnil(e),u.lua_setglobal(e,_("collectgarbage")),u.lua_pushnil(e),u.lua_setglobal(e,_("coroutine")),u.lua_pushnil(e),u.lua_setglobal(e,_("fengari"))}var ra={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},Os=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],hi=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),$s=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],Ds={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},Gs={container:["isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor"],textbox:["text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],textwindow:["interactable","showScrollBar","text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],image:["imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","reverseMaskArea","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount"],button:["interactable","clickAudioId","raycastTarget"],cursor:["raycastTarget"],grid:["itemPrefabIndex","raycastTarget","showScrollBar","interactable","scrollProgress"],keyhint:["keyboardKeyCode","controllerKeyCode"],animation:["animationId","playSoundEffect","layer"],fullscreen:["animationId","playSoundEffect"]},zs=["GetChildren","GetChild","FindChild","SetActive","SetVisible","GetSiblingIndex","SetSiblingIndex","SetAsFirstSibling","SetAsLastSibling","GetAnchoredPosition","SetAnchoredPosition","GetSizeDelta","SetSizeDelta","GetAnchorMin","SetAnchorMin","GetAnchorMax","SetAnchorMax","GetPivot","SetPivot","GetLocalScale","SetLocalScale","GetLocalRotation","SetLocalRotation","GetScriptByPath","GetScript","GetScripts","AddKeyEventListener","RemoveKeyEventListener","RemoveKeyEventListeners","RemoveAllKeyEventListeners","AddNavigationEventListener","RemoveNavigationEventListener","RemoveNavigationEventListeners","RemoveAllNavigationEventListeners","SetControllerNavigation","GetControllerNavigation"],aa=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Vs={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:aa,cursor:aa,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function fn(e,t){return Os.includes(t)||(Ds[e.kind]||[]).includes(t)?"ro":$s.includes(t)||(Gs[e.kind]||[]).includes(t)?"rw":null}function oa(e,t){return zs.includes(t)||(Vs[e.kind]||[]).includes(t)}var Ys={container:{isolateNavigation:!1,disableKeyEventPassthrough:!1,disableCursorEventPassthrough:!1,showCursor:!1},textbox:{text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},textwindow:{interactable:!0,showScrollBar:!0,text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},image:{imageSource:null,imageId:0,imageColor:4294967295,imageType:null,enableMask:!1,enableSoftEdge:!1,softEdgeMode:"Percentage",softEdgeWidthX:8,softEdgeWidthY:8,horizontalSoftRange:85,verticalSoftRange:85,enableFill:!1,fillType:"Unused",fillHorizontalType:"Left",fillVerticalType:"Bottom",fillRadial90Type:"BottomLeft",fillRadialType:"Bottom",reverseMaskArea:!1,fillAmount:1},button:{interactable:!0,clickAudioId:0,raycastTarget:!0,unavailableChildId:null,hoverChildId:null,pressedChildId:null,selectedChildId:null,pressed:!1},cursor:{raycastTarget:!0},grid:{itemCount:0,itemPrefabIndex:null,raycastTarget:!0,interactable:!0,showScrollBar:!0,scrollDirection:"Vertical",layoutConstraint:"AutoWrap",layoutConstraintFixedCount:null,scrollProgress:0,cellSizeX:50,cellSizeY:50,spacingX:8,spacingY:8,padding1X:20,padding1Y:20,padding2X:20,padding2Y:20,previewCount:5},keyhint:{keyboardKeyCode:null,controllerKeyCode:null},animation:{animationId:null,playSoundEffect:null,layer:null,raycastTarget:!1},fullscreen:{animationId:null,playSoundEffect:null,raycastTarget:!1},reference:{referencedPrefabIndex:null}},Be=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=ra[this.kind]||ra.container,this.alive=!0,this.Id=i.Id??t.nextControlId(),this.authoringId=i.authoringId??null,this.prefabIndex=i.prefabIndex??0,this.name=i.name??"",this.active=i.active===!0,this.visible=i.visible!==!1,this._parent=null,this.children=[],this.scripts=[],this.cursorListeners=new Map,this.keyListeners=new Map,this.navListeners=new Map,this.navConfig=new Map,this.anchoredPositionX=i.anchoredPositionX??0,this.anchoredPositionY=i.anchoredPositionY??0,this.sizeDeltaX=i.sizeDeltaX??0,this.sizeDeltaY=i.sizeDeltaY??0,this.anchorMinX=i.anchorMinX??.5,this.anchorMinY=i.anchorMinY??.5,this.anchorMaxX=i.anchorMaxX??.5,this.anchorMaxY=i.anchorMaxY??.5,this.pivotX=i.pivotX??.5,this.pivotY=i.pivotY??.5,this.localScaleX=i.localScaleX??1,this.localScaleY=i.localScaleY??1,this.localScaleZ=i.localScaleZ??1,this.localRotationX=i.localRotationX??0,this.localRotationY=i.localRotationY??0,this.localRotationZ=i.localRotationZ??0,this.canControllerFocus=i.canControllerFocus??!1,this._playDirty=!0,this._playDeepDirty=!0,this._playChildDirty=!1;let n=Ys[this.kind]||{};for(let[r,a]of Object.entries(n))this[r]===void 0&&(this[r]=i[r]!==void 0?i[r]:a);if(i.children)for(let r of i.children){let a=r instanceof e?r:new e(t,r);this.addChild(a)}}get parent(){return this._parent}set parent(t){if(this._parent===t)return;if(t!==null&&!(t instanceof e))throw new Error("parent must be a Control or nil");if(t&&t.runtime!==this.runtime)throw new Error("parent must belong to the same runtime");if(t===this)throw new Error("cannot parent a control to itself or its descendant");for(let n=t;n;n=n._parent)if(n===this)throw new Error("cannot parent a control to itself or its descendant");let i=this._parent;if(i){let n=i.children.indexOf(this);n>=0&&i.children.splice(n,1),i.markPlayDirty(!0)}else{let n=this.runtime.roots.indexOf(this);n>=0&&this.runtime.roots.splice(n,1)}this._parent=t,this.markPlayDirty(!0),t&&!t.children.includes(this)?(t.children.push(this),t.markPlayDirty(!0)):!t&&this.alive&&!this.runtime.roots.includes(this)&&this.runtime.roots.push(this)}markPlayDirty(t=!1){this._playDirty=!0,t&&(this._playDeepDirty=!0);for(let i=this._parent;i&&!i._playChildDirty;i=i._parent)i._playChildDirty=!0}get activeInHierarchy(){return this.active?this._parent?this._parent.activeInHierarchy:!0:!1}addChild(t){return t.parent=this,t}GetChildren(){return this.children.slice()}GetChild(t){return this.children.find(i=>i.name===t)||null}FindChild(t){if(!t)return null;if(!t.includes("/"))return this.GetChild(t);let i=t.split("/").filter(Boolean),n=this;for(let r of i)if(n=n.GetChild(r),!n)return null;return n}SetActive(t){let i=!!t;if(this.active!==i){if(typeof this.runtime?.onControlActiveChanging=="function"){this.runtime.onControlActiveChanging(this,i);return}this.active=i,this.markPlayDirty(!0)}}SetVisible(t){this.visible=!!t,this.markPlayDirty(!0)}GetSiblingIndex(){if(!this._parent)return-1;let t=this._parent.children,i=t.indexOf(this);return i<0?-1:t.length-1-i}SetSiblingIndex(t){if(!this._parent)return!1;let i=this._parent.children,n=i.indexOf(this);if(n<0)return!1;let r=i.length-1;return!Number.isInteger(t)||t<0||t>r?!1:(i.splice(n,1),i.splice(r-t,0,this),this._parent.markPlayDirty(!0),this.markPlayDirty(),!0)}SetAsFirstSibling(){return this.SetSiblingIndex(0)}SetAsLastSibling(){return this._parent?this.SetSiblingIndex(this._parent.children.length-1):!1}GetAnchoredPosition(){return[this.anchoredPositionX,this.anchoredPositionY]}SetAnchoredPosition(t,i){this.anchoredPositionX=t,this.anchoredPositionY=i,this.markPlayDirty()}GetSizeDelta(){return[this.sizeDeltaX,this.sizeDeltaY]}SetSizeDelta(t,i){this.sizeDeltaX=t,this.sizeDeltaY=i,this.markPlayDirty(!0)}GetAnchorMin(){return[this.anchorMinX,this.anchorMinY]}SetAnchorMin(t,i){this.anchorMinX=t,this.anchorMinY=i,this.markPlayDirty(!0)}GetAnchorMax(){return[this.anchorMaxX,this.anchorMaxY]}SetAnchorMax(t,i){this.anchorMaxX=t,this.anchorMaxY=i,this.markPlayDirty(!0)}GetPivot(){return[this.pivotX,this.pivotY]}SetPivot(t,i){this.pivotX=t,this.pivotY=i,this.markPlayDirty(!0)}GetLocalScale(){return[this.localScaleX,this.localScaleY,this.localScaleZ]}SetLocalScale(t,i,n){this.localScaleX=t,this.localScaleY=i,this.localScaleZ=n,this.markPlayDirty()}GetLocalRotation(){return[this.localRotationX,this.localRotationY,this.localRotationZ]}SetLocalRotation(t,i,n){this.localRotationX=t,this.localRotationY=i,this.localRotationZ=n,this.markPlayDirty()}GetScriptByPath(t){return this.scripts.find(i=>i.path===t)||null}GetScript(t){return this.scripts.find(i=>i.scriptMappingId===t)||null}GetScripts(){return this.scripts.slice()}_addListener(t,i,n){let r=t.get(i)||[];r.push(n),t.set(i,r)}_removeListener(t,i,n){let r=t.get(i);r&&(t.set(i,r.filter(a=>a!==n)),this.runtime.unrefLuaCallback?.(n))}_removeListeners(t,i){let n=t.get(i)||[];for(let r of n)this.runtime.unrefLuaCallback?.(r);t.delete(i)}_removeAllListeners(t){for(let i of t.values())for(let n of i)this.runtime.unrefLuaCallback?.(n);t.clear()}AddCursorEventListener(t,i){this._addListener(this.cursorListeners,t,i)}RemoveCursorEventListener(t,i){this._removeListener(this.cursorListeners,t,i)}RemoveCursorEventListeners(t){this._removeListeners(this.cursorListeners,t)}RemoveAllCursorEventListeners(){this._removeAllListeners(this.cursorListeners)}SimulateCursorClick(){let t=this.runtime.makeCursorEventData({x:0,y:0,pressX:0,pressY:0});this.emitCursor("CursorDown",t),this.emitCursor("CursorUp",t),this.emitCursor("CursorClick",t)}emitCursor(t,i){if(!this.runtime.cursorEventsEnabled(this))return;let n=this.cursorListeners.get(t)||[];for(let r of n)r(i)}AddKeyEventListener(t,i){this._addListener(this.keyListeners,t,i)}RemoveKeyEventListener(t,i){this._removeListener(this.keyListeners,t,i)}RemoveKeyEventListeners(t){this._removeListeners(this.keyListeners,t)}RemoveAllKeyEventListeners(){this._removeAllListeners(this.keyListeners)}emitKey(t){let i=this.keyListeners.get(t)||[];for(let n of i)if(n()===!0)return!0;return!1}AddNavigationEventListener(t,i){this._addListener(this.navListeners,t,i)}RemoveNavigationEventListener(t,i){this._removeListener(this.navListeners,t,i)}RemoveNavigationEventListeners(t){this._removeListeners(this.navListeners,t)}RemoveAllNavigationEventListeners(){this._removeAllListeners(this.navListeners)}SetControllerNavigation(t,i,n){this.navConfig.set(t,{mode:i,target:n})}GetControllerNavigation(t){let i=this.navConfig.get(t),n=i?[i.mode,i.target]:[null,null];return n.__multi=!0,n}SetImage(t,i){this.imageSource=t,this.imageId=i,this.markPlayDirty()}SetSoftEdgeWidth(t,i){this.softEdgeWidthX=t,this.softEdgeWidthY=i,this.markPlayDirty()}SetFillUnused(){this.fillType="Unused",this.markPlayDirty()}SetFillHorizontal(t,i){this.fillType="Horizontal",this.fillHorizontalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillVertical(t,i){this.fillType="Vertical",this.fillVerticalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial90(t,i){this.fillType="Radial90",this.fillRadial90Type=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial180(t,i){this.fillType="Radial180",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial360(t,i){this.fillType="Radial360",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}PlayAnimation(){}StopAnimation(){}RefreshItems(){throw new Error("ClientUIGridScrollerControl:RefreshItems not implemented")}GetItemIndex(){throw new Error("ClientUIGridScrollerControl:GetItemIndex not implemented")}GetItemSize(){throw new Error("ClientUIGridScrollerControl:GetItemSize not implemented")}GetItemSpacing(){throw new Error("ClientUIGridScrollerControl:GetItemSpacing not implemented")}GetPadding(){throw new Error("ClientUIGridScrollerControl:GetPadding not implemented")}ScrollToItemAt(){throw new Error("ClientUIGridScrollerControl:ScrollToItemAt not implemented")}GetContentLength(){throw new Error("ClientUIGridScrollerControl:GetContentLength not implemented")}};function Ee(e,t){t(e);for(let i of e.children)Ee(i,t)}function dn(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let n of e.children)dn(n,t,i+" ");return t}function pi(e){return 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}var sa={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,InQuint:e=>e**5,OutQuint:e=>1-(1-e)**5,InOutQuint:e=>e<.5?16*e**5:1-(-2*e+2)**5/2,InExpo:e=>e===0?0:2**(10*e-10),OutExpo:e=>e===1?1:1-2**(-10*e),InOutExpo:e=>e===0||e===1?e:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2,InCirc:e=>1-Math.sqrt(1-e**2),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=>(1.70158+1)*e*e*e-1.70158*e*e,OutBack:e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,InOutBack:e=>{let i=2.5949095;return e<.5?(2*e)**2*((i+1)*2*e-i)/2:((2*e-2)**2*((i+1)*(e*2-2)+i)+2)/2},InElastic:e=>e===0||e===1?e:-(2**(10*e-10))*Math.sin((e*10-10.75)*(2*Math.PI/3)),OutElastic:e=>e===0||e===1?e:2**(-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1,InOutElastic:e=>{if(e===0||e===1)return e;let t=2*Math.PI/4.5;return e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*t))/2:2**(-20*e+10)*Math.sin((20*e-11.125)*t)/2+1},InBounce:e=>1-pi(1-e),OutBounce:pi,InOutBounce:e=>e<.5?(1-pi(1-2*e))/2:(1+pi(2*e-1))/2};function la(e,t){let i=sa[e]||sa.Linear;return t<=0?0:t>=1?1:i(t)}function wt(e,t,i,n=255){let r=mi(e),a=mi(t),o=mi(i);return((n==null?255:mi(n))<<24|r<<16|a<<8|o)>>>0}function Yt(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function mi(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function ua(e,t,i){let n=Yt(e),r=Yt(t);return wt(n[0]+(r[0]-n[0])*i,n[1]+(r[1]-n[1])*i,n[2]+(r[2]-n[2])*i,n[3]+(r[3]-n[3])*i)}var Bs=new Set(["fontColor","bgColor","outlineColor","imageColor"]),gi=class{constructor(t,i,n,r){this.runtime=t,this.object=i,this.data={...n},this.duration=Math.max(0,Number(r)||0),this.easeName="Linear",this.relative=!1,this.playing=!1,this.paused=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.from={},this.to={},this.initialFrom=null,this.initialTo=null,this.onComplete=null,this.onStepComplete=null,this.killed=!1}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let n=this.object[t];this.from[t]=n,this.to[t]=this.relative?Number(n)+Number(i):i}}restoreInitial(){this.initialFrom?(this.from={...this.initialFrom},this.to={...this.initialTo}):this.capture()}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this._start(!1)}_start(t){return this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to}),this.runtime.tweens.add(this),this.duration===0&&this.Complete(),this}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this._start(!0)}Complete(){this.apply(1),this.finish(!0)}Kill(t){t?this.Complete():this.finish(!1)}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){let i=la(this.easeName,t),n=!1,r=!1;for(let a of Object.keys(this.to)){let o=this.from[a],s=this.to[a];Bs.has(a)&&typeof o=="number"&&typeof s=="number"?this.object[a]=ua(o,s,i):typeof o=="number"&&typeof s=="number"?this.object[a]=o+(s-o)*i:this.object[a]=i>=1?s:o,n=!0,hi.has(a)&&(r=!0)}n&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(r)}step(t){if(!this.playing||this.paused||this.killed)return;this.elapsed+=t;let i=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);if(this.apply(i),i>=1){this.onStepComplete&&this.runtime.safeCall(this.onStepComplete);let n=this.loops<0;if(this.loopIndex++,n||this.loopIndex<this.loops){this.elapsed=Math.max(0,this.elapsed-this.duration),this.relative?this.capture():this.restoreInitial();let r=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);this.apply(r)}else this.finish(!0)}}finish(t){this.playing=!1,this.killed=!0,this.runtime.tweens.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},yi=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._built=[]}Append(t){return this.steps.push({kind:"tween",tween:t,parallel:!1}),this}AppendInterval(t){return this.steps.push({kind:"interval",duration:t}),this}AppendCallback(t){return this.steps.push({kind:"callback",fn:t}),this}Join(t){return this.steps.push({kind:"tween",tween:t,parallel:!0}),this}Insert(t,i){return this.steps.push({kind:"insert",time:t,tween:i}),this}InsertCallback(t,i){return this.steps.push({kind:"insertCb",time:t,fn:i}),this}Play(){return this.playing=!0,this.paused=!1,this.killed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this._activateDueEntries(),this.runtime.sequences.add(this),this}_schedule(){let t=0,i=0,n=!1;this._built=[];for(let r of this.steps)if(r.kind==="tween"&&r.parallel){let a=n?i:t;this._built.push({at:a,tween:r.tween}),t=Math.max(t,a+r.tween.duration)}else r.kind==="tween"?(this._built.push({at:t,tween:r.tween}),i=t,n=!0,t+=r.tween.duration):r.kind==="interval"?(i=t,n=!0,t+=r.duration):r.kind==="callback"?this._built.push({at:t,fn:r.fn}):r.kind==="insert"?(this._built.push({at:r.time,tween:r.tween}),t=Math.max(t,r.time+r.tween.duration)):r.kind==="insertCb"&&(this._built.push({at:r.time,fn:r.fn}),t=Math.max(t,r.time));this._end=t,this._fired=new Set}Pause(){this.paused=!0;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Pause()}Resume(){this.paused=!1;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Resume()}Restart(){this.Play()}Complete(){for(let t of this._built)t.tween&&(this._fired.has(t)||t.tween.Play(),t.tween.Complete()),t.fn&&!this._fired.has(t)&&this.runtime.safeCall(t.fn),this._fired.add(t);this.finish(!0)}Kill(t){if(t)this.Complete();else{for(let i of this._built)i.tween&&this._fired.has(i)&&i.tween.Kill(!1);this.finish(!1)}}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}_activateDueEntries(){for(let t of this._built)this._fired.has(t)||this.elapsed+1e-9<t.at||(this._fired.add(t),t.tween&&t.tween.Play(),t.fn&&this.runtime.safeCall(t.fn))}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._activateDueEntries(),this.elapsed>=this._end&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._schedule()):this.finish(!0)))}finish(t){this.playing=!1,this.killed=!0,this.runtime.sequences.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var bi={EaseType:["Linear","InSine","OutSine","InOutSine","InQuad","OutQuad","InOutQuad","InCubic","OutCubic","InOutCubic","InQuart","OutQuart","InOutQuart","InQuint","OutQuint","InOutQuint","InExpo","OutExpo","InOutExpo","InCirc","OutCirc","InOutCirc","InBack","OutBack","InOutBack","InElastic","OutElastic","InOutElastic","InBounce","OutBounce","InOutBounce"],CustomVariableEntityType:["Level","PlayerSelf","AvatarSelf"],Device:["KeyboardAndMouse","Mobile","Controller","MobileController"],StageMode:["Beyond","Classic"],LanguageType:["LanguageNone","LanguageEng","LanguageChs","LanguageCht","LanguageFra","LanguageDeu","LanguageSpa","LanguagePor","LanguageRus","LanguageJpn","LanguageKor","LanguageTha","LanguageVie","LanguageInd","LanguageTur","LanguageIta"],ParamType:["Entity","EntityList","Int","IntList","Bool","BoolList","Float","FloatList","String","StringList","Vector3","Vector3List","Guid","GuidList","ConfigId","PrefabId","ConfigIdList","PrefabIdList"],CursorEventType:["CursorDown","CursorUp","CursorEnter","CursorExit","CursorDrag","CursorBeginDrag","CursorEndDrag","CursorClick"],ScrollDirection:["Horizontal","Vertical"],ScrollLayoutConstraint:["AutoWrap","Fixed"],ScrollAlignType:["Bottom","Center","Top"],ControllerNavigationDir:["Up","Down","Left","Right"],ControllerNavigationEventType:["Confirm","Cancel","Focus","LostFocus","RightStickUp","RightStickDown","RightStickRight","RightStickLeft","LeftStickUp","LeftStickDown","LeftStickRight","LeftStickLeft"],ControllerNavigationMode:["None","NearestControl","Specified"],TextHorizontalAlignment:["Left","Middle","Right"],TextVerticalAlignment:["Top","Middle","Bottom"],ImageType:["Basic","Stretch"],ImageSource:["StaticReference","Item","Equipment","Skill","UnitStatus","Faction","Currency","Prefab"],ImageFillType:["Unused","Horizontal","Vertical","Radial90","Radial180","Radial360"],ImageFillHorizontalType:["Left","Right"],ImageFillVerticalType:["Bottom","Top"],ImageFillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],ImageFillRadialType:["Bottom","Left","Top","Right"],ImageMaskSoftEdgeMode:["Percentage","Pixel"],UIAnimationLayer:["AboveAllControls","BelowAllControls"]},Us=[...Array.from({length:43},(e,t)=>`CraftspersonKey${t+1}`),"MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","None"],Hs=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function Ls(){let e=[];for(let t of["Down","Up"]){for(let i=1;i<=43;i++)e.push(`KeyboardCraftspersonKey${i}${t}`);for(let i of["MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key"])e.push(`Keyboard${i}${t}`);for(let i=1;i<=14;i++)e.push(`ControllerCraftspersonKey${i}${t}`);for(let i of["SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey"])e.push(`Controller${i}${t}`)}return e}bi.KeyboardKeyCode=Us;bi.ControllerKeyCode=Hs;bi.KeyEventType=Ls();var ca=new Map;function Qe(e,t){let i=`${e}\0${t}`,n=ca.get(i);return n||(n={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},ca.set(i,n)),n}function hn(e,t){return t==null?t:t.__kind==="EnumItem"?Qe(t.EnumType||e,t.Name):typeof t=="string"&&t?Qe(e,t):t}function pn(){let e={};for(let[t,i]of Object.entries(bi)){let n={};for(let r of i)n[r]=Qe(t,r);e[t]=n}return e}var fa={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},et=u.LUA_REGISTRYINDEX,Xs=u.LUA_MULTRET,Ks=Object.freeze({InstantiateClientUIControl:2,DestroyClientUIControl:1,GetClientUIControl:1,FindClientUIRoot:1,GetClientUIRoots:0,GetUICanvasSize:0,GetCursorUIPos:0,GetDevice:0,SetControllerFocus:1,GetControllerFocus:0,GetControllerLeftStickAxis:0,GetControllerRightStickAxis:0,Tween:3,TweenSequence:0,ServerSignal:1,GetGlobalCustomVariableValue:2,PauseLevelTime:1,IsLevelTimePaused:0,PlayAudio2D:1,StopAudio:1,IsAudioAlive:1,GetLanguageType:0,GetStageMode:0,IsTestPlay:0,GetText:1,PrintClientUITree:0});function me(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}function Ws(e){let t=String(e).replace(/\\/g,"/").replace(/\.lua$/i,"");return t.split("/").pop()||t}var vi=class{constructor(t={}){this.canvasWidth=t.canvasWidth??1600,this.canvasHeight=t.canvasHeight??900,this.device=t.device??"KeyboardAndMouse",this.language=t.language??"LanguageChs",this.stageMode=t.stageMode??"Classic",this.testPlay=t.testPlay!==!1,this.clock={time:0,levelTime:0,paused:!1,frame:0},this.logs=[],this.mountErrors=[],this.tweens=new Set,this.sequences=new Set,this.audios=new Map,this.nextAudioId=1,this._nextControlId=1,this._playRemoved=[],this._nextScriptMappingId=1,this.lifecyclePhase="idle",this.controlsById=new Map,this.roots=[],this.templates=new Map,this.scriptFiles=new Map,this.requireAliases=new Map,this.requireCache=new Map,this.moduleBaseEnvironments=new Map,this.luaFunctions=new Map,this.mountedScripts=[],this.serverVars={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)},this.serverBridge=null,this.varHandlers=[],this.signalHandlers=[],this.cursor={x:0,y:0},this.focus=null,this.stick={left:[0,0],right:[0,0]},this.enumTree=pn(),this.luaStates=new Set,this.L=null}nextControlId(){let t=this._nextControlId;return this._nextControlId+=1,t}resolveScriptMappingId(t){let i=Number(t);if(Number.isSafeInteger(i)&&i>0)return this._nextScriptMappingId=Math.max(this._nextScriptMappingId,i+1),i;let n=this._nextScriptMappingId;return this._nextScriptMappingId+=1,n}pushPackedColor(t,i){let n=i>>>0;(n|0)===n?u.lua_pushinteger(t,n):u.lua_pushnumber(t,n)}unrefLuaCallback(t){ta(this,t)}log(t,...i){let n=i.map(r=>r==null?"nil":typeof r=="object"&&r!==null&&r.__kind==="EnumItem"?r.Name:String(r)).join(" ");this.logs.push({level:t,text:n,time:this.clock.time})}safeCall(t,...i){try{return t(...i)}catch(n){this.log("lua-error",n&&n.message?n.message:String(n))}}scriptCanRun(t){if(!t?.alive||!t.enabled)return!1;let i=t.object;return!i||i.alive&&i.activeInHierarchy}cursorEventsEnabled(t){for(let i=t;i;i=i.parent)if(i.kind==="container"&&i.showCursor===!0)return!0;return!1}registerTemplate(t,i){this.templates.set(Number(t),i)}registerScriptFile(t,i){let n=this.normalizeRequirePath(t);this.scriptFiles.set(n,i),n.startsWith("default_import_file/")||this.requireAliases.set(`default_import_file/${n}`,n)}normalizeRequirePath(t){let i=String(t).replace(/\\/g,"/");return i.endsWith(".lua")&&(i=i.slice(0,-4)),i}addRoot(t){let i=t instanceof Be?t:new Be(this,t);return this.roots.push(i),Ee(i,n=>this.controlsById.set(n.Id,n)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof Be)return;let n=a=>(a.scripts?.length||0)>0||(a.children||[]).some(n);if(!t||!n(t))return;let r=this.lifecyclePhase;try{let a=(o,s)=>{for(let l of o.scripts||[])try{this.mountScript({path:l.path,source:l.source,control:s,scriptMappingId:l.scriptMappingId})}catch(f){let h=f&&f.message?f.message:String(f);this.mountErrors.push(h),this.log("lua-error",h)}let c=o.children||[];for(let l=0;l<c.length;l+=1)a(c[l],s?.children?.[l])};a(t,i)}finally{this.lifecyclePhase=r}}makeCursorEventData({x:t=0,y:i=0,pressX:n=t,pressY:r=i,deltaX:a=t-n,deltaY:o=i-r,dragging:s=!1,touchId:c=-1}={}){let l=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:s,touchId:c,x:t,y:i,pressX:n,pressY:r,GetUIPos(){return[t,i]},GetPressUIPos(){return[n,r]},GetUIPosDelta(){return[a,o]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),a=[];for(let o=1;o<=r;o++)a.push(pe(n,i,o));return i.log("info",...a),0}),u.lua_setglobal(t,_("print")),u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),a=[];for(let o=1;o<=r;o++)a.push(pe(n,i,o));return i.log("error",...a),0}),u.lua_setglobal(t,_("printerr")),u.lua_pushcfunction(t,n=>{if(u.lua_type(n,1)===u.LUA_TTABLE&&!Ye(n,1))return u.lua_pushstring(n,_("table")),1;let r=pe(n,i,1);return u.lua_pushstring(n,_(i.typeofOf(r))),1}),u.lua_setglobal(t,_("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),u.lua_pushcfunction(t,n=>i.luaRequire(n)),u.lua_setglobal(t,_("require"))}typeofOf(t){return t==null?"nil":t.__kind==="Script"?"Script":t.__kind==="EnumItem"?"EnumItem":t.__kind==="CursorEventData"?"CursorEventData":t.typeofName?t.typeofName:typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t}pushColorLib(t){u.lua_newtable(t),u.lua_pushcfunction(t,i=>(this.pushPackedColor(i,wt(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),255)),1)),u.lua_setfield(t,-2,_("FromRGB")),u.lua_pushcfunction(t,i=>{let n=u.lua_isnoneornil(i,4)?255:u.lua_tonumber(i,4);return this.pushPackedColor(i,wt(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),n)),1}),u.lua_setfield(t,-2,_("FromRGBA")),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,1)>>>0,[r,a,o,s]=Yt(n);return u.lua_pushnumber(i,r),u.lua_pushnumber(i,a),u.lua_pushnumber(i,o),u.lua_pushnumber(i,s),4}),u.lua_setfield(t,-2,_("ToRGBA")),u.lua_newtable(t),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,2),r=u.lua_tonumber(i,3),a=u.lua_tonumber(i,4),o=u.lua_isnoneornil(i,5)?255:u.lua_tonumber(i,5);return this.pushPackedColor(i,wt(n,r,a,o)),1}),u.lua_setfield(t,-2,_("__call")),u.lua_setmetatable(t,-2),u.lua_setglobal(t,_("Color"))}pushEnumLib(t){u.lua_newtable(t);for(let[i,n]of Object.entries(this.enumTree)){u.lua_newtable(t);for(let[r,a]of Object.entries(n))this.pushEnumItem(t,a),u.lua_setfield(t,-2,_(r));u.lua_setfield(t,-2,_(i))}u.lua_setglobal(t,_("Enum"))}pushEnumItem(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i),te.luaL_setmetatable(t,_("EnumItem"))}pushControl(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i),te.luaL_setmetatable(t,_("Control"))}pushScript(t,i){u.lua_newtable(t),u.lua_pushlightuserdata(t,cn);let n=u.lua_newuserdata(t,0);Ze(n,i),u.lua_rawset(t,-3),te.luaL_getmetatable(t,_("Script")),u.lua_setmetatable(t,-2)}pushTween(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i);let r=i.Append?"TweenSequence":"Tween";te.luaL_setmetatable(t,_(r))}pushCursor(t,i){let n=u.lua_newuserdata(t,0);Ze(n,i),te.luaL_setmetatable(t,_("CursorEventData"))}pushGameLib(t){let i=this;u.lua_newtable(t);let n={InstantiateClientUIControl:r=>{let a=u.lua_tointeger(r,1),o=be(u.lua_touserdata(r,2)),s=i.instantiate(a,o,i.lifecyclePhase);return s?(i.pushControl(r,s),1):(u.lua_pushnil(r),1)},DestroyClientUIControl:r=>{let a=be(u.lua_touserdata(r,1));return a&&i.destroyControl(a),0},GetClientUIControl:r=>{let a=u.lua_tointeger(r,1),o=i.controlsById.get(a);return o?i.pushControl(r,o):u.lua_pushnil(r),1},FindClientUIRoot:r=>{let a=K(r,1),o=i.roots.find(s=>s.name===a);return o?i.pushControl(r,o):u.lua_pushnil(r),1},GetClientUIRoots:r=>(u.lua_createtable(r,i.roots.length,0),i.roots.forEach((a,o)=>{i.pushControl(r,a),u.lua_rawseti(r,-2,o+1)}),1),GetUICanvasSize:r=>(u.lua_pushnumber(r,i.canvasWidth),u.lua_pushnumber(r,i.canvasHeight),2),GetCursorUIPos:r=>(u.lua_pushnumber(r,i.cursor.x),u.lua_pushnumber(r,i.cursor.y),2),GetDevice:r=>(i.pushEnumItem(r,Qe("Device",i.device)),1),SetControllerFocus:r=>(i.focus=be(u.lua_touserdata(r,1)),0),GetControllerFocus:r=>(i.focus?i.pushControl(r,i.focus):u.lua_pushnil(r),1),GetControllerLeftStickAxis:r=>(u.lua_pushnumber(r,i.stick.left[0]),u.lua_pushnumber(r,i.stick.left[1]),2),GetControllerRightStickAxis:r=>(u.lua_pushnumber(r,i.stick.right[0]),u.lua_pushnumber(r,i.stick.right[1]),2),Tween:r=>{let a=be(u.lua_touserdata(r,1))||pe(r,i,1),o=pe(r,i,2)||{},s=u.lua_tonumber(r,3),c=new gi(i,a,o,s);return i.pushTween(r,c),1},TweenSequence:r=>(i.pushTween(r,new yi(i)),1),ServerSignal:r=>{let a=K(r,1),o=i.makeServerSignal(a),s=u.lua_newuserdata(r,0);return Ze(s,o),te.luaL_setmetatable(r,_("ServerSignal")),1},GetGlobalCustomVariableValue:r=>{let a=me(pe(r,i,1)),o=K(r,2);return ae(r,i,i.getVar(a,o)),1},PauseLevelTime:r=>(i.clock.paused=!!u.lua_toboolean(r,1),0),IsLevelTimePaused:r=>(u.lua_pushboolean(r,i.clock.paused),1),PlayAudio2D:r=>{let a=i.nextAudioId++;return i.audios.set(a,{audioId:u.lua_tointeger(r,1),alive:!0}),u.lua_pushinteger(r,a),1},StopAudio:r=>{let a=u.lua_tointeger(r,1),o=i.audios.get(a);return o&&(o.alive=!1),0},IsAudioAlive:r=>{let a=i.audios.get(u.lua_tointeger(r,1));return u.lua_pushboolean(r,!!(a&&a.alive)),1},GetLanguageType:r=>(i.pushEnumItem(r,Qe("LanguageType",i.language)),1),GetStageMode:r=>(i.pushEnumItem(r,Qe("StageMode",i.stageMode)),1),IsTestPlay:r=>(u.lua_pushboolean(r,i.testPlay),1),GetText:r=>{let a=K(r,1);return u.lua_pushstring(r,_(a)),1},PrintClientUITree:r=>{for(let a of i.roots)i.log("info",dn(a).join(`
|
|
108
|
+
`));return 0}};for(let[r,a]of Object.entries(n)){let o=Ks[r];if(o===void 0)throw new Error(`missing game arity for ${r}`);u.lua_pushcfunction(t,s=>{let c=u.lua_gettop(s);return c!==o?te.luaL_error(s,_(`bad argument count to '${r}' (${o} expected, got ${c})`)):a(s)}),u.lua_setfield(t,-2,_(r))}u.lua_setglobal(t,_("game"))}makeServerSignal(t){let i=[],n=this;return{__kind:"ServerSignal",name:t,AddParam(r,a){i.push({type:me(r),value:a})},AddInt(r){i.push({type:"Int",value:r})},AddIntList(r){i.push({type:"IntList",value:r})},AddFloat(r){i.push({type:"Float",value:r})},AddFloatList(r){i.push({type:"FloatList",value:r})},AddString(r){i.push({type:"String",value:r})},AddStringList(r){i.push({type:"StringList",value:r})},AddVector3(r){i.push({type:"Vector3",value:r})},AddVector3List(r){i.push({type:"Vector3List",value:r})},AddBool(r){i.push({type:"Bool",value:r})},AddBoolList(r){i.push({type:"BoolList",value:r})},AddGuid(r){i.push({type:"Guid",value:r})},AddGuidList(r){i.push({type:"GuidList",value:r})},AddEntity(r){i.push({type:"Entity",value:r})},AddEntityList(r){i.push({type:"EntityList",value:r})},AddPrefabId(r){i.push({type:"PrefabId",value:r})},AddPrefabIdList(r){i.push({type:"PrefabIdList",value:r})},AddConfigId(r){i.push({type:"ConfigId",value:r})},AddConfigIdList(r){i.push({type:"ConfigIdList",value:r})},SendSignal(){let r=i.slice();n.serverBridge&&typeof n.serverBridge.receiveFromClient=="function"&&n.serverBridge.receiveFromClient(t,r)}}}instantiate(t,i,n){if(n==="OnInit"||n==="OnDestroy")return null;let r=this.templates.get(Number(t));if(!r||!i)return null;let a=new Be(this,{...r,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(a),Ee(a,o=>this.controlsById.set(o.Id,o)),this.mountSpecScripts(r,a),a}destroyControl(t){if(!(!t||!t.alive)){if(t._destroying)throw new Error(`\u5BA2\u6237\u7AEF\u63A7\u4EF6\u751F\u547D\u5468\u671F\u5904\u4E8E\u521B\u5EFA\u6216\u9500\u6BC1\u65F6\uFF0C\u65E0\u6CD5\u8C03\u7528DestroyClientUIControl, ID:${t.name}`);Ee(t,i=>{i._destroying=!0}),this._destroyControlTree(t)}}_destroyControlTree(t){this.releaseControlListeners(t);for(let i of t.scripts.slice())this.unmountScript(i);for(let i of t.children.slice())this._destroyControlTree(i);if(t.alive=!1,this._playRemoved.push(t.Id),t.parent){let i=t.parent,n=i.children.indexOf(t);n>=0&&i.children.splice(n,1),t._parent=null,i.markPlayDirty(!0)}else{let i=this.roots.indexOf(t);i>=0&&this.roots.splice(i,1)}this.controlsById.delete(t.Id),this.focus===t&&(this.focus=null);for(let i of[...this.tweens])i.object===t&&i.Kill(!1)}releaseControlListeners(t){for(let i of t.cursorListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.keyListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.navListeners.values())for(let n of i)this.unrefLuaCallback(n);t.cursorListeners.clear(),t.keyListeners.clear(),t.navListeners.clear(),t.navConfig.clear()}onControlActiveChanging(t,i){let n=[];Ee(t,r=>n.push({control:r,was:r.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let r of n){let a=r.control.activeInHierarchy;if(r.was!==a)for(let o of r.control.scripts.slice())a?this.enableScript(o):this.disableScript(o)}}bindScriptEnv(t){let i=t.env;return i?(this.pushScript(i,t),u.lua_setglobal(i,_("script")),i):null}disableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="running")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnDisable"),t.lifecyclePhase="disabled",this.lifecyclePhase=i}enableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="disabled")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnEnable",t.lifecyclePhase="OnEnable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnEnable"),t.lifecyclePhase="running",this.lifecyclePhase=i}unmountScript(t){if(!t||!t.alive)return;let i=t.env,n=this.lifecyclePhase;i&&(t.lifecyclePhase==="running"&&(this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(i,"OnDisable")),this.lifecyclePhase="OnDestroy",t.lifecyclePhase="OnDestroy",this.bindScriptEnv(t),this.callGlobal(i,"OnDestroy")),t.alive=!1,t.lifecyclePhase="destroyed",this.lifecyclePhase=n,this.mountedScripts=this.mountedScripts.filter(r=>r!==t),t.object&&(t.object.scripts=t.object.scripts.filter(r=>r!==t)),this.varHandlers=this.varHandlers.filter(r=>r.script!==t),this.signalHandlers=this.signalHandlers.filter(r=>r.script!==t),i&&i!==this.L&&this.closeTrackedLuaState(i),t.env=null}installMetatables(t){this.mtEnum(t),this.mtControl(t),this.mtScript(t),this.mtTween(t),this.mtSeq(t),this.mtSignal(t),this.mtCursor(t)}mtIndexNewindex(t,i,n,r,a,o){te.luaL_newmetatable(t,_(i)),u.lua_pushcfunction(t,s=>{let c=Ye(s,1)||be(u.lua_touserdata(s,1)),l=K(s,2);if(a[l]&&(!o||o(c,l)))return u.lua_pushcfunction(s,a[l]),1;let f=n(c,l);return f===void 0?(u.lua_pushnil(s),1):(ae(s,this,f),1)}),u.lua_setfield(t,-2,_("__index")),u.lua_pushcfunction(t,s=>{try{let c=Ye(s,1)||be(u.lua_touserdata(s,1)),l=K(s,2),f=pe(s,this,3);return r(c,l,f),0}catch(c){return u.lua_pushstring(s,_(String(c.message||c))),u.lua_error(s)}}),u.lua_setfield(t,-2,_("__newindex")),u.lua_pushcfunction(t,s=>{let c=Ye(s,1)||be(u.lua_touserdata(s,1)),l=Ye(s,2)||be(u.lua_touserdata(s,2));return u.lua_pushboolean(s,c===l),1}),u.lua_setfield(t,-2,_("__eq")),u.lua_pop(t,1)}method(t){let i=this;return n=>{let r=Ye(n,1)||be(u.lua_touserdata(n,1)),a=u.lua_gettop(n),o=[];for(let s=2;s<=a;s++)o.push(pe(n,i,s));try{let s=t(r,...o);if(s===r)return u.lua_pushvalue(n,1),1;if(s===void 0)return 0;if(Array.isArray(s)&&s.__multi){for(let c of s)ae(n,i,c);return s.length}if(Array.isArray(s)&&!(s.length&&typeof s[0]=="object"&&s[0]?.typeofName)){if(s.__controls)return u.lua_createtable(n,s.length,0),s.forEach((c,l)=>{i.pushControl(n,c),u.lua_rawseti(n,-2,l+1)}),1;if(s.__scripts)return u.lua_createtable(n,s.length,0),s.forEach((c,l)=>{i.pushScript(n,c),u.lua_rawseti(n,-2,l+1)}),1;if(typeof s[0]=="number"&&s.length<=4){for(let c of s)u.lua_pushnumber(n,c);return s.length}}return ae(n,i,s),1}catch(s){return u.lua_pushstring(n,_(String(s.message||s))),u.lua_error(n)}}}mtEnum(t){let i=new Set(["Name","FullName","EnumType"]);this.mtIndexNewindex(t,"EnumItem",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{})}mtCursor(t){let i=new Set(["dragging","touchId"]);this.mtIndexNewindex(t,"CursorEventData",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{GetUIPos:this.method(n=>n.GetUIPos()),GetPressUIPos:this.method(n=>n.GetPressUIPos()),GetUIPosDelta:this.method(n=>n.GetUIPosDelta())})}mtControl(t){let i={GetChildren:this.method(n=>{let r=n.GetChildren();return r.__controls=!0,r}),GetChild:this.method((n,r)=>n.GetChild(r)),FindChild:this.method((n,r)=>n.FindChild(r)),SetActive:this.method((n,r)=>n.SetActive(r)),SetVisible:this.method((n,r)=>n.SetVisible(r)),GetSiblingIndex:this.method(n=>n.GetSiblingIndex()),SetSiblingIndex:this.method((n,r)=>n.SetSiblingIndex(r)),SetAsFirstSibling:this.method(n=>n.SetAsFirstSibling()),SetAsLastSibling:this.method(n=>n.SetAsLastSibling()),GetAnchoredPosition:this.method(n=>n.GetAnchoredPosition()),SetAnchoredPosition:this.method((n,r,a)=>n.SetAnchoredPosition(r,a)),GetSizeDelta:this.method(n=>n.GetSizeDelta()),SetSizeDelta:this.method((n,r,a)=>n.SetSizeDelta(r,a)),GetAnchorMin:this.method(n=>n.GetAnchorMin()),SetAnchorMin:this.method((n,r,a)=>n.SetAnchorMin(r,a)),GetAnchorMax:this.method(n=>n.GetAnchorMax()),SetAnchorMax:this.method((n,r,a)=>n.SetAnchorMax(r,a)),GetPivot:this.method(n=>n.GetPivot()),SetPivot:this.method((n,r,a)=>n.SetPivot(r,a)),GetLocalScale:this.method(n=>n.GetLocalScale()),SetLocalScale:this.method((n,r,a,o)=>n.SetLocalScale(r,a,o)),GetLocalRotation:this.method(n=>n.GetLocalRotation()),SetLocalRotation:this.method((n,r,a,o)=>n.SetLocalRotation(r,a,o)),GetScriptByPath:this.method((n,r)=>n.GetScriptByPath(r)),GetScript:this.method((n,r)=>n.GetScript(r)),GetScripts:this.method(n=>{let r=n.GetScripts();return r.__scripts=!0,r}),AddCursorEventListener:this.method((n,r,a)=>n.AddCursorEventListener(me(r),a)),RemoveCursorEventListener:this.method((n,r,a)=>n.RemoveCursorEventListener(me(r),a)),RemoveCursorEventListeners:this.method((n,r)=>n.RemoveCursorEventListeners(me(r))),RemoveAllCursorEventListeners:this.method(n=>n.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(n=>n.SimulateCursorClick()),AddKeyEventListener:this.method((n,r,a)=>n.AddKeyEventListener(me(r),a)),RemoveKeyEventListener:this.method((n,r,a)=>n.RemoveKeyEventListener(me(r),a)),RemoveKeyEventListeners:this.method((n,r)=>n.RemoveKeyEventListeners(me(r))),RemoveAllKeyEventListeners:this.method(n=>n.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((n,r,a)=>n.AddNavigationEventListener(me(r),a)),RemoveNavigationEventListener:this.method((n,r,a)=>n.RemoveNavigationEventListener(me(r),a)),RemoveNavigationEventListeners:this.method((n,r)=>n.RemoveNavigationEventListeners(me(r))),RemoveAllNavigationEventListeners:this.method(n=>n.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((n,r,a,o)=>n.SetControllerNavigation(me(r),a,o)),GetControllerNavigation:this.method((n,r)=>n.GetControllerNavigation(me(r))),SetImage:this.method((n,r,a)=>n.SetImage(r,a)),SetSoftEdgeWidth:this.method((n,r,a)=>n.SetSoftEdgeWidth(r,a)),SetFillUnused:this.method(n=>n.SetFillUnused()),SetFillHorizontal:this.method((n,r,a)=>n.SetFillHorizontal(r,a)),SetFillVertical:this.method((n,r,a)=>n.SetFillVertical(r,a)),SetFillRadial90:this.method((n,r,a)=>n.SetFillRadial90(r,a)),SetFillRadial180:this.method((n,r,a)=>n.SetFillRadial180(r,a)),SetFillRadial360:this.method((n,r,a)=>n.SetFillRadial360(r,a)),PlayAnimation:this.method(n=>n.PlayAnimation()),StopAnimation:this.method(n=>n.StopAnimation()),RefreshItems:this.method(n=>n.RefreshItems()),GetItemIndex:this.method(n=>n.GetItemIndex()),GetItemSize:this.method(n=>n.GetItemSize()),GetItemSpacing:this.method(n=>n.GetItemSpacing()),GetPadding:this.method(n=>n.GetPadding()),ScrollToItemAt:this.method(n=>n.ScrollToItemAt()),GetContentLength:this.method(n=>n.GetContentLength())};this.mtIndexNewindex(t,"Control",(n,r)=>{if(!fn(n,r))return;let a=n[r],o=fa[r];return o?hn(o,a):a},(n,r,a)=>{if(fn(n,r)==="rw"){let s=fa[r];n[r]=s?hn(s,a):a,typeof n.markPlayDirty=="function"&&n.markPlayDirty(hi.has(r));return}throw new Error(`cannot set ${r}, no such field`)},i,oa)}mtScript(t){let i=this,n=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(r,a)=>n.has(a)?r[a]:void 0,(r,a,o)=>{if(a==="enabled"){r.enabled=!!o;return}throw new Error(`cannot set ${a}, no such field`)},{GetParam:this.method((r,a)=>Object.prototype.hasOwnProperty.call(r.params,a)?r.params[a]:null),Invoke:this.method((r,a,...o)=>r.invoke(a,o)),EnableUpdate:this.method((r,a)=>{r.updateEnabled=!!a}),RegisterServerSignalHandler:this.method((r,a,o)=>{i.signalHandlers.push({script:r,name:a,fn:o})}),UnregisterServerSignalHandler:this.method((r,a)=>{i.signalHandlers=i.signalHandlers.filter(o=>!(o.script===r&&o.name===a))}),RegisterCustomVariableChangedHandler:this.method((r,a,o,s)=>{i.varHandlers.push({script:r,entityType:me(a),name:o,fn:s})}),UnregisterCustomVariableChangedHandler:this.method((r,a,o)=>{let s=me(a);i.varHandlers=i.varHandlers.filter(c=>!(c.script===r&&c.entityType===s&&c.name===o))})})}mtTween(t){this.mtIndexNewindex(t,"Tween",()=>{},()=>{},{SetEase:this.method((i,n)=>i.SetEase(n)),SetRelative:this.method((i,n)=>i.SetRelative(n)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSeq(t){this.mtIndexNewindex(t,"TweenSequence",()=>{},()=>{},{Append:this.method((i,n)=>i.Append(n)),AppendInterval:this.method((i,n)=>i.AppendInterval(n)),AppendCallback:this.method((i,n)=>i.AppendCallback(n)),Join:this.method((i,n)=>i.Join(n)),Insert:this.method((i,n,r)=>i.Insert(n,r)),InsertCallback:this.method((i,n,r)=>i.InsertCallback(n,r)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSignal(t){this.mtIndexNewindex(t,"ServerSignal",()=>{},()=>{},{AddParam:this.method((i,n,r)=>i.AddParam(n,r)),SendSignal:this.method(i=>i.SendSignal()),AddInt:this.method((i,n)=>i.AddInt(n)),AddIntList:this.method((i,n)=>i.AddIntList(n)),AddFloat:this.method((i,n)=>i.AddFloat(n)),AddFloatList:this.method((i,n)=>i.AddFloatList(n)),AddString:this.method((i,n)=>i.AddString(n)),AddStringList:this.method((i,n)=>i.AddStringList(n)),AddVector3:this.method((i,n)=>i.AddVector3(n)),AddVector3List:this.method((i,n)=>i.AddVector3List(n)),AddBool:this.method((i,n)=>i.AddBool(n)),AddBoolList:this.method((i,n)=>i.AddBoolList(n)),AddGuid:this.method((i,n)=>i.AddGuid(n)),AddGuidList:this.method((i,n)=>i.AddGuidList(n)),AddEntity:this.method((i,n)=>i.AddEntity(n)),AddEntityList:this.method((i,n)=>i.AddEntityList(n)),AddPrefabId:this.method((i,n)=>i.AddPrefabId(n)),AddPrefabIdList:this.method((i,n)=>i.AddPrefabIdList(n)),AddConfigId:this.method((i,n)=>i.AddConfigId(n)),AddConfigIdList:this.method((i,n)=>i.AddConfigIdList(n))})}luaRequire(t){let i=K(t,1),n=this.normalizeRequirePath(i),r=this.requireAliases.get(n)||n;u.lua_rawgeti(t,et,u.LUA_RIDX_MAINTHREAD);let a=u.lua_tothread(t,-1);u.lua_pop(t,1);let o=this.requireCache.get(a);o||(o=new Map,this.requireCache.set(a,o));let s=o.get(r);if(s?.loading)return u.lua_pushstring(t,_(`failed to load script '${n}': cyclic require`)),u.lua_error(t);if(s&&s.ref!=null)return u.lua_rawgeti(t,et,s.ref),1;let c=this.scriptFiles.get(r);if(c==null)return u.lua_pushstring(t,_(`failed to load script '${n}'`)),u.lua_error(t);let l=u.lua_gettop(t);o.set(r,{loading:!0});try{this.loadModule(t,a,r,c),u.lua_pushvalue(t,-1);let f=te.luaL_ref(t,et);return o.set(r,{ref:f}),1}catch(f){return o.delete(r),u.lua_settop(t,l),u.lua_pushstring(t,_(`failed to load script '${n}': ${f.message||f}`)),u.lua_error(t)}}newLuaThread(){let t=te.luaL_newstate();return Zr.luaL_openlibs(t),na(t),this.installMetatables(t),this.installGlobals(t),this.luaStates.add(t),u.lua_pushglobaltable(t),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.moduleBaseEnvironments.set(t,te.luaL_ref(t,et)),t}copyLuaEnvironment(t,i){let n=u.lua_absindex(t,i);u.lua_newtable(t);let r=u.lua_absindex(t,-1);for(u.lua_pushnil(t);u.lua_next(t,n)!==0;)u.lua_pushvalue(t,-2),u.lua_pushvalue(t,-2),u.lua_rawset(t,r),u.lua_pop(t,1);u.lua_pushvalue(t,r),u.lua_setfield(t,r,_("_G"))}closeTrackedLuaState(t){if(!t||!this.luaStates.has(t))return;for(let n of this.requireCache.get(t)?.values()||[])n.ref!=null&&te.luaL_unref(t,et,n.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&te.luaL_unref(t,et,i),this.moduleBaseEnvironments.delete(t),this.luaStates.delete(t),this.luaFunctions)for(let[n,r]of this.luaFunctions)r.__luaState===t&&this.luaFunctions.delete(n);ia(t)}loadModule(t,i,n,r){let a={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:n,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},o=String(r).replace(/^\uFEFF/,""),s=di(o);if(te.luaL_loadbuffer(t,s,s.length,_(`@${n}`))!==xe)throw new Error(K(t,-1));let l=u.lua_absindex(t,-1);if(u.lua_rawgeti(t,et,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.pushScript(t,a),u.lua_setfield(t,-2,_("script")),u.lua_setupvalue(t,l,1),u.lua_pcall(t,0,1,0)!==xe)throw new Error(K(t,-1))}mountScript({path:t,source:i,control:n,params:r={},scriptMappingId:a=void 0}){this.L||this.boot();let o=this.newLuaThread(),s={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(a),object:n,path:Ws(t),enabled:!0,updateEnabled:!1,params:r,env:o,lifecyclePhase:"idle"};s.invoke=(l,f)=>this.invokeOn(o,l,f),n&&n.scripts.push(s),this.mountedScripts.push(s),this.pushScript(o,s),u.lua_setglobal(o,_("script"));let c=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",s.lifecyclePhase="OnInit",this.runChunk(o,i,t);let l=this.callGlobal(o,"OnInit");l&&this.mountErrors.push(l),this.lifecyclePhase="OnEnable",s.lifecyclePhase="OnEnable";let f=this.callGlobal(o,"OnEnable");f&&this.mountErrors.push(f),this.lifecyclePhase="OnStart",s.lifecyclePhase="OnStart";let h=this.callGlobal(o,"OnStart");return h&&this.mountErrors.push(h),this.lifecyclePhase="running",s.lifecyclePhase="running",s}catch(l){throw s.alive=!1,s.lifecyclePhase="failed",this.mountedScripts=this.mountedScripts.filter(f=>f!==s),n&&(n.scripts=n.scripts.filter(f=>f!==s)),this.varHandlers=this.varHandlers.filter(f=>f.script!==s),this.signalHandlers=this.signalHandlers.filter(f=>f.script!==s),this.lifecyclePhase=c,o&&o!==this.L&&this.closeTrackedLuaState(o),s.env=null,l}}runChunk(t,i,n){let r=String(i).replace(/^\uFEFF/,""),a=di(r),o=te.luaL_loadbuffer(t,a,a.length,_(`@${n}`));if(o!==xe){let c=K(t,-1)||`luaL_loadbuffer status ${o}`;throw u.lua_pop(t,1),new Error(c)}let s=u.lua_pcall(t,0,0,0);if(s!==xe){let c=K(t,-1)||`lua_pcall status ${s}`;throw u.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(u.lua_getglobal(t,_(i)),u.lua_isfunction(t,-1)){if(u.lua_pcall(t,0,0,0)!==xe){let r=K(t,-1);u.lua_pop(t,1);let a=`${i}: ${r}`;return this.log("lua-error",a),a}}else u.lua_pop(t,1);return null}callGlobalDt(t,i,n){if(u.lua_getglobal(t,_(i)),u.lua_isfunction(t,-1)){if(u.lua_pushnumber(t,n),u.lua_pcall(t,1,0,0)!==xe){let a=K(t,-1);u.lua_pop(t,1),this.log("lua-error",`${i}: ${a}`)}}else u.lua_pop(t,1)}invokeOn(t,i,n){let r=u.lua_gettop(t);if(u.lua_getglobal(t,_(i)),!u.lua_isfunction(t,-1)){u.lua_settop(t,r);return}for(let c of n)ae(t,this,c);if(u.lua_pcall(t,n.length,Xs,0)!==xe){let c=K(t,-1);throw u.lua_settop(t,r),new Error(c)}let o=u.lua_gettop(t)-r;if(o<=0){u.lua_settop(t,r);return}if(o===1){let c=pe(t,this,-1);return u.lua_settop(t,r),c}let s=[];for(let c=1;c<=o;c++)s.push(pe(t,this,r+c));return u.lua_settop(t,r),s.__multi=!0,s}runScriptPhase(t,i){for(let n of this.mountedScripts){if(!this.scriptCanRun(n))continue;let r=n.env;r&&(this.pushScript(r,n),u.lua_setglobal(r,_("script")),!(t==="OnUpdate"&&!n.updateEnabled)&&this.callGlobalDt(r,t,i))}}step(t=1/30){if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new TypeError("dt must be a finite non-negative number");this.clock.frame++,this.clock.time+=t;let i=!this.clock.paused;for(let n of[...this.tweens])n.step(t);for(let n of[...this.sequences])n.step(t);this.runScriptPhase("OnUpdate",t),i&&(this.clock.levelTime+=t,this.runScriptPhase("OnLevelUpdate",t))}injectKey(t){let i=n=>{if(!n.alive||!n.activeInHierarchy)return!1;if(n.keyListeners.has(t)&&n.emitKey(t))return!0;for(let r of[...n.children])if(i(r))return!0;return!1};for(let n of[...this.roots])i(n)}injectCursor(t,i,n){let r=n||this.makeCursorEventData({});Number.isFinite(r.x)&&Number.isFinite(r.y)&&(this.cursor.x=r.x,this.cursor.y=r.y),t.emitCursor(i,r)}getVar(t,i){if(this.serverBridge&&typeof this.serverBridge.getVar=="function")return this.serverBridge.getVar(t,i);let n=this.serverVars[t];return n?n[i]:void 0}notifyVarHandlers(t,i){for(let n of this.varHandlers)this.scriptCanRun(n.script)&&n.entityType===t&&n.name===i&&this.safeCall(n.fn,this.enumTree.CustomVariableEntityType[t],i)}setVar(t,i,n){if(this.serverBridge&&typeof this.serverBridge.setVar=="function"){this.serverBridge.setVar(t,i,n);return}let r=this.serverVars[t]||(this.serverVars[t]=Object.create(null));r[i]=n,this.notifyVarHandlers(t,i)}sendClientSignal(t,i){for(let n of this.signalHandlers)this.scriptCanRun(n.script)&&n.name===t&&this.safeCall(n.fn,t,i)}evalQueryScript(t,i){this.L||this.boot();let n=this.L;u.lua_createtable(n,0,5);let r=(a,o)=>{u.lua_pushcfunction(n,o),u.lua_setfield(n,-2,_(a))};return r("var",a=>(ae(a,this,i.var(K(a,1),K(a,2))),1)),r("logContains",a=>(u.lua_pushboolean(a,i.logContains(K(a,1))),1)),r("control",a=>(ae(a,this,i.control(K(a,1))),1)),r("logs",a=>(ae(a,this,i.logs()),1)),r("signals",a=>(ae(a,this,i.signals(K(a,1))),1)),r("serverLogs",a=>(ae(a,this,i.serverLogs?i.serverLogs():[]),1)),r("serverLogContains",a=>{let o=i.serverLogContains;return u.lua_pushboolean(a,o?!!o(K(a,1)):!1),1}),u.lua_setglobal(n,_("query")),this.runChunk(n,t,"autotest-assert"),!0}destroy(){for(let t of this.roots.slice())this.destroyControl(t);for(let t of this.mountedScripts.slice())this.unmountScript(t);this.lifecyclePhase="idle",this.mountedScripts=[],this.luaFunctions.clear();for(let t of[...this.luaStates])this.closeTrackedLuaState(t);this.L=null}};function Bt(e){let t=new vi(e);return t.boot(),t}var it=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),yn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),va=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var mn=Object.freeze([...va,...it,...yn]),Sa=Object.freeze(["PlayerSelf","AllPlayers",...it]),qs=Object.freeze(["Level","PlayerSelf",...it]),da=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),js=-2147483648,Js=2147483647,Zs=new Set(["set-custom-variable","get-custom-variable","custom-variable-changed","\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF","\u83B7\u53D6\u81EA\u5B9A\u4E49\u53D8\u91CF","\u81EA\u5B9A\u4E49\u53D8\u91CF\u53D8\u5316\u65F6","send-signal","listen-signal","send-client-script-signal","\u53D1\u9001\u4FE1\u53F7","\u76D1\u542C\u4FE1\u53F7","\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7","setVar","getVar","signal","var"]);function Ut(e){return`Player${Number(e)}`}function Si(e){return`Avatar${Number(e)}`}function ha(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function tt(e){if(e==null||e==="")return 1;let t=Number(e);if(!Number.isInteger(t)||t<1||t>8)throw new Error("playerCount must be an integer 1-8");return t}function Pe(e,t=8){let i=tt(t);if(e==null||e==="")return 1;let n=Number(e);if(!Number.isInteger(n)||n<1||n>i)throw new Error(`playerIndex must be an integer 1-${i}`);return n}function pa(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of it)e[t]=Object.create(null);for(let t of yn)e[t]=Object.create(null);return e}function wa(e){let t=String(e||"");if(!mn.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function Qs(e,t){let i=wa(e);if(!qs.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function Ht(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function wi(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function gn(e){let t=String(e||"PlayerSelf");if(!Sa.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function Lt(e){if(e==null)return"";if(typeof e=="boolean")return"Bool";if(typeof e=="string")return"String";if(typeof e=="number")return Number.isInteger(e)?"Int":"Float";if(Array.isArray(e)){if(e.length===0)return"IntList";let t=Lt(e[0]);return t&&!t.endsWith("List")&&t!=="Dict"&&t!=="Struct"?`${t}List`:"IntList"}return e&&typeof e=="object"?"x"in e||"y"in e||"z"in e?"Vector3":"Dict":""}function ye(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function ma(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?t.value:t):[]}function ga(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?{type:String(t.type||""),value:t.value}:{type:Lt(t),value:t}):[]}function el(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function Ii(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ia(e,t){if(!Ii(e)||!Object.prototype.hasOwnProperty.call(e,"fromSignalParam"))return null;if(Object.keys(e).some(n=>n!=="fromSignalParam"))throw new Error(`${t}.fromSignalParam cannot be combined with literal fields`);let i=Number(e.fromSignalParam);if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t}.fromSignalParam must be a non-negative integer`);return{fromSignalParam:i}}function ya(e,t){return Ia(e,t)||ye(e)}function tl(e,t,i){if(!Ii(e))throw new Error(`serverLogic.rules[${t}].actions[${i}] must be an object`);let n=String(e.kind||e.type||""),r=`serverLogic.rules[${t}].actions[${i}]`;if(n==="setCustomVariable"){let a=Qs(e.entityType,r);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${r}.value is required`);return{kind:n,entityType:a,name:Ht(e.name),value:ya(e.value,`${r}.value`),...e.variableType?{variableType:String(e.variableType)}:{}}}if(n==="sendClientScriptSignal"){if(!Array.isArray(e.params))throw new Error(`${r}.params must be an array`);return{kind:n,target:gn(e.target),signalName:wi(e.signalName),params:e.params.map((a,o)=>ya(a,`${r}.params[${o}]`))}}throw new Error(`${r}.kind must be setCustomVariable or sendClientScriptSignal`)}function It(e){if(e==null)return{version:1,rules:[]};if(!Ii(e))throw new Error("serverLogic must be an object");let t=e.rules===void 0?[]:e.rules;if(!Array.isArray(t))throw new Error("serverLogic.rules must be an array");return{version:1,rules:t.map((i,n)=>{if(!Ii(i))throw new Error(`serverLogic.rules[${n}] must be an object`);if(!Array.isArray(i.actions)||i.actions.length===0)throw new Error(`serverLogic.rules[${n}].actions must be a non-empty array`);return{id:String(i.id||`signal-${n+1}`),signalName:wi(i.signalName),actions:i.actions.map((r,a)=>tl(r,n,a))}})}}function ba(e,t,{typed:i=!1}={}){let n=Ia(e,"server logic value");if(n){let r=i?t.params:t.values;if(n.fromSignalParam>=r.length)throw new Error(`signal ${t.name} has no parameter at index ${n.fromSignalParam}`);return ye(r[n.fromSignalParam])}return ye(e)}function il(e){return e==="Level"?"Level":it.includes(e)?"PlayerSelf":yn.includes(e)?"AvatarSelf":e}function Ca(e={}){let t=pa(),i=pa(),n=[],r=[],a=[],o=[],s=Array.from({length:9},()=>null),c=1,l=0,f=Number(e.onlineLatencyMs||0);(!Number.isFinite(f)||f<0)&&(f=0);let h=It(e.logic),p=tt(e.playerCount),m=Pe(e.viewPlayerIndex,p);function g(b,x){o.push({source:"server",level:String(b||"engine"),text:String(x),time:l})}function I(b){let x=s[b||m],v=Number(x?.clock?.time);Number.isFinite(v)&&(l=v)}function k(b,x,v,C){t[b][x]=v,i[b][x]={type:C||Lt(v)||i[b][x]?.type||""}}function E(b,x,v){return typeof v!="number"||!Number.isInteger(v)?{ok:!0,value:v}:v>=js&&v<=Js?{ok:!0,value:v}:(g("engine",`Int custom variable ${b}.${x} out of range ${v}; keeping previous legal value`),{ok:!1,value:t[b][x]})}function $(b,x){let v=wa(b),C=x||m;return v==="PlayerSelf"?Ut(C):v==="AvatarSelf"?Si(C):v}function O(b,x){let v=il(b);if(b==="Level"){for(let S=1;S<=p;S+=1){let P=s[S];P&&typeof P.notifyVarHandlers=="function"&&P.notifyVarHandlers("Level",x)}return}let C=ha(b);if(!C)return;let M=s[C];M&&typeof M.notifyVarHandlers=="function"&&M.notifyVarHandlers(v,x)}function Y(b,x){let v=gn(b);return v==="AllPlayers"?Array.from({length:p},(C,M)=>M+1):v==="PlayerSelf"?[x||m]:[ha(v)]}function W(b){for(let x of h.rules)if(x.signalName===b.name)for(let v of x.actions){if(v.kind==="setCustomVariable"){let C=ba(v.value,b);N.setVar(v.entityType,v.name,C,{type:v.variableType,playerIndex:b.playerIndex}),g("info",`logic ${x.id}: set ${v.entityType}.${v.name}`);continue}if(v.kind==="sendClientScriptSignal"){let C=v.params.map(M=>ba(M,b,{typed:!0}));N.sendToClient(v.signalName,C,{target:v.target,playerIndex:b.playerIndex}),g("info",`logic ${x.id}: sent ${v.signalName} to ${v.target}`)}}}function Z(b,x){b&&(b.serverBridge={getVar:(v,C)=>N.getVar(v,C,{playerIndex:x}),setVar:(v,C,M)=>N.setVar(v,C,M,{playerIndex:x}),receiveFromClient:(v,C)=>N.receiveFromClient(v,C,{playerIndex:x})})}function q(b){b&&(b.serverBridge=null)}let N={ENTITY_TYPES:va,ALL_ENTITY_TYPES:mn,CLIENT_SIGNAL_TARGETS:Sa,get clock(){return l},get playerCount(){return p},get viewPlayerIndex(){return m},setClock(b){l=Number(b)||0},setPlayerCount(b){return p=tt(b),m>p&&(m=p),p},setViewPlayerIndex(b){return m=Pe(b,p),m},log(b,x){g(b,x)},defineVar(b,x,v={},{playerIndex:C}={}){let M=$(b,C),S=Ht(x);if(Object.prototype.hasOwnProperty.call(t[M],S))throw new Error(`custom variable already exists: ${M}.${S}`);let P=v.type?String(v.type):Lt(v.value??v.defaultValue);if(P&&!da.includes(P))throw new Error(`unsupported custom variable type: ${P}`);let G=v.value!==void 0?v.value:v.defaultValue!==void 0?v.defaultValue:null;return k(M,S,G,P),N.getVar(M,S)},getVar(b,x,{playerIndex:v}={}){let C=$(b,v),M=Ht(x);if(!Object.prototype.hasOwnProperty.call(t[C],M)){g("engine",`GetGlobalCustomVariableValue missing ${C}.${M}; returning nil (simulator policy)`);return}return t[C][M]},setVar(b,x,v,{notify:C=!0,type:M,playerIndex:S}={}){let P=$(b,S),G=Ht(x),z=M||i[P][G]?.type||Lt(v);if(z&&!da.includes(z)&&z!=="")throw new Error(`unsupported custom variable type: ${z}`);let ne=v;if(!((z==="Int"||z===""&&typeof v=="number"&&Number.isInteger(v))&&(ne=E(P,G,v).value,ne===void 0)))return k(P,G,ne,z),C&&O(P,G),ne},listVars(b){let x=b?[$(b)]:["Level",...Array.from({length:p},(C,M)=>Ut(M+1)),...Array.from({length:p},(C,M)=>Si(M+1))],v=[];for(let C of x)for(let M of Object.keys(t[C]))v.push({entityType:C,name:M,type:i[C][M]?.type||"",value:ye(t[C][M])});return v},receiveFromClient(b,x=[],{playerIndex:v}={}){let C=Pe(v||m,p);I(C);let M=wi(b),S={id:c++,direction:"inbound",name:M,params:ga(x),values:ma(x),time:l,playerIndex:C,from:Ut(C)};return n.push(S),W(S),S},sendToClient(b,x=[],{target:v="PlayerSelf",playerIndex:C}={}){let M=wi(b),S=gn(v),G=Y(S,C||m),z={id:c++,direction:"outbound",name:M,params:ga(x),values:ma(x),time:l,target:S,players:G,deliverAt:l+f/1e3,delivered:!1};return r.push(z),f===0?N.deliver(z):a.push(z),z},getLogic(){return ye(h)},setLogic(b){return h=It(b),N.getLogic()},deliver(b){if(!b||b.delivered)return;b.delivered=!0;let x=Array.isArray(b.players)&&b.players.length?b.players:Y(b.target);for(let v of x){let C=s[v];C&&typeof C.sendClientSignal=="function"&&C.sendClientSignal(b.name,b.values)}},flush(b){b!==void 0&&(l=Number(b)||0);let x=[];for(let v=a.length-1;v>=0;v-=1)a[v].deliverAt<=l&&x.push(a.splice(v,1)[0]);x.sort((v,C)=>v.id-C.id);for(let v of x)N.deliver(v);return x},inbound(){return n.slice()},outbound(){return r.slice()},loadConfig(b){if(b!=null){if(typeof b!="object")throw new Error("server config must be an object");if(b.graph&&!Array.isArray(b.nodes))throw new Error("unsupported server node graph: v1 only accepts custom variables and signals");for(let x of b.nodes||[]){let v=el(x);if(!Zs.has(v))throw new Error(`unsupported server node: ${v||JSON.stringify(x)}. v1 only supports custom variables and signals`)}if(b.onlineLatencyMs!==void 0){let x=Number(b.onlineLatencyMs);if(!Number.isFinite(x)||x<0)throw new Error("onlineLatencyMs must be a non-negative finite number");f=x}b.playerCount!==void 0&&N.setPlayerCount(b.playerCount),b.viewPlayerIndex!==void 0&&N.setViewPlayerIndex(b.viewPlayerIndex),(b.logic!==void 0||b.serverLogic!==void 0)&&N.setLogic(b.logic??b.serverLogic);for(let x of b.vars||[]){let v=$(x.entityType),C=Ht(x.name);Object.prototype.hasOwnProperty.call(t[v],C)?N.setVar(v,C,x.value??x.defaultValue,{notify:!1,type:x.type}):N.defineVar(v,C,x)}}},attachRuntime(b,{playerIndex:x=1}={}){let v=Pe(x,8);return s[v]&&s[v]!==b&&q(s[v]),s[v]=b||null,Z(s[v],v),N},attachRuntimes(b){N.detachRuntime();let x=Array.isArray(b)?b:[];for(let v=0;v<x.length&&v<8;v+=1)s[v+1]=x[v]||null,Z(s[v+1],v+1);return N},detachRuntime(){for(let b=1;b<=8;b+=1)q(s[b]),s[b]=null},snapshot(){let b=Ut(m),x=Si(m),v={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let C of Object.keys(t.Level))v.Level[C]={type:i.Level[C]?.type||"",value:ye(t.Level[C])};for(let C of Object.keys(t[b]))v.PlayerSelf[C]={type:i[b][C]?.type||"",value:ye(t[b][C])};for(let C of Object.keys(t[x]))v.AvatarSelf[C]={type:i[x][C]?.type||"",value:ye(t[x][C])};for(let C=1;C<=p;C+=1){let M=Ut(C),S=Si(C);v[M]={},v[S]={};for(let P of Object.keys(t[M]))v[M][P]={type:i[M][P]?.type||"",value:ye(t[M][P])};for(let P of Object.keys(t[S]))v[S][P]={type:i[S][P]?.type||"",value:ye(t[S][P])}}return{clock:l,onlineLatencyMs:f,playerCount:p,viewPlayerIndex:m,logic:N.getLogic(),vars:v,inbound:n.map(C=>({id:C.id,name:C.name,params:ye(C.params),values:ye(C.values),time:C.time,playerIndex:C.playerIndex,from:C.from})),outbound:r.map(C=>({id:C.id,name:C.name,params:ye(C.params),values:ye(C.values),time:C.time,target:C.target,players:Array.isArray(C.players)?C.players.slice():[],deliverAt:C.deliverAt,delivered:!!C.delivered})),logs:o.map(C=>({source:"server",level:C.level,text:C.text,time:C.time}))}},reset(){for(let b of mn){for(let x of Object.keys(t[b]))delete t[b][x];for(let x of Object.keys(i[b]))delete i[b][x]}n.length=0,r.length=0,a.length=0,o.length=0,c=1,l=0},destroy(){N.detachRuntime(),N.reset()}};e.config&&N.loadConfig(e.config);for(let b of e.vars||[])N.defineVar(b.entityType,b.name,b);return N}var nl={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function bn(e,t,i=null){let n=Ge(e.transformByPlatform,t),r={authoringId:e.id,kind:nl[e.kind]||"container",name:e.name,prefabIndex:e.guid||0,active:e.active!==!1,visible:e.visible!==!1,canControllerFocus:e.canControllerFocus===!0,anchoredPositionX:n.offset.x,anchoredPositionY:n.offset.y,sizeDeltaX:n.size.x,sizeDeltaY:n.size.y,anchorMinX:n.anchorMin.x,anchorMinY:n.anchorMin.y,anchorMaxX:n.anchorMax.x,anchorMaxY:n.anchorMax.y,pivotX:n.pivot.x,pivotY:n.pivot.y,localScaleX:n.scale.x,localScaleY:n.scale.y,localScaleZ:n.scale.z,localRotationX:n.rotation.x,localRotationY:n.rotation.y,localRotationZ:n.rotation.z,children:(e.children||[]).map(o=>bn(o,t,i))},a=i?.get(e.id);return a?.length&&(r.scripts=a.map(o=>{let s=Number(o.guid);return{path:o.path||o.id,source:o.source||"",...Number.isSafeInteger(s)&&s>0?{scriptMappingId:s}:{}}})),e.kind==="container"&&(r.isolateNavigation=e.isolateNavigation===!0,r.disableKeyEventPassthrough=e.disableKeyEventPassthrough===!0,r.disableCursorEventPassthrough=e.disableCursorEventPassthrough===!0,r.showCursor=e.showCursor===!0),(e.kind==="textbox"||e.kind==="textwindow")&&(r.text=e.text??"",r.fontSize=e.fontSize,r.adaptiveFontSize=e.adaptiveFontSize===!0,r.minimumFontSize=e.minimumFontSize,r.fontColor=e.fontColor,r.bgColor=e.bgColor,r.enableOutline=e.enableOutline!==!1,r.outlineColor=e.outlineColor,r.horizontalAlignment=e.horizontalAlignment||"Left",r.verticalAlignment=e.verticalAlignment||"Top",e.kind==="textwindow"&&(r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1)),e.kind==="image"&&(r.imageSource=e.imageSource,r.imageId=e.imageId??0,r.imageColor=e.imageColor,r.raycastTarget=e.raycastTarget===!0,r.enableMask=e.enableMask===!0,r.enableSoftEdge=e.enableSoftEdge===!0,r.softEdgeMode=e.softEdgeMode,r.softEdgeWidthX=e.softEdgeWidthX,r.softEdgeWidthY=e.softEdgeWidthY,r.horizontalSoftRange=e.horizontalSoftRange,r.verticalSoftRange=e.verticalSoftRange,r.enableFill=e.enableFill===!0,r.fillType=e.enableFill?e.fillType:"Unused",r.fillHorizontalType=e.fillHorizontalType,r.fillVerticalType=e.fillVerticalType,r.fillRadial90Type=e.fillRadial90Type,r.fillRadialType=e.fillRadialType,r.fillAmount=e.fillAmount,r.reverseMaskArea=e.reverseMaskArea===!0),e.kind==="button"&&(r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.clickAudioId=e.clickAudioId,r.unavailableChildId=e.unavailableChildId??null,r.hoverChildId=e.hoverChildId??null,r.pressedChildId=e.pressedChildId??null,r.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(r.raycastTarget=e.raycastTarget!==!1),e.kind==="reference"&&(r.referencedPrefabIndex=e.referencedPrefabId),e.kind==="grid"&&(r.itemPrefabIndex=e.itemPrefabId,r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1,r.scrollDirection=e.scrollDirection,r.layoutConstraint=e.layoutConstraint,r.layoutConstraintFixedCount=e.layoutConstraintFixedCount,r.cellSizeX=e.cellSizeX,r.cellSizeY=e.cellSizeY,r.spacingX=e.spacingX,r.spacingY=e.spacingY,r.padding1X=e.padding1X,r.padding1Y=e.padding1Y,r.padding2X=e.padding2X,r.padding2Y=e.padding2Y,r.previewCount=e.previewCount),e.kind==="keyhint"&&(r.keyboardKeyCode=e.keyboardKeyCode,r.controllerKeyCode=e.controllerKeyCode),(e.kind==="animation"||e.kind==="fullscreen")&&(r.raycastTarget=!1,r.animationId=e.animationId,r.playSoundEffect=e.playSoundEffect,e.kind==="animation"&&(r.layer=e.layer)),r}function vn(e,t=[],i=""){let n=i&&X[i]?i:e.canvasId,r=X[n],a=Dt(e),o=new Map;for(let c of t){if(!c.controlId)continue;let l=o.get(c.controlId)||[];l.push(c),o.set(c.controlId,l)}let s=e.meta?.assetType==="client-control-template"?(e.root.children||[]).map(c=>bn(c,n,o)):[];return{canvasId:n,platform:r.platform,device:r.luaDevice,canvasWidth:r.width,canvasHeight:r.height,root:bn(a,n,o),templates:s}}var Ci="qxqy-autotest";var nt=.03333333333333333,rl=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),al=new Set(["log","control","var","signal","tree","lua"]);function Xt(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function Sn(e){return JSON.parse(JSON.stringify(e??null))}function ki(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!rl.has(i))throw new Error(`unsupported event kind: ${i||"(empty)"}`);let n=e.payload&&typeof e.payload=="object"?{...e.payload}:{};if(i==="pointer")!n.type&&e.type&&(n.type=e.type),n.x===void 0&&(n.x=e.x),n.y===void 0&&(n.y=e.y),n.x=Xt(n.x,"pointer.x"),n.y=Xt(n.y,"pointer.y"),n.type=String(n.type||"click");else if(i==="key"){if(n.typeName=String(n.typeName||n.key||e.typeName||e.key||""),!n.typeName)throw new Error("key event requires typeName")}else if(i==="click"){if(n.name=String(n.name||e.name||""),!n.name)throw new Error("click event requires control name")}else if(i==="serverSet"){if(n.entityType=String(n.entityType||e.entityType||""),n.name=String(n.name||e.name||""),n.value===void 0&&(n.value=e.value),n.value===void 0&&(n.value=null),!n.entityType||!n.name)throw new Error("serverSet requires entityType and name")}else if(i==="serverSend"){if(n.name=String(n.name||e.name||""),n.params=Array.isArray(n.params)?n.params:Array.isArray(e.params)?e.params:[],n.target=String(n.target||e.target||"PlayerSelf"),!n.name)throw new Error("serverSend requires signal name")}else if(i==="view"&&(n.playerIndex=Number(n.playerIndex||n.viewPlayerIndex||e.playerIndex||e.viewPlayerIndex||0),!Number.isInteger(n.playerIndex)||n.playerIndex<1))throw new Error("view event requires playerIndex 1-8");return{t:Xt(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:n}}function wn(e,t){if(!e||typeof e!="object")throw new Error(`asserts[${t}] must be an object`);let i=String(e.kind||(e.check?"log":""));if(!al.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let n={kind:i};if(e.at!==void 0&&(n.at=Xt(e.at,"assert.at")),i==="log"){if(n.contains=String(e.contains||e.check||e.text||""),n.source=e.source==="server"?"server":"client",e.level&&(n.level=String(e.level)),!n.contains)throw new Error("log assert requires contains")}else if(i==="control"){if(n.id=e.id?String(e.id):"",n.name=e.name?String(e.name):"",n.field=String(e.field||""),!n.field)throw new Error("control assert requires field");if(!n.id&&!n.name)throw new Error("control assert requires id or name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("control assert requires equals");n.equals=Sn(e.equals)}else if(i==="var"){if(n.entityType=String(e.entityType||""),n.name=String(e.name||""),!n.entityType||!n.name)throw new Error("var assert requires entityType and name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("var assert requires equals");n.equals=Sn(e.equals)}else if(i==="signal"){if(n.direction=e.direction==="outbound"?"outbound":"inbound",n.name=String(e.name||""),!n.name)throw new Error("signal assert requires name");e.values!==void 0&&(n.values=Sn(e.values))}else if(i==="tree"){if(n.name=String(e.name||""),n.exists=e.exists!==!1,!n.name)throw new Error("tree assert requires name")}else if(i==="lua"&&(n.source=String(e.source||""),!n.source.trim()))throw new Error("lua assert requires source");return n}function ka(e){let t=0,i=[],n=[];for(let r of e){if(!r||typeof r!="object")throw new Error("queue step must be an object");if(r.do!=="start"){if(r.do==="step"){t+=Xt(r.dt??nt,"step.dt");continue}if(r.do==="pointer"||r.do==="key"||r.do==="click"||r.do==="pause"||r.do==="resume"||r.do==="serverSet"||r.do==="serverSend"||r.do==="view"){i.push(ki({...r,kind:r.do,t},i.length));continue}if(r.assert||r.check||r.kind){n.push(wn({...r.assert||r,at:r.at??t},n.length));continue}throw new Error(`unsupported queue step: ${JSON.stringify(r)}`)}}return{events:i,asserts:n,dt:nt}}function Kt(e){if(Array.isArray(e)){let n=ka(e);return{format:Ci,version:1,name:"",dt:n.dt,events:n.events,asserts:n.asserts}}if(!e||typeof e!="object")throw new Error("autotest case must be an object or step array");if(Array.isArray(e.queue)||Array.isArray(e.steps)){let n=ka(e.queue||e.steps);return{format:Ci,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):n.dt,events:n.events,asserts:n.asserts}}let t=(e.events||[]).map((n,r)=>ki(n,r)),i=(e.asserts||[]).map((n,r)=>wn(n,r));return t.sort((n,r)=>n.t-r.t||0),{format:Ci,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):nt,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function xa(e,t={}){let i=(e||[]).map((n,r)=>ki(n,r));return{format:Ci,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):nt,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((n,r)=>wn(n,r))}}function Ea(e,t,i){if(!e)return null;let n=ki({...t,t:t.t??i??0},e.events.length);return e.events.push(n),n}var ol=Object.freeze(Object.values(X).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function xn(e){let t=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function n(r,a,o){let s=Ae(a,r);s.activeInHierarchy=o&&r.active!==!1,i.set(r.Id,s);let c=s.activeInHierarchy;for(let l of r.children)n(l,s,c)}for(let r of e.runtime.roots)n(r,t,!0);return i}function sl(e,t=xn(e)){let i=new Map;function n(r,a){let o=t.get(r.Id);if(!o)return;let s=$t(a,o,r);i.set(r.Id,s);for(let c of r.children)n(c,s)}for(let r of e.runtime.roots)n(r,yt());return i}function _a(e,t){let i=t.get(e.Id);return{id:e.Id,prefabId:e.prefabIndex,authoringId:e.authoringId,name:e.name,kind:e.kind,typeofName:e.typeofName,instantiated:!e.authoringId,active:!!e.active,visible:!!e.visible,activeInHierarchy:!!i?.activeInHierarchy,raycastTarget:e.raycastTarget!==!1,interactable:e.interactable!==!1,pressed:e.pressed===!0,anchoredPositionX:e.anchoredPositionX,anchoredPositionY:e.anchoredPositionY,sizeDeltaX:e.sizeDeltaX,sizeDeltaY:e.sizeDeltaY,localScaleX:e.localScaleX,localScaleY:e.localScaleY,localScaleZ:e.localScaleZ,localRotationZ:e.localRotationZ,text:e.kind==="textbox"||e.kind==="textwindow"?e.text??"":null,fontSize:e.kind==="textbox"||e.kind==="textwindow"?e.fontSize:null,fontColor:e.kind==="textbox"||e.kind==="textwindow"?e.fontColor:null,bgColor:e.kind==="textbox"||e.kind==="textwindow"?e.bgColor:null,enableOutline:e.kind==="textbox"||e.kind==="textwindow"?e.enableOutline===!0:null,outlineColor:e.kind==="textbox"||e.kind==="textwindow"?e.outlineColor:null,imageId:e.kind==="image"?e.imageId??0:null,primitive:e.kind==="image"?mt[e.imageId]||"missing":null,imageColor:e.kind==="image"?e.imageColor:null,enableMask:e.kind==="image"?e.enableMask===!0:null,enableSoftEdge:e.kind==="image"?e.enableSoftEdge===!0:null,softEdgeMode:e.kind==="image"?e.softEdgeMode:null,softEdgeWidthX:e.kind==="image"?e.softEdgeWidthX:null,softEdgeWidthY:e.kind==="image"?e.softEdgeWidthY:null,horizontalSoftRange:e.kind==="image"?e.horizontalSoftRange:null,verticalSoftRange:e.kind==="image"?e.verticalSoftRange:null,enableFill:e.kind==="image"?e.enableFill===!0:null,fillType:e.kind==="image"?e.fillType:null,fillHorizontalType:e.kind==="image"?e.fillHorizontalType:null,fillVerticalType:e.kind==="image"?e.fillVerticalType:null,fillRadial90Type:e.kind==="image"?e.fillRadial90Type:null,fillRadialType:e.kind==="image"?e.fillRadialType:null,reverseMaskArea:e.kind==="image"?e.reverseMaskArea===!0:null,fillAmount:e.kind==="image"?e.fillAmount:null,box:i?{left:i.left,bottom:i.bottom,width:i.width,height:i.height}:null,children:e.children.map(n=>_a(n,t))}}function ll(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function ul(e,t,i){let n=Bt({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device});for(let r of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(r.prefabIndex)&&r.prefabIndex>0&&n.registerTemplate(r.prefabIndex,r);for(let r of i){let a=r.path||r.id,o=r.source||"";a&&o&&n.registerScriptFile(a,o)}return n}var cl=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","hoveredControl","selectedControl","stateRestores","viewCache"];function fl(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of cl)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return e.views[e.viewPlayerIndex-1][t]},set(i){e.views[e.viewPlayerIndex-1][t]=i}})}function Pa(e,{templatesProject:t=null,scripts:i=[],sceneScripts:n=null,templateScripts:r=null,serverConfig:a=null,canvasId:o="",playerCount:s=1,viewPlayerIndex:c=1}={}){let l=n||i,f=r||i,h=vn(e,l,o),p=t?vn(t,f,o):null,m=tt(s),g=Pe(c,m),I=Ca({playerCount:m,viewPlayerIndex:g});a&&I.loadConfig({...a,playerCount:m,viewPlayerIndex:g});let k=[];for(let O=0;O<m;O+=1)k.push(ul(h,p,i));I.attachRuntimes(k);for(let O of k)O.addRoot(h.root);let E={runtimes:k,views:k.map(()=>ll()),playerCount:m,viewPlayerIndex:g,server:I,compiled:h,mountError:k.find(O=>O.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};fl(E);let $=E.viewPlayerIndex;for(let O=1;O<=m;O+=1)E.viewPlayerIndex=O,Cl(E);return E.viewPlayerIndex=$,E}function En(e,t){if(!e)throw new Error("play session has not started");let i=Pe(t,e.playerCount);return i===e.viewPlayerIndex||(Ue(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function Ue(e,t){!e?.recording||!e.history||Ea(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function dl(e){return e?.history?.events||[]}var An=new Set(["image","textbox","textwindow","button"]);function hl(e,t){let i=Xe(t,e.centerX,e.centerY);return{centerX:i.x,centerY:i.y,scaleX:Math.hypot(t.a,t.b),scaleY:Math.hypot(t.c,t.d),rotationZ:Math.atan2(t.b,t.a)*180/Math.PI,matrix:{a:t.a,b:t.b,c:t.c,d:t.d,tx:i.x,ty:i.y}}}function rt(e){return typeof e=="string"?e:e?.Name}function Ra(e){return{fillType:rt(e.fillType),fillHorizontalType:rt(e.fillHorizontalType),fillVerticalType:rt(e.fillVerticalType),fillAmount:e.fillAmount}}function pl(e,t,i){let n=Math.abs(t.width*i.scaleX),r=Math.abs(t.height*i.scaleY),a={id:e.Id,kind:e.kind,name:e.name,left:i.centerX-n/2,bottom:i.centerY-r/2,width:n,height:r,sourceWidth:t.width,sourceHeight:t.height,rotationZ:i.rotationZ,matrix:i.matrix,pressed:e.pressed===!0};return e.kind==="image"&&(a.primitive=mt[e.imageId]||"missing",a.imageColor=e.imageColor,a.imageId=e.imageId,Object.assign(a,Ra(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(a.text=e.text??"",a.fontSize=e.fontSize,a.fontColor=e.fontColor,a.bgColor=e.bgColor,a.enableOutline=e.enableOutline===!0,a.outlineColor=e.outlineColor,a.horizontalAlignment=rt(e.horizontalAlignment),a.verticalAlignment=rt(e.verticalAlignment)),a}function ml(e,t=xn(e)){let i=[],n=sl(e,t);function r(a){let o=t.get(a.Id);if(!o||a.visible===!1||!o.activeInHierarchy)return;let s=n.get(a.Id);if(!s)return;let c=hl(o,s);An.has(a.kind)&&i.push(pl(a,o,c));let l=a.children||[];for(let f=l.length-1;f>=0;f-=1)r(l[f])}for(let a of e.runtime.roots)r(a);return i}function gl(e,t){let i={kind:e.kind,name:e.name,sourceWidth:t.width,sourceHeight:t.height,pressed:e.pressed===!0};return e.kind==="image"&&(i.primitive=mt[e.imageId]||"missing",i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,Ra(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(i.text=e.text??"",i.fontSize=e.fontSize,i.fontColor=e.fontColor,i.bgColor=e.bgColor,i.enableOutline=e.enableOutline===!0,i.outlineColor=e.outlineColor,i.horizontalAlignment=rt(e.horizontalAlignment),i.verticalAlignment=rt(e.verticalAlignment)),i}function yl(e,t,i){let n=zi(e,t),r=Xe(n,e.centerX,e.centerY);return{a:n.a,b:n.b,c:n.c,d:n.d,tx:r.x-(i?i.centerX:0),ty:r.y-(i?i.centerY:0)}}function Ta(e){let t=e.matrix;return[e.parent,e.z,e.group?1:0,t.a,t.b,t.c,t.d,t.tx,t.ty,e.kind,e.name,e.sourceWidth,e.sourceHeight,e.pressed,e.primitive,e.imageColor,e.imageId,e.fillType,e.fillHorizontalType,e.fillVerticalType,e.fillAmount,e.text,e.fontSize,e.fontColor,e.bgColor,e.enableOutline,e.outlineColor,e.horizontalAlignment,e.verticalAlignment].join(" ")}function Ma(e,t,i,n,r,a){return{id:e.Id,parent:t,z:r,group:a>=16,matrix:yl(n,e,i),...gl(e,n)}}function bl(e){let t=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,n=new Map,r=new Map;function a(c,l,f){let h=Ae(l,c);if(h.activeInHierarchy=f&&c.active!==!1,r.set(c.Id,h),c.visible===!1||!h.activeInHierarchy)return!1;let p=c.children||[],m=An.has(c.kind),g=0;for(let I=0;I<p.length;I+=1)a(p[I],h,h.activeInHierarchy)&&(m=!0,g+=1);return m?(i.add(c.Id),n.set(c.Id,g),!0):!1}function o(c,l,f,h){if(!i.has(c.Id))return;let p=r.get(c.Id);s.push(Ma(c,l,f,p,h,n.get(c.Id)||0));let m=c.children||[];for(let g=0;g<m.length;g+=1)o(m[g],c.Id,p,g)}let s=[];for(let c=0;c<e.runtime.roots.length;c+=1)a(e.runtime.roots[c],t,!0),o(e.runtime.roots[c],null,null,c);return{nodes:s,childCounts:n}}function kn(e){let t=e._playChildDirty===!0||e._playDeepDirty===!0;if(e._playDirty=!1,e._playChildDirty=!1,e._playDeepDirty=!1,!t)return;let i=e.children;for(let n=0;n<i.length;n+=1)kn(i[n])}function vl(e,t){let i=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=[],r=[],a=t.count,o=e.runtime._playRemoved||[];for(let l=0;l<o.length;l+=1){let f=o[l];t.fingerprints.has(f)&&(r.push(f),t.fingerprints.delete(f),t.childCounts.delete(f),a-=1)}e.runtime._playRemoved=[];function s(l){t.fingerprints.has(l.Id)&&(r.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),a-=1);let f=l.children;for(let h=0;h<f.length;h+=1)s(f[h])}function c(l,f,h,p,m,g){let I=g||l._playDeepDirty===!0,k=I||l._playDirty===!0,E=I||l._playChildDirty===!0;if(!k&&!E)return;if(!(m&&l.active!==!1)||l.visible===!1){s(l);return}let O=Ae(f,l),Y=t.childCounts.get(l.Id)||0;if(E){Y=0;let x=l.children;for(let v=0;v<x.length;v+=1)c(x[v],O,l.Id,v,!0,I),t.fingerprints.has(x[v].Id)&&(Y+=1)}if(!(An.has(l.kind)||Y>0)){t.fingerprints.has(l.Id)&&(r.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),a-=1);return}let Z=t.childCounts.get(l.Id);t.childCounts.set(l.Id,Y);let q=Y>=16!=(Z||0)>=16;if(!k&&!q&&t.fingerprints.has(l.Id))return;let N=Ma(l,h,f===i?null:f,O,p,Y),b=Ta(N);t.fingerprints.get(N.id)!==b&&(t.fingerprints.has(N.id)||(a+=1),t.fingerprints.set(N.id,b),n.push(N))}for(let l=0;l<e.runtime.roots.length;l+=1)c(e.runtime.roots[l],i,null,l,!0,!1);return t.count=a,{changed:n,removed:r,count:a}}function Sl(e,t){let i=e.viewCache||(e.viewCache={rev:0,fingerprints:new Map,childCounts:new Map,count:0}),n=Number(t);if(!(Number.isFinite(n)&&n===i.rev&&i.fingerprints.size>0)){let{nodes:c,childCounts:l}=bl(e);i.rev+=1,i.fingerprints=new Map(c.map(f=>[f.id,Ta(f)])),i.childCounts=l,i.count=c.length;for(let f of e.runtime.roots)kn(f);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:a,removed:o,count:s}=vl(e,i);i.rev+=1;for(let c of e.runtime.roots)kn(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:s,changed:a,removed:o}}function _n(e,{inspect:t=!1,view:i=!1,paint:n=!1,sceneRev:r,compact:a=!1}={}){let o=e.runtime,s=e.compiled,[c,l]=[o.canvasWidth,o.canvasHeight];e.server&&e.server.setClock(o.clock.time);let f=a?o.logs.slice(-100):o.logs,h=dl(e),p=e.server?e.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};a&&(p.inbound=p.inbound.slice(-100),p.outbound=p.outbound.slice(-100),p.logs=p.logs.slice(-100));let m={canvasId:s.canvasId,platform:s.platform,device:o.device,canvasWidth:c,canvasHeight:l,canvasPresets:ol,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(g,I)=>({index:I+1,label:`\u73A9\u5BB6${I+1}`,entityType:`Player${I+1}`})),time:o.clock.time,frame:o.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!o.clock.paused,mountError:e.mountError||o.mountErrors[0]||null,logs:f.map(g=>({source:"client",level:g.level,text:g.text,time:g.time})),tree:[],paint:[],scene:null,server:p,history:(a?h.slice(-100):h).map(g=>({t:g.t,source:g.source||"user",kind:g.kind,payload:g.payload||{}}))};if(t||n){let g=xn(e);t&&(m.tree=o.roots.map(I=>_a(I,g))),n&&(m.paint=ml(e,g))}return i&&(m.scene=Sl(e,r)),gt(m),m}function xi(e,t=1/30){let i=e.runtimes||(e.runtime?[e.runtime]:[]);for(let n of i)n.step(t);e.server&&(e.server.setClock(e.runtime.clock.time),e.server.flush())}function Pn(e,t){Ue(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function wl(e,t){let i=null;for(let n of e.runtime.roots)Ee(n,r=>{!i&&r.name===t&&(i=r)});return i}function Rn(e,t){Ue(e,{kind:"click",payload:{name:String(t)}});let i=wl(e,t);i&&Tn(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function Il(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var Na={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function Fa(e,t){let i=[];for(let[n,r]of Object.entries(Na)){let a=t[r]?Il(t,t[r]):null;a&&i.push({state:n,child:a})}return i}function Cl(e){for(let t of e.runtime.roots)Ee(t,i=>{if(i.kind==="button"){for(let{child:n}of Fa(e,i))e.stateRestores.has(n.Id)||e.stateRestores.set(n.Id,{child:n,active:n.active,visible:n.visible}),n.active=!0,n.visible=!1,typeof n.markPlayDirty=="function"&&n.markPlayDirty(!0);qt(e,i)}})}function qt(e,t){if(!t||t.kind!=="button")return;let i=null;t.interactable===!1?i="unavailable":t.pressed===!0?i="pressed":e.hoveredControl===t?i="hover":e.selectedControl===t&&(i="selected");for(let n of Fa(e,t))n.child.active=!0,n.child.visible=n.state===i,typeof n.child.markPlayDirty=="function"&&n.child.markPlayDirty(!0)}function In(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(Na).map(n=>t[n]).filter(Boolean).includes(e.authoringId)?t:e}function Tn(e){return e.kind==="button"?e.raycastTarget!==!1&&e.interactable!==!1:e.kind==="cursor"||e.kind==="grid"?e.raycastTarget!==!1:e.kind==="textwindow"?e.interactable!==!1:e.raycastTarget===!0}function Oa(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function $a(e,t){let i=e.Id,n=t.get(i);if(n!==void 0)return n;let r=Tn(e);if(!r&&Oa(e)){let a=e.children;for(let o=0;o<a.length;o+=1)if($a(a[o],t)){r=!0;break}}return t.set(i,r),r}function Cn(e,t,i){let n=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=new Map;function a(s,c,l,f){if(!f||s.active===!1||s.visible===!1||!$a(s,r))return null;let h=Ae(c,s),p=$t(l,h,s),m=ai(p);if(!m)return null;let g=Xe(m,t,i);if(g.x<h.left||g.x>h.right||g.y<h.bottom||g.y>h.top)return null;if(Oa(s))for(let I=0;I<s.children.length;I+=1){let k=a(s.children[I],h,p,!0);if(k)return k}return Tn(s)?s:null}let o=yt();for(let s=e.runtime.roots.length-1;s>=0;s-=1){let c=a(e.runtime.roots[s],n,o,!0);if(c)return c}return null}function Wt(e,t,i,{dragging:n=!1,press:r=null,previous:a=null}={}){let o=r||{x:t,y:i},s=a||{x:t,y:i};return e.runtime.makeCursorEventData({x:t,y:i,pressX:o.x,pressY:o.y,deltaX:t-s.x,deltaY:i-s.y,dragging:n})}function Aa(e,t,i){t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),qt(e,t)}function jt(e,t,i,n,r={}){let a=Number(i),o=Number(n);if(!Number.isFinite(a)||!Number.isFinite(o))throw new Error("pointer coordinates must be finite");if(e.runtime.cursor.x=a,e.runtime.cursor.y=o,r.silent||Ue(e,{kind:"pointer",payload:{type:t,x:a,y:o}}),t==="move"){let s=e.pointerLastPosition||{x:a,y:o},c=e.pointerHoverControl,l=In(Cn(e,a,o)),f=Wt(e,a,o,{previous:s});c&&c!==l&&e.runtime.injectCursor(c,"CursorExit",f),l&&c!==l&&e.runtime.injectCursor(l,"CursorEnter",f),e.pointerHoverControl=l;let h=e.hoveredControl;e.hoveredControl=l?.kind==="button"?l:null,h&&h!==e.hoveredControl&&qt(e,h),e.hoveredControl&&qt(e,e.hoveredControl);let p=e.pointerDownControl;if(p){let m=e.pointerDownPosition||s,g=a!==s.x||o!==s.y;!e.pointerDragging&&g&&(e.runtime.injectCursor(p,"CursorBeginDrag",Wt(e,a,o,{press:m,previous:s,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&e.runtime.injectCursor(p,"CursorDrag",Wt(e,a,o,{press:m,previous:s,dragging:!0}))}return e.pointerLastPosition={x:a,y:o},l}if(t==="down"){let s=In(Cn(e,a,o));return e.pointerDownControl=s,e.pointerDownPosition={x:a,y:o},e.pointerLastPosition={x:a,y:o},e.pointerDragging=!1,s&&(Aa(e,s,!0),e.runtime.injectCursor(s,"CursorDown",Wt(e,a,o))),s}if(t==="up"){let s=e.pointerDownControl,c=In(Cn(e,a,o));if(s){let l=Wt(e,a,o,{press:e.pointerDownPosition,previous:e.pointerLastPosition,dragging:e.pointerDragging});if(e.runtime.injectCursor(s,"CursorUp",l),e.pointerDragging)e.runtime.injectCursor(s,"CursorEndDrag",l);else if(c===s){e.runtime.injectCursor(s,"CursorClick",l);let f=e.selectedControl;e.selectedControl=s.kind==="button"?s:null,f&&f!==e.selectedControl&&qt(e,f)}Aa(e,s,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:a,y:o},e.pointerDragging=!1,c}if(t==="click")return jt(e,"down",a,o,{silent:!0}),jt(e,"up",a,o,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function Mn(e,t,i,n){if(!e?.server)throw new Error("play session has no server");return Ue(e,{kind:"serverSet",payload:{entityType:t,name:i,value:n,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,n,{playerIndex:e.viewPlayerIndex})}function Da(e,t,i){if(!e?.server)throw new Error("play session has no server");let n=e.server.getVar(t,i,{playerIndex:e.viewPlayerIndex});return n===void 0?null:n}function Nn(e,t,i=[],n="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return Ue(e,{kind:"serverSend",payload:{name:t,params:i,target:n,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:n,playerIndex:e.viewPlayerIndex})}function Ei(e){return{snapshot:t=>_n(e,t),step:t=>xi(e,t),pointer:(t,i,n)=>jt(e,t,i,n),key:t=>Pn(e,t),click:t=>Rn(e,t),view:t=>En(e,t),pause:()=>{Ue(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{Ue(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,n)=>Mn(e,t,i,n),serverSend:(t,i,n)=>Nn(e,t,i,n)}}function Fn(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function On(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ga(e,t){for(let i of e||[])t(i),i.children?.length&&Ga(i.children,t)}function $n(e,{id:t,name:i}){let n=null;return Ga(e,r=>{n||(t&&String(r.id)===String(t)||!t&&i&&r.name===i)&&(n=r)}),n}function kl(e,t){if(e){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(e.box&&Object.prototype.hasOwnProperty.call(e.box,t))return e.box[t]}}function xl(e){return{var(t,i){return e.server?.vars?.[t]?.[i]?.value??null},logs(){return(e.logs||[]).map(t=>t.text)},logContains(t){return(e.logs||[]).some(i=>String(i.text||"").includes(String(t)))},serverLogs(){return(e.server?.logs||e.serverLogs||[]).map(t=>t.text)},serverLogContains(t){return(e.server?.logs||e.serverLogs||[]).some(i=>String(i.text||"").includes(String(t)))},control(t){let i=$n(e.tree,{name:String(t)});return i?{id:i.id,name:i.name,kind:i.kind,active:i.active,visible:i.visible,pressed:i.pressed,text:i.text,interactable:i.interactable}:null},signals(t){let i=t==="outbound"?"outbound":"inbound";return(e.server?.[i]||[]).map(n=>({name:n.name,values:n.values}))}}}function El(e,t){if(e.kind==="log"){let i=e.source==="server"?t.server?.logs||t.serverLogs||[]:t.logs||[];return i.some(r=>e.level&&r.level!==e.level?!1:String(r.text||"").includes(e.contains))?{ok:!0,actual:e.contains}:{ok:!1,actual:i.map(r=>r.text).slice(-8),expected:e.contains}}if(e.kind==="control"){let i=$n(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let n=kl(i,e.field);return On(n,e.equals)?{ok:!0,actual:n}:{ok:!1,actual:n,expected:e.equals}}if(e.kind==="var"){let i=t.server?.vars?.[e.entityType],r=!i||!Object.prototype.hasOwnProperty.call(i,e.name)?null:i[e.name].value;return On(r,e.equals)?{ok:!0,actual:r}:{ok:!1,actual:r,expected:e.equals}}if(e.kind==="signal"){let i=e.direction==="outbound"?t.server?.outbound||[]:t.server?.inbound||[],n=i.find(r=>r.name===e.name&&(e.values===void 0||On(r.values,e.values)));return n?{ok:!0,actual:n.values}:{ok:!1,actual:i.map(r=>({name:r.name,values:r.values})),expected:{name:e.name,values:e.values??null}}}if(e.kind==="tree"){let i=!!$n(t.tree,{name:e.name});return i===e.exists?{ok:!0,actual:i}:{ok:!1,actual:i,expected:e.exists}}return{ok:!1,message:`unsupported assert kind ${e.kind}`}}function Al(e,t){let i=Bt();try{return i.evalQueryScript(e,xl(t)),{ok:!0,actual:!0}}catch(n){return{ok:!1,message:n?.message||String(n)}}finally{i.destroy()}}function za(e,t){return e.kind==="lua"?Al(e.source,t):El(e,t)}function _l(e,t){let i=t>0?t:nt;return Math.round((e+i)*1e9)/1e9}function Pl(e,t){let i=t.payload||{};if(t.kind==="pointer")e.pointer(i.type,i.x,i.y);else if(t.kind==="key")e.key(i.typeName);else if(t.kind==="click")e.click(i.name);else if(t.kind==="pause")e.pause();else if(t.kind==="resume")e.resume();else if(t.kind==="serverSet")e.serverSet(i.entityType,i.name,i.value);else if(t.kind==="serverSend")e.serverSend(i.name,i.params,i.target);else if(t.kind==="view")e.view(i.playerIndex);else throw new Error(`unsupported event kind: ${t.kind}`)}function Rl(e,t){let i=za(e,t);return{kind:e.kind,at:Number(e.at||0),ok:!!i.ok,actual:i.actual??null,expected:i.expected??null,message:i.message||""}}function Va(e,t){let i=Kt(t),n=i.events.slice().sort((E,$)=>E.t-$.t),r=i.asserts.slice(),a=i.dt||nt,o=n.reduce((E,$)=>Math.max(E,$.t),0),s=r.reduce((E,$)=>Math.max(E,Number($.at||0)),0),c=Math.max(o,s),l=0,f=[],h=0,p=r.some(E=>E.kind==="control"||E.kind==="tree"||E.kind==="lua"),m=e.snapshot({inspect:p}),g=()=>{for(;l<n.length&&n[l].t<=h+1e-9;)Pl(e,n[l]),l+=1,m=e.snapshot({inspect:p})},I=()=>{for(let E of r)if(!E._done&&Number(E.at||0)<=h+1e-9){let $=Rl(E,m);if(f.push($),E._done=!0,!$.ok)return{passed:!1,failedAt:h,frame:m.frame||0,results:f,snapshot:m}}return null};g();let k=I();if(k)return Dn(i,k);for(;h+1e-9<c;){e.step(a),h=_l(h,a),m=e.snapshot({inspect:p}),g();let E=I();if(E)return Dn(i,E)}return Dn(i,{passed:f.every(E=>E.ok),failedAt:null,frame:m.frame||0,results:f,snapshot:m})}function Dn(e,t){return D({format:e.format,name:e.name,passed:t.passed,failedAt:t.failedAt,frame:t.frame,results:t.results,snapshot:{time:t.snapshot?.time??0,frame:t.snapshot?.frame??0,logs:t.snapshot?.logs||[],serverLogs:t.snapshot?.serverLogs||t.snapshot?.server?.logs||[],server:t.snapshot?.server||{vars:{},inbound:[],outbound:[],logs:[]}}})}function Gn(e){return Array.isArray(e)?e.slice():[]}var Ol={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(it.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function $l(e,t=1){let i=e?.vars||{},n=[],r=Number(t)>0?Number(t):1,a=["Level","PlayerSelf","AvatarSelf"];if(r>1)for(let s=1;s<=r;s+=1)a.push(`Player${s}`,`Avatar${s}`);let o=new Set;for(let s of a){if(o.has(s)||!i[s])continue;o.add(s);let c=i[s]||{};for(let l of Object.keys(c))n.push(D({entityType:s,entityLabel:Ol[s]||s,name:l,type:c[l]?.type||"",value:c[l]?.value??null}))}return n}var ot="qxqy-simulator-save",Dl="qxqy-simulator-scripts",ie="server-control-template",V="client-control-template",Ua={[ie]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[V]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function at(e){return e===V?"client":"server"}function Gl(e){let t=[e?.guid,e?.id];for(let i of t){let n=Number(i);if(Number.isSafeInteger(n)&&n>0&&n<=2147483647)return n}return 0}function Ai(e){let t=String(e?.controlAsset||""),i=Gl(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===V||t==="client"?V:t===ie||t==="server"?ie:""}}function Ha(e){let t=[],i=(n,r="")=>{if(n&&(n.path||n.source)){let a=Ai(n);t.push(r?{...a,controlAsset:r}:a)}};if(Array.isArray(e?.assets?.scripts)){for(let n of e.assets.scripts)n&&(n.path||n.source)&&t.push(Ai(n));return t}if(i(e?.assets?.server?.script,ie),i(e?.assets?.client?.script,V),e&&e.format!==ot){i(e?.script);for(let n of e?.scripts||[])i(n)}return t}function zn(e){return ke(e===V?Je():De())}var zl="\u672A\u7ED1\u5B9A",Ct="\u672A\u547D\u540D\u5B58\u6863",Vl="\u672A\u547D\u540D\u754C\u9762";function Yl(e){let t=e;for(let i=0;i<8;i++){if(Jt(Ya(t,"simulator","studio"))&&Jt(Ya(t,"lua")))return t;let n=Nl(t);if(n===t)break;t=n}return e}function Bl(e){return e?{name:kt(e),path:e,bound:!0}:{name:zl,path:"",bound:!1}}function Ul(e,t=process.cwd()){if(Fl(e)&&Jt(e))return e;let i=t||process.cwd(),n=Yl(i),r=Ba(n,e);if(Jt(r))return r;let a=Ba(i,e);if(Jt(a))return a;throw new Error("script file not found: "+e)}function La(e,t={}){e?.format===ot&&rn(e.version);let i=[],n=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",r=e?.format===ot&&e.assets,a=r?null:ke(e,{warnings:i}),o={server:r&&e.assets.server?ke(e.assets.server,{warnings:i}):zn(ie),client:r&&e.assets.client?ke(e.assets.client,{warnings:i}):zn(V)};a&&(o[at(a.meta.assetType)]=a);let s=r&&e.activeAssetType===V?V:a?.meta.assetType||ie,c=r&&e.meta?.name?String(e.meta.name):"",l=()=>c||Ct;!e?.meta?.name&&o.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(o.server.meta.name=Vl);let f=[],h=new Set;function p(){h.clear(),bt(o.server.root,h),bt(o.client.root,h,{skipServerContainer:!0});for(let d of f)Ce(d.guid)&&h.add(Number(d.guid))}function m(d=0){p();let y=Ce(d)&&!h.has(Number(d))?Number(d):Oe(h);return h.add(y),y}function g(d){let y=Ai(d),w=m(y.guid);return{...y,guid:w,id:String(w)}}for(let d of Ha(e))f.push(g(d));let I=It(e?.serverLogic),k=null,E="",$=1,O=1;function Y(d){let y=String(d||"").trim();if(!y)return"";if(!X[y])throw new Error(`unknown canvas preset: ${y} (available: ${Object.keys(X).join(", ")})`);return y}let W=()=>o[at(s)];function Z(d){if(!d)return null;for(let[y,w]of[["server",o.server],["client",o.client]]){let R=ue(w.root,d);if(R&&R.kind!=="server-container")return{key:y,node:R}}return null}function q(d){if(!d.controlId)return null;let y=d.controlAsset===V?"client":d.controlAsset===ie?"server":null;if(y){let w=ue(o[y].root,d.controlId);return w&&w.kind!=="server-container"?{key:y,node:w}:null}return Z(d.controlId)}function N(){for(let d of f)d.controlId&&!q(d)&&(d.controlId="",d.controlAsset="")}function b(d){if(!Ce(d))return null;for(let[y,w]of[[ie,o.server],[V,o.client]]){let R="";if(J(w.root,F=>{!R&&(F.scriptMappingIds||[]).includes(Number(d))&&(R=F.id)}),R)return{controlId:R,controlAsset:y}}return null}function x(d,y,w){let R=o[at(d.controlAsset)],F=R&&ue(R.root,d.controlId);F&&(F.scriptMappingIds=(F.scriptMappingIds||[]).map(T=>Number(T)===Number(y)?Number(w):T))}N();function v(){return f.map(d=>{let y=q(d),w=y?y.key==="client"?V:ie:"";return D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||w,controlName:y?.node.name||"",assetType:w,assetLabel:y?Ua[w]:"",mounted:!!y})})}function C(){let d=[],y=(w,R)=>{J(w.root,F=>{F.kind!=="server-container"&&d.push(D({id:F.id,name:F.name,kind:F.kind,assetType:R,assetLabel:Ua[R]}))})};return y(o.server,ie),y(o.client,V),d}function M(d){let y=[];return J(d.root,w=>{w.kind!=="server-container"&&y.push(JSON.stringify({kind:w.kind,name:w.name,text:w.text??null,imageId:w.imageId??null,fontSize:w.fontSize??null,fontColor:w.fontColor??null,bgColor:w.bgColor??null,imageColor:w.imageColor??null,fillType:w.fillType??null,fillAmount:w.fillAmount??null,syncAllDevices:w.syncAllDevices!==!1,transformByPlatform:w.transformByPlatform||null}))}),y.join("/")}let S=M(Je()),P=M(De());function G(d){let y=M(d);return d.meta?.assetType===V?y===S:y===P}function z(d,y){return String(d||"").replace(/[\\/:*?"<>|]/g,"-").trim()||y}function ne(d){let y=z(l(),Ct),w=d.meta?.assetType===V?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${y} \xB7 ${w}`}function j(){if(!((o.server.root.children||[]).find(y=>y.kind==="container")||o.server.root.children?.[0]))throw new Error("\u6574\u5408\u5305\u9700\u8981\u670D\u52A1\u7AEF\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668\u4E0B\u81F3\u5C11\u6709\u4E00\u4E2A\u6839\u63A7\u4EF6");return Fr(o.server,o.client,{scripts:f,fileName:`${z(l(),Ct)} \xB7 \u6574\u5408\u5305.gia`})}function ce(){let d=y=>({type:y.meta.assetType,name:y.meta.name,sourceFile:y.meta.sourceFile||""});return{format:ot,name:l(),activeAssetType:s,assets:{server:d(o.server),client:d(o.client),scripts:v()}}}function Re(){return D({format:ot,version:4,meta:{name:l()},activeAssetType:s,serverLogic:I,assets:{server:o.server,client:o.client,scripts:f.map(d=>D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||""}))}})}function oe(){let d=W(),y=Jr(d);return y.workspace=Bl(n),y.save=ce(),y.scripts=v(),y.mountTargets=C(),y.serverLogic=I,y.migrationWarnings=[...i],nr(y),y}function lt(d){let y=W();if(d.expectedRevision!==void 0&&Number(d.expectedRevision)!==y.version)throw new Error(`revision conflict: expected ${d.expectedRevision}, current ${y.version}`);return y}function He(d,y,w=""){let R=String(y||"");if(R){let F=w===V?V:w===ie?ie:"";if(!q({controlId:R,controlAsset:F}))throw new Error("\u6302\u8F7D\u76EE\u6807\u5FC5\u987B\u662F\u5B58\u6863\u5185\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F");d.controlAsset=F}else d.controlAsset="";d.controlId=R}function Pt(d){let y=lt(d);if(d.op==="addScript"){let w=g({path:String(d.path||""),source:String(d.source||""),controlId:"",controlAsset:""});d.controlId!==void 0&&d.controlId!==""&&He(w,d.controlId,d.controlAsset),f.push(w)}else if(d.op==="updateScript"){let w=f.find(R=>R.id===d.id);if(!w)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`);d.controlId!==void 0&&He(w,d.controlId,d.controlAsset),d.path!==void 0&&(w.path=String(d.path)),d.source!==void 0&&(w.source=String(d.source))}else if(d.op==="removeScript"){let w=f.length;if(f=f.filter(R=>R.id!==d.id),f.length===w)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`)}return y.version+=1,oe()}function ut(d){if(!d||typeof d!="object")throw new Error("patch requires op");if(d.op==="setServerLogic"){let y=lt(d);return I=It(d.logic),y.version+=1,oe()}if(d.op==="addScript"||d.op==="updateScript"||d.op==="removeScript")return Pt(d);if(d.op==="selectAsset")return s=d.assetType===V?V:ie,oe();if(d.op==="renameSave"){let y=String(d.name||"").trim();if(!y)throw new Error("\u5B58\u6863\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");return c=y,oe()}if(d.op==="newAsset"){let y=lt(d);s=d.assetType===V?V:ie;let w=zn(s);return w.version=y.version+1,o[at(s)]=w,N(),oe()}return sn(W(),d),N(),oe()}function ct(d){return f.filter(y=>{let w=q(y);return!!(w&&w.key==="client"==(d===V))})}function Rt(d="json",y=""){let w=String(d).toLowerCase();if(w==="save"||w==="archive"){let T=Buffer.from(JSON.stringify(Re(),null,2),"utf8");return D({filename:`${l().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:T.toString("base64"),warnings:[]})}if(w==="save-gia"||w==="archive-gia"){let T=[],B=[],Q=(ve,Me="")=>{let ee=Rt(ve,Me);T.push(D({filename:ee.filename,mimeType:ee.mimeType,encoding:ee.encoding,data:ee.data,warnings:ee.warnings||[]})),B.push(...ee.warnings||[])},ft=(ve,Me)=>{let ee=o[at(ve)],Ne=ve===s,dt=f.some(ge=>ge.controlAsset===ve&&ge.controlId);if(!Ne&&G(ee)&&!dt){B.push(Me);return}Q("gia",ve)};if(ft(ie,"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u6A71\u7A97\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),ft(V,"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u300CLua\u5B9E\u4F8B\u5316\u9762\u677F\u300D\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),f.some(ve=>ve.path||ve.source)&&Q("scripts-gia"),!T.length)throw new Error("\u8D44\u4EA7\u5305 GIA \u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u5DF2\u6539\u52A8\u9879\uFF1B\u8BF7\u5148\u7F16\u8F91\u5F53\u524D\u754C\u9762\uFF0C\u6216\u6539\u7528\u300C\u5F53\u524D\u754C\u9762 GIA\u300D\u3002");return D({format:"qxqy-gia-package",files:T,warnings:[...new Set(B)]})}if(w==="gia-combined"||w==="combined-gia"||w==="combined"){let T=j();return D({filename:`${z(l(),Ct)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:T.buffer.toString("base64"),warnings:[...new Set(T.warnings||[])]})}if(w==="scripts"){let T=D({format:Dl,version:1,scripts:f.map(Q=>D({id:Q.id,guid:Q.guid||0,path:Q.path||"",source:Q.source||"",controlId:Q.controlId||"",controlAsset:Q.controlAsset||""}))}),B=Buffer.from(JSON.stringify(T,null,2),"utf8");return D({filename:`${z(l(),Ct)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:B.toString("base64"),warnings:[]})}if(w==="scripts-gia"||w==="scriptsgia"){let T=Gr(f);return D({filename:`${z(l(),Ct)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:T.buffer.toString("base64"),warnings:T.warnings})}if(w==="lua"){let T=f.find(Q=>Q.id===y)||f.find(Q=>Q.path===y);if(!T)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let B=kt(T.path||"")||`qxqy-script-${T.id}`;return D({filename:/\.lua$/i.test(B)?B:`${B}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(T.source||"","utf8").toString("base64"),warnings:[]})}let R=y?o[at(y)]:W(),F=ne(R);if(w==="json"){let T=D({...R,scripts:ct(R.meta.assetType)}),B=Buffer.from(JSON.stringify(T,null,2),"utf8");return D({filename:`${F}.json`,mimeType:"application/json",encoding:"base64",data:B.toString("base64"),warnings:[]})}if(w==="gia"){let T=Nr(R,R.meta.assetType===V?{scripts:ct(V)}:{}),B=R.meta.assetType===V?[]:ct(ie);return B.length&&T.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${B.length} \u4E2A Lua \u811A\u672C\u7684\u6E90\u7801\uFF1B\u8BF7\u4F7F\u7528\u300C\u8D44\u4EA7\u5305 GIA \u6574\u5408\u5305\u300D\uFF0C\u6216\u53E6\u884C\u5BFC\u5165\u811A\u672C\u5305\u5E76\u6838\u5BF9\u6302\u8F7D\u3002`),D({filename:`${F}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:T.buffer.toString("base64"),warnings:T.warnings})}throw new Error(`unsupported export format: ${d}`)}function L(d){for(let y of d){let w=Ai(y);if(!w.path&&!w.source)continue;let R=w.controlId?null:b(w.guid),F=g(R?{...w,...R}:w);R&&F.guid!==w.guid&&x(R,w.guid,F.guid),F.controlId&&!q(F)&&(F.controlId="",F.controlAsset=""),f.push(F)}}function we(d,y,w=""){let R=String(d||"").toLowerCase();if(typeof y!="string"||!y)throw new Error("import data is required");let F=Buffer.from(y,"base64"),T,B=[],Q={};if(R==="json"){try{T=JSON.parse(F.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(T?.project&&(T=T.project),T?.format===ot&&T?.assets){rn(T.version);let ee=ke(T.assets.server||De(),{warnings:B}),Ne=ke(T.assets.client||Je(),{warnings:B}),dt=It(T.serverLogic);return o.server=ee,o.client=Ne,i=[...B],s=T.activeAssetType===V?V:ie,c=String(T.meta?.name||kt(w).replace(/\.json$/i,"")||c),I=dt,f=[],h.clear(),L(Ha(T)),N(),D({snapshot:oe(),warnings:B,metadata:{format:ot}})}}else{if(R==="lua")return f.push(g({path:kt(w||"imported.lua"),source:F.toString("utf8"),controlId:""})),D({snapshot:oe(),warnings:B,metadata:{assetType:"lua-script"}});if(R==="gia"){if(zr(F)){let ge=Yr(F);return L(ge.scripts),D({snapshot:oe(),warnings:ge.warnings,metadata:ge.metadata})}let ee=Br(F);T=ee.project,B=ee.warnings,Q=ee.metadata,ee.clientProject&&(o.client=ke(ee.clientProject),B.push("\u6574\u5408\u5305\u5DF2\u62C6\u56DE\u300CUI\u63A7\u4EF6-\u670D\u52A1\u7AEF\u300D\u4E0E\u300CUI\u63A7\u4EF6-\u5BA2\u6237\u7AEF\u300D\uFF1B\u5BA2\u6237\u7AEF\u6A21\u677F\u8FB9\u754C\u5DF2\u4FDD\u7559\u3002"));let Ne=new Map,dt=(ge,zo)=>{ge&&J(ge.root,Qn=>{for(let Gi of Qn.scriptMappingIds||[]){let er=Ne.get(Number(Gi));if(er){B.push(`\u811A\u672C GUID ${Gi} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${er.controlAsset===ie?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}Ne.set(Number(Gi),{controlId:Qn.id,controlAsset:zo})}})};dt(ee.project,ie),dt(ee.clientProject,V),L((ee.scripts||[]).map(ge=>Ne.has(Number(ge.guid))?{...ge,...Ne.get(Number(ge.guid))}:ge))}else throw new Error(`unsupported import format: ${d}`)}let ft=ke(T,{warnings:B});i=[...B];let ve=at(ft.meta.assetType);o[ve]=ft,s=ft.meta.assetType;let Me=o[ve];return w&&(Me.meta.name=kt(w).replace(/\.(json|gia)$/i,"")||Me.meta.name,Me.meta.sourceFile=kt(w),Me.meta.sourceFormat=R),L(T?.scripts||[]),T?.script&&(T.script.path||T.script.source)&&L([T.script]),D({snapshot:oe(),warnings:B,metadata:Q})}function Le(d,y){return sn(W(),{op:"pick",x:d,y}),oe()}function ti(d){let y=typeof d=="string"&&d?d:"";!y||y===n||(n=y)}function Tt(d){let y=d.source||"";if(!y.trim()&&d.path.trim())try{y=Ml(Ul(d.path,n),"utf8")}catch(w){throw new Error(`\u811A\u672C ${d.path} \u8BFB\u53D6\u5931\u8D25: ${w?.message||w}`)}return y}function Te(d={}){let y=Y(d.canvasId);y&&(E=y),d.playerCount!==void 0&&d.playerCount!==null&&d.playerCount!==""&&($=tt(d.playerCount),O>$&&(O=1)),d.viewPlayerIndex!==void 0&&d.viewPlayerIndex!==null&&d.viewPlayerIndex!==""&&(O=Pe(d.viewPlayerIndex,$)),k&&Fn(k);let w=f.map(F=>{try{return{id:F.id,guid:F.guid||0,path:F.path||F.id,source:Tt(F),controlId:F.controlId||"",controlAsset:F.controlAsset||""}}catch(T){return{id:F.id,guid:F.guid||0,path:F.path||F.id,source:`error([==[ ${String(T.message).replace(/]=+]/g,"] =]")} ])`,controlId:F.controlId||"",controlAsset:F.controlAsset||""}}}),R=F=>w.filter(T=>{let B={controlId:T.controlId,controlAsset:T.controlAsset},Q=T.controlId?q(B):null;return!!(Q&&Q.key===F)});return k=Pa(o.server,{templatesProject:o.client,scripts:w,sceneScripts:R("server"),templateScripts:R("client"),serverConfig:{logic:I},canvasId:E,playerCount:$,viewPlayerIndex:O}),se(d)}function Mt(d,y={}){let w=Y(d);if(!w)throw new Error("playSetCanvas requires canvasId");return Te({...y,canvasId:w})}function se(d={}){if(!k)return D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let y=_n(k,d);return y.running=!0,y.logs=Gn(y.logs),y.serverLogs=Gn(y.server?.logs||[]),y.serverVars=$l(y.server,y.playerCount||1),y}function Co(d,y={}){return k||Te(),xi(k,d),y.observe===!1?D({running:!0,time:k.runtime.clock.time,frame:k.runtime.clock.frame,paused:!!k.debugPaused,levelTimePaused:!!k.runtime.clock.paused,playerCount:k.playerCount||1,viewPlayerIndex:k.viewPlayerIndex||1}):se(y)}function ko(d=0){Te();let y=Math.max(0,Number(d)||0);for(let w=0;w<y;w++)xi(k,1/30);return se()}function xo(){return k&&Fn(k),k=null,E="",$=1,O=1,D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function Eo(d,y={}){let w=Nt();return O=En(w,d),y.observe===!1?null:se(y)}function Ao(d,y={}){if(!k)throw new Error("play session has not started");return Pn(k,d),y.observe===!1?null:se(y)}function _o(d,y={}){if(!k)throw new Error("play session has not started");return Rn(k,d),y.observe===!1?null:se(y)}function Po(d,y,w,R={}){if(!k)throw new Error("play session has not started");return jt(k,d,y,w),R.observe===!1?null:se(R)}function Ro(d={}){return k&&Ei(k).pause(),d.observe===!1?null:se(d)}function To(d={}){return k&&Ei(k).resume(),d.observe===!1?null:se(d)}function Nt(){if(!k)throw new Error("play session has not started");return k}function Mo(d,y){let w=Nt();if(!d&&!y){let R=se();return D({vars:R.serverVars||[]})}return D({entityType:String(d||""),name:String(y||""),value:Da(w,d,y)})}function No(d,y,w){let R=Nt();return Mn(R,d,y,w),se()}function Fo(d,y=[],w="PlayerSelf"){let R=Nt();return Nn(R,d,y,w),se()}function Oo(){let d=se();return D({events:d.history||[],case:xa(d.history||[],{playerCount:d.playerCount||1})})}function $o(d={}){let y=se(),w=Kt({name:d.name||"",dt:d.dt,playerCount:d.playerCount||y.playerCount||1,events:d.events||y.history||[],asserts:d.asserts||[]});return D(w)}function Do(d,y={}){let w=Kt(d);Te({...y,playerCount:y.playerCount||w.playerCount||1});let R=Nt();R.recording=!1;try{return Va(Ei(R),d)}finally{R.recording=!0}}function Go(){if(!k)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let d=k.runtime.clock;return{running:!0,paused:!!k.debugPaused,levelTimePaused:!!d.paused,time:d.time,frame:d.frame,playerCount:k.playerCount||1,viewPlayerIndex:k.viewPlayerIndex||1}}let Zn={get:oe,patch:ut,setWorkspace:ti,exportData:Rt,importData:we,pick:Le,playStart:Te,playSetCanvas:Mt,playSetView:Eo,playGet:se,playStatus:Go,playStep:Co,playRun:ko,playStop:xo,playKey:Ao,playClick:_o,playPointer:Po,playPause:Ro,playResume:To,playServerGet:Mo,playServerSet:No,playServerSend:Fo,playHistory:Oo,playSaveCase:$o,playRunCase:Do,archiveData:Re};return Object.defineProperty(Zn,"_project",{enumerable:!1,get:W}),Zn}import{createRequire as Hl}from"node:module";function Xa(e,t,i){if(e.fillType!=="Horizontal"&&e.fillType!=="Vertical")return null;let n=Number(e.fillAmount??1),r=Number.isFinite(n)?Math.max(0,Math.min(1,n)):1;if(e.fillType==="Horizontal"){let o=t*r;return{x:e.fillHorizontalType==="Right"?t/2-o:-t/2,y:-i/2,width:o,height:i}}let a=i*r;return{x:-t/2,y:e.fillVerticalType==="Top"?-i/2:i/2-a,width:t,height:a}}var Ll=Hl(import.meta.url),Xl=[0,-.5,.5,.5,-.5,.5],Kl=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],Wl=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],Vn=Buffer.from([137,80,78,71,13,10,26,10]),ql=new Set(["image","textbox","textwindow","button"]),_i={cursor:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF",reference:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6",grid:"\u7F51\u683C\u89C6\u7A97",button:"\u9884\u8BBE\u6309\u94AE",keyhint:"\u6309\u952E\u63D0\u793A",animation:"\u754C\u9762\u52A8\u6548",fullscreen:"\u5168\u5C4F\u52A8\u6548"},Pi=null;function Wa(){if(Pi)return Pi;try{Pi=Ll("@napi-rs/canvas")}catch(e){let t=e?.message||String(e);throw new Error(`Host screenshot renderer requires @napi-rs/canvas (${t})`)}return Pi}function U(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ti(e,t=4294967295){let i=Number(e??t)>>>0;return{r:i>>>16&255,g:i>>>8&255,b:i&255,a:(i>>>24&255)/255}}function st(e,t=1){return`rgba(${e.r},${e.g},${e.b},${Math.max(0,Math.min(1,e.a*t))})`}function qa(e,t,i=1){let n=Math.max(1,Math.round(U(e,1))),r=Math.max(1,Math.round(U(t,1))),a=Math.max(1,Math.min(2,U(i,1)));return{width:n,height:r,pixelWidth:Math.max(1,Math.round(n*a)),pixelHeight:Math.max(1,Math.round(r*a)),pixelRatio:a}}function ja(e){let t=Buffer.from(e.toBuffer("image/png"));if(t.length<Vn.length||!t.subarray(0,Vn.length).equals(Vn))throw new Error("Host screenshot renderer did not produce a PNG");return t}function jl(e){return e==="triangle"?Xl:e==="fourstar"?Kl:Wl}function Jl(e,t,i,n,r){let a=jl(t);e.beginPath();for(let o=0;o<a.length;o+=2){let s=a[o]*i,c=a[o+1]*n;o===0?e.moveTo(s,c):e.lineTo(s,c)}e.closePath(),e.fillStyle=st(r),e.fill()}function Zl(e,t,i){let n=t?.matrix,r=n&&typeof n=="object"?[n.a,n.b,n.c,n.d,n.tx,n.ty].map(Number):null,a=t?.pressed?.98:1;if(r&&r.every(Number.isFinite)){let[o,s,c,l,f,h]=r;e.transform(o*a,-s*a,-c*a,l*a,f,i-h);return}e.translate(U(t.left)+U(t.width)/2,i-U(t.bottom)-U(t.height)/2),e.rotate(-U(t.rotationZ)*Math.PI/180),e.scale(a,a)}function Ql(e,t,i,n,r,a){if(typeof e.roundRect=="function"){e.roundRect(t,i,n,r,a);return}let o=Math.max(0,Math.min(a,n/2,r/2));e.moveTo(t+o,i),e.arcTo(t+n,i,t+n,i+r,o),e.arcTo(t+n,i+r,t,i+r,o),e.arcTo(t,i+r,t,i,o),e.arcTo(t,i,t+n,i,o),e.closePath()}function Ja(e,t,i,n){let r=Ti(t.bgColor,16777215);e.fillStyle=st(r),e.fillRect(-i/2,-n/2,i,n);let a=Math.max(8,U(t.fontSize,12)),o=Ti(t.fontColor,4294967295),s=t.horizontalAlignment==="Right"?1:t.horizontalAlignment==="Middle"?.5:0,c=t.verticalAlignment==="Bottom"?1:t.verticalAlignment==="Middle"?.5:0;if(e.save(),e.beginPath(),e.rect(-i/2,-n/2,i,n),e.clip(),e.font=`${a}px "Microsoft YaHei UI","Microsoft YaHei",sans-serif`,e.fillStyle=st(o),e.textAlign=s===1?"right":s===.5?"center":"left",e.textBaseline=c===1?"bottom":c===.5?"middle":"top",t.enableOutline){let g=Ti(t.outlineColor,4278190080);e.strokeStyle=st(g),e.lineWidth=Math.max(2,a*.12),e.lineJoin="round"}let l=s===0?-i/2+2:s===1?i/2-2:0,f=c===0?-n/2:c===1?n/2:0,h=String(t.text||"").split(`
|
|
109
|
+
`),p=a*1.2,m=c===.5?f-(h.length-1)*p/2:c===1?f-(h.length-1)*p:f;for(let g=0;g<h.length;g+=1){let I=m+g*p;t.enableOutline&&e.strokeText(h[g],l,I),e.fillText(h[g],l,I)}e.restore()}function Za(e,t,i,n){e.beginPath(),Ql(e,-i/2,-n/2,i,n,6),e.fillStyle="#3268cf",e.fill(),e.strokeStyle="rgba(112,160,255,0.8)",e.lineWidth=1,e.stroke(),t.pressed&&(e.fillStyle="rgba(0,0,0,0.28)",e.fill())}function Qa(e,t,i,n){let r=Ti(t.imageColor,4294967295);if(t.primitive==="missing"){e.fillStyle="rgba(72,34,40,0.36)",e.fillRect(-i/2,-n/2,i,n),e.strokeStyle="#ff7481",e.lineWidth=1,e.strokeRect(-i/2+.5,-n/2+.5,Math.max(0,i-1),Math.max(0,n-1));return}if(t.primitive==="circle"){e.beginPath(),e.ellipse(0,0,i/2,n/2,0,0,Math.PI*2),e.fillStyle=st(r),e.fill();return}if(t.primitive==="ring"){e.beginPath(),e.ellipse(0,0,Math.max(1,i/2-3.5),Math.max(1,n/2-3.5),0,0,Math.PI*2),e.strokeStyle=st(r),e.lineWidth=7,e.stroke();return}if(t.primitive==="triangle"||t.primitive==="fourstar"||t.primitive==="fivestar"){Jl(e,t.primitive,i,n,r);return}e.fillStyle=st(r),e.fillRect(-i/2,-n/2,i,n)}function eu(e,t,i){let n=Math.max(0,U(t.sourceWidth,U(t.width))),r=Math.max(0,U(t.sourceHeight,U(t.height)));if(e.save(),Zl(e,t,i),t.kind==="textbox"||t.kind==="textwindow")Ja(e,t,n,r);else if(t.kind==="button")Za(e,t,n,r);else{let a=Xa(t,n,r);a&&(e.beginPath(),e.rect(a.x,a.y,a.width,a.height),e.clip()),Qa(e,t,n,r)}e.restore()}function eo(e,t,i,{checker:n=!1}={}){if(n){e.fillStyle="#28313e",e.fillRect(0,0,t,i);let a=16;for(let o=0;o<i;o+=a)for(let s=0;s<t;s+=a)(s/a+o/a)%2===0&&(e.fillStyle="rgba(255,255,255,0.04)",e.fillRect(s,o,a,a));e.strokeStyle="#40b8cf",e.lineWidth=1,e.strokeRect(.5,.5,t-1,i-1);return}let r=e.createRadialGradient(t/2,i*.45,8,t/2,i/2,Math.max(t,i)*.72);r.addColorStop(0,"#123a6b"),r.addColorStop(.72,"#061934"),r.addColorStop(1,"#071426"),e.fillStyle=r,e.fillRect(0,0,t,i)}function tu(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,tx:e.a*t.tx+e.c*t.ty+e.tx,ty:e.b*t.tx+e.d*t.ty+e.ty}}function Ka(e){let t=e?.matrix;return!t||typeof t!="object"?{a:1,b:0,c:0,d:1,tx:0,ty:0}:{a:U(t.a,1),b:U(t.b),c:U(t.c),d:U(t.d,1),tx:U(t.tx),ty:U(t.ty)}}function iu(e){let t=Array.isArray(e?.nodes)?e.nodes:[],i=new Map;for(let o of t){if(!o||o.id===void 0||o.id===null)continue;let s=o.parent==null?"":String(o.parent),c=i.get(s);c?c.push(o):i.set(s,[o])}for(let o of i.values())o.sort((s,c)=>U(s.z)-U(c.z));let n=[];function r(o,s){if(!ql.has(o.kind))return;let c=Math.abs(U(o.sourceWidth)*Math.hypot(s.a,s.b)),l=Math.abs(U(o.sourceHeight)*Math.hypot(s.c,s.d));n.push({...o,left:s.tx-c/2,bottom:s.ty-l/2,width:c,height:l,rotationZ:Math.atan2(s.b,s.a)*180/Math.PI,matrix:{a:s.a,b:s.b,c:s.c,d:s.d,tx:s.tx,ty:s.ty}})}function a(o,s){let c=i.get(o)||[];for(let l=c.length-1;l>=0;l-=1){let f=c[l],h=s?tu(s,Ka(f)):Ka(f);r(f,h),a(String(f.id),h)}}return a("",null),n}function to(e,t,i,n={}){return nu(iu(e),t,i,n)}function nu(e,t,i,n={}){let{createCanvas:r}=Wa(),a=qa(t,i,n.scale),o=r(a.pixelWidth,a.pixelHeight),s=o.getContext("2d");s.scale(a.pixelRatio,a.pixelRatio),eo(s,a.width,a.height);let c=Array.isArray(e)?e:[];for(let l of c)!l||l.id===void 0||l.id===null||eu(s,l,a.height);return{data:ja(o),width:a.width,height:a.height,pixelWidth:a.pixelWidth,pixelHeight:a.pixelHeight}}function ru(e){return{kind:e.kind,left:U(e.renderLeft,e.left),bottom:U(e.renderBottom,e.bottom),width:Math.max(0,U(e.renderWidth,e.width)),height:Math.max(0,U(e.renderHeight,e.height)),rotationZ:U(e.renderRotationZ,e.rotationZ)}}function Ri(e,t,i){let n=String(t||"");if(!n)return;e.font='10px "Microsoft YaHei UI","Microsoft YaHei",sans-serif',e.textAlign="center",e.textBaseline="middle";let r=e.measureText(n),a=Math.min(i-4,Math.max(24,r.width+8)),o=16;e.fillStyle="rgba(17,25,37,0.66)",e.fillRect(-a/2,-o/2,a,o),e.fillStyle="#e7edf5",e.fillText(n,0,0)}function au(e,t,i,n){let r=ru(t);if(r.width<=0||r.height<=0)return;e.save(),e.translate(r.left+r.width/2,i-r.bottom-r.height/2),e.rotate(-r.rotationZ*Math.PI/180);let a=-r.width/2,o=-r.height/2;if(t.kind==="image")Qa(e,t,r.width,r.height);else if(t.kind==="textbox"||t.kind==="textwindow")Ja(e,t,r.width,r.height);else if(t.kind==="button")Za(e,t,r.width,r.height),Ri(e,t.name||_i.button,r.width);else if(t.kind==="cursor")e.setLineDash([6,4]),e.strokeStyle="rgba(74,142,181,0.7)",e.fillStyle="rgba(74,142,181,0.1)",e.fillRect(a,o,r.width,r.height),e.strokeRect(a,o,r.width,r.height),Ri(e,t.name||_i.cursor,r.width);else if(t.kind==="grid"){e.strokeStyle="rgba(106,146,189,0.55)",e.strokeRect(a,o,r.width,r.height),e.beginPath();for(let s=20;s<r.width;s+=20)e.moveTo(a+s,o),e.lineTo(a+s,o+r.height);for(let s=20;s<r.height;s+=20)e.moveTo(a,o+s),e.lineTo(a+r.width,o+s);e.stroke(),Ri(e,t.name||_i.grid,r.width)}else t.kind!=="container"&&t.kind!=="server-container"?(e.setLineDash(t.kind==="reference"||t.kind==="animation"||t.kind==="fullscreen"?[4,4]:[]),e.strokeStyle="rgba(203,218,237,0.55)",e.strokeRect(a,o,r.width,r.height),Ri(e,t.name||_i[t.kind]||t.kind,r.width)):(e.strokeStyle="rgba(78,165,230,0.42)",e.strokeRect(a,o,r.width,r.height));t.id===n&&t.kind!=="container"&&t.kind!=="server-container"&&(e.setLineDash([]),e.strokeStyle="#61b9ff",e.lineWidth=2,e.strokeRect(a,o,r.width,r.height)),e.restore()}function io(e,t={}){let{createCanvas:i}=Wa(),n=e?.canvas||{},r=qa(n.width||1600,n.height||900,t.scale),a=i(r.pixelWidth,r.pixelHeight),o=a.getContext("2d");o.scale(r.pixelRatio,r.pixelRatio),eo(o,r.width,r.height,{checker:!0});let s=Array.isArray(e?.boxes)?e.boxes:[],c=e?.selectedId;for(let l of s)!l||l.kind==="server-container"||l.visible===!1||au(o,l,r.height,c);return{data:ja(a),page:e?.asset?.type==="client-control-template"?"UI\u63A7\u4EF6-\u5BA2\u6237\u7AEF":"UI \u7F16\u8F91",width:r.width,height:r.height,pixelWidth:r.pixelWidth,pixelHeight:r.pixelHeight}}import{closeSync as ou,existsSync as Mi,openSync as su,opendirSync as lu,readSync as uu,realpathSync as xt,statSync as ro}from"node:fs";import{basename as cu,dirname as no,isAbsolute as Hn,join as fu,relative as ao,resolve as ei}from"node:path";var du="qxqy-simulator-save",oo=new Set(["node_modules",".git","dist",".dsh","coverage"]),Zt=50,so=4096,Yn=1e4,Bn=1e3,Un=8;function Ln(e=""){let t=ei(String(e||process.cwd()));if(!Mi(t))throw new Error(`workspace does not exist: ${t}`);if(!ro(t).isDirectory())throw new Error(`workspace is not a directory: ${t}`);return xt(t)}function Qt(e,t,i=!1){let n=ao(e,t);if(!i&&!n||n.startsWith("..")||Hn(n))throw new Error("path must stay inside the configured workspace");return n}function lo(e,t){let i=String(t||"").trim();if(!i||Hn(i))throw new Error("path must be a non-empty workspace-relative path");let n=xt(ei(e)),r=ei(n,i);if(Qt(n,r),!Mi(r))throw new Error(`file does not exist: ${i}`);let a=xt(r);return Qt(n,a),a}function uo(e,t){let i=String(t||"").trim();if(!i||Hn(i))throw new Error("path must be a non-empty workspace-relative path");let n=xt(ei(e)),r=ei(n,i);Qt(n,r);let a=no(r);for(;!Mi(a);){let o=no(a);if(o===a)throw new Error("unable to resolve output directory");a=o}return Qt(n,xt(a),!0),Mi(r)&&Qt(n,xt(r)),r}function hu(e,t=so){let i=Buffer.alloc(t),n=su(e,"r");try{let r=uu(n,i,0,t,0);return i.subarray(0,r).toString("utf8")}finally{ou(n)}}function co(e,t,i,n,r){if(n>Un){r.depthLimitedDirectories+=1;return}if(r.scannedDirectories>=Bn){r.directoryLimitReached=!0;return}let a;try{r.scannedDirectories+=1,a=lu(e)}catch{r.unreadableEntries+=1;return}try{let o;for(;o=a.readSync();){if(r.scannedEntries>=Yn){r.entryLimitReached=!0;return}if(r.scannedEntries+=1,o.name.startsWith(".")||o.isDirectory()&&oo.has(o.name)){r.skippedEntries+=1,o.isDirectory()&&(r.skippedDirectories+=1);continue}let s=fu(e,o.name);if(o.isDirectory()){if(co(s,t,i,n+1,r),r.entryLimitReached||r.directoryLimitReached)return;continue}if(!(!o.isFile()||!/\.json$/i.test(o.name))){r.scannedJsonFiles+=1;try{let c=ro(s),l=hu(s);if(!l.includes(du))continue;let f=l.match(/"name"\s*:\s*("(?:\\.|[^"\\])*")/)?.[1],h=cu(o.name,".json");if(f)try{h=JSON.parse(f)||h}catch{}i.push({path:ao(t,s).replaceAll("\\","/"),name:h,bytes:c.size,mtime:c.mtimeMs})}catch{r.unreadableEntries+=1}}}}catch{r.unreadableEntries+=1}finally{try{a.closeSync()}catch{r.unreadableEntries+=1}}}function Ni(e){let t=Ln(e),i=[],n={truncated:!1,warnings:[],scannedDirectories:0,scannedEntries:0,scannedJsonFiles:0,matchedArchives:0,skippedDirectories:0,skippedEntries:0,unreadableEntries:0,depthLimitedDirectories:0,entryLimitReached:!1,directoryLimitReached:!1,limits:{archives:Zt,entries:Yn,directories:Bn,depth:Un,headBytes:so},policy:{excludedDirectories:[...oo],hiddenEntries:!1,symlinks:!1,validatesJson:!1}};return co(t,t,i,0,n),i.sort((r,a)=>a.mtime-r.mtime||r.path.localeCompare(a.path)),n.matchedArchives=i.length,i.length>Zt&&n.warnings.push(`\u53D1\u73B0 ${i.length} \u4E2A\u5B58\u6863\uFF0C\u4EC5\u663E\u793A\u4FEE\u6539\u65F6\u95F4\u6700\u65B0\u7684 ${Zt} \u4E2A\uFF1B\u5176\u4ED6\u5B58\u6863\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u3002`),(n.entryLimitReached||n.directoryLimitReached)&&n.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u8FBE\u5230\u626B\u63CF\u4E0A\u9650\uFF08${Yn} \u9879 / ${Bn} \u4E2A\u76EE\u5F55\uFF09\uFF0C\u5217\u8868\u53EF\u80FD\u4E0D\u5B8C\u6574\uFF1B\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u5B58\u6863\u3002`),n.depthLimitedDirectories&&n.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u8DF3\u8FC7 ${n.depthLimitedDirectories} \u4E2A\u8D85\u8FC7 ${Un} \u5C42\u7684\u76EE\u5F55\uFF1B\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u5176\u4E2D\u7684\u5B58\u6863\u3002`),n.skippedEntries&&n.warnings.push("\u81EA\u52A8\u53D1\u73B0\u8DF3\u8FC7\u9690\u85CF\u9879\u53CA\u751F\u6210\u76EE\u5F55\uFF08\u5982 node_modules\u3001dist\uFF09\uFF1B\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u5176\u4E2D\u7684\u5B58\u6863\u3002"),n.unreadableEntries&&n.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u65E0\u6CD5\u8BFB\u53D6 ${n.unreadableEntries} \u4E2A\u6587\u4EF6\u6216\u76EE\u5F55\uFF1B\u8BF7\u68C0\u67E5\u8BBF\u95EE\u6743\u9650\uFF0C\u6216\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u67E5\u770B\u5177\u4F53\u9519\u8BEF\u3002`),n.truncated=i.length>Zt||n.entryLimitReached||n.directoryLimitReached||n.depthLimitedDirectories>0,{bound:!0,workspace:t,archives:i.slice(0,Zt),discovery:n}}var Su=Math.max(1e3,Number(process.env.QXQY_PLAY_TIMEOUT_MS)||8e3),wu=8e3;function fo(){let e=new Error("operation aborted");return e.name="AbortError",e}var Fi=class{constructor(t=""){this.workspacePath=t?Ln(t):"",this.studio=La(void 0,this.workspacePath?{workspacePath:this.workspacePath}:void 0),this.worker=null,this.pending=new Map,this.sequence=1,this.lock=Promise.resolve(),this.archivePath=""}async exclusive(t){let i=this.lock,n;this.lock=new Promise(r=>{n=r}),await i;try{return await t()}finally{n()}}get(){return this.studio.get()}patch(t){return this.studio.patch(t)}listArchives(){return Ni(this.workspacePath)}loadArchive(t){let i=this.activeWorkspacePath();if(!i)throw new Error("workspace is not bound");let n=lo(i,t),r=gu(n),a=this.studio.importData("json",r.toString("base64"),bu(n));return this.archivePath=String(t).trim().replaceAll("\\","/"),a}saveArchive(t=this.archivePath||"qxqy-simulator.save.json"){let i=String(t).trim(),n=this.activeWorkspacePath();if(!n)throw new Error("workspace is not bound");let r=uo(n,i);mu(vu(r),{recursive:!0});let a=Buffer.from(JSON.stringify(this.studio.archiveData(),null,2)+`
|
|
110
|
+
`,"utf8");return yu(r,a),this.archivePath=i.replaceAll("\\","/"),{path:this.archivePath,bytes:a.length,revision:this.studio.get().version,name:this.studio.get().save?.name||""}}activeWorkspacePath(){let t=this.studio.get().workspace;return t?.bound&&t.path?String(t.path):this.workspacePath}createWorker(){let t=new pu(new URL("./worker.js",import.meta.url),{type:"module"});return t.on("message",i=>{let n=this.pending.get(i?.id);n&&(this.pending.delete(i.id),i.ok?n.resolve(i.value):n.reject(new Error(i.error||"play worker failed")))}),t.on("error",i=>{this.worker===t&&(this.worker=null),this.rejectPending(i)}),t.on("exit",i=>{this.worker===t&&(this.worker=null),i!==0&&this.rejectPending(new Error(`play worker exited with code ${i}`))}),this.worker=t,t}rejectPending(t){for(let i of this.pending.values())i.reject(t);this.pending.clear()}async terminateWorker(t=new Error("play worker terminated")){let i=this.worker;this.worker=null,this.rejectPending(t),i&&await i.terminate().catch(()=>{})}request(t,i,n,r=Su){let a=this.worker||this.createWorker(),o=this.sequence++;return new Promise((s,c)=>{let l=!1,f=(m,g)=>{l||(l=!0,clearTimeout(p),n?.removeEventListener("abort",h),m(g))},h=()=>{this.pending.delete(o),f(c,fo()),this.terminateWorker(fo())},p=setTimeout(()=>{this.pending.delete(o);let m=new Error(`play worker timed out after ${r}ms`);f(c,m),this.terminateWorker(m)},r);if(this.pending.set(o,{resolve:m=>f(s,m),reject:m=>f(c,m)}),n?.aborted)return h();n?.addEventListener("abort",h,{once:!0}),a.postMessage({id:o,action:t,args:i})})}async play(t,i={},n){if(t==="start")return await this.terminateWorker(),this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i},n);if(t==="device"){let r=String(i.canvasId||"").trim();if(!X[r])throw new Error(`unknown canvas preset: ${r||"(empty)"} (available: ${Object.keys(X).join(", ")})`);return await this.terminateWorker(),this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i,canvasId:r},n)}if(t==="stop"){if(!this.worker)return{running:!1,tree:[],logs:[]};try{return await this.request("stop",i,n)}finally{await this.terminateWorker()}}if(!this.worker)throw new Error("play session has not started");return this.request(t,i,n)}async playScreenshot(t){if(!this.worker)throw new Error("play session has not started");let i=await this.request("get",{view:!0},t,wu),n=to(i.scene,i.canvasWidth,i.canvasHeight);return{data:n.data,canvasId:String(i.canvasId||""),frame:Number.isFinite(Number(i.frame))?Number(i.frame):0,time:Number.isFinite(Number(i.time))?Number(i.time):0,width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight}}uiScreenshot(){let t=io(this.studio.get());return{data:t.data,page:t.page,width:t.width,height:t.height,pixelWidth:t.pixelWidth,pixelHeight:t.pixelHeight}}async dispose(){await this.terminateWorker()}};import{defineTool as Et}from"@deepseek-ai/dsh-tools";import{existsSync as mo,realpathSync as ho}from"node:fs";import{isAbsolute as Xn,relative as po,resolve as Oi}from"node:path";function go(e,t){if(!e)throw new Error("\u5DE5\u4F5C\u533A\u672A\u7ED1\u5B9A\uFF0C\u65E0\u6CD5\u4ECE\u78C1\u76D8\u62C9\u53D6\u5B58\u6863");let i=String(t||"").trim();if(!i)throw new Error("path is required");let n=ho(Oi(e)),r=Xn(i)?Oi(i):Oi(n,i),a=po(n,r);if(!a||a.startsWith("..")||Xn(a))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");if(!mo(r))throw new Error(`\u5B58\u6863\u4E0D\u5B58\u5728: ${i}`);let o=ho(r),s=po(n,o);if(!s||s.startsWith("..")||Xn(s))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");return o}function yo(e){if(!e)return{bound:!1,archives:[]};let t=Oi(e);return mo(t)?Ni(t):{bound:!1,archives:[]}}var cd="qxqy-simulator",fd=["tools","webServer"],bo="/qxqy-simulator/api",vo="/qxqy-simulator/play",xu="/qxqy-simulator/play-renderer.js",Eu=8*1024*1024,Au=32,So=8e3,qn=class extends Fi{constructor(t=""){super(t),this.touchedAt=Date.now()}touch(){this.touchedAt=Date.now()}get(){return this.touch(),super.get()}patch(t){return this.touch(),super.patch(Di(t))}exportData(t,i){return this.touch(),this.studio.exportData(t,i)}importData(t,i,n){return this.touch(),this.studio.importData(t,i,n)}listArchives(){return this.touch(),yo(this.studio.get().workspace?.path||"")}loadArchive(t){this.touch();let i=this.studio.get().workspace?.path||"",n=go(i,t),r=Jn(n),a=this.studio.importData("json",r.toString("base64"),Cu(n));return this.archivePath=ku(Iu(i),n).replaceAll("\\","/"),a}async play(t,i={},n){return this.touch(),super.play(t,Di(i)||{},n)}async requestScreenshot(t){return{...await super.playScreenshot(t),capturedAt:new Date().toISOString()}}requestUiScreenshot(){return this.touch(),{...super.uiScreenshot(),capturedAt:new Date().toISOString()}}async dispose(){await this.terminateWorker()}};function Io(e){let t=String(e||"").trim();if(!t||t.length>256)throw new Error("sessionId is required");return t}function Di(e){if(e!=null){if(typeof e!="string")return e;try{let t=JSON.parse(e);return t&&typeof t=="object"?t:void 0}catch{return}}}function At(e){return Io(e?.agent?.id)}function jn(e){let t=e?.cwd;return typeof t=="string"&&t?t:""}function _t(e){return jn(e?.agent?.session?.header)}async function _u(e,t={}){let i=t.sessions?.get?.(e),n=jn(i?.header);if(n)return n;let r=t.sessionPersistence?.inspect;if(typeof r!="function")return"";try{let a=await r.call(t.sessionPersistence,e);return jn(a?.meta)}catch{return""}}function Pu(){let e=new Map;function t(){if(e.size<Au)return;let i=[...e.entries()].sort((n,r)=>n[1].touchedAt-r[1].touchedAt)[0];i&&(e.delete(i[0]),i[1].dispose())}return{get(i,n=""){let r=Io(i),a=e.get(r);return a?n&&a.studio.setWorkspace(n):(t(),a=new qn(n),e.set(r,a)),a.touch(),a},async dispose(){await Promise.all([...e.values()].map(i=>i.dispose())),e.clear()}}}function $i(e,t,i){let n=JSON.stringify(i);e.statusCode=t,e.setHeader("content-type","application/json; charset=utf-8"),e.setHeader("cache-control","no-store"),e.end(n)}function Ru(){if(!Kn){let t=[new URL("./play.html",import.meta.url),new URL("../lib/play.html",import.meta.url)].find(i=>wo(i));if(!t)throw new Error("standalone play page is missing");Kn=Jn(t,"utf8")}return Kn}var Kn=null;function Tu(){if(!Wn){let t=[new URL("../dist/play-renderer.js",import.meta.url),new URL("./play-renderer.js",import.meta.url)].find(i=>wo(i));if(!t)throw new Error("standalone play renderer bundle is missing; run npm run build");Wn=Jn(t,"utf8")}return Wn}var Wn=null;function Mu(e){e.webServer.register({kind:"prefix",path:vo,handler(t,i){let n=new URL(t.url,"http://localhost").pathname.replace(/\/$/,"");if(t.method!=="GET"||n!==vo){i.statusCode=t.method==="GET"?404:405,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(t.method==="GET"?"not found":"GET required");return}i.statusCode=200,i.setHeader("content-type","text/html; charset=utf-8"),i.setHeader("cache-control","no-store"),i.setHeader("x-content-type-options","nosniff"),i.end(Ru())}})}function Nu(e){e.webServer.register({kind:"exact",path:xu,handler(t,i){if(t.method!=="GET"){i.statusCode=405,i.setHeader("content-type","text/plain; charset=utf-8"),i.end("GET required");return}try{i.statusCode=200,i.setHeader("content-type","text/javascript; charset=utf-8"),i.setHeader("cache-control","no-store"),i.setHeader("x-content-type-options","nosniff"),i.end(Tu())}catch(n){i.statusCode=500,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(n?.message||String(n))}}})}function Fu(e){return new Promise((t,i)=>{let n=0,r=[];e.on("data",a=>{if(n+=a.length,n>Eu){i(new Error("request body is too large")),e.destroy();return}r.push(a)}),e.on("end",()=>{try{let a=Buffer.concat(r).toString("utf8");t(a?JSON.parse(a):{})}catch{i(new Error("invalid JSON body"))}}),e.on("error",i)})}function Ou(e,t){e.tools.register(Et({name:"qxqy_studio_get",description:"\u8BFB\u53D6\u5F53\u524D DeepSeek Harness \u4F1A\u8BDD\u7684\u5343\u661F UI \u7F16\u8F91\u5668\u65E0\u635F JSON \u5FEB\u7167\u3002",parameters:{},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!0,async execute(i,n){return t.get(At(n),_t(n)).get()}})),e.tools.register(Et({name:"qxqy_studio_play_screenshot",description:"\u83B7\u53D6\u5F53\u524D\u8BD5\u73A9 Runtime \u753B\u9762\u7684 PNG\u3002Host \u4E0E\u72EC\u7ACB\u8BD5\u73A9\u9875\u5171\u7528 Runtime scene \u6811\uFF08\u540C\u7EA7\u5148\u51FA\u73B0\u7684\u5B50\u8282\u70B9\u5728\u4E0A\uFF09\u518D\u753B\u6210 PNG\uFF0C\u4E0D\u9700\u8981\u6253\u5F00\u8BD5\u73A9\u9875\u6216\u5207\u6362\u6807\u7B7E\u3002\u4EC5\u5728\u9700\u8981\u89C2\u5BDF\u8FD0\u884C\u65F6\u753B\u9762\u3001\u52A8\u753B\u6216\u4EA4\u4E92\u7ED3\u679C\u65F6\u8C03\u7528\uFF1B\u82E5\u8981\u770B\u7F16\u8F91\u5668\u821E\u53F0\uFF0C\u8BF7\u6539\u7528 qxqy_studio_ui_screenshot\u3002\u4E0D\u4F1A\u6B65\u8FDB\u65F6\u95F4\uFF0C\u4E5F\u4E0D\u66FF\u4EE3 get {inspect:true} \u7684\u7ED3\u6784\u5316\u65AD\u8A00\u3002",parameters:{},output:{schema:{type:"json"},render:(i,n)=>{let a=[{type:"text",text:`\u8BD5\u73A9\u622A\u56FE\uFF1A${n.canvasId||"unknown"}\uFF0CFrame ${n.frame??0}\uFF0C${n.width||0}\xD7${n.height||0}`}];return n.image&&a.push({type:"image",attachment:n.image}),a}},timeoutMs:So+1e3,isConcurrencySafe:()=>!1,async execute(i,n){let a=await t.get(At(n),_t(n)).requestScreenshot(n.signal),o=e.get?.("attachments");if(!o?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let s=await o.saveImage({data:a.data,mediaType:"image/png",name:`qxqy-play-${a.canvasId||"canvas"}-f${a.frame}.png`}),{data:c,...l}=a;return{...l,image:{attachmentId:s.attachmentId,mediaType:s.mediaType,bytes:s.bytes,width:s.width,height:s.height,...s.name===void 0?{}:{name:s.name}}}}})),e.tools.register(Et({name:"qxqy_studio_ui_screenshot",description:"\u83B7\u53D6\u5F53\u524D\u7F16\u8F91\u5668\u821E\u53F0\u7684 PNG\u3002Host \u6839\u636E boxes \u5728\u8FDB\u7A0B\u5185\u6E32\u67D3\uFF0C\u4E0D\u9700\u8981\u6253\u5F00\u6216\u4FDD\u6301\u201C\u6A21\u62DF\u5668\u201D\u6807\u7B7E\u3002\u7528\u4E8E\u68C0\u67E5\u9759\u6001 UI \u5E03\u5C40\u3001\u9009\u4E2D\u9879\u548C\u63A7\u4EF6\u56FE\u5143\uFF1B\u4E0D\u542B\u5B8C\u6574 Chrome DOM \u5DE5\u5177\u680F/\u68C0\u89C6\u5668\u3002\u82E5\u8981\u770B Lua Runtime \u8BD5\u73A9\u753B\u9762\uFF0C\u8BF7\u6539\u7528 qxqy_studio_play_screenshot\u3002",parameters:{},output:{schema:{type:"json"},render:(i,n)=>{let o=[{type:"text",text:`\u7F16\u8F91\u5668\u622A\u56FE\uFF1A${n.page||"\u6A21\u62DF\u5668"}\uFF0C${n.width||0}\xD7${n.height||0}`}];return n.image&&o.push({type:"image",attachment:n.image}),o}},timeoutMs:So+1e3,isConcurrencySafe:()=>!1,async execute(i,n){let a=t.get(At(n),_t(n)).requestUiScreenshot(),o=e.get?.("attachments");if(!o?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let s=await o.saveImage({data:a.data,mediaType:"image/png",name:`qxqy-ui-${a.page||"editor"}.png`}),{data:c,...l}=a;return{...l,image:{attachmentId:s.attachmentId,mediaType:s.mediaType,bytes:s.bytes,width:s.width,height:s.height,...s.name===void 0?{}:{name:s.name}}}}})),e.tools.register(Et({name:"qxqy_studio_patch",description:"\u4FEE\u6539\u5F53\u524D\u4F1A\u8BDD\u7684\u5343\u661F UI \u5DE5\u7A0B\u3002op \u5FC5\u987B\u643A\u5E26 expectedRevision \u4EE5\u9632\u6B62\u9648\u65E7\u5199\u5165\u3002",parameters:{op:{type:"json",required:!0,description:"\u7F16\u8F91\u5668 patch \u5BF9\u8C61\u3002"}},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!1,async execute(i,n){let r=Di(i.op);if(!r)throw new Error("patch requires op");return t.get(At(n),_t(n)).patch(r)}})),e.tools.register(Et({name:"qxqy_studio_play",description:"\u63A7\u5236\u5F53\u524D\u4F1A\u8BDD\u7684\u5343\u661F UI \u8BD5\u73A9 Worker\uFF1A\u542F\u52A8\u3001\u6B65\u8FDB\u3001\u8F93\u5165\u3001\u6682\u505C\u3001\u505C\u6B62\u3001\u591A\u8BBE\u5907\u753B\u5E03\u5207\u6362\u3001\u591A\u4EBA\u89C6\u89D2\u3001\u670D\u52A1\u7AEF\u53D8\u91CF/\u4FE1\u53F7\uFF0C\u4EE5\u53CA\u5F55\u5236\u56DE\u653E\u7528\u4F8B\u3002",parameters:{action:{type:"string",enum:["start","device","view","get","step","pointer","key","click","pause","resume","stop","serverGet","serverSet","serverSend","history","saveCase","runCase"],required:!0},args:{type:"json",description:"\u52A8\u4F5C\u53C2\u6570\uFF1Bpointer \u4F7F\u7528 type/x/y\uFF0Cstep \u4F7F\u7528 dt\uFF1Bget/start \u53EF\u7528 inspect:true \u62C9\u8FD0\u884C\u6811\uFF1Bstart/device \u7528 canvasId \u5207\u6362\u8BBE\u5907\u753B\u5E03\uFF08\u5982 pc-16-9 / mobile-19.5-9\uFF09\uFF1Bstart \u53EF\u7528 playerCount(1-8)\uFF1Bview \u7528 playerIndex \u5207\u6362\u5F53\u524D\u73A9\u5BB6\u89C6\u89D2\uFF1BrunCase \u53EF\u5E26 canvasId/playerCount\uFF1BserverSet \u4F7F\u7528 entityType/name/value\uFF1BrunCase \u4F7F\u7528 case\u3002"}},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:1e4,isConcurrencySafe:()=>!1,async execute(i,n){let r=Di(i.args)||{};return t.get(At(n),_t(n)).play(i.action,r,n.signal)}})),e.tools.register(Et({name:"qxqy_studio_load",description:"\u4ECE\u5F53\u524D\u4F1A\u8BDD\u5DE5\u4F5C\u533A\u62C9\u53D6\u5343\u661F\u6A21\u62DF\u5668\u5B58\u6863\u3002\u4E0D\u4F20 path \u65F6\u5217\u51FA\u5DE5\u4F5C\u533A\u5185\u7684 qxqy-simulator-save\uFF1B\u4F20\u5165\u76F8\u5BF9\u8DEF\u5F84\u5219\u52A0\u8F7D\u8BE5\u5B58\u6863\u3002",parameters:{path:{type:"string",description:"\u5DE5\u4F5C\u533A\u5185\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 workspace/flappy-fish/flappy-fish.save.json\u3002\u7701\u7565\u5219\u53EA\u5217\u51FA\u53EF\u62C9\u53D6\u5B58\u6863\u3002"}},output:{schema:{type:"json"},render:(i,n)=>[{type:"text",text:JSON.stringify(n,null,2)}]},timeoutMs:8e3,isConcurrencySafe:()=>!1,async execute(i,n){let r=t.get(At(n),_t(n));return i.path?r.loadArchive(i.path):r.listArchives()}}))}function $u(e,t){e.webServer.register({kind:"prefix",path:bo,async handler(i,n){if(i.method!=="POST"){$i(n,405,{ok:!1,value:null,error:"POST required"});return}let a=new URL(i.url,"http://localhost").pathname.slice(bo.length).replace(/^\/+/,"");if(a==="health"){$i(n,200,{ok:!0,value:{status:"ok"},error:null});return}let o=new AbortController;i.once("aborted",()=>o.abort());try{let s=await Fu(i),c=await _u(s.sessionId,{sessions:e.get?.("sessions"),sessionPersistence:e.get?.("sessionPersistence")}),l=t.get(s.sessionId,c),f;if(a==="get")f=l.get();else if(a==="patch")f=l.patch(s.op);else if(a==="export")f=l.exportData(s.format,s.assetType);else if(a==="import")f=l.importData(s.format,s.data,s.filename);else if(a==="archives")f=l.listArchives();else if(a==="load-archive")f=l.loadArchive(s.path);else if(a==="play")f=await l.play(s.action,s.args||{},o.signal);else throw new Error("unknown API action");$i(n,200,{ok:!0,value:f,error:null})}catch(s){$i(n,400,{ok:!1,value:null,error:s?.message||String(s)})}}})}function dd(e){let t=Pu();Ou(e,t),$u(e,t),Mu(e),Nu(e),e.effect(()=>()=>{t.dispose()},"qxqy-simulator: dispose sessions")}export{qn as SimulatorController,dd as apply,jn as headerWorkspace,fd as inject,Di as jsonParam,_u as lookupSessionWorkspace,cd as name,_t as sessionWorkspace};
|