dsh-plugin-beyond-simulator 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dsh-plugin/cordis.patch.yml +1 -1
- package/dsh-plugin/dist/client.js +11 -8
- package/dsh-plugin/dist/index.js +49 -14
- package/dsh-plugin/dist/play-renderer.js +73 -72
- package/dsh-plugin/dist/worker.js +44 -11
- package/dsh-plugin/lib/play.html +56 -40
- package/dsh-plugin/presets/wonderland-lua-builder/README.md +8 -0
- package/dsh-plugin/presets/wonderland-lua-builder/agent.cordis.yml +1 -1
- package/dsh-plugin/skill.md +3 -1
- package/package.json +2 -2
package/dsh-plugin/dist/index.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import{existsSync as hl,readFileSync as ml,realpathSync as hd}from"node:fs";import{relative as md}from"node:path";import{Worker as id}from"node:worker_threads";import{existsSync as rd,mkdirSync as nd,readFileSync as aa,writeFileSync as ad}from"node:fs";import{basename as od,dirname as sd}from"node:path";import{existsSync as vi,readFileSync as Du}from"node:fs";import{randomUUID as zu}from"node:crypto";import{isAbsolute as ya,win32 as ba}from"node:path";function _i(e,t=!1){let i=String(e??"").trim().replaceAll("\\","/");if(t&&(!i||i==="."))return"";if(!i||ya(i)||ba.isAbsolute(i)||i.split("/").some(r=>!r||r==="."||r===".."||/[<>:"|?*\x00-\x1f]/.test(r)||/[. ]$/.test(r)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(r)))throw new Error("\u811A\u672C\u76EE\u5F55/\u8DEF\u5F84\u5FC5\u987B\u662F\u6709\u6548\u7684\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B .. \u6216 Windows \u7279\u6B8A\u6587\u4EF6\u540D");return i}function Jt(e){if(e==null)return null;if(e.version!==1)throw new Error("unsupported scriptSync version");let t=String(e.clientImportRoot||"").trim();if(!ya(t)&&!ba.isAbsolute(t))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:_i(e.workspaceDir,!0),clientImportRoot:t,clientSubdir:_i(e.clientSubdir,!0)}}import{basename as Ht,dirname as $u,isAbsolute as Gu,join as Is,resolve as xs}from"node:path";var va="https://oss.070077.xyz/prefabs/",Zt="prefab-v1",zl=[[10003004,10003004],[10005001,10005142],[10006001,10006002],[10007002,10007002],[10008001,10008001],[10009001,10009011],[20001001,20001074],[20001076,20001121],[20001123,20001156],[20001158,20001302],[20001304,20001568],[20001570,20001999],[20002001,20002755],[20002757,20002999],[20003001,20003455],[30001001,30001016],[30002001,30002017],[30003001,30003011],[30004001,30004001],[30005001,30005020],[30006001,30006026],[30007001,30007013],[30008001,30008011]];function Pi(e){return!Number.isSafeInteger(e)||!zl.some(([t,i])=>e>=t&&e<=i)?null:e===10003004||e===10008001?128:256}var Ti="https://oss.070077.xyz/images/",Rr="sprite-v1",Ri="/qxqy-assets/",$l=[[100001,100006],[100101,100213],[101001,101018],[101020,101028],[101030,101046],[101048,101048],[101050,101054],[101056,101080],[102001,102052],[103001,103148],[104001,104010],[105001,105140],[105142,105219],[105221,105317],[106001,106047],[106049,106096],[107001,107007],[107010,107020],[107031,107092],[107094,107180],[107183,107201],[107203,107205],[107207,107228],[107231,107278],[107280,107402],[108001,108017],[108019,108020],[109001,109031],[109033,109034],[109036,109075],[110001,110053],[111001,111139],[112001,112042]];function Ie(e){return e==null||e===""?"StaticReference":typeof e=="string"?e:typeof e.Name=="string"?e.Name:"Unknown"}function Mi(e,t){return`${Ie(t)}:${e}`}function Sa(e,t){return Ie(t)==="StaticReference"&&Xe(e,t)}function Xe(e,t){let i=Ie(t);return i==="Prefab"?Pi(e)!==null:i==="StaticReference"&&Number.isSafeInteger(e)&&e>100006&&$l.some(([r,n])=>e>=r&&e<=n)}var Ni="7.1.0",ce=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),J=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"}}),Oi="pc-16-9",pe=2,kt=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),Et=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"}),Fi=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),wa=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}),Gl=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"});function At(e,t){return Ie(t)==="StaticReference"&&Gl[e]||(Xe(e,t)?"sprite":"missing")}var Ia=50888,Qt=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function _t(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((r,n)=>_t(r,`${t}[${n}]`,i));else for(let[r,n]of Object.entries(e))_t(n,`${t}.${r}`,i);i.delete(e)}}function G(e){return _t(e),JSON.parse(JSON.stringify(e))}function xa(e,t="$"){_t(e,t)}function Ca(e){return J[e]||J[Oi]}function ei(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 Vl(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 Hl(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 Di({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 De(e){let t=e||Di();return{scale:Vl(t.scale),rotation:Hl(t.rotation),anchorMin:ei(t.anchorMin??t.anchor_min,.5,.5),anchorMax:ei(t.anchorMax??t.anchor_max,.5,.5),offset:ei(t.offset,0,0),size:ei(t.size,0,0),pivot:ei(t.pivot,.5,.5)}}function ge(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ge(e,t){let i=e.width,r=e.height,n=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},u=t.pivot||{x:t.pivotX,y:t.pivotY},d=ge(o?.x,.5)*i,h=ge(o?.y,.5)*r,p=ge(s?.x,.5)*i,m=ge(s?.y,.5)*r,y=ge(l?.x),x=ge(l?.y),E=ge(u?.x,.5),I=ge(u?.y,.5),O=p-d+y,N=m-h+x,H=n+d+ge(c?.x)-y*E,B=a+h+ge(c?.y)-x*I;return{left:H,bottom:B,width:O,height:N,right:H+O,top:B+N,centerX:H+O/2,centerY:B+N/2}}function Pt(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function Yl(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 Ve(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 Mr(e,t){let i=t.rotation||{z:t.localRotationZ},r=t.scale||{x:t.localScaleX,y:t.localScaleY},n=t.pivot||{x:t.pivotX,y:t.pivotY},a=ge(i?.z)*Math.PI/180,o=Math.cos(a),s=Math.sin(a),c=ge(r?.x,1),l=ge(r?.y,1),u=e.left+e.width*ge(n?.x,.5),d=e.bottom+e.height*ge(n?.y,.5),h=o*c,p=s*c,m=-s*l,y=o*l;return{a:h,b:p,c:m,d:y,tx:u-h*u-m*d,ty:d-p*u-y*d}}function ti(e,t,i){return Yl(e||Pt(),Mr(t,i))}function ka(e,t){let i=xe(t,e.centerX,e.centerY),r=Math.abs(e.width*Math.hypot(t.a,t.b)),n=Math.abs(e.height*Math.hypot(t.c,t.d));return{left:i.x-r/2,bottom:i.y-n/2,width:r,height:n,centerX:i.x,centerY:i.y,rotationZ:Math.atan2(t.b,t.a)*180/Math.PI}}function ye(e){let t=typeof e=="string"?Ca(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 Nr(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function ot(e,t,i){let r=De(t),n=e.width,a=e.height,o=r.anchorMin.x*n,s=r.anchorMin.y*a,c=r.anchorMax.x*n,l=r.anchorMax.y*a,u=Number(i.width),d=Number(i.height),h=Number(i.posX),p=Number(i.posY),m=h-u/2,y=p-d/2;return r.size={x:u-(c-o),y:d-(l-s)},r.offset={x:m-e.left-o+r.size.x*r.pivot.x,y:y-e.bottom-s+r.size.y*r.pivot.y},r}function Ea(e,t){let i=De(e),n={"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 n&&(i.anchorMin={x:n[0][0],y:n[0][1]},i.anchorMax={x:n[1][0],y:n[1][1]},i.pivot={x:n[2][0],y:n[2][1]}),i}function Aa(e){let t=De(e),i=(r,n)=>Math.abs(r-n)<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 r=t.anchorMin.x,n=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(r,o[0])&&i(n,o[1]))return o[2]}return"custom"}function st(e){return Ca(e).platform}function _a(e){let t={};for(let i of ce)t[i]=e(i);return t}var Bl={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function Pa(e,t){for(let[i,r]of Object.entries(Bl))for(let n of r)if(!Number.isFinite(e?.[i]?.[n]))throw new Error(`${t}.${i}.${n} must be a finite number`)}function qe(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(!ce.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of ce)Pa(e[i],`${t}.${i}`)}function lt(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`);qe(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function ct(e,t){if(!ce.includes(t))throw new Error(`unknown platform ${t}`);return Pa(e?.[t],`transformByPlatform.${t}`),De(e[t])}var Ul=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"}]),jl=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:"imageSlotType",label:"\u56FE\u7247\u7C7B\u578B\u539F\u59CB\u503C",type:"number",defaultValue:0,wire:"ImageSlotConfig.imageType"},{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 Ta(e){return[...Ul,...jl[e]||[]]}function Ra(e,t){return Ta(e).find(i=>i.key===t)||null}function Or(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 Ma(e,t={}){let i={};for(let r of Ta(e)){let n=Object.hasOwn(t||{},r.key)?t[r.key]:r.defaultValue;i[r.key]=Or(r,n)}return i}function _e(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Fr(e,t){if(e){t(e);for(let i of e.children||[])Fr(i,t)}}function Tt(e,t=new Set,{skipServerContainer:i=!1}={}){return Fr(e,r=>{i&&r.kind==="server-container"||_e(r.guid)&&t.add(Number(r.guid))}),t}function We(e,t=1073741850){let i=Number.isSafeInteger(t)&&t>0?t:1073741850;i<1073741850&&(i=1073741850);for(let r of e)_e(r)&&r>=i&&(i=Number(r)+1);for(;e.has(i);)i+=1;if(i>2147483647)throw new Error("GUID space exhausted");return i}function Na(e,t=new Set,{skipServerContainer:i=!1}={}){let r=[];Fr(e,n=>{if(i&&n.kind==="server-container")return;let a=Number(n.guid);if(_e(a)&&!t.has(a)){t.add(a),n.guid=a;return}r.push(n)});for(let n of r){let a=We(t);n.guid=a,t.add(a)}return t}function ke(e){return Number.isSafeInteger(e)&&e>0&&e<=2147483647}function He(e,{warnings:t=[]}={}){if(e.meta?.assetType!=="client-control-template")return;if(e.meta.giaAssetIndexSchemaVersion>1)throw new Error(`\u4E0D\u652F\u6301\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7\u7248\u672C ${e.meta.giaAssetIndexSchemaVersion}`);let i=[],r=m=>{m.kind!=="server-container"&&i.push(m);for(let y of m.children||[])r(y)};r(e.root);let n=new Map,a=new Map;for(let m of i){if(!ke(m.giaInfoIndex))continue;let y=n.get(m.giaInfoIndex)||[];y.push(m),n.set(m.giaInfoIndex,y);let x=a.get(m.kind)||new Set;x.add(m.giaInfoIndex),a.set(m.kind,x)}let o=(e.root.children||[]).filter(m=>m.kind!=="server-container"),s=new Set(o),c=o.some((m,y)=>ke(m.giaInfoIndex)&&o.slice(0,y).some(x=>x.giaInfoIndex===m.giaInfoIndex)),l=!e.meta.giaAssetIndexSchemaVersion&&c&&i.every(m=>m.giaInfoIndexSource!=="authoring")&&[...a.values()].every(m=>m.size===1)&&[...n.values()].every(m=>m.every(y=>y.kind===m[0].kind)),u=new Set;if(l)for(let m of n.values()){let y=m.find(x=>s.has(x))||m[0];for(let x of m)x!==y&&u.add(x)}let d=new Map,h=Number.isSafeInteger(e.meta.giaNextAssetIndex)&&e.meta.giaNextAssetIndex>=2?e.meta.giaNextAssetIndex:2;for(let m of i){if(!ke(m.giaInfoIndex)||(h=Math.max(h,m.giaInfoIndex+1),u.has(m)))continue;let y=d.get(m.giaInfoIndex);if(y&&(y.giaInfoIndexSource==="authoring"||m.giaInfoIndexSource==="authoring"))throw new Error(`\u65B0\u5EFA\u8D44\u4EA7\u7F16\u53F7 ${m.giaInfoIndex} \u91CD\u590D\uFF1A${y.name} / ${m.name}`);d.set(m.giaInfoIndex,m)}l&&(h=Math.max(h,13));let p=l?[...o,...i.filter(m=>!s.has(m))].filter(m=>u.has(m)||!ke(m.giaInfoIndex)):i.filter(m=>!ke(m.giaInfoIndex));if(p.length&&h+p.length-1>2147483647)throw new Error("\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7\u7A7A\u95F4\u5DF2\u8017\u5C3D");for(let m of p)m.giaInfoIndex=h++,m.giaInfoIndexSource="authoring";e.meta.giaNextAssetIndex=h,e.meta.giaAssetIndexSchemaVersion=1,u.size&&t.push(`\u65E7\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7\u81EA\u52A8\u8FC1\u79FB\uFF1A\u4FEE\u590D ${u.size} \u6761\u6309\u63A7\u4EF6\u7C7B\u578B\u590D\u7528\u7684\u7F16\u53F7\uFF1BGUID\u3001Lua \u5F15\u7528\u548C\u63A7\u4EF6\u5C5E\u6027\u4FDD\u6301\u4E0D\u53D8\u3002`)}var Dr=1;function zr(e="n"){let t=`${e}${Dr}`;return Dr+=1,t}function zi(e=1){Dr=e}function $r(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return Di({layout:"stretch"});let i=wa[e]||[80,80];return Di({layout:"center",size:i})}function Ll(e,t){return _a(()=>$r(e,t))}function Xl(e){qe(e);let t={};for(let i of ce)t[i]=ct(e,i);return t}function W(e,t={}){if(!Et[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&<(t);let i=t.isRootContainer===!0,r=t.id||zr(e==="server-container"?"sc":"n"),n=Object.hasOwn(t,"transformByPlatform")?Xl(t.transformByPlatform):Ll(e,{isRootContainer:i}),a={id:r,kind:e,name:t.name||Et[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(o=>Number.isSafeInteger(Number(o))&&Number(o)>0).map(Number):[],...ke(Number(t.giaInfoIndex))?{giaInfoIndex:Number(t.giaInfoIndex),giaInfoIndexSource:t.giaInfoIndexSource==="authoring"?"authoring":"imported"}:{},active:t.active!==!1,visible:t.visible!==!1,canControllerFocus:t.canControllerFocus??t.giaRaw?.footerField505===1,syncAllDevices:t.syncAllDevices!==!1,giaRaw:Ma(e,t.giaRaw),transformByPlatform:n,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??Qt.font,a.bgColor=t.bgColor??Qt.bg,a.enableOutline=t.enableOutline!==!1,a.outlineColor=t.outlineColor??Qt.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.imageType=["Basic","Stretch"].includes(t.imageType)?t.imageType:null,a.imageId=t.imageId??100001,a.imageColor=t.imageColor??Qt.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??Ia,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 ut(){zi(1);let e=W("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),t=W("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=W("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),r=W("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),n=W("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),a=W("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),o=W("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),s=W("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),c=W("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),l=W("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),u=W("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),d=W("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),h=(p,m,y)=>{for(let x of Object.values(p.transformByPlatform))x.offset={x:m,y}};return h(i,-300,250),h(r,-300,140),h(n,-300,30),h(a,-300,-100),h(o,0,0),h(s,300,250),h(c,300,140),h(l,300,30),h(u,300,-100),t.children.push(i,r,n,a,o,s,c,l,u,d),e.children.push(t),zi(12),Na(e),{version:1,layoutSchemaVersion:pe,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 Rt(){zi(1);let e=W("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),t=W("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=W("textbox",{id:"n2",guid:1073742101,name:"\u6A21\u677F\u6807\u9898",text:"\u5BA2\u6237\u7AEF\u6A21\u677F\u5DF2\u5B9E\u4F8B\u5316",fontSize:28,horizontalAlignment:"Middle"}),r=W("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),n=W("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),a=W("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),o=(l,u,d)=>{for(let h of Object.values(l.transformByPlatform))h.offset={x:u,y:d}};((l,u,d)=>{for(let h of Object.values(l.transformByPlatform))h.size={x:u,y:d}})(t,520,320),o(i,0,110),o(r,0,0),o(n,0,-110),n.children.push(a),t.children.push(i,r,n),e.children.push(t),zi(6);let c={version:1,layoutSchemaVersion:pe,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:Ni,giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:e};return He(c),c}function Q(e,t,i=null){t(e,i);for(let r of e.children||[])Q(r,t,e)}function fe(e,t){let i=null;return Q(e,r=>{r.id===t&&(i=r)}),i}function Gr(e,t="n"){let i=zr(t);for(;fe(e,i);)i=zr(t);return i}function Ke(e,t){let i=null;return Q(e,(r,n)=>{r.id===t&&(i=n)}),i}function Vr(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function ii(e){if(e.meta?.assetType!=="client-control-template")return Vr(e);let t=fe(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=Ke(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=Ke(e.root,t.id);return t}function Hr(e){lt(e);let t={id:e.id,name:e.name,guid:e.guid,giaRelatedGuids:e.giaRelatedGuids,giaInfoIndex:e.giaInfoIndex,giaInfoIndexSource:e.giaInfoIndexSource,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.imageType=e.imageType,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"&&ql(e.transformByPlatform);let i=W(e.kind,t);return i.children=(e.children||[]).map(r=>Hr(r)),i}function ql(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 Oa(e,t,i={}){if(e.kind==="server-container"&&t!=="container")throw new Error("server container only accepts container nodes");let r=W(t,i);return e.children.push(r),r}function Fa(e,t){if(e.id===t)throw new Error("cannot remove root");let i=Ke(e,t);if(!i)return!1;let r=i.children.findIndex(n=>n.id===t);return r<0?!1:(i.children.splice(r,1),!0)}var Da=1e-4;function Wl(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>Da&&Math.abs(e.size[t])<=Da}function Kl(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 r=Ge(t,e),n=(r.centerX-t.left)/t.width,a=(r.centerY-t.bottom)/t.height,o=ot(i,e,{posX:i.left+n*i.width,posY:i.bottom+a*i.height,width:r.width,height:r.height});for(let s of["x","y"])Wl(e,s)&&(o.offset[s]=e.offset[s],o.size[s]=e.size[s]);return o}function za({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:r,sourceParentBox:n=ye(i),targetParentBoxByPlatform:a={}}){qe(e);let o=st(i),s={};for(let c of ce)c===o?s[c]=De(t):r!==!1?s[c]=Kl(t,n,a[c]||ye(kt[c])):s[c]=ct(e,c);return qe(s),s}function Je(e,t){return ct(e,st(t))}function $a(e,t){let i=[];function r(n){t[n.id]&&i.push(t[n.id]);let a=n.children||[];for(let o=a.length-1;o>=0;o-=1)r(a[o])}return r(e),i}function Ze(e,t,i=st(t)){let r=ye(t),n={};function a(o,s,c){let l=ct(o.transformByPlatform,i),u=Ge(s,l),d=o.kind==="server-container"?c:ti(c,u,l),h=ka(u,d);n[o.id]={...u,...Nr(u),id:o.id,kind:o.kind,name:o.name,visible:o.visible!==!1,active:o.active!==!1,rotationZ:l.rotation.z,renderLeft:h.left,renderBottom:h.bottom,renderWidth:h.width,renderHeight:h.height,renderRotationZ:h.rotationZ,renderMatrix:d,primitive:o.kind==="image"?At(o.imageId,o.imageSource):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,imageType:o.imageType??null,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 p=o.kind==="server-container"?s:u;for(let m of o.children||[])a(m,p,d)}return a(e,r,Pt()),{canvas:r,boxes:n}}function Yr(e,t){let i=[];function r(n,a,o=null,s=[],c=0,l=1,u=e.id){i.push({id:n.id,guid:t?.get(n.id)??(n.guid||0),kind:n.kind,name:n.name,label:Et[n.kind]||n.kind,depth:a,parentId:o,ancestorIds:s,siblingIndex:c,siblingCount:l,templateId:u,childCount:(n.children||[]).length,incomplete:!Fi.includes(n.kind)});let d=n.children||[];for(let h=0;h<d.length;h+=1)r(d[h],a+1,n.id,[...s,n.id],h,d.length,u)}return r(e,0),i}function P(e,t,i,r,n={}){return{key:e,label:t,type:i,value:r,...n}}function Ga(e,t,i,r){if(!e)return null;let n=Je(e.transformByPlatform,t),a=Nr(i),o=[P("name","\u540D\u79F0","string",e.name),P("active","\u521D\u59CB\u6FC0\u6D3B","bool",e.active!==!1),P("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",e.visible!==!1),P("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",e.canControllerFocus===!0),P("posX","\u4F4D\u7F6E X","number",a.posX,{computed:!0}),P("posY","\u4F4D\u7F6E Y","number",a.posY,{computed:!0}),P("width","\u5927\u5C0F W","number",a.width,{computed:!0}),P("height","\u5927\u5C0F H","number",a.height,{computed:!0}),P("rotationZ","\u65CB\u8F6C Z","number",n.rotation.z),P("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",e.syncAllDevices!==!1),P("anchorType","\u951A\u70B9\u7C7B\u578B","enum",Aa(n),{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"}]}),P("anchorMinX","\u951A\u70B9 Min X","number",n.anchorMin.x),P("anchorMinY","\u951A\u70B9 Min Y","number",n.anchorMin.y),P("anchorMaxX","\u951A\u70B9 Max X","number",n.anchorMax.x),P("anchorMaxY","\u951A\u70B9 Max Y","number",n.anchorMax.y),P("pivotX","\u4E2D\u5FC3 X","number",n.pivot.x),P("pivotY","\u4E2D\u5FC3 Y","number",n.pivot.y)];if(e.kind==="container"&&o.push(P("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",e.isolateNavigation===!0),P("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableKeyEventPassthrough===!0),P("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableCursorEventPassthrough===!0),P("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(P("fontSize","\u5B57\u53F7","number",e.fontSize),P("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",e.adaptiveFontSize===!0),P("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",e.minimumFontSize),P("fontColor","\u6587\u672C\u8272","color",e.fontColor),P("bgColor","\u80CC\u666F\u8272","color",e.bgColor),P("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",e.enableOutline!==!1),P("outlineColor","\u63CF\u8FB9\u8272","color",e.outlineColor),P("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"}]}),P("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"}]}),P("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(P("imageSource","\u56FE\u7247\u6E90","enum",e.imageSource,{options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"},{value:"Prefab",label:"\u5143\u4EF6"}]}),P("imageId","imageId","number",e.imageId??0),P("imageType","\u56FE\u7247\u7C7B\u578B","enum",e.imageType??null,{options:[{value:"Basic",label:"\u57FA\u7840"},{value:"Stretch",label:"\u62C9\u4F38"}]}),P("imageColor","\u586B\u5145\u8272","color",e.imageColor),P("enableMask","\u5F00\u542F\u906E\u7F69","bool",e.enableMask===!0),P("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",e.enableSoftEdge===!0,{gia:"W"}),P("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",e.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),P("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",e.softEdgeWidthX),P("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",e.softEdgeWidthY),P("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",e.horizontalSoftRange),P("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",e.verticalSoftRange),P("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",e.enableFill===!0,{gia:"W"}),P("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"}]}),P("fillHorizontalType","\u65B9\u5411","enum",e.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),P("fillVerticalType","\u65B9\u5411","enum",e.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),P("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"}]}),P("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"}]}),P("fillAmount","\u8FDB\u5EA6","percent",e.fillAmount),P("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(P("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),P("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",e.interactable!==!1),P("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",e.unavailableChildId,{options:s,gia:"W"}),P("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",e.hoverChildId,{options:s,gia:"W"}),P("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",e.pressedChildId,{options:s,gia:"W"}),P("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",e.selectedChildId,{options:s,gia:"W"}),P("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",e.clickAudioId))}return e.kind==="reference"&&o.push(P("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),(e.kind==="textwindow"||e.kind==="grid")&&o.push(P("interactable","\u5141\u8BB8\u6EDA\u52A8\u4EA4\u4E92","bool",e.interactable!==!1),P("showScrollBar","\u663E\u793A\u6EDA\u52A8\u6761","bool",e.showScrollBar!==!1)),e.kind==="grid"&&o.push(P("itemPrefabId","\u5217\u8868\u9879\u6A21\u677F\u7D22\u5F15","number",e.itemPrefabId??0),P("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),P("scrollDirection","\u6EDA\u52A8\u65B9\u5411","enum",e.scrollDirection,{options:[{value:"Vertical",label:"\u7EB5\u5411"},{value:"Horizontal",label:"\u6A2A\u5411"}]}),P("layoutConstraint","\u6392\u5217\u9650\u5236","enum",e.layoutConstraint,{options:[{value:"AutoWrap",label:"\u81EA\u52A8\u6362\u884C"},{value:"Fixed",label:"\u56FA\u5B9A\u884C\u5217\u6570"}]}),P("layoutConstraintFixedCount","\u6BCF\u884C\u6216\u6BCF\u5217\u6570\u91CF","number",e.layoutConstraintFixedCount??1),P("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",e.cellSizeX,{evidence:"W"}),P("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",e.cellSizeY,{evidence:"W"}),P("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",e.spacingX,{evidence:"W"}),P("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",e.spacingY,{evidence:"W"}),P("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",e.padding1X,{evidence:"W"}),P("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",e.padding1Y,{evidence:"W"}),P("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",e.padding2X,{evidence:"W"}),P("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",e.padding2Y,{evidence:"W"}),P("previewCount","\u9884\u89C8\u6570\u91CF","number",e.previewCount)),e.kind==="keyhint"&&o.push(P("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",e.keyboardKeyCode??e.giaRaw?.keyHintField502??1,{gia:"W"}),P("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",e.controllerKeyCode??e.giaRaw?.keyHintField501??1)),(e.kind==="animation"||e.kind==="fullscreen")&&o.push(P("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),(!Fi.includes(e.kind)||e.kind==="textwindow"||e.kind==="grid")&&o.push(P("incomplete","\u5B8C\u6574\u5EA6","note",e.kind==="textwindow"||e.kind==="grid"?"\u8BD5\u73A9\u652F\u6301\u57FA\u7840\u6EDA\u52A8\uFF1B\u6EDA\u52A8\u4EA4\u4E92\u3001\u6EDA\u52A8\u6761\u53CA\u5217\u8868\u914D\u7F6E\u4EE5 JSON/Lua \u4E3A\u51C6\uFF0C\u76F8\u5173 GIA \u5F00\u5173\u6620\u5C04\u5C1A\u672A\u6838\u5B9E\u3002":"\u672C\u9636\u6BB5\u4EC5\u516C\u5171\u53D8\u6362\uFF0C\u4E1A\u52A1\u69FD\u4E0D\u5B8C\u6574")),{id:e.id,guid:r?.get(e.id)??(e.guid||0),kind:e.kind,label:Et[e.kind]||e.kind,incomplete:!Fi.includes(e.kind),fields:o}}function Va(e,t,i){let r=(Array.isArray(e)?e:Object.values(e)).filter(n=>n.kind!=="server-container");for(let n=r.length-1;n>=0;n-=1){let a=r[n];if(!a.visible||!a.active)continue;let o=a.renderMatrix&&Ve(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 Jl from"protobufjs";var Zl=String.raw`
|
|
1
|
+
var Mp=Object.create;var Bl=Object.defineProperty;var Fp=Object.getOwnPropertyDescriptor;var Dp=Object.getOwnPropertyNames;var zp=Object.getPrototypeOf,$p=Object.prototype.hasOwnProperty;var Lp=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Gp=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dp(e))!$p.call(t,n)&&n!==i&&Bl(t,n,{get:()=>e[n],enumerable:!(r=Fp(e,n))||r.enumerable});return t};var qp=(t,e,i)=>(i=t!=null?Mp(zp(t)):{},Gp(e||!t||!t.__esModule?Bl(i,"default",{value:t,enumerable:!0}):i,t));var Es=te((Ib,Ru)=>{"use strict";Ru.exports=wm;function wm(t,e){for(var i=new Array(arguments.length-1),r=0,n=2,o=!0;n<arguments.length;)i[r++]=arguments[n++];return new Promise(function(a,l){i[r]=function(c){if(o)if(o=!1,c)l(c);else{for(var f=new Array(arguments.length-1),h=0;h<f.length;)f[h++]=arguments[h];a.apply(null,f)}};try{t.apply(e||null,i)}catch(u){o&&(o=!1,l(u))}})}});var Pu=te(Nu=>{"use strict";var $n=Nu;$n.length=function(e){var i=e.length;if(!i)return 0;for(;i>0&&e.charAt(i-1)==="=";)--i;return Math.floor(i*3/4)};var or=new Array(64),Ln=new Array(123);for(bt=0;bt<64;)Ln[or[bt]=bt<26?bt+65:bt<52?bt+71:bt<62?bt-4:bt-59|43]=bt++;var bt;Ln[45]=62;Ln[95]=63;$n.encode=function(e,i,r){for(var n=null,o=[],s=0,a=0,l;i<r;){var u=e[i++];switch(a){case 0:o[s++]=or[u>>2],l=(u&3)<<4,a=1;break;case 1:o[s++]=or[l|u>>4],l=(u&15)<<2,a=2;break;case 2:o[s++]=or[l|u>>6],o[s++]=or[u&63],a=0;break}s>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,o)),s=0)}return a&&(o[s++]=or[l],o[s++]=61,a===1&&(o[s++]=61)),n?(s&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))};var Ou="invalid encoding";$n.decode=function(e,i,r){for(var n=r,o=0,s,a=0;a<e.length;){var l=e.charCodeAt(a++);if(l===61&&o>1)break;if((l=Ln[l])===void 0)throw Error(Ou);switch(o){case 0:s=l,o=1;break;case 1:i[r++]=s<<2|(l&48)>>4,s=l,o=2;break;case 2:i[r++]=(s&15)<<4|(l&60)>>2,s=l,o=3;break;case 3:i[r++]=(s&3)<<6|l,o=0;break}}if(o===1)throw Error(Ou);return r-n};var Sm=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,xm=/[-_]/,_m=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;$n.test=function(e){return Sm.test(e)||xm.test(e)&&_m.test(e)}});var Fu=te((Cb,Mu)=>{"use strict";Mu.exports=Gn;function Gn(){this._listeners=Object.create(null)}Gn.prototype.on=function(e,i,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:i,ctx:r||this}),this};Gn.prototype.off=function(e,i){if(e===void 0)this._listeners=Object.create(null);else if(i===void 0)this._listeners[e]=[];else{var r=this._listeners[e];if(!r)return this;for(var n=0;n<r.length;)r[n].fn===i?r.splice(n,1):++n}return this};Gn.prototype.emit=function(e){var i=this._listeners[e];if(i){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<i.length;)i[n].fn.apply(i[n++].ctx,r)}return this}});var Bu=te((kb,qu)=>{"use strict";qu.exports=Du(Du);function Du(t){return typeof Float32Array<"u"?(function(){var e=new Float32Array([-0]),i=new Uint8Array(e.buffer),r=i[3]===128;function n(l,u,c){e[0]=l,u[c]=i[0],u[c+1]=i[1],u[c+2]=i[2],u[c+3]=i[3]}function o(l,u,c){e[0]=l,u[c]=i[3],u[c+1]=i[2],u[c+2]=i[1],u[c+3]=i[0]}t.writeFloatLE=r?n:o,t.writeFloatBE=r?o:n;function s(l,u){return i[0]=l[u],i[1]=l[u+1],i[2]=l[u+2],i[3]=l[u+3],e[0]}function a(l,u){return i[3]=l[u],i[2]=l[u+1],i[1]=l[u+2],i[0]=l[u+3],e[0]}t.readFloatLE=r?s:a,t.readFloatBE=r?a:s})():(function(){function e(r,n,o,s){var a=n<0?1:0;if(a&&(n=-n),n===0)r(1/n>0?0:2147483648,o,s);else if(isNaN(n))r(2143289344,o,s);else if(n>34028234663852886e22)r((a<<31|2139095040)>>>0,o,s);else if(n<11754943508222875e-54)r((a<<31|Math.round(n/1401298464324817e-60))>>>0,o,s);else{var l=Math.floor(Math.log(n)/Math.LN2),u=Math.round(n*Math.pow(2,-l)*8388608)&8388607;r((a<<31|l+127<<23|u)>>>0,o,s)}}t.writeFloatLE=e.bind(null,zu),t.writeFloatBE=e.bind(null,$u);function i(r,n,o){var s=r(n,o),a=(s>>31)*2+1,l=s>>>23&255,u=s&8388607;return l===255?u?NaN:a*(1/0):l===0?a*1401298464324817e-60*u:a*Math.pow(2,l-150)*(u+8388608)}t.readFloatLE=i.bind(null,Lu),t.readFloatBE=i.bind(null,Gu)})(),typeof Float64Array<"u"?(function(){var e=new Float64Array([-0]),i=new Uint8Array(e.buffer),r=i[7]===128;function n(l,u,c){e[0]=l,u[c]=i[0],u[c+1]=i[1],u[c+2]=i[2],u[c+3]=i[3],u[c+4]=i[4],u[c+5]=i[5],u[c+6]=i[6],u[c+7]=i[7]}function o(l,u,c){e[0]=l,u[c]=i[7],u[c+1]=i[6],u[c+2]=i[5],u[c+3]=i[4],u[c+4]=i[3],u[c+5]=i[2],u[c+6]=i[1],u[c+7]=i[0]}t.writeDoubleLE=r?n:o,t.writeDoubleBE=r?o:n;function s(l,u){return i[0]=l[u],i[1]=l[u+1],i[2]=l[u+2],i[3]=l[u+3],i[4]=l[u+4],i[5]=l[u+5],i[6]=l[u+6],i[7]=l[u+7],e[0]}function a(l,u){return i[7]=l[u],i[6]=l[u+1],i[5]=l[u+2],i[4]=l[u+3],i[3]=l[u+4],i[2]=l[u+5],i[1]=l[u+6],i[0]=l[u+7],e[0]}t.readDoubleLE=r?s:a,t.readDoubleBE=r?a:s})():(function(){function e(r,n,o,s,a,l){var u=s<0?1:0;if(u&&(s=-s),s===0)r(0,a,l+n),r(1/s>0?0:2147483648,a,l+o);else if(isNaN(s))r(0,a,l+n),r(2146959360,a,l+o);else if(s>17976931348623157e292)r(0,a,l+n),r((u<<31|2146435072)>>>0,a,l+o);else{var c;if(s<22250738585072014e-324)c=s/5e-324,r(c>>>0,a,l+n),r((u<<31|c/4294967296)>>>0,a,l+o);else{var f=Math.floor(Math.log(s)/Math.LN2);f===1024&&(f=1023),c=s*Math.pow(2,-f),r(c*4503599627370496>>>0,a,l+n),r((u<<31|f+1023<<20|c*1048576&1048575)>>>0,a,l+o)}}}t.writeDoubleLE=e.bind(null,zu,0,4),t.writeDoubleBE=e.bind(null,$u,4,0);function i(r,n,o,s,a){var l=r(s,a+n),u=r(s,a+o),c=(u>>31)*2+1,f=u>>>20&2047,h=4294967296*(u&1048575)+l;return f===2047?h?NaN:c*(1/0):f===0?c*5e-324*h:c*Math.pow(2,f-1075)*(h+4503599627370496)}t.readDoubleLE=i.bind(null,Lu,0,4),t.readDoubleBE=i.bind(null,Gu,4,0)})(),t}function zu(t,e,i){e[i]=t&255,e[i+1]=t>>>8&255,e[i+2]=t>>>16&255,e[i+3]=t>>>24}function $u(t,e,i){e[i]=t>>>24,e[i+1]=t>>>16&255,e[i+2]=t>>>8&255,e[i+3]=t&255}function Lu(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function Gu(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}});var Uu=te(Vu=>{"use strict";var Bn=Vu,qn=new TextDecoder("utf-8",{ignoreBOM:!0}),qr,ju=64;try{qr=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}catch{qr=qn}Bn.length=function(e){for(var i=0,r=0,n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?i+=1:r<2048?i+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,i+=4):i+=3;return i};function sr(t,e,i,r){var n=i===0&&r===e.length?e:e.subarray(i,r);return t.decode(n)}Bn.read=function(e,i,r){if(r-i<1)return"";if(r-i>=ju)return sr(qn,e,i,r);for(var n="",o=i,s,a,l,u,c,f,h,m;o+7<r;o+=8){if(s=e[o],a=e[o+1],l=e[o+2],u=e[o+3],c=e[o+4],f=e[o+5],h=e[o+6],m=e[o+7],(s|a|l|u|c|f|h|m)&128)return n+sr(qn,e,o,r);n+=String.fromCharCode(s,a,l,u,c,f,h,m)}for(;o<r;++o){if(s=e[o],s&128)return n+sr(qn,e,o,r);n+=String.fromCharCode(s)}return n};Bn.readStrict=function(e,i,r){if(r-i<1)return"";if(r-i>=ju)return sr(qr,e,i,r);for(var n="",o=i,s,a,l,u,c,f,h,m;o+7<r;o+=8){if(s=e[o],a=e[o+1],l=e[o+2],u=e[o+3],c=e[o+4],f=e[o+5],h=e[o+6],m=e[o+7],(s|a|l|u|c|f|h|m)&128)return n+sr(qr,e,o,r);n+=String.fromCharCode(s,a,l,u,c,f,h,m)}for(;o<r;++o){if(s=e[o],s&128)return n+sr(qr,e,o,r);n+=String.fromCharCode(s)}return n};Bn.write=function(e,i,r){for(var n=r,o,s,a=0;a<e.length;++a)o=e.charCodeAt(a),o<128?i[r++]=o:o<2048?(i[r++]=o>>6|192,i[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(a+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++a,i[r++]=o>>18|240,i[r++]=o>>12&63|128,i[r++]=o>>6&63|128,i[r++]=o&63|128):(i[r++]=o>>12|224,i[r++]=o>>6&63|128,i[r++]=o&63|128);return r-n}});var Yu=te((Tb,Hu)=>{"use strict";Hu.exports=Im;function Im(t,e,i){var r=i||8192,n=r>>>1,o=null,s=r;return function(l){if(l<1||l>n)return t(l);s+l>r&&(o=t(r),s=0);var u=e.call(o,s,s+=l);return s&7&&(s=(s|7)+1),u}}});var Wu=te((Rb,Xu)=>{"use strict";Xu.exports=Fe;var Br;function Fe(t,e){this.lo=t>>>0,this.hi=e>>>0}var Ni=Fe.zero=new Fe(0,0);Ni.toNumber=function(){return 0};Ni.zzEncode=Ni.zzDecode=function(){return this};Ni.length=function(){return 1};var Em=Fe.zeroHash="\0\0\0\0\0\0\0\0";Fe.fromNumber=function(e){if(e===0)return Ni;var i=e<0;i&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return i&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Fe(r,n)};Fe.from=function(e){if(typeof e=="number")return Fe.fromNumber(e);if(typeof e=="string"||e instanceof String)if(Br)e=Br.fromString(e);else return Fe.fromNumber(parseInt(e,10));return e.low||e.high?new Fe(e.low>>>0,e.high>>>0):Ni};Fe.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var i=~this.lo+1>>>0,r=~this.hi>>>0;return i||(r=r+1>>>0),-(i+r*4294967296)}return this.lo+this.hi*4294967296};Fe.prototype.toLong=function(e){return Br?new Br(this.lo|0,this.hi|0,!!e):{low:this.lo|0,high:this.hi|0,unsigned:!!e}};var ci=String.prototype.charCodeAt;Fe.fromHash=function(e){return e===Em?Ni:new Fe((ci.call(e,0)|ci.call(e,1)<<8|ci.call(e,2)<<16|ci.call(e,3)<<24)>>>0,(ci.call(e,4)|ci.call(e,5)<<8|ci.call(e,6)<<16|ci.call(e,7)<<24)>>>0)};Fe.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};Fe.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this};Fe.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};Fe.prototype.length=function(){var e=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?i===0?e<16384?e<128?1:2:e<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:r<128?9:10};Fe._configure=function(t){Br=t}});var Ku=te((jr,Cs)=>{(function(t,e){function i(r){return r.default||r}typeof define=="function"&&define.amd?define([],function(){var r={};return e(r),i(r)}):typeof jr=="object"?(e(jr),typeof Cs=="object"&&(Cs.exports=i(jr))):(function(){var r={};e(r),t.Long=i(r)})()})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:jr,function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=null;try{e=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function i(x,d,w){this.low=x|0,this.high=d|0,this.unsigned=!!w}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0});function r(x){return(x&&x.__isLong__)===!0}function n(x){var d=Math.clz32(x&-x);return x?31-d:d}i.isLong=r;var o={},s={};function a(x,d){var w,F,V;return d?(x>>>=0,(V=0<=x&&x<256)&&(F=s[x],F)?F:(w=u(x,0,!0),V&&(s[x]=w),w)):(x|=0,(V=-128<=x&&x<128)&&(F=o[x],F)?F:(w=u(x,x<0?-1:0,!1),V&&(o[x]=w),w))}i.fromInt=a;function l(x,d){if(isNaN(x))return d?S:D;if(d){if(x<0)return S;if(x>=I)return _}else{if(x<=-C)return O;if(x+1>=C)return B}return x<0?l(-x,d).neg():u(x%v|0,x/v|0,d)}i.fromNumber=l;function u(x,d,w){return new i(x,d,w)}i.fromBits=u;var c=Math.pow;function f(x,d,w){if(x.length===0)throw Error("empty string");if(typeof d=="number"?(w=d,d=!1):d=!!d,x==="NaN"||x==="Infinity"||x==="+Infinity"||x==="-Infinity")return d?S:D;if(w=w||10,w<2||36<w)throw RangeError("radix");var F;if((F=x.indexOf("-"))>0)throw Error("interior hyphen");if(F===0)return f(x.substring(1),d,w).neg();for(var V=l(c(w,8)),H=D,Z=0;Z<x.length;Z+=8){var ne=Math.min(8,x.length-Z),ve=parseInt(x.substring(Z,Z+ne),w);if(ne<8){var be=l(c(w,ne));H=H.mul(be).add(l(ve))}else H=H.mul(V),H=H.add(l(ve))}return H.unsigned=d,H}i.fromString=f;function h(x,d){return typeof x=="number"?l(x,d):typeof x=="string"?f(x,d):u(x.low,x.high,typeof d=="boolean"?d:x.unsigned)}i.fromValue=h;var m=65536,g=1<<24,v=m*m,I=v*v,C=I/2,E=a(g),D=a(0);i.ZERO=D;var S=a(0,!0);i.UZERO=S;var z=a(1);i.ONE=z;var L=a(1,!0);i.UONE=L;var j=a(-1);i.NEG_ONE=j;var B=u(-1,2147483647,!1);i.MAX_VALUE=B;var _=u(-1,-1,!0);i.MAX_UNSIGNED_VALUE=_;var O=u(0,-2147483648,!1);i.MIN_VALUE=O;var y=i.prototype;y.toInt=function(){return this.unsigned?this.low>>>0:this.low},y.toNumber=function(){return this.unsigned?(this.high>>>0)*v+(this.low>>>0):this.high*v+(this.low>>>0)},y.toString=function(d){if(d=d||10,d<2||36<d)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(O)){var w=l(d),F=this.div(w),V=F.mul(w).sub(this);return F.toString(d)+V.toInt().toString(d)}else return"-"+this.neg().toString(d);for(var H=l(c(d,6),this.unsigned),Z=this,ne="";;){var ve=Z.div(H),be=Z.sub(ve.mul(H)).toInt()>>>0,ge=be.toString(d);if(Z=ve,Z.isZero())return ge+ne;for(;ge.length<6;)ge="0"+ge;ne=""+ge+ne}},y.getHighBits=function(){return this.high},y.getHighBitsUnsigned=function(){return this.high>>>0},y.getLowBits=function(){return this.low},y.getLowBitsUnsigned=function(){return this.low>>>0},y.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var d=this.high!=0?this.high:this.low,w=31;w>0&&(d&1<<w)==0;w--);return this.high!=0?w+33:w+1},y.isSafeInteger=function(){var d=this.high>>21;return d?this.unsigned?!1:d===-1&&!(this.low===0&&this.high===-2097152):!0},y.isZero=function(){return this.high===0&&this.low===0},y.eqz=y.isZero,y.isNegative=function(){return!this.unsigned&&this.high<0},y.isPositive=function(){return this.unsigned||this.high>=0},y.isOdd=function(){return(this.low&1)===1},y.isEven=function(){return(this.low&1)===0},y.equals=function(d){return r(d)||(d=h(d)),this.unsigned!==d.unsigned&&this.high>>>31===1&&d.high>>>31===1?!1:this.high===d.high&&this.low===d.low},y.eq=y.equals,y.notEquals=function(d){return!this.eq(d)},y.neq=y.notEquals,y.ne=y.notEquals,y.lessThan=function(d){return this.comp(d)<0},y.lt=y.lessThan,y.lessThanOrEqual=function(d){return this.comp(d)<=0},y.lte=y.lessThanOrEqual,y.le=y.lessThanOrEqual,y.greaterThan=function(d){return this.comp(d)>0},y.gt=y.greaterThan,y.greaterThanOrEqual=function(d){return this.comp(d)>=0},y.gte=y.greaterThanOrEqual,y.ge=y.greaterThanOrEqual,y.compare=function(d){if(r(d)||(d=h(d)),this.eq(d))return 0;var w=this.isNegative(),F=d.isNegative();return w&&!F?-1:!w&&F?1:this.unsigned?d.high>>>0>this.high>>>0||d.high===this.high&&d.low>>>0>this.low>>>0?-1:1:this.sub(d).isNegative()?-1:1},y.comp=y.compare,y.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(z)},y.neg=y.negate,y.add=function(d){r(d)||(d=h(d));var w=this.high>>>16,F=this.high&65535,V=this.low>>>16,H=this.low&65535,Z=d.high>>>16,ne=d.high&65535,ve=d.low>>>16,be=d.low&65535,ge=0,ee=0,ce=0,Se=0;return Se+=H+be,ce+=Se>>>16,Se&=65535,ce+=V+ve,ee+=ce>>>16,ce&=65535,ee+=F+ne,ge+=ee>>>16,ee&=65535,ge+=w+Z,ge&=65535,u(ce<<16|Se,ge<<16|ee,this.unsigned)},y.subtract=function(d){return r(d)||(d=h(d)),this.add(d.neg())},y.sub=y.subtract,y.multiply=function(d){if(this.isZero())return this;if(r(d)||(d=h(d)),e){var w=e.mul(this.low,this.high,d.low,d.high);return u(w,e.get_high(),this.unsigned)}if(d.isZero())return this.unsigned?S:D;if(this.eq(O))return d.isOdd()?O:D;if(d.eq(O))return this.isOdd()?O:D;if(this.isNegative())return d.isNegative()?this.neg().mul(d.neg()):this.neg().mul(d).neg();if(d.isNegative())return this.mul(d.neg()).neg();if(this.lt(E)&&d.lt(E))return l(this.toNumber()*d.toNumber(),this.unsigned);var F=this.high>>>16,V=this.high&65535,H=this.low>>>16,Z=this.low&65535,ne=d.high>>>16,ve=d.high&65535,be=d.low>>>16,ge=d.low&65535,ee=0,ce=0,Se=0,mt=0;return mt+=Z*ge,Se+=mt>>>16,mt&=65535,Se+=H*ge,ce+=Se>>>16,Se&=65535,Se+=Z*be,ce+=Se>>>16,Se&=65535,ce+=V*ge,ee+=ce>>>16,ce&=65535,ce+=H*be,ee+=ce>>>16,ce&=65535,ce+=Z*ve,ee+=ce>>>16,ce&=65535,ee+=F*ge+V*be+H*ve+Z*ne,ee&=65535,u(Se<<16|mt,ee<<16|ce,this.unsigned)},y.mul=y.multiply,y.divide=function(d){if(r(d)||(d=h(d)),d.isZero())throw Error("division by zero");if(e){if(!this.unsigned&&this.high===-2147483648&&d.low===-1&&d.high===-1)return this;var w=(this.unsigned?e.div_u:e.div_s)(this.low,this.high,d.low,d.high);return u(w,e.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?S:D;var F,V,H;if(this.unsigned){if(d.unsigned||(d=d.toUnsigned()),d.gt(this))return S;if(d.gt(this.shru(1)))return L;H=S}else{if(this.eq(O)){if(d.eq(z)||d.eq(j))return O;if(d.eq(O))return z;var Z=this.shr(1);return F=Z.div(d).shl(1),F.eq(D)?d.isNegative()?z:j:(V=this.sub(d.mul(F)),H=F.add(V.div(d)),H)}else if(d.eq(O))return this.unsigned?S:D;if(this.isNegative())return d.isNegative()?this.neg().div(d.neg()):this.neg().div(d).neg();if(d.isNegative())return this.div(d.neg()).neg();H=D}for(V=this;V.gte(d);){F=Math.max(1,Math.floor(V.toNumber()/d.toNumber()));for(var ne=Math.ceil(Math.log(F)/Math.LN2),ve=ne<=48?1:c(2,ne-48),be=l(F),ge=be.mul(d);ge.isNegative()||ge.gt(V);)F-=ve,be=l(F,this.unsigned),ge=be.mul(d);be.isZero()&&(be=z),H=H.add(be),V=V.sub(ge)}return H},y.div=y.divide,y.modulo=function(d){if(r(d)||(d=h(d)),e){var w=(this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,d.low,d.high);return u(w,e.get_high(),this.unsigned)}return this.sub(this.div(d).mul(d))},y.mod=y.modulo,y.rem=y.modulo,y.not=function(){return u(~this.low,~this.high,this.unsigned)},y.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},y.clz=y.countLeadingZeros,y.countTrailingZeros=function(){return this.low?n(this.low):n(this.high)+32},y.ctz=y.countTrailingZeros,y.and=function(d){return r(d)||(d=h(d)),u(this.low&d.low,this.high&d.high,this.unsigned)},y.or=function(d){return r(d)||(d=h(d)),u(this.low|d.low,this.high|d.high,this.unsigned)},y.xor=function(d){return r(d)||(d=h(d)),u(this.low^d.low,this.high^d.high,this.unsigned)},y.shiftLeft=function(d){return r(d)&&(d=d.toInt()),(d&=63)===0?this:d<32?u(this.low<<d,this.high<<d|this.low>>>32-d,this.unsigned):u(0,this.low<<d-32,this.unsigned)},y.shl=y.shiftLeft,y.shiftRight=function(d){return r(d)&&(d=d.toInt()),(d&=63)===0?this:d<32?u(this.low>>>d|this.high<<32-d,this.high>>d,this.unsigned):u(this.high>>d-32,this.high>=0?0:-1,this.unsigned)},y.shr=y.shiftRight,y.shiftRightUnsigned=function(d){return r(d)&&(d=d.toInt()),(d&=63)===0?this:d<32?u(this.low>>>d|this.high<<32-d,this.high>>>d,this.unsigned):d===32?u(this.high,0,this.unsigned):u(this.high>>>d-32,0,this.unsigned)},y.shru=y.shiftRightUnsigned,y.shr_u=y.shiftRightUnsigned,y.rotateLeft=function(d){var w;return r(d)&&(d=d.toInt()),(d&=63)===0?this:d===32?u(this.high,this.low,this.unsigned):d<32?(w=32-d,u(this.low<<d|this.high>>>w,this.high<<d|this.low>>>w,this.unsigned)):(d-=32,w=32-d,u(this.high<<d|this.low>>>w,this.low<<d|this.high>>>w,this.unsigned))},y.rotl=y.rotateLeft,y.rotateRight=function(d){var w;return r(d)&&(d=d.toInt()),(d&=63)===0?this:d===32?u(this.high,this.low,this.unsigned):d<32?(w=32-d,u(this.high<<w|this.low>>>d,this.low<<w|this.high>>>d,this.unsigned)):(d-=32,w=32-d,u(this.low<<w|this.high>>>d,this.high<<w|this.low>>>d,this.unsigned))},y.rotr=y.rotateRight,y.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},y.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},y.toBytes=function(d){return d?this.toBytesLE():this.toBytesBE()},y.toBytesLE=function(){var d=this.high,w=this.low;return[w&255,w>>>8&255,w>>>16&255,w>>>24,d&255,d>>>8&255,d>>>16&255,d>>>24]},y.toBytesBE=function(){var d=this.high,w=this.low;return[d>>>24,d>>>16&255,d>>>8&255,d&255,w>>>24,w>>>16&255,w>>>8&255,w&255]},i.fromBytes=function(d,w,F){return F?i.fromBytesLE(d,w):i.fromBytesBE(d,w)},i.fromBytesLE=function(d,w){return new i(d[0]|d[1]<<8|d[2]<<16|d[3]<<24,d[4]|d[5]<<8|d[6]<<16|d[7]<<24,w)},i.fromBytesBE=function(d,w){return new i(d[4]<<24|d[5]<<16|d[6]<<8|d[7],d[0]<<24|d[1]<<16|d[2]<<8|d[3],w)},typeof BigInt=="function"&&(i.fromBigInt=function(d,w){var F=Number(BigInt.asIntN(32,d)),V=Number(BigInt.asIntN(32,d>>BigInt(32)));return u(F,V,w)},i.fromValue=function(d,w){return typeof d=="bigint"?i.fromBigInt(d,w):h(d,w)},y.toBigInt=function(){var d=BigInt(this.low>>>0),w=BigInt(this.unsigned?this.high>>>0:this.high);return w<<BigInt(32)|d});var N=t.default=i})});var Pt=te(ks=>{"use strict";var W=ks;W.asPromise=Es();W.base64=Pu();W.EventEmitter=Fu();W.float=Bu();W.utf8=Uu();W.pool=Yu();W.LongBits=Wu();function Ju(t){return t==="__proto__"||t==="prototype"||t==="constructor"}W.isUnsafeProperty=Ju;W.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node);W.global=W.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||typeof globalThis<"u"&&globalThis||ks;W.emptyArray=Object.freeze?Object.freeze([]):[];W.emptyObject=Object.freeze?Object.freeze({}):{};W.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};W.isString=function(e){return typeof e=="string"||e instanceof String};W.isObject=function(e){return e&&typeof e=="object"};W.isset=W.isSet=function(e,i){var r=e[i];return r!=null&&Object.hasOwnProperty.call(e,i)?typeof r!="object"||(Array.isArray(r)?r.length:Object.keys(r).length)>0:!1};W.Buffer=(function(){try{var t=W.global.Buffer;return t.prototype.utf8Write||W.isNode?t:null}catch{return null}})();W.newBuffer=function(e){var i=W.Buffer;return typeof e=="number"?i?i.allocUnsafe(e):new Uint8Array(e):i?i.from(e):new Uint8Array(e)};W.rawField=function(e,i,r){var n=[],o=e<<3|i;for(o>>>=0;o>127;)n.push(o&127|128),o>>>=7;n.push(o);for(var s=0;s<r.length;++s)n.push(r[s]);return W.newBuffer(n)};W.Array=Uint8Array;W.Long=W.global.dcodeIO&&W.global.dcodeIO.Long||W.global.Long||(function(){try{var t=Ku();return t&&t.isLong?t:null}catch{return null}})();W.key2Re=/^(?:true|false|0|1)$/;W.key32Re=/^-?(?:0|[1-9][0-9]*)$/;W.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/;W.longToHash=function(e){return e?W.LongBits.from(e).toHash():W.LongBits.zeroHash};W.longFromHash=function(e,i){var r=W.LongBits.fromHash(e);return W.Long?W.Long.fromBits(r.lo,r.hi,i):r.toNumber(!!i)};W.longFromKey=function(e,i){return W.key64Re.test(e)&&!W.key32Re.test(e)?W.longFromHash(e,i):e};W.boolFromKey=function(e){return e==="true"||e==="1"};function Zu(t){var e=typeof arguments[arguments.length-1]=="boolean",i=e?arguments.length-1:arguments.length;e=e&&arguments[arguments.length-1];for(var r=1;r<i;++r){var n=arguments[r];if(n)for(var o=Object.keys(n),s=0;s<o.length;++s)!Ju(o[s])&&(!e||!Object.prototype.hasOwnProperty.call(t,o[s])||t[o[s]]===void 0)&&(t[o[s]]=n[o[s]])}return t}W.merge=Zu;W.nestingLimit=32;W.recursionLimit=100;W.makeProp=function(e,i,r){Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{enumerable:r===void 0?!0:r,configurable:!0,writable:!0})};W.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function Qu(t){function e(i,r){if(!(this instanceof e))return new e(i,r);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),r&&Zu(this,r)}return e.prototype=Object.create(Error.prototype,{constructor:{value:e,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),e}W.newError=Qu;W.ProtocolError=Qu("ProtocolError");W.oneOfGetter=function(e){for(var i={},r=0;r<e.length;++r)i[e[r]]=1;return function(){for(var n=Object.keys(this),o=n.length-1;o>-1;--o)if(i[n[o]]===1&&this[n[o]]!==void 0&&this[n[o]]!==null)return n[o]}};W.oneOfSetter=function(e){return function(i){for(var r=0;r<e.length;++r)e[r]!==i&&delete this[e[r]]}};W.toJSONOptions={longs:String,enums:String,bytes:String,json:!0}});var Vn=te((Nb,nc)=>{"use strict";nc.exports=K;var Mt=Pt(),Ts,Wt=Mt.LongBits,ec=Mt.base64,As=Mt.utf8;function K(){this.pos=0,this.buf=this.constructor.alloc(K.initialBufferSize),this.view=null,this.states=null}K.initialBufferSize=128;Object.defineProperty(K.prototype,"len",{configurable:!0,enumerable:!0,get:function(){return this.pos}});var tc=function(){return Mt.Buffer?function(){return(K.create=function(){return new Ts})()}:function(){return new K}};K.create=tc();K.alloc=function(e){return new Uint8Array(e)};K.alloc=Mt.pool(K.alloc,Uint8Array.prototype.subarray);function Rs(t){return t<128?1:t<16384?2:t<2097152?3:t<268435456?4:5}K.prototype._reserve=function(e){var i=this.pos+e;if(i>this.buf.length){var r=this.buf.length<<1;r<i&&(r=i);var n=this.constructor.alloc(r);n.set(this.buf.subarray(0,this.pos),0),this.buf=n,this.view=null}};function Cm(t,e,i){for(var r=0;r<t.length;)e[i++]=t.charCodeAt(r++)}function Pi(t,e,i){for(;t>127;)e[i++]=t&127|128,t>>>=7;return e[i]=t,i+1}K.prototype.uint32=function(e){e=e>>>0,this._reserve(5);var i=this.pos;return this.pos=Pi(e,this.buf,i),this};K.prototype.int32=function(e){return(e|=0)<0?(this._reserve(10),lr(Wt.fromNumber(e),this.buf,this.pos),this.pos+=10,this):this.uint32(e)};K.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function lr(t,e,i){for(var r=t.lo,n=t.hi;n;)e[i++]=r&127|128,r=(r>>>7|n<<25)>>>0,n>>>=7;for(;r>127;)e[i++]=r&127|128,r=r>>>7;return e[i]=r,i+1}K.prototype.uint64=function(e){var i=Wt.from(e);this._reserve(10);var r=this.pos;return this.pos=lr(i,this.buf,r),this};K.prototype.int64=K.prototype.uint64;K.prototype.sint64=function(e){var i=Wt.from(e).zzEncode();this._reserve(10);var r=this.pos;return this.pos=lr(i,this.buf,r),this};K.prototype.bool=function(e){return this._reserve(1),this.buf[this.pos++]=e?1:0,this};function ar(t,e,i){e[i]=t&255,e[i+1]=t>>>8&255,e[i+2]=t>>>16&255,e[i+3]=t>>>24}K.prototype.fixed32=function(e){return this._reserve(4),ar(e>>>0,this.buf,this.pos),this.pos+=4,this};K.prototype.sfixed32=K.prototype.fixed32;K.prototype.fixed64=function(e){var i=Wt.from(e);return this._reserve(8),ar(i.lo,this.buf,this.pos),ar(i.hi,this.buf,this.pos+4),this.pos+=8,this};K.prototype.sfixed64=K.prototype.fixed64;K.prototype.float=function(e){return this._reserve(4),Mt.float.writeFloatLE(e,this.buf,this.pos),this.pos+=4,this};K.prototype.double=function(e){return this._reserve(8),Mt.float.writeDoubleLE(e,this.buf,this.pos),this.pos+=8,this};K.prototype.bytes=function(e){var i=e.length>>>0;if(!i)return this._reserve(1),this.buf[this.pos++]=0,this;if(Mt.isString(e)){var r=K.alloc(i=ec.length(e));ec.decode(e,r,0),e=r}return this.uint32(i),this._reserve(i),this.buf.set(e,this.pos),this.pos+=i,this};K.prototype.raw=function(e){var i=e.length>>>0;return i?(this._reserve(i),this.buf.set(e,this.pos),this.pos+=i,this):this};K.prototype._delim=function(e,i){var r=Rs(i);return r>1&&this.buf.copyWithin(e+r,e+1,e+1+i),Pi(i,this.buf,e),this.pos=e+r+i,this};K.prototype.string=function(e){var i=e.length;if(!i)return this._reserve(1),this.buf[this.pos++]=0,this;if(i<128){this._reserve(i*3+5);var r=this.pos;return this._delim(r,As.write(e,this.buf,r+1))}var n=As.length(e);return this.uint32(n),this._reserve(n),n===e.length?Cm(e,this.buf,this.pos):As.write(e,this.buf,this.pos),this.pos+=n,this};K.prototype.uint32s=function(e){var i=e.length;this._reserve(i*5+5);for(var r=this.buf,n=this.pos,o=n+1,s=0;s<i;++s)o=Pi(e[s]>>>0,r,o);return this._delim(n,o-n-1)};K.prototype.int32s=function(e){var i=e.length;this._reserve(i*10+5);for(var r=this.buf,n=this.pos,o=n+1,s,a=0;a<i;++a)(s=e[a]|0)<0?o=lr(Wt.fromNumber(s),r,o):o=Pi(s,r,o);return this._delim(n,o-n-1)};K.prototype.sint32s=function(e){var i=e.length;this._reserve(i*5+5);for(var r=this.buf,n=this.pos,o=n+1,s=0;s<i;++s)o=Pi((e[s]<<1^e[s]>>31)>>>0,r,o);return this._delim(n,o-n-1)};K.prototype.uint64s=function(e){var i=e.length;this._reserve(i*10+5);for(var r=this.buf,n=this.pos,o=n+1,s=0;s<i;++s)o=lr(Wt.from(e[s]),r,o);return this._delim(n,o-n-1)};K.prototype.int64s=K.prototype.uint64s;K.prototype.sint64s=function(e){var i=e.length;this._reserve(i*10+5);for(var r=this.buf,n=this.pos,o=n+1,s=0;s<i;++s)o=lr(Wt.from(e[s]).zzEncode(),r,o);return this._delim(n,o-n-1)};K.prototype.bools=function(e){var i=e.length;this.uint32(i),this._reserve(i);for(var r=this.buf,n=this.pos,o=0;o<i;++o)r[n++]=e[o]?1:0;return this.pos+=i,this};var ic=16,rc=128;function jn(t,e,i){var r=t.view;if(r||e<i)return r;var n=t.buf;return t.view=new DataView(n.buffer,n.byteOffset,n.byteLength)}K.prototype.fixed32s=function(e){var i=e.length,r=i*4;this.uint32(r),this._reserve(r);var n=this.pos,o,s=jn(this,i,rc);if(s)for(o=0;o<i;++o)s.setUint32(n,e[o]>>>0,!0),n+=4;else{var a=this.buf;for(o=0;o<i;++o)ar(e[o]>>>0,a,n),n+=4}return this.pos+=r,this};K.prototype.sfixed32s=K.prototype.fixed32s;K.prototype.fixed64s=function(e){var i=e.length,r=i*8;this.uint32(r),this._reserve(r);var n=this.pos,o,s,a=jn(this,i,rc);if(a)for(o=0;o<i;++o)s=Wt.from(e[o]),a.setUint32(n,s.lo,!0),a.setUint32(n+4,s.hi,!0),n+=8;else{var l=this.buf;for(o=0;o<i;++o)s=Wt.from(e[o]),ar(s.lo,l,n),ar(s.hi,l,n+4),n+=8}return this.pos+=r,this};K.prototype.sfixed64s=K.prototype.fixed64s;K.prototype.floats=function(e){var i=e.length,r=i*4;this.uint32(r),this._reserve(r);var n=this.pos,o,s=jn(this,i,ic);if(s)for(o=0;o<i;++o)s.setFloat32(n,e[o],!0),n+=4;else{var a=this.buf;for(o=0;o<i;++o)Mt.float.writeFloatLE(e[o],a,n),n+=4}return this.pos+=r,this};K.prototype.doubles=function(e){var i=e.length,r=i*8;this.uint32(r),this._reserve(r);var n=this.pos,o,s=jn(this,i,ic);if(s)for(o=0;o<i;++o)s.setFloat64(n,e[o],!0),n+=8;else{var a=this.buf;for(o=0;o<i;++o)Mt.float.writeDoubleLE(e[o],a,n),n+=8}return this.pos+=r,this};K.prototype.fork=function(){return this._reserve(1),(this.states||(this.states=[])).push(this.pos),this.pos+=1,this};K.prototype.reset=function(){var e=this.states;return e&&e.length?this.pos=e.pop():this.pos=0,this};K.prototype.ldelim=function(){var e=this.states,i,r;if(e&&e.length){var n=e.pop();i=this.pos-n-1,r=Rs(i),r>1?(this._reserve(r-1),this.buf.copyWithin(n+r,n+1,n+1+i),this.pos+=r-1,Pi(i,this.buf,n)):this.buf[n]=i}else i=this.pos,r=Rs(i),this._reserve(r),this.buf.copyWithin(r,0,i),Pi(i,this.buf,0),this.pos+=r;return this};K.prototype.finish=function(e){if(e)return this.buf.subarray(0,this.pos);var i=this.constructor.alloc(this.pos);return i.set(this.buf.subarray(0,this.pos),0),i};K.prototype.finishInto=function(e,i){return i===void 0&&(i=0),e.set(this.buf.subarray(0,this.pos),i),e};K._configure=function(t){Ts=t,K.create=tc(),Ts._configure()}});var ac=te((Pb,sc)=>{"use strict";sc.exports=di;var oc=Vn();di.prototype=Object.create(oc.prototype,{constructor:{value:di,writable:!0,enumerable:!1,configurable:!0}});var fi=Pt();function di(){oc.call(this)}var Os;di._configure=function(){di.alloc=fi.Buffer&&fi.Buffer.allocUnsafe,Os=fi.Buffer&&fi.Buffer.prototype.utf8Write?function(e,i,r){return i.utf8Write(e,r)}:function(e,i,r){return i.write(e,r)}};di.prototype.bytes=function(e){fi.isString(e)&&(e=fi.Buffer.from(e,"base64"));var i=e.length>>>0;return this.uint32(i),i&&(this._reserve(i),this.buf.set(e,this.pos),this.pos+=i),this};di.prototype.string=function(e){var i=e.length;if(!i)return this._reserve(1),this.buf[this.pos++]=0,this;if(i<128){this._reserve(i*3+5);var r=this.pos,n=this.buf;return this._delim(r,i<40?fi.utf8.write(e,n,r+1):Os(e,n,r+1))}var o=fi.Buffer.byteLength(e);return this.uint32(o),this._reserve(o),Os(e,this.buf,this.pos),this.pos+=o,this};di._configure()});var Hn=te((Mb,mc)=>{"use strict";mc.exports=ae;var wt=Pt(),Ps,cc=wt.LongBits,fc=wt.utf8;function ye(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function ae(t){this.buf=t,this.pos=0,this.len=t.length,this.view=null,this.discardUnknown=ae.discardUnknown}function lc(t){if(Array.isArray(t)&&(t=new Uint8Array(t)),t instanceof Uint8Array)return new ae(t);throw Error("illegal buffer")}var dc=function(){return wt.Buffer?function(i){return(ae.create=function(n){return wt.Buffer.isBuffer(n)?new Ps(n):lc(n)})(i)}:lc};ae.create=dc();ae.prototype.raw=function(e,i){return this.buf.subarray(e,i)};ae.prototype.uint32=function(){var e=this.buf,i=this.pos,r=(e[i]&127)>>>0;if(e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&127)<<7)>>>0,e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&127)<<14)>>>0,e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&127)<<21)>>>0,e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&15)<<28)>>>0,e[i++]<128)return this.pos=i,r;for(var n=0;n<5;++n){if(i>=this.len)throw this.pos=i,ye(this);if(e[i++]<128)return this.pos=i,r}throw this.pos=i,Error("invalid varint encoding")};ae.prototype.tag=function(){var e=this.buf,i=this.pos,r=(e[i]&127)>>>0;if(e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&127)<<7)>>>0,e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&127)<<14)>>>0,e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&127)<<21)>>>0,e[i++]<128)return this.pos=i,r;if(r=(r|(e[i]&15)<<28)>>>0,e[i]<128&&(e[i]&112)===0)return this.pos=i+1,r;throw this.pos=i+1,Error("invalid tag encoding")};ae.prototype.int32=function(){return this.uint32()|0};ae.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function Ns(){var t=new cc(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<4;++e){if(this.pos>=this.len)throw ye(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}throw ye(this)}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw ye(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}ae.prototype.bool=function(){for(var e=!1,i,r=0;r<10;++r){if(this.pos>=this.len)throw ye(this);if(i=this.buf[this.pos++],i&127&&(e=!0),i<128)return e}throw Error("invalid varint encoding")};function ur(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}ae.prototype.fixed32=function(){if(this.pos+4>this.len)throw ye(this,4);return ur(this.buf,this.pos+=4)};ae.prototype.sfixed32=function(){if(this.pos+4>this.len)throw ye(this,4);return ur(this.buf,this.pos+=4)|0};function uc(){if(this.pos+8>this.len)throw ye(this,8);return new cc(ur(this.buf,this.pos+=4),ur(this.buf,this.pos+=4))}ae.prototype.float=function(){if(this.pos+4>this.len)throw ye(this,4);var e=wt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};ae.prototype.double=function(){if(this.pos+8>this.len)throw ye(this,4);var e=wt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};ae.prototype.uint32s=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos,r=this.buf,n=this.pos,o;n<i;)o=r[n++],o<128?e.push(o):(this.pos=n-1,e.push(this.uint32()),n=this.pos);return this.pos=n,e};ae.prototype.int32s=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos,r=this.buf,n=this.pos,o;n<i;)o=r[n++],o<128?e.push(o):(this.pos=n-1,e.push(this.int32()),n=this.pos);return this.pos=n,e};ae.prototype.sint32s=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos;this.pos<i;)e.push(this.sint32());return e};ae.prototype.bools=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos,r=this.buf,n=this.pos,o;n<i;)o=r[n++],o<128?e.push(o!==0):(this.pos=n-1,e.push(this.bool()),n=this.pos);return this.pos=n,e};var hc=8,pc=128;function Un(t,e,i){var r=t.view;if(r||e<i)return r;var n=t.buf;return t.view=new DataView(n.buffer,n.byteOffset,n.byteLength)}ae.prototype.fixed32s=function(e){e===void 0&&(e=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw ye(this,i);var n=i>>>2,o=e.length,s=this.pos;e.length=o+n;var a=Un(this,n,pc);if(a)for(var l=0;l<n;++l,s+=4)e[o++]=a.getUint32(s,!0);else for(var u=this.buf,c=0;c<n;++c,s+=4)e[o++]=ur(u,s+4);if(this.pos=s,s!==r)throw ye(this,4);return e};ae.prototype.sfixed32s=function(e){e===void 0&&(e=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw ye(this,i);var n=i>>>2,o=e.length,s=this.pos;e.length=o+n;var a=Un(this,n,pc);if(a)for(var l=0;l<n;++l,s+=4)e[o++]=a.getInt32(s,!0);else for(var u=this.buf,c=0;c<n;++c,s+=4)e[o++]=ur(u,s+4)|0;if(this.pos=s,s!==r)throw ye(this,4);return e};ae.prototype.floats=function(e){e===void 0&&(e=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw ye(this,i);var n=i>>>2,o=e.length,s=this.pos;e.length=o+n;var a=Un(this,n,hc);if(a)for(var l=0;l<n;++l,s+=4)e[o++]=a.getFloat32(s,!0);else for(var u=this.buf,c=0;c<n;++c,s+=4)e[o++]=wt.float.readFloatLE(u,s);if(this.pos=s,s!==r)throw ye(this,4);return e};ae.prototype.doubles=function(e){e===void 0&&(e=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw ye(this,i);var n=i>>>3,o=e.length,s=this.pos;e.length=o+n;var a=Un(this,n,hc);if(a)for(var l=0;l<n;++l,s+=8)e[o++]=a.getFloat64(s,!0);else for(var u=this.buf,c=0;c<n;++c,s+=8)e[o++]=wt.float.readDoubleLE(u,s);if(this.pos=s,s!==r)throw ye(this,8);return e};ae.prototype.uint64s=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos;this.pos<i;)e.push(this.uint64());return e};ae.prototype.int64s=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos;this.pos<i;)e.push(this.int64());return e};ae.prototype.sint64s=function(e){e===void 0&&(e=[]);for(var i=this.uint32()+this.pos;this.pos<i;)e.push(this.sint64());return e};ae.prototype.fixed64s=function(e){e===void 0&&(e=[]);var i=this.uint32(),r=this.pos+i,n=e.length;if(r>this.len)throw ye(this,i);var o=i>>>3;e.length=n+o;for(var s=0;s<o;++s)e[n++]=this.fixed64();if(this.pos!==r)throw ye(this,8);return e};ae.prototype.sfixed64s=function(e){e===void 0&&(e=[]);var i=this.uint32(),r=this.pos+i,n=e.length;if(r>this.len)throw ye(this,i);var o=i>>>3;e.length=n+o;for(var s=0;s<o;++s)e[n++]=this.sfixed64();if(this.pos!==r)throw ye(this,8);return e};ae.prototype.bytes=function(){var e=this.uint32(),i=this.pos,r=this.pos+e;if(r>this.len)throw ye(this,e);return this.pos=r,this.raw(i,r)};ae.prototype.string=function(){var e=this.uint32(),i=this.pos,r=this.pos+e;if(r>this.len)throw ye(this,e);return this.pos=r,fc.read(this.buf,i,r)};ae.prototype.stringVerify=function(){var e=this.uint32(),i=this.pos,r=this.pos+e;if(r>this.len)throw ye(this,e);return this.pos=r,fc.readStrict(this.buf,i,r)};ae.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ye(this);while(this.buf[this.pos++]&128);return this};ae.recursionLimit=wt.recursionLimit;ae.discardUnknown=!0;ae.prototype.skipType=function(t,e,i){if(e===void 0&&(e=0),e>ae.recursionLimit)throw Error("max depth exceeded");if(i===0)throw Error("illegal tag: field number 0");switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var r=this.tag(),n=r>>>3;if(t=r&7,!n)throw Error("illegal tag: field number 0");if(t===4){if(i!==void 0&&n!==i)throw Error("invalid end group tag");break}this.skipType(t,e+1,n)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this};ae._configure=function(t){Ps=t,ae.create=dc(),Ps._configure();var e=wt.Long?"toLong":"toNumber";wt.merge(ae.prototype,{int64:function(){return Ns.call(this)[e](!1)},uint64:function(){return Ns.call(this)[e](!0)},sint64:function(){return Ns.call(this).zzDecode()[e](!1)},fixed64:function(){return uc.call(this)[e](!0)},sfixed64:function(){return uc.call(this)[e](!1)}})}});var bc=te((Fb,vc)=>{"use strict";vc.exports=hi;var yc=Hn();hi.prototype=Object.create(yc.prototype,{constructor:{value:hi,writable:!0,enumerable:!1,configurable:!0}});var gc=Pt();function hi(t){yc.call(this,t)}hi._configure=function(){gc.Buffer&&(hi.prototype._slice=gc.Buffer.prototype.slice)};hi.prototype.raw=function(e,i){return this._slice.call(this.buf,e,i)};hi.prototype.string=function(){var e=this.uint32(),i=this.pos,r=this.pos+e;if(r>this.len)throw RangeError("index out of range: "+this.pos+" + "+e+" > "+this.len);return this.pos=r,this.buf.utf8Slice?this.buf.utf8Slice(i,r):this.buf.toString("utf-8",i,r)};hi._configure()});var Sc=te((Db,wc)=>{"use strict";wc.exports=Vr;var Ms=Pt();Vr.prototype=Object.create(Ms.EventEmitter.prototype,{constructor:{value:Vr,writable:!0,enumerable:!1,configurable:!0}});function Vr(t,e,i){if(typeof t!="function")throw TypeError("rpcImpl must be a function");Ms.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!e,this.responseDelimited=!!i}Vr.prototype.rpcCall=function t(e,i,r,n,o){if(!n)throw TypeError("request must be specified");var s=this;if(!o)return Ms.asPromise(t,s,e,i,r,n);if(!s.rpcImpl){setTimeout(function(){o(Error("already ended"))},0);return}try{return s.rpcImpl(e,i[s.requestDelimited?"encodeDelimited":"encode"](n).finish(),function(l,u){if(l)return s.emit("error",l,e),o(l);if(u===null){s.end(!0);return}if(!(u instanceof r))try{u=r[s.responseDelimited?"decodeDelimited":"decode"](u)}catch(c){return s.emit("error",c,e),o(c)}return s.emit("data",u,e),o(null,u)})}catch(a){s.emit("error",a,e),setTimeout(function(){o(a)},0);return}};Vr.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var Fs=te(xc=>{"use strict";var km=xc;km.Service=Sc()});var Ds=te(($b,_c)=>{"use strict";_c.exports=Object.create(null)});var Ec=te(He=>{"use strict";He.build="minimal";He.Writer=Vn();He.BufferWriter=ac();He.Reader=Hn();He.BufferReader=bc();He.util=Pt();He.rpc=Fs();He.roots=Ds();He.configure=Ic;function Ic(){He.util.LongBits._configure(He.util.Long),He.Writer._configure(He.BufferWriter),He.Reader._configure(He.BufferReader)}Ic()});var $s=te(Cc=>{"use strict";var zs=Cc;zs.numberRe=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;zs.typeRefRe=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;zs.reservedRe=/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/});var Ac=te((qb,kc)=>{"use strict";kc.exports=Ls;var Am=$s(),Tm=Am.reservedRe;function Ls(t,e){typeof t=="string"&&(e=t,t=void 0);var i=[];function r(o){if(typeof o!="string"){var s=n();if(Ls.verbose&&console.log("codegen: "+s),s="return "+s,o){for(var a=Object.keys(o),l=new Array(a.length+1),u=new Array(a.length),c=0;c<a.length;)l[c]=a[c],u[c]=o[a[c++]];return l[c]=s,Function.apply(null,l).apply(null,u)}return Function(s)()}for(var f=new Array(arguments.length-1),h=0;h<f.length;)f[h]=arguments[++h];if(h=0,o=o.replace(/%([%dfijs])/g,function(g,v){var I=f[h++];switch(v){case"d":case"f":return I=Number(I),Object.is(I,-0)?"-0":String(I);case"i":return String(Math.floor(I));case"j":return JSON.stringify(I);case"s":return String(I)}return"%"}),h!==f.length)throw Error("parameter count mismatch");return i.push(o),r}function n(o){return"function "+Rm(o||e)+"("+(t&&t.join(",")||"")+`){
|
|
2
|
+
`+i.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
}`}return Object.defineProperty(r,"toString",{value:n,writable:!0,enumerable:!0,configurable:!0}),r}Ls.verbose=!1;function Rm(t){return!t||(t=String(t).replace(/[^\w$]/g,""),!t)?"":(/^\d/.test(t)&&(t="_"+t),Tm.test(t)?t+"_":t)}});var Gs=te((Bb,Tc)=>{"use strict";var cr=null;try{cr=Lp("fs"),(!cr||!cr.readFile||!cr.readFileSync)&&(cr=null)}catch{}Tc.exports=cr});var Oc=te((jb,Rc)=>{"use strict";Rc.exports=Ur;var Om=Es(),qs=Gs();function Ur(t,e,i){return typeof e=="function"?(i=e,e={}):e||(e={}),i?!e.xhr&&qs&&qs.readFile?qs.readFile(t,function(n,o){return n&&typeof XMLHttpRequest<"u"?Ur.xhr(t,e,i):n?i(n):i(null,e.binary?o:o.toString("utf8"))}):Ur.xhr(t,e,i):Om(Ur,this,t,e)}Ur.xhr=function(e,i,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(n.readyState===4){if(n.status!==0&&n.status!==200)return r(Error("status "+n.status));if(i.binary){var s=n.response;if(!s){s=[];for(var a=0;a<n.responseText.length;++a)s.push(n.responseText.charCodeAt(a)&255)}return r(null,typeof Uint8Array<"u"?new Uint8Array(s):s)}return r(null,n.responseText)}},i.binary&&("overrideMimeType"in n&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.responseType="arraybuffer"),n.open("GET",e),n.send()}});var Mc=te(Pc=>{"use strict";var Vs=Pc,js=/^[a-zA-Z][a-zA-Z0-9+.-]+:\/\//;function Nm(t){if(typeof URL>"u"||!js.test(t))return null;try{return new URL(t).href}catch{return null}}function Pm(t,e){if(typeof URL>"u"||!js.test(t)||js.test(e))return null;try{return new URL(e,t).href}catch{return null}}var Nc=Vs.isAbsolute=function(e){return/^(?:\/|\w+:|\\\\\w+)/.test(e)},Bs=Vs.normalize=function(e){var i=Nm(e);if(i)return i;var r=e.substring(0,2),n="";r==="\\\\"&&(n=r,e=e.substring(2)),e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/");var o=e.split("/"),s=Nc(e),a="";s&&(a=o.shift()+"/");for(var l=0;l<o.length;)o[l]===".."?l>0&&o[l-1]!==".."?o.splice(--l,2):s?o.splice(l,1):++l:o[l]==="."?o.splice(l,1):++l;return n+a+o.join("/")};Vs.resolve=function(e,i,r){var n=Pm(e,i);return n||(r||(i=Bs(i)),Nc(i)?i:(r||(e=Bs(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?Bs(e+"/"+i):i))}});var dr=te((Ub,zc)=>{"use strict";zc.exports=ue;var Yn=gi();ue.prototype=Object.create(Yn.prototype,{constructor:{value:ue,writable:!0,enumerable:!1,configurable:!0}});ue.className="Namespace";var Us=mi(),pi=Be(),Mm=Di(),Mi,fr,Fi;ue.fromJSON=function(e,i,r){if(r===void 0&&(r=0),r>pi.recursionLimit)throw Error("max depth exceeded");return new ue(e,i.options).addJSON(i.nested,r)};function Fc(t,e){if(t&&t.length){for(var i={},r=0;r<t.length;++r)i[t[r].name]=t[r].toJSON(e);return i}}ue.arrayToJSON=Fc;ue.isReservedId=function(e,i){if(e){for(var r=0;r<e.length;++r)if(typeof e[r]!="string"&&e[r][0]<=i&&e[r][1]>=i)return!0}return!1};ue.isReservedName=function(e,i){if(e){for(var r=0;r<e.length;++r)if(e[r]===i)return!0}return!1};function ue(t,e){Yn.call(this,t,e),this.nested=void 0,this._nestedArray=null,this._lookupCache=Object.create(null),this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0}function Dc(t){t._nestedArray=null,t._lookupCache=Object.create(null);for(var e=t;e=e.parent;)e._lookupCache=Object.create(null);return t}Object.defineProperty(ue.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=pi.toArray(this.nested))}});ue.prototype.toJSON=function(e){return pi.toObject(["options",this.options,"nested",Fc(this.nestedArray,e)])};ue.prototype.addJSON=function(e,i){if(i===void 0&&(i=0),i>pi.recursionLimit)throw Error("max depth exceeded");var r=this;if(e)for(var n=Object.keys(e),o=0,s;o<n.length;++o)s=e[n[o]],r.add((s.fields!==void 0?Mi.fromJSON:s.values!==void 0?Fi.fromJSON:s.methods!==void 0?fr.fromJSON:s.id!==void 0?Us.fromJSON:ue.fromJSON)(n[o],s,i+1));return this};ue.prototype.get=function(e){return this.nested&&Object.prototype.hasOwnProperty.call(this.nested,e)?this.nested[e]:null};ue.prototype.getEnum=function(e){if(this.nested&&Object.prototype.hasOwnProperty.call(this.nested,e)&&this.nested[e]instanceof Fi)return this.nested[e].values;throw Error("no such enum: "+e)};ue.prototype.add=function(e){if(!(e instanceof Us&&e.extend!==void 0||e instanceof Mi||e instanceof Mm||e instanceof Fi||e instanceof fr||e instanceof ue))throw TypeError("object must be a valid nested object");if(e.name==="__proto__")return this;if(!this.nested)this.nested={};else{var i=this.get(e.name);if(i)if(i instanceof ue&&e instanceof ue&&!(i instanceof Mi||i instanceof fr)){for(var r=i.nestedArray,n=0;n<r.length;++n)e.add(r[n]);this.remove(i),this.nested||(this.nested={}),e.setOptions(i.options,!0)}else throw Error("duplicate name '"+e.name+"' in "+this)}this.nested[e.name]=e,this instanceof Mi||this instanceof fr||this instanceof Fi||this instanceof Us||e._edition||(e._edition=e._defaultEdition),this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0;for(var o=this;o=o.parent;)o._needsRecursiveFeatureResolution=!0,o._needsRecursiveResolve=!0;return e.onAdd(this),Dc(this)};ue.prototype.remove=function(e){if(!(e instanceof Yn))throw TypeError("object must be a ReflectionObject");if(e.parent!==this)throw Error(e+" is not a member of "+this);if(!pi.remove(this.nested,e,e.name))throw Error(e+" is not a member of "+this);return Object.keys(this.nested).length||(this.nested=void 0),e.onRemove(this),Dc(this)};ue.prototype.define=function(e,i){if(pi.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&e[0]==="")throw Error("path must be relative");if(e.length>pi.recursionLimit)throw Error("max depth exceeded");for(var r=this;e.length>0;){var n=e.shift();if(r.nested&&r.nested[n]){if(r=r.nested[n],!(r instanceof ue))throw Error("path conflicts with non-namespace objects")}else r.add(r=new ue(n))}return i&&r.addJSON(i),r};ue.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;this._needsRecursiveFeatureResolution&&this._resolveFeaturesRecursive(this._edition);var e=this.nestedArray,i=0;for(this.resolve();i<e.length;)e[i]instanceof ue?e[i++].resolveAll():e[i++].resolve();return this._needsRecursiveResolve=!1,this};ue.prototype._resolveFeaturesRecursive=function(e){return this._needsRecursiveFeatureResolution?(this._needsRecursiveFeatureResolution=!1,e=this._edition||e,Yn.prototype._resolveFeaturesRecursive.call(this,e),this.nestedArray.forEach(i=>{i._resolveFeaturesRecursive(e)}),this):this};ue.prototype.lookup=function(e,i,r){if(typeof i=="boolean"?(r=i,i=void 0):i&&!Array.isArray(i)&&(i=[i]),pi.isString(e)&&e.length){if(e===".")return this.root;e=e.split(".")}else if(!e.length)return this;var n=e.join(".");if(e[0]==="")return this.root.lookup(e.slice(1),i);var o=this._lookupImpl(e,n);if(o&&(!i||i.indexOf(o.constructor)>-1)||(o=this.root._fullyQualifiedObjects&&this.root._fullyQualifiedObjects["."+n],o&&(!i||i.indexOf(o.constructor)>-1)))return o;if(r)return null;for(var s=this;s.parent;){if(o=s.parent._lookupImpl(e,n),o&&(!i||i.indexOf(o.constructor)>-1))return o;s=s.parent}return null};ue.prototype._lookupImpl=function(e,i){if(Object.prototype.hasOwnProperty.call(this._lookupCache,i))return this._lookupCache[i];var r=this.get(e[0]),n=null;if(r)e.length===1?n=r:r instanceof ue&&(e=e.slice(1),n=r._lookupImpl(e,e.join(".")));else for(var o=0;o<this.nestedArray.length;++o)if(this._nestedArray[o]instanceof ue&&(r=this._nestedArray[o]._lookupImpl(e,i))){n=r;break}return this._lookupCache[i]=n,n};ue.prototype.lookupType=function(e){var i=this.lookup(e,[Mi]);if(!i)throw Error("no such type: "+e);return i};ue.prototype.lookupEnum=function(e){var i=this.lookup(e,[Fi]);if(!i)throw Error("no such Enum '"+e+"' in "+this);return i};ue.prototype.lookupTypeOrEnum=function(e){var i=this.lookup(e,[Mi,Fi]);if(!i)throw Error("no such Type or Enum '"+e+"' in "+this);return i};ue.prototype.lookupService=function(e){var i=this.lookup(e,[fr]);if(!i)throw Error("no such Service '"+e+"' in "+this);return i};ue._configure=function(t,e,i){Mi=t,fr=e,Fi=i}});var Xn=te((Hb,$c)=>{"use strict";$c.exports=Ft;var Hs=mi();Ft.prototype=Object.create(Hs.prototype,{constructor:{value:Ft,writable:!0,enumerable:!1,configurable:!0}});Ft.className="MapField";var Fm=yi(),hr=Be();function Ft(t,e,i,r,n,o){if(Hs.call(this,t,e,r,void 0,void 0,n,o),!hr.isString(i))throw TypeError("keyType must be a string");this.keyType=i,this.resolvedKeyType=null,this.map=!0}Ft.fromJSON=function(e,i){var r=new Ft(e,i.id,i.keyType,i.type,i.options,i.comment);return i.protoName&&(r.protoName=i.protoName),i.jsonName!==void 0?r.jsonName=i.jsonName:i.options&&i.options.json_name!==void 0&&(r.jsonName=i.options.json_name),r};Ft.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return hr.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"protoName",this.protoName!==this.name?this.protoName:void 0,"jsonName",this.jsonName!==hr.jsonName(this.protoName||this.name)?this.jsonName:void 0,"options",this.options,"comment",i?this.comment:void 0])};Ft.prototype.resolve=function(){if(this.resolved)return this;if(Fm.mapKey[this.keyType]===void 0)throw Error("invalid key type: "+this.keyType);return Hs.prototype.resolve.call(this)};Ft.d=function(e,i,r){return typeof r=="function"?r=hr.decorateType(r).name:r&&typeof r=="object"&&(r=hr.decorateEnum(r).name),function(o,s){hr.decorateType(o.constructor).add(new Ft(s,e,i,r))}}});var Wn=te((Yb,Lc)=>{"use strict";Lc.exports=vi;var Ys=gi();vi.prototype=Object.create(Ys.prototype,{constructor:{value:vi,writable:!0,enumerable:!1,configurable:!0}});vi.className="Method";var pr=Be();function vi(t,e,i,r,n,o,s,a,l){if(pr.isObject(n)?(s=n,n=o=void 0):pr.isObject(o)&&(s=o,o=void 0),!(e===void 0||pr.isString(e)))throw TypeError("type must be a string");if(!pr.isString(i))throw TypeError("requestType must be a string");if(!pr.isString(r))throw TypeError("responseType must be a string");Ys.call(this,t,s),this.type=e||"rpc",this.requestType=i,this.requestStream=n?!0:void 0,this.responseType=r,this.responseStream=o?!0:void 0,this.path="/"+this.name,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=a,this.parsedOptions=l}vi.fromJSON=function(e,i){return new vi(e,i.type,i.requestType,i.responseType,i.requestStream,i.responseStream,i.options,i.comment,i.parsedOptions)};vi.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return pr.toObject(["type",this.type!=="rpc"&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",i?this.comment:void 0,"parsedOptions",this.parsedOptions])};vi.prototype.resolve=function(){if(this.resolved)return this;if(this.parent){var e=this.parent.fullName;e.charAt(0)==="."&&(e=e.substring(1)),this.path="/"+e+"/"+this.name}else this.path="/"+this.name;return this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),Ys.prototype.resolve.call(this)}});var Jn=te((Xb,Bc)=>{"use strict";Bc.exports=it;var Kt=dr();it.prototype=Object.create(Kt.prototype,{constructor:{value:it,writable:!0,enumerable:!1,configurable:!0}});it.className="Service";var Xs=Wn(),Kn=Be(),Gc=Fs();function it(t,e){Kt.call(this,t,e),this.methods={},this._methodsArray=null}it.fromJSON=function(e,i,r){if(r===void 0&&(r=0),r>Kn.recursionLimit)throw Error("max depth exceeded");var n=new it(e,i.options);if(i.methods)for(var o=Object.keys(i.methods),s=0;s<o.length;++s)n.add(Xs.fromJSON(o[s],i.methods[o[s]]));return i.nested&&n.addJSON(i.nested,r),i.edition&&(n._edition=i.edition),n.comment=i.comment,n._defaultEdition="proto3",n};it.prototype.toJSON=function(e){var i=Kt.prototype.toJSON.call(this,e),r=e?!!e.keepComments:!1;return Kn.toObject(["edition",this._editionToJSON(),"options",i&&i.options||void 0,"methods",Kt.arrayToJSON(this.methodsArray,e)||{},"nested",i&&i.nested||void 0,"comment",r?this.comment:void 0])};Object.defineProperty(it.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=Kn.toArray(this.methods))}});function qc(t){return t._methodsArray=null,t}it.prototype.get=function(e){return Object.prototype.hasOwnProperty.call(this.methods,e)?this.methods[e]:Kt.prototype.get.call(this,e)};it.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;Kt.prototype.resolve.call(this);for(var e=this.methodsArray,i=0;i<e.length;++i)e[i].resolve();return this};it.prototype._resolveFeaturesRecursive=function(e){return this._needsRecursiveFeatureResolution?(e=this._edition||e,Kt.prototype._resolveFeaturesRecursive.call(this,e),this.methodsArray.forEach(i=>{i._resolveFeaturesRecursive(e)}),this):this};it.prototype.add=function(e){if(this.get(e.name))throw Error("duplicate name '"+e.name+"' in "+this);return e instanceof Xs?e.name==="__proto__"?this:(this.methods[e.name]=e,e.parent=this,qc(this)):Kt.prototype.add.call(this,e)};it.prototype.remove=function(e){if(e instanceof Xs){if(this.methods[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.methods[e.name],e.parent=null,qc(this)}return Kt.prototype.remove.call(this,e)};it.prototype.create=function(e,i,r){for(var n=new Gc.Service(e,i,r),o=0,s;o<this.methodsArray.length;++o){var a=Kn.lcFirst((s=this._methodsArray[o]).resolve().name).replace(/[^$\w_]/g,"");n[a]=(function(l,u,c){return function(h,m){return Gc.Service.prototype.rpcCall.call(this,l,u,c,h,m)}})(s,s.resolvedRequestType.ctor,s.resolvedResponseType.ctor)}return n}});var Zn=te((Wb,jc)=>{"use strict";jc.exports=Dt;var Dm=Pt();function Dt(t){if(t)for(var e=Object.keys(t),i=0;i<e.length;++i)t[e[i]]!=null&&e[i]!=="__proto__"&&(this[e[i]]=t[e[i]])}Dt.create=function(e){return this.$type.create(e)};Dt.encode=function(e,i){return this.$type.encode(e,i)};Dt.encodeDelimited=function(e,i){return this.$type.encodeDelimited(e,i)};Dt.decode=function(e){return this.$type.decode(e)};Dt.decodeDelimited=function(e){return this.$type.decodeDelimited(e)};Dt.verify=function(e){return this.$type.verify(e)};Dt.fromObject=function(e){return this.$type.fromObject(e)};Dt.toObject=function(e,i){return this.$type.toObject(e,i)};Dt.prototype.toJSON=function(){return this.$type.toObject(this,Dm.toJSONOptions)}});var Ws=te((Kb,Vc)=>{"use strict";Vc.exports=$m;var Qn=St(),De=yi(),eo=Be();function zm(t){return"missing required '"+t.name+"'"}function Hr(t){return t._features.utf8_validation==="VERIFY"?"stringVerify":"string"}function mr(t,e){return t("if(!r.discardUnknown){")('util.makeProp(m,"$unknowns",false);')("(m.$unknowns||(m.$unknowns=[])).push(%s)",e)("}")}function $m(t){for(var e=!1,i=!1,r=0;r<t.fieldsArray.length;++r){var n=t._fieldsArray[r];n.map&&(e=!0),(n.resolvedType instanceof Qn||!n.repeated&&!n.map&&!n.hasPresence)&&(i=!0)}var o=eo.codegen(["r","l","z","q","g"])("if(!(r instanceof Reader))")("r=Reader.create(r)")("if(q===undefined)q=0")("if(q>Reader.recursionLimit)")('throw Error("max depth exceeded")')("var c=l===undefined?r.len:r.pos+l,m=g||new C"+(e?",k,v":i?",v":""))("while(r.pos<c){")("var s=r.pos")("var t=r.tag()")("if(t===z){")("z=undefined")("break")("}");for(t.fieldsArray.length&&o("var u=t&7")("switch(t>>>=3){"),r=0;r<t.fieldsArray.length;++r){var s=t._fieldsArray[r].resolve(),a=s.resolvedType instanceof Qn?"int32":s.type,l="m"+eo.safeProp(s.name),u=s.resolvedType instanceof Qn&&s.resolvedType._features.enum_type==="CLOSED";if(s.map){o("case %i:{",s.id)("if(u!==2)")("break"),u||o("if(%s===util.emptyObject)",l)("%s={}",l),o("var c2=r.uint32()+r.pos"),De.defaults[s.keyType]!==void 0?o("k=%j",De.defaults[s.keyType]):o("k=null"),De.long[a]!==void 0?o("v=util.Long?util.Long.fromNumber(0,%j):0",a==="uint64"||a==="fixed64"):De.defaults[a]!==void 0?o("v=%j",De.defaults[a]):o("v=null"),o("while(r.pos<c2){")("var t2=r.tag()")("u=t2&7")("switch(t2>>>=3){")("case 1:")("if(u!==%i)",De.mapKey[s.keyType])("break")("k=r.%s()",s.keyType==="string"?Hr(s):s.keyType)("continue")("case 2:")("if(u!==%i)",De.basic[a]===void 0?2:De.basic[a])("break"),De.basic[a]===void 0?o("v=types[%i].decode(r,r.uint32(),undefined,q+1,v)",r):o("v=r.%s()",a==="string"?Hr(s):a),o("continue")("}")("r.skipType(u,q,t2)")("}"),u&&(o("if(types[%i].valuesById[v]===undefined){",r),mr(o,"r.raw(s,r.pos)")("continue")("}")("if(%s===util.emptyObject)",l)("%s={}",l));var c=De.basic[a]===void 0?"v||new types["+r+"].ctor":"v";De.long[s.keyType]!==void 0?o('%s[typeof k==="object"?util.longToHash(k):k]=%s',l,c):(s.keyType==="string"&&o('if(k==="__proto__")')("util.makeProp(%s,k)",l),o("%s[k]=%s",l,c))}else s.repeated?(o("case %i:",s.id)("{"),De.packed[a]!==void 0&&(o("if(u===2){"),u?(o("var c2=r.uint32()+r.pos")("while(r.pos<c2){")("s=r.pos")("v=r.%s()",a)("if(types[%i].valuesById[v]!==undefined){",r)("if(!(%s&&%s.length))",l,l)("%s=[]",l)("%s.push(v)",l)("}else"),mr(o,"util.rawField("+s.id+",0,r.raw(s,r.pos))")("}")):o("if(!(%s&&%s.length))",l,l)("%s=[]",l)("r.%ss(%s)",a,l),o("continue")("}")),o("if(u!==%i)",De.basic[a]===void 0?s.delimited?3:2:De.basic[a])("break"),u||o("if(!(%s&&%s.length))",l,l)("%s=[]",l),De.basic[a]===void 0?s.delimited?o("%s.push(types[%i].decode(r,undefined,%i,q+1))",l,r,s.id*8+4):o("%s.push(types[%i].decode(r,r.uint32(),undefined,q+1))",l,r):u?(o("v=r.%s()",a)("if(types[%i].valuesById[v]!==undefined){",r)("if(!(%s&&%s.length))",l,l)("%s=[]",l)("%s.push(v)",l)("}else"),mr(o,"r.raw(s,r.pos)")):o("%s.push(r.%s())",l,a==="string"?Hr(s):a)):De.basic[a]===void 0?(o("case %i:{",s.id)("if(u!==%i)",s.delimited?3:2)("break"),s.delimited?o("%s=types[%i].decode(r,undefined,%i,q+1,%s)",l,r,s.id*8+4,l):o("%s=types[%i].decode(r,r.uint32(),undefined,q+1,%s)",l,r,l)):s.hasPresence?(o("case %i:{",s.id)("if(u!==%i)",De.basic[a])("break"),u?(o("v=r.%s()",a)("if(types[%i].valuesById[v]!==undefined){",r)("%s=v",l),s.partOf&&o("m%s=%j",eo.safeProp(s.partOf.name),s.name),o("}else"),mr(o,"r.raw(s,r.pos)")):o("%s=r.%s()",l,a==="string"?Hr(s):a)):(o("case %i:{",s.id)("if(u!==%i)",De.basic[a])("break"),u?(o("v=r.%s()",a)("if(types[%i].valuesById[v]!==undefined){",r)("if(v!==%j)",s.typeDefault)("%s=v",l)("else")("delete %s",l)("}else{"),mr(o,"r.raw(s,r.pos)")("}")):(s.resolvedType instanceof Qn&&s.typeDefault!==0?o("if((v=r.%s())!==%j)",a,s.typeDefault):a==="string"?o("if((v=r.%s()).length)",Hr(s)):a==="bytes"?o("if((v=r.%s()).length)",a):De.long[a]!==void 0?o('if(typeof(v=r.%s())==="object"?v.low||v.high:v!==0)',a):o(a==="double"||a==="float"?"if(!Object.is(v=r.%s(),0))":"if(v=r.%s())",a),o("%s=v",l)("else")("delete %s",l)));s.partOf&&!u&&o("m%s=%j",eo.safeProp(s.partOf.name),s.name),o("continue")("}")}for(r&&o("}"),o("r.skipType(%s,q,t)",r?"u":"t&7"),mr(o,"r.raw(s,r.pos)")("}")("if(z!==undefined)")('throw Error("missing end group")'),r=0;r<t._fieldsArray.length;++r){var f=t._fieldsArray[r];f.required&&o("if(!Object.hasOwnProperty.call(m,%j))",f.name)("throw util.ProtocolError(%j,{instance:m})",zm(f))}return o("return m")}});var Zs=te((Jb,Uc)=>{"use strict";Uc.exports=qm;var Lm=St(),Ks=Be();function at(t,e){return t.name+": "+e+(t.repeated&&e!=="array"?"[]":t.map&&e!=="object"?"{k:"+t.keyType+"}":"")+" expected"}function Js(t,e,i,r){var n=e.resolvedType;if(n)if(n instanceof Lm)if(n._features.enum_type==="CLOSED"){t("switch(%s){",r)("default:")("return%j",at(e,"enum value"));for(var o=Object.keys(n.values),s=0;s<o.length;++s)t("case %i:",n.values[o[s]]);t("break")("}")}else t('if(typeof %s!=="number"||(%s|0)!==%s)',r,r,r)("return%j",at(e,"enum value"));else t("{")("var e=types[%i].verify(%s,q+1);",i,r)("if(e)")("return%j+e",e.name+".")("}");else switch(e.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",r)("return%j",at(e,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",r,r,r,r)("return%j",at(e,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',r)("return%j",at(e,"number"));break;case"bool":t('if(typeof %s!=="boolean")',r)("return%j",at(e,"boolean"));break;case"string":t("if(!util.isString(%s))",r)("return%j",at(e,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',r,r,r)("return%j",at(e,"buffer"));break}return t}function Gm(t,e,i){switch(e.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.key32Re.test(%s))",i)("return%j",at(e,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.key64Re.test(%s))",i)("return%j",at(e,"integer|Long key"));break;case"bool":t("if(!util.key2Re.test(%s))",i)("return%j",at(e,"boolean key"));break}return t}function qm(t){var e=Ks.codegen(["m","q"])('if(typeof m!=="object"||m===null)')("return%j","object expected")("if(q===undefined)q=0")("if(q>util.recursionLimit)")("return%j","max depth exceeded"),i=t.oneofsArray,r={};i.length&&e("var p={}");for(var n=0;n<t.fieldsArray.length;++n){var o=t._fieldsArray[n].resolve(),s="m"+Ks.safeProp(o.name);if(o.optional&&e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",s,o.name),o.map)e("if(!util.isObject(%s))",s)("return%j",at(o,"object"))("var k=Object.keys(%s)",s)("for(var i=0;i<k.length;++i){"),Gm(e,o,"k[i]"),Js(e,o,n,s+"[k[i]]")("}");else if(o.repeated)e("if(!Array.isArray(%s))",s)("return%j",at(o,"array"))("for(var i=0;i<%s.length;++i){",s),Js(e,o,n,s+"[i]")("}");else{if(o.partOf){var a=Ks.safeProp(o.partOf.name);r[o.partOf.name]===1&&e("if(p%s===1)",a)("return%j",o.partOf.name+": multiple values"),r[o.partOf.name]=1,e("p%s=1",a)}Js(e,o,n,s)}o.optional&&e("}")}return e("return null")}});var ia=te(Yc=>{"use strict";var Hc=Yc,Jt=St(),ta=yi(),xt=Be();function Qs(t,e,i,r,n){if(e.resolvedType)if(e.resolvedType instanceof Jt){var o=n?"m"+n+"[m"+n+".length]":"m"+r;t("switch(d%s){",r);for(var s=e.resolvedType.values,a=Object.keys(s),l=0;l<a.length;++l)t("case%j:",a[l])("case %i:",s[a[l]])("%s=%j",o,s[a[l]])("break");t("default:"),e.resolvedType._features.enum_type!=="CLOSED"&&t('if(typeof d%s==="number"&&(d%s|0)===d%s)',r,r,r)("%s=d%s",o,r),t("}")}else t("if(!util.isObject(d%s))",r)("throw TypeError(%j)",e.fullName+": object expected")("m%s=types[%i].fromObject(d%s,q+1)",r,i,r);else{var u=!1;switch(e.type){case"double":case"float":t("m%s=Number(d%s)",r,r);break;case"uint32":case"fixed32":t("m%s=d%s>>>0",r,r);break;case"int32":case"sint32":case"sfixed32":t("m%s=d%s|0",r,r);break;case"uint64":case"fixed64":u=!0;case"int64":case"sint64":case"sfixed64":t("if(util.Long)")("m%s=util.Long.fromValue(d%s,%j)",r,r,u)('else if(typeof d%s==="string")',r)("m%s=parseInt(d%s,10)",r,r)('else if(typeof d%s==="number")',r)("m%s=d%s",r,r)('else if(typeof d%s==="object")',r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",r,r,r,u?"true":"");break;case"bytes":t('if(typeof d%s==="string")',r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",r,r,r)("else if(d%s.length>=0)",r)("m%s=d%s",r,r);break;case"string":t("m%s=String(d%s)",r,r);break;case"bool":t("m%s=Boolean(d%s)",r,r);break}}return t}Hc.fromObject=function(e){var i=e.fieldsArray,r=xt.codegen(["d","q"])("if(d instanceof C)")("return d")("if(!util.isObject(d))")("throw TypeError(%j)",e.fullName+": object expected")("if(q===undefined)q=0")("if(q>util.recursionLimit)")('throw Error("max depth exceeded")');if(!i.length)return r("return new C");r("var m=new C");for(var n=0;n<i.length;++n){var o=i[n].resolve(),s=xt.safeProp(o.name),a=!o.hasPresence&&!o.repeated&&!o.map&&(o.resolvedType instanceof Jt||ta.basic[o.type]!==void 0);o.map?(r("if(d%s){",s)("if(!util.isObject(d%s))",s)("throw TypeError(%j)",o.fullName+": object expected")("m%s={}",s)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",s),r('if(ks[i]==="__proto__")')("util.makeProp(m%s,ks[i])",s),Qs(r,o,n,s+"[ks[i]]")("}")("}")):o.repeated?(r("if(d%s){",s)("if(!Array.isArray(d%s))",s)("throw TypeError(%j)",o.fullName+": array expected"),o.resolvedType instanceof Jt?r("m%s=[]",s):r("m%s=Array(d%s.length)",s,s),r("for(var i=0;i<d%s.length;++i){",s),Qs(r,o,n,s+"[i]",o.resolvedType instanceof Jt?s:void 0)("}")("}")):(o.resolvedType instanceof Jt||r("if(d%s!=null){",s),a&&(o.resolvedType instanceof Jt?r('if(d%s!==%j&&(typeof d%s!=="string"||types[%i].values[d%s]!==%j)){',s,o.typeDefault,s,n,s,o.typeDefault):o.type==="string"?r('if(typeof d%s!=="string"||d%s.length){',s,s):o.type==="bytes"?r("if(d%s.length){",s):o.type==="bool"?r("if(d%s){",s):o.type==="double"||o.type==="float"?r("if(!Object.is(Number(d%s),0)){",s):ta.long[o.type]!==void 0?r('if(typeof d%s==="object"?d%s.low||d%s.high:Number(d%s)!==0){',s,s,s,s):r("if(Number(d%s)!==0){",s)),Qs(r,o,n,s),a&&r("}"),o.resolvedType instanceof Jt||r("}"))}return r("return m")};function ea(t,e,i,r,n){if(n||(n=r),e.resolvedType)e.resolvedType instanceof Jt?t("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",r,i,n,n,i,n,n):t("d%s=types[%i].toObject(m%s,o,q+1)",r,i,n);else{var o=!1;switch(e.type){case"double":case"float":t("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",r,n,n,n);break;case"uint64":case"fixed64":o=!0;case"int64":case"sint64":case"sfixed64":t('if(typeof BigInt!=="undefined"&&o.longs===BigInt)')('d%s=typeof m%s==="number"?BigInt(m%s):util.Long.fromBits(m%s.low>>>0,m%s.high>>>0,%j).toBigInt()',r,n,n,n,n,o)('else if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",r,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",r,n,n,n,o?"true":"",n);break;case"bytes":t("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",r,n,n,n,n);break;default:t("d%s=m%s",r,n);break}}return t}Hc.toObject=function(e){var i=e.fieldsArray.slice().sort(xt.compareFieldsById);if(!i.length)return xt.codegen()("return {}");for(var r=xt.codegen(["m","o","q"])("if(!o)")("o={}")("if(q===undefined)q=0")("if(q>util.recursionLimit)")('throw Error("max depth exceeded")')("var d={}"),n=[],o=[],s=[],a=0;a<i.length;++a)i[a].partOf||(i[a].resolve().repeated?n:i[a].map?o:s).push(i[a]);if(n.length){for(r("if(o.arrays||o.defaults){"),a=0;a<n.length;++a)r("d%s=[]",xt.safeProp(n[a].name));r("}")}if(o.length){for(r("if(o.objects||o.defaults){"),a=0;a<o.length;++a)r("d%s={}",xt.safeProp(o[a].name));r("}")}if(s.length){for(r("if(o.defaults){"),a=0;a<s.length;++a){var l=s[a],u=xt.safeProp(l.name);if(l.resolvedType instanceof Jt)r("d%s=o.enums===String?%j:%j",u,l.resolvedType.valuesById[l.typeDefault],l.typeDefault);else if(l.long)r("if(util.Long){")("var n=new util.Long(%i,%i,%j)",l.typeDefault.low,l.typeDefault.high,l.typeDefault.unsigned)('d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!=="undefined"&&o.longs===BigInt?n.toBigInt():n',u)("}else")('d%s=o.longs===String?%j:typeof BigInt!=="undefined"&&o.longs===BigInt?BigInt(%j):%i',u,l.typeDefault.toString(),l.typeDefault.toString(),l.typeDefault.toNumber());else if(l.bytes){var c=Array.prototype.slice.call(l.typeDefault);r("if(o.bytes===String)d%s=%j",u,xt.base64.encode(l.typeDefault,0,l.typeDefault.length))("else{")("d%s=%j",u,c)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",u,u)("}")}else(l.type==="double"||l.type==="float")&&typeof l.typeDefault=="number"&&(!isFinite(l.typeDefault)||Object.is(l.typeDefault,-0))?r("d%s=%f",u,l.typeDefault)("if(o.json&&!isFinite(d%s))d%s=String(d%s)",u,u,u):r("d%s=%j",u,l.typeDefault)}r("}")}var f=!1;for(a=0;a<i.length;++a){var l=i[a],h=e._fieldsArray.indexOf(l),u=xt.safeProp(l.name);if(l.map){f||(f=!0,r("var ks2")),r("if(m%s&&(ks2=Object.keys(m%s)).length){",u,u)("d%s={}",u);var m=ta.long[l.keyType]!==void 0,g=u+"[ks2[j]]";r("for(var j=0;j<ks2.length;++j){"),m&&r("var k2=util.longFromKey(ks2[j],%j).toString()",l.keyType==="uint64"||l.keyType==="fixed64"),r('if(ks2[j]==="__proto__")')("util.makeProp(d%s,ks2[j])",u),ea(r,l,h,m?u+"[k2]":g,g)("}")}else l.repeated?(r("if(m%s&&m%s.length){",u,u)("d%s=Array(m%s.length)",u,u)("for(var j=0;j<m%s.length;++j){",u),ea(r,l,h,u+"[j]")("}")):(r("if(m%s!=null&&Object.hasOwnProperty.call(m,%j)){",u,l.name),ea(r,l,h,u),l.partOf&&!l.partOf.isProto3Optional&&r("if(o.oneofs)")("d%s=%j",xt.safeProp(l.partOf.name),l.name));r("}")}return r("return d")}});var ra=te(Xc=>{"use strict";var Bm=Xc,jm=Zn(),Vm=Pt();Bm[".google.protobuf.Any"]={fromObject:function(t,e){if(t&&t["@type"]){var i=t["@type"].substring(t["@type"].lastIndexOf("/")+1),r=this.lookup(i,[this.constructor]);if(r){var n=t["@type"].charAt(0)==="."?t["@type"].slice(1):t["@type"];return n.indexOf("/")===-1&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(t,e===void 0?1:e+1)).finish()})}}return this.fromObject(t,e)},toObject:function(t,e,i){if(i===void 0&&(i=0),i>Vm.recursionLimit)throw Error("max depth exceeded");var r="type.googleapis.com/",n="",o="";if(e&&e.json&&t.type_url&&t.value){o=t.type_url.substring(t.type_url.lastIndexOf("/")+1),n=t.type_url.substring(0,t.type_url.lastIndexOf("/")+1);var s=this.lookup(o,[this.constructor]);s&&(t=s.decode(t.value,void 0,void 0,i+1))}if(!(t instanceof this.ctor)&&t instanceof jm){var a=t.$type.toObject(t,e,i+1),l=t.$type.fullName[0]==="."?t.$type.fullName.slice(1):t.$type.fullName;return n===""&&(n=r),o=n+l,a["@type"]=o,a}return this.toObject(t,e,i)}}});var ro=te((ew,Jc)=>{"use strict";Jc.exports=pe;var ft=dr();pe.prototype=Object.create(ft.prototype,{constructor:{value:pe,writable:!0,enumerable:!1,configurable:!0}});pe.className="Type";var Um=St(),sa=Di(),to=mi(),Hm=Xn(),Ym=Jn(),na=Zn(),oa=Hn(),Kc=Vn(),ze=Be(),Xm=aa(),Wm=Ws(),Km=Zs(),Wc=ia(),Jm=ra();function pe(t,e){t=t.replace(/\W/g,""),ft.call(this,t,e),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null,this._fieldsByJsonName=null}Object.defineProperties(pe.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var t=Object.keys(this.fields),e=0;e<t.length;++e){var i=this.fields[t[e]],r=i.id;if(this._fieldsById[r])throw Error("duplicate id "+r+" in "+this);this._fieldsById[r]=i}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=ze.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=ze.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=pe.generateConstructor(this)())},set:function(t){var e=t.prototype;e instanceof na||(t.prototype=new na,Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),ze.merge(t.prototype,e)),t.$type=t.prototype.$type=this,ze.merge(t,na,!0),this._ctor=t,delete this.decode,delete this.fromObject;for(var i=0,r;i<this.fieldsArray.length;++i)r=this._fieldsArray[i].resolve(),t.prototype[r.name]=r.defaultValue;var n={};for(i=0;i<this.oneofsArray.length;++i)n[this._oneofsArray[i].resolve().name]={get:ze.oneOfGetter(this._oneofsArray[i].oneof),set:ze.oneOfSetter(this._oneofsArray[i].oneof)};i&&Object.defineProperties(t.prototype,n)}}});pe.generateConstructor=function(e){for(var i=ze.codegen(["p"]),r=0,n;r<e.fieldsArray.length;++r)(n=e._fieldsArray[r]).map?i("this%s={}",ze.safeProp(n.name)):n.repeated&&i("this%s=[]",ze.safeProp(n.name));return i('if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null&&ks[i]!=="__proto__")')("this[ks[i]]=p[ks[i]]")};function io(t){return t._fieldsById=t._fieldsArray=t._oneofsArray=t._fieldsByJsonName=null,delete t.encode,delete t.decode,delete t.verify,t}pe.fromJSON=function(e,i,r){if(r===void 0&&(r=0),r>ze.nestingLimit)throw Error("max depth exceeded");var n=new pe(e,i.options);n.extensions=i.extensions,n.reserved=i.reserved;for(var o=Object.keys(i.fields),s=0;s<o.length;++s)n.add((typeof i.fields[o[s]].keyType<"u"?Hm.fromJSON:to.fromJSON)(o[s],i.fields[o[s]]));if(i.oneofs)for(o=Object.keys(i.oneofs),s=0;s<o.length;++s)n.add(sa.fromJSON(o[s],i.oneofs[o[s]]));if(i.nested)for(o=Object.keys(i.nested),s=0;s<o.length;++s){var a=i.nested[o[s]];n.add((a.id!==void 0?to.fromJSON:a.fields!==void 0?pe.fromJSON:a.values!==void 0?Um.fromJSON:a.methods!==void 0?Ym.fromJSON:ft.fromJSON)(o[s],a,r+1))}return i.extensions&&i.extensions.length&&(n.extensions=i.extensions),i.reserved&&i.reserved.length&&(n.reserved=i.reserved),i.group&&(n.group=!0),i.comment&&(n.comment=i.comment),i.edition&&(n._edition=i.edition),n._defaultEdition="proto3",n};pe.prototype.toJSON=function(e){var i=ft.prototype.toJSON.call(this,e),r=e?!!e.keepComments:!1;return ze.toObject(["edition",this._editionToJSON(),"options",i&&i.options||void 0,"oneofs",ft.arrayToJSON(this.oneofsArray,e),"fields",ft.arrayToJSON(this.fieldsArray.filter(function(n){return!n.declaringField}),e)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",i&&i.nested||void 0,"comment",r?this.comment:void 0])};pe.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;ft.prototype.resolveAll.call(this);var e=this.oneofsArray;for(r=0;r<e.length;)e[r++].resolve();for(var i=this.fieldsArray,r=0;r<i.length;)i[r++].resolve();return this};pe.prototype._resolveFeaturesRecursive=function(e){return this._needsRecursiveFeatureResolution?(e=this._edition||e,ft.prototype._resolveFeaturesRecursive.call(this,e),this.oneofsArray.forEach(i=>{i._resolveFeatures(e)}),this.fieldsArray.forEach(i=>{i._resolveFeatures(e)}),this):this};pe.prototype.get=function(e){return Object.prototype.hasOwnProperty.call(this.fields,e)?this.fields[e]:this.oneofs&&Object.prototype.hasOwnProperty.call(this.oneofs,e)?this.oneofs[e]:this.nested&&Object.prototype.hasOwnProperty.call(this.nested,e)?this.nested[e]:null};pe.prototype.add=function(e){if(this.get(e.name))throw Error("duplicate name '"+e.name+"' in "+this);if(e instanceof to&&e.extend===void 0){if(this._fieldsById?this._fieldsById[e.id]:this.fieldsById[e.id])throw Error("duplicate id "+e.id+" in "+this);if(this.isReservedId(e.id))throw Error("id "+e.id+" is reserved in "+this);if(this.isReservedName(e.name)||e.name.charAt(0)==="$")throw Error("name '"+e.name+"' is reserved in "+this);return e.name==="__proto__"?this:(e.parent&&e.parent.remove(e),this.fields[e.name]=e,e.message=this,e.onAdd(this),io(this))}if(e instanceof sa){if(e.name.charAt(0)==="$")throw Error("name '"+e.name+"' is reserved in "+this);return e.name==="__proto__"?this:(this.oneofs||(this.oneofs={}),this.oneofs[e.name]=e,e.onAdd(this),io(this))}return ft.prototype.add.call(this,e)};pe.prototype.remove=function(e){if(e instanceof to&&e.extend===void 0){if(!ze.remove(this.fields,e,e.name))throw Error(e+" is not a member of "+this);return e.parent=null,e.onRemove(this),io(this)}if(e instanceof sa){if(!ze.remove(this.oneofs,e,e.name))throw Error(e+" is not a member of "+this);return e.parent=null,e.onRemove(this),io(this)}return ft.prototype.remove.call(this,e)};pe.prototype.isReservedId=function(e){return ft.isReservedId(this.reserved,e)};pe.prototype.isReservedName=function(e){return ft.isReservedName(this.reserved,e)};pe.prototype.create=function(e){return new this.ctor(e)};pe.prototype.setup=function(){var e=this.root;if(e&&e._needsRecursiveFeatureResolution){var i=e._edition||this._edition;i&&e._resolveFeaturesRecursive(i)}for(var r=this.fullName,n=[],o=0;o<this.fieldsArray.length;++o)n.push(this._fieldsArray[o].resolve().resolvedType);this.encode=Xm(this)({Writer:Kc,types:n,util:ze}),this.decode=Wm(this)({Reader:oa,types:n,util:ze,C:this.ctor}),this.verify=Km(this)({types:n,util:ze}),this.fromObject=Wc.fromObject(this)({types:n,util:ze,C:this.ctor}),this.toObject=Wc.toObject(this)({types:n,util:ze});var s=Jm[r];if(s){var a=Object.create(this);a._ctor=this.ctor,a.fromObject=this.fromObject,this.fromObject=s.fromObject.bind(a),a.toObject=this.toObject,this.toObject=s.toObject.bind(a)}return this};pe.prototype.encode=function(e,i){return this.setup().encode.apply(this,arguments)};pe.prototype.encodeDelimited=function(e,i){return this.encode(e,(i||Kc.create()).fork()).ldelim()};pe.prototype.decode=function(e,i){return this.setup().decode.apply(this,arguments)};pe.prototype.decodeDelimited=function(e){return e instanceof oa||(e=oa.create(e)),this.decode(e,e.uint32())};pe.prototype.verify=function(e){return this.setup().verify.apply(this,arguments)};pe.prototype.fromObject=function(e){return this.setup().fromObject.apply(this,arguments)};pe.prototype.toObject=function(e,i){return this.setup().toObject.apply(this,arguments)};pe.prototype.getTypeUrl=function(e){e===void 0&&(e="type.googleapis.com");var i=this.fullName;return e+"/"+(i.charAt(0)==="."?i.substring(1):i)};pe.d=function(e){return function(r){ze.decorateType(r,e)}}});var ao=te((tw,ef)=>{"use strict";ef.exports=rt;var so=dr();rt.prototype=Object.create(so.prototype,{constructor:{value:rt,writable:!0,enumerable:!1,configurable:!0}});rt.className="Root";var no=mi(),la=St(),Zm=Di(),zt=Be(),ua,ca,gr;function rt(t){so.call(this,"",t),this.deferred=[],this.files=[],this._edition="proto2",this._fullyQualifiedObjects={}}rt.fromJSON=function(e,i,r){if(r===void 0&&(r=0),r>zt.recursionLimit)throw Error("max depth exceeded");return i||(i=new rt),e.options&&i.setOptions(e.options),i.addJSON(e.nested,r).resolveAll()};rt.prototype.resolvePath=zt.path.resolve;rt.prototype.fetch=zt.fetch;function Qc(){}rt.prototype.load=function t(e,i,r){typeof i=="function"&&(r=i,i=void 0);var n=this;if(!r)return zt.asPromise(t,n,e,i);var o=r===Qc;function s(m,g){if(r){if(o)throw m;g&&g.resolveAll();var v=r;r=null,v(m,g)}}function a(m){var g=m.lastIndexOf("google/protobuf/");if(g>-1){var v=m.substring(g);if(Object.prototype.hasOwnProperty.call(gr,v))return v}return Object.prototype.hasOwnProperty.call(gr,m)?m:null}function l(m,g,v){v===void 0&&(v=0);try{if(v>zt.recursionLimit)throw Error("max depth exceeded");if(zt.isString(g)&&g.charAt(0)==="{"&&(g=JSON.parse(g)),!zt.isString(g))n.setOptions(g.options).addJSON(g.nested);else{ca.filename=m;var I=ca(g,n,i),C,E=0;if(I.imports)for(;E<I.imports.length;++E)(C=a(I.imports[E])||n.resolvePath(m,I.imports[E]))&&u(C,!1,v+1);if(I.weakImports)for(E=0;E<I.weakImports.length;++E)(C=a(I.weakImports[E])||n.resolvePath(m,I.weakImports[E]))&&u(C,!0,v+1)}}catch(D){s(D)}!o&&!c&&s(null,n)}function u(m,g,v){if(v===void 0&&(v=0),m=a(m)||m,!(n.files.indexOf(m)>-1)){if(n.files.push(m),Object.prototype.hasOwnProperty.call(gr,m)){o?l(m,gr[m],v):(++c,setTimeout(function(){--c,l(m,gr[m],v)}));return}if(o){var I;try{I=zt.fs.readFileSync(m).toString("utf8")}catch(C){g||s(C);return}l(m,I,v)}else++c,n.fetch(m,function(C,E){if(--c,!!r){if(C){g?c||s(null,n):s(C);return}l(m,E,v)}})}}var c=0;zt.isString(e)&&(e=[e]);for(var f=0,h;f<e.length;++f)(h=n.resolvePath("",e[f]))&&u(h);return o?(n.resolveAll(),n):(c||s(null,n),n)};rt.prototype.loadSync=function(e,i){if(!zt.isNode)throw Error("not supported");return this.load(e,i,Qc)};rt.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(e){return"'extend "+e.extend+"' in "+e.parent.fullName}).join(", "));return so.prototype.resolveAll.call(this)};var oo=/^[A-Z]/;function Zc(t,e){var i=e.parent.lookup(e.extend);if(i){var r=new no(e.fullName,e.id,e.type,e.rule,void 0,e.options);return i.get(r.name)||(r.declaringField=e,e.extensionField=r,i.add(r)),!0}return!1}rt.prototype._handleAdd=function(e){if(e instanceof no)e.extend!==void 0&&!e.extensionField&&(Zc(this,e)||this.deferred.push(e));else if(e instanceof la)oo.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof Zm)){if(e instanceof ua)for(var i=0;i<this.deferred.length;)Zc(this,this.deferred[i])?this.deferred.splice(i,1):++i;for(var r=0;r<e.nestedArray.length;++r)this._handleAdd(e._nestedArray[r]);oo.test(e.name)&&(e.parent[e.name]=e)}(e instanceof ua||e instanceof la||e instanceof no)&&(this._fullyQualifiedObjects[e.fullName]=e)};rt.prototype._handleRemove=function(e){if(e instanceof no){if(e.extend!==void 0)if(e.extensionField)e.extensionField.parent.remove(e.extensionField),e.extensionField=null;else{var i=this.deferred.indexOf(e);i>-1&&this.deferred.splice(i,1)}}else if(e instanceof la)oo.test(e.name)&&delete e.parent[e.name];else if(e instanceof so){for(var r=0;r<e.nestedArray.length;++r)this._handleRemove(e._nestedArray[r]);oo.test(e.name)&&delete e.parent[e.name]}delete this._fullyQualifiedObjects[e.fullName]};rt._configure=function(t,e,i){ua=t,ca=e,gr=i}});var Be=te((iw,nf)=>{"use strict";var _e=nf.exports=Pt(),tf=Ds(),fa,da;_e.codegen=Ac();_e.fetch=Oc();_e.path=Mc();_e.patterns=$s();var rf=_e.patterns.reservedRe;_e.fs=Gs();_e.toArray=function(e){if(e){for(var i=Object.keys(e),r=new Array(i.length),n=0;n<i.length;)r[n]=e[i[n++]];return r}return[]};_e.toObject=function(e){for(var i={},r=0;r<e.length;){var n=e[r++],o=e[r++];o!==void 0&&(i[n]=o)}return i};_e.remove=function(e,i,r){if(!e)return!1;if(r!==void 0&&Object.prototype.hasOwnProperty.call(e,r)&&e[r]===i)return delete e[r],!0;for(var n=Object.keys(e),o=0;o<n.length;++o)if(e[n[o]]===i)return delete e[n[o]],!0;return!1};_e.isReserved=function(e){return rf.test(e)};_e.safeProp=function(e){return!/^[$\w_]+$/.test(e)||rf.test(e)?"["+JSON.stringify(e)+"]":"."+e};_e.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var Qm=/_([a-z])/g;_e.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(Qm,function(i,r){return r.toUpperCase()})};_e.jsonName=function(e){for(var i="",r=!1,n=0;n<e.length;++n){var o=e.charAt(n);o==="_"?r=!0:r?(i+=o.toUpperCase(),r=!1):i+=o}return i};_e.compareFieldsById=function(e,i){return e.id-i.id};_e.decorateType=function(e,i){if(e.$type)return i&&e.$type.name!==i&&(_e.decorateRoot.remove(e.$type),e.$type.name=i,_e.decorateRoot.add(e.$type)),e.$type;fa||(fa=ro());var r=new fa(i||e.name);return _e.decorateRoot.add(r),r.ctor=e,Object.defineProperty(e,"$type",{value:r,enumerable:!1}),Object.defineProperty(e.prototype,"$type",{value:r,enumerable:!1}),r};var eg=0;_e.decorateEnum=function(e){if(e.$type)return e.$type;da||(da=St());var i=new da("Enum"+eg++,e);return _e.decorateRoot.add(i),Object.defineProperty(e,"$type",{value:i,enumerable:!1}),i};_e.setProperty=function(e,i,r,n){function o(s,a,l){var u=a.shift();if(_e.isUnsafeProperty(u))return s;if(a.length>0)s[u]=o(s[u]||{},a,l);else{var c=s[u];if(c&&n)return s;c&&(l=[].concat(c).concat(l)),s[u]=l}return s}if(typeof e!="object")throw TypeError("dst must be an object");if(!i)throw TypeError("path must be specified");if(i=i.split("."),i.length>_e.recursionLimit)throw Error("max depth exceeded");return o(e,i,r)};Object.defineProperty(_e,"decorateRoot",{get:function(){return tf.decorated||(tf.decorated=new(ao()))}})});var yi=te(of=>{"use strict";var Yr=of,tg=Be(),ig=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function Xr(t,e){var i=0,r=Object.create(null);for(e|=0;i<t.length;)r[ig[i+e]]=t[i++];return r}Yr.basic=Xr([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]);Yr.defaults=Xr([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",tg.emptyArray,null]);Yr.long=Xr([0,0,0,1,1],7);Yr.mapKey=Xr([0,0,0,5,5,0,0,0,1,1,0,2],2);Yr.packed=Xr([1,5,0,0,0,5,5,0,0,0,1,1,0])});var mi=te((nw,af)=>{"use strict";af.exports=$e;var Kr=gi();$e.prototype=Object.create(Kr.prototype,{constructor:{value:$e,writable:!0,enumerable:!1,configurable:!0}});$e.className="Field";var sf=St(),lo=yi(),Te=Be(),Wr,rg=/^(?:required|optional|repeated)$/;$e.fromJSON=function(e,i){var r=new $e(e,i.id,i.type,i.rule,i.extend,i.options,i.comment);return i.edition&&(r._edition=i.edition),i.protoName&&(r.protoName=i.protoName),i.jsonName!==void 0?r.jsonName=i.jsonName:i.options&&i.options.json_name!==void 0&&(r.jsonName=i.options.json_name),r._defaultEdition="proto3",r};function $e(t,e,i,r,n,o,s){if(Te.isObject(r)?(s=n,o=r,r=n=void 0):Te.isObject(n)&&(s=o,o=n,n=void 0),Kr.call(this,t,o),!Te.isInteger(e)||e<0)throw TypeError("id must be a non-negative integer");if(!Te.isString(i))throw TypeError("type must be a string");if(r!==void 0&&!rg.test(r=r.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(n!==void 0&&!Te.isString(n))throw TypeError("extend must be a string");this.rule=r&&r!=="optional"?r:void 0,this.type=i,this.id=e,this.extend=n||void 0,this.repeated=r==="repeated",this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=Te.Long?lo.long[i]!==void 0:!1,this.bytes=i==="bytes",this.resolvedType=null,this.extensionField=null,this.declaringField=null,this.comment=s,this.protoName=void 0,this.jsonName=void 0}Object.defineProperty($e.prototype,"required",{get:function(){return this._features.field_presence==="LEGACY_REQUIRED"}});Object.defineProperty($e.prototype,"optional",{get:function(){return!this.required}});Object.defineProperty($e.prototype,"delimited",{get:function(){return this.resolvedType instanceof Wr&&this._features.message_encoding==="DELIMITED"}});Object.defineProperty($e.prototype,"packed",{get:function(){return this._features.repeated_field_encoding==="PACKED"}});Object.defineProperty($e.prototype,"hasPresence",{get:function(){return this.repeated||this.map?!1:this.partOf||this.declaringField||this.extensionField||this._features.field_presence!=="IMPLICIT"}});$e.prototype.setOption=function(e,i,r){return Kr.prototype.setOption.call(this,e,i,r)};$e.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return Te.toObject(["edition",this._editionToJSON(),"rule",this.rule!=="optional"&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"protoName",this.protoName!==this.name?this.protoName:void 0,"jsonName",this.jsonName!==Te.jsonName(this.protoName||this.name)?this.jsonName:void 0,"options",this.options,"comment",i?this.comment:void 0])};$e.prototype.resolve=function(){if(this.resolved)return this;if((this.typeDefault=lo.defaults[this.type])===void 0?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof Wr?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&this.options.default!=null&&(this.typeDefault=this.options.default,this.resolvedType instanceof sf&&typeof this.typeDefault=="string"&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(this.options.packed!==void 0&&this.resolvedType&&!(this.resolvedType instanceof sf)&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long){var e=this.type==="uint64"||this.type==="fixed64";this.typeDefault=typeof this.typeDefault=="string"?Te.Long.fromString(this.typeDefault,e):Te.Long.fromNumber(this.typeDefault,e),Object.freeze&&Object.freeze(this.typeDefault)}else if(lo.long[this.type]!==void 0&&typeof this.typeDefault=="string")this.typeDefault=parseInt(this.typeDefault,10);else if(this.bytes&&typeof this.typeDefault=="string"){var i;Te.base64.test(this.typeDefault)?Te.base64.decode(this.typeDefault,i=Te.newBuffer(Te.base64.length(this.typeDefault)),0):Te.utf8.write(this.typeDefault,i=Te.newBuffer(Te.utf8.length(this.typeDefault)),0),this.typeDefault=i}return this.map?this.defaultValue=Te.emptyObject:this.repeated?this.defaultValue=Te.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof Wr&&this.parent._ctor&&(this.parent._ctor.prototype[this.name]=this.defaultValue),this.protoName===void 0&&(this.protoName=this.name),this.jsonName===void 0&&(this.jsonName=Te.jsonName(this.protoName)),Kr.prototype.resolve.call(this)};$e.prototype._inferLegacyProtoFeatures=function(e){if(e!=="proto2"&&e!=="proto3")return{};var i={};if(this.rule==="required"&&(i.field_presence="LEGACY_REQUIRED"),this.parent&&lo.defaults[this.type]===void 0){var r=this.parent.get(this.type.split(".").pop());r&&r instanceof Wr&&r.group&&(i.message_encoding="DELIMITED")}return this.getOption("packed")===!0?i.repeated_field_encoding="PACKED":this.getOption("packed")===!1&&(i.repeated_field_encoding="EXPANDED"),i};$e.prototype._resolveFeatures=function(e){return Kr.prototype._resolveFeatures.call(this,this._edition||e)};$e.d=function(e,i,r,n){return typeof i=="function"?i=Te.decorateType(i).name:i&&typeof i=="object"&&(i=Te.decorateEnum(i).name),function(s,a){Te.decorateType(s.constructor).add(new $e(a,e,i,r,{default:n}))}};$e._configure=function(e){Wr=e}});var Di=te((ow,cf)=>{"use strict";cf.exports=nt;var co=gi();nt.prototype=Object.create(co.prototype,{constructor:{value:nt,writable:!0,enumerable:!1,configurable:!0}});nt.className="OneOf";var lf=mi(),uo=Be();function nt(t,e,i,r){if(Array.isArray(e)||(i=e,e=void 0),co.call(this,t,i),!(e===void 0||Array.isArray(e)))throw TypeError("fieldNames must be an Array");this.oneof=e||[],this.fieldsArray=[],this.comment=r}nt.fromJSON=function(e,i){return new nt(e,i.oneof,i.options,i.comment)};nt.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return uo.toObject(["options",this.options,"oneof",this.oneof,"comment",i?this.comment:void 0])};function uf(t){if(t.parent)for(var e=0;e<t.fieldsArray.length;++e)t.fieldsArray[e].parent||t.parent.add(t.fieldsArray[e])}nt.prototype.add=function(e){if(!(e instanceof lf))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,uf(this),this};nt.prototype.remove=function(e){if(!(e instanceof lf))throw TypeError("field must be a Field");var i=this.fieldsArray.indexOf(e);if(i<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(i,1),i=this.oneof.indexOf(e.name),i>-1&&this.oneof.splice(i,1),e.partOf=null,this};nt.prototype.onAdd=function(e){co.prototype.onAdd.call(this,e);for(var i=this,r=0;r<this.oneof.length;++r){var n=e.get(this.oneof[r]);n&&!n.partOf&&(n.partOf=i,i.fieldsArray.push(n))}uf(this)};nt.prototype.onRemove=function(e){for(var i=0,r;i<this.fieldsArray.length;++i)(r=this.fieldsArray[i]).parent&&r.parent.remove(r);co.prototype.onRemove.call(this,e)};Object.defineProperty(nt.prototype,"isProto3Optional",{get:function(){if(this.fieldsArray==null||this.fieldsArray.length!==1)return!1;var t=this.fieldsArray[0];return t.options!=null&&t.options.proto3_optional===!0}});nt.d=function(){for(var e=new Array(arguments.length),i=0;i<arguments.length;)e[i]=arguments[i++];return function(n,o){uo.decorateType(n.constructor).add(new nt(o,e)),Object.defineProperty(n,o,{get:uo.oneOfGetter(e),set:uo.oneOfSetter(e)})}}});var gi=te((sw,ff)=>{"use strict";ff.exports=Ue;Ue.className="ReflectionObject";var ng=Di(),_t=Be(),fo,og={enum_type:"OPEN",field_presence:"EXPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY",enforce_naming_style:"STYLE2024",default_symbol_visibility:"EXPORT_TOP_LEVEL"},sg={enum_type:"OPEN",field_presence:"EXPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY",enforce_naming_style:"STYLE_LEGACY",default_symbol_visibility:"EXPORT_ALL"},ag={enum_type:"CLOSED",field_presence:"EXPLICIT",json_format:"LEGACY_BEST_EFFORT",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"EXPANDED",utf8_validation:"NONE",enforce_naming_style:"STYLE_LEGACY",default_symbol_visibility:"EXPORT_ALL"},lg={enum_type:"OPEN",field_presence:"IMPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY",enforce_naming_style:"STYLE_LEGACY",default_symbol_visibility:"EXPORT_ALL"};function Ue(t,e){if(!_t.isString(t))throw TypeError("name must be a string");if(e&&!_t.isObject(e))throw TypeError("options must be an object");this.options=e,this.parsedOptions=null,this.name=t,this._edition=null,this._defaultEdition="proto2",this._features={},this._featuresResolved=!1,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(Ue.prototype,{root:{get:function(){for(var t=this;t.parent!==null;)t=t.parent;return t}},fullName:{get:function(){for(var t=[this.name],e=this.parent;e;)t.unshift(e.name),e=e.parent;return t.join(".")}}});Ue.prototype.toJSON=function(){throw Error()};Ue.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var i=e.root;i instanceof fo&&i._handleAdd(this)};Ue.prototype.onRemove=function(e){var i=e.root;i instanceof fo&&i._handleRemove(this),this.parent=null,this.resolved=!1};Ue.prototype.resolve=function(){return this.resolved?this:(this.root instanceof fo&&(this.resolved=!0),this)};Ue.prototype._resolveFeaturesRecursive=function(e){return this._resolveFeatures(this._edition||e)};Ue.prototype._resolveFeatures=function(e){if(!this._featuresResolved){var i={};if(!e)throw new Error("Unknown edition for "+this.fullName);var r=_t.merge({},this.options&&this.options.features,this._inferLegacyProtoFeatures(e));if(this._edition){if(e==="proto2")i=Object.assign({},ag);else if(e==="proto3")i=Object.assign({},lg);else if(e==="2023")i=Object.assign({},sg);else if(e==="2024")i=Object.assign({},og);else throw new Error("Unknown edition: "+e);this._features=_t.merge(i,r)}else if(this.partOf instanceof ng){var n=_t.merge({},this.partOf._features);this._features=_t.merge(n,r)}else if(!this.declaringField)if(this.parent){var o=_t.merge({},this.parent._features);this._features=_t.merge(o,r)}else throw new Error("Unable to find a parent for "+this.fullName);this.extensionField&&(this.extensionField._features=this._features),this._featuresResolved=!0}};Ue.prototype._inferLegacyProtoFeatures=function(){return{}};Ue.prototype.getOption=function(e){if(this.options&&Object.prototype.hasOwnProperty.call(this.options,e))return this.options[e]};Ue.prototype.setOption=function(e,i,r){if(e==="__proto__")return this;if(this.options||(this.options={}),/^features\./.test(e))_t.setProperty(this.options,e,i,r);else{var n=this.getOption(e);(!r||n===void 0)&&(n!==i&&(this.resolved=!1),this.options[e]=i)}return this};Ue.prototype.setParsedOption=function(e,i,r){if(e==="__proto__")return this;this.parsedOptions||(this.parsedOptions=[]);var n=this.parsedOptions;if(r){var o=n.find(function(l){return Object.prototype.hasOwnProperty.call(l,e)});if(o){var s=o[e];_t.setProperty(s,r,i)}else o={},o[e]=_t.setProperty({},r,i),n.push(o)}else{var a={};a[e]=i,n.push(a)}return this};Ue.prototype.setOptions=function(e,i){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)this.setOption(r[n],e[r[n]],i);return this};Object.defineProperty(Ue.prototype,"toString",{value:function(){var e=this.constructor.className,i=this.fullName;return i.length?e+" "+i:e},writable:!0,enumerable:!1,configurable:!0});Ue.prototype._editionToJSON=function(){if(!(!this._edition||this._edition==="proto3"))return this._edition};Ue._configure=function(t){fo=t}});var St=te((aw,hf)=>{"use strict";hf.exports=dt;var ha=gi();dt.prototype=Object.create(ha.prototype,{constructor:{value:dt,writable:!0,enumerable:!1,configurable:!0}});dt.className="Enum";var df=dr(),yr=Be();function dt(t,e,i,r,n,o){if(ha.call(this,t,i),e&&typeof e!="object")throw TypeError("values must be an object");if(this.valuesById=Object.create(null),this.values=Object.create(this.valuesById),this.comment=r,this.comments=n||{},this.valuesOptions=o,this._valuesFeatures={},this.reserved=void 0,e)for(var s=Object.keys(e),a=0;a<s.length;++a)s[a]!=="__proto__"&&typeof e[s[a]]=="number"&&(this.values[s[a]]=e[s[a]],this.valuesById[e[s[a]]]===void 0&&(this.valuesById[e[s[a]]]=s[a]))}dt.prototype._resolveFeatures=function(e){return e=this._edition||e,ha.prototype._resolveFeatures.call(this,e),Object.keys(this.values).forEach(i=>{var r=yr.merge({},this._features);this._valuesFeatures[i]=yr.merge(r,this.valuesOptions&&this.valuesOptions[i]&&this.valuesOptions[i].features||{})}),this};dt.fromJSON=function(e,i){var r=new dt(e,i.values,i.options,i.comment,i.comments,i.valuesOptions);return r.reserved=i.reserved,i.edition&&(r._edition=i.edition),r._defaultEdition="proto3",r};dt.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return yr.toObject(["edition",this._editionToJSON(),"options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",i?this.comment:void 0,"comments",i?this.comments:void 0])};dt.prototype.add=function(e,i,r,n){if(!yr.isString(e))throw TypeError("name must be a string");if(!yr.isInteger(i))throw TypeError("id must be an integer");if(e==="__proto__")return this;if(this.values[e]!==void 0)throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(i))throw Error("id "+i+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(this.valuesById[i]!==void 0){if(!(this.options&&this.options.allow_alias))throw Error("duplicate id "+i+" in "+this);this.values[e]=i}else this.valuesById[this.values[e]=i]=e;return n&&(this.valuesOptions===void 0&&(this.valuesOptions={}),this.valuesOptions[e]=n||null),this.comments[e]=r||null,this};dt.prototype.remove=function(e){if(!yr.isString(e))throw TypeError("name must be a string");var i=this.values[e];if(i==null)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[i],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this};dt.prototype.isReservedId=function(e){return df.isReservedId(this.reserved,e)};dt.prototype.isReservedName=function(e){return df.isReservedName(this.reserved,e)}});var aa=te((lw,mf)=>{"use strict";mf.exports=ug;var pa=St(),bi=yi(),ma=Be();function pf(t,e,i,r){return e.delimited?t("types[%i].encode(%s,w.uint32(%i),q+1).uint32(%i)",i,r,(e.id<<3|3)>>>0,(e.id<<3|4)>>>0):t("types[%i].encode(%s,w.uint32(%i).fork(),q+1).ldelim()",i,r,(e.id<<3|2)>>>0)}function ug(t){for(var e=ma.codegen(["m","w","q"])("if(!w)")("w=Writer.create()")("if(q===undefined)q=0")("if(q>util.recursionLimit)")('throw Error("max depth exceeded")'),i,r,n=t.fieldsArray.slice().sort(ma.compareFieldsById),i=0;i<n.length;++i){var o=n[i].resolve(),s=t._fieldsArray.indexOf(o),a=o.resolvedType instanceof pa?"int32":o.type,l=bi.basic[a];r="m"+ma.safeProp(o.name),o.map?(e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",r,o.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",r),o.keyType==="bool"?e("w.uint32(%i).fork().uint32(%i).bool(util.boolFromKey(ks[i]))",(o.id<<3|2)>>>0,8|bi.mapKey[o.keyType]):bi.long[o.keyType]!==void 0?e("w.uint32(%i).fork().uint32(%i).%s(util.longFromKey(ks[i],%j))",(o.id<<3|2)>>>0,8|bi.mapKey[o.keyType],o.keyType,o.keyType==="uint64"||o.keyType==="fixed64"):e("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(o.id<<3|2)>>>0,8|bi.mapKey[o.keyType],o.keyType),l===void 0?e("types[%i].encode(%s[ks[i]],w.uint32(18).fork(),q+1).ldelim().ldelim()",s,r):e(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|l,a,r),e("}")("}")):o.repeated?(e("if(%s!=null&&%s.length){",r,r),o.packed&&bi.packed[a]!==void 0?e("w.uint32(%i).%ss(%s)",(o.id<<3|2)>>>0,a,r):(e("for(var i=0;i<%s.length;++i)",r),l===void 0?pf(e,o,s,r+"[i]"):e("w.uint32(%i).%s(%s[i])",(o.id<<3|l)>>>0,a,r)),e("}")):(o.required||(o.hasPresence||!(o.resolvedType instanceof pa||bi.basic[a]!==void 0)?e("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",r,o.name):o.resolvedType instanceof pa?e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&%s!==%j)",r,o.name,r,o.typeDefault):a==="bool"?e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&%s!==false)",r,o.name,r):a==="string"?e('if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&%s!=="")',r,o.name,r):a==="bytes"?e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&%s.length)",r,o.name,r):a==="double"||a==="float"?e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&!Object.is(%s,0))",r,o.name,r):bi.long[a]!==void 0?e('if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&(typeof %s==="object"?%s.low||%s.high:%s!==0))',r,o.name,r,r,r,r):e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)&&%s!==0)",r,o.name,r)),l===void 0?pf(e,o,s,r):e("w.uint32(%i).%s(%s)",(o.id<<3|l)>>>0,a,r))}return e('if(m.$unknowns!=null&&Object.hasOwnProperty.call(m,"$unknowns"))')("for(var i=0;i<m.$unknowns.length;++i)")("w.raw(m.$unknowns[i])")("return w")}});var yf=te((le,gf)=>{"use strict";le=gf.exports=Ec();le.build="light";function cg(t,e,i){return typeof e=="function"?(i=e,e=new le.Root):e||(e=new le.Root),e.load(t,i)}le.load=cg;function fg(t,e){return e||(e=new le.Root),e.loadSync(t)}le.loadSync=fg;le.encoder=aa();le.decoder=Ws();le.verifier=Zs();le.converter=ia();le.ReflectionObject=gi();le.Namespace=dr();le.Root=ao();le.Enum=St();le.Type=ro();le.Field=mi();le.OneOf=Di();le.MapField=Xn();le.Service=Jn();le.Method=Wn();le.Message=Zn();le.wrappers=ra();le.types=yi();le.util=Be();le.ReflectionObject._configure(le.Root);le.Namespace._configure(le.Type,le.Service,le.Enum);le.Root._configure(le.Type,void 0,{});le.Field._configure(le.Type)});var ya=te((uw,wf)=>{"use strict";wf.exports=bf;var ga=/[\s{}=;:[\],'"()<>]/g,dg=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,hg=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,pg=/^ *[*/]+ */,mg=/^\s*\*?\/*/,gg=/\n/g,yg=/\s/,vg=/\\(.?)/g,bg={0:"\0",r:"\r",n:`
|
|
5
|
+
`,t:" "};function vf(t){return t.replace(vg,function(e,i){switch(i){case"\\":case"":return i;default:return bg[i]||""}})}bf.unescape=vf;function bf(t,e){t=t.toString();var i=0,r=t.length,n=1,o=0,s={},a=[],l=null;function u(S){return Error("illegal "+S+" (line "+n+")")}function c(){var S=l==="'"?hg:dg;S.lastIndex=i-1;var z=S.exec(t);if(!z)throw u("string");return i=S.lastIndex,I(l),l=null,vf(z[1])}function f(S){return t.charAt(S)}function h(S,z,L){var j={type:t.charAt(S++),lineEmpty:!1,leading:L},B;e?B=2:B=3;var _=S-B,O;do if(--_<0||(O=t.charAt(_))===`
|
|
6
|
+
`){j.lineEmpty=!0;break}while(O===" "||O===" ");for(var y=t.substring(S,z).split(gg),N=0;N<y.length;++N)y[N]=y[N].replace(e?mg:pg,"").trim();j.text=y.join(`
|
|
7
|
+
`).trim(),s[n]=j,o=n}function m(S){var z=g(S),L=t.substring(S,z),j=/^\s*\/\//.test(L);return j}function g(S){for(var z=S;z<r&&f(z)!==`
|
|
8
|
+
`;)z++;return z}function v(){if(a.length>0)return a.shift();if(l)return c();var S,z,L,j,B,_,O=i===0;do{if(i===r)return null;for(S=!1;yg.test(L=f(i));)if(L===`
|
|
9
|
+
`&&(O=!0,++n),++i===r)return null;if(f(i)==="/"){if(++i===r)throw u("comment");if(f(i)==="/")if(e){if(j=i,B=!1,m(i-1)){B=!0;do{if(i=g(i),i===r||(i++,!O))break;_=m(i),_&&n++}while(_)}else i=Math.min(r,g(i)+1);B&&(h(j,i,O),O=!0),n++,S=!0}else{for(B=f(j=i+1)==="/";f(++i)!==`
|
|
10
|
+
`;)if(i===r)return null;++i,B&&(h(j,i-1,O),O=!0),++n,S=!0}else if((L=f(i))==="*"){j=i+1,B=e||f(j)==="*";do{if(L===`
|
|
11
|
+
`&&++n,++i===r)throw u("comment");z=L,L=f(i)}while(z!=="*"||L!=="/");++i,B&&(h(j,i-2,O),O=!0),S=!0}else return"/"}}while(S);var y=i;ga.lastIndex=0;var N=ga.test(f(y++));if(!N)for(;y<r&&!ga.test(f(y));)++y;var x=t.substring(i,i=y);return(x==='"'||x==="'")&&(l=x),x}function I(S){a.push(S)}function C(){if(!a.length){var S=v();if(S===null)return null;I(S)}return a[0]}function E(S,z){var L=C(),j=L===S;if(j)return v(),!0;if(!z)throw u("token '"+L+"', '"+S+"' expected");return!1}function D(S){var z=null,L;return S===void 0?(L=s[n-1],delete s[n-1],L&&(e||L.type==="*"||L.lineEmpty)&&(z=L.leading?L.text:null)):(o<S&&C(),L=s[S],delete s[S],L&&!L.lineEmpty&&(e||L.type==="/")&&(z=L.leading?null:L.text)),z}return Object.defineProperty({next:v,peek:C,push:I,skip:E,cmnt:D},"line",{get:function(){return n}})}});var Ef=te((cw,If)=>{"use strict";If.exports=Qt;Qt.filename=null;Qt.defaults={keepCase:!1};var wg=ya(),Sf=ao(),xf=ro(),ho=mi(),Sg=Xn(),_f=Di(),xg=St(),_g=Jn(),Ig=Wn(),Eg=gi(),Cg=yi(),Zt=Be(),kg=/^[1-9][0-9]*$/,Ag=/^-?[1-9][0-9]*$/,Tg=/^0[x][0-9a-fA-F]+$/,Rg=/^-?0[x][0-9a-fA-F]+$/,Og=/^0[0-7]+$/,Ng=/^-?0[0-7]+$/,Pg=/^(?:u?int|sint|s?fixed)(?:32|64)$/,Mg=/^(?:uint|fixed)(?:32|64)$/,Fg=Zt.patterns.numberRe,$t=/^[a-zA-Z_][a-zA-Z_0-9]*$/,It=Zt.patterns.typeRefRe,Dg=536870911,zg=2147483647;function Qt(t,e,i){e instanceof Sf||(i=e,e=new Sf),i||(i=Qt.defaults);var r=i.preferTrailingComment||!1,n=wg(t,i.alternateCommentMode||!1),o=n.next,s=n.push,a=n.peek,l=n.skip,u=n.cmnt,c=!0,f,h,m,g="proto2",v=e,I=[],C={},E=i.keepCase?function(T){return T}:Zt.camelCase;function D(){I.forEach(T=>{T._edition=g,Object.keys(C).forEach(A=>{T.getOption(A)===void 0&&T.setOption(A,C[A],!0)})})}function S(T,A,P){var M=Qt.filename;return P||(Qt.filename=null),Error("illegal "+(A||"token")+" '"+T+"' ("+(M?M+", ":"")+"line "+n.line+")")}function z(){var T=[],A;do{if((A=o())!=='"'&&A!=="'")throw S(A);T.push(o()),l(A),A=a()}while(A==='"'||A==="'");return T.join("")}function L(T){var A=o();switch(A){case"'":case'"':return s(A),z();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return B(A,!0)}catch{if(T&&It.test(A))return A;throw S(A,"value")}}function j(T,A,P,M){var U,J;do if(A&&((U=a())==='"'||U==="'")){var re=z();if(T.push(re),g>=2023)throw S(re,"id")}else try{T.push([J=O(o(),M,P),l("to",!0)?O(o(),M,P):J])}catch(ie){if(A&&It.test(U)&&g>=2023)T.push(U);else throw ie}while(l(",",!0));var oe={options:void 0};oe.setOption=function(ie,Me){this.options===void 0&&(this.options={}),this.options[ie]=Me},F(oe,function(Me){if(Me==="option")ee(oe,Me),l(";");else throw S(Me)},function(){qt(oe)})}function B(T,A){var P=1;switch(T.charAt(0)==="-"&&(P=-1,T=T.substring(1)),T){case"inf":case"INF":case"Inf":return P*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return P*0}if(kg.test(T))return P*parseInt(T,10);if(Tg.test(T))return P*parseInt(T,16);if(Og.test(T))return P*parseInt(T,8);if(Fg.test(T))return P*parseFloat(T);throw S(T,"number",A)}function _(T,A,P){if(T===null)throw S(T,"end of input");if(!A&&T.charAt(0)==="-")throw S(T,P||"integer");if(T==="0"||T==="-0")return 0;var M;if(Ag.test(T))M=parseInt(T,10);else if(Rg.test(T))M=parseInt(T,16);else if(Ng.test(T))M=parseInt(T,8);else throw S(T,P||"integer");return M||0}function O(T,A,P){switch(T){case"max":case"MAX":case"Max":return P||Dg}return _(T,A,"id")}function y(){if(f!==void 0)throw S("package");if(f=o(),f===null||!It.test(f))throw S(f,"name");v=v.define(f),l(";")}function N(){var T=a(),A;switch(T){case"option":if(g<"2024")throw S("option");o(),z(),l(";");return;case"weak":A=m||(m=[]),o();break;case"public":o();default:A=h||(h=[]);break}T=z(),l(";"),A.push(T)}function x(){if(l("="),g=z(),g<2023)throw S(g,"syntax");l(";")}function d(){if(l("="),g=z(),!["2023","2024"].includes(g))throw S(g,"edition");l(";")}function w(T,A,P){switch(P===void 0&&(P=0),A){case"option":return ee(T,A),l(";"),!0;case"message":return V(T,A,P+1),!0;case"enum":return be(T,A),!0;case"export":case"local":return g<"2024"||(A=o(),A==="export"||A==="local")||A!=="message"&&A!=="enum"?!1:w(T,A,P);case"service":return Re(T,A,P+1),!0;case"extend":return gt(T,A,P),!0}return!1}function F(T,A,P){var M=n.line;if(T&&(typeof T.comment!="string"&&(T.comment=u()),T.filename=Qt.filename),l("{",!0)){for(var U;(U=o())!=="}";)A(U);l(";",!0)}else P&&P(),l(";"),T&&(typeof T.comment!="string"||r)&&(T.comment=u(M)||T.comment)}function V(T,A,P){if(P===void 0&&(P=0),P>Zt.nestingLimit)throw Error("max depth exceeded");if((A=o())===null||!$t.test(A))throw S(A,"type name");var M=new xf(A);F(M,function(J){if(!w(M,J,P))switch(J){case";":break;case"map":ne(M,J);break;case"required":if(g!=="proto2")throw S(J);case"repeated":H(M,J,void 0,P+1);break;case"optional":if(g==="proto3")H(M,"proto3_optional",void 0,P+1);else{if(g!=="proto2")throw S(J);H(M,"optional",void 0,P+1)}break;case"oneof":ve(M,J,P+1);break;case"extensions":j(M.extensions||(M.extensions=[]));break;case"reserved":j(M.reserved||(M.reserved=[]),!0);break;default:if(g==="proto2"||!It.test(J))throw S(J);s(J),H(M,"optional",void 0,P+1);break}}),T.add(M),T===v&&I.push(M)}function H(T,A,P,M){var U=o();if(U===null)throw S(U,"end of input");if(U==="group"){Z(T,A,P,M);return}for(;U.endsWith(".")||(a()||"").startsWith(".");){var J=o();if(J===null)throw S(J,"end of input");U+=J}if(!It.test(U))throw S(U,"type");var re=o();if(re===null)throw S(re,"end of input");if(!$t.test(re))throw S(re,"name");var oe=re;re=E(re),l("=");var ie=new ho(re,O(o()),U,A==="proto3_optional"?"optional":A,P);if(oe!==re&&(ie.protoName=oe),F(ie,function(Rt){if(Rt==="option")ee(ie,Rt),l(";");else throw S(Rt)},function(){qt(ie)}),A==="proto3_optional"){var Me=new _f("_"+re);ie.setOption("proto3_optional",!0),Me.add(ie),T.add(Me)}else T.add(ie);T===v&&I.push(ie)}function Z(T,A,P,M){if(M===void 0&&(M=0),M>Zt.nestingLimit)throw Error("max depth exceeded");if(g>=2023)throw S("group");var U=o();if(U===null||!$t.test(U))throw S(U,"name");var J=Zt.lcFirst(U);U===J&&(U=Zt.ucFirst(U)),l("=");var re=O(o()),oe=new xf(U);oe.group=!0;var ie=new ho(J,re,U,A,P);ie.filename=Qt.filename,F(oe,function(Oe){switch(Oe){case";":break;case"map":ne(oe);break;case"option":ee(oe,Oe),l(";");break;case"required":case"repeated":H(oe,Oe,void 0,M+1);break;case"optional":g==="proto3"?H(oe,"proto3_optional",void 0,M+1):H(oe,"optional",void 0,M+1);break;case"message":V(oe,Oe,M+1);break;case"enum":be(oe,Oe);break;case"reserved":j(oe.reserved||(oe.reserved=[]),!0);break;case"export":case"local":if(g<"2024")throw S(Oe);switch(Oe=o(),Oe){case"message":V(oe,Oe,M+1);break;case"enum":V(oe,Oe,M+1);break;default:throw S(Oe)}break;default:throw S(Oe)}}),T.add(oe).add(ie),T===v&&(I.push(oe),I.push(ie))}function ne(T){l("<");var A=o();if(Cg.mapKey[A]===void 0)throw S(A,"type");l(",");var P=o();if(!It.test(P))throw S(P,"type");l(">");var M=o();if(M===null||!$t.test(M))throw S(M,"name");l("=");var U=M;M=E(M);var J=new Sg(M,O(o()),A,P);U!==M&&(J.protoName=U),F(J,function(oe){if(oe==="option")ee(J,oe),l(";");else throw S(oe)},function(){qt(J)}),T.add(J)}function ve(T,A,P){if((A=o())===null||!$t.test(A))throw S(A,"name");var M=new _f(E(A));F(M,function(J){J==="option"?(ee(M,J),l(";")):(s(J),H(M,"optional",void 0,P))}),T.add(M)}function be(T,A){if((A=o())===null||!$t.test(A))throw S(A,"name");var P=new xg(A),M=[];F(P,function(re){switch(re){case";":break;case"option":ee(P,re),l(";");break;case"reserved":j(P.reserved||(P.reserved=[]),!0,zg,!0),P.reserved===void 0&&(P.reserved=[]);break;default:M.push(ge(re))}});for(var U=0;U<M.length;++U)P.add(M[U].name,M[U].id,M[U].comment,M[U].options);T.add(P),T===v&&I.push(P)}function ge(T){if(!$t.test(T))throw S(T,"name");l("=");var A=O(o(),!0),P={options:void 0};return P.getOption=function(M){return this.options[M]},P.setOption=function(M,U){Eg.prototype.setOption.call(P,M,U)},P.setParsedOption=function(){},F(P,function(U){if(U==="option")ee(P,U),l(";");else throw S(U)},function(){qt(P)}),{name:T,id:A,comment:P.comment,options:P.parsedOptions||P.options}}function ee(T,A){var P,M,U=!0;for(A==="option"&&(A=o());A!=="=";){if(A===null)throw S(A,"end of input");if(A==="("){var J=o();l(")"),A="("+J+")"}if(U){if(U=!1,A.includes(".")&&!A.includes("(")){var re=A.split(".");P=re[0]+".",A=re[1];continue}P=A}else M=M?M+=A:A;A=o()}var oe=M?P.concat(M):P,ie=ce(T,oe);M=M&&M[0]==="."?M.slice(1):M,P=P&&P[P.length-1]==="."?P.slice(0,-1):P,mt(T,P,ie,M)}function ce(T,A,P){if(P===void 0&&(P=0),P>Zt.recursionLimit)throw Error("max depth exceeded");if(l("{",!0)){for(var M={};!l("}",!0);){de=o();var U;if(de===null)throw S(de,"end of input");if(de==="["){de=o();var J=de===null?-1:de.lastIndexOf("/");if(de===null||!It.test(J<0?de:de.slice(J+1)))throw S(de,"name");U="["+de+"]",l("]")}else{if(!$t.test(de))throw S(de,"name");U=de}var re;if(l(":",!0),a()==="{")re=ce(T,A+"."+U,P+1);else if(a()==="["){re=[];var oe,ie;if(l("[",!0)&&!l("]",!0)){do ie=a()==="{",oe=ie?ce(T,A+"."+U,P+1):L(!0),re.push(oe);while(l(",",!0));l("]"),typeof oe<"u"&&(ie||Se(T,A+"."+U,oe))}}else re=L(!0),Se(T,A+"."+U,re);var Me=Object.prototype.hasOwnProperty.call(M,U)?M[U]:void 0;Me&&(re=[].concat(Me).concat(re)),U!=="__proto__"&&(M[U]=re),l(",",!0),l(";",!0)}return M}var Oe=A==="default"&&T instanceof ho&&Pg.test(T.type)?_(o(),!Mg.test(T.type)):L(!0);return Se(T,A,Oe),Oe}function Se(T,A,P){if(v===T&&/^features\./.test(A)){C[A]=P;return}A==="json_name"&&T instanceof ho&&(T.jsonName=P),T.setOption&&T.setOption(A,P)}function mt(T,A,P,M){T.setParsedOption&&T.setParsedOption(A,P,M)}function qt(T){if(l("[",!0)){do ee(T,"option");while(l(",",!0));l("]")}return T}function Re(T,A,P){if(P===void 0&&(P=0),P>Zt.recursionLimit)throw Error("max depth exceeded");if((A=o())===null||!$t.test(A))throw S(A,"service name");var M=new _g(A);F(M,function(J){if(!w(M,J,P)&&J!==";")if(J==="rpc")ut(M,J);else throw S(J)}),T.add(M),T===v&&I.push(M)}function ut(T,A){var P=u(),M=A;if(!$t.test(A=o()))throw S(A,"name");var U=A,J,re,oe,ie;if(l("("),l("stream",!0)&&(re=!0),!It.test(A=o())||(J=A,l(")"),l("returns"),l("("),l("stream",!0)&&(ie=!0),!It.test(A=o())))throw S(A);oe=A,l(")");var Me=new Ig(U,M,J,oe,re,ie);Me.comment=P,F(Me,function(Rt){if(Rt!==";")if(Rt==="option")ee(Me,Rt),l(";");else throw S(Rt)}),T.add(Me)}function gt(T,A,P){if((A=o())===null||!It.test(A))throw S(A,"reference");var M=A;F(null,function(J){switch(J){case"required":case"repeated":H(T,J,M,P+1);break;case"optional":g==="proto3"?H(T,"proto3_optional",M,P+1):H(T,"optional",M,P+1);break;default:if(g==="proto2"||!It.test(J))throw S(J);s(J),H(T,"optional",M,P+1);break}})}for(var de;(de=o())!==null;)switch(de){case";":break;case"package":if(!c)throw S(de);y();break;case"import":N();break;case"syntax":if(!c)throw S(de);x();break;case"edition":if(!c)throw S(de);d();break;case"option":ee(v,de),l(";",!0);break;default:if(w(v,de,0)){c=!1;continue}throw S(de)}return D(),Qt.filename=null,{package:f,imports:h,weakImports:m,root:e}}});var Af=te((fw,kf)=>{"use strict";kf.exports=Et;var $g=/\/|\./;function Et(t,e){$g.test(t)||(t="google/protobuf/"+t+".proto",e={nested:{google:{nested:{protobuf:{nested:e}}}}}),Et[t]=e}Et("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var Cf;Et("duration",{Duration:Cf={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});Et("timestamp",{Timestamp:Cf});Et("empty",{Empty:{fields:{}}});Et("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1,protoName:"null_value"},numberValue:{type:"double",id:2,protoName:"number_value"},stringValue:{type:"string",id:3,protoName:"string_value"},boolValue:{type:"bool",id:4,protoName:"bool_value"},structValue:{type:"Struct",id:5,protoName:"struct_value"},listValue:{type:"ListValue",id:6,protoName:"list_value"}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}});Et("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}});Et("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}});Et.get=function(e){return Et[e]||null}});var Rf=te((Lt,Tf)=>{"use strict";Lt=Tf.exports=yf();Lt.build="full";Lt.tokenize=ya();Lt.parse=Ef();Lt.common=Af();Lt.Root._configure(Lt.Type,Lt.parse,Lt.common)});var Nf=te((dw,Of)=>{"use strict";Of.exports=Rf()});import{existsSync as vp,readFileSync as bp,realpathSync as hv}from"node:fs";import{relative as pv}from"node:path";import{Worker as H1}from"node:worker_threads";import{existsSync as Y1,mkdirSync as X1,readFileSync as Ol,writeFileSync as W1}from"node:fs";import{basename as K1,dirname as J1}from"node:path";import{existsSync as pn,readFileSync as _0}from"node:fs";import{randomUUID as mh}from"node:crypto";import{isAbsolute as jl,win32 as Vl}from"node:path";function _n(t,e=!1){let i=String(t??"").trim().replaceAll("\\","/");if(e&&(!i||i==="."))return"";if(!i||jl(i)||Vl.isAbsolute(i)||i.split("/").some(r=>!r||r==="."||r===".."||/[<>:"|?*\x00-\x1f]/.test(r)||/[. ]$/.test(r)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(r)))throw new Error("\u811A\u672C\u76EE\u5F55/\u8DEF\u5F84\u5FC5\u987B\u662F\u6709\u6548\u7684\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B .. \u6216 Windows \u7279\u6B8A\u6587\u4EF6\u540D");return i}function Mr(t){if(t==null)return null;if(t.version!==1)throw new Error("unsupported scriptSync version");let e=String(t.clientImportRoot||"").trim();if(!jl(e)&&!Vl.isAbsolute(e))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:_n(t.workspaceDir,!0),clientImportRoot:e,clientSubdir:_n(t.clientSubdir,!0)}}import{basename as kr,dirname as I0,isAbsolute as E0,join as gh,resolve as yh}from"node:path";var Ul="https://oss.070077.xyz/prefabs/",Fr="prefab-v1",Bp=[[10003004,10003004],[10005001,10005142],[10006001,10006002],[10007002,10007002],[10008001,10008001],[10009001,10009011],[20001001,20001074],[20001076,20001121],[20001123,20001156],[20001158,20001302],[20001304,20001568],[20001570,20001999],[20002001,20002755],[20002757,20002999],[20003001,20003455],[30001001,30001016],[30002001,30002017],[30003001,30003011],[30004001,30004001],[30005001,30005020],[30006001,30006026],[30007001,30007013],[30008001,30008011]];function In(t){return!Number.isSafeInteger(t)||!Bp.some(([e,i])=>t>=e&&t<=i)?null:t===10003004||t===10008001?128:256}var En="https://oss.070077.xyz/images/",os="sprite-v1",Cn="/qxqy-assets/",jp=[[100001,100006],[100101,100213],[101001,101018],[101020,101028],[101030,101046],[101048,101048],[101050,101054],[101056,101080],[102001,102052],[103001,103148],[104001,104010],[105001,105140],[105142,105219],[105221,105317],[106001,106047],[106049,106096],[107001,107007],[107010,107020],[107031,107092],[107094,107180],[107183,107201],[107203,107205],[107207,107228],[107231,107278],[107280,107402],[108001,108017],[108019,108020],[109001,109031],[109033,109034],[109036,109075],[110001,110053],[111001,111139],[112001,112042]];function st(t){return t==null||t===""?"StaticReference":typeof t=="string"?t:typeof t.Name=="string"?t.Name:"Unknown"}function kn(t,e){return`${st(e)}:${t}`}function Hl(t,e){return st(e)==="StaticReference"&&ni(t,e)}function ni(t,e){let i=st(e);return i==="Prefab"?In(t)!==null:i==="StaticReference"&&Number.isSafeInteger(t)&&t>100006&&jp.some(([r,n])=>t>=r&&t<=n)}var An="7.1.0",qe=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),Ee=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"}}),Tn="pc-16-9",Ze=2,Ji=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),Zi=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"}),Rn=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),Yl=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}),Vp=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"});function Qi(t,e){return st(e)==="StaticReference"&&Vp[t]||(ni(t,e)?"sprite":"missing")}var Xl=50888,Dr=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function er(t,e="$",i=new Set){if(t===void 0)throw new Error(`undefined at ${e}`);if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`non-finite number at ${e}`);if(typeof t=="bigint"||typeof t=="function"||typeof t=="symbol")throw new Error(`non-JSON value at ${e}`);if(!(t===null||typeof t!="object")){if(i.has(t))throw new Error(`circular value at ${e}`);if(i.add(t),Array.isArray(t))t.forEach((r,n)=>er(r,`${e}[${n}]`,i));else for(let[r,n]of Object.entries(t))er(n,`${e}.${r}`,i);i.delete(t)}}function se(t){return er(t),JSON.parse(JSON.stringify(t))}function Wl(t,e="$"){er(t,e)}function Kl(t){return Ee[t]||Ee[Tn]}function zr(t,e=0,i=0){return!t||typeof t!="object"?{x:e,y:i}:{x:Number(t.x??e),y:Number(t.y??i)}}function Up(t){return!t||typeof t!="object"?{x:1,y:1,z:1}:{x:Number(t.x??1),y:Number(t.y??1),z:Number(t.z??1)}}function Hp(t){return!t||typeof t!="object"?{x:0,y:0,z:0}:{x:Number(t.x??0),y:Number(t.y??0),z:Number(t.z??0)}}function On({layout:t="center",size:e=[100,40],offset:i=[0,0]}={}){return t==="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(e[0]??0),y:Number(e[1]??0)},pivot:{x:.5,y:.5}}}function Nt(t){let e=t||On();return{scale:Up(e.scale),rotation:Hp(e.rotation),anchorMin:zr(e.anchorMin??e.anchor_min,.5,.5),anchorMax:zr(e.anchorMax??e.anchor_max,.5,.5),offset:zr(e.offset,0,0),size:zr(e.size,0,0),pivot:zr(e.pivot,.5,.5)}}function je(t,e=0){let i=Number(t);return Number.isFinite(i)?i:e}function Vt(t,e){let i=t.width,r=t.height,n=t.left,o=t.bottom,s=e.anchorMin||{x:e.anchorMinX,y:e.anchorMinY},a=e.anchorMax||{x:e.anchorMaxX,y:e.anchorMaxY},l=e.offset||{x:e.anchoredPositionX,y:e.anchoredPositionY},u=e.size||{x:e.sizeDeltaX,y:e.sizeDeltaY},c=e.pivot||{x:e.pivotX,y:e.pivotY},f=je(s?.x,.5)*i,h=je(s?.y,.5)*r,m=je(a?.x,.5)*i,g=je(a?.y,.5)*r,v=je(u?.x),I=je(u?.y),C=je(c?.x,.5),E=je(c?.y,.5),D=m-f+v,S=g-h+I,z=n+f+je(l?.x)-v*C,L=o+h+je(l?.y)-I*E;return{left:z,bottom:L,width:D,height:S,right:z+D,top:L+S,centerX:z+D/2,centerY:L+S/2}}function tr(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function Yp(t,e){return{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,tx:t.a*e.tx+t.c*e.ty+t.tx,ty:t.b*e.tx+t.d*e.ty+t.ty}}function tt(t,e,i){return{x:t.a*e+t.c*i+t.tx,y:t.b*e+t.d*i+t.ty}}function Ut(t){let e=t.a*t.d-t.b*t.c;return!Number.isFinite(e)||Math.abs(e)<1e-8?null:{a:t.d/e,b:-t.b/e,c:-t.c/e,d:t.a/e,tx:(t.c*t.ty-t.d*t.tx)/e,ty:(t.b*t.tx-t.a*t.ty)/e}}function ss(t,e){let i=e.rotation||{x:e.localRotationX,y:e.localRotationY,z:e.localRotationZ},r=e.scale||{x:e.localScaleX,y:e.localScaleY},n=e.pivot||{x:e.pivotX,y:e.pivotY},o=je(i?.z)*Math.PI/180,s=Math.cos(o),a=Math.sin(o),l=je(i?.x)*Math.PI/180,u=je(i?.y)*Math.PI/180,c=Math.cos(l),f=Math.sin(l),h=Math.cos(u),m=Math.sin(u),g=j=>Math.abs(j)<1e-12?0:j,v=je(r?.x,1),I=je(r?.y,1),C=t.left+t.width*je(n?.x,.5),E=t.bottom+t.height*je(n?.y,.5),D=g(h*s+m*f*a)*v,S=g(c*a)*v,z=g(-h*a+m*f*s)*I,L=g(c*s)*I;return{a:D,b:S,c:z,d:L,tx:C-D*C-z*E,ty:E-S*C-L*E}}function $r(t,e,i){return Yp(t||tr(),ss(e,i))}function Jl(t,e){let i=tt(e,t.centerX,t.centerY),r=Math.abs(t.width*Math.hypot(e.a,e.b)),n=Math.abs(t.height*Math.hypot(e.c,e.d));return{left:i.x-r/2,bottom:i.y-n/2,width:r,height:n,centerX:i.x,centerY:i.y,rotationZ:Math.atan2(e.b,e.a)*180/Math.PI}}function Qe(t){let e=typeof t=="string"?Kl(t):t;return{left:0,bottom:0,width:e.width,height:e.height,right:e.width,top:e.height,centerX:e.width/2,centerY:e.height/2}}function as(t){return{posX:t.centerX,posY:t.centerY,width:t.width,height:t.height}}function ki(t,e,i){let r=Nt(e),n=t.width,o=t.height,s=r.anchorMin.x*n,a=r.anchorMin.y*o,l=r.anchorMax.x*n,u=r.anchorMax.y*o,c=Number(i.width),f=Number(i.height),h=Number(i.posX),m=Number(i.posY),g=h-c/2,v=m-f/2;return r.size={x:c-(l-s),y:f-(u-a)},r.offset={x:g-t.left-s+r.size.x*r.pivot.x,y:v-t.bottom-a+r.size.y*r.pivot.y},r}function Zl(t,e){let i=Nt(t),n={"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]]}[e];return n&&(i.anchorMin={x:n[0][0],y:n[0][1]},i.anchorMax={x:n[1][0],y:n[1][1]},i.pivot={x:n[2][0],y:n[2][1]}),i}function Ql(t){let e=Nt(t),i=(r,n)=>Math.abs(r-n)<1e-4;if(i(e.anchorMin.x,0)&&i(e.anchorMin.y,0)&&i(e.anchorMax.x,1)&&i(e.anchorMax.y,1))return"stretch";if(i(e.anchorMin.x,e.anchorMax.x)&&i(e.anchorMin.y,e.anchorMax.y)){let r=e.anchorMin.x,n=e.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 s of o)if(i(r,s[0])&&i(n,s[1]))return s[2]}return"custom"}function Ai(t){return Kl(t).platform}function eu(t){let e={};for(let i of qe)e[i]=t(i);return e}var Xp={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function tu(t,e){for(let[i,r]of Object.entries(Xp))for(let n of r)if(!Number.isFinite(t?.[i]?.[n]))throw new Error(`${e}.${i}.${n} must be a finite number`)}function oi(t,e="transformByPlatform"){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e}: \u9700\u8981\u5B8C\u6574\u7684\u56DB\u5E73\u53F0\u5E03\u5C40`);for(let i of Object.keys(t))if(!qe.includes(i))throw new Error(`${e}: unknown platform ${i}`);for(let i of qe)tu(t[i],`${e}.${i}`)}function Ti(t){if(Object.hasOwn(t,"transformByCanvas"))throw new Error(`${t.name||t.id||"\u63A7\u4EF6"}: \u4E0D\u518D\u652F\u6301 transformByCanvas\uFF1B\u8BF7\u4F7F\u7528\u56DB\u5E73\u53F0 transformByPlatform \u5E03\u5C40`);oi(t.transformByPlatform,`${t.name||t.id||"\u63A7\u4EF6"}.transformByPlatform`)}function Ri(t,e){if(!qe.includes(e))throw new Error(`unknown platform ${e}`);return tu(t?.[e],`transformByPlatform.${e}`),Nt(t[e])}var Wp=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"}]),Kp=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:"imageSlotType",label:"\u56FE\u7247\u7C7B\u578B\u539F\u59CB\u503C",type:"number",defaultValue:0,wire:"ImageSlotConfig.imageType"},{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 iu(t){return[...Wp,...Kp[t]||[]]}function ru(t,e){return iu(t).find(i=>i.key===e)||null}function ls(t,e){if(!t)throw new Error("unknown raw GIA field");if(t.type==="string")return String(e??"");let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t.wire} must be a finite number`);return Math.trunc(i)}function nu(t,e={}){let i={};for(let r of iu(t)){let n=Object.hasOwn(e||{},r.key)?e[r.key]:r.defaultValue;i[r.key]=ls(r,n)}if(t==="reference")for(let r of["templateRefSlotBase64","templateRefOuterBase64"]){if(!Object.hasOwn(e||{},r))continue;let n=e[r];if(typeof n!="string"||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(n))throw new Error(`${r} must be base64`);n&&(i[r]=n)}return i}function vt(t){let e=Number(t);return Number.isSafeInteger(e)&&e>0&&e<=2147483647}function us(t,e){if(t){e(t);for(let i of t.children||[])us(i,e)}}function ir(t,e=new Set,{skipServerContainer:i=!1}={}){return us(t,r=>{i&&r.kind==="server-container"||vt(r.guid)&&e.add(Number(r.guid))}),e}function si(t,e=1073741850){let i=Number.isSafeInteger(e)&&e>0?e:1073741850;i<1073741850&&(i=1073741850);for(let r of t)vt(r)&&r>=i&&(i=Number(r)+1);for(;t.has(i);)i+=1;if(i>2147483647)throw new Error("GUID space exhausted");return i}function ou(t,e=new Set,{skipServerContainer:i=!1}={}){let r=[];us(t,n=>{if(i&&n.kind==="server-container")return;let o=Number(n.guid);if(vt(o)&&!e.has(o)){e.add(o),n.guid=o;return}r.push(n)});for(let n of r){let o=si(e);n.guid=o,e.add(o)}return e}function ct(t){return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Ht(t,{warnings:e=[]}={}){if(t.meta?.assetType!=="client-control-template")return;if(t.meta.giaAssetIndexSchemaVersion>1)throw new Error(`\u4E0D\u652F\u6301\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7\u7248\u672C ${t.meta.giaAssetIndexSchemaVersion}`);let i=[],r=g=>{g.kind!=="server-container"&&i.push(g);for(let v of g.children||[])r(v)};r(t.root);let n=new Map,o=new Map;for(let g of i){if(!ct(g.giaInfoIndex))continue;let v=n.get(g.giaInfoIndex)||[];v.push(g),n.set(g.giaInfoIndex,v);let I=o.get(g.kind)||new Set;I.add(g.giaInfoIndex),o.set(g.kind,I)}let s=(t.root.children||[]).filter(g=>g.kind!=="server-container"),a=new Set(s),l=s.some((g,v)=>ct(g.giaInfoIndex)&&s.slice(0,v).some(I=>I.giaInfoIndex===g.giaInfoIndex)),u=!t.meta.giaAssetIndexSchemaVersion&&l&&i.every(g=>g.giaInfoIndexSource!=="authoring")&&[...o.values()].every(g=>g.size===1)&&[...n.values()].every(g=>g.every(v=>v.kind===g[0].kind)),c=new Set;if(u)for(let g of n.values()){let v=g.find(I=>a.has(I))||g[0];for(let I of g)I!==v&&c.add(I)}let f=new Map,h=Number.isSafeInteger(t.meta.giaNextAssetIndex)&&t.meta.giaNextAssetIndex>=2?t.meta.giaNextAssetIndex:2;for(let g of i){if(!ct(g.giaInfoIndex)||(h=Math.max(h,g.giaInfoIndex+1),c.has(g)))continue;let v=f.get(g.giaInfoIndex);if(v&&(v.giaInfoIndexSource==="authoring"||g.giaInfoIndexSource==="authoring"))throw new Error(`\u65B0\u5EFA\u8D44\u4EA7\u7F16\u53F7 ${g.giaInfoIndex} \u91CD\u590D\uFF1A${v.name} / ${g.name}`);f.set(g.giaInfoIndex,g)}u&&(h=Math.max(h,13));let m=u?[...s,...i.filter(g=>!a.has(g))].filter(g=>c.has(g)||!ct(g.giaInfoIndex)):i.filter(g=>!ct(g.giaInfoIndex));if(m.length&&h+m.length-1>2147483647)throw new Error("\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7\u7A7A\u95F4\u5DF2\u8017\u5C3D");for(let g of m)g.giaInfoIndex=h++,g.giaInfoIndexSource="authoring";t.meta.giaNextAssetIndex=h,t.meta.giaAssetIndexSchemaVersion=1,c.size&&e.push(`\u65E7\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7\u81EA\u52A8\u8FC1\u79FB\uFF1A\u4FEE\u590D ${c.size} \u6761\u6309\u63A7\u4EF6\u7C7B\u578B\u590D\u7528\u7684\u7F16\u53F7\uFF1BGUID\u3001Lua \u5F15\u7528\u548C\u63A7\u4EF6\u5C5E\u6027\u4FDD\u6301\u4E0D\u53D8\u3002`)}var cs=1;function fs(t="n"){let e=`${t}${cs}`;return cs+=1,e}function Nn(t=1){cs=t}function ds(t,{isRootContainer:e=!1}={}){if(t==="server-container"||t==="fullscreen"||t==="container"&&e)return On({layout:"stretch"});let i=Yl[t]||[80,80];return On({layout:"center",size:i})}function Jp(t,e){return eu(()=>ds(t,e))}function Zp(t){oi(t);let e={};for(let i of qe)e[i]=Ri(t,i);return e}function we(t,e={}){if(!Zi[t])throw new Error(`unknown kind: ${t}`);Object.hasOwn(e,"transformByCanvas")&&Ti(e);let i=e.isRootContainer===!0,r=e.id||fs(t==="server-container"?"sc":"n"),n=Object.hasOwn(e,"transformByPlatform")?Zp(e.transformByPlatform):Jp(t,{isRootContainer:i}),o={id:r,kind:t,name:e.name||Zi[t],guid:e.guid??0,giaRelatedGuids:Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(s=>Number.isSafeInteger(Number(s))&&Number(s)>0).map(Number):[],...ct(Number(e.giaInfoIndex))?{giaInfoIndex:Number(e.giaInfoIndex),giaInfoIndexSource:e.giaInfoIndexSource==="authoring"?"authoring":"imported"}:{},active:e.active!==!1,visible:e.visible!==!1,canControllerFocus:e.canControllerFocus??e.giaRaw?.footerField505===1,syncAllDevices:e.syncAllDevices!==!1,giaRaw:nu(t,e.giaRaw),transformByPlatform:n,children:[],scriptMappingIds:Array.isArray(e.scriptMappingIds)?e.scriptMappingIds.filter(s=>Number.isSafeInteger(Number(s))&&Number(s)>0).map(Number):[]};if(t==="container"&&(o.isolateNavigation=e.isolateNavigation===!0,o.disableKeyEventPassthrough=e.disableKeyEventPassthrough===!0,o.disableCursorEventPassthrough=e.disableCursorEventPassthrough===!0,o.showCursor=e.showCursor===!0),(t==="textbox"||t==="textwindow")&&(o.fontSize=e.fontSize??20,o.adaptiveFontSize=e.adaptiveFontSize===!0,o.minimumFontSize=e.minimumFontSize??20,o.fontColor=e.fontColor??Dr.font,o.bgColor=e.bgColor??Dr.bg,o.enableOutline=e.enableOutline!==!1,o.outlineColor=e.outlineColor??Dr.outline,o.horizontalAlignment=e.horizontalAlignment||"Left",o.verticalAlignment=e.verticalAlignment||"Top",Number.isInteger(e.giaRaw?.textVerticalAlign)&&![0,1,2].includes(e.giaRaw.textVerticalAlign)&&(o.giaRaw.textVerticalAlign=e.giaRaw.textVerticalAlign),o.text=e.text??"",Object.hasOwn(e.giaRaw||{},"textAlign")||(o.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o.horizontalAlignment]??o.giaRaw.textAlign),t==="textwindow"&&(o.interactable=e.interactable!==!1,o.showScrollBar=e.showScrollBar!==!1)),t==="image"&&(o.imageSource=e.imageSource||"StaticReference",o.imageType=["Basic","Stretch"].includes(e.imageType)?e.imageType:null,o.imageId=e.imageId??100001,o.imageColor=e.imageColor??Dr.image,o.enableMask=e.enableMask===!0,o.enableSoftEdge=e.enableSoftEdge===!0,o.softEdgeMode=e.softEdgeMode||"Percentage",o.softEdgeWidthX=e.softEdgeWidthX??8,o.softEdgeWidthY=e.softEdgeWidthY??8,o.horizontalSoftRange=e.horizontalSoftRange??85,o.verticalSoftRange=e.verticalSoftRange??85,o.enableFill=e.enableFill===!0,o.fillType=e.fillType||"Horizontal",o.fillHorizontalType=e.fillHorizontalType||"Left",o.fillVerticalType=e.fillVerticalType||"Bottom",o.fillRadial90Type=e.fillRadial90Type||"BottomLeft",o.fillRadialType=e.fillRadialType||"Bottom",o.fillAmount=e.fillAmount??1,o.reverseMaskArea=e.reverseMaskArea===!0||e.reverseMask===!0,Object.hasOwn(e.giaRaw||{},"imageFillType")||(o.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o.fillType]??o.giaRaw.imageFillType)),t==="button"&&(o.raycastTarget=e.raycastTarget!==!1,o.interactable=e.interactable!==!1,o.clickAudioId=e.clickAudioId??Xl,o.unavailableChildId=e.unavailableChildId??null,o.hoverChildId=e.hoverChildId??null,o.pressedChildId=e.pressedChildId??null,o.selectedChildId=e.selectedChildId??null),t==="cursor"&&(o.raycastTarget=e.raycastTarget??e.giaRaw?.cursorField501!==0),t==="reference"&&(o.referencedPrefabId=e.referencedPrefabId??e.giaRaw?.templateRefSlot??null,Object.hasOwn(e.giaRaw||{},"templateRefSlot")||(o.giaRaw.templateRefSlot=String(o.referencedPrefabId??""))),t==="grid"&&(o.itemPrefabId=e.itemPrefabId??null,o.raycastTarget=e.raycastTarget!==!1,o.interactable=e.interactable!==!1,o.showScrollBar=e.showScrollBar!==!1,o.scrollDirection=e.scrollDirection||"Vertical",o.layoutConstraint=e.layoutConstraint||"AutoWrap",o.layoutConstraintFixedCount=e.layoutConstraintFixedCount??null,o.cellSizeX=e.cellSizeX??50,o.cellSizeY=e.cellSizeY??50,o.spacingX=e.spacingX??8,o.spacingY=e.spacingY??8,o.padding1X=e.padding1X??20,o.padding1Y=e.padding1Y??20,o.padding2X=e.padding2X??20,o.padding2Y=e.padding2Y??20,o.previewCount=e.previewCount??e.giaRaw?.gridField511??5,Object.hasOwn(e.giaRaw||{},"gridField511")||(o.giaRaw.gridField511=Math.trunc(o.previewCount))),t==="keyhint"&&(o.keyboardKeyCode=e.keyboardKeyCode??e.giaRaw?.keyHintField502??null,o.controllerKeyCode=e.controllerKeyCode??e.giaRaw?.keyHintField501??null,Object.hasOwn(e.giaRaw||{},"keyHintField502")||(o.giaRaw.keyHintField502=Math.trunc(o.keyboardKeyCode??1)),Object.hasOwn(e.giaRaw||{},"keyHintField501")||(o.giaRaw.keyHintField501=Math.trunc(o.controllerKeyCode??1))),t==="animation"||t==="fullscreen"){let s=t==="animation"?e.giaRaw?.effectSlot:e.giaRaw?.fullscreenEffectSlot;o.animationId=e.animationId??s??null,o.playSoundEffect=e.playSoundEffect??null,t==="animation"&&(o.layer=e.layer??null);let a=t==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(e.giaRaw||{},a)||(o.giaRaw[a]=String(o.animationId??""))}if(e.children)for(let s of e.children)o.children.push(s);return o}function Oi(){Nn(1);let t=we("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),e=we("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=we("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),r=we("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),n=we("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),o=we("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),s=we("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),a=we("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),l=we("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),u=we("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),c=we("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),f=we("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),h=(m,g,v)=>{for(let I of Object.values(m.transformByPlatform))I.offset={x:g,y:v}};return h(i,-300,250),h(r,-300,140),h(n,-300,30),h(o,-300,-100),h(s,0,0),h(a,300,250),h(l,300,140),h(u,300,30),h(c,300,-100),e.children.push(i,r,n,o,s,a,l,u,c,f),t.children.push(e),Nn(12),ou(t),{version:1,layoutSchemaVersion:Ze,meta:{name:"\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"authoring",sourceFile:""},canvasId:"pc-16-9",selectedId:"n2",root:t}}function rr(){Nn(1);let t=we("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),e=we("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=we("textbox",{id:"n2",guid:1073742101,name:"\u6A21\u677F\u6807\u9898",text:"\u5BA2\u6237\u7AEF\u6A21\u677F\u5DF2\u5B9E\u4F8B\u5316",fontSize:28,horizontalAlignment:"Middle"}),r=we("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),n=we("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),o=we("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),s=(u,c,f)=>{for(let h of Object.values(u.transformByPlatform))h.offset={x:c,y:f}};((u,c,f)=>{for(let h of Object.values(u.transformByPlatform))h.size={x:c,y:f}})(e,520,320),s(i,0,110),s(r,0,0),s(n,0,-110),n.children.push(o),e.children.push(i,r,n),t.children.push(e),Nn(6);let l={version:1,layoutSchemaVersion:Ze,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:An,giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:t};return Ht(l),l}function Ae(t,e,i=null){e(t,i);for(let r of t.children||[])Ae(r,e,t)}function Ve(t,e){let i=null;return Ae(t,r=>{r.id===e&&(i=r)}),i}function hs(t,e="n"){let i=fs(e);for(;Ve(t,i);)i=fs(e);return i}function ai(t,e){let i=null;return Ae(t,(r,n)=>{r.id===e&&(i=n)}),i}function ps(t){let e=t.root||t;return e.kind==="container"?e:(e.children||[]).find(i=>i.kind==="container")||(e.children||[])[0]||e}function Lr(t){if(t.meta?.assetType!=="client-control-template")return ps(t);let e=Ve(t.root,t.selectedId);if(!e||e.kind==="server-container")return t.root.children?.[0]||t.root;let i=ai(t.root,e.id);for(;i&&i.kind!=="server-container";)e=i,i=ai(t.root,e.id);return e}function ms(t){Ti(t);let e={id:t.id,name:t.name,guid:t.guid,giaRelatedGuids:t.giaRelatedGuids,giaInfoIndex:t.giaInfoIndex,giaInfoIndexSource:t.giaInfoIndexSource,scriptMappingIds:t.scriptMappingIds,giaRaw:t.giaRaw,active:t.active,visible:t.visible,canControllerFocus:t.canControllerFocus,syncAllDevices:t.syncAllDevices,transformByPlatform:t.transformByPlatform};t.kind==="container"&&(e.isolateNavigation=t.isolateNavigation,e.disableKeyEventPassthrough=t.disableKeyEventPassthrough,e.disableCursorEventPassthrough=t.disableCursorEventPassthrough,e.showCursor=t.showCursor),(t.kind==="textbox"||t.kind==="textwindow")&&(e.fontSize=t.fontSize,e.adaptiveFontSize=t.adaptiveFontSize,e.minimumFontSize=t.minimumFontSize,e.fontColor=t.fontColor,e.bgColor=t.bgColor,e.enableOutline=t.enableOutline,e.outlineColor=t.outlineColor,e.horizontalAlignment=t.horizontalAlignment,e.verticalAlignment=t.verticalAlignment,e.text=t.text??"",t.kind==="textwindow"&&(e.interactable=t.interactable,e.showScrollBar=t.showScrollBar)),t.kind==="image"&&(e.imageSource=t.imageSource,e.imageType=t.imageType,e.imageId=t.imageId,e.imageColor=t.imageColor,e.enableMask=t.enableMask,e.enableSoftEdge=t.enableSoftEdge,e.softEdgeMode=t.softEdgeMode,e.softEdgeWidthX=t.softEdgeWidthX,e.softEdgeWidthY=t.softEdgeWidthY,e.horizontalSoftRange=t.horizontalSoftRange,e.verticalSoftRange=t.verticalSoftRange,e.enableFill=t.enableFill,e.fillType=t.fillType,e.fillHorizontalType=t.fillHorizontalType,e.fillVerticalType=t.fillVerticalType,e.fillRadial90Type=t.fillRadial90Type,e.fillRadialType=t.fillRadialType,e.fillAmount=t.fillAmount,e.reverseMaskArea=t.reverseMaskArea??t.reverseMask),t.kind==="button"&&(e.raycastTarget=t.raycastTarget,e.interactable=t.interactable,e.clickAudioId=t.clickAudioId,e.unavailableChildId=t.unavailableChildId??null,e.hoverChildId=t.hoverChildId??null,e.pressedChildId=t.pressedChildId??null,e.selectedChildId=t.selectedChildId??null),t.kind==="cursor"&&(e.raycastTarget=t.raycastTarget),t.kind==="reference"&&(e.referencedPrefabId=t.referencedPrefabId??null),t.kind==="grid"&&(e.itemPrefabId=t.itemPrefabId??null,e.raycastTarget=t.raycastTarget,e.interactable=t.interactable,e.showScrollBar=t.showScrollBar,e.scrollDirection=t.scrollDirection,e.layoutConstraint=t.layoutConstraint,e.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,e.cellSizeX=t.cellSizeX,e.cellSizeY=t.cellSizeY,e.spacingX=t.spacingX,e.spacingY=t.spacingY,e.padding1X=t.padding1X,e.padding1Y=t.padding1Y,e.padding2X=t.padding2X,e.padding2Y=t.padding2Y,e.previewCount=t.previewCount),t.kind==="keyhint"&&(e.keyboardKeyCode=t.keyboardKeyCode??null,e.controllerKeyCode=t.controllerKeyCode??null),(t.kind==="animation"||t.kind==="fullscreen")&&(e.animationId=t.animationId??null,e.playSoundEffect=t.playSoundEffect??null,t.kind==="animation"&&(e.layer=t.layer??null)),e.isRootContainer=t.kind==="container"&&Qp(t.transformByPlatform);let i=we(t.kind,e);return i.children=(t.children||[]).map(r=>ms(r)),i}function Qp(t){let e=t&&(t.KEYBOARD||Object.values(t)[0]);return e?Math.abs(e.anchorMin?.x??.5)<1e-4&&Math.abs(e.anchorMin?.y??.5)<1e-4&&Math.abs((e.anchorMax?.x??.5)-1)<1e-4&&Math.abs((e.anchorMax?.y??.5)-1)<1e-4:!1}function su(t,e,i={}){if(t.kind==="server-container"&&e!=="container")throw new Error("server container only accepts container nodes");let r=we(e,i);return t.children.push(r),r}function au(t,e){if(t.id===e)throw new Error("cannot remove root");let i=ai(t,e);if(!i)return!1;let r=i.children.findIndex(n=>n.id===e);return r<0?!1:(i.children.splice(r,1),!0)}var lu=1e-4;function em(t,e){return Math.abs(t.anchorMax[e]-t.anchorMin[e])>lu&&Math.abs(t.size[e])<=lu}function tm(t,e,i){if(!(e.width>0)||!(e.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 r=Vt(e,t),n=(r.centerX-e.left)/e.width,o=(r.centerY-e.bottom)/e.height,s=ki(i,t,{posX:i.left+n*i.width,posY:i.bottom+o*i.height,width:r.width,height:r.height});for(let a of["x","y"])em(t,a)&&(s.offset[a]=t.offset[a],s.size[a]=t.size[a]);return s}function uu({transformByPlatform:t,source:e,canvasId:i,syncAllDevices:r,sourceParentBox:n=Qe(i),targetParentBoxByPlatform:o={}}){oi(t);let s=Ai(i),a={};for(let l of qe)l===s?a[l]=Nt(e):r!==!1?a[l]=tm(e,n,o[l]||Qe(Ji[l])):a[l]=Ri(t,l);return oi(a),a}function li(t,e){return Ri(t,Ai(e))}import{createCanvas as bm}from"@napi-rs/canvas";import{existsSync as cm,openSync as fm,closeSync as dm,fstatSync as hm,readFileSync as pm}from"node:fs";import{extname as mm,isAbsolute as gm}from"node:path";import{createHash as ym}from"node:crypto";import{workerData as Fn}from"node:worker_threads";import{GlobalFonts as pu}from"@napi-rs/canvas";var cu='"Microsoft YaHei UI","Microsoft YaHei","HarmonyOS Sans SC","Noto Sans CJK SC",sans-serif',nr="/qxqy-font";var gs=t=>`QxqyLocal_${t}`,fu=t=>t?`"${gs(t)}",${cu}`:cu;import{existsSync as im,mkdirSync as rm,readFileSync as nm,renameSync as om,rmSync as sm,writeFileSync as am}from"node:fs";import{randomUUID as lm}from"node:crypto";import{homedir as ys}from"node:os";import{dirname as um,join as Pn,win32 as Mn}from"node:path";function vs(t=process.platform,e=process.env){if(t!=="win32")return[];let i=e.SystemDrive||"C:",r=e.ProgramFiles||`${i}\\Program Files`,n="YuanShen_Data\\StreamingAssets\\MiHoYoSDKRes\\HttpServerResources\\font\\zh-cn.ttf";return[...new Set([Mn.join(r,"Genshin Impact","Genshin Impact Game",n),Mn.join(i+"\\","Mihoyo","Genshin Impact","Genshin Impact Game",n),Mn.join(r,"HoYoPlay","games","Genshin Impact game",n),Mn.join(r,"miHoYo Launcher","games","Genshin Impact Game",n)])]}function du(){if(process.env.QXQY_FONT_CONFIG_PATH)return process.env.QXQY_FONT_CONFIG_PATH;let t=process.platform==="win32"?process.env.APPDATA||Pn(ys(),"AppData","Roaming"):process.platform==="darwin"?Pn(ys(),"Library","Application Support"):process.env.XDG_CONFIG_HOME||Pn(ys(),".config");return Pn(t,"beyond-simulator","font.json")}function bs(t){if(!t||!["auto","custom","system"].includes(t.mode))throw new Error("\u8BF7\u9009\u62E9\u81EA\u52A8\u67E5\u627E\u3001\u6307\u5B9A\u6587\u4EF6\u6216\u7CFB\u7EDF\u5B57\u4F53");let e=typeof t.path=="string"?t.path.trim():"";if(e.length>4096)throw new Error("\u5B57\u4F53\u8DEF\u5F84\u8FC7\u957F");if((e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1)),t.mode==="custom"&&!e)throw new Error("\u8BF7\u586B\u5199\u5B57\u4F53\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");return{mode:t.mode,path:t.mode==="custom"?e:""}}function ws(t=du()){if(!im(t))return{mode:"auto",path:""};try{return bs(JSON.parse(nm(t,"utf8")))}catch{throw new Error("\u672C\u673A\u5B57\u4F53\u8BBE\u7F6E\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u8BF7\u5728\u300C\u5B57\u4F53\u8BBE\u7F6E\u300D\u4E2D\u91CD\u65B0\u4FDD\u5B58")}}function hu(t,e=du()){let i=`${e}.${lm()}.tmp`;try{rm(um(e),{recursive:!0}),am(i,JSON.stringify(t,null,2)+`
|
|
12
|
+
`,{flag:"wx",mode:384}),om(i,e)}catch(r){throw new Error("\u65E0\u6CD5\u4FDD\u5B58\u672C\u673A\u5B57\u4F53\u8BBE\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u76EE\u5F55\u7684\u5199\u5165\u6743\u9650",{cause:r})}finally{sm(i,{force:!0})}}function bu(t){let e=Buffer.from(t),i=e.subarray(0,4).toString("hex");if(e.length<12||e.length>33554432||!["00010000","4f54544f"].includes(i))throw new Error("QXQY_FONT_PATH must contain a valid TTF or OTF font (at most 32 MiB)");let r=ym("sha256").update(e).digest("hex"),n=gs(r);try{if(!pu.has(n)&&!pu.register(e,n))throw new Error("invalid font")}catch{throw new Error("QXQY_FONT_PATH font could not be registered")}return{id:r,data:e,type:i==="4f54544f"?"font/otf":"font/ttf"}}function Ss(t){if(!t)return null;if(!gm(t)||![".ttf",".otf"].includes(mm(t).toLowerCase()))throw new Error("QXQY_FONT_PATH must be an absolute path to a TTF or OTF font");let e,i;try{e=fm(t,"r");let r=hm(e);if(!r.isFile()||r.size<12||r.size>33554432)throw new Error("invalid size");i=pm(e)}catch{throw new Error("QXQY_FONT_PATH must point to a readable font file of at most 32 MiB")}finally{e!==void 0&&dm(e)}return bu(i)}var mu=!1,Dn=null,xs={path:"",source:"system"},zn=null,wu="",Su=!1;function xu(t){if(t.mode==="custom")return{font:Ss(t.path),path:t.path,source:"custom"};if(t.mode==="auto"){let e;for(let i of vs())if(cm(i))try{return{font:Ss(i),path:i,source:"auto"}}catch(r){e=r}if(e)throw e}return{font:null,path:"",source:"system"}}function Yt(){if(!mu){if(Fn&&Object.hasOwn(Fn,"localFont"))Dn=Fn.localFont?bu(Fn.localFont):null;else if(process.env.QXQY_FONT_PATH)Dn=Ss(process.env.QXQY_FONT_PATH),xs={path:process.env.QXQY_FONT_PATH,source:"environment"};else try{zn=ws();let t=xu(zn);Dn=t.font,xs={path:t.path,source:t.source}}catch(t){wu=t.message}mu=!0}return Dn}function _u(){Yt();let t={mode:"auto",path:""},e=wu;try{t=ws()}catch(i){e=i.message}return{...t,active:{...xs},error:e,environmentPath:process.env.QXQY_FONT_PATH||"",defaultPaths:vs(),restartRequired:Su||zn!==null&&JSON.stringify(zn)!==JSON.stringify(t)}}function vm(t){if(Yt(),process.env.QXQY_FONT_PATH)throw new Error("\u5F53\u524D\u5B57\u4F53\u7531 QXQY_FONT_PATH \u56FA\u5B9A\uFF0C\u8BF7\u79FB\u9664\u8BE5\u73AF\u5883\u53D8\u91CF\u5E76\u91CD\u542F\u540E\u518D\u4F7F\u7528\u524D\u7AEF\u8BBE\u7F6E");let e=bs(t),i=xu(e);return hu(e),Su=!0,{..._u(),nextFont:{path:i.path,source:i.source}}}var Gr=()=>fu(Yt()?.id),gu=t=>["127.0.0.1","localhost","::1","[::1]","::ffff:127.0.0.1"].includes(t);function yu(t){try{let e=t.headers.host;return gu(t.socket.remoteAddress)&&gu(new URL(`http://${e}`).hostname)&&!t.headers.forwarded&&!t.headers["x-forwarded-for"]&&!t.headers["x-forwarded-host"]&&!t.headers.via&&t.headers["sec-fetch-site"]!=="cross-site"&&(!t.headers.origin||new URL(t.headers.origin).host===e)}catch{return!1}}function Iu(t,e,{settingsEnabled:i=!0}={}){let r=new URL(t.url||"/","http://localhost");if(r.pathname!==nr&&!r.pathname.startsWith(`${nr}/`))return!1;let n=(o,s,a)=>(e.writeHead(o,{"content-type":s,"cache-control":"no-store","x-content-type-options":"nosniff","cross-origin-resource-policy":"same-origin"}),e.end(t.method==="HEAD"?void 0:a),!0);if(r.pathname===`${nr}/settings`)return!i||!yu(t)?n(403,"text/plain","\u5B57\u4F53\u8BBE\u7F6E\u4EC5\u9650\u672C\u673A\u76F4\u63A5\u8BBF\u95EE"):(async()=>{try{let o;if(t.method==="GET")o=_u();else if(t.method==="POST"){if(!/^application\/json(?:;|$)/i.test(t.headers["content-type"]||""))return n(415,"text/plain","application/json required");let s=[],a=0;for await(let l of t){if(a+=l.length,a>8192)return n(413,"text/plain","\u5B57\u4F53\u8BBE\u7F6E\u8FC7\u5927");s.push(l)}o=vm(JSON.parse(Buffer.concat(s).toString("utf8")))}else return n(405,"text/plain","GET or POST required");return n(200,"application/json",JSON.stringify(o))}catch(o){return n(400,"text/plain",o.message)}})();if(!["GET","HEAD"].includes(t.method))return n(405,"text/plain","Method not allowed");try{let o=Yt();return o&&!yu(t)?n(403,"text/plain","Local font access requires a direct loopback connection"):r.pathname===`${nr}/manifest`?n(200,"application/json",JSON.stringify({id:o?.id??null})):o&&r.pathname===`${nr}/file/${o.id}`?n(200,o.type,o.data):n(404,"text/plain","Font not found")}catch{return n(500,"text/plain","Local font configuration failed; check QXQY_FONT_PATH and restart the host")}}var _s=bm(1,1).getContext("2d"),Eu=new WeakMap,Cu=(t,e)=>Math.max(1,Math.trunc(Number.isFinite(Number(t))?Number(t):e));function Xt(t,e,i){let r=String(t.text??"").replace(/\r\n?/g,`
|
|
13
|
+
`),n=Cu(t.fontSize,20),o=Math.min(n,Cu(t.minimumFontSize,10)),s=t.adaptiveFontSize===!0,a=Gr(),l=JSON.stringify([r,e,i,n,o,s,t.kind,t.showScrollBar,a]),u=Eu.get(t);if(u?.key===l)return u.value;let c=(m,g)=>{_s.font=`${m}px ${a}`;let v=[];for(let z of r.split(`
|
|
14
|
+
`)){let L="";for(let j of z)L&&_s.measureText(L+j).width>g&&(v.push(L),L=""),L+=j;v.push(L)}let I=m*1.2,C=v.length*I,E=t.kind==="textbox"&&r?m*.25+4:0,D=r?C+E:0,S=D<=i+1e-6&&v.every(z=>_s.measureText(z).width<=g+1e-6);return{fontSize:m,lines:v,lineHeight:I,contentHeight:C,blockInset:E,requiredHeight:D,textWidth:g,fits:S}},f=Math.max(0,e-4),h=c(n,f);if(s&&!h.fits&&o<n){h=c(o,f);let m=o+1,g=n-1;for(;m<=g;){let v=Math.floor((m+g)/2),I=c(v,f);I.fits?(h=I,m=v+1):g=v-1}}return t.kind==="textwindow"&&t.showScrollBar!==!1&&h.contentHeight>i&&(h=c(h.fontSize,Math.max(0,f-12))),Eu.set(t,{key:l,value:h}),h}function ku(t,e){let i=[];function r(n){e[n.id]&&i.push(e[n.id]);let o=n.children||[];for(let s=o.length-1;s>=0;s-=1)r(o[s])}return r(t),i}function ui(t,e,i=Ai(e)){let r=Qe(e),n={};function o(s,a,l){let u=Ri(s.transformByPlatform,i),c=Vt(a,u),f=s.kind==="server-container"?l:$r(l,c,u),h=Jl(c,f);n[s.id]={...c,...as(c),id:s.id,kind:s.kind,name:s.name,visible:s.visible!==!1,active:s.active!==!1,rotationX:u.rotation.x,rotationY:u.rotation.y,rotationZ:u.rotation.z,renderLeft:h.left,renderBottom:h.bottom,renderWidth:h.width,renderHeight:h.height,renderRotationZ:h.rotationZ,renderMatrix:f,primitive:s.kind==="image"?Qi(s.imageId,s.imageSource):null,...s.kind==="textbox"||s.kind==="textwindow"?{text:s.text??"",fontSize:s.fontSize,adaptiveFontSize:s.adaptiveFontSize===!0,minimumFontSize:s.minimumFontSize,textLayout:Xt(s,c.width,c.height),fontColor:s.fontColor,bgColor:s.bgColor,enableOutline:s.enableOutline!==!1,outlineColor:s.outlineColor,horizontalAlignment:s.horizontalAlignment,verticalAlignment:s.verticalAlignment}:{},...s.kind==="image"?{imageSource:s.imageSource,imageType:s.imageType??null,imageId:s.imageId,imageColor:s.imageColor,enableMask:s.enableMask===!0,enableSoftEdge:s.enableSoftEdge===!0,softEdgeMode:s.softEdgeMode,softEdgeWidthX:s.softEdgeWidthX,softEdgeWidthY:s.softEdgeWidthY,horizontalSoftRange:s.horizontalSoftRange,verticalSoftRange:s.verticalSoftRange,enableFill:s.enableFill===!0,fillType:s.fillType,fillHorizontalType:s.fillHorizontalType,fillVerticalType:s.fillVerticalType,fillRadial90Type:s.fillRadial90Type,fillRadialType:s.fillRadialType,fillAmount:s.fillAmount,reverseMaskArea:s.reverseMaskArea===!0}:{},...s.kind==="button"?{raycastTarget:s.raycastTarget!==!1,interactable:s.interactable!==!1,clickAudioId:s.clickAudioId,unavailableChildId:s.unavailableChildId??null,hoverChildId:s.hoverChildId??null,pressedChildId:s.pressedChildId??null,selectedChildId:s.selectedChildId??null}:{}};let m=s.kind==="server-container"?a:c;for(let g of s.children||[])o(g,m,f)}return o(t,r,tr()),{canvas:r,boxes:n}}function Is(t,e){let i=[];function r(n,o,s=null,a=[],l=0,u=1,c=t.id){i.push({id:n.id,guid:e?.get(n.id)??(n.guid||0),kind:n.kind,name:n.name,label:Zi[n.kind]||n.kind,depth:o,parentId:s,ancestorIds:a,siblingIndex:l,siblingCount:u,templateId:c,childCount:(n.children||[]).length,incomplete:!Rn.includes(n.kind)});let f=n.children||[];for(let h=0;h<f.length;h+=1)r(f[h],o+1,n.id,[...a,n.id],h,f.length,c)}return r(t,0),i}function $(t,e,i,r,n={}){return{key:t,label:e,type:i,value:r,...n}}function Au(t,e,i,r){if(!t)return null;let n=li(t.transformByPlatform,e),o=as(i),s=[$("name","\u540D\u79F0","string",t.name),$("active","\u521D\u59CB\u6FC0\u6D3B","bool",t.active!==!1),$("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",t.visible!==!1),$("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",t.canControllerFocus===!0),$("posX","\u4F4D\u7F6E X","number",o.posX,{computed:!0}),$("posY","\u4F4D\u7F6E Y","number",o.posY,{computed:!0}),$("width","\u5927\u5C0F W","number",o.width,{computed:!0}),$("height","\u5927\u5C0F H","number",o.height,{computed:!0}),$("rotationX","\u65CB\u8F6C X","number",n.rotation.x),$("rotationY","\u65CB\u8F6C Y","number",n.rotation.y),$("rotationZ","\u65CB\u8F6C Z","number",n.rotation.z),$("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",t.syncAllDevices!==!1),$("anchorType","\u951A\u70B9\u7C7B\u578B","enum",Ql(n),{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"}]}),$("anchorMinX","\u951A\u70B9 Min X","number",n.anchorMin.x),$("anchorMinY","\u951A\u70B9 Min Y","number",n.anchorMin.y),$("anchorMaxX","\u951A\u70B9 Max X","number",n.anchorMax.x),$("anchorMaxY","\u951A\u70B9 Max Y","number",n.anchorMax.y),$("pivotX","\u4E2D\u5FC3 X","number",n.pivot.x),$("pivotY","\u4E2D\u5FC3 Y","number",n.pivot.y)];if(t.kind==="container"&&s.push($("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",t.isolateNavigation===!0),$("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",t.disableKeyEventPassthrough===!0),$("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",t.disableCursorEventPassthrough===!0),$("showCursor","\u663E\u793A\u5E38\u9A7B\u5149\u6807","bool",t.showCursor===!0)),t.kind==="textbox"||t.kind==="textwindow"){let a=t.giaRaw?.textAlign,l=[0,1,2].includes(a)?t.horizontalAlignment||"Left":`__unrecognized:${a}`;s.push($("fontSize","\u5B57\u53F7","number",t.fontSize),$("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",t.adaptiveFontSize===!0),$("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",t.minimumFontSize),$("fontColor","\u6587\u672C\u8272","color",t.fontColor),$("bgColor","\u80CC\u666F\u8272","color",t.bgColor),$("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",t.enableOutline!==!1),$("outlineColor","\u63CF\u8FB9\u8272","color",t.outlineColor),$("horizontalAlignment","\u6C34\u5E73\u5BF9\u9F50","enum",l,{...[0,1,2].includes(a)?{}:{unknownValue:a},options:[{value:"Left",label:"\u5DE6\u5BF9\u9F50"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Right",label:"\u53F3\u5BF9\u9F50"}]}),$("verticalAlignment","\u5782\u76F4\u5BF9\u9F50","enum",t.verticalAlignment||"Top",{options:[{value:"Top",label:"\u9876\u90E8"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Bottom",label:"\u5E95\u90E8"}]}),$("text","\u6587\u672C","text",t.text??""))}if(t.kind==="image"){let a=t.giaRaw?.imageFillType,l=[1,2,3,4,5].includes(a)?t.fillType:`__unrecognized:${a}`;s.push($("imageSource","\u56FE\u7247\u6E90","enum",t.imageSource,{options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"},{value:"Prefab",label:"\u5143\u4EF6"}]}),$("imageId","imageId","number",t.imageId??0),$("imageType","\u56FE\u7247\u7C7B\u578B","enum",t.imageType??null,{options:[{value:"Basic",label:"\u57FA\u7840"},{value:"Stretch",label:"\u62C9\u4F38"}]}),$("imageColor","\u586B\u5145\u8272","color",t.imageColor),$("enableMask","\u5F00\u542F\u906E\u7F69","bool",t.enableMask===!0),$("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",t.enableSoftEdge===!0,{gia:"W"}),$("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",t.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),$("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",t.softEdgeWidthX),$("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",t.softEdgeWidthY),$("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",t.horizontalSoftRange),$("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",t.verticalSoftRange),$("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",t.enableFill===!0,{gia:"W"}),$("fillType","\u5F62\u72B6","enum",l,{...[1,2,3,4,5].includes(a)?{}:{unknownValue:a},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"}]}),$("fillHorizontalType","\u65B9\u5411","enum",t.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),$("fillVerticalType","\u65B9\u5411","enum",t.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),$("fillRadial90Type","\u8D77\u70B9","enum",t.fillRadial90Type,{options:[{value:"BottomLeft",label:"\u5DE6\u4E0B"},{value:"TopLeft",label:"\u5DE6\u4E0A"},{value:"TopRight",label:"\u53F3\u4E0A"},{value:"BottomRight",label:"\u53F3\u4E0B"}]}),$("fillRadialType","\u8D77\u70B9","enum",t.fillRadialType,{options:[{value:"Bottom",label:"\u4E0B\u65B9"},{value:"Left",label:"\u5DE6\u4FA7"},{value:"Top",label:"\u4E0A\u65B9"},{value:"Right",label:"\u53F3\u4FA7"}]}),$("fillAmount","\u8FDB\u5EA6","percent",t.fillAmount),$("reverseMaskArea","\u906E\u7F69\u533A\u57DF\u53CD\u8F6C","bool",t.reverseMaskArea===!0,{gia:"W"}))}if(t.kind==="button"){let a=[{value:"",label:"\u672A\u8BBE\u7F6E"},...(t.children||[]).map(l=>({value:l.id,label:`${l.name} \xB7 ${l.id}`}))];s.push($("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",t.raycastTarget!==!1),$("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",t.interactable!==!1),$("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",t.unavailableChildId,{options:a,gia:"W"}),$("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",t.hoverChildId,{options:a,gia:"W"}),$("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",t.pressedChildId,{options:a,gia:"W"}),$("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",t.selectedChildId,{options:a,gia:"W"}),$("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",t.clickAudioId))}return t.kind==="reference"&&s.push($("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",t.referencedPrefabId??"")),(t.kind==="textwindow"||t.kind==="grid")&&s.push($("interactable","\u5141\u8BB8\u6EDA\u52A8\u4EA4\u4E92","bool",t.interactable!==!1),$("showScrollBar","\u663E\u793A\u6EDA\u52A8\u6761","bool",t.showScrollBar!==!1)),t.kind==="grid"&&s.push($("itemPrefabId","\u5217\u8868\u9879\u6A21\u677F\u7D22\u5F15","number",t.itemPrefabId??0),$("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",t.raycastTarget!==!1),$("scrollDirection","\u6EDA\u52A8\u65B9\u5411","enum",t.scrollDirection,{options:[{value:"Vertical",label:"\u7EB5\u5411"},{value:"Horizontal",label:"\u6A2A\u5411"}]}),$("layoutConstraint","\u6392\u5217\u9650\u5236","enum",t.layoutConstraint,{options:[{value:"AutoWrap",label:"\u81EA\u52A8\u6362\u884C"},{value:"Fixed",label:"\u56FA\u5B9A\u884C\u5217\u6570"}]}),$("layoutConstraintFixedCount","\u6BCF\u884C\u6216\u6BCF\u5217\u6570\u91CF","number",t.layoutConstraintFixedCount??1),$("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",t.cellSizeX,{evidence:"W"}),$("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",t.cellSizeY,{evidence:"W"}),$("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",t.spacingX,{evidence:"W"}),$("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",t.spacingY,{evidence:"W"}),$("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",t.padding1X,{evidence:"W"}),$("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",t.padding1Y,{evidence:"W"}),$("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",t.padding2X,{evidence:"W"}),$("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",t.padding2Y,{evidence:"W"}),$("previewCount","\u9884\u89C8\u6570\u91CF","number",t.previewCount)),t.kind==="keyhint"&&s.push($("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",t.keyboardKeyCode??t.giaRaw?.keyHintField502??1,{gia:"W"}),$("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",t.controllerKeyCode??t.giaRaw?.keyHintField501??1)),(t.kind==="animation"||t.kind==="fullscreen")&&s.push($("animationId",t.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",t.animationId??"")),(!Rn.includes(t.kind)||t.kind==="textwindow"||t.kind==="grid")&&s.push($("incomplete","\u5B8C\u6574\u5EA6","note",t.kind==="textwindow"||t.kind==="grid"?"\u8BD5\u73A9\u652F\u6301\u57FA\u7840\u6EDA\u52A8\uFF1B\u6EDA\u52A8\u4EA4\u4E92\u3001\u6EDA\u52A8\u6761\u53CA\u5217\u8868\u914D\u7F6E\u4EE5 JSON/Lua \u4E3A\u51C6\uFF0C\u76F8\u5173 GIA \u5F00\u5173\u6620\u5C04\u5C1A\u672A\u6838\u5B9E\u3002":"\u672C\u9636\u6BB5\u4EC5\u516C\u5171\u53D8\u6362\uFF0C\u4E1A\u52A1\u69FD\u4E0D\u5B8C\u6574")),{id:t.id,guid:r?.get(t.id)??(t.guid||0),kind:t.kind,label:Zi[t.kind]||t.kind,incomplete:!Rn.includes(t.kind),fields:s}}function Tu(t,e,i){let r=(Array.isArray(t)?t:Object.values(t)).filter(n=>n.kind!=="server-container");for(let n=r.length-1;n>=0;n-=1){let o=r[n];if(!o.visible||!o.active)continue;let s=o.renderMatrix&&Ut(o.renderMatrix),a=s&&tt(s,e,i);if(a&&a.x>=o.left&&a.x<=o.right&&a.y>=o.bottom&&a.y<=o.top)return o.id}return null}var Mf=qp(Nf(),1);function vr(t,e=!1){let i=[],r=(n,o)=>{n.kind!=="server-container"&&i.push({node:n,parent:o});let s=e&&n.kind!=="server-container"?[...n.children||[]].reverse():n.children||[];for(let a of s)r(a,n)};return r(t.root,null),i}var Lg=String.raw`
|
|
2
15
|
syntax = "proto3";
|
|
3
16
|
// Root.graph is singular in the game's canonical schema, but template-list
|
|
4
17
|
// assets legally emit field 1 more than once. Model it as repeated here so
|
|
@@ -24,7 +37,7 @@ message UiControlGroup {
|
|
|
24
37
|
oneof value {
|
|
25
38
|
Transform transform = 11; WrapperString name = 12; Field14 field14 = 14;
|
|
26
39
|
string empty72 = 72; string empty73 = 73; string empty74 = 74; string empty75 = 75;
|
|
27
|
-
|
|
40
|
+
bytes empty76 = 76; string empty77 = 77; string empty78 = 78; string empty79 = 79;
|
|
28
41
|
string empty80 = 80; string empty81 = 81; string empty82 = 82; string empty83 = 83;
|
|
29
42
|
string empty84 = 84; string empty85 = 85; string empty86 = 86;
|
|
30
43
|
}
|
|
@@ -34,7 +47,7 @@ message UiControlGroup {
|
|
|
34
47
|
oneof value {
|
|
35
48
|
Transform transform = 13; Field14 field14 = 14; RootChildRef rootChildRef = 73;
|
|
36
49
|
GenericSlot genericSlot = 74; TextConfig textConfig = 75; CursorConfig cursorConfig = 76;
|
|
37
|
-
|
|
50
|
+
bytes templateRefSlot = 77; FooterSlot footerSlot = 78; ContainerNodeConfig containerNodeSlot = 79;
|
|
38
51
|
GridViewConfig gridView = 80; ButtonPresetConfig buttonPreset = 81; KeyHintConfig keyHint = 83;
|
|
39
52
|
ImageSlotConfig imageSlot = 84; ImageConfig image = 85; string effectSlot = 86;
|
|
40
53
|
string fullscreenEffectSlot = 87;
|
|
@@ -99,16 +112,38 @@ message ImageConfig {
|
|
|
99
112
|
message SliceVector { float field501 = 501; float field502 = 502; }
|
|
100
113
|
}
|
|
101
114
|
message FooterSlot { int32 field505 = 505; }
|
|
102
|
-
`,{root:Ql}=Jl.parse(Zl,{keepCase:!1}),Pe=Ql.lookupType("Root"),Qe=20,Br=4,Ya=806,Ba=1657,ri={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},Ua={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},ec="server-control-template",Gi="client-control-template";function $i(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var tc=Object.fromEntries(Object.entries(Ua).map(([e,t])=>[t,e])),ja=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"]]}),La=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}),ic=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Ur(e){return{class:1,type:8,id:e}}function ni(e,t,i,r){return{...r,field501:t,field502:i,field503:1,nodeRef:Ur(e)}}function rc(e){let t=[],i=e.meta?.assetType==="client-control-template";return Q(e.root,r=>{i&&r.kind==="server-container"||t.push(r)}),t}function ai(e,t=new Set){let i=new Map,r=[];for(let n of rc(e)){let a=Number(n.guid);_e(a)&&!t.has(a)?(t.add(a),n.guid=a,i.set(n.id,a)):r.push(n)}for(let n of r){let a=We(t);t.add(a),n.guid=a,i.set(n.id,a)}return i}function nc(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 ac(e,t){let r={multiPlatform:{platforms:ce.map(n=>({platformType:Ua[n],transform:nc(e.transformByPlatform[n])})),field502:ri[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:ni(t,4,12,{transform:r})}}function oc(e,t,i){let r=i?{empty15:"",field501:5}:{field17:{},field501:7},n=i?r:{...r,...e.visible===!1?{field17:{initiallyHidden:!0}}:{},...e.active===!1?{initiallyInactive:!0}:{}};return[{name:{value:e.name},field501:2,field502:15},{field14:r,field501:4,field502:i?23:86,details:ni(t,5,i?23:86,{field14:n})},ac(e,t)]}function sc(e,t,i,r){let n=(l,u,d,h,p)=>({[d]:"",field501:l,field502:u,details:ni(t,l+2,u,{[h]:p})}),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=n(63,83,"empty73","genericSlot",o),c=n(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(a.footerField505)?e.canControllerFocus?1:0:a.footerField505});if(e.kind==="container")return[s,n(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"&&r.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,u=Number.isFinite(a.textAlign)?Math.trunc(a.textAlign):l,d={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}:{},...u?{align:u}:{},verticalAlign:a.textVerticalAlign??{Top:0,Middle:1,Bottom:2}[e.verticalAlignment]??0};return e.kind==="textwindow"?((e.interactable===!1||e.showScrollBar===!1)&&r.push(`${e.name}: \u6587\u672C\u89C6\u7A97\u4EA4\u4E92/\u6EDA\u52A8\u6761\u5F00\u5173\u4EC5\u4FDD\u5B58\u5728 JSON\uFF0CGIA \u672A\u6620\u5C04\u8FD9\u4E9B\u6539\u52A8\u3002`),d.field511=a.textField511??1,d.viewFlags={field502:a.textViewField502??1,field503:a.textViewField503??1},[s,{empty81:"",field501:71,field502:94,details:ni(t,66,94,{textConfig:d})},c]):[s,n(64,84,"empty74","textConfig",d),c]}if(e.kind==="image"){let l=[0,1].includes(a.imageSlotType??0)?e.imageType==="Stretch"?1:0:a.imageSlotType;e.imageType==null&&e.imageSource==="StaticReference"&&e.imageId>100006&&r.push(`${e.name}: \u56FE\u7247\u7C7B\u578B\u968F\u7D20\u6750\u8FB9\u754C\u81EA\u52A8\u9009\u62E9\uFF0CGIA \u6309\u57FA\u7840\u5BFC\u51FA\uFF1B\u9700\u8981\u62C9\u4F38\u8BF7\u5148\u660E\u786E\u9009\u62E9\u6216\u5728 Lua \u8BBE\u7F6E imageType\u3002`),e.imageSource&&e.imageSource!=="StaticReference"&&r.push(`${e.name}: \u56FE\u7247\u6765\u6E90 ${e.imageSource} \u4EC5\u4FDD\u5B58\u5728 JSON\uFF0C\u5C1A\u672A\u6620\u5C04\u5230 GIA\uFF1B\u8BF7\u5728 Lua \u4E2D\u7528 SetImage(Enum.ImageSource.${e.imageSource}, ${e.imageId}) \u8BBE\u7F6E\u3002`);let u={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[e.fillType],d=Number.isFinite(a.imageFillType)?Math.trunc(a.imageFillType):u||1;e.enableFill&&!d&&r.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"&&r.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"&&r.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:$i(e.softEdgeWidthX,8),field502:$i(e.softEdgeWidthY,8)},field512:$i(e.horizontalSoftRange,85),field513:$i(e.verticalSoftRange,85),fillType:d,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&d?{enableFill:1}:{},...e.reverseMaskArea?{reverseMask:1}:{}};return[s,n(73,96,"empty83","imageSlot",{field502:Number.isFinite(e.imageColor)?e.imageColor>>>0:4294967295,assetId:e.imageId>>>0,...l?{imageType:l}:{}}),n(74,97,"empty84","image",h),c]}if(e.kind==="button"){let l=(m,y)=>{let x=e[m];return x?(e.children||[]).some(E=>E.id===x)?i.get(x)||0:(r.push(`${e.name}: ${y}\u72B6\u6001\u8282\u70B9\u4E0D\u662F\u6309\u94AE\u7684\u76F4\u63A5\u5B50\u63A7\u4EF6\uFF0CGIA \u672A\u5199\u5165\u8BE5\u72B6\u6001\u3002`),0):0},u=l("unavailableChildId","\u4E0D\u53EF\u7528"),d=l("hoverChildId","\u60AC\u505C"),h=l("pressedChildId","\u6309\u4E0B"),p=l("selectedChildId","\u9009\u4E2D");return[s,n(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(e.clickAudioId),...u?{disabledChild:u}:{},...d?{hoverChild:d}:{},...h?{pressedChild:h}:{},...p?{selectedChild:p}:{},...e.interactable?{interactable:1}:{},...e.raycastTarget?{raycastTarget:1}:{}}),c]}return e.kind==="cursor"?[s,n(65,85,"empty75","cursorConfig",{field501:[void 0,0,1].includes(a.cursorField501)?e.raycastTarget!==!1?1:0:a.cursorField501}),c]:e.kind==="reference"?[s,n(66,89,"empty76","templateRefSlot",a.templateRefSlot??""),c]:e.kind==="grid"?((e.itemPrefabId||e.interactable===!1||e.showScrollBar===!1||e.raycastTarget===!1||e.scrollDirection!=="Vertical"||e.layoutConstraint!=="AutoWrap")&&r.push(`${e.name}: \u7F51\u683C\u5217\u8868\u9879\u6A21\u677F\u3001\u4EA4\u4E92/\u6EDA\u52A8\u6761\u5F00\u5173\u3001\u6EDA\u52A8\u65B9\u5411\u53CA\u6392\u5217\u9650\u5236\u4EC5\u4FDD\u5B58\u5728 JSON\uFF0CGIA \u672A\u6620\u5C04\u8FD9\u4E9B\u6539\u52A8\u3002`),[s,n(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,n(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,n(75,98,"empty85","effectSlot",a.effectSlot??""),c]:e.kind==="fullscreen"?[s,n(76,99,"empty86","fullscreenEffectSlot",a.fullscreenEffectSlot??""),c]:(r.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 lc(e,t){if(t)return 1;if(!ke(e.giaInfoIndex))throw new Error(`${e.name}: \u7F3A\u5C11\u5408\u6CD5\u7684\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7`);return e.giaInfoIndex}function cc(e,t,i){let r=Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(n=>Number.isSafeInteger(n)&&n>0&&n<=2147483647):[];return r.length?r:(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 jr(e,t){let i=String(e.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let r=(l,u)=>Number.isSafeInteger(Number(l))&&Number(l)>0?Number(l):u,n=r(e.meta?.giaOwnerUid,114514),a=r(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),o=r(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`${n}-${a}-${o}-\\${c}.gia`}function Vi(e,t,i,r,n,a=!1,o=!1,s=o,c=!1){let l=i.get(e.id),d=(c?[...e.children||[]].reverse():e.children||[]).map(m=>i.get(m.id)),h=a?r:d,p=oc(e,l,a);if(a){let m=e.children?.[0];m&&p.push({empty72:"",field501:62,field502:82,details:ni(l,64,82,{rootChildRef:{guid:i.get(m.id)}})})}else p.push(...sc(e,l,i,n));return{id:Ur(l),relatedIds:h.map(m=>Ur(m)),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:lc(e,a)},field501:2,field502:6}]:[],...a||o?[{related:{value:cc(e,n,a?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:a?[]:d,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:p}}}}function Xa(e){let t=[];return Q(e.root,(i,r)=>{i.kind!=="server-container"&&t.push({node:i,parent:r})}),t}function uc(e,t){let i=new Map;for(let r of e||[]){if(!r.controlId||!(t===Gi?r.controlAsset===Gi:r.controlAsset!==Gi))continue;let a=i.get(r.controlId)||[];a.push(r.guid),i.set(r.controlId,a)}return i}function qa(e,t,i,r){let n=uc(t,i),a=new Map;Q(e.root,o=>{n.has(o.id)&&(a.set(o,o.scriptMappingIds),o.scriptMappingIds=n.get(o.id))});try{return r()}finally{for(let[o,s]of a)s===void 0?delete o.scriptMappingIds:o.scriptMappingIds=s}}function Lr(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function Xr(e){let t=e.meta?.gameVersion;return!t||t==="7.0.50"?Ni:t}function Wa(e,t,i,r,n=[]){let a=Xa(e),o=a.filter(({parent:u})=>u?.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:u})=>u.id)),c=a.filter(({node:u})=>!s.has(u.id)),l=a.map(({node:u})=>t.get(u.id));return qa(e,n,Gi,()=>({graph:o.map(({node:u,parent:d})=>Vi(u,d,t,l,i,!1,!0)),accessories:c.map(({node:u,parent:d})=>Vi(u,d,t,l,i,!1,!1,!0)),filePath:r||jr(e,!0),gameVersion:Xr(e),...Lr(e)}))}function Ka(e,t,i,r,n){let a=Xa(e),o=[a[0],...a.slice(1).reverse()],s=o.map(({node:c})=>t.get(c.id));return qa(e,i.scripts,ec,()=>({graph:[Vi(e.root,null,t,s,r,!0,!1,!1,!0),...i.units||[]],accessories:o.map(({node:c,parent:l})=>Vi(c,l,t,s,r,!1,!1,!1,!0)),filePath:n||jr(e,!1),gameVersion:Xr(e),...Lr(e)}))}function Ja(e,t){let i=qr(e),r=t(i);if(!r.valid)throw new Error(`GIA compatibility validation failed:
|
|
115
|
+
`,{root:Gg}=Mf.default.parse(Lg,{keepCase:!1}),Ct=Gg.lookupType("Root"),wi=20,va=4,Ff=806,Df=1657,Jr={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},zf={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},qg="server-control-template",mo="client-control-template";function po(t,e){let i=Number(t);return Number.isFinite(i)?i:e}var Bg=Object.fromEntries(Object.entries(zf).map(([t,e])=>[e,t])),$f=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"]]}),Lf=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}),jg=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function ba(t){return{class:1,type:8,id:t}}function Zr(t,e,i,r){return{...r,field501:e,field502:i,field503:1,nodeRef:ba(t)}}function Vg(t){let e=[],i=t.meta?.assetType==="client-control-template";return Ae(t.root,r=>{i&&r.kind==="server-container"||e.push(r)}),e}function Qr(t,e=new Set){let i=new Map,r=[];for(let n of Vg(t)){let o=Number(n.guid);vt(o)&&!e.has(o)?(e.add(o),n.guid=o,i.set(n.id,o)):r.push(n)}for(let n of r){let o=si(e);e.add(o),n.guid=o,i.set(n.id,o)}return i}function Ug(t){return{scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},anchorMin:{x:t.anchorMin.x,y:t.anchorMin.y},anchorMax:{x:t.anchorMax.x,y:t.anchorMax.y},offset:{x:t.offset.x,y:t.offset.y},size:{x:t.size.x,y:t.size.y},pivot:{x:t.pivot.x,y:t.pivot.y},field508:Object.fromEntries(Object.entries(t.rotation).filter(([,e])=>e!==0))}}function Hg(t,e){let r={multiPlatform:{platforms:qe.map(n=>({platformType:zf[n],transform:Ug(t.transformByPlatform[n])})),field502:Jr[t.kind]||25,...t.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:Zr(e,4,12,{transform:r})}}function Yg(t,e,i){let r=i?{empty15:"",field501:5}:{field17:{},field501:7},n=i?r:{...r,...t.visible===!1?{field17:{initiallyHidden:!0}}:{},...t.active===!1?{initiallyInactive:!0}:{}};return[{name:{value:t.name},field501:2,field502:15},{field14:r,field501:4,field502:i?23:86,details:Zr(e,5,i?23:86,{field14:n})},Hg(t,e)]}function Xg(t,e,i,r){let n=(u,c,f,h,m)=>({[f]:"",field501:u,field502:c,details:Zr(e,u+2,c,{[h]:m})}),o=t.giaRaw||{},s=Array.isArray(t.scriptMappingIds)&&t.scriptMappingIds.length?{field501:o.genericField501||1,field502:t.scriptMappingIds.map(u=>({field1:{id:Number(u)}}))}:{field501:o.genericField501??0},a=n(63,83,"empty73","genericSlot",s),l=n(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(o.footerField505)?t.canControllerFocus?1:0:o.footerField505});if(t.kind==="container")return[a,n(68,91,"empty78","containerNodeSlot",{...t.isolateNavigation?{isolateNavigation:!0}:{},...t.disableKeyEventPassthrough?{disableKeyEventPassthrough:!0}:{},...t.disableCursorEventPassthrough?{disableCursorEventPassthrough:!0}:{},...t.showCursor?{showCursor:!0}:{}}),l];if(t.kind==="textbox"||t.kind==="textwindow"){t.verticalAlignment==="Middle"&&r.push(`${t.name}: \u5782\u76F4\u5C45\u4E2D\u6309\u63A8\u5B9A\u503C\u5BFC\u51FA\uFF0C\u5C1A\u5F85\u5B9E\u673A\u786E\u8BA4\u3002`);let u={Left:0,Middle:1,Right:2}[t.horizontalAlignment]??0,c=Number.isFinite(o.textAlign)?Math.trunc(o.textAlign):u,f={field501:o.textField501??20,field503:o.textField503??12,color:t.fontColor>>>0,color2:t.bgColor>>>0,color3:t.outlineColor>>>0,text:{value:t.text||""},fontSize:Math.trunc(t.fontSize),minimumFontSize:Math.trunc(t.minimumFontSize),...t.adaptiveFontSize?{adaptive:1}:{},...t.enableOutline===!1?{outlineOff:1}:{},...c?{align:c}:{},verticalAlign:o.textVerticalAlign??{Top:0,Middle:1,Bottom:2}[t.verticalAlignment]??0};return t.kind==="textwindow"?((t.interactable===!1||t.showScrollBar===!1)&&r.push(`${t.name}: \u6587\u672C\u89C6\u7A97\u4EA4\u4E92/\u6EDA\u52A8\u6761\u5F00\u5173\u4EC5\u4FDD\u5B58\u5728 JSON\uFF0CGIA \u672A\u6620\u5C04\u8FD9\u4E9B\u6539\u52A8\u3002`),f.field511=o.textField511??1,f.viewFlags={field502:o.textViewField502??1,field503:o.textViewField503??1},[a,{empty81:"",field501:71,field502:94,details:Zr(e,66,94,{textConfig:f})},l]):[a,n(64,84,"empty74","textConfig",f),l]}if(t.kind==="image"){let u=[0,1].includes(o.imageSlotType??0)?t.imageType==="Stretch"?1:0:o.imageSlotType;t.imageType==null&&t.imageSource==="StaticReference"&&t.imageId>100006&&r.push(`${t.name}: \u56FE\u7247\u7C7B\u578B\u968F\u7D20\u6750\u8FB9\u754C\u81EA\u52A8\u9009\u62E9\uFF0CGIA \u6309\u57FA\u7840\u5BFC\u51FA\uFF1B\u9700\u8981\u62C9\u4F38\u8BF7\u5148\u660E\u786E\u9009\u62E9\u6216\u5728 Lua \u8BBE\u7F6E imageType\u3002`),t.imageSource&&t.imageSource!=="StaticReference"&&r.push(`${t.name}: \u56FE\u7247\u6765\u6E90 ${t.imageSource} \u4EC5\u4FDD\u5B58\u5728 JSON\uFF0C\u5C1A\u672A\u6620\u5C04\u5230 GIA\uFF1B\u8BF7\u5728 Lua \u4E2D\u7528 SetImage(Enum.ImageSource.${t.imageSource}, ${t.imageId}) \u8BBE\u7F6E\u3002`);let c={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[t.fillType],f=Number.isFinite(o.imageFillType)?Math.trunc(o.imageFillType):c||1;t.enableFill&&!f&&r.push(`${t.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`),t.fillType==="Horizontal"&&t.fillHorizontalType!=="Left"&&r.push(`${t.name}: \u5F53\u524D\u6A2A\u5411\u586B\u5145\u65B9\u5411\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`),t.fillType==="Radial180"&&t.fillRadialType!=="Bottom"&&r.push(`${t.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(t.fillAmount)||0))*100),border:{field501:po(t.softEdgeWidthX,8),field502:po(t.softEdgeWidthY,8)},field512:po(t.horizontalSoftRange,85),field513:po(t.verticalSoftRange,85),fillType:f,...t.enableMask?{enableMask:1}:{},...t.enableSoftEdge?{enableSoftEdge:1}:{},...t.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...t.enableFill&&f?{enableFill:1}:{},...t.reverseMaskArea?{reverseMask:1}:{}};return[a,n(73,96,"empty83","imageSlot",{field502:Number.isFinite(t.imageColor)?t.imageColor>>>0:4294967295,assetId:t.imageId>>>0,...u?{imageType:u}:{}}),n(74,97,"empty84","image",h),l]}if(t.kind==="button"){let u=(g,v)=>{let I=t[g];return I?(t.children||[]).some(C=>C.id===I)?i.get(I)||0:(r.push(`${t.name}: ${v}\u72B6\u6001\u8282\u70B9\u4E0D\u662F\u6309\u94AE\u7684\u76F4\u63A5\u5B50\u63A7\u4EF6\uFF0CGIA \u672A\u5199\u5165\u8BE5\u72B6\u6001\u3002`),0):0},c=u("unavailableChildId","\u4E0D\u53EF\u7528"),f=u("hoverChildId","\u60AC\u505C"),h=u("pressedChildId","\u6309\u4E0B"),m=u("selectedChildId","\u9009\u4E2D");return[a,n(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(t.clickAudioId),...c?{disabledChild:c}:{},...f?{hoverChild:f}:{},...h?{pressedChild:h}:{},...m?{selectedChild:m}:{},...t.interactable?{interactable:1}:{},...t.raycastTarget?{raycastTarget:1}:{}}),l]}if(t.kind==="cursor")return[a,n(65,85,"empty75","cursorConfig",{field501:[void 0,0,1].includes(o.cursorField501)?t.raycastTarget!==!1?1:0:o.cursorField501}),l];if(t.kind==="reference"){let u=o.templateRefSlotBase64;(u||o.templateRefOuterBase64)&&r.push(`${t.name}: \u6A21\u677F\u5F15\u7528\u7684\u975E\u7A7A\u4E8C\u8FDB\u5236\u914D\u7F6E\u5C1A\u672A\u89E3\u6790\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u5C55\u5F00\u88AB\u5F15\u7528\u6A21\u677F\u3002`);let c=n(66,89,"empty76","templateRefSlot",u?Buffer.from(u,"base64"):Buffer.from(o.templateRefSlot??"","utf8"));return c.empty76=Buffer.from(o.templateRefOuterBase64||"","base64"),[a,c,l]}return t.kind==="grid"?((t.itemPrefabId||t.interactable===!1||t.showScrollBar===!1||t.raycastTarget===!1||t.scrollDirection!=="Vertical"||t.layoutConstraint!=="AutoWrap")&&r.push(`${t.name}: \u7F51\u683C\u5217\u8868\u9879\u6A21\u677F\u3001\u4EA4\u4E92/\u6EDA\u52A8\u6761\u5F00\u5173\u3001\u6EDA\u52A8\u65B9\u5411\u53CA\u6392\u5217\u9650\u5236\u4EC5\u4FDD\u5B58\u5728 JSON\uFF0CGIA \u672A\u6620\u5C04\u8FD9\u4E9B\u6539\u52A8\u3002`),[a,n(69,92,"empty79","gridView",{field501:o.gridField501??1,cellSize:{field501:t.cellSizeX,field502:t.cellSizeY},gap:{field501:t.spacingX,field502:t.spacingY},padding1:{field501:t.padding1X,field502:t.padding1Y},padding2:{field501:t.padding2X,field502:t.padding2Y},field507:o.gridField507??1,field508:o.gridField508??1,field509:o.gridField509??1,field511:o.gridField511??5,field512:o.gridField512??1}),l]):t.kind==="keyhint"?[a,n(72,95,"empty82","keyHint",{field501:Number.isFinite(o.keyHintField501)?Math.trunc(o.keyHintField501):t.controllerKeyCode??1,field502:Number.isFinite(o.keyHintField502)?Math.trunc(o.keyHintField502):t.keyboardKeyCode??1}),l]:t.kind==="animation"?[a,n(75,98,"empty85","effectSlot",o.effectSlot??""),l]:t.kind==="fullscreen"?[a,n(76,99,"empty86","fullscreenEffectSlot",o.fullscreenEffectSlot??""),l]:(r.push(`${t.name}: ${t.kind} \u4E0D\u662F\u5DF2\u77E5 GIA \u63A7\u4EF6\u7C7B\u578B\uFF0C\u5DF2\u4EC5\u5199\u516C\u5171\u53D8\u6362\u3002`),[a,l])}function Wg(t,e){if(e)return 1;if(!ct(t.giaInfoIndex))throw new Error(`${t.name}: \u7F3A\u5C11\u5408\u6CD5\u7684\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7`);return t.giaInfoIndex}function Kg(t,e,i){let r=Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(n=>Number.isSafeInteger(n)&&n>0&&n<=2147483647):[];return r.length?r:(e.push(`${t.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 wa(t,e){let i=String(t.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let r=(u,c)=>Number.isSafeInteger(Number(u))&&Number(u)>0?Number(u):c,n=r(t.meta?.giaOwnerUid,114514),o=r(t.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),s=r(t.meta?.giaFileId,e?1073741829:1073741830),a=e?"\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",l=String(t.meta?.giaFileName||a).replace(/[\\/:*?"<>|]/gu,"-").replace(/\.gia$/iu,"").trim()||a.replace(/\.gia$/iu,"");return`${n}-${o}-${s}-\\${l}.gia`}function go(t,e,i,r,n,o=!1,s=!1,a=s,l=!1){let u=i.get(t.id),f=(l?[...t.children||[]].reverse():t.children||[]).map(g=>i.get(g.id)),h=o?r:f,m=Yg(t,u,o);if(o){let g=t.children?.[0];g&&m.push({empty72:"",field501:62,field502:82,details:Zr(u,64,82,{rootChildRef:{guid:i.get(g.id)}})})}else m.push(...Xg(t,u,i,n));return{id:ba(u),relatedIds:h.map(g=>ba(g)),name:t.name,which:o?21:s?70:15,ui:{content:{guid:u,info:[{guid:{value:u},field501:1,field502:5},...o||a?[{index:{value:Wg(t,o)},field501:2,field502:6}]:[],...o||s?[{related:{value:Kg(t,n,o?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:o?[]:f,parent:e&&e.kind!=="server-container"?i.get(e.id):0,data:m}}}}function Jg(t,e){let i=new Map;for(let r of t||[]){if(!r.controlId||!(e===mo?r.controlAsset===mo:r.controlAsset!==mo))continue;let o=i.get(r.controlId)||[];o.push(r.guid),i.set(r.controlId,o)}return i}function Gf(t,e,i,r){let n=Jg(e,i),o=new Map;Ae(t.root,s=>{n.has(s.id)&&(o.set(s,s.scriptMappingIds),s.scriptMappingIds=n.get(s.id))});try{return r()}finally{for(let[s,a]of o)a===void 0?delete s.scriptMappingIds:s.scriptMappingIds=a}}function Sa(t){let e=Number(t.meta?.giaModeFlag);return Number.isSafeInteger(e)&&e>=0?{modeFlag:e}:{}}function xa(t){let e=t.meta?.gameVersion;return!e||e==="7.0.50"?An:e}function qf(t,e,i,r,n=[]){let o=vr(t,!0),s=o.filter(({parent:c})=>c?.kind==="server-container");if(!s.length)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u6A21\u677F");let a=new Set(s.map(({node:c})=>c.id)),l=o.filter(({node:c})=>!a.has(c.id)),u=o.map(({node:c})=>e.get(c.id));return Gf(t,n,mo,()=>({graph:s.map(({node:c,parent:f})=>go(c,f,e,u,i,!1,!0,!0,!0)),accessories:l.map(({node:c,parent:f})=>go(c,f,e,u,i,!1,!1,!0,!0)),filePath:r||wa(t,!0),gameVersion:xa(t),...Sa(t)}))}function Bf(t,e,i,r,n){let o=vr(t),s=[o[0],...o.slice(1).reverse()],a=s.map(({node:l})=>e.get(l.id));return Gf(t,i.scripts,qg,()=>({graph:[go(t.root,null,e,a,r,!0,!1,!1,!0),...i.units||[]],accessories:s.map(({node:l,parent:u})=>go(l,u,e,a,r,!1,!1,!1,!0)),filePath:n||wa(t,!1),gameVersion:xa(t),...Sa(t)}))}function jf(t,e){let i=_a(t),r=e(i);if(!r.valid)throw new Error(`GIA compatibility validation failed:
|
|
103
116
|
${r.errors.join(`
|
|
104
|
-
`)}`);return i}function
|
|
117
|
+
`)}`);return i}function Vf(t,e={}){Ae(t.root,Ti);let i=[];Ht(t,{warnings:i});let r=Qr(se(t)),n=t.meta?.assetType==="client-control-template",o;if(n)o=qf(t,r,i,void 0,e.scripts||[]);else{let a=Ia(e.scripts||[],new Set(r.values()));i.push(...a.warnings),o=Bf(t,r,a,i)}return{buffer:jf(o,n?Ca:ka),warnings:[...new Set(i)]}}function Uf(t,e,i={}){Ae(t.root,Ti),e&&Ae(e.root,Ti);let r=["\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"];e&&Ht(e,{warnings:r});let n=e?.root?.children||[];n.length||r.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 o=new Set,s=se(t),a=e?se(e):null,l=Qr(s,o),u=Ia(i.scripts||[],o);r.push(...u.warnings.filter(I=>I!==Yf));let c=String(i.fileName||`${s.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),f=wa({...s,meta:{...s.meta,giaFileName:c}},!1),h=Bf(s,l,u,r,f),m={graph:[],accessories:[]};if(n.length&&a){let I=Qr({...a,meta:{...a.meta,assetType:"client-control-template"}},o);m=qf(a,I,r,f,u.scripts)}let g={graph:[...h.graph,...m.graph],accessories:[...h.accessories,...m.accessories],filePath:f,gameVersion:xa({meta:{gameVersion:t.meta?.gameVersion||e?.meta?.gameVersion}}),...Sa(t)};return{buffer:jf(g,ka),warnings:[...new Set(r)]}}var zi=69,Hf=30,Yf="\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 Zg(t){return(String(t.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${t.id||""}`}function _a(t){let e=Ct.verify(t);if(e)throw new Error(`GIA encode validation failed: ${e}`);let i=Ct.encode(Ct.create(t)).finish(),r=Buffer.alloc(wi+i.length+va);return r.writeUInt32BE(r.length-4,0),r.writeUInt32BE(1,4),r.writeUInt32BE(Ff,8),r.writeUInt32BE(3,12),r.writeUInt32BE(i.length,16),Buffer.from(i).copy(r,wi),r.writeUInt32BE(Df,wi+i.length),r}function Ia(t,e=new Set){let i=(t||[]).filter(s=>s.path||s.source).map(s=>({...s})),r=[];for(let s of i){let a=Number(s.guid);vt(a)&&!e.has(a)?(e.add(a),s.guid=a):r.push(s)}for(let s of r){let a=si(e);e.add(a),s.guid=a}let n=[];return(t||[]).some(s=>s.controlId)&&n.push(Yf),{units:i.map(s=>{let a=Zg(s),l=String(s.path||"").replace(/\\/g,"/"),u=/\.lua$/iu.test(l)?l:`${l||a}.lua`,c={id:s.guid,name:a,filePath:u};return String(s.source||"")&&(c.source=String(s.source)),{id:{class:Hf,id:s.guid},name:a,which:zi,script:{mapping:c}}}),warnings:n,scripts:i}}function Xf(t){let e=Ia(t);if(!e.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:e.units,filePath:`114514-${Math.floor(Date.now()/1e3)}-1073741832-\\script.gia`,gameVersion:"7.0.51"},r=_a(i),n=Qg(r);if(!n.valid)throw new Error(`GIA compatibility validation failed:
|
|
105
118
|
${n.errors.join(`
|
|
106
|
-
`)}`);return{buffer:r,warnings:[...new Set(t.warnings)]}}function Kr(e){return Pe.toObject(Pe.decode(Yi(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function ro(e){try{let i=Kr(e).graph||[];return i.length>0&&i.every(r=>Number(r.which)===Mt)}catch{return!1}}function no(e){let t=(e.graph||[]).filter(n=>Number(n.which)===Mt),i=[],r=t.map((n,a)=>{let o=n.script?.mapping||{},s=Number(n.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[n,a]of r.entries())a.path&&!/\.lua$/iu.test(a.path)&&i.push(`\u7B2C ${n+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:r,warnings:i}}function ao(e){let t=Kr(e),i=no(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 dc(e){let t=[],i;try{i=Kr(e)}catch(n){return{valid:!1,errors:[n?.message||String(n)],scriptCount:0}}let r=i.graph||[];return r.length||t.push("Root.graph \u4E3A\u7A7A"),(i.accessories||[]).length&&t.push("script.gia \u4E0D\u5E94\u5305\u542B accessories"),r.forEach((n,a)=>{let o=`\u5355\u5143 ${a+1}`;Number(n.which)!==Mt&&t.push(`${o}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${n.which}`),Number(n.id?.class)!==eo&&t.push(`${o}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${n.id?.class}`),Number(n.id?.type??0)!==0&&t.push(`${o}: id.type \u5E94\u7F3A\u7701`);let s=n.script?.mapping;if(!s){t.push(`${o}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(n.id?.id)<=0&&t.push(`${o}: GraphUnit.id.id \u975E\u6CD5`),Number(s.id)!==Number(n.id?.id)&&t.push(`${o}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(s.name||"")!==String(n.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:r.length}}function Yi(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Qe+Br)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==Ya||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-Qe-Br)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Qe+i)!==Ba)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(Qe,Qe+i)}function de(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function hc(e){let t=de(e,"transform")?.multiPlatform,i={};for(let n of t?.platforms||[]){let a=tc[n.platformType||0],o=n.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 r=i.KEYBOARD||i[Object.keys(i)[0]];if(!r)throw new Error(`GIA \u63A7\u4EF6 ${e.name||e.id?.id} \u7F3A\u5C11\u591A\u5E73\u53F0\u53D8\u6362`);for(let n of ce)i[n]||(i[n]=structuredClone(r));return i}function Hi(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 Ha(e,{reverseSiblings:t=!1,idOffset:i=0}={}){if(!e.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let r=new Map(e.map((l,u)=>[l.id?.id,`n${i+u+1}`])),n=new Map,a=new Map,o=[];for(let l of e){let u=Hi(l),d=de(l,"textConfig"),h=de(l,"imageSlot"),p=de(l,"image"),m=de(l,"buttonPreset"),y=de(l,"gridView"),x=de(l,"genericSlot"),E=de(l,"footerSlot"),I=de(l,"cursorConfig"),O=de(l,"keyHint"),N=de(l,"containerNodeSlot"),H=de(l,"templateRefSlot"),B=de(l,"effectSlot"),Y=de(l,"fullscreenEffectSlot"),z=W(u,{id:r.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||u,visible:de(l,"field14")?.field17?.initiallyHidden!==!0,active:de(l,"field14")?.initiallyInactive!==!0,canControllerFocus:E?.field505===1,scriptMappingIds:(x?.field502||[]).map(b=>Number(b?.field1?.id)).filter(b=>Number.isSafeInteger(b)&&b>0),transformByPlatform:hc(l),syncAllDevices:de(l,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:x?.field501??0,footerField505:E?.field505??0,...u==="textbox"||u==="textwindow"?{textField501:d?.field501??20,textField503:d?.field503??12,textAlign:d?.align??0,...[void 0,0,1,2].includes(d?.verticalAlign)?{}:{textVerticalAlign:d.verticalAlign},...u==="textwindow"?{textField511:d?.field511??1,textViewField502:d?.viewFlags?.field502??1,textViewField503:d?.viewFlags?.field503??1}:{}}:{},...u==="cursor"?{cursorField501:I?.field501??0}:{},...u==="reference"?{templateRefSlot:H??""}:{},...u==="grid"?{gridField501:y?.field501??1,gridField507:y?.field507??1,gridField508:y?.field508??1,gridField509:y?.field509??1,gridField511:y?.field511??5,gridField512:y?.field512??1}:{},...u==="keyhint"?{keyHintField501:O?.field501??1,keyHintField502:O?.field502??1}:{},...u==="image"?{imageSlotType:h?.imageType??0,imageField502:p?.field502??1,imageField504:p?.field504??1,imageField505:p?.field505??1,imageField507:p?.field507??2,imageFillType:p?.fillType??1}:{},...u==="animation"?{effectSlot:B??""}:{},...u==="fullscreen"?{fullscreenEffectSlot:Y??""}:{}},...u==="container"?{isolateNavigation:N?.isolateNavigation===!0,disableKeyEventPassthrough:N?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:N?.disableCursorEventPassthrough===!0,showCursor:N?.showCursor===!0}:{},...u==="cursor"?{raycastTarget:I?.field501===1}:{},...u==="textbox"||u==="textwindow"?{text:d?.text?.value??"",fontSize:d?.fontSize??20,minimumFontSize:d?.minimumFontSize??20,adaptiveFontSize:d?.adaptive===1,fontColor:d?.color??4294967295,bgColor:d?.color2??0,enableOutline:d?.outlineOff!==1,outlineColor:d?.color3??858993459,horizontalAlignment:d?.align===1?"Middle":d?.align===2?"Right":"Left",verticalAlignment:{0:"Top",1:"Middle",2:"Bottom"}[d?.verticalAlign??0]||"Top",...u==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...u==="image"?{imageSource:"StaticReference",imageId:h?.assetId??0,imageType:h?.imageType===1?"Stretch":"Basic",imageColor:Number.isFinite(h?.field502)?h.field502>>>0:4294967295,enableMask:p?.enableMask===1,enableSoftEdge:p?.enableSoftEdge===1,enableFill:p?.enableFill===1,softEdgeMode:p?.softEdgePixel===1?"Pixel":"Percentage",softEdgeWidthX:p?.border?.field501??8,softEdgeWidthY:p?.border?.field502??8,horizontalSoftRange:p?.field512??85,verticalSoftRange:p?.field513??85,fillType:{1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[p?.fillType]||"Horizontal",fillAmount:Number.isFinite(p?.field508)?Math.max(0,Math.min(1,p.field508/100)):p?.enableFill===1?0:1,reverseMaskArea:p?.reverseMask===1}:{},...u==="button"?{interactable:m?.interactable===1,raycastTarget:m?.raycastTarget===1,clickAudioId:m?.clickAudioId??50888}:{},...u==="grid"?{cellSizeX:y?.cellSize?.field501??50,cellSizeY:y?.cellSize?.field502??50,spacingX:y?.gap?.field501??8,spacingY:y?.gap?.field502??8,padding1X:y?.padding1?.field501??20,padding1Y:y?.padding1?.field502??20,padding2X:y?.padding2?.field501??20,padding2Y:y?.padding2?.field502??20,previewCount:y?.field511??5}:{},...u==="reference"?{referencedPrefabId:H??""}:{},...u==="keyhint"?{keyboardKeyCode:O?.field502??null,controllerKeyCode:O?.field501??null}:{},...u==="animation"?{animationId:B??""}:{},...u==="fullscreen"?{animationId:Y??""}:{}});n.set(l.id?.id,z),(u==="textbox"||u==="textwindow")&&![void 0,0,1,2].includes(d?.align)&&o.push(`${z.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${d.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(u==="textbox"||u==="textwindow")&&![void 0,0,1,2].includes(d?.verticalAlign)&&o.push(`${z.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${d.verticalAlign} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),u==="image"&&![void 0,0,1,2,3,4,5].includes(p?.fillType)&&o.push(`${z.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${p.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),u==="button"&&a.set(z.id,{unavailableChildId:m?.disabledChild,hoverChildId:m?.hoverChild,pressedChildId:m?.pressedChild,selectedChildId:m?.selectedChild})}let s=[],c=new Set;for(let l of e){let u=n.get(l.id?.id),d=(l.ui?.content?.children||[]).map(h=>n.get(h)).filter(Boolean);if(d.length){u.children=t?d.slice().reverse():d;for(let h of d)c.add(h.id)}}for(let l of e){let u=n.get(l.id?.id),d=l.ui?.content?.parent||0,h=n.get(d);h?c.has(u.id)||(t?h.children.unshift(u):h.children.push(u)):s.push(u)}for(let[l,u]of a){let d=[...n.values()].find(h=>h.id===l);for(let[h,p]of Object.entries(u))d[h]=r.get(p)||null}return{nodes:n,rootCandidates:s,warnings:o}}function oo(e){let t=Yi(e),i=Pe.toObject(Pe.decode(t),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),r=i.graph||[];if(!r.some(m=>m.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let n=r.find(m=>m.which===21)||null,a=r.filter(m=>Number(m.which)===70),o=i.accessories||[],s=new Set((n?.relatedIds||[]).map(m=>m.id||0)),c=n?s.size?o.filter(m=>s.has(m.id?.id||0)):o:[],l=a.length?[...a,...o.filter(m=>!s.has(m.id?.id||0))]:n?[]:[...r,...o];if(!c.length&&!l.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let u=["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"],d=no(i);u.push(...d.warnings);let h=null,p=null;if(c.length){let m=Ha(c,{reverseSiblings:!0,idOffset:0});u.push(...m.warnings);let y=m.rootCandidates.find(E=>E.kind==="container")||m.rootCandidates[0];if(!y)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let x=W("server-container",{id:"sc1",guid:n?.id?.id||0,name:n?.name||"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",giaRelatedGuids:(n?.ui?.content?.info||[]).find(E=>E.field501===4&&E.field502===4)?.related?.value||[]});x.children=[y],m.rootCandidates.length>1&&u.push(`\u68C0\u6D4B\u5230 ${m.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${y.name}\u201D\u4E3A\u6839\u7684\u6811\u3002`),h={version:1,layoutSchemaVersion:pe,meta:{name:n?.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:y.id,script:{controlId:y.id,path:"",source:""},root:x}}if(l.length){let m=Ha(l,{reverseSiblings:!1,idOffset:1e3});if(u.push(...m.warnings),!m.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let y=W("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});y.children=m.rootCandidates,p={version:1,layoutSchemaVersion:pe,meta:{name:m.rootCandidates.length===1?m.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:m.rootCandidates[0].id,script:{controlId:m.rootCandidates[0].id,path:"",source:""},root:y},He(p,{warnings:u}),h||(h=p)}return{project:h,clientProject:p&&h!==p?p:void 0,scripts:d.scripts,warnings:u,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(n&&a.length)}}}function Jr(e){let t=Yi(e),i=Pe.toObject(Pe.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),r=i.graph||[],n=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=r.filter(p=>p.which===70).map(p=>{let m=Hi(p),y=p.ui?.content?.info||[],x=y.find(O=>O.field501===2&&O.field502===6)?.index?.value,E=y.find(O=>O.field501===4&&O.field502===4),I=E?.related?.value||[];return ke(x)||a.push(`${p.name}: Info.index=${x??"<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:x,relatedPresent:!!E,relatedGuids:I}}),u=new Map;for(let p of l){if(!ke(p.actualIndex))continue;let m=u.get(p.actualIndex);m?a.push(`${p.name}: \u72EC\u7ACB\u6A21\u677F\u8D44\u4EA7\u7F16\u53F7 ${p.actualIndex} \u4E0E ${m.name} \u91CD\u590D`):u.set(p.actualIndex,p)}l.length||a.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let d=0,h=0;for(let p of[...r,...n]){if(!p.ui?.content)continue;let m=p.id?.id||0,y=p.ui.content,x=Hi(p),E=r.includes(p)&&p.which===70,I=`${p.name||"<unnamed>"}(${m||"<missing-guid>"})`;!Number.isSafeInteger(m)||m<=0||m>2147483647?a.push(`${I}: GraphUnit GUID \u975E\u6CD5`):s.has(m)?a.push(`${I}: GUID \u4E0E ${s.get(m).name||"<unnamed>"} \u91CD\u590D`):s.set(m,p),(p.id?.class!==1||p.id?.type!==8)&&a.push(`${I}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),y.guid!==m&&a.push(`${I}: content.guid=${y.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),E&&p.which!==70&&a.push(`${I}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!E&&p.which!==15&&a.push(`${I}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let O=y.info||[],N=O.find(_=>_.field501===1&&_.field502===5),H=O.find(_=>_.field501===2&&_.field502===6);N?.guid?.value!==m&&a.push(`${I}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),ke(H?.index?.value)||a.push(`${I}: Info.index=${H?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let B=O.find(_=>_.field501===4&&_.field502===4);E&&!B&&a.push(`${I}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!E&&B&&a.push(`${I}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let Y=ja[x],z=y.data||[],b=z.map(_=>`${_.field501}/${_.field502}`),A=Y?.map(([_])=>_)||[];Y?JSON.stringify(b)!==JSON.stringify(A)&&a.push(`${I}: Data \u69FD\u4F4D\u987A\u5E8F ${b.join(",")}\uFF0C\u5E94\u4E3A ${A.join(",")}`):a.push(`${I}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${x}`);for(let _=0;_<Math.min(z.length,Y?.length||0);_+=1){let $=z[_],[V,re,X]=Y[_];if(o($,re)||a.push(`${I}: Data ${V} \u7F3A\u5C11 ${re} \u5206\u652F`),!X)continue;o($.details,X)||a.push(`${I}: Details ${V} \u7F3A\u5C11 ${X} \u5206\u652F`);let te=La[V];($.details?.field501!==te||$.details?.field502!==$.field502||$.details?.field503!==1)&&a.push(`${I}: Details ${V} \u6807\u8BB0\u5E94\u4E3A ${te}/${$.field502}/1`);let Ae=$.details?.nodeRef;(Ae?.class!==1||Ae?.type!==8||Ae?.id!==m)&&a.push(`${I}: Details ${V} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let S=(p.ui.content.data||[]).find(_=>_.field501===4&&_.field502===86);S&&(o(S.field14,"field17")?d+=1:a.push(`${I}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),o(S.details?.field14,"field17")?d+=1:a.push(`${I}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let C=(p.ui.content.data||[]).find(_=>_.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];C.length!==4&&a.push(`${I}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${C.length}\uFF0C\u5E94\u4E3A 4`);let F=C.map(_=>_.platformType||0);JSON.stringify(F)!==JSON.stringify([0,1,2,3])&&a.push(`${I}: \u5E73\u53F0\u987A\u5E8F ${F.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let k=(p.ui.content.data||[]).find(_=>_.details?.transform)?.details?.transform;k?.multiPlatform?.field502!==ri[x]&&a.push(`${I}: \u53D8\u6362 preset=${k?.multiPlatform?.field502??"<missing>"}\uFF0C${x} \u5E94\u4E3A ${ri[x]}`);for(let _ of C)o(_.transform,"field508")?h+=1:a.push(`${I}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);c.push({id:m,name:p.name||"",kind:x,template:E,parent:y.parent||0,children:[...y.children||[]],relatedIds:(p.relatedIds||[]).map(_=>_.id||0),dataSignatures:b})}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 y=s.get(p.parent);y?(y.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 y of p.children){let x=s.get(y);x?(x.ui?.content?.parent||0)!==p.id&&a.push(`${m}: child=${y} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):a.push(`${m}: child=${y} \u4E0D\u5B58\u5728`)}}return{valid:a.length===0,errors:a,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:l.length,accessoryCount:n.length,templates:l,units:c,explicitEmpty:{field17:d,rectField508:h}}}function Zr(e){let t=Yi(e),i=Pe.toObject(Pe.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),r=(i.graph||[]).filter(k=>k.ui?.content&&Number(k.which)===21),n=(i.graph||[]).filter(k=>Number(k.which)===70),a=(i.graph||[]).filter(k=>Number(k.which)===Mt),o=(i.accessories||[]).filter(k=>k.ui?.content),s=[],c=(k,_)=>k!=null&&Object.prototype.hasOwnProperty.call(k,_);/^\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>"}`),r.length!==1&&s.push(`\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F UIControlGroup \u6570\u91CF=${r.length}\uFF0C\u5E94\u4E3A 1`);let l=(i.graph||[]).filter(k=>{let _=Number(k.which);return _===Mt||_===70||_===21?!1:!k.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 u=r[0];if(!u)return{valid:!1,errors:s,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:o.length,controls:[],scriptCount:a.length,explicitEmpty:{field17:0,rectField508:0}};let d=[u,...n,...o],h=new Map;for(let k of d){let _=k.id?.id||0,$=`${k.name||"<unnamed>"}(${_||"<missing-guid>"})`;!Number.isSafeInteger(_)||_<=0||_>2147483647?s.push(`${$}: GraphUnit GUID \u975E\u6CD5`):h.has(_)?s.push(`${$}: GUID \u91CD\u590D`):h.set(_,k),(k.id?.class!==1||k.id?.type!==8)&&s.push(`${$}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),k.ui?.content?.guid!==_&&s.push(`${$}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let p=u.id?.id||0,m=u.ui.content,y=`${u.name||"<unnamed>"}(${p})`;u.which!==21&&s.push(`${y}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let x=m.info||[];x.find(k=>k.field501===1&&k.field502===5)?.guid?.value!==p&&s.push(`${y}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),x.find(k=>k.field501===2&&k.field502===6)?.index?.value!==1&&s.push(`${y}: Info.index \u5FC5\u987B\u4E3A 1`);let E=x.find(k=>k.field501===4&&k.field502===4);E||s.push(`${y}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let I=0,O=0,N=(k,_,$,V=!1)=>{let re=k.id?.id||0,X=`${k.name||"<unnamed>"}(${re})`,te=k.ui.content.data||[],Ae=te.map(ae=>`${ae.field501}/${ae.field502}`),Ct=$.map(([ae])=>ae);JSON.stringify(Ae)!==JSON.stringify(Ct)&&s.push(`${X}: Data \u69FD\u4F4D\u987A\u5E8F ${Ae.join(",")}\uFF0C\u5E94\u4E3A ${Ct.join(",")}`);for(let ae=0;ae<Math.min(te.length,$.length);ae+=1){let Ne=te[ae],[$e,Lt,Xt]=$[ae];if(c(Ne,Lt)||s.push(`${X}: Data ${$e} \u7F3A\u5C11 ${Lt} \u5206\u652F`),!Xt)continue;c(Ne.details,Xt)||s.push(`${X}: Details ${$e} \u7F3A\u5C11 ${Xt} \u5206\u652F`);let Le=La[$e];(Ne.details?.field501!==Le||Ne.details?.field502!==Ne.field502||Ne.details?.field503!==1)&&s.push(`${X}: Details ${$e} \u6807\u8BB0\u5E94\u4E3A ${Le}/${Ne.field502}/1`);let qt=Ne.details?.nodeRef;(qt?.class!==1||qt?.type!==8||qt?.id!==re)&&s.push(`${X}: Details ${$e} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let jt=te.find(ae=>ae.field501===4&&ae.field502===(V?23:86)),ne=V?"empty15":"field17";c(jt?.field14,ne)?V||(I+=1):s.push(`${X}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${ne} \u7A7A\u4E32`),c(jt?.details?.field14,ne)?V||(I+=1):s.push(`${X}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${ne} \u7A7A\u4E32`);let Me=te.find(ae=>ae.details?.transform)?.details?.transform,at=Me?.multiPlatform?.platforms||[];at.length!==4&&s.push(`${X}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${at.length}\uFF0C\u5E94\u4E3A 4`);let Ei=at.map(ae=>ae.platformType||0);JSON.stringify(Ei)!==JSON.stringify([0,1,2,3])&&s.push(`${X}: \u5E73\u53F0\u987A\u5E8F ${Ei.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let Ai=V?ri["server-container"]:ri[_];Me?.multiPlatform?.field502!==Ai&&s.push(`${X}: \u53D8\u6362 preset=${Me?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${Ai}`);for(let ae of at)c(ae.transform,"field508")?O+=1:s.push(`${X}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return Ae};N(u,"server-container",ic,!0);let H=(u.relatedIds||[]).map(k=>k.id||0),B=new Set(H),Y=o.filter(k=>B.has(k.id?.id||0)),z=Y.map(k=>k.id?.id||0);JSON.stringify(H)!==JSON.stringify(z)&&s.push(`${y}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let b=m.data?.find(k=>k.details?.rootChildRef)?.details?.rootChildRef?.guid||0,A=h.get(b);(!A||!Y.includes(A))&&s.push(`${y}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),z[0]!==b&&s.push(`${y}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let S=[];for(let k of Y){let _=k.id?.id||0,$=k.ui.content,V=`${k.name||"<unnamed>"}(${_})`,re=Hi(k);k.which!==15&&s.push(`${V}: which \u5FC5\u987B\u4E3A UIControl(15)`);let X=$.info||[];(X.length!==1||X[0]?.field501!==1||X[0]?.field502!==5||X[0]?.guid?.value!==_)&&s.push(`${V}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let te=ja[re];te||s.push(`${V}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${re}`);let Ae=te?N(k,re,te):[];S.push({id:_,name:k.name||"",kind:re,parent:$.parent||0,children:[...$.children||[]],relatedIds:(k.relatedIds||[]).map(Ct=>Ct.id||0),dataSignatures:Ae})}let C=S.find(k=>k.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 F=new Map(S.map(k=>[k.id,k]));for(let k of S){let _=`${k.name}(${k.id})`;if(JSON.stringify(k.relatedIds)!==JSON.stringify(k.children)&&s.push(`${_}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),k.id!==b){let $=F.get(k.parent);$?$.children.includes(k.id)||s.push(`${_}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):s.push(`${_}: parent=${k.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let $ of k.children){let V=F.get($);V?V.parent!==k.id&&s.push(`${_}: child=${$} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):s.push(`${_}: child=${$} \u4E0D\u5B58\u5728`)}}if(n.length){let k=Jr(qr({...i,graph:n,accessories:o.filter(_=>!B.has(_.id?.id||0))}));s.push(...k.errors.map(_=>`\u5BA2\u6237\u7AEF\u6A21\u677F: ${_}`))}return{valid:s.length===0,errors:s,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:p,name:u.name||"",relatedGuids:E?.related?.value||[],rootGuid:b},accessoryCount:o.length,controls:S,scriptCount:a.length,explicitEmpty:{field17:I,rectField508:O}}}function so(e,t=[]){if(!e||e.layoutSchemaVersion===pe)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:pe};let i=structuredClone(e),r=0;return Q(i.root,n=>{let a=n.transformByPlatform||{},o=n.transformByCanvas||{},s=n.name||n.id;for(let l of Object.keys(a))if(!ce.includes(l))throw new Error(`${s}: unknown platform ${l}`);let c={};for(let l of ce){let u=kt[l],d=J[u].platform,h=Object.keys(J).filter(x=>J[x].platform===d&&o[x]),p=o[u]?u:h[0],m=l==="CONTROLLER_CONSOLE"?c.KEYBOARD:l==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,y=a[l]??m??(p?o[p]:null);if(c[l]=y?De(y):$r(n.kind),y||t.push(`${s}: ${l} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!a[l]&&!m&&p&&p!==u&&t.push(`${s}: \u7F3A\u5C11 ${u}\uFF0C\u5DF2\u91C7\u7528 ${p} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!m)for(let x of h)JSON.stringify(c[l])!==JSON.stringify(De(o[x]))&&t.push(`${s}: ${x} \u4E0E ${l} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${a[l]?"\u5DF2\u6709\u5E73\u53F0":p}\u53C2\u6570`)}qe(c,`${s}.transformByPlatform`),n.transformByPlatform=c,delete n.transformByCanvas,r++}),i.layoutSchemaVersion=pe,t.unshift(`\u5DF2\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E03\u5C40\uFF1A${r} \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 Qr(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 tn(e,t,i,r=e.canvasId){let n=Ke(e.root,t);return!n||n.kind==="server-container"?ye(r):i[n.id]||ye(r)}function et(e,{warnings:t=[]}={}){if(!e)return ut();if(e=so(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==pe)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${pe} \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",r=i==="client-control-template"?Rt():ut(),n={layoutSchemaVersion:pe,version:Number.isSafeInteger(e.version)&&e.version>0?e.version:1,meta:{name:String(e.meta?.name||r.meta.name),assetType:i,sourceFormat:String(e.meta?.sourceFormat||r.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(e.meta?.giaNextAssetIndex)&&e.meta.giaNextAssetIndex>=2?{giaNextAssetIndex:e.meta.giaNextAssetIndex}:{},...Number.isSafeInteger(e.meta?.giaAssetIndexSchemaVersion)&&e.meta.giaAssetIndexSchemaVersion>0?{giaAssetIndexSchemaVersion:e.meta.giaAssetIndexSchemaVersion}:{},...Number.isSafeInteger(Number(e.meta?.giaModeFlag))&&Number(e.meta.giaModeFlag)>=0?{giaModeFlag:Number(e.meta.giaModeFlag)}:{}},canvasId:e.canvasId&&J[e.canvasId]?e.canvasId:Oi,selectedId:e.selectedId||r.selectedId,root:Hr(e.root||r.root)};return ho(n),He(n,{warnings:t}),n}function ho(e){let t=new Set;Q(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=Vr(e.root).id)}function lo(e){return We(Tt(e))}function mc(e,t){let i=!1;return Q(e,r=>{r.id===t&&(i=!0)}),i}function pc(e,t,i,r){let a=Ze(e.root,e.canvasId).boxes[t.id],o=i.children.findIndex(d=>d.id===t.id);if(o<0)throw new Error("reparent: source node is not attached");if(i.children.splice(o,1),r.children.push(t),!a)return;let s=Ze(e.root,e.canvasId),c=r.kind==="server-container"?ye(e.canvasId):s.boxes[r.id]||ye(e.canvasId),l=Je(t.transformByPlatform,e.canvasId),u=ot(c,l,{posX:a.centerX,posY:a.centerY,width:a.width,height:a.height});Nt(e,t,u)}function gc(e,t){return e.meta.assetType!=="client-control-template"?Yr(e.root,t):(e.root.children||[]).flatMap(i=>Yr(i,t))}function mo(e,t){let i=$a(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let r=ii(e),n=new Set;return r&&r.kind!=="server-container"&&Q(r,a=>n.add(a.id)),i.filter(a=>n.has(a.id))}function po(e){let{canvas:t,boxes:i}=Ze(e.root,e.canvasId),r=ai(e),n=fe(e.root,e.selectedId),a=n?i[n.id]:null;return G({layoutSchemaVersion:pe,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:J[e.canvasId].platform,label:J[e.canvasId].label,presets:Object.values(J).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"&&ii(e)?.id||""},tree:gc(e,r),boxes:mo(e,i),inspector:Ga(n,e.canvasId,a||t,r),root:e.root})}function Nt(e,t,i){let r=Ze(e.root,e.canvasId),n=tn(e,t.id,r.boxes),a={};if(t.syncAllDevices!==!1)for(let o of ce){if(o===st(e.canvasId))continue;let s=kt[o],c=Ze(e.root,s,o);a[o]=tn(e,t.id,c.boxes,s)}t.transformByPlatform=za({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:n,targetParentBoxByPlatform:a})}var yc=new Set(["name","active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text","imageSource","imageType","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","itemPrefabId","layoutConstraintFixedCount"]),bc=new Set(["posX","posY","width","height"]),vc=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function Sc(e){if(typeof e=="number"&&Number.isFinite(e))return e>>>0;if(typeof e=="string"){let t=e.trim();if(t.startsWith("#")){let r=t.slice(1);if(r.length===6)return(4278190080|parseInt(r,16))>>>0;if(r.length===8)return parseInt(r,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 Ye(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function co(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 wc=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode","itemPrefabId","layoutConstraintFixedCount"]),Ic=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),xc=new Set(["name","imageSource","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),uo=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),fo={imageSource:["StaticReference","Prefab"],imageType:["Basic","Stretch",null],scrollDirection:["Horizontal","Vertical"],layoutConstraint:["AutoWrap","Fixed"],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 Cc(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&fe(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:r}=Ze(e.root,e.canvasId),n=mo(e,r),a=Va(n,Number(t.x),Number(t.y));return a&&(e.selectedId=a),e}if(i==="setCanvas")return t.canvasId&&J[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 r=t.assetType==="client-control-template"?Rt():ut();return e.version=r.version,e.meta=r.meta,e.canvasId=r.canvasId,e.selectedId=r.selectedId,e.root=r.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 r=W(t.kind,{id:Gr(e.root),guid:lo(e.root),name:t.name||`\u65B0${t.kind==="container"?"\u5BB9\u5668\u8282\u70B9":t.kind}\u6A21\u677F`});return e.root.children.push(r),e.selectedId=r.id,e}if(i==="add"){let r=fe(e.root,t.parentId||e.selectedId);if(!r)throw new Error("add: parent not found");let n=Oa(r,t.kind,{id:Gr(e.root),guid:lo(e.root),name:t.name});return e.selectedId=n.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 r=fe(e.root,t.id||e.selectedId),n=r?Ke(e.root,r.id):null,a=fe(e.root,t.parentId);if(!r||r.kind==="server-container"||!n)throw new Error("reparent: node not found");if(!a)throw new Error("reparent: parent not found");if(a.id===r.id||mc(r,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"&&n.kind==="server-container")return e;if(n.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 pc(e,r,n,a),e.selectedId=r.id,e}if(i==="moveSibling"){let r=fe(e.root,t.id||e.selectedId),n=r?Ke(e.root,r.id):null;if(!r||!n)throw new Error("moveSibling: node not found");let a=n.children.findIndex(c=>c.id===r.id),o=t.direction==="up"?-1:t.direction==="down"?1:0,s=a+o;return!o||s<0||s>=n.children.length||(n.children.splice(a,1),n.children.splice(s,0,r),e.selectedId=r.id),e}if(i==="remove"){let r=t.id||e.selectedId,n=Ke(e.root,r);if(n?.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 Fa(e.root,r)&&(Q(e.root,a=>{if(a.kind==="button")for(let o of uo)a[o]&&!fe(e.root,a[o])&&(a[o]=null)}),e.selectedId=n?n.id:e.root.id),e}if(i==="set"){let r=fe(e.root,t.id||e.selectedId);if(!r)throw new Error("set: node not found");let n=t.key;n==="reverseMask"&&(n="reverseMaskArea");let a=t.value;if(n.startsWith("giaRaw.")){let l=n.slice(7);if(!l||l.includes("."))throw new Error("invalid raw GIA field path");let u=Ra(r.kind,l);if(!u)throw new Error(`unknown raw GIA field for ${r.kind}: ${l}`);if(r.giaRaw||={},r.giaRaw[l]=Or(u,a),l==="footerField505"&&[0,1].includes(r.giaRaw[l])&&(r.canControllerFocus=r.giaRaw[l]===1),r.kind==="cursor"&&l==="cursorField501"&&[0,1].includes(r.giaRaw[l])&&(r.raycastTarget=r.giaRaw[l]===1),(r.kind==="textbox"||r.kind==="textwindow")&&l==="textAlign"){let d={0:"Left",1:"Middle",2:"Right"}[r.giaRaw[l]];d&&(r.horizontalAlignment=d)}if(r.kind==="image"&&l==="imageFillType"){let d={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[r.giaRaw[l]];d&&(r.fillType=d)}return r.kind==="keyhint"&&l==="keyHintField502"&&(r.keyboardKeyCode=r.giaRaw[l]),r.kind==="keyhint"&&l==="keyHintField501"&&(r.controllerKeyCode=r.giaRaw[l]),e}if(n==="syncAllDevices"){if(r.syncAllDevices=co(a),r.syncAllDevices){let l=Je(r.transformByPlatform,e.canvasId);Nt(e,r,l)}return e}if(yc.has(n)){if(n.endsWith("Color")&&(a=Sc(a)),wc.has(n)){if(a=Ye(a,n),a<0)throw new Error(`${n} must not be negative`);if((n==="imageId"||n==="clickAudioId"||n==="keyboardKeyCode"||n==="controllerKeyCode")&&(a=Math.trunc(a)),n==="fillAmount"&&a>1)throw new Error("fillAmount must be between 0 and 1")}if(Ic.has(n)&&(a=co(a)),xc.has(n)&&(a=String(a??"")),n==="horizontalAlignment"&&!["Left","Middle","Right"].includes(a))throw new Error("invalid horizontalAlignment");if(n==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(a))throw new Error("invalid verticalAlignment");if(fo[n]&&!fo[n].includes(a))throw new Error(`invalid ${n}`);if(uo.has(n))if(a===""||a===void 0||a===null)a=null;else{a=String(a);let l=fe(e.root,a);if(!l||l===r||l.kind==="server-container"||!(r.children||[]).some(u=>u.id===a))throw new Error(`${n} must reference a direct child of this button`)}if(r.kind==="image"&&(n==="imageSource"||n==="imageId")&&r[n]!==a&&(r.imageType=null,r.giaRaw.imageSlotType=0),r[n]=a,r.kind==="image"&&n==="imageType"&&(r.giaRaw.imageSlotType=a==="Stretch"?1:0),n==="canControllerFocus"&&(r.giaRaw.footerField505=a?1:0),r.kind==="cursor"&&n==="raycastTarget"&&(r.giaRaw.cursorField501=a?1:0),(r.kind==="textbox"||r.kind==="textwindow")&&n==="horizontalAlignment"&&(r.giaRaw.textAlign={Left:0,Middle:1,Right:2}[a]),(r.kind==="textbox"||r.kind==="textwindow")&&n==="verticalAlignment"&&delete r.giaRaw.textVerticalAlign,r.kind==="image"&&n==="fillType"){let l={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[a];l&&(r.giaRaw.imageFillType=l)}return r.kind==="reference"&&n==="referencedPrefabId"&&(r.giaRaw.templateRefSlot=a),r.kind==="grid"&&n==="previewCount"&&(r.giaRaw.gridField511=Math.trunc(a)),r.kind==="keyhint"&&n==="keyboardKeyCode"&&(r.giaRaw.keyHintField502=Math.trunc(a)),r.kind==="keyhint"&&n==="controllerKeyCode"&&(r.giaRaw.keyHintField501=Math.trunc(a)),(r.kind==="animation"||r.kind==="fullscreen")&&n==="animationId"&&(r.giaRaw[r.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=a),e}let{boxes:o}=Ze(e.root,e.canvasId),s=tn(e,r.id,o),c=Je(r.transformByPlatform,e.canvasId);if(n==="anchorType"){let l=en(o[r.id]),u=Ea(c,a);return u=ot(s,u,l),Nt(e,r,u),e}if(n==="rotationZ"){let l={...c,rotation:{...c.rotation,z:Ye(a,n)}};return Nt(e,r,l),e}if(vc.has(n)){let l=en(o[r.id]),u={...c,anchorMin:{...c.anchorMin},anchorMax:{...c.anchorMax},pivot:{...c.pivot}};return n==="anchorMinX"&&(u.anchorMin.x=Ye(a,n)),n==="anchorMinY"&&(u.anchorMin.y=Ye(a,n)),n==="anchorMaxX"&&(u.anchorMax.x=Ye(a,n)),n==="anchorMaxY"&&(u.anchorMax.y=Ye(a,n)),n==="pivotX"&&(u.pivot.x=Ye(a,n)),n==="pivotY"&&(u.pivot.y=Ye(a,n)),Nt(e,r,ot(s,u,l)),e}if(bc.has(n)){let l=en(o[r.id]),u=Ye(a,n);if((n==="width"||n==="height")&&u<0)throw new Error(`${n} must not be negative`);return l[n]=u,Nt(e,r,ot(s,c,l)),e}throw new Error(`set: unknown key ${n}`)}if(i==="replace"){let r=et(t.project);return e.version=r.version,e.meta=r.meta,e.canvasId=r.canvasId,e.selectedId=r.selectedId,e.root=r.root,e}throw new Error(`unknown op ${i}`)}function rn(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,r=JSON.parse(JSON.stringify(e));return Cc(r,t),ho(r),He(r),r.version=i+1,Object.keys(e).forEach(n=>{delete e[n]}),Object.assign(e,r),e}function en(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import kc from"fengari";var{lua:f,lauxlib:ee,lualib:go,to_luastring:Bi,to_jsstring:Ec}=kc,Ac=f.LUA_TNIL,_c=f.LUA_TBOOLEAN,Pc=f.LUA_TNUMBER,Tc=f.LUA_TSTRING,yo=f.LUA_TTABLE,Rc=f.LUA_TFUNCTION,nn=f.LUA_TUSERDATA,Te=f.LUA_OK,bo=new WeakMap,an=Symbol("luaTableEntries"),on={__scriptHostKey:!0};function R(e){return Bi(String(e))}function ft(e,t){bo.set(e,t)}function Ce(e){return bo.get(e)}var oi=class{constructor(t){this.value=t}};function le(e,t,i){if(i instanceof oi){f.lua_pushnumber(e,i.value);return}if(i==null){f.lua_pushnil(e);return}let r=typeof i;if(r==="boolean"){f.lua_pushboolean(e,i);return}if(r==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?f.lua_pushinteger(e,i):f.lua_pushnumber(e,i);return}if(r==="string"){f.lua_pushstring(e,R(i));return}if(r==="function"){Oc(e,t,i);return}if(i&&i[an]){let n=i[an];f.lua_createtable(e,Array.isArray(i)?i.length:0,n.length);for(let[a,o]of n)le(e,t,a),le(e,t,o),f.lua_settable(e,-3);return}if(Array.isArray(i)){f.lua_createtable(e,i.length,0);for(let n=0;n<i.length;n++)le(e,t,i[n]),f.lua_rawseti(e,-2,n+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.__kind==="ServerSignal"){t.pushSignal(e,i);return}if(i&&(i.SetEase||i.Append)){t.pushTween(e,i);return}if(r==="object"){f.lua_createtable(e,0,Object.keys(i).length);for(let[n,a]of Object.entries(i))le(e,t,a),f.lua_setfield(e,-2,R(n));return}f.lua_pushnil(e)}function Z(e,t){if(f.lua_isnil(e,t)||f.lua_type(e,t)===f.LUA_TNONE)return"";if(!f.lua_isstring(e,t)&&f.lua_type(e,t)!==f.LUA_TNUMBER)return`lua_type=${f.lua_type(e,t)}`;let i=f.lua_tostring(e,t);return i==null?"":Ec(i)}function Be(e,t){t=f.lua_absindex(e,t);let i=f.lua_type(e,t);if(i===nn)return Ce(f.lua_touserdata(e,t));if(i===yo){f.lua_pushlightuserdata(e,on),f.lua_rawget(e,t);let r=f.lua_type(e,-1)===nn?f.lua_touserdata(e,-1):null;return f.lua_pop(e,1),r?Ce(r):null}return null}function he(e,t,i){i=f.lua_absindex(e,i);let r=f.lua_type(e,i);if(r===Ac)return null;if(r===_c)return!!f.lua_toboolean(e,i);if(r===Pc)return f.lua_isinteger(e,i)?f.lua_tointeger(e,i):f.lua_tonumber(e,i);if(r===Tc)return Z(e,i);if(r===nn){let n=f.lua_touserdata(e,i);return Ce(n)??n}if(r===Rc)return Mc(e,t,i);if(r===yo){let n=Be(e,i);if(n)return n;let a=[];for(f.lua_pushnil(e);f.lua_next(e,i)!==0;){let l=he(e,t,-2),u=he(e,t,-1);a.push([l,u]),f.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,u]of a)Array.isArray(c)&&Number.isInteger(l)&&l>=1?c[l-1]=u:(typeof l=="string"||typeof l=="number")&&(c[l]=u);return Object.defineProperty(c,an,{value:a}),c}return null}function Mc(e,t,i){t.luaFunctions||(t.luaFunctions=new Map);let r=typeof f.lua_topointer=="function"?f.lua_topointer(e,i):null;if(r!=null&&t.luaFunctions.has(r))return t.luaFunctions.get(r);f.lua_pushvalue(e,i);let n=ee.luaL_ref(e,f.LUA_REGISTRYINDEX),a=Nc(e,t,n);return r!=null&&t.luaFunctions.set(r,a),a}function Nc(e,t,i){let r=(...n)=>{if(r.__luaRef==null)throw new Error("attempt to call a released Lua callback");let a=f.lua_gettop(e);f.lua_rawgeti(e,f.LUA_REGISTRYINDEX,r.__luaRef);for(let l of n)le(e,t,l);if(f.lua_pcall(e,n.length,f.LUA_MULTRET,0)!==Te){let l=Z(e,-1);throw f.lua_settop(e,a),new Error(l)}let s=f.lua_gettop(e)-a,c=[];for(let l=1;l<=s;l++)c.push(he(e,t,a+l));if(f.lua_settop(e,a),c.length!==0)return c.length===1?c[0]:c};return r.__luaRef=i,r.__luaState=e,r}function vo(e){e?.__luaRef!=null&&(e.__luaHolds=(e.__luaHolds||0)+1)}function So(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;if(t.__luaHolds>1){t.__luaHolds-=1;return}let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&ee.luaL_unref(i,f.LUA_REGISTRYINDEX,t.__luaRef),t.__luaRef=null,t.__luaState=null,e?.luaFunctions)for(let[r,n]of e.luaFunctions)n===t&&e.luaFunctions.delete(r)}function Oc(e,t,i){f.lua_pushlightuserdata(e,i),f.lua_pushlightuserdata(e,t),f.lua_pushcclosure(e,function(n){let a=f.lua_touserdata(n,f.lua_upvalueindex(1)),o=f.lua_touserdata(n,f.lua_upvalueindex(2)),s=f.lua_gettop(n),c=[];for(let l=1;l<=s;l++)c.push(he(n,o,l));try{let l=a(...c);if(Array.isArray(l)&&l.__multi){for(let u of l)le(n,o,u);return l.length}return l===void 0?0:(le(n,o,l),1)}catch(l){return f.lua_pushstring(n,R(String(l&&l.message?l.message:l))),f.lua_error(n)}},2)}function wo(e){!e||typeof f.lua_close!="function"||f.lua_close(e)}function Io(e){if(ee.luaL_loadstring(e,R(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
|
|
107
|
-
`)))===Te&&f.lua_pcall(e,0,0,0),f.lua_settop(e,0),f.lua_pushnil(e),f.lua_setglobal(e,R("_VERSION")),f.lua_getglobal(e,R("string")),!f.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])f.lua_pushnil(e),f.lua_setfield(e,-2,R(i));if(f.lua_pop(e,1),f.lua_pushnil(e),f.lua_setglobal(e,R("io")),f.lua_getglobal(e,R("os")),!f.lua_isnil(e,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))f.lua_pushnil(e),f.lua_setfield(e,-2,R(i));f.lua_pop(e,1),f.lua_getglobal(e,R("debug")),f.lua_isnil(e,-1)?f.lua_pop(e,1):(f.lua_getfield(e,-1,R("traceback")),f.lua_newtable(e),f.lua_pushvalue(e,-2),f.lua_setfield(e,-2,R("traceback")),f.lua_setglobal(e,R("debug")),f.lua_pop(e,2)),f.lua_getglobal(e,R("math")),f.lua_isnil(e,-1)||(f.lua_pushcfunction(e,i=>{let r=f.lua_tonumber(i,1);return f.lua_pushboolean(i,Number.isNaN(r)),1}),f.lua_setfield(e,-2,R("isnan")),f.lua_pushcfunction(e,i=>{let r=f.lua_tonumber(i,1);return f.lua_pushboolean(i,r===1/0||r===-1/0),1}),f.lua_setfield(e,-2,R("isinf"))),f.lua_pop(e,1),f.lua_pushnil(e),f.lua_setglobal(e,R("package")),f.lua_pushnil(e),f.lua_setglobal(e,R("load")),f.lua_pushnil(e),f.lua_setglobal(e,R("loadfile")),f.lua_pushnil(e),f.lua_setglobal(e,R("dofile")),f.lua_pushnil(e),f.lua_setglobal(e,R("collectgarbage")),f.lua_pushnil(e),f.lua_setglobal(e,R("coroutine")),f.lua_pushnil(e),f.lua_setglobal(e,R("fengari"))}var Ee=(e,t=0)=>Number.isFinite(Number(e))?Number(e):t,xo=e=>e?.Name||e,Ui=e=>Math.max(0,Math.min(1,Ee(e)));function si(e){let t=e.parent?si(e.parent):[e.runtime.canvasWidth,e.runtime.canvasHeight];return[Math.max(0,(e.anchorMaxX-e.anchorMinX)*t[0]+Ee(e.sizeDeltaX)),Math.max(0,(e.anchorMaxY-e.anchorMinY)*t[1]+Ee(e.sizeDeltaY))]}function li(e){let[t,i]=si(e),r=xo(e.scrollDirection)==="Horizontal",n=Math.max(1,Ee(e.cellSizeX,50)),a=Math.max(1,Ee(e.cellSizeY,50)),o=Math.max(0,Ee(e.spacingX)),s=Math.max(0,Ee(e.spacingY)),c=Math.max(0,Ee(e.padding1X)),l=Math.max(0,Ee(e.padding1Y)),u=Math.max(0,Ee(e.padding2X)),d=Math.max(0,Ee(e.padding2Y)),h=r?i-l-d:t-c-u,p=r?a:n,m=r?s:o,y=xo(e.layoutConstraint)==="Fixed"?Math.max(1,Math.floor(Ee(e.layoutConstraintFixedCount,1))):Math.max(1,Math.floor((h+m)/(p+m))),x=Math.ceil(e.itemCount/y),E=x?r?c+u+x*n+(x-1)*o:l+d+x*a+(x-1)*s:0,I=r?t:i,O=Math.max(0,E-I);return{width:t,height:i,horizontal:r,cellW:n,cellH:a,gapX:o,gapY:s,left:c,top:l,right:u,bottom:d,lanes:y,length:E,viewport:I,max:O,offset:Ui(e.scrollProgress)*O}}function Ot(e){let t=li(e);for(let i=0;i<(e._gridItems?.length||0);i+=1){let r=e._gridItems[i];if(!r.alive||r.parent!==e)continue;let n=Math.floor(i/t.lanes),a=i%t.lanes,o=t.horizontal?n:a,s=t.horizontal?a:n,c=t.left+o*(t.cellW+t.gapX)+t.cellW/2-(t.horizontal?t.offset:0),l=-t.top-s*(t.cellH+t.gapY)-t.cellH/2+(t.horizontal?0:t.offset),u={anchorMinX:0,anchorMaxX:0,anchorMinY:1,anchorMaxY:1,pivotX:.5,pivotY:.5,sizeDeltaX:t.cellW,sizeDeltaY:t.cellH,anchoredPositionX:c,anchoredPositionY:l};Object.entries(u).some(([d,h])=>r[d]!==h)&&(Object.assign(r,u),r.markPlayDirty(!0))}return t}var Co={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},Fc=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],ji=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),Dc=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],zc={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},$c={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"]},Gc=["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"],ko=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Vc={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:ko,cursor:ko,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function ln(e,t){return e.kind==="image"&&t==="imageType"&&e.runtime.canSelectImageType(e.imageId,e.imageSource)?"rw":Fc.includes(t)||(zc[e.kind]||[]).includes(t)?"ro":Dc.includes(t)||($c[e.kind]||[]).includes(t)?"rw":null}var Hc=["localRotationX","localRotationY","localRotationZ"],Ft=Math.PI/180;function Eo(e,t){return[e[3]*t[0]+e[0]*t[3]+e[1]*t[2]-e[2]*t[1],e[3]*t[1]-e[0]*t[2]+e[1]*t[3]+e[2]*t[0],e[3]*t[2]+e[0]*t[1]-e[1]*t[0]+e[2]*t[3],e[3]*t[3]-e[0]*t[0]-e[1]*t[1]-e[2]*t[2]]}function sn(e){if(Object.is(e,-0))return e;let t=(e%360+360)%360,i=Math.round(t*1e6)/1e6;return i>=360?0:i}function Ao(e,t,i){let r=I=>[Math.sin(I*Ft/2),Math.cos(I*Ft/2)],[n,a]=r(e),[o,s]=r(t),[c,l]=r(i),[u,d,h,p]=Eo(Eo([0,o,0,s],[n,0,0,a]),[0,0,c,l]),m=Math.max(-1,Math.min(1,-2*(d*h-p*u))),y,x,E;return Math.abs(m)>.999999?(y=Math.sign(m)*90,x=2*Math.atan2(d,p)/Ft,E=0):(y=Math.asin(m)/Ft,x=Math.atan2(2*(p*d+u*h),1-2*(u*u+d*d))/Ft,E=Math.atan2(2*(p*h+u*d),1-2*(u*u+h*h))/Ft),[sn(y),sn(x),sn(E)]}function _o(e,t){return Gc.includes(t)||(Vc[e.kind]||[]).includes(t)}var Yc={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}},tt=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=Co[this.kind]||Co.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,(this.kind==="grid"||this.kind==="textwindow")&&(this.runtime.scrollControls||=new Set,this.runtime.scrollControls.add(this));let r=Yc[this.kind]||{};for(let[n,a]of Object.entries(r))this[n]===void 0&&(this[n]=i[n]!==void 0?i[n]:a);if(this.kind==="grid"&&(this.scrollProgress=i.scrollProgress??0),i.children)for(let n of i.children){let a=n instanceof e?n:new e(t,n);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 r=t;r;r=r._parent)if(r===this)throw new Error("cannot parent a control to itself or its descendant");let i=this._parent;if(i){let r=i.children.indexOf(this);r>=0&&i.children.splice(r,1),i.markPlayDirty(!0)}else{let r=this.runtime.roots.indexOf(this);r>=0&&this.runtime.roots.splice(r,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}get scrollProgress(){return this._scrollProgress??0}set scrollProgress(t){if(typeof t!="number"||!Number.isFinite(t))throw new Error("scrollProgress must be a finite number");this._scrollProgress=Ui(t),this.markPlayDirty()}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),r=this;for(let n of i)if(r=r.GetChild(n),!r)return null;return r}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,r=i.indexOf(this);if(r<0)return!1;let n=i.length-1;return!Number.isInteger(t)||t<0||t>n?!1:(i.splice(r,1),i.splice(n-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,r){this.localScaleX=t,this.localScaleY=i,this.localScaleZ=r,this.markPlayDirty()}GetLocalRotation(){return Ao(this.localRotationX,this.localRotationY,this.localRotationZ)}luaFieldValue(t){if(t==="imageType")return this.imageType??"Stretch";let i=Hc.indexOf(t);return i<0?this[t]:Ao(this.localRotationX,this.localRotationY,this.localRotationZ)[i]}SetLocalRotation(t,i,r){this.localRotationX=t,this.localRotationY=i,this.localRotationZ=r,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,r){let n=t.get(i)||[];n.push(r),t.set(i,n),this.runtime.retainLuaCallback?.(r)}_removeListener(t,i,r){let n=t.get(i);if(!n)return;let a=n.filter(o=>o!==r);t.set(i,a);for(let o=a.length;o<n.length;o++)this.runtime.unrefLuaCallback?.(r)}_removeListeners(t,i){let r=t.get(i)||[];for(let n of r)this.runtime.unrefLuaCallback?.(n);t.delete(i)}_removeAllListeners(t){for(let i of t.values())for(let r of i)this.runtime.unrefLuaCallback?.(r);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 r=this.cursorListeners.get(t)||[];for(let n of r)n(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 r of i)if(r()===!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,r){this.navConfig.set(t,{mode:i,target:r})}GetControllerNavigation(t){let i=this.navConfig.get(t),r=i?[i.mode,i.target]:[null,null];return r.__multi=!0,r}SetImage(t,i){let r=this.imageSource?.Name||this.imageSource,n=t?.Name||t;(i!==this.imageId||r!==n)&&(this.imageType=null),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(t,i){if(!Number.isInteger(t)||t<0||t>2e3)throw new Error("RefreshItems: simulator supports 0..2000 items");if(typeof i!="function")throw new Error("RefreshItems: callback must be a function");if(!this.alive||this._refreshingGrid)throw new Error("RefreshItems: destroyed control or recursive refresh");if(t&&!this.runtime.templates.has(Number(this.itemPrefabIndex)))throw new Error("RefreshItems: item template not found");if(t&&["OnInit","OnDestroy"].includes(this.runtime.lifecyclePhase))throw new Error("RefreshItems: items cannot be created during OnInit/OnDestroy");this._refreshingGrid=!0;try{this._gridItems||=[];let r=[];for(let n of this._gridItems)n.alive&&n.parent===this&&n.prefabIndex===Number(this.itemPrefabIndex)&&r.length<t?r.push(n):n.alive&&n.parent===this&&this.runtime.destroyControl(n);for(this._gridItems=r;r.length<t;){let n=this.runtime.instantiate(this.itemPrefabIndex,this,this.runtime.lifecyclePhase);if(!n)throw new Error("RefreshItems: could not instantiate item");r.push(n),n.SetActive(!0)}this.itemCount=t,Ot(this),this.markPlayDirty(!0);for(let n=0;n<r.length&&this.alive;n+=1)i(r[n],n)}finally{this._refreshingGrid=!1}}GetItemIndex(t){return t?.alive&&t.parent===this?this._gridItems?.indexOf(t)??-1:-1}GetItemSize(){return[this.cellSizeX,this.cellSizeY]}GetItemSpacing(){return[this.spacingX,this.spacingY]}GetPadding(){return[this.padding1Y,this.padding2Y,this.padding1X,this.padding2X]}ScrollToItemAt(t,i){if(!Number.isInteger(t)||t<0||t>=this.itemCount)throw new Error("ScrollToItemAt: item index out of range");let r=li(this),n=r.horizontal?r.cellW:r.cellH,a=r.horizontal?r.gapX:r.gapY,o=(r.horizontal?r.left:r.top)+Math.floor(t/r.lanes)*(n+a),s=i?.Name||i;if(!["Top","Center","Bottom"].includes(s))throw new Error("ScrollToItemAt: invalid alignment");let c=o-(s==="Center"?(r.viewport-n)/2:s==="Bottom"?r.viewport-n:0);this.scrollProgress=r.max?Ui(c/r.max):0,Ot(this),this.markPlayDirty(!0)}GetContentLength(){return li(this).length}};function ze(e,t){t(e);for(let i of e.children)ze(i,t)}function cn(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let r of e.children)cn(r,t,i+" ");return t}function Li(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 Po={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-Li(1-e),OutBounce:Li,InOutBounce:e=>e<.5?(1-Li(1-2*e))/2:(1+Li(2*e-1))/2};function To(e,t){let i=Po[e]||Po.Linear;return t<=0?0:t>=1?1:i(t)}function Dt(e,t,i,r=255){let n=Xi(e),a=Xi(t),o=Xi(i);return((r==null?255:Xi(r))<<24|n<<16|a<<8|o)>>>0}function ci(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function Xi(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function Ro(e,t,i){let r=ci(e),n=ci(t);return Dt(r[0]+(n[0]-r[0])*i,r[1]+(n[1]-r[1])*i,r[2]+(n[2]-r[2])*i,r[3]+(n[3]-r[3])*i)}var Bc=new Set(["fontColor","bgColor","outlineColor","imageColor"]),Uc=new Set(["fontSize","minimumFontSize"]),un=1e-9;function jc(e,t){return typeof e?.luaFieldValue=="function"?e.luaFieldValue(t):e[t]}var ui=class{constructor(t,i,r,n){this.runtime=t,this.object=i,this.data={...r},this.duration=Math.max(0,Number(n)||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,this.dead=!1,this.completed=!1}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let r=jc(this.object,t);this.from[t]=r,this.to[t]=this.relative?Number(r)+Number(i):i}}restoreInitial(){this.from={...this.initialFrom},this.to={...this.initialTo}}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._start(!1)}_begin(t){this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,this.completed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to})}_start(t){return this._begin(t),this.runtime.tweens.add(this),this.runtime.animations.add(this),this}get loopCount(){return this.loops>0?this.loops:1}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this.dead?this:this._start(!0)}Complete(){this.dead||this.completed||(this.initialFrom||this._begin(!1),this.apply(1),this.finish(!0))}Kill(t){t?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){if(this.object?.alive===!1)return;let i=To(this.easeName,t),r=!1,n=!1;for(let a of Object.keys(this.to)){let o=this.from[a],s=this.to[a];if(Bc.has(a)&&typeof o=="number"&&typeof s=="number")this.object[a]=Ro(o,s,i);else if(typeof o=="number"&&typeof s=="number"){let c=o+(s-o)*i;this.object[a]=Uc.has(a)?Math.trunc(c):c}else this.object[a]=i>=1?s:o;r=!0,ji.has(a)&&(n=!0)}r&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(n)}_advance(t,i){this.elapsed+=t;let r=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);return this.apply(r),r<1?!1:i>=0&&this.loopIndex+1>=i?!0:(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.elapsed=0,this.restoreInitial(),!1)}step(t){!this.playing||this.paused||this.killed||this._advance(t,this.loops<0?-1:this.loopCount)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0))}finish(t){this.playing=!1,this.killed=!0,t&&(this.completed=!0),this.runtime.tweens.delete(this),this.runtime.animations.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},zt=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.dead=!1,this.completed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._entries=null}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.dead?this:this.playing?(this.paused=!1,this):this._play()}_play(){return this.playing=!0,this.paused=!1,this.killed=!1,this.completed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this.runtime.sequences.add(this),this.runtime.animations.add(this),this}_schedule(){let t=0,i=0,r=!1,n=[],a=o=>o.duration*o.loopCount;for(let o of this.steps)if(o.kind==="tween"&&o.parallel){let s=r?i:t;n.push({at:s,tween:o.tween}),t=Math.max(t,s+a(o.tween))}else o.kind==="tween"?(n.push({at:t,tween:o.tween}),i=t,r=!0,t+=a(o.tween)):o.kind==="interval"?(i=t,r=!0,t+=o.duration):o.kind==="callback"?n.push({at:t,fn:o.fn}):o.kind==="insert"?(n.push({at:o.time,tween:o.tween}),t=Math.max(t,o.time+a(o.tween))):o.kind==="insertCb"&&(n.push({at:o.time,fn:o.fn}),t=Math.max(t,o.time));this._entries=n.map((o,s)=>({...o,index:s,end:o.tween?o.at+a(o.tween):o.at})),this._end=t,this._resetEntries()}_resetEntries(){for(let t of this._entries)t.started=!1,t.done=!1}_startChild(t){t.started=!0,t.tween._begin(!!t.tween.initialFrom)}_finishChild(t){t.done=!0,t.tween.apply(1),t.tween.onStepComplete&&this.runtime.safeCall(t.tween.onStepComplete),t.tween.finish(!0)}_advanceTo(t,i){let r=this._entries,n=[];for(let o of r)!o.started&&o.at<=t+un&&n.push({at:o.at,rank:o.fn?1:2,entry:o}),o.tween&&!o.done&&o.end<=t+un&&n.push({at:o.end,rank:0,entry:o});n.sort((o,s)=>o.at-s.at||o.rank-s.rank||o.entry.index-s.entry.index);let a=new Set;for(let{rank:o,entry:s}of n)if(o===1){if(s.started=!0,this.runtime.safeCall(s.fn),!this.playing||this.killed||this._entries!==r)return!1}else s.started||(this._startChild(s),a.add(s)),o===0&&!s.done&&this._finishChild(s);for(let o of r)!o.tween||!o.started||o.done||(a.has(o)?o.tween._advance(t-o.at,o.tween.loopCount):o.tween._advance(i,o.tween.loopCount));return!0}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._advanceTo(this.elapsed,t)&&(this.elapsed+un<this._end||(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._resetEntries()):this.finish(!0))))}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){this.dead||this._play()}Complete(){this.dead||this.completed||(this._entries||this._schedule(),this.playing=!0,this.killed=!1,this._advanceTo(1/0,0)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0)))}Kill(t){t?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}finish(t){this.playing=!1,this.killed=!0,t&&(this.completed=!0),this.runtime.sequences.delete(this),this.runtime.animations.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var qi={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"]},Lc=[...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"],Xc=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function qc(){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}qi.KeyboardKeyCode=Lc;qi.ControllerKeyCode=Xc;qi.KeyEventType=qc();var Mo=new Map;function dt(e,t){let i=`${e}\0${t}`,r=Mo.get(i);return r||(r={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},Mo.set(i,r)),r}function fn(e,t){return t==null?t:t.__kind==="EnumItem"?dt(t.EnumType||e,t.Name):typeof t=="string"&&t?dt(e,t):t}function dn(){let e={};for(let[t,i]of Object.entries(qi)){let r={};for(let n of i)r[n]=dt(t,n);e[t]=r}return e}var Wc=new Set(["Id","prefabIndex","imageId","fontSize","minimumFontSize","clickAudioId","itemCount","itemPrefabIndex","animationId","referencedPrefabIndex"]),Kc=new Set(["imageColor","fontColor","bgColor","outlineColor"]),No={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",imageType:"ImageType",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},ht=f.LUA_REGISTRYINDEX,Oo=f.LUA_MULTRET,Jc=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 be(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}var Wi=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.canSelectImageType=t.canSelectImageType||(()=>!1),this.clock={time:0,levelTime:0,paused:!1,frame:0},this.logs=[],this.mountErrors=[],this.tweens=new Set,this.sequences=new Set,this.animations=new Set,this.audios=new Map,this.nextAudioId=1,this.audioDuration=t.audioDuration||(()=>null),this.audioHistory=[],this.audioWarnings=new Set,this.audioRevision=0,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 r=this._nextScriptMappingId;return this._nextScriptMappingId+=1,r}pushPackedColor(t,i){let r=i>>>0;(r|0)===r?f.lua_pushinteger(t,r):f.lua_pushnumber(t,r)}retainLuaCallback(t){vo(t)}unrefLuaCallback(t){So(this,t)}log(t,...i){let r=i.map(n=>n==null?"nil":typeof n=="object"&&n!==null&&n.__kind==="EnumItem"?n.Name:String(n)).join(" ");this.logs.push({level:t,text:r,time:this.clock.time})}safeCall(t,...i){try{return t(...i)}catch(r){this.log("lua-error",r&&r.message?r.message:String(r))}}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 r=this.normalizeRequirePath(t);this.scriptFiles.set(r,i),r.startsWith("default_import_file/")||this.requireAliases.set(`default_import_file/${r}`,r)}normalizeRequirePath(t){let i=String(t).replace(/\\/g,"/");return i.endsWith(".lua")&&(i=i.slice(0,-4)),i}addRoot(t){let i=t instanceof tt?t:new tt(this,t);return this.roots.push(i),ze(i,r=>this.controlsById.set(r.Id,r)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof tt)return;let r=a=>(a.scripts?.length||0)>0||(a.children||[]).some(r);if(!t||!r(t))return;let n=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(u){let d=u&&u.message?u.message:String(u);this.mountErrors.push(d),this.log("lua-error",d)}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=n}}makeCursorEventData({x:t=0,y:i=0,pressX:r=t,pressY:n=i,deltaX:a=t-r,deltaY:o=i-n,dragging:s=!1,touchId:c=-1}={}){let l=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:s,touchId:c,x:t,y:i,pressX:r,pressY:n,GetUIPos(){return[t,i]},GetPressUIPos(){return[r,n]},GetUIPosDelta(){return[a,o]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;f.lua_pushcfunction(t,r=>{let n=f.lua_gettop(r),a=[];for(let o=1;o<=n;o++)a.push(he(r,i,o));return i.log("info",...a),0}),f.lua_setglobal(t,R("print")),f.lua_pushcfunction(t,r=>{let n=f.lua_gettop(r),a=[];for(let o=1;o<=n;o++)a.push(he(r,i,o));return i.log("error",...a),0}),f.lua_setglobal(t,R("printerr")),f.lua_pushcfunction(t,r=>{if(f.lua_type(r,1)===f.LUA_TTABLE&&!Be(r,1))return f.lua_pushstring(r,R("table")),1;let n=he(r,i,1);return f.lua_pushstring(r,R(i.typeofOf(n))),1}),f.lua_setglobal(t,R("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),f.lua_pushcfunction(t,r=>i.luaRequire(r)),f.lua_setglobal(t,R("require"))}typeofOf(t){return t==null?"nil":t.__kind==="Script"?"Script":t.__kind==="EnumItem"?"EnumItem":t.__kind==="CursorEventData"?"CursorEventData":t.__kind==="ServerSignal"?"ServerSignal":t instanceof zt?"TweenSequence":t instanceof ui?"Tween":t.typeofName?t.typeofName:typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t}pushColorLib(t){f.lua_newtable(t),f.lua_pushcfunction(t,i=>(this.pushPackedColor(i,Dt(f.lua_tonumber(i,1),f.lua_tonumber(i,2),f.lua_tonumber(i,3),255)),1)),f.lua_setfield(t,-2,R("FromRGB")),f.lua_pushcfunction(t,i=>{let r=f.lua_isnoneornil(i,4)?255:f.lua_tonumber(i,4);return this.pushPackedColor(i,Dt(f.lua_tonumber(i,1),f.lua_tonumber(i,2),f.lua_tonumber(i,3),r)),1}),f.lua_setfield(t,-2,R("FromRGBA")),f.lua_pushcfunction(t,i=>{let r=f.lua_tonumber(i,1)>>>0;for(let n of ci(r))f.lua_pushinteger(i,n);return 4}),f.lua_setfield(t,-2,R("ToRGBA")),f.lua_newtable(t),f.lua_pushcfunction(t,i=>{let r=f.lua_tonumber(i,2),n=f.lua_tonumber(i,3),a=f.lua_tonumber(i,4),o=f.lua_isnoneornil(i,5)?255:f.lua_tonumber(i,5);return this.pushPackedColor(i,Dt(r,n,a,o)),1}),f.lua_setfield(t,-2,R("__call")),f.lua_setmetatable(t,-2),f.lua_setglobal(t,R("Color"))}pushEnumLib(t){f.lua_newtable(t);for(let[i,r]of Object.entries(this.enumTree)){f.lua_newtable(t);for(let[n,a]of Object.entries(r))this.pushEnumItem(t,a),f.lua_setfield(t,-2,R(n));f.lua_setfield(t,-2,R(i))}f.lua_setglobal(t,R("Enum"))}pushEnumItem(t,i){let r=f.lua_newuserdata(t,0);ft(r,i),ee.luaL_setmetatable(t,R("EnumItem"))}pushControl(t,i){let r=f.lua_newuserdata(t,0);ft(r,i),ee.luaL_setmetatable(t,R("Control"))}pushScript(t,i){f.lua_newtable(t),f.lua_pushlightuserdata(t,on);let r=f.lua_newuserdata(t,0);ft(r,i),f.lua_rawset(t,-3),ee.luaL_getmetatable(t,R("Script")),f.lua_setmetatable(t,-2)}pushTween(t,i){let r=f.lua_newuserdata(t,0);ft(r,i);let n=i instanceof zt?"TweenSequence":"Tween";ee.luaL_setmetatable(t,R(n))}pushSignal(t,i){let r=f.lua_newuserdata(t,0);ft(r,i),ee.luaL_setmetatable(t,R("ServerSignal"))}pushCursor(t,i){let r=f.lua_newuserdata(t,0);ft(r,i),ee.luaL_setmetatable(t,R("CursorEventData"))}pushGameLib(t){let i=this;f.lua_newtable(t);let r={InstantiateClientUIControl:n=>{let a=f.lua_tointeger(n,1),o=Ce(f.lua_touserdata(n,2)),s=i.instantiate(a,o,i.lifecyclePhase);return s?(i.pushControl(n,s),1):(f.lua_pushnil(n),1)},DestroyClientUIControl:n=>{let a=Ce(f.lua_touserdata(n,1));return a&&i.destroyControl(a),0},GetClientUIControl:n=>{let a=f.lua_tointeger(n,1),o=i.controlsById.get(a);return o?i.pushControl(n,o):f.lua_pushnil(n),1},FindClientUIRoot:n=>{let a=Z(n,1),o=i.roots.find(s=>s.name===a);return o?i.pushControl(n,o):f.lua_pushnil(n),1},GetClientUIRoots:n=>(f.lua_createtable(n,i.roots.length,0),i.roots.forEach((a,o)=>{i.pushControl(n,a),f.lua_rawseti(n,-2,o+1)}),1),GetUICanvasSize:n=>(f.lua_pushnumber(n,i.canvasWidth),f.lua_pushnumber(n,i.canvasHeight),2),GetCursorUIPos:n=>(f.lua_pushnumber(n,i.cursor.x),f.lua_pushnumber(n,i.cursor.y),2),GetDevice:n=>(i.pushEnumItem(n,dt("Device",i.device)),1),SetControllerFocus:n=>(i.focus=Ce(f.lua_touserdata(n,1)),0),GetControllerFocus:n=>(i.focus?i.pushControl(n,i.focus):f.lua_pushnil(n),1),GetControllerLeftStickAxis:n=>(f.lua_pushnumber(n,i.stick.left[0]),f.lua_pushnumber(n,i.stick.left[1]),2),GetControllerRightStickAxis:n=>(f.lua_pushnumber(n,i.stick.right[0]),f.lua_pushnumber(n,i.stick.right[1]),2),Tween:n=>{let a=Ce(f.lua_touserdata(n,1))||he(n,i,1),o=he(n,i,2)||{},s=f.lua_tonumber(n,3),c=new ui(i,a,o,s);return i.pushTween(n,c),1},TweenSequence:n=>(i.pushTween(n,new zt(i)),1),ServerSignal:n=>{let a=Z(n,1);return i.pushSignal(n,i.makeServerSignal(a)),1},GetGlobalCustomVariableValue:n=>{let a=be(he(n,i,1)),o=Z(n,2);return le(n,i,i.getVar(a,o)),1},PauseLevelTime:n=>(i.clock.paused=!!f.lua_toboolean(n,1),0),IsLevelTimePaused:n=>(f.lua_pushboolean(n,i.clock.paused),1),PlayAudio2D:n=>{let a=i.playAudio(i.audioInteger(n));return f.lua_pushinteger(n,a),1},StopAudio:n=>(i.stopAudio(i.audioInteger(n)),0),IsAudioAlive:n=>{let a=i.audios.get(i.audioInteger(n));return f.lua_pushboolean(n,!!(a&&a.alive)),1},GetLanguageType:n=>(i.pushEnumItem(n,dt("LanguageType",i.language)),1),GetStageMode:n=>(i.pushEnumItem(n,dt("StageMode",i.stageMode)),1),IsTestPlay:n=>(f.lua_pushboolean(n,i.testPlay),1),GetText:n=>{let a=Z(n,1);return f.lua_pushstring(n,R(a)),1},PrintClientUITree:n=>{for(let a of i.roots)i.log("info",cn(a).join(`
|
|
108
|
-
`));return 0}};for(let[n,a]of Object.entries(r)){let o=Jc[n];if(o===void 0)throw new Error(`missing game arity for ${n}`);f.lua_pushcfunction(t,s=>{let c=f.lua_gettop(s);return c!==o?ee.luaL_error(s,R(`bad argument count to '${n}' (${o} expected, got ${c})`)):a(s)}),f.lua_setfield(t,-2,R(n))}f.lua_setglobal(t,R("game"))}makeServerSignal(t){let i=[],r=this;return{__kind:"ServerSignal",name:t,AddParam(n,a){i.push({type:be(n),value:a})},AddInt(n){i.push({type:"Int",value:n})},AddIntList(n){i.push({type:"IntList",value:n})},AddFloat(n){i.push({type:"Float",value:n})},AddFloatList(n){i.push({type:"FloatList",value:n})},AddString(n){i.push({type:"String",value:n})},AddStringList(n){i.push({type:"StringList",value:n})},AddVector3(n){i.push({type:"Vector3",value:n})},AddVector3List(n){i.push({type:"Vector3List",value:n})},AddBool(n){i.push({type:"Bool",value:n})},AddBoolList(n){i.push({type:"BoolList",value:n})},AddGuid(n){i.push({type:"Guid",value:n})},AddGuidList(n){i.push({type:"GuidList",value:n})},AddEntity(n){i.push({type:"Entity",value:n})},AddEntityList(n){i.push({type:"EntityList",value:n})},AddPrefabId(n){i.push({type:"PrefabId",value:n})},AddPrefabIdList(n){i.push({type:"PrefabIdList",value:n})},AddConfigId(n){i.push({type:"ConfigId",value:n})},AddConfigIdList(n){i.push({type:"ConfigIdList",value:n})},SendSignal(){let n=i.slice();r.serverBridge&&typeof r.serverBridge.receiveFromClient=="function"&&r.serverBridge.receiveFromClient(t,n)}}}audioInteger(t){let i=f.lua_tonumber(t,1);return f.lua_type(t,1)!==f.LUA_TNUMBER||!Number.isSafeInteger(i)?ee.luaL_error(t,R("audio argument must be an integer")):i}playAudio(t){this.audioRevision++;let i=this.nextAudioId++,r=this.audioDuration(t),n=Number.isFinite(r)&&r>0,a={instanceId:i,audioId:t,startedAt:this.clock.time,duration:n?r:0,alive:n,stopped:!1};return this.audioHistory.push(a),this.audioHistory.length>128&&this.audioHistory.shift(),n?(this.audios.size>=128&&this.stopAudio(this.audios.keys().next().value),this.audios.set(i,a)):this.audioWarnings.has(t)||(this.audioWarnings.size>=128&&this.audioWarnings.delete(this.audioWarnings.values().next().value),this.audioWarnings.add(t),this.log("warn",`\u97F3\u6548 ${t} \u672A\u5217\u5165\u6A21\u62DF\u5668\u97F3\u9891\u767D\u540D\u5355`)),i}stopAudio(t){let i=this.audios.get(t)||this.audioHistory.find(r=>r.instanceId===t);i&&!i.stopped&&(i.alive=!1,i.stopped=!0,this.audioRevision++),this.audios.delete(t)}audioSnapshot(){return{sequence:this.nextAudioId-1,revision:this.audioRevision,active:[...this.audios.values()].map(t=>({...t})),recent:this.audioHistory.map(t=>({...t}))}}instantiate(t,i,r){if(r==="OnInit"||r==="OnDestroy")return null;let n=this.templates.get(Number(t));if(!n||!i)return null;let a=new tt(this,{...n,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(a),a.SetAsLastSibling(),ze(a,o=>this.controlsById.set(o.Id,o)),this.mountSpecScripts(n,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}`);ze(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.scrollControls?.delete(t),this._playRemoved.push(t.Id),t.parent){let i=t.parent,r=i.children.indexOf(t);r>=0&&i.children.splice(r,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 r of i)this.unrefLuaCallback(r);for(let i of t.keyListeners.values())for(let r of i)this.unrefLuaCallback(r);for(let i of t.navListeners.values())for(let r of i)this.unrefLuaCallback(r);t.cursorListeners.clear(),t.keyListeners.clear(),t.navListeners.clear(),t.navConfig.clear()}onControlActiveChanging(t,i){let r=[];ze(t,n=>r.push({control:n,was:n.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let n of r){let a=n.control.activeInHierarchy;if(n.was!==a)for(let o of n.control.scripts.slice())a?this.enableScript(o):this.disableScript(o)}}bindScriptEnv(t){let i=t.env;return i?(this.pushScript(i,t),f.lua_setglobal(i,R("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,r=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=r,this.mountedScripts=this.mountedScripts.filter(n=>n!==t),t.object&&(t.object.scripts=t.object.scripts.filter(n=>n!==t)),this.varHandlers=this.varHandlers.filter(n=>n.script!==t),this.signalHandlers=this.signalHandlers.filter(n=>n.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,r,n,a,o){ee.luaL_newmetatable(t,R(i)),f.lua_pushcfunction(t,s=>{let c=Be(s,1)||Ce(f.lua_touserdata(s,1)),l=Z(s,2);if(a[l]&&(!o||o(c,l)))return f.lua_pushcfunction(s,a[l]),1;let u;try{u=r(c,l)}catch(d){return ee.luaL_error(s,R(String(d.message||d)))}return u===void 0?(f.lua_pushnil(s),1):(le(s,this,u),1)}),f.lua_setfield(t,-2,R("__index")),f.lua_pushcfunction(t,s=>{try{let c=Be(s,1)||Ce(f.lua_touserdata(s,1)),l=Z(s,2),u=he(s,this,3);return n(c,l,u),0}catch(c){return f.lua_pushstring(s,R(String(c.message||c))),f.lua_error(s)}}),f.lua_setfield(t,-2,R("__newindex")),f.lua_pushcfunction(t,s=>{let c=Be(s,1)||Ce(f.lua_touserdata(s,1)),l=Be(s,2)||Ce(f.lua_touserdata(s,2));return f.lua_pushboolean(s,c===l),1}),f.lua_setfield(t,-2,R("__eq")),f.lua_pop(t,1)}method(t){let i=this;return r=>{let n=Be(r,1)||Ce(f.lua_touserdata(r,1)),a=f.lua_gettop(r),o=[];for(let s=2;s<=a;s++)o.push(he(r,i,s));try{let s=t(n,...o);if(s===n)return f.lua_pushvalue(r,1),1;if(s===void 0)return 0;if(Array.isArray(s)&&s.__multi){for(let c of s)le(r,i,c);return s.length}if(Array.isArray(s)&&!(s.length&&typeof s[0]=="object"&&s[0]?.typeofName)){if(s.__controls)return f.lua_createtable(r,s.length,0),s.forEach((c,l)=>{i.pushControl(r,c),f.lua_rawseti(r,-2,l+1)}),1;if(s.__scripts)return f.lua_createtable(r,s.length,0),s.forEach((c,l)=>{i.pushScript(r,c),f.lua_rawseti(r,-2,l+1)}),1;if(typeof s[0]=="number"&&s.length<=4){for(let c of s)f.lua_pushnumber(r,c);return s.length}}return le(r,i,s),1}catch(s){return f.lua_pushstring(r,R(String(s.message||s))),f.lua_error(r)}}}mtEnum(t){let i=new Set(["Name","FullName","EnumType"]);this.mtIndexNewindex(t,"EnumItem",(r,n)=>i.has(n)?r[n]:void 0,(r,n)=>{throw new Error(`cannot set ${n}, no such field`)},{})}mtCursor(t){let i=new Set(["dragging","touchId"]);this.mtIndexNewindex(t,"CursorEventData",(r,n)=>i.has(n)?r[n]:void 0,(r,n)=>{throw new Error(`cannot set ${n}, no such field`)},{GetUIPos:this.method(r=>r.GetUIPos()),GetPressUIPos:this.method(r=>r.GetPressUIPos()),GetUIPosDelta:this.method(r=>r.GetUIPosDelta())})}mtControl(t){let i={GetChildren:this.method(r=>{let n=r.GetChildren();return n.__controls=!0,n}),GetChild:this.method((r,n)=>r.GetChild(n)),FindChild:this.method((r,n)=>r.FindChild(n)),SetActive:this.method((r,n)=>r.SetActive(n)),SetVisible:this.method((r,n)=>r.SetVisible(n)),GetSiblingIndex:this.method(r=>r.GetSiblingIndex()),SetSiblingIndex:this.method((r,n)=>r.SetSiblingIndex(n)),SetAsFirstSibling:this.method(r=>r.SetAsFirstSibling()),SetAsLastSibling:this.method(r=>r.SetAsLastSibling()),GetAnchoredPosition:this.method(r=>r.GetAnchoredPosition()),SetAnchoredPosition:this.method((r,n,a)=>r.SetAnchoredPosition(n,a)),GetSizeDelta:this.method(r=>r.GetSizeDelta()),SetSizeDelta:this.method((r,n,a)=>r.SetSizeDelta(n,a)),GetAnchorMin:this.method(r=>r.GetAnchorMin()),SetAnchorMin:this.method((r,n,a)=>r.SetAnchorMin(n,a)),GetAnchorMax:this.method(r=>r.GetAnchorMax()),SetAnchorMax:this.method((r,n,a)=>r.SetAnchorMax(n,a)),GetPivot:this.method(r=>r.GetPivot()),SetPivot:this.method((r,n,a)=>r.SetPivot(n,a)),GetLocalScale:this.method(r=>r.GetLocalScale()),SetLocalScale:this.method((r,n,a,o)=>r.SetLocalScale(n,a,o)),GetLocalRotation:this.method(r=>r.GetLocalRotation()),SetLocalRotation:this.method((r,n,a,o)=>r.SetLocalRotation(n,a,o)),GetScriptByPath:this.method((r,n)=>r.GetScriptByPath(n)),GetScript:this.method((r,n)=>r.GetScript(n)),GetScripts:this.method(r=>{let n=r.GetScripts();return n.__scripts=!0,n}),AddCursorEventListener:this.method((r,n,a)=>r.AddCursorEventListener(be(n),a)),RemoveCursorEventListener:this.method((r,n,a)=>r.RemoveCursorEventListener(be(n),a)),RemoveCursorEventListeners:this.method((r,n)=>r.RemoveCursorEventListeners(be(n))),RemoveAllCursorEventListeners:this.method(r=>r.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(r=>r.SimulateCursorClick()),AddKeyEventListener:this.method((r,n,a)=>r.AddKeyEventListener(be(n),a)),RemoveKeyEventListener:this.method((r,n,a)=>r.RemoveKeyEventListener(be(n),a)),RemoveKeyEventListeners:this.method((r,n)=>r.RemoveKeyEventListeners(be(n))),RemoveAllKeyEventListeners:this.method(r=>r.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((r,n,a)=>r.AddNavigationEventListener(be(n),a)),RemoveNavigationEventListener:this.method((r,n,a)=>r.RemoveNavigationEventListener(be(n),a)),RemoveNavigationEventListeners:this.method((r,n)=>r.RemoveNavigationEventListeners(be(n))),RemoveAllNavigationEventListeners:this.method(r=>r.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((r,n,a,o)=>r.SetControllerNavigation(be(n),a,o)),GetControllerNavigation:this.method((r,n)=>r.GetControllerNavigation(be(n))),SetImage:this.method((r,n,a)=>r.SetImage(n,a)),SetSoftEdgeWidth:this.method((r,n,a)=>r.SetSoftEdgeWidth(n,a)),SetFillUnused:this.method(r=>r.SetFillUnused()),SetFillHorizontal:this.method((r,n,a)=>r.SetFillHorizontal(n,a)),SetFillVertical:this.method((r,n,a)=>r.SetFillVertical(n,a)),SetFillRadial90:this.method((r,n,a)=>r.SetFillRadial90(n,a)),SetFillRadial180:this.method((r,n,a)=>r.SetFillRadial180(n,a)),SetFillRadial360:this.method((r,n,a)=>r.SetFillRadial360(n,a)),PlayAnimation:this.method(r=>r.PlayAnimation()),StopAnimation:this.method(r=>r.StopAnimation()),RefreshItems:this.method((r,n,a)=>{this.retainLuaCallback(a);try{r.RefreshItems(n,a)}finally{this.unrefLuaCallback(a)}}),GetItemIndex:this.method((r,n)=>r.GetItemIndex(n)),GetItemSize:this.method(r=>r.GetItemSize()),GetItemSpacing:this.method(r=>r.GetItemSpacing()),GetPadding:this.method(r=>r.GetPadding()),ScrollToItemAt:this.method((r,n,a)=>r.ScrollToItemAt(n,a)),GetContentLength:this.method(r=>r.GetContentLength())};this.mtIndexNewindex(t,"Control",(r,n)=>{if(!ln(r,n))return;if(!r.alive&&n!=="alive")throw new Error(`attempt to read '${n}' of a destroyed control`);let a=r.luaFieldValue(n),o=No[n];return o?fn(o,a):typeof a=="number"&&!Wc.has(n)&&!Kc.has(n)?new oi(a):a},(r,n,a)=>{if(ln(r,n)==="rw"){if((n==="fontSize"||n==="minimumFontSize")&&!Number.isInteger(a)){let c=a===null?"nil":typeof a;throw new Error(`bad argument #2 to '${n}' (integer expected, got ${c})`)}let s=No[n];if(n==="imageType"&&(a?.EnumType!=="ImageType"||!["Basic","Stretch"].includes(a.Name)))throw new Error("imageType requires Enum.ImageType.Basic or Stretch");r[n]=s?fn(s,a):a,typeof r.markPlayDirty=="function"&&r.markPlayDirty(ji.has(n));return}throw new Error(`cannot set ${n}, no such field`)},i,_o)}mtScript(t){let i=this,r=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(n,a)=>r.has(a)?n[a]:void 0,(n,a,o)=>{if(a==="enabled"){n.enabled=!!o;return}throw new Error(`cannot set ${a}, no such field`)},{GetParam:this.method((n,a)=>Object.prototype.hasOwnProperty.call(n.params,a)?n.params[a]:null),Invoke:n=>i.luaInvoke(n),EnableUpdate:this.method((n,a)=>{n.updateEnabled=!!a}),RegisterServerSignalHandler:this.method((n,a,o)=>{i.signalHandlers.push({script:n,name:a,fn:o})}),UnregisterServerSignalHandler:this.method((n,a)=>{i.signalHandlers=i.signalHandlers.filter(o=>!(o.script===n&&o.name===a))}),RegisterCustomVariableChangedHandler:this.method((n,a,o,s)=>{i.varHandlers.push({script:n,entityType:be(a),name:o,fn:s})}),UnregisterCustomVariableChangedHandler:this.method((n,a,o)=>{let s=be(a);i.varHandlers=i.varHandlers.filter(c=>!(c.script===n&&c.entityType===s&&c.name===o))})})}mtTween(t){this.mtIndexNewindex(t,"Tween",()=>{},()=>{},{SetEase:this.method((i,r)=>i.SetEase(r)),SetRelative:this.method((i,r)=>i.SetRelative(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,r)=>i.Kill(r)),SetOnComplete:this.method((i,r)=>i.SetOnComplete(r)),SetOnStepComplete:this.method((i,r)=>i.SetOnStepComplete(r)),SetLoops:this.method((i,r)=>i.SetLoops(r))})}mtSeq(t){this.mtIndexNewindex(t,"TweenSequence",()=>{},()=>{},{Append:this.method((i,r)=>i.Append(r)),AppendInterval:this.method((i,r)=>i.AppendInterval(r)),AppendCallback:this.method((i,r)=>i.AppendCallback(r)),Join:this.method((i,r)=>i.Join(r)),Insert:this.method((i,r,n)=>i.Insert(r,n)),InsertCallback:this.method((i,r,n)=>i.InsertCallback(r,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,r)=>i.Kill(r)),SetOnComplete:this.method((i,r)=>i.SetOnComplete(r)),SetOnStepComplete:this.method((i,r)=>i.SetOnStepComplete(r)),SetLoops:this.method((i,r)=>i.SetLoops(r))})}mtSignal(t){this.mtIndexNewindex(t,"ServerSignal",()=>{},()=>{},{AddParam:this.method((i,r,n)=>i.AddParam(r,n)),SendSignal:this.method(i=>i.SendSignal()),AddInt:this.method((i,r)=>i.AddInt(r)),AddIntList:this.method((i,r)=>i.AddIntList(r)),AddFloat:this.method((i,r)=>i.AddFloat(r)),AddFloatList:this.method((i,r)=>i.AddFloatList(r)),AddString:this.method((i,r)=>i.AddString(r)),AddStringList:this.method((i,r)=>i.AddStringList(r)),AddVector3:this.method((i,r)=>i.AddVector3(r)),AddVector3List:this.method((i,r)=>i.AddVector3List(r)),AddBool:this.method((i,r)=>i.AddBool(r)),AddBoolList:this.method((i,r)=>i.AddBoolList(r)),AddGuid:this.method((i,r)=>i.AddGuid(r)),AddGuidList:this.method((i,r)=>i.AddGuidList(r)),AddEntity:this.method((i,r)=>i.AddEntity(r)),AddEntityList:this.method((i,r)=>i.AddEntityList(r)),AddPrefabId:this.method((i,r)=>i.AddPrefabId(r)),AddPrefabIdList:this.method((i,r)=>i.AddPrefabIdList(r)),AddConfigId:this.method((i,r)=>i.AddConfigId(r)),AddConfigIdList:this.method((i,r)=>i.AddConfigIdList(r))})}luaRequire(t){let i=Z(t,1),r=this.normalizeRequirePath(i),n=this.requireAliases.get(r)||r;f.lua_rawgeti(t,ht,f.LUA_RIDX_MAINTHREAD);let a=f.lua_tothread(t,-1);f.lua_pop(t,1);let o=this.requireCache.get(a);o||(o=new Map,this.requireCache.set(a,o));let s=o.get(n);if(s?.loading)return f.lua_pushstring(t,R(`failed to load script '${r}': cyclic require`)),f.lua_error(t);if(s&&s.ref!=null)return f.lua_rawgeti(t,ht,s.ref),1;let c=this.scriptFiles.get(n);if(c==null)return f.lua_pushstring(t,R(`failed to load script '${r}'`)),f.lua_error(t);let l=f.lua_gettop(t);o.set(n,{loading:!0});try{this.loadModule(t,a,n,c),f.lua_pushvalue(t,-1);let u=ee.luaL_ref(t,ht);return o.set(n,{ref:u}),1}catch(u){return o.delete(n),f.lua_settop(t,l),f.lua_pushstring(t,R(`failed to load script '${r}': ${u.message||u}`)),f.lua_error(t)}}newLuaThread(){let t=ee.luaL_newstate();return go.luaL_openlibs(t),Io(t),this.installMetatables(t),this.installGlobals(t),this.luaStates.add(t),f.lua_pushglobaltable(t),this.copyLuaEnvironment(t,-1),f.lua_remove(t,-2),this.moduleBaseEnvironments.set(t,ee.luaL_ref(t,ht)),t}copyLuaEnvironment(t,i){let r=f.lua_absindex(t,i);f.lua_newtable(t);let n=f.lua_absindex(t,-1);for(f.lua_pushnil(t);f.lua_next(t,r)!==0;)f.lua_pushvalue(t,-2),f.lua_pushvalue(t,-2),f.lua_rawset(t,n),f.lua_pop(t,1);f.lua_pushvalue(t,n),f.lua_setfield(t,n,R("_G"))}closeTrackedLuaState(t){if(!t||!this.luaStates.has(t))return;for(let r of this.requireCache.get(t)?.values()||[])r.ref!=null&&ee.luaL_unref(t,ht,r.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&ee.luaL_unref(t,ht,i),this.moduleBaseEnvironments.delete(t),this.luaStates.delete(t),this.luaFunctions)for(let[r,n]of this.luaFunctions)n.__luaState===t&&this.luaFunctions.delete(r);wo(t)}loadModule(t,i,r,n){let a={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:r,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},o=String(n).replace(/^\uFEFF/,""),s=Bi(o);if(ee.luaL_loadbuffer(t,s,s.length,R(`@${r}`))!==Te)throw new Error(Z(t,-1));let l=f.lua_absindex(t,-1);if(f.lua_rawgeti(t,ht,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),f.lua_remove(t,-2),this.pushScript(t,a),f.lua_setfield(t,-2,R("script")),f.lua_setupvalue(t,l,1),f.lua_pcall(t,0,1,0)!==Te)throw new Error(Z(t,-1))}mountScript({path:t,source:i,control:r,params:n={},scriptMappingId:a=void 0}){this.L||this.boot();let o=this.newLuaThread(),s={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(a),object:r,path:this.normalizeRequirePath(t),enabled:!0,updateEnabled:!1,params:n,env:o,lifecyclePhase:"idle"};s.invoke=(l,u)=>this.invokeOn(o,l,u),r&&r.scripts.push(s),this.mountedScripts.push(s),this.pushScript(o,s),f.lua_setglobal(o,R("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 u=this.callGlobal(o,"OnEnable");u&&this.mountErrors.push(u),this.lifecyclePhase="OnStart",s.lifecyclePhase="OnStart";let d=this.callGlobal(o,"OnStart");return d&&this.mountErrors.push(d),this.lifecyclePhase="running",s.lifecyclePhase="running",s}catch(l){throw s.alive=!1,s.lifecyclePhase="failed",this.mountedScripts=this.mountedScripts.filter(u=>u!==s),r&&(r.scripts=r.scripts.filter(u=>u!==s)),this.varHandlers=this.varHandlers.filter(u=>u.script!==s),this.signalHandlers=this.signalHandlers.filter(u=>u.script!==s),this.lifecyclePhase=c,o&&o!==this.L&&this.closeTrackedLuaState(o),s.env=null,l}}runChunk(t,i,r){let n=String(i).replace(/^\uFEFF/,""),a=Bi(n),o=ee.luaL_loadbuffer(t,a,a.length,R(`@${r}`));if(o!==Te){let c=Z(t,-1)||`luaL_loadbuffer status ${o}`;throw f.lua_pop(t,1),new Error(c)}let s=f.lua_pcall(t,0,0,0);if(s!==Te){let c=Z(t,-1)||`lua_pcall status ${s}`;throw f.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(f.lua_getglobal(t,R(i)),f.lua_isfunction(t,-1)){if(f.lua_pcall(t,0,0,0)!==Te){let n=Z(t,-1);f.lua_pop(t,1);let a=`${i}: ${n}`;return this.log("lua-error",a),a}}else f.lua_pop(t,1);return null}callGlobalDt(t,i,r){if(f.lua_getglobal(t,R(i)),f.lua_isfunction(t,-1)){if(f.lua_pushnumber(t,r),f.lua_pcall(t,1,0,0)!==Te){let a=Z(t,-1);f.lua_pop(t,1),this.log("lua-error",`${i}: ${a}`)}}else f.lua_pop(t,1)}luaInvoke(t){let i=Be(t,1);if(!i||i.__kind!=="Script")return ee.luaL_error(t,R("bad self to 'Invoke' (Script expected)"));let r=Z(t,2),n=i.env;if(!n||n.l_G!==t.l_G){let c=[];for(let d=3;d<=f.lua_gettop(t);d++)c.push(he(t,this,d));let l;try{l=i.invoke(r,c)}catch(d){return ee.luaL_error(t,R(String(d.message||d)))}if(l===void 0)return 0;let u=Array.isArray(l)&&l.__multi?l:[l];for(let d of u)le(t,this,d);return u.length}let a=2;if(f.lua_getglobal(t,R(r)),!f.lua_isfunction(t,-1))return 0;f.lua_replace(t,a),f.lua_remove(t,1);let o=f.lua_gettop(t)-1;return f.lua_pcall(t,o,Oo,0)!==Te?f.lua_error(t):f.lua_gettop(t)}invokeOn(t,i,r){let n=f.lua_gettop(t);if(f.lua_getglobal(t,R(i)),!f.lua_isfunction(t,-1)){f.lua_settop(t,n);return}for(let c of r)le(t,this,c);if(f.lua_pcall(t,r.length,Oo,0)!==Te){let c=Z(t,-1);throw f.lua_settop(t,n),new Error(c)}let o=f.lua_gettop(t)-n;if(o<=0){f.lua_settop(t,n);return}if(o===1){let c=he(t,this,-1);return f.lua_settop(t,n),c}let s=[];for(let c=1;c<=o;c++)s.push(he(t,this,n+c));return f.lua_settop(t,n),s.__multi=!0,s}runScriptPhase(t,i){for(let r of this.mountedScripts){if(!this.scriptCanRun(r))continue;let n=r.env;n&&(this.pushScript(n,r),f.lua_setglobal(n,R("script")),!(t==="OnUpdate"&&!r.updateEnabled)&&this.callGlobalDt(n,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;for(let[r,n]of this.audios)this.clock.time+1e-9>=n.startedAt+n.duration&&(n.alive=!1,this.audios.delete(r),this.audioRevision++);let i=!this.clock.paused;for(let r of[...this.animations])r.step(t);this.runScriptPhase("OnUpdate",t),i&&(this.clock.levelTime+=t,this.runScriptPhase("OnLevelUpdate",t))}injectKey(t){let i=r=>{if(!r.alive||!r.activeInHierarchy)return!1;if(r.keyListeners.has(t)&&r.emitKey(t))return!0;for(let n of[...r.children])if(i(n))return!0;return!1};for(let r of[...this.roots])i(r)}injectCursor(t,i,r){let n=r||this.makeCursorEventData({});Number.isFinite(n.x)&&Number.isFinite(n.y)&&(this.cursor.x=n.x,this.cursor.y=n.y),t.emitCursor(i,n)}getVar(t,i){if(this.serverBridge&&typeof this.serverBridge.getVar=="function")return this.serverBridge.getVar(t,i);let r=this.serverVars[t];return r?r[i]:void 0}notifyVarHandlers(t,i){for(let r of this.varHandlers)this.scriptCanRun(r.script)&&r.entityType===t&&r.name===i&&this.safeCall(r.fn,this.enumTree.CustomVariableEntityType[t],i)}setVar(t,i,r){if(this.serverBridge&&typeof this.serverBridge.setVar=="function"){this.serverBridge.setVar(t,i,r);return}let n=this.serverVars[t]||(this.serverVars[t]=Object.create(null));n[i]=r,this.notifyVarHandlers(t,i)}sendClientSignal(t,i){for(let r of this.signalHandlers)this.scriptCanRun(r.script)&&r.name===t&&this.safeCall(r.fn,t,i)}evalQueryScript(t,i){this.L||this.boot();let r=this.L;f.lua_createtable(r,0,5);let n=(a,o)=>{f.lua_pushcfunction(r,o),f.lua_setfield(r,-2,R(a))};return n("var",a=>(le(a,this,i.var(Z(a,1),Z(a,2))),1)),n("logContains",a=>(f.lua_pushboolean(a,i.logContains(Z(a,1))),1)),n("control",a=>(le(a,this,i.control(Z(a,1))),1)),n("logs",a=>(le(a,this,i.logs()),1)),n("signals",a=>(le(a,this,i.signals(Z(a,1))),1)),n("serverLogs",a=>(le(a,this,i.serverLogs?i.serverLogs():[]),1)),n("serverLogContains",a=>{let o=i.serverLogContains;return f.lua_pushboolean(a,o?!!o(Z(a,1)):!1),1}),f.lua_setglobal(r,R("query")),this.runChunk(r,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,this.audios.clear(),this.audioHistory.length=0,this.audioWarnings.clear()}};function fi(e){let t=new Wi(e);return t.boot(),t}var pt=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),pn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),Yo=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var hn=Object.freeze([...Yo,...pt,...pn]),Bo=Object.freeze(["PlayerSelf","AllPlayers",...pt]),Zc=Object.freeze(["Level","PlayerSelf",...pt]),Fo=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),Qc=-2147483648,eu=2147483647,tu=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 di(e){return`Player${Number(e)}`}function Ki(e){return`Avatar${Number(e)}`}function Do(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function mt(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 Ue(e,t=8){let i=mt(t);if(e==null||e==="")return 1;let r=Number(e);if(!Number.isInteger(r)||r<1||r>i)throw new Error(`playerIndex must be an integer 1-${i}`);return r}function zo(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of pt)e[t]=Object.create(null);for(let t of pn)e[t]=Object.create(null);return e}function Uo(e){let t=String(e||"");if(!hn.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function iu(e,t){let i=Uo(e);if(!Zc.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function hi(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function Ji(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function mn(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 mi(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=mi(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 Se(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function $o(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 Go(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:mi(t),value:t}):[]}function ru(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function Zi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jo(e,t){if(!Zi(e)||!Object.prototype.hasOwnProperty.call(e,"fromSignalParam"))return null;if(Object.keys(e).some(r=>r!=="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 Vo(e,t){return jo(e,t)||Se(e)}function nu(e,t,i){if(!Zi(e))throw new Error(`serverLogic.rules[${t}].actions[${i}] must be an object`);let r=String(e.kind||e.type||""),n=`serverLogic.rules[${t}].actions[${i}]`;if(r==="setCustomVariable"){let a=iu(e.entityType,n);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${n}.value is required`);return{kind:r,entityType:a,name:hi(e.name),value:Vo(e.value,`${n}.value`),...e.variableType?{variableType:String(e.variableType)}:{}}}if(r==="sendClientScriptSignal"){if(!Array.isArray(e.params))throw new Error(`${n}.params must be an array`);return{kind:r,target:mn(e.target),signalName:Ji(e.signalName),params:e.params.map((a,o)=>Vo(a,`${n}.params[${o}]`))}}throw new Error(`${n}.kind must be setCustomVariable or sendClientScriptSignal`)}function pi(e){if(e==null)return{version:1,rules:[]};if(!Zi(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,r)=>{if(!Zi(i))throw new Error(`serverLogic.rules[${r}] must be an object`);if(!Array.isArray(i.actions)||i.actions.length===0)throw new Error(`serverLogic.rules[${r}].actions must be a non-empty array`);return{id:String(i.id||`signal-${r+1}`),signalName:Ji(i.signalName),actions:i.actions.map((n,a)=>nu(n,r,a))}})}}function Ho(e,t,{typed:i=!1}={}){let r=jo(e,"server logic value");if(r){let n=i?t.params:t.values;if(r.fromSignalParam>=n.length)throw new Error(`signal ${t.name} has no parameter at index ${r.fromSignalParam}`);return Se(n[r.fromSignalParam])}return Se(e)}function au(e){return e==="Level"?"Level":pt.includes(e)?"PlayerSelf":pn.includes(e)?"AvatarSelf":e}function Lo(e={}){let t=zo(),i=zo(),r=[],n=[],a=[],o=[],s=Array.from({length:9},()=>null),c=1,l=0,u=Number(e.onlineLatencyMs||0);(!Number.isFinite(u)||u<0)&&(u=0);let d=pi(e.logic),h=mt(e.playerCount),p=Ue(e.viewPlayerIndex,h);function m(b,A){o.push({source:"server",level:String(b||"engine"),text:String(A),time:l})}function y(b){let A=s[b||p],S=Number(A?.clock?.time);Number.isFinite(S)&&(l=S)}function x(b,A,S,C){t[b][A]=S,i[b][A]={type:C||mi(S)||i[b][A]?.type||""}}function E(b,A,S){return typeof S!="number"||!Number.isInteger(S)?{ok:!0,value:S}:S>=Qc&&S<=eu?{ok:!0,value:S}:(m("engine",`Int custom variable ${b}.${A} out of range ${S}; keeping previous legal value`),{ok:!1,value:t[b][A]})}function I(b,A){let S=Uo(b),C=A||p;return S==="PlayerSelf"?di(C):S==="AvatarSelf"?Ki(C):S}function O(b,A){let S=au(b);if(b==="Level"){for(let k=1;k<=h;k+=1){let _=s[k];_&&typeof _.notifyVarHandlers=="function"&&_.notifyVarHandlers("Level",A)}return}let C=Do(b);if(!C)return;let F=s[C];F&&typeof F.notifyVarHandlers=="function"&&F.notifyVarHandlers(S,A)}function N(b,A){let S=mn(b);return S==="AllPlayers"?Array.from({length:h},(C,F)=>F+1):S==="PlayerSelf"?[A||p]:[Do(S)]}function H(b){for(let A of d.rules)if(A.signalName===b.name)for(let S of A.actions){if(S.kind==="setCustomVariable"){let C=Ho(S.value,b);z.setVar(S.entityType,S.name,C,{type:S.variableType,playerIndex:b.playerIndex}),m("info",`logic ${A.id}: set ${S.entityType}.${S.name}`);continue}if(S.kind==="sendClientScriptSignal"){let C=S.params.map(F=>Ho(F,b,{typed:!0}));z.sendToClient(S.signalName,C,{target:S.target,playerIndex:b.playerIndex}),m("info",`logic ${A.id}: sent ${S.signalName} to ${S.target}`)}}}function B(b,A){b&&(b.serverBridge={getVar:(S,C)=>z.getVar(S,C,{playerIndex:A}),setVar:(S,C,F)=>z.setVar(S,C,F,{playerIndex:A}),receiveFromClient:(S,C)=>z.receiveFromClient(S,C,{playerIndex:A})})}function Y(b){b&&(b.serverBridge=null)}let z={ENTITY_TYPES:Yo,ALL_ENTITY_TYPES:hn,CLIENT_SIGNAL_TARGETS:Bo,get clock(){return l},get playerCount(){return h},get viewPlayerIndex(){return p},setClock(b){l=Number(b)||0},setPlayerCount(b){return h=mt(b),p>h&&(p=h),h},setViewPlayerIndex(b){return p=Ue(b,h),p},log(b,A){m(b,A)},defineVar(b,A,S={},{playerIndex:C}={}){let F=I(b,C),k=hi(A);if(Object.prototype.hasOwnProperty.call(t[F],k))throw new Error(`custom variable already exists: ${F}.${k}`);let _=S.type?String(S.type):mi(S.value??S.defaultValue);if(_&&!Fo.includes(_))throw new Error(`unsupported custom variable type: ${_}`);let $=S.value!==void 0?S.value:S.defaultValue!==void 0?S.defaultValue:null;return x(F,k,$,_),z.getVar(F,k)},getVar(b,A,{playerIndex:S}={}){let C=I(b,S),F=hi(A);if(!Object.prototype.hasOwnProperty.call(t[C],F)){m("engine",`GetGlobalCustomVariableValue missing ${C}.${F}; returning nil (simulator policy)`);return}return t[C][F]},setVar(b,A,S,{notify:C=!0,type:F,playerIndex:k}={}){let _=I(b,k),$=hi(A),V=F||i[_][$]?.type||mi(S);if(V&&!Fo.includes(V)&&V!=="")throw new Error(`unsupported custom variable type: ${V}`);let re=S;if(!((V==="Int"||V===""&&typeof S=="number"&&Number.isInteger(S))&&(re=E(_,$,S).value,re===void 0)))return x(_,$,re,V),C&&O(_,$),re},listVars(b){let A=b?[I(b)]:["Level",...Array.from({length:h},(C,F)=>di(F+1)),...Array.from({length:h},(C,F)=>Ki(F+1))],S=[];for(let C of A)for(let F of Object.keys(t[C]))S.push({entityType:C,name:F,type:i[C][F]?.type||"",value:Se(t[C][F])});return S},receiveFromClient(b,A=[],{playerIndex:S}={}){let C=Ue(S||p,h);y(C);let F=Ji(b),k={id:c++,direction:"inbound",name:F,params:Go(A),values:$o(A),time:l,playerIndex:C,from:di(C)};return r.push(k),H(k),k},sendToClient(b,A=[],{target:S="PlayerSelf",playerIndex:C}={}){let F=Ji(b),k=mn(S),$=N(k,C||p),V={id:c++,direction:"outbound",name:F,params:Go(A),values:$o(A),time:l,target:k,players:$,deliverAt:l+u/1e3,delivered:!1};return n.push(V),u===0?z.deliver(V):a.push(V),V},getLogic(){return Se(d)},setLogic(b){return d=pi(b),z.getLogic()},deliver(b){if(!b||b.delivered)return;b.delivered=!0;let A=Array.isArray(b.players)&&b.players.length?b.players:N(b.target);for(let S of A){let C=s[S];C&&typeof C.sendClientSignal=="function"&&C.sendClientSignal(b.name,b.values)}},flush(b){b!==void 0&&(l=Number(b)||0);let A=[];for(let S=a.length-1;S>=0;S-=1)a[S].deliverAt<=l&&A.push(a.splice(S,1)[0]);A.sort((S,C)=>S.id-C.id);for(let S of A)z.deliver(S);return A},inbound(){return r.slice()},outbound(){return n.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 A of b.nodes||[]){let S=ru(A);if(!tu.has(S))throw new Error(`unsupported server node: ${S||JSON.stringify(A)}. v1 only supports custom variables and signals`)}if(b.onlineLatencyMs!==void 0){let A=Number(b.onlineLatencyMs);if(!Number.isFinite(A)||A<0)throw new Error("onlineLatencyMs must be a non-negative finite number");u=A}b.playerCount!==void 0&&z.setPlayerCount(b.playerCount),b.viewPlayerIndex!==void 0&&z.setViewPlayerIndex(b.viewPlayerIndex),(b.logic!==void 0||b.serverLogic!==void 0)&&z.setLogic(b.logic??b.serverLogic);for(let A of b.vars||[]){let S=I(A.entityType),C=hi(A.name);Object.prototype.hasOwnProperty.call(t[S],C)?z.setVar(S,C,A.value??A.defaultValue,{notify:!1,type:A.type}):z.defineVar(S,C,A)}}},attachRuntime(b,{playerIndex:A=1}={}){let S=Ue(A,8);return s[S]&&s[S]!==b&&Y(s[S]),s[S]=b||null,B(s[S],S),z},attachRuntimes(b){z.detachRuntime();let A=Array.isArray(b)?b:[];for(let S=0;S<A.length&&S<8;S+=1)s[S+1]=A[S]||null,B(s[S+1],S+1);return z},detachRuntime(){for(let b=1;b<=8;b+=1)Y(s[b]),s[b]=null},snapshot(){let b=di(p),A=Ki(p),S={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let C of Object.keys(t.Level))S.Level[C]={type:i.Level[C]?.type||"",value:Se(t.Level[C])};for(let C of Object.keys(t[b]))S.PlayerSelf[C]={type:i[b][C]?.type||"",value:Se(t[b][C])};for(let C of Object.keys(t[A]))S.AvatarSelf[C]={type:i[A][C]?.type||"",value:Se(t[A][C])};for(let C=1;C<=h;C+=1){let F=di(C),k=Ki(C);S[F]={},S[k]={};for(let _ of Object.keys(t[F]))S[F][_]={type:i[F][_]?.type||"",value:Se(t[F][_])};for(let _ of Object.keys(t[k]))S[k][_]={type:i[k][_]?.type||"",value:Se(t[k][_])}}return{clock:l,onlineLatencyMs:u,playerCount:h,viewPlayerIndex:p,logic:z.getLogic(),vars:S,inbound:r.map(C=>({id:C.id,name:C.name,params:Se(C.params),values:Se(C.values),time:C.time,playerIndex:C.playerIndex,from:C.from})),outbound:n.map(C=>({id:C.id,name:C.name,params:Se(C.params),values:Se(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 hn){for(let A of Object.keys(t[b]))delete t[b][A];for(let A of Object.keys(i[b]))delete i[b][A]}r.length=0,n.length=0,a.length=0,o.length=0,c=1,l=0},destroy(){z.detachRuntime(),z.reset()}};e.config&&z.loadConfig(e.config);for(let b of e.vars||[])z.defineVar(b.entityType,b.name,b);return z}var ou={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 r=Je(e.transformByPlatform,t),n={authoringId:e.id,kind:ou[e.kind]||"container",name:e.name,prefabIndex:e.guid||0,active:e.active!==!1,visible:e.visible!==!1,canControllerFocus:e.canControllerFocus===!0,anchoredPositionX:r.offset.x,anchoredPositionY:r.offset.y,sizeDeltaX:r.size.x,sizeDeltaY:r.size.y,anchorMinX:r.anchorMin.x,anchorMinY:r.anchorMin.y,anchorMaxX:r.anchorMax.x,anchorMaxY:r.anchorMax.y,pivotX:r.pivot.x,pivotY:r.pivot.y,localScaleX:r.scale.x,localScaleY:r.scale.y,localScaleZ:r.scale.z,localRotationX:r.rotation.x,localRotationY:r.rotation.y,localRotationZ:r.rotation.z,children:(e.children||[]).map(o=>gn(o,t,i))},a=i?.get(e.id);return a?.length&&(n.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"&&(n.isolateNavigation=e.isolateNavigation===!0,n.disableKeyEventPassthrough=e.disableKeyEventPassthrough===!0,n.disableCursorEventPassthrough=e.disableCursorEventPassthrough===!0,n.showCursor=e.showCursor===!0),(e.kind==="textbox"||e.kind==="textwindow")&&(n.text=e.text??"",n.fontSize=e.fontSize,n.adaptiveFontSize=e.adaptiveFontSize===!0,n.minimumFontSize=e.minimumFontSize,n.fontColor=e.fontColor,n.bgColor=e.bgColor,n.enableOutline=e.enableOutline!==!1,n.outlineColor=e.outlineColor,n.horizontalAlignment=e.horizontalAlignment||"Left",n.verticalAlignment=e.verticalAlignment||"Top",e.kind==="textwindow"&&(n.interactable=e.interactable!==!1,n.showScrollBar=e.showScrollBar!==!1)),e.kind==="image"&&(n.imageSource=e.imageSource,n.imageType=e.imageType??null,n.imageId=e.imageId??0,n.imageColor=e.imageColor,n.raycastTarget=e.raycastTarget===!0,n.enableMask=e.enableMask===!0,n.enableSoftEdge=e.enableSoftEdge===!0,n.softEdgeMode=e.softEdgeMode,n.softEdgeWidthX=e.softEdgeWidthX,n.softEdgeWidthY=e.softEdgeWidthY,n.horizontalSoftRange=e.horizontalSoftRange,n.verticalSoftRange=e.verticalSoftRange,n.enableFill=e.enableFill===!0,n.fillType=e.enableFill?e.fillType:"Unused",n.fillHorizontalType=e.fillHorizontalType,n.fillVerticalType=e.fillVerticalType,n.fillRadial90Type=e.fillRadial90Type,n.fillRadialType=e.fillRadialType,n.fillAmount=e.fillAmount,n.reverseMaskArea=e.reverseMaskArea===!0),e.kind==="button"&&(n.raycastTarget=e.raycastTarget!==!1,n.interactable=e.interactable!==!1,n.clickAudioId=e.clickAudioId,n.unavailableChildId=e.unavailableChildId??null,n.hoverChildId=e.hoverChildId??null,n.pressedChildId=e.pressedChildId??null,n.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(n.raycastTarget=e.raycastTarget!==!1),e.kind==="reference"&&(n.referencedPrefabIndex=e.referencedPrefabId),e.kind==="grid"&&(n.itemPrefabIndex=e.itemPrefabId,n.raycastTarget=e.raycastTarget!==!1,n.interactable=e.interactable!==!1,n.showScrollBar=e.showScrollBar!==!1,n.scrollDirection=e.scrollDirection,n.layoutConstraint=e.layoutConstraint,n.layoutConstraintFixedCount=e.layoutConstraintFixedCount,n.cellSizeX=e.cellSizeX,n.cellSizeY=e.cellSizeY,n.spacingX=e.spacingX,n.spacingY=e.spacingY,n.padding1X=e.padding1X,n.padding1Y=e.padding1Y,n.padding2X=e.padding2X,n.padding2Y=e.padding2Y,n.previewCount=e.previewCount),e.kind==="keyhint"&&(n.keyboardKeyCode=e.keyboardKeyCode,n.controllerKeyCode=e.controllerKeyCode),(e.kind==="animation"||e.kind==="fullscreen")&&(n.raycastTarget=!1,n.animationId=e.animationId,n.playSoundEffect=e.playSoundEffect,e.kind==="animation"&&(n.layer=e.layer)),n}function yn(e,t=[],i=""){let r=i&&J[i]?i:e.canvasId,n=J[r],a=ii(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=>gn(c,r,o)):[];return{canvasId:r,platform:n.platform,device:n.luaDevice,canvasWidth:n.width,canvasHeight:n.height,root:gn(a,r,o),templates:s}}var Qi="qxqy-autotest";var yt=.03333333333333333,su=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),lu=new Set(["log","control","var","signal","tree","lua"]);function gt(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 er(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!su.has(i))throw new Error(`unsupported event kind: ${i||"(empty)"}`);let r=e.payload&&typeof e.payload=="object"?{...e.payload}:{};if(i==="pointer")!r.type&&e.type&&(r.type=e.type),r.x===void 0&&(r.x=e.x),r.y===void 0&&(r.y=e.y),r.x=gt(r.x,"pointer.x"),r.y=gt(r.y,"pointer.y"),r.type=String(r.type||"click"),r.type==="wheel"&&(r.deltaX=gt(r.deltaX??e.deltaX??0,"pointer.deltaX"),r.deltaY=gt(r.deltaY??e.deltaY??0,"pointer.deltaY"));else if(i==="key"){if(r.typeName=String(r.typeName||r.key||e.typeName||e.key||""),!r.typeName)throw new Error("key event requires typeName")}else if(i==="click"){if(r.name=String(r.name||e.name||""),!r.name)throw new Error("click event requires control name")}else if(i==="serverSet"){if(r.entityType=String(r.entityType||e.entityType||""),r.name=String(r.name||e.name||""),r.value===void 0&&(r.value=e.value),r.value===void 0&&(r.value=null),!r.entityType||!r.name)throw new Error("serverSet requires entityType and name")}else if(i==="serverSend"){if(r.name=String(r.name||e.name||""),r.params=Array.isArray(r.params)?r.params:Array.isArray(e.params)?e.params:[],r.target=String(r.target||e.target||"PlayerSelf"),!r.name)throw new Error("serverSend requires signal name")}else if(i==="view"&&(r.playerIndex=Number(r.playerIndex||r.viewPlayerIndex||e.playerIndex||e.viewPlayerIndex||0),!Number.isInteger(r.playerIndex)||r.playerIndex<1))throw new Error("view event requires playerIndex 1-8");return{t:gt(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:r}}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(!lu.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let r={kind:i};if(e.at!==void 0&&(r.at=gt(e.at,"assert.at")),i==="log"){if(r.contains=String(e.contains||e.check||e.text||""),r.source=e.source==="server"?"server":"client",e.level&&(r.level=String(e.level)),!r.contains)throw new Error("log assert requires contains")}else if(i==="control"){if(r.id=e.id?String(e.id):"",r.name=e.name?String(e.name):"",r.field=String(e.field||""),!r.field)throw new Error("control assert requires field");if(!r.id&&!r.name)throw new Error("control assert requires id or name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("control assert requires equals");r.equals=bn(e.equals)}else if(i==="var"){if(r.entityType=String(e.entityType||""),r.name=String(e.name||""),!r.entityType||!r.name)throw new Error("var assert requires entityType and name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("var assert requires equals");r.equals=bn(e.equals)}else if(i==="signal"){if(r.direction=e.direction==="outbound"?"outbound":"inbound",r.name=String(e.name||""),!r.name)throw new Error("signal assert requires name");e.values!==void 0&&(r.values=bn(e.values))}else if(i==="tree"){if(r.name=String(e.name||""),r.exists=e.exists!==!1,!r.name)throw new Error("tree assert requires name")}else if(i==="lua"&&(r.source=String(e.source||""),!r.source.trim()))throw new Error("lua assert requires source");return r}function Xo(e){let t=0,i=[],r=[];for(let n of e){if(!n||typeof n!="object")throw new Error("queue step must be an object");if(n.do!=="start"){if(n.do==="step"){t+=gt(n.dt??yt,"step.dt");continue}if(n.do==="pointer"||n.do==="key"||n.do==="click"||n.do==="pause"||n.do==="resume"||n.do==="serverSet"||n.do==="serverSend"||n.do==="view"){i.push(er({...n,kind:n.do,t},i.length));continue}if(n.assert||n.check||n.kind){r.push(vn({...n.assert||n,at:n.at??t},r.length));continue}throw new Error(`unsupported queue step: ${JSON.stringify(n)}`)}}return{events:i,asserts:r,dt:yt}}function gi(e){if(Array.isArray(e)){let r=Xo(e);return{format:Qi,version:1,name:"",dt:r.dt,events:r.events,asserts:r.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 r=Xo(e.queue||e.steps);return{format:Qi,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):r.dt,events:r.events,asserts:r.asserts}}let t=(e.events||[]).map((r,n)=>er(r,n)),i=(e.asserts||[]).map((r,n)=>vn(r,n));return t.sort((r,n)=>r.t-n.t||0),{format:Qi,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):yt,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function qo(e,t={}){let i=(e||[]).map((r,n)=>er(r,n));return{format:Qi,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):yt,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((r,n)=>vn(r,n))}}function Wo(e,t,i){if(!e)return null;let r=er({...t,t:t.t??i??0},e.events.length);return e.events.push(r),r}import{createCanvas as cu}from"@napi-rs/canvas";var Ko=cu(1,1).getContext("2d"),uu='"Microsoft YaHei UI","Microsoft YaHei",sans-serif',tr=(e,t)=>Math.max(0,Math.min(t,Number.isFinite(e)?e:0));function Jo(e,t,i){let r=Math.max(8,Number(e.fontSize)||12),n=String(e.text??"").replace(/\r\n?/g,`
|
|
109
|
-
|
|
110
|
-
`)){let x="";for(let E of y)x&&Ko.measureText(x+E).width>p&&(m.push(x),x=""),x+=E;m.push(x)}return m},u=l(Math.max(1,t-4)),d=e.showScrollBar!==!1&&u.length*r*1.2>i,h=Math.max(1,t-4-(d?12:0));d&&(u=l(h)),o=e._textWindowLayout={key:a,lines:u,font:r,textWidth:h,lineHeight:r*1.2,length:u.length*r*1.2}}let s=Math.max(0,o.length-i),c=tr(e._scrollOffset||0,s);return e._scrollOffset=c,{...o,max:s,offset:c,viewport:i,horizontal:!1,width:t,height:i}}function $t(e,t,i){if(!e?.showBar||e.max<=0||t<=0||i<=0)return null;let r=e.horizontal===!0,n=r?t:i,a=Math.max(0,n-4),o=Math.min(a,Math.max(18,a*n/(n+e.max))),s=a-o,c=s*e.offset/e.max,l=Math.min(8,r?i:t),u=r?{x:-t/2+2,y:i/2-l-2,width:a,height:l}:{x:t/2-l-2,y:-i/2+2,width:l,height:a},d=r?{...u,x:u.x+c,width:o}:{...u,y:u.y+c,height:o};return{track:u,thumb:d,travel:s}}var Zo="https://oss.070077.xyz/",Sn="mp3-v1",ir="/qxqy-audio/",fu=[[10001,"ura.1ht4.2ag9.1hh5.jbb.k02.jcw.2tv.2wn.2xk.2r3.d5s.94l.ebv.kcr.b40.77k.9gp.97w.1hb5.jag.btu.jc9.hp5.bmj.blq.blq.ff9.ffk.o74.1owl.rp.mg.l3.lf.lh.qy.1a3z.2xk.2xk.2xk.2xk.2xk.17dc.1f2b.2bc.2bc.2bc.2bc.2bc.ffo.ffo.126.1fk.4mo.4mo.15e.1h2.237.2ba.2kd.2bc.4mo.4mo.4mo.4mo.1mc.1n6.2cu.1ud.2b1.2ee.1tj.1tk"],[20001,"o6.fh.kb.cr.og.sm.6x.8c.87.o7.vz.kt.qo.lg.ob.9w.mg.1kz.zc.1ex.1d5.ps.uu.su.qs.ys.zp.10k.15a.xc.uk.mx.1ax.nt.tu.19m.uj.1ku.tt.100.ie.d3.fp.ie.ie.d3.fp.ie.8p.7k.fw.h0.qc.ot.uc.ot.rk.gb.1c2.ff.cl.9v.wg.1ir.1lr.1b8.1ri.1p0.104.10n.mw.j6.jb.f1.dv.84.a0.cp.bx.1ko.1au.1ia.rs.rt.rs.t7.x6.wi.zc.16f.1i6.2jh.28d.qh.k8.1gz.1ko.2iv.1xp.1l4.1gk.10j.yo.1jk.1jk.xv.104.15o.1xg.1xg.1xi.25i.p1.t1.yh.1ak.1i6.1y2.xt.32u.3g6.1bz.2mn.14l.14c.1e1.op.s8.p2.v5.2ix.1a0.ry.16m.17n.13c.134.ys.yu.xr.sl.sr.sd.yh.z5.gd.gl.hx.h2.g8.fj.iy.hz.jj.th.12n.16r.d3.j9.dg.lj.fl.a7.f9.iw.el.27f.1dh.1rh.2ph.yd.w5.x5.tr.pq.zf.16h.1a5.17t.wy.vn.y8.wl.yv.2ye.2qt.1ah.163.19t.uf.119.2vv.1bm.13h.14p.1so.c3.as.9z.19w.1l4.1nl.rj.we"],[30001,"jo.my.ss.dw.c1.b4.hl.hl.hl.cz.dw.dw.b4.dw.fr.kd.qv.px.px.74.6u.8h.60.8q.8b.eo.eo.eo.8k.a5.99.12v.13y.lg.m4.qr.dw.ex.g0.ef.cd.br.11n.17h.1b8.1c9.9p.ag.9z.l9.m8.m8.lw.m8.cz.99.b4.8c.63.7f.6h.99.re.pp.pi.cq.c9.cp.ck.c6.b0.bd.al.f6.gl.ed.fs.lc.k6.kh.i6.cx.j1.hk.gb.d7.h7.g2.em.kj.kn.k4.j5.rh.t0.qt.mj.i7.ih.i2.hd.3r.8d.6u.6z.by.de.dg.cr.1a5.1ab.16c.18g.n2.ly.no.nt.f9.de.lr.fe.f0.fj.el.fo.t1.g9.ly.h3.g6.de.2ak.2f3.wf.kg.qn.11p.rg.uj.u6.11c.22o.2cs.3dp.3dq.3d5.3d6.1zx.18v"],[40001,"19x.215.2zt.1ex.2pj.7hy.1ur.1gn.1g7.1b1.u9.1tw.108.1ew.rs.1qu.w9.lk.244.qi.b6.tk.jg.jg.jg.y4.c1.b4.iv.hi.r4.n7.gy.ev.qe.12z.18n.dw.1l6.ou.wz.1un.19t.18k.yy.1hs.sl.dw.1vl.100.14k.1q8.209.1jk.1xr.ua.1j2.pr.26h.1gs.s9.px.15v.pf.1jk.xc.1hb.111.172.ut.285.1oh.149.zj.22r.2l9.14a.ok.23y.1eh.xe.1j0.1rp.1cz.wf.1mh.22k.334.1z2.1xo.1br.4ji.5nq.5nf.2za.18r.h3.eo.ia.1kn.dc.ss.s0.1bl.1oc.is.km.177.1ec.1ao.h4.hp.dx.l9.iw.i3.12w.n1.yq.12w.1ju.yx.14s.18b.22t.u3.my.2rb.36w.13u.z8.20r.18g.19r.2x9.w4.q2.1d2.wo.13a.v6.17w.ur.288.1b6.14m.1fi.1xx.1ee.kj.121.j2.1d2.2ad.1ri.2lc.1vk.138.12r.xj.1h5.1c5.2qx.1gj.t2.lv.rf.18q.1kz.dw.2aq.ia.1i9.k5.199.f4.10y.18a.xf.rk.1g9.1q3.10h.sj.15o.e3.dz.sv.135.w9.yg.aw.2a2.19m.22w.1c8.272.13o.104.1sr.rs.1pb.d5.df.kp.jq.1a7.s8.1ao.ba.rb.in.pz.q8.140.ij.1e7.jl.yk.117.10i.1tn.1oj.1sv.sj.1e3.2so.1c7.1gv.178.107.10n.1dx.1qi.1wp.2bc.218.16r.105.xc.z6.11w.1mc.1y9.17p.1cs.2ij.18c.1ie.nn.16c.1ce.xb.1ei.3j0.ve.14x.1sx.285.1b8.1at.v4.rv.rs.10z.xq.11o.15k.xq.u1.i2.pu.i4.l3.9u.oh.mc.nm.pw.1i3.1h4.pj.111.l4.lb.qq.qf.u0.h4.nk.yf.6h.ij.ds.oy.re.m8.1gl.cz.16z.a1.1f8.1x6.vp.dz.gp.g6.fr.vl.fr.gg.qc.aj.99.go.ij.fz.11a.x5.mo.1u9.h0.m8.10m.1an.2bc.3uw.2gk.124.xb.1uk.1b6.2xj.1os.11a.vs.1i9.1lr.2gv.265.668.1xg.45j.404.2x1.1io.3om.4q2.4mo.1d4.2bp.1pr.166.2y6.2bv.361.2nc.2bc.3g0.7g4.334.2bc.2xo.3uw.6ic.4ig.3uw.23v.1la.2zr.1jt.1cq.27a.1n1.19x.1qg.1jn.1ca.26y.2d6.4v4.4mo.4mo.7ps.1jk.153.1fo.1dm.1s2.1w1.oe.1lb.319.2eg.58p.4mo.3dw.2y2.2xm.1u8.1ko.12n.1e0.2sd.1md.2cl.1q2.372.4mo.48s.b14.3fu.334.334.34i.4nf.4ji.5eg.3uw.2u8.1g1.110.37x.2jo.su.334.3aj.3uw.63f.2bc.2bc.8v4.1ts.ax5.5du.34d.3oc.34j.4si.174.rt.1rp.2b0.37d.1ta.2gh.28a.22z.1nc.1a5.1pa.4dd.3ha.2cs.5mv.4mq.5c2.3uw.1gf.4md.113.10x.21o.2hj.1b3.1cx.1ol.3ar.1fv.17t.1a7.2uj.2we.1jk"],[50001,"1o8.1k1.mo.1wu.2c9.22d.1kb.23n.1b8.1ic.24c.2wz.1mq.1mu.1jx.1z1.o3.190.vp.1h7.th.4mo.1rp.4mo.4mo.7ps.zz.143.21v.1nf.34s.1s3.r9.18t.s1.r9.21w.277.ls.25k.5v1.2bc.1kh.wt.14i.1eq.15o.668.sh.rl.3wi.3vc.43c.3yn.17c.f5.xu.jg.176.19v.1xy.23m.18x.30c.10l.13k.v8.vp.17t.qj.17m.1wr.1la.8t.s7.18d.1l2.152.mx.1c8.1l4.1f5.1xe.rz.2hz.1et.13t.xb.14r.15o.z0.1zo.ur.257.1gb.li.12d.15a.132.1m1.3vu.296.1mg.11m.z0.159.mp.hd.x4.1go.ns.xh.2a7.tt.2vb.1bx.1kh.u3.11i.1y1.24e.2hp.2mn.1w6.3zm.166.14g.1mo.2v9.2rg.2f9.1r0.139.m1.k3.ys.1dy.29k.1mm.22m.3zx.4dr.2h7.22o.tv.rm.1et.2wv.2ar.1t7.ku.12s.10b.1v9.1gu.12m.1b3.tv.1c8.tk.10s.ul.1tt.ka.oi.qb.13f.13f.13k.17h.1uh.ez.en.2x7.2ln.2h8.3h8.ig.n9.27o.18b.hl.nm.uk.11a.1ta.1k4.1eh.wv.1go.1gg.sc.18u.1dz.2aq.vt.2l7.25h.1l5.1kn.1vc.1b4.28i.17t.1d6.1k2.18z.jy.jw.dh.1mx.fr.vp.35w.34z.35w.34z.4so.vf.yx.1bg.1d3.2yc.1tg.8q3.99g.am.2du.rm.rg.xa.2cw.xc.1j6.1if.18z.13a.yz.142.1z5.262.1bj.1y8.ur.u5.16j.1pf.1bi.l8.1il.3vz.2dr.jo.ls.18s.16l.18c.141.219.1yz.1fc.24t.27e.481.1vp.25h.1yq.1zn.1uw.11u.1jp.1pz.39o.t6.1mj.1u5.11l.1vd.1dk.1zb.1ic.3ql.14p.1wq.25x.267.zn.zn.1pf.13z.1j7.r9.1hb.4yp.1lt.1cw.1z4.19z.1og.1j4.1cl.1eg.u8.16s.1en.zu.1hr.1js.19g.303.22j.2oa.180.1v7.2ud.2d7.21s.3g9.vh.v1.284.3lg.3lg.17q.1h3.4mo.1cm.1rv.22i.2mc.2j3.27o.333.1q8.237.2ll.23b.2sp.2ll.2ox.2cf.2f8.2hz.1uo.y4.s9.w6.2dg.2q9.up.1m1.1vz.2n8.192.1eb.z7.2em.2q3.1sd.1gj.348.3vf.2iu.29x.1dc.7oj.4pq.5vb.4mx.5me.5sf.5yf.7ps.yj.q0.10w.13p.18b.2wd.11q.2vx.dd.iv.12p.jh.u9.1uy.w0.3f0.3bj.126.qo.1gj.11k.pu.22h.1z6.rp.y4.y0.xl.1d0.11s.wa.1a6.127.10m.12r.1nh.1fy.yo.1js.162.n4.174.1aj.y4.o8.qz.rh.qa.18s.mr.j3.ii.sr.sx.1jk.17l.mj.zr.uy.wa.19t.2bt.xe.1od.hs.xr.5b.12c.1ab.we.gz.mz.4y.sf.11s.e0.1l7.ew.h6.jz.l0.e8.1cx.p6.17u.bw.1ah.10r.10e.o9.1bc.uv.lq.tl.zb.100.jy.b8.bj.336.10n.na.sq.14r.yr.nm.123.tf.l1.zp.1xc.1vk.31l.zl.2bj.2b9.2fv.17p.y0.so.1ln.29c.1eh.nh.xn.131.qc.186.ff.fc.xq.1bm.la.l8.14f.243.111.xi.qw.1qn.11v.1ur.1jx.1ks.s9.nz.269.1zj.2zd.1pv.18n.2vk.p3.1fh.13v.1lf.1lu.2db.1sr.1k3.26o.1dl.1f3.187.2lh.166.v9.xh.1e3.119.s2.mt.1iu.1k6.1o2.12s.u4.2br.1q3.qv.1e4.1zu.1v4.1vk.1t3.3p7.1ob.14d.1ns.1ef.1e4.12w.2kk.1ba.2jx.1e0.1s5.12w.17r.14s.wz.1qp.183.3fb.188.1gr.2ot.168.1u7.w8.28o.1zd.32z.230.w7.vq.x8.1qh.19f.14o.2r9.qg.1ey.1qr.1p6.3a3.1ov.13d.tz.wk.22v.1qa.2l9.yw.yf.nw.p6.1ly.1jk.1nh.x9.q0.17r.17h.ux.uw.12y.p7.g7.kt.14c.ze.1kh.1eo.18a.1d8.26j.15k.19f.1ym.1j5.1c6.11k.1sd.1jp.1ws.13s.1o5.214.sx.px.20x.14h.1ja.s6.1q8.w8.1ks.so.ub.121.202.1ej.1g1.1s8.2bc.4t1.bih.3uw.3pb.avp.6c7.bko.5eg.79c.6wh.3wd.4pn.55j.4a5.3gg.bko.5ei.52p.578.bcv.6gr.2bc.4j9.5y7.9d2.2bb.2bc.668.73z.5pg.50f.5m7.788.267.642.8h2.8h2.49s.64g.5e8.5e8.2bb.3ih.5ur.6bk.578.4ck.3sg.5fe.23i.e9w.2b8.5oj.6bw.2al.2rk.2rk.5pj.n6e.350.6v9.70t.639.3uw.3uw.2bg.639.2bb.2bd.6gj.2bh.660.578.3bk.65e.359.3o0.44i.4tn.1zq.5ee.4a5.3zu.rs.639.33q.5eg.1k1.15o.dw.3uw.b7p.7qd.898.4l4.5uu.5uu.b4g.2yh.2yh.3uw.51a.51a.5kk.66f.iq9.3n7.4nb.46a.1wb.20p.bih.8xa.7ps.70t.70t.4rv.5p1.6aq.ts.63z.668.5v2.5nu.563.55s.55s.5p3.2ga.32x.42x.5cr.4c2.71b.5zp.5c2.66t.4c8.2bc.2bc.2gn.3ea.2kp.fz6.8hz.3e8.4an.bko.j7e.jag.7sr.2bc.3zx.7qd.5ut.5jp.2wk.5q7.3uw.334.4i3.3uw.4bd.5eu.46h.4i2.6t4.446.5s7.5cg.4bk.5nd.7bf.4rt.23b.2bc.2bc.2bc.2bc.2ba.4mo.4dv.3wn.2bc.1we.4he.2bc.4gz.3wn.3km.4xy.4hi.4mr.2bc.247.3yj.2c6.2bc.3aj.446.4ub.3uw.51.e0.86.is.i1.hg.mn.m4.2c.7h.sg.e3.jb.7r.eq.nf.u0.60.4o.ke.47.47.47.47.b8.4x.dr.dy.rw.rw.59.8j.5z.a5.l3.c0.ik.f7.li.lr.7x.dv.du.dd.5e.91.1b.ce.cc.59.bh.e6.8m.9n.cl.lt.7ip.4mr.4si.4kf.vo.we.13e.17n.1iw.2pi.lp.r6.gw.7x.xz.qt.bq.ls.q1.eh.bx.cr.3c.j7.b8.fz.4k.8p.bg.5w.iy.j3.12o.rs.cz.dp.yz.jk.63.63.7ps.7ps.7ps.40g.3jp.4tw.89k.88a.7s0.83d.668.7ps.2fw.2ev.2fp.7ps.2jb.2dh.2ud.25i.24c.2bt.1pa.17r.1a7.7ps.7pt.5rg.4nl.3vv.7qo.31a.2p0.2k0.49a.3v4.3nl.1ug.1ug.1l6.7s1.7ps.2cp.2f8.2i7.7ps.28q.2be.275.1ma.1oz.1q7.16s.1iq.1e0.78m.7ps.2bc.2bc.2bc.bko.2wu.2wu.2wu.3b4.38f.3uw.3uw.3uw.3uw.7ps.7qa.32n.2gg.2wk.7rv.1v3.1qq.1rb.1zk.1my.1zp.1yn.1oh.1uh.7st.9q.9q.9q.9q.9q.kk.kk.kk.kk.kk.dw.dp.dw.rs.rs.rs.rs.s4.sd.54j.5n8.2n6.21r.1nu.1o5.14u.t6.3f7.2j0.32c.304.189.1gf.18w.18j.1st.1vq.116.kw.3uw.3uw.vr.zx.xc.tc.7d.7r.9d.9w.8s.9p.3b.3b"]].map(([e,t])=>[e,t.split(".").map(i=>parseInt(i,36)/1e3)]);function rr(e){if(!Number.isSafeInteger(e))return null;for(let[t,i]of fu)if(e>=t&&e<t+i.length)return i[e-t];return null}var nr=e=>Number.isFinite(Number(e))?Math.max(0,Number(e)):0;function ar(e,t){if(!e||e.kind!=="image"||e.enableMask!==!0||!t)return null;let i=nr(e.sourceWidth??e.width),r=nr(e.sourceHeight??e.height),n=e.enableSoftEdge===!0,a=e.softEdgeMode!=="Pixel",o=n?nr(e.softEdgeWidthX):0,s=n?nr(e.softEdgeWidthY):0;return{id:e.id,matrix:t,width:i,height:r,featherX:a?i*o/100:o,featherY:a?r*s/100:s}}function Qo(e,t,i){let r=xe(e,t,i);return{a:e.a,b:e.b,c:e.c,d:e.d,tx:r.x,ty:r.y}}function es(e,t,i){let r=(n,a)=>n<=0?0:!(a>0)||n>=a?1:n/a;return Math.min(r(e+i.width/2,i.featherX),r(i.width/2-e,i.featherX),r(t+i.height/2,i.featherY),r(i.height/2-t,i.featherY))}function ts(e){let t={children:[]},i=[t],r=[];for(let n of e||[]){if(!n||n.id==null)continue;let a=n.masks||[],o=a.map(c=>JSON.stringify([c.id,c.matrix,c.width,c.height,c.featherX,c.featherY])),s=0;for(;s<r.length&&s<o.length&&r[s]===o[s];)s++;i.length=s+1;for(let c=s;c<a.length;c++){let l={mask:a[c],children:[]};i.at(-1).children.push(l),i.push(l)}i.at(-1).children.push({item:n}),r=o}return t.children}import{randomUUID as as}from"node:crypto";function lr(e){for(let t of e.runtime.scrollControls||[]){let[i,r]=si(t),n=t.kind==="grid"?Ot(t):Jo(t,i,r),a={offset:n.offset,max:n.max,horizontal:n.horizontal,showBar:t.showScrollBar!==!1,textWidth:n.textWidth??0,lines:n.lines||[],lineHeight:n.lineHeight||0,contentLength:n.length},o=JSON.stringify(a);t._scrollKey!==o&&(t._scrollKey=o,t._scroll=a,t.markPlayDirty())}}function os(e){return{...e._scroll?{scroll:e._scroll}:{},...e.parent?._gridItems?.includes(e)?{clipToParent:!0}:{}}}function wn(e,t){let i=e._scroll?.max||0;e.kind==="grid"?e.scrollProgress=i?tr(t,i)/i:0:e._scrollOffset=tr(t,i),e.markPlayDirty()}var du=Object.freeze(Object.values(J).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function cr(e){lr(e);let t=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function r(n,a,o){let s=Ge(a,n);s.activeInHierarchy=o&&n.active!==!1,i.set(n.Id,s);let c=s.activeInHierarchy;for(let l of n.children)r(l,s,c)}for(let n of e.runtime.roots)r(n,t,!0);return i}function ss(e,t=cr(e)){let i=new Map;function r(n,a){let o=t.get(n.Id);if(!o)return;let s=ti(a,o,n);i.set(n.Id,s);for(let c of n.children)r(c,s)}for(let n of e.runtime.roots)r(n,Pt());return i}function ls(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,...e._scroll?{scrollOffset:e._scroll.offset,scrollMax:e._scroll.max}:{},...e.kind==="grid"?{itemCount:e.itemCount,scrollProgress:e.scrollProgress}:{},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,imageSource:e.kind==="image"?Ie(e.imageSource):null,imageType:e.kind==="image"?e.imageType==null?null:Re(e.imageType):null,primitive:e.kind==="image"?At(e.imageId,e.imageSource):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(r=>ls(r,t))}}function hu(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,pointerScroll:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function mu(e,t,i,r){let n=fi({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device,audioDuration:rr,canSelectImageType:Sa,...r?{language:r}:{}});for(let a of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(a.prefabIndex)&&a.prefabIndex>0&&n.registerTemplate(a.prefabIndex,a);for(let a of i){let o=a.path||a.id,s=a.source||"";o&&s&&n.registerScriptFile(o,s)}return n}var pu=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","pointerScroll","hoveredControl","selectedControl","stateRestores","viewCache"];function gu(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of pu)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 cs(e,{templatesProject:t=null,scripts:i=[],sceneScripts:r=null,templateScripts:n=null,serverConfig:a=null,canvasId:o="",playerCount:s=1,viewPlayerIndex:c=1,language:l=""}={}){let u=r||i,d=n||i,h=yn(e,u,o),p=t?yn(t,d,o):null,m=mt(s),y=Ue(c,m),x=Lo({playerCount:m,viewPlayerIndex:y});a&&x.loadConfig({...a,playerCount:m,viewPlayerIndex:y});let E=[];for(let N=0;N<m;N+=1)E.push(mu(h,p,i,l));x.attachRuntimes(E);for(let N of E)N.addRoot(h.root);let I={audioSessionId:as(),runtimes:E,views:E.map(()=>hu()),playerCount:m,viewPlayerIndex:y,server:x,compiled:h,mountError:E.find(N=>N.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};gu(I);let O=I.viewPlayerIndex;for(let N=1;N<=m;N+=1)I.viewPlayerIndex=N,Au(I);return I.viewPlayerIndex=O,I}function kn(e,t){if(!e)throw new Error("play session has not started");let i=Ue(t,e.playerCount);return i===e.viewPlayerIndex||(it(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function it(e,t){!e?.recording||!e.history||Wo(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function yu(e){return e?.history?.events||[]}var En=new Set(["image","textbox","textwindow","button","grid"]);function bu(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 Re(e){return typeof e=="string"?e:e?.Name}function us(e){return{fillType:Re(e.fillType),fillHorizontalType:Re(e.fillHorizontalType),fillVerticalType:Re(e.fillVerticalType),fillAmount:e.fillAmount}}function vu(e,t,i){let r=Math.abs(t.width*i.scaleX),n=Math.abs(t.height*i.scaleY),a={id:e.Id,kind:e.kind,name:e.name,left:i.centerX-r/2,bottom:i.centerY-n/2,width:r,height:n,sourceWidth:t.width,sourceHeight:t.height,rotationZ:i.rotationZ,matrix:i.matrix,pressed:e.pressed===!0,...os(e)};return e.kind==="image"&&(a.imageSource=Ie(e.imageSource),a.imageType=e.imageType==null?null:Re(e.imageType),a.primitive=At(e.imageId,a.imageSource),a.imageColor=e.imageColor,a.imageId=e.imageId,Object.assign(a,us(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=Re(e.horizontalAlignment),a.verticalAlignment=Re(e.verticalAlignment)),a}function Su(e,t=cr(e)){let i=[],r=ss(e,t);function n(a,o=[],s=[]){let c=t.get(a.Id);if(!c||a.visible===!1||!c.activeInHierarchy)return;let l=r.get(a.Id);if(!l)return;let u=bu(c,l),d=a.kind==="image"&&a.enableMask===!0?ar({...fs(a,c),id:a.Id},Qo(l,c.centerX,c.centerY)):null,h=d?[...s,d]:s,p=()=>i.push({...vu(a,c,u),...o.length?{clipPolygons:o}:{},...h.length?{masks:h}:{}});En.has(a.kind)&&a.kind!=="grid"&&p();let m=a.children||[];for(let y=m.length-1;y>=0;y-=1){let x=a._gridItems?.includes(m[y])?[...o,[[c.left,c.bottom],[c.right,c.bottom],[c.right,c.top],[c.left,c.top]].map(([E,I])=>xe(l,E,I))]:o;n(m[y],x,h)}a.kind==="grid"&&p()}for(let a of e.runtime.roots)n(a);return i}function fs(e,t){let i={kind:e.kind,name:e.name,sourceWidth:t.width,sourceHeight:t.height,pressed:e.pressed===!0,...os(e)};return e.kind==="image"&&(i.imageSource=Ie(e.imageSource),i.imageType=e.imageType==null?null:Re(e.imageType),i.primitive=At(e.imageId,i.imageSource),i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,us(e),{enableMask:e.enableMask===!0,enableSoftEdge:e.enableSoftEdge===!0,softEdgeMode:Re(e.softEdgeMode)||"Percentage",softEdgeWidthX:e.softEdgeWidthX,softEdgeWidthY:e.softEdgeWidthY})),(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=Re(e.horizontalAlignment),i.verticalAlignment=Re(e.verticalAlignment)),i}function wu(e,t,i){let r=Mr(e,t),n=xe(r,e.centerX,e.centerY);return{a:r.a,b:r.b,c:r.c,d:r.d,tx:n.x-(i?i.centerX:0),ty:n.y-(i?i.centerY:0)}}function ds(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.imageSource,e.imageType,e.fillType,e.fillHorizontalType,e.fillVerticalType,e.fillAmount,e.enableMask,e.enableSoftEdge,e.softEdgeMode,e.softEdgeWidthX,e.softEdgeWidthY,e.text,e.fontSize,e.fontColor,e.bgColor,e.enableOutline,e.outlineColor,e.horizontalAlignment,e.verticalAlignment,JSON.stringify(e.scroll),e.clipToParent].join(" ")}function hs(e,t,i,r,n,a){return{id:e.Id,parent:t,z:n,group:a>=16,matrix:wu(r,e,i),...fs(e,r)}}function Iu(e){let t=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,r=new Map,n=new Map;function a(c,l,u){let d=Ge(l,c);if(d.activeInHierarchy=u&&c.active!==!1,n.set(c.Id,d),c.visible===!1||!d.activeInHierarchy)return!1;let h=c.children||[],p=En.has(c.kind),m=0;for(let y=0;y<h.length;y+=1)a(h[y],d,d.activeInHierarchy)&&(p=!0,m+=1);return p?(i.add(c.Id),r.set(c.Id,m),!0):!1}function o(c,l,u,d){if(!i.has(c.Id))return;let h=n.get(c.Id);s.push(hs(c,l,u,h,d,r.get(c.Id)||0));let p=c.children||[];for(let m=0;m<p.length;m+=1)o(p[m],c.Id,h,m)}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:r}}function xn(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 r=0;r<i.length;r+=1)xn(i[r])}function xu(e,t){let i=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=[],n=[],a=t.count,o=e.runtime._playRemoved||[];for(let l=0;l<o.length;l+=1){let u=o[l];t.fingerprints.has(u)&&(n.push(u),t.fingerprints.delete(u),t.childCounts.delete(u),a-=1)}e.runtime._playRemoved=[];function s(l){t.fingerprints.has(l.Id)&&(n.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),a-=1);let u=l.children;for(let d=0;d<u.length;d+=1)s(u[d])}function c(l,u,d,h,p,m){let y=m||l._playDeepDirty===!0,x=y||l._playDirty===!0,E=y||l._playChildDirty===!0;if(!x&&!E)return;if(!(p&&l.active!==!1)||l.visible===!1){s(l);return}let O=Ge(u,l),N=t.childCounts.get(l.Id)||0;if(E){N=0;let A=l.children;for(let S=0;S<A.length;S+=1)c(A[S],O,l.Id,S,!0,y),t.fingerprints.has(A[S].Id)&&(N+=1)}if(!(En.has(l.kind)||N>0)){t.fingerprints.has(l.Id)&&(n.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),a-=1);return}let B=t.childCounts.get(l.Id);t.childCounts.set(l.Id,N);let Y=N>=16!=(B||0)>=16;if(!x&&!Y&&t.fingerprints.has(l.Id))return;let z=hs(l,d,u===i?null:u,O,h,N),b=ds(z);t.fingerprints.get(z.id)!==b&&(t.fingerprints.has(z.id)||(a+=1),t.fingerprints.set(z.id,b),r.push(z))}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:r,removed:n,count:a}}function Cu(e,t){let i=e.viewCache||(e.viewCache={rev:0,fingerprints:new Map,childCounts:new Map,count:0}),r=Number(t);if(!(Number.isFinite(r)&&r===i.rev&&i.fingerprints.size>0)){let{nodes:c,childCounts:l}=Iu(e);i.rev+=1,i.fingerprints=new Map(c.map(u=>[u.id,ds(u)])),i.childCounts=l,i.count=c.length;for(let u of e.runtime.roots)xn(u);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:a,removed:o,count:s}=xu(e,i);i.rev+=1;for(let c of e.runtime.roots)xn(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:s,changed:a,removed:o}}function An(e,{inspect:t=!1,view:i=!1,paint:r=!1,sceneRev:n,compact:a=!1}={}){lr(e),e.audioSessionId||=as();let o=e.runtime,s=e.compiled,[c,l]=[o.canvasWidth,o.canvasHeight];e.server&&e.server.setClock(o.clock.time);let u=a?o.logs.slice(-100):o.logs,d=yu(e),h=e.server?e.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};a&&(h.inbound=h.inbound.slice(-100),h.outbound=h.outbound.slice(-100),h.logs=h.logs.slice(-100));let p={canvasId:s.canvasId,platform:s.platform,device:o.device,canvasWidth:c,canvasHeight:l,canvasPresets:du,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(m,y)=>({index:y+1,label:`\u73A9\u5BB6${y+1}`,entityType:`Player${y+1}`})),time:o.clock.time,frame:o.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!o.clock.paused,audio:{sessionId:e.audioSessionId,playerIndex:e.viewPlayerIndex||1,...o.audioSnapshot()},mountError:e.mountError||o.mountErrors[0]||null,logs:u.map(m=>({source:"client",level:m.level,text:m.text,time:m.time})),tree:[],paint:[],scene:null,server:h,history:(a?d.slice(-100):d).map(m=>({t:m.t,source:m.source||"user",kind:m.kind,payload:m.payload||{}}))};if(t||r){let m=cr(e);t&&(p.tree=o.roots.map(y=>ls(y,m))),r&&(p.paint=Su(e,m))}return i&&(p.scene=Cu(e,n)),_t(p),p}function ur(e,t=1/30){let i=e.runtimes||(e.runtime?[e.runtime]:[]);for(let r of i)r.step(t);e.server&&(e.server.setClock(e.runtime.clock.time),e.server.flush())}function _n(e,t){it(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function ku(e,t){let i=null;for(let r of e.runtime.roots)ze(r,n=>{!i&&n.name===t&&(i=n)});return i}function Pn(e,t){it(e,{kind:"click",payload:{name:String(t)}});let i=ku(e,t);i&&Tn(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function Eu(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var ms={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function ps(e,t){let i=[];for(let[r,n]of Object.entries(ms)){let a=t[n]?Eu(t,t[n]):null;a&&i.push({state:r,child:a})}return i}function Au(e){for(let t of e.runtime.roots)ze(t,i=>{if(i.kind==="button"){for(let{child:r}of ps(e,i))e.stateRestores.has(r.Id)||e.stateRestores.set(r.Id,{child:r,active:r.active,visible:r.visible}),r.active=!0,r.visible=!1,typeof r.markPlayDirty=="function"&&r.markPlayDirty(!0);yi(e,i)}})}function yi(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 r of ps(e,t))r.child.active=!0,r.child.visible=r.state===i,typeof r.child.markPlayDirty=="function"&&r.child.markPlayDirty(!0)}function In(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(ms).map(r=>t[r]).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 gs(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function ys(e,t){let i=e.Id,r=t.get(i);if(r!==void 0)return r;let n=Tn(e);if(!n&&gs(e)){let a=e.children;for(let o=0;o<a.length;o+=1)if(ys(a[o],t)){n=!0;break}}return t.set(i,n),n}function or(e,t,i){lr(e);let r=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=new Map;function a(s,c,l,u){if(!u||s.active===!1||s.visible===!1||!ys(s,n))return null;let d=Ge(c,s),h=ti(l,d,s),p=Ve(h);if(!p)return null;let m=xe(p,t,i);if(m.x<d.left||m.x>d.right||m.y<d.bottom||m.y>d.top)return null;if(sr(s)){let y=$t(s._scroll,d.width,d.height)?.track,x=m.x-d.centerX,E=d.centerY-m.y;if(y&&x>=y.x&&x<=y.x+y.width&&E>=y.y&&E<=y.y+y.height)return s}if(gs(s))for(let y=0;y<s.children.length;y+=1){let x=a(s.children[y],d,h,!0);if(x)return x}return Tn(s)?s:null}let o=Pt();for(let s=e.runtime.roots.length-1;s>=0;s-=1){let c=a(e.runtime.roots[s],r,o,!0);if(c)return c}return null}function Gt(e,t,i,{dragging:r=!1,press:n=null,previous:a=null}={}){let o=n||{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:r})}function Cn(e,t,i){t.kind==="grid"||t.kind==="textwindow"||(t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),yi(e,t))}function sr(e){if(!e?.alive||!e.activeInHierarchy||e.interactable===!1||e.raycastTarget===!1)return!1;for(let t=e;t;t=t.parent)if(t.visible===!1)return!1;return e._scroll?.max>0}function is(e){for(let t=e;t;t=t.parent)if(sr(t))return t;return null}function rs(e,t,i,r){let n=cr(e),a=n.get(t.Id),o=ss(e,n).get(t.Id),s=o&&Ve(o);if(!a||!s)return null;let c=xe(s,i,r);return{x:c.x-a.centerX,y:a.centerY-c.y,width:a.width,height:a.height}}function ns(e,t,i){let r=e.pointerDownControl;if(r?.alive){let n=Gt(e,t,i,{dragging:e.pointerDragging,press:e.pointerDownPosition,previous:e.pointerLastPosition});e.runtime.injectCursor(r,"CursorUp",n),e.pointerDragging&&!e.pointerScroll&&e.runtime.injectCursor(r,"CursorEndDrag",n),Cn(e,r,!1)}e.pointerDownControl=null,e.pointerScroll=null,e.pointerDownPosition=null,e.pointerDragging=!1,e.pointerLastPosition={x:t,y:i}}function bi(e,t,i,r,n={}){let a=Number(i),o=Number(r);if(!Number.isFinite(a)||!Number.isFinite(o))throw new Error("pointer coordinates must be finite");e.runtime.cursor.x=a,e.runtime.cursor.y=o;let s=Number(n.deltaX??0),c=Number(n.deltaY??0);if(t==="wheel"&&(!Number.isFinite(s)||!Number.isFinite(c)))throw new Error("wheel deltas must be finite");if(n.silent||it(e,{kind:"pointer",payload:{type:t,x:a,y:o,...t==="wheel"?{deltaX:s,deltaY:c}:{}}}),t==="wheel"){let l=or(e,a,o),u=is(l);if(u){let d=u._scroll.horizontal&&s||c;wn(u,u._scroll.offset+d)}return l}if(t==="cancel")return ns(e,a,o),null;if((t==="move"||t==="up")&&e.pointerScroll&&!sr(e.pointerScroll.control)&&ns(e,a,o),t==="move"){let l=e.pointerLastPosition||{x:a,y:o},u=e.pointerHoverControl,d=In(or(e,a,o)),h=Gt(e,a,o,{previous:l});u&&u!==d&&e.runtime.injectCursor(u,"CursorExit",h),d&&u!==d&&e.runtime.injectCursor(d,"CursorEnter",h),e.pointerHoverControl=d;let p=e.hoveredControl;e.hoveredControl=d?.kind==="button"?d:null,p&&p!==e.hoveredControl&&yi(e,p),e.hoveredControl&&yi(e,e.hoveredControl);let m=e.pointerDownControl,y=e.pointerScroll;if(y)if(!sr(y.control))e.pointerScroll=null;else{let x=rs(e,y.control,a,o);if(x){let E=y.control._scroll,I=E.horizontal?x.x-y.start.x:x.y-y.start.y,O=$t(E,x.width,x.height)?.travel||0,N=y.bar?O?I*E.max/O:0:-I;wn(y.control,y.offset+N)}}if(m?.alive){let x=e.pointerDownPosition||l,E=a!==l.x||o!==l.y;!e.pointerDragging&&E&&(y||e.runtime.injectCursor(m,"CursorBeginDrag",Gt(e,a,o,{press:x,previous:l,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&!y&&e.runtime.injectCursor(m,"CursorDrag",Gt(e,a,o,{press:x,previous:l,dragging:!0}))}return e.pointerLastPosition={x:a,y:o},d}if(t==="down"){let l=In(or(e,a,o));e.pointerDownControl=l,e.pointerDownPosition={x:a,y:o},e.pointerLastPosition={x:a,y:o},e.pointerDragging=!1,e.pointerScroll=null;let u=is(l);if(u){let d=rs(e,u,a,o),h=d&&$t(u._scroll,d.width,d.height),p=y=>d.x>=y.x&&d.x<=y.x+y.width&&d.y>=y.y&&d.y<=y.y+y.height,m=h&&p(h.track);if(m&&!p(h.thumb)){let y=u._scroll.horizontal?d.x-h.track.x-h.thumb.width/2:d.y-h.track.y-h.thumb.height/2;wn(u,h.travel?y/h.travel*u._scroll.max:0),lr(e)}d&&(e.pointerScroll={control:u,start:d,offset:u._scroll.offset,bar:!!m})}return l&&(Cn(e,l,!0),e.runtime.injectCursor(l,"CursorDown",Gt(e,a,o))),l}if(t==="up"){let l=e.pointerDownControl,u=In(or(e,a,o));if(l?.alive){let d=Gt(e,a,o,{press:e.pointerDownPosition,previous:e.pointerLastPosition,dragging:e.pointerDragging});if(e.runtime.injectCursor(l,"CursorUp",d),e.pointerDragging)e.pointerScroll||e.runtime.injectCursor(l,"CursorEndDrag",d);else if(u===l&&!e.pointerScroll?.bar){e.runtime.injectCursor(l,"CursorClick",d);let h=e.selectedControl;e.selectedControl=l.kind==="button"?l:null,h&&h!==e.selectedControl&&yi(e,h)}Cn(e,l,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:a,y:o},e.pointerDragging=!1,e.pointerScroll=null,u}if(t==="click")return bi(e,"down",a,o,{silent:!0}),bi(e,"up",a,o,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function Rn(e,t,i,r){if(!e?.server)throw new Error("play session has no server");return it(e,{kind:"serverSet",payload:{entityType:t,name:i,value:r,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,r,{playerIndex:e.viewPlayerIndex})}function bs(e,t,i){if(!e?.server)throw new Error("play session has no server");let r=e.server.getVar(t,i,{playerIndex:e.viewPlayerIndex});return r===void 0?null:r}function Mn(e,t,i=[],r="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return it(e,{kind:"serverSend",payload:{name:t,params:i,target:r,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:r,playerIndex:e.viewPlayerIndex})}function fr(e){return{snapshot:t=>An(e,t),step:t=>ur(e,t),pointer:(t,i,r,n)=>bi(e,t,i,r,n),key:t=>_n(e,t),click:t=>Pn(e,t),view:t=>kn(e,t),pause:()=>{it(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{it(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,r)=>Rn(e,t,i,r),serverSend:(t,i,r)=>Mn(e,t,i,r)}}function Nn(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 vs(e,t){for(let i of e||[])t(i),i.children?.length&&vs(i.children,t)}function Fn(e,{id:t,name:i}){let r=null;return vs(e,n=>{r||(t&&String(n.id)===String(t)||!t&&i&&n.name===i)&&(r=n)}),r}function _u(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 Pu(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=Fn(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(r=>({name:r.name,values:r.values}))}}}function Tu(e,t){if(e.kind==="log"){let i=e.source==="server"?t.server?.logs||t.serverLogs||[]:t.logs||[];return i.some(n=>e.level&&n.level!==e.level?!1:String(n.text||"").includes(e.contains))?{ok:!0,actual:e.contains}:{ok:!1,actual:i.map(n=>n.text).slice(-8),expected:e.contains}}if(e.kind==="control"){let i=Fn(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let r=_u(i,e.field);return On(r,e.equals)?{ok:!0,actual:r}:{ok:!1,actual:r,expected:e.equals}}if(e.kind==="var"){let i=t.server?.vars?.[e.entityType],n=!i||!Object.prototype.hasOwnProperty.call(i,e.name)?null:i[e.name].value;return On(n,e.equals)?{ok:!0,actual:n}:{ok:!1,actual:n,expected:e.equals}}if(e.kind==="signal"){let i=e.direction==="outbound"?t.server?.outbound||[]:t.server?.inbound||[],r=i.find(n=>n.name===e.name&&(e.values===void 0||On(n.values,e.values)));return r?{ok:!0,actual:r.values}:{ok:!1,actual:i.map(n=>({name:n.name,values:n.values})),expected:{name:e.name,values:e.values??null}}}if(e.kind==="tree"){let i=!!Fn(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 Ru(e,t){let i=fi();try{return i.evalQueryScript(e,Pu(t)),{ok:!0,actual:!0}}catch(r){return{ok:!1,message:r?.message||String(r)}}finally{i.destroy()}}function Ss(e,t){return e.kind==="lua"?Ru(e.source,t):Tu(e,t)}function Mu(e,t){let i=t>0?t:yt;return Math.round((e+i)*1e9)/1e9}function Nu(e,t){let i=t.payload||{};if(t.kind==="pointer")e.pointer(i.type,i.x,i.y,i);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 Ou(e,t){let i=Ss(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 ws(e,t){let i=gi(t),r=i.events.slice().sort((E,I)=>E.t-I.t),n=i.asserts.slice(),a=i.dt||yt,o=r.reduce((E,I)=>Math.max(E,I.t),0),s=n.reduce((E,I)=>Math.max(E,Number(I.at||0)),0),c=Math.max(o,s),l=0,u=[],d=0,h=n.some(E=>E.kind==="control"||E.kind==="tree"||E.kind==="lua"),p=e.snapshot({inspect:h}),m=()=>{for(;l<r.length&&r[l].t<=d+1e-9;)Nu(e,r[l]),l+=1,p=e.snapshot({inspect:h})},y=()=>{for(let E of n)if(!E._done&&Number(E.at||0)<=d+1e-9){let I=Ou(E,p);if(u.push(I),E._done=!0,!I.ok)return{passed:!1,failedAt:d,frame:p.frame||0,results:u,snapshot:p}}return null};m();let x=y();if(x)return Dn(i,x);for(;d+1e-9<c;){e.step(a),d=Mu(d,a),p=e.snapshot({inspect:h}),m();let E=y();if(E)return Dn(i,E)}return Dn(i,{passed:u.every(E=>E.ok),failedAt:null,frame:p.frame||0,results:u,snapshot:p})}function Dn(e,t){return G({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 zn(e){return Array.isArray(e)?e.slice():[]}var Vu={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(pt.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function Hu(e,t=1){let i=e?.vars||{},r=[],n=Number(t)>0?Number(t):1,a=["Level","PlayerSelf","AvatarSelf"];if(n>1)for(let s=1;s<=n;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))r.push(G({entityType:s,entityLabel:Vu[s]||s,name:l,type:c[l]?.type||"",value:c[l]?.value??null}))}return r}var vt="qxqy-simulator-save",Yu="qxqy-simulator-scripts",se="server-control-template",L="client-control-template",$n={[se]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[L]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function bt(e){return e===L?"client":"server"}function dr(e){if(!(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e.trim()))||!_e(e))throw new Error("\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F 1\u20132147483647 \u8303\u56F4\u5185\u7684\u6574\u6570");return Number(e)}function Gn(e=[]){if(!Array.isArray(e))throw new Error("controlGuidChanges \u5FC5\u987B\u662F\u6570\u7EC4");let t=new Set;return e.map(i=>{if(!i||typeof i.id!="string"||!i.id||t.has(i.id)||![se,L].includes(i.controlAsset)||typeof i.controlId!="string"||!i.controlId||typeof i.controlName!="string")throw new Error("controlGuidChanges \u5305\u542B\u65E0\u6548\u6216\u91CD\u590D\u7684\u53D8\u66F4\u8BB0\u5F55");return t.add(i.id),{id:i.id,controlAsset:i.controlAsset,controlId:i.controlId,controlName:i.controlName,oldGuid:dr(i.oldGuid),newGuid:dr(i.newGuid)}})}function Bu(e){let t=[e?.guid,e?.id];for(let i of t){let r=Number(i);if(Number.isSafeInteger(r)&&r>0&&r<=2147483647)return r}return 0}function hr(e){let t=String(e?.controlAsset||""),i=Bu(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===L||t==="client"?L:t===se||t==="server"?se:""}}function Uu(e){let t=[],i=(r,n="")=>{if(r&&(r.path||r.source)){let a=hr(r);t.push(n?{...a,controlAsset:n}:a)}};if(Array.isArray(e?.assets?.scripts)){for(let r of e.assets.scripts)r&&(r.path||r.source)&&t.push(hr(r));return t}if(i(e?.assets?.server?.script,se),i(e?.assets?.client?.script,L),e&&e.format!==vt){i(e?.script);for(let r of e?.scripts||[])i(r)}return t}function Vn(e){return et(e===L?Rt():ut())}var ju="\u672A\u7ED1\u5B9A",Vt="\u672A\u547D\u540D\u5B58\u6863",Lu="\u672A\u547D\u540D\u754C\u9762";function Xu(e){let t=e;for(let i=0;i<8;i++){if(vi(Is(t,"simulator","studio"))&&vi(Is(t,"lua")))return t;let r=$u(t);if(r===t)break;t=r}return e}function qu(e){return e?{name:Ht(e),path:e,bound:!0}:{name:ju,path:"",bound:!1}}function Wu(e,t=process.cwd()){if(Gu(e)&&vi(e))return e;let i=t||process.cwd(),r=Xu(i),n=xs(r,e);if(vi(n))return n;let a=xs(i,e);if(vi(a))return a;throw new Error("script file not found: "+e)}function Hn(e,t={}){e?.format===vt&&Qr(e.version);let i=[],r=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",n=e?.format===vt&&e.assets,a=Gn(e?.controlGuidChanges),o=Jt(e?.scriptSync),s=n?null:et(e,{warnings:i}),c={server:n&&e.assets.server?et(e.assets.server,{warnings:i}):Vn(se),client:n&&e.assets.client?et(e.assets.client,{warnings:i}):Vn(L)};s&&(c[bt(s.meta.assetType)]=s);let l=n&&e.activeAssetType===L?L:s?.meta.assetType||se,u=n&&e.meta?.name?String(e.meta.name):"",d=()=>u||Vt;!e?.meta?.name&&c.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(c.server.meta.name=Lu);let h=[],p=new Set;function m(){p.clear(),Tt(c.server.root,p),Tt(c.client.root,p,{skipServerContainer:!0});for(let g of h)_e(g.guid)&&p.add(Number(g.guid))}function y(g=0){m();let v=_e(g)&&!p.has(Number(g))?Number(g):We(p);return p.add(v),v}function x(g){let v=hr(g),w=y(v.guid);return{...v,guid:w,id:String(w)}}Le(Uu(e));let E=pi(e?.serverLogic),I=null,O="",N=1,H=1;function B(g){let v=String(g||"").trim();if(!v)return"";if(!J[v])throw new Error(`unknown canvas preset: ${v} (available: ${Object.keys(J).join(", ")})`);return v}let Y=()=>c[bt(l)];function z(g){if(!g)return null;for(let[v,w]of[["server",c.server],["client",c.client]]){let T=fe(w.root,g);if(T&&T.kind!=="server-container")return{key:v,node:T}}return null}function b(g){if(!g.controlId)return null;let v=g.controlAsset===L?"client":g.controlAsset===se?"server":null;if(v){let w=fe(c[v].root,g.controlId);return w&&w.kind!=="server-container"?{key:v,node:w}:null}return z(g.controlId)}function A(){for(let g of h)g.controlId&&!b(g)&&(g.controlId="",g.controlAsset="")}function S(g){if(!_e(g))return null;for(let[v,w]of[[se,c.server],[L,c.client]]){let T="";if(Q(w.root,M=>{!T&&(M.scriptMappingIds||[]).includes(Number(g))&&(T=M.id)}),T)return{controlId:T,controlAsset:v}}return null}function C(g,v,w){let T=c[bt(g.controlAsset)],M=T&&fe(T.root,g.controlId);M&&(M.scriptMappingIds=(M.scriptMappingIds||[]).map(D=>Number(D)===Number(v)?Number(w):D))}A();function F(){return h.map(g=>{let v=b(g),w=v?v.key==="client"?L:se:"";return G({id:g.id,guid:g.guid||0,path:g.path||"",source:g.source||"",controlId:g.controlId||"",controlAsset:g.controlAsset||w,controlName:v?.node.name||"",assetType:w,assetLabel:v?$n[w]:"",mounted:!!v})})}function k(){let g=[],v=(w,T)=>{Q(w.root,M=>{M.kind!=="server-container"&&g.push(G({id:M.id,name:M.name,kind:M.kind,assetType:T,assetLabel:$n[T]}))})};return v(c.server,se),v(c.client,L),g}function _(g){let v=[];return Q(g.root,w=>{w.kind!=="server-container"&&v.push(JSON.stringify({kind:w.kind,guid:w.guid,name:w.name,text:w.text??null,imageId:w.imageId??null,imageSource:w.imageSource??null,imageType:w.imageType??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}))}),v.join("/")}let $=_(Rt()),V=_(ut());function re(g){let v=_(g);return g.meta?.assetType===L?v===$:v===V}function X(g,v){return String(g||"").replace(/[\\/:*?"<>|]/g,"-").trim()||v}function te(g){let v=X(d(),Vt),w=g.meta?.assetType===L?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${v} \xB7 ${w}`}function Ae(){if(!((c.server.root.children||[]).find(v=>v.kind==="container")||c.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 Qa(c.server,c.client,{scripts:h,fileName:`${X(d(),Vt)} \xB7 \u6574\u5408\u5305.gia`})}function Ct(){let g=v=>({type:v.meta.assetType,name:v.meta.name,sourceFile:v.meta.sourceFile||""});return{format:vt,name:d(),activeAssetType:l,assets:{server:g(c.server),client:g(c.client),scripts:F()}}}function jt(){return G({format:vt,version:4,meta:{name:d()},activeAssetType:l,serverLogic:E,controlGuidChanges:a,scriptSync:o,assets:{server:c.server,client:c.client,scripts:h.map(g=>G({id:g.id,guid:g.guid||0,path:g.path||"",source:g.source||"",controlId:g.controlId||"",controlAsset:g.controlAsset||""}))}})}function ne(){let g=Y(),v=po(g);return v.workspace=qu(r),v.save=Ct(),v.scripts=F(),v.mountTargets=k(),v.serverLogic=E,v.migrationWarnings=[...i],v.controlGuidChanges=G(a),v.scriptSync=G(o),xa(v),v}function Me(g){let v=Y();if(g.expectedRevision!==void 0&&Number(g.expectedRevision)!==v.version)throw new Error(`revision conflict: expected ${g.expectedRevision}, current ${v.version}`);return v}function at(g,v,w=""){let T=String(v||"");if(T){let M=w===L?L:w===se?se:"";if(!b({controlId:T,controlAsset:M}))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");g.controlAsset=M}else g.controlAsset="";g.controlId=T}function Ei(g){let v=Me(g);if(g.op==="addScript"){let w=x({path:String(g.path||""),source:String(g.source||""),controlId:"",controlAsset:""});g.controlId!==void 0&&g.controlId!==""&&at(w,g.controlId,g.controlAsset),h.push(w)}else if(g.op==="updateScript"){let w=h.find(T=>T.id===g.id);if(!w)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${g.id}`);g.controlId!==void 0&&at(w,g.controlId,g.controlAsset),g.path!==void 0&&(w.path=String(g.path)),g.source!==void 0&&(w.source=String(g.source))}else if(g.op==="removeScript"){let w=h.length;if(h=h.filter(T=>T.id!==g.id),h.length===w)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${g.id}`)}return v.version+=1,ne()}function Ai(g){let v=Me(g),w=fe(v.root,g.id??v.selectedId);if(!w||w.kind==="server-container")throw new Error("\u4EC5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5141\u8BB8\u4FEE\u6539\u7D22\u5F15");let T=dr(g.guid),M=dr(w.guid);if(T===M)return ne();let D=[];for(let j of Object.values(c))Q(j.root,oe=>{j===c.client&&oe.kind==="server-container"||D.push({node:oe,project:j})});if(D.some(j=>j.node!==w&&Number(j.node.guid)===T)||h.some(j=>Number(j.guid)===T))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${T} \u5DF2\u88AB\u5176\u4ED6\u63A7\u4EF6\u6216\u811A\u672C\u5360\u7528`);let U=[],K=(j,oe,Fe)=>{let ie=j?.[oe];(typeof ie=="number"||typeof ie=="string"&&/^\d+$/.test(ie.trim()))&&Number(ie)===M&&U.push({owner:j,key:oe,project:Fe.project})};for(let j of D)K(j.node,"referencedPrefabId",j),K(j.node,"itemPrefabId",j),K(j.node.giaRaw,"templateRefSlot",j);if(U.length&&D.filter(j=>Number(j.node.guid)===M).length!==1)throw new Error(`\u65E7\u7D22\u5F15 ${M} \u5728\u591A\u68F5\u8D44\u4EA7\u6811\u4E2D\u91CD\u590D\uFF0C\u65E0\u6CD5\u786E\u5B9A\u6A21\u677F\u5F15\u7528\u5F52\u5C5E\uFF1B\u8BF7\u5148\u6D88\u9664\u6B67\u4E49\u540E\u4FEE\u6539`);let Oe={id:zu(),controlAsset:l,controlId:w.id,controlName:w.name,oldGuid:M,newGuid:T};w.guid=T;let me=new Set([v]);for(let{owner:j,key:oe,project:Fe}of U)j[oe]=typeof j[oe]=="string"?String(T):T,me.add(Fe);a.push(Oe);for(let j of me)j.version+=1;return ne()}function ae(g){let v=Me(g);if(!Array.isArray(g.changeIds)||!g.changeIds.length||g.changeIds.some(T=>typeof T!="string"||!a.some(M=>M.id===T)))throw new Error("\u8BF7\u660E\u786E\u6307\u5B9A\u5DF2\u6838\u5BF9 Lua \u5F15\u7528\u7684\u6709\u6548\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55 changeIds");let w=new Set(g.changeIds);return a=a.filter(T=>!w.has(T.id)),v.version+=1,ne()}function Ne(g){if(!g||typeof g!="object")throw new Error("patch requires op");if(g.op==="setScriptSync"){let v=Me(g);return o=Jt(g.config),v.version+=1,ne()}if(g.op==="setControlGuid")return Ai(g);if(g.op==="acknowledgeControlGuidChanges")return ae(g);if(g.op==="setServerLogic"){let v=Me(g);return E=pi(g.logic),v.version+=1,ne()}if(g.op==="addScript"||g.op==="updateScript"||g.op==="removeScript")return Ei(g);if(g.op==="selectAsset")return l=g.assetType===L?L:se,ne();if(g.op==="renameSave"){let v=String(g.name||"").trim();if(!v)throw new Error("\u5B58\u6863\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");return u=v,ne()}if(g.op==="newAsset"){let v=Me(g);l=g.assetType===L?L:se;let w=Vn(l);return w.version=v.version+1,c[bt(l)]=w,a=a.filter(T=>T.controlAsset!==l),A(),ne()}return rn(Y(),g),A(),ne()}function $e(g){return h.filter(v=>{let w=b(v);return!!(w&&w.key==="client"==(g===L))})}function Lt(g="json",v=""){let w=Xt(g,v);if(a.length&&!["save","archive"].includes(String(g).toLowerCase())){let T=a.map(M=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${$n[M.controlAsset]} / ${M.controlName} (${M.controlId})\uFF1A${M.oldGuid} \u2192 ${M.newGuid}\u3002\u8BF7\u6309\u8BED\u4E49\u66F4\u65B0\u811A\u672C\u4E2D\u7684\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\uFF0C\u6838\u5BF9\u540E\u786E\u8BA4\u53D8\u66F4\u8BB0\u5F55 ${M.id}\uFF1B\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\u3002`);w.warnings=[...new Set([...w.warnings||[],...T])]}return w}function Xt(g="json",v=""){let w=String(g).toLowerCase();if(w==="save"||w==="archive"){let D=Buffer.from(JSON.stringify(jt(),null,2),"utf8");return G({filename:`${d().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:D.toString("base64"),warnings:[]})}if(w==="save-gia"||w==="archive-gia"){let D=[],U=[],K=(me,j="")=>{let oe=Lt(me,j);D.push(G({filename:oe.filename,mimeType:oe.mimeType,encoding:oe.encoding,data:oe.data,warnings:oe.warnings||[]})),U.push(...oe.warnings||[])},Oe=(me,j)=>{let oe=c[bt(me)],Fe=me===l,ie=h.some(ve=>ve.controlAsset===me&&ve.controlId);if(!Fe&&re(oe)&&!ie){U.push(j);return}K("gia",me)};if(Oe(se,"\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"),Oe(L,"\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"),h.some(me=>me.path||me.source)&&K("scripts-gia"),!D.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 G({format:"qxqy-gia-package",files:D,warnings:[...new Set(U)]})}if(w==="gia-combined"||w==="combined-gia"||w==="combined"){let D=Ae();return G({filename:`${X(d(),Vt)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:D.buffer.toString("base64"),warnings:[...new Set(D.warnings||[])]})}if(w==="scripts"){let D=G({format:Yu,version:1,scripts:h.map(K=>G({id:K.id,guid:K.guid||0,path:K.path||"",source:K.source||"",controlId:K.controlId||"",controlAsset:K.controlAsset||""}))}),U=Buffer.from(JSON.stringify(D,null,2),"utf8");return G({filename:`${X(d(),Vt)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:U.toString("base64"),warnings:[]})}if(w==="scripts-gia"||w==="scriptsgia"){let D=io(h);return G({filename:`${X(d(),Vt)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:D.buffer.toString("base64"),warnings:D.warnings})}if(w==="lua"){let D=h.find(K=>K.id===v)||h.find(K=>K.path===v);if(!D)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let U=Ht(D.path||"")||`qxqy-script-${D.id}`;return G({filename:/\.lua$/i.test(U)?U:`${U}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(D.source||"","utf8").toString("base64"),warnings:[]})}let T=v?c[bt(v)]:Y(),M=te(T);if(w==="json"){let D=G({...T,scripts:$e(T.meta.assetType),controlGuidChanges:a.filter(K=>K.controlAsset===T.meta.assetType)}),U=Buffer.from(JSON.stringify(D,null,2),"utf8");return G({filename:`${M}.json`,mimeType:"application/json",encoding:"base64",data:U.toString("base64"),warnings:[]})}if(w==="gia"){let D=Za(T,T.meta.assetType===L?{scripts:$e(L)}:{}),U=T.meta.assetType===L?[]:$e(se);return U.length&&D.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${U.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`),G({filename:`${M}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:D.buffer.toString("base64"),warnings:D.warnings})}throw new Error(`unsupported export format: ${g}`)}function Le(g){for(let v of g){let w=hr(v);if(!w.path&&!w.source)continue;let T=w.controlId?null:S(w.guid),M=x(T?{...w,...T}:w);T&&M.guid!==w.guid&&C(T,w.guid,M.guid),M.controlId&&!b(M)&&(M.controlId="",M.controlAsset=""),h.push(M)}}function qt(g,v,w=""){let T=String(g||"").toLowerCase();if(typeof v!="string"||!v)throw new Error("import data is required");let M=Buffer.from(v,"base64"),D,U=[],K={};if(T==="json"){try{D=JSON.parse(M.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(D?.project&&(D=D.project),D?.format===vt&&D?.assets){Qr(D.version);let ie=Hn(D);U.push(...ie.get().migrationWarnings);let ve=ie.archiveData();return c.server=ve.assets.server,c.client=ve.assets.client,i=[...U],l=D.activeAssetType===L?L:se,u=String(D.meta?.name||Ht(w).replace(/\.json$/i,"")||u),E=ve.serverLogic,h=ve.assets.scripts,a=ve.controlGuidChanges,o=ve.scriptSync,p.clear(),G({snapshot:ne(),warnings:U,metadata:{format:vt}})}}else{if(T==="lua")return h.push(x({path:Ht(w||"imported.lua"),source:M.toString("utf8"),controlId:""})),G({snapshot:ne(),warnings:U,metadata:{assetType:"lua-script"}});if(T==="gia"){if(ro(M)){let we=ao(M);return Le(we.scripts),G({snapshot:ne(),warnings:we.warnings,metadata:we.metadata})}let ie=oo(M);D=ie.project,U=ie.warnings,K=ie.metadata,ie.clientProject&&(c.client=et(ie.clientProject),a=a.filter(we=>we.controlAsset!==L),U.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 ve=new Map,ma=(we,Dl)=>{we&&Q(we.root,pa=>{for(let Tr of pa.scriptMappingIds||[]){let ga=ve.get(Number(Tr));if(ga){U.push(`\u811A\u672C GUID ${Tr} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${ga.controlAsset===se?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}ve.set(Number(Tr),{controlId:pa.id,controlAsset:Dl})}})};ma(ie.project,se),ma(ie.clientProject,L),Le((ie.scripts||[]).map(we=>ve.has(Number(we.guid))?{...we,...ve.get(Number(we.guid))}:we))}else throw new Error(`unsupported import format: ${g}`)}let Oe=et(D,{warnings:U}),me=Gn(D?.controlGuidChanges);if(me.some(ie=>ie.controlAsset!==Oe.meta.assetType))throw new Error("\u5355\u8D44\u4EA7 JSON \u7684\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u5BFC\u5165\u8D44\u4EA7");let j=Gn([...a.filter(ie=>ie.controlAsset!==Oe.meta.assetType),...me]);i=[...U];let oe=bt(Oe.meta.assetType);c[oe]=Oe,a=j,l=Oe.meta.assetType;let Fe=c[oe];return w&&(Fe.meta.name=Ht(w).replace(/\.(json|gia)$/i,"")||Fe.meta.name,Fe.meta.sourceFile=Ht(w),Fe.meta.sourceFormat=T),Le(D?.scripts||[]),D?.script&&(D.script.path||D.script.source)&&Le([D.script]),G({snapshot:ne(),warnings:U,metadata:K})}function gl(g,v){return rn(Y(),{op:"pick",x:g,y:v}),ne()}function yl(g){let v=typeof g=="string"&&g?g:"";!v||v===r||(r=v)}function bl(g){let v=g.source||"";if(!v.trim()&&g.path.trim())try{v=Du(Wu(g.path,r),"utf8")}catch(w){throw new Error(`\u811A\u672C ${g.path} \u8BFB\u53D6\u5931\u8D25: ${w?.message||w}`)}return v}function Wt(g={}){let v=B(g.canvasId);v&&(O=v),g.playerCount!==void 0&&g.playerCount!==null&&g.playerCount!==""&&(N=mt(g.playerCount),H>N&&(H=1)),g.viewPlayerIndex!==void 0&&g.viewPlayerIndex!==null&&g.viewPlayerIndex!==""&&(H=Ue(g.viewPlayerIndex,N)),I&&Nn(I);let w=h.map(M=>{try{return{id:M.id,guid:M.guid||0,path:M.path||M.id,source:bl(M),controlId:M.controlId||"",controlAsset:M.controlAsset||""}}catch(D){return{id:M.id,guid:M.guid||0,path:M.path||M.id,source:`error([==[ ${String(D.message).replace(/]=+]/g,"] =]")} ])`,controlId:M.controlId||"",controlAsset:M.controlAsset||""}}}),T=M=>w.filter(D=>{let U={controlId:D.controlId,controlAsset:D.controlAsset},K=D.controlId?b(U):null;return!!(K&&K.key===M)});return I=cs(c.server,{templatesProject:c.client,scripts:w,sceneScripts:T("server"),templateScripts:T("client"),serverConfig:{logic:E},canvasId:O,playerCount:N,viewPlayerIndex:H,language:g.language||""}),ue(g)}function vl(g,v={}){let w=B(g);if(!w)throw new Error("playSetCanvas requires canvasId");return Wt({...v,canvasId:w})}function ue(g={}){if(!I)return G({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let v=An(I,g);return v.running=!0,v.logs=zn(v.logs),v.serverLogs=zn(v.server?.logs||[]),v.serverVars=Hu(v.server,v.playerCount||1),v}function Sl(g,v={}){return I||Wt(),ur(I,g),v.observe===!1?G({running:!0,time:I.runtime.clock.time,frame:I.runtime.clock.frame,paused:!!I.debugPaused,levelTimePaused:!!I.runtime.clock.paused,playerCount:I.playerCount||1,viewPlayerIndex:I.viewPlayerIndex||1}):ue(v)}function wl(g=0){Wt();let v=Math.max(0,Number(g)||0);for(let w=0;w<v;w++)ur(I,1/30);return ue()}function Il(){return I&&Nn(I),I=null,O="",N=1,H=1,G({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function xl(g,v={}){let w=Kt();return H=kn(w,g),v.observe===!1?null:ue(v)}function Cl(g,v={}){if(!I)throw new Error("play session has not started");return _n(I,g),v.observe===!1?null:ue(v)}function kl(g,v={}){if(!I)throw new Error("play session has not started");return Pn(I,g),v.observe===!1?null:ue(v)}function El(g,v,w,T={}){if(!I)throw new Error("play session has not started");return bi(I,g,v,w,T),T.observe===!1?null:ue(T)}function Al(g={}){return I&&fr(I).pause(),g.observe===!1?null:ue(g)}function _l(g={}){return I&&fr(I).resume(),g.observe===!1?null:ue(g)}function Kt(){if(!I)throw new Error("play session has not started");return I}function Pl(g,v){let w=Kt();if(!g&&!v){let T=ue();return G({vars:T.serverVars||[]})}return G({entityType:String(g||""),name:String(v||""),value:bs(w,g,v)})}function Tl(g,v,w){let T=Kt();return Rn(T,g,v,w),ue()}function Rl(g,v=[],w="PlayerSelf"){let T=Kt();return Mn(T,g,v,w),ue()}function Ml(){let g=ue();return G({events:g.history||[],case:qo(g.history||[],{playerCount:g.playerCount||1})})}function Nl(g={}){let v=ue(),w=gi({name:g.name||"",dt:g.dt,playerCount:g.playerCount||v.playerCount||1,events:g.events||v.history||[],asserts:g.asserts||[]});return G(w)}function Ol(g,v={}){let w=gi(g);Wt({...v,playerCount:v.playerCount||w.playerCount||1});let T=Kt();T.recording=!1;try{return ws(fr(T),g)}finally{T.recording=!0}}function Fl(){if(!I)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let g=I.runtime.clock;return{running:!0,paused:!!I.debugPaused,levelTimePaused:!!g.paused,time:g.time,frame:g.frame,playerCount:I.playerCount||1,viewPlayerIndex:I.viewPlayerIndex||1}}let ha={get:ne,patch:Ne,setWorkspace:yl,exportData:Lt,importData:qt,pick:gl,playStart:Wt,playSetCanvas:vl,playSetView:xl,playGet:ue,playStatus:Fl,playStep:Sl,playRun:wl,playStop:Il,playKey:Cl,playClick:kl,playPointer:El,playPause:Al,playResume:_l,playServerGet:Pl,playServerSet:Tl,playServerSend:Rl,playHistory:Ml,playSaveCase:Nl,playRunCase:Ol,archiveData:jt};return Object.defineProperty(ha,"_project",{enumerable:!1,get:Y}),ha}import{createRequire as Zu}from"node:module";function Yn(e,t,i){if(e.fillType!=="Horizontal"&&e.fillType!=="Vertical")return null;let r=Number(e.fillAmount??1),n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1;if(e.fillType==="Horizontal"){let o=t*n;return{x:e.fillHorizontalType==="Right"?t/2-o:-t/2,y:-i/2,width:o,height:i}}let a=i*n;return{x:-t/2,y:e.fillVerticalType==="Top"?-i/2:i/2-a,width:t,height:a}}function Cs(e,t,i){let r=t?.m_Rect,n=t?.m_RD?.textureRectOffset,a=t?.m_RD?.textureRect,o=Math.round(Number(r?.width)),s=Math.round(Number(r?.height)),c=Math.round(Number(n?.X)),l=Math.round(Number(n?.Y)),u=Math.round(Number(a?.width)),d=Math.round(Number(a?.height)),h=t?.m_RD?.settingsRaw?.packingRotation;if(![o,s,u,d].every(y=>Number.isInteger(y)&&y>0&&y<=8192)||o*s>16777216||!Number.isFinite(c)||!Number.isFinite(l)||c<0||l<0||c+u>o||l+d>s)throw new Error("Invalid sprite dimensions or trim offset");if(h&&h!=="None")throw new Error(`Unsupported sprite packing rotation: ${h}`);let p=i(o,s),m=p.getContext("2d");if(e.width===o&&e.height===s)m.drawImage(e,0,0);else{if(e.width!==u||e.height!==d)throw new Error("Sprite PNG does not match its trim metadata");m.drawImage(e,c,s-l-d)}return p}function ks(e,t,i){let r=Number(t??4294967295)>>>0;if((r&16777215)===16777215)return e;let n=i(e.width,e.height),a=n.getContext("2d");a.drawImage(e,0,0);let o=a.getImageData(0,0,n.width,n.height),s=r>>>16&255,c=r>>>8&255,l=r&255;for(let u=0;u<o.data.length;u+=4)o.data[u]=Math.round(o.data[u]*s/255),o.data[u+1]=Math.round(o.data[u+1]*c/255),o.data[u+2]=Math.round(o.data[u+2]*l/255);return a.putImageData(o,0,0),n}function Ku(e){return!!e?.border&&Object.values(e.border).some(t=>Number.isFinite(t)&&t>0)}function As(e,t){let i=typeof t=="object"?t?.Name:t;return Ku(e)&&i!=="Basic"?"Stretch":"Basic"}function _s(e){if(!e)return null;let t=Number(e.m_Rect?.width),i=Number(e.m_Rect?.height);if(![t,i].every(n=>Number.isFinite(n)&&n>0&&n<=8192)||t*i>16777216)throw new Error("Invalid image metadata dimensions");let r={};for(let[n,a]of[["left","X"],["bottom","Y"],["right","Z"],["top","W"]]){let o=Number(e.m_Border?.[a]??0);if(!Number.isFinite(o))throw new Error("Invalid image border");r[n]=Math.max(0,o)}return{width:t,height:i,border:r}}function Ju(e,t,i,r){t=Number.isFinite(t)?Math.max(0,t):0,i=Number.isFinite(i)?Math.max(0,i):0;let n=Math.min(1,e/(t+i||1));t*=n,i*=n;let a=Math.min(1,r/(t+i||1));return{source:[0,t,e-i,e],target:[0,t*a,r-i*a,r]}}var Es=new WeakMap;function Ps(e,t,i,r,n){let a=Math.max(0,i),o=Math.max(0,r),s=Math.min(1,4096/Math.max(1,a),4096/Math.max(1,o)),c=Math.max(1,Math.round(a*s)),l=Math.max(1,Math.round(o*s)),u=n(c,l),d=u.getContext("2d");if(!a||!o)return u;let h=Es.get(e);if(!h){let I=n(e.width,e.height),O=I.getContext("2d");O.drawImage(e,0,0),h=O.getImageData(0,0,e.width,e.height),Es.set(e,h)}let p=d.createImageData(c,l),m=h.data,y=(I,O,N,H,B,Y)=>{let{source:z,target:b}=Ju(O,N,H,B);return Array.from({length:Y},(A,S)=>{let C=(S+.5)*B/Y,F=C<b[1]?0:C<b[2]?1:2,k=b[F+1]>b[F]?(C-b[F])/(b[F+1]-b[F]):0,_=Math.max(0,Math.min(I-1,(z[F]+k*(z[F+1]-z[F]))*I/O-.5)),$=Math.floor(_);return[$,Math.min(I-1,$+1),_-$]})},x=y(e.width,t.width,t.border.left,t.border.right,a,c),E=y(e.height,t.height,t.border.top,t.border.bottom,o,l);for(let I=0;I<l;I++)for(let O=0;O<c;O++){let[N,H,B]=x[O],[Y,z,b]=E[I],A=(Y*e.width+N)*4,S=(Y*e.width+H)*4,C=(z*e.width+N)*4,F=(z*e.width+H)*4,k=m[A+3]*(1-B)*(1-b),_=m[S+3]*B*(1-b),$=m[C+3]*(1-B)*b,V=m[F+3]*B*b,re=k+_+$+V,X=(I*c+O)*4;p.data[X+3]=Math.round(re);for(let te=0;te<3;te++)p.data[X+te]=re?Math.round((m[A+te]*k+m[S+te]*_+m[C+te]*$+m[F+te]*V)/re):0}return d.putImageData(p,0,0),u}var Qu=Zu(import.meta.url),ef=[0,-.5,.5,.5,-.5,.5],tf=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],rf=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],Bn=Buffer.from([137,80,78,71,13,10,26,10]),nf=new Set(["image","textbox","textwindow","button","grid"]),mr={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"},pr=null;function Si(){if(pr)return pr;try{pr=Qu("@napi-rs/canvas")}catch(e){let t=e?.message||String(e);throw new Error(`Host screenshot renderer requires @napi-rs/canvas (${t})`)}return pr}function q(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function yr(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 Rs(e,t,i=1){let r=Math.max(1,Math.round(q(e,1))),n=Math.max(1,Math.round(q(t,1))),a=Math.max(1,Math.min(2,q(i,1)));return{width:r,height:n,pixelWidth:Math.max(1,Math.round(r*a)),pixelHeight:Math.max(1,Math.round(n*a)),pixelRatio:a}}function Ms(e){let t=Buffer.from(e.toBuffer("image/png"));if(t.length<Bn.length||!t.subarray(0,Bn.length).equals(Bn))throw new Error("Host screenshot renderer did not produce a PNG");return t}function af(e){return e==="triangle"?ef:e==="fourstar"?tf:rf}function of(e,t,i,r,n){let a=af(t);e.beginPath();for(let o=0;o<a.length;o+=2){let s=a[o]*i,c=a[o+1]*r;o===0?e.moveTo(s,c):e.lineTo(s,c)}e.closePath(),e.fillStyle=St(n),e.fill()}function sf(e,t,i){let r=t?.matrix,n=r&&typeof r=="object"?[r.a,r.b,r.c,r.d,r.tx,r.ty].map(Number):null,a=t?.pressed?.98:1;if(n&&n.every(Number.isFinite)){let[o,s,c,l,u,d]=n;e.transform(o*a,-s*a,-c*a,l*a,u,i-d);return}e.translate(q(t.left)+q(t.width)/2,i-q(t.bottom)-q(t.height)/2),e.rotate(-q(t.rotationZ)*Math.PI/180),e.scale(a,a)}function lf(e,t,i,r,n,a){if(typeof e.roundRect=="function"){e.roundRect(t,i,r,n,a);return}let o=Math.max(0,Math.min(a,r/2,n/2));e.moveTo(t+o,i),e.arcTo(t+r,i,t+r,i+n,o),e.arcTo(t+r,i+n,t,i+n,o),e.arcTo(t,i+n,t,i,o),e.arcTo(t,i,t+r,i,o),e.closePath()}function Ns(e,t,i,r){let n=yr(t.bgColor,16777215);e.fillStyle=St(n),e.fillRect(-i/2,-r/2,i,r);let a=Math.max(8,q(t.fontSize,12)),o=yr(t.fontColor,4294967295),s=t.horizontalAlignment==="Right"?1:t.horizontalAlignment==="Middle"?.5:0,c=t.verticalAlignment==="Bottom"?1:t.verticalAlignment==="Middle"?.5:0;e.save(),e.beginPath(),e.rect(-i/2,-r/2,i,r),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";let l=t.kind==="textwindow"?t.scroll:null;if(e.textBaseline=l?"top":c===1?"bottom":c===.5?"middle":"top",t.enableOutline){let y=yr(t.outlineColor,4278190080);e.strokeStyle=St(y),e.lineWidth=Math.max(2,a*.12),e.lineJoin="round"}let u=l?-i/2+2+s*l.textWidth:s===0?-i/2+2:s===1?i/2-2:0,d=c===0?-r/2:c===1?r/2:0,h=l?.lines||String(t.text||"").split(`
|
|
111
|
-
`),p=l?.lineHeight||a*1.2,m=l?-r/2-l.offset+(l.max>0?0:c*(r-l.contentLength)):c===.5?d-(h.length-1)*p/2:c===1?d-(h.length-1)*p:d;for(let y=0;y<h.length;y+=1){let x=m+y*p;l&&(x+p<-r/2||x>r/2)||(t.enableOutline&&e.strokeText(h[y],u,x),e.fillText(h[y],u,x))}e.restore()}function cf(e,t,i,r){let n=$t(t.scroll,i,r);if(n)for(let[a,o]of[[n.track,"#263447"],[n.thumb,"#90aecb"]])e.fillStyle=o,e.fillRect(a.x,a.y,a.width,a.height)}function Os(e,t,i,r){e.beginPath(),lf(e,-i/2,-r/2,i,r,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 Fs(e,t,i,r,n){let a=yr(t.imageColor,4294967295),o=Mi(t.imageId,t.imageSource),s=n?.images?.get(o);if(t.primitive==="sprite"&&s){let c=n.imageMetadata?.get(o),l=As(c,t.imageType),u=`${o}:${Number(t.imageColor??4294967295)&16777215}:${l}:${l==="Stretch"?`${i}:${r}`:""}`,d=n.tints.get(u);if(!d){let h=l==="Stretch"?Ps(s,c,i,r,Si().createCanvas):s;d=ks(h,t.imageColor,Si().createCanvas),n.tints.set(u,d)}e.globalAlpha*=a.a,e.drawImage(d,-i/2,-r/2,i,r);return}if(t.primitive==="missing"||t.primitive==="sprite"){e.fillStyle="rgba(72,34,40,0.36)",e.fillRect(-i/2,-r/2,i,r),e.strokeStyle="#ff7481",e.lineWidth=1,e.strokeRect(-i/2+.5,-r/2+.5,Math.max(0,i-1),Math.max(0,r-1));return}if(t.primitive==="circle"){e.beginPath(),e.ellipse(0,0,i/2,r/2,0,0,Math.PI*2),e.fillStyle=St(a),e.fill();return}if(t.primitive==="ring"){e.beginPath(),e.ellipse(0,0,Math.max(1,i/2-3.5),Math.max(1,r/2-3.5),0,0,Math.PI*2),e.strokeStyle=St(a),e.lineWidth=7,e.stroke();return}if(t.primitive==="triangle"||t.primitive==="fourstar"||t.primitive==="fivestar"){of(e,t.primitive,i,r,a);return}e.fillStyle=St(a),e.fillRect(-i/2,-r/2,i,r)}function uf(e,t,i,r){let n=Math.max(0,q(t.sourceWidth,q(t.width))),a=Math.max(0,q(t.sourceHeight,q(t.height)));e.save();for(let o of t.clipPolygons||[])e.beginPath(),o.forEach((s,c)=>c?e.lineTo(s.x,i-s.y):e.moveTo(s.x,i-s.y)),e.closePath(),e.clip();if(sf(e,t,i),t.kind==="textbox"||t.kind==="textwindow")Ns(e,t,n,a);else if(t.kind==="button")Os(e,t,n,a);else if(t.kind!=="grid"){let o=Yn(t,n,a);o&&(e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.clip()),Fs(e,t,n,a,r)}cf(e,t,n,a),e.restore()}function Ds(e,t,i,{checker:r=!1}={}){if(r){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 n=e.createRadialGradient(t/2,i*.45,8,t/2,i/2,Math.max(t,i)*.72);n.addColorStop(0,"#123a6b"),n.addColorStop(.72,"#061934"),n.addColorStop(1,"#071426"),e.fillStyle=n,e.fillRect(0,0,t,i)}function ff(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 Ts(e){let t=e?.matrix;return!t||typeof t!="object"?{a:1,b:0,c:0,d:1,tx:0,ty:0}:{a:q(t.a,1),b:q(t.b),c:q(t.c),d:q(t.d,1),tx:q(t.tx),ty:q(t.ty)}}function df(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)=>q(s.z)-q(c.z));let r=[];function n(o,s,c,l){if(!nf.has(o.kind))return;let u=Math.abs(q(o.sourceWidth)*Math.hypot(s.a,s.b)),d=Math.abs(q(o.sourceHeight)*Math.hypot(s.c,s.d));r.push({...o,left:s.tx-u/2,bottom:s.ty-d/2,width:u,height:d,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},...c.length?{clipPolygons:c}:{},...l.length?{masks:l}:{}})}function a(o,s,c=null,l=[],u=[]){let d=i.get(o)||[];for(let h=d.length-1;h>=0;h-=1){let p=d[h],m=s?ff(s,Ts(p)):Ts(p),y=l;if(p.clipToParent&&s&&c){let I=c.sourceWidth/2,O=c.sourceHeight/2;y=[...l,[[-I,-O],[I,-O],[I,O],[-I,O]].map(([N,H])=>({x:s.a*N+s.c*H+s.tx,y:s.b*N+s.d*H+s.ty}))]}let x=ar(p,m),E=x?[...u,x]:u;p.kind!=="grid"&&n(p,m,y,E),a(String(p.id),m,p,y,E),p.kind==="grid"&&n(p,m,y,E)}}return a("",null),r}function zs(e,t,i,r={}){return pf(df(e),t,i,r)}function hf(e,t,i){if(!(e.width>0&&e.height>0)||!Ve(e.matrix))return null;let r=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([c,l])=>{let u=xe(e.matrix,c*e.width/2,l*e.height/2);return{x:u.x*i.pixelRatio,y:(i.height-u.y)*i.pixelRatio}}),n=Math.max(t.x,Math.floor(Math.min(...r.map(c=>c.x)))),a=Math.max(t.y,Math.floor(Math.min(...r.map(c=>c.y)))),o=Math.min(t.x+t.canvas.width,Math.ceil(Math.max(...r.map(c=>c.x)))),s=Math.min(t.y+t.canvas.height,Math.ceil(Math.max(...r.map(c=>c.y))));return o>n&&s>a?{x:n,y:a,width:o-n,height:s-a}:null}function mf(e,t,i,r){let n=t.canvas.width,a=t.canvas.height,o=t.ctx.getImageData(0,0,n,a).data,s=t.x-e.x,c=t.y-e.y,l=e.ctx.getImageData(s,c,n,a),u=l.data,d=Ve(i.matrix);for(let h=0;h<a;h++){let p=r.height-(t.y+h+.5)/r.pixelRatio;for(let m=0;m<n;m++){let y=(h*n+m)*4;if(!o[y+3])continue;let x=(t.x+m+.5)/r.pixelRatio,E=d.a*x+d.c*p+d.tx,I=d.b*x+d.d*p+d.ty,O=es(E,I,i),N=Math.round(o[y+3]*O)/255;if(!N)continue;let H=u[y+3]/255,B=N+H*(1-N);for(let Y=0;Y<3;Y++)u[y+Y]=Math.round((o[y+Y]*N+u[y+Y]*H*(1-N))/B);u[y+3]=Math.round(B*255)}}e.ctx.save(),e.ctx.setTransform(1,0,0,1,0,0),e.ctx.putImageData(l,s,c),e.ctx.restore()}function $s(e,t,i,r){for(let n of t){if(n.item){uf(e.ctx,n.item,i.height,r);continue}let a=hf(n.mask,e,i);if(!a)continue;let o=Si().createCanvas(a.width,a.height),s=o.getContext("2d");s.setTransform(i.pixelRatio,0,0,i.pixelRatio,-a.x,-a.y);let c={canvas:o,ctx:s,x:a.x,y:a.y};$s(c,n.children,i,r),mf(e,c,n.mask,i)}}function pf(e,t,i,r={}){let{createCanvas:n}=Si(),a=Rs(t,i,r.scale),o=n(a.pixelWidth,a.pixelHeight),s=o.getContext("2d");s.scale(a.pixelRatio,a.pixelRatio),r.background!=="transparent"&&Ds(s,a.width,a.height);let c=Array.isArray(e)?e:[],l={images:r.images,imageMetadata:r.imageMetadata,tints:new Map};return $s({canvas:o,ctx:s,x:0,y:0},ts(c),a,l),{data:Ms(o),width:a.width,height:a.height,pixelWidth:a.pixelWidth,pixelHeight:a.pixelHeight}}function gf(e){return{kind:e.kind,left:q(e.renderLeft,e.left),bottom:q(e.renderBottom,e.bottom),width:Math.max(0,q(e.renderWidth,e.width)),height:Math.max(0,q(e.renderHeight,e.height)),rotationZ:q(e.renderRotationZ,e.rotationZ)}}function gr(e,t,i){let r=String(t||"");if(!r)return;e.font='10px "Microsoft YaHei UI","Microsoft YaHei",sans-serif',e.textAlign="center",e.textBaseline="middle";let n=e.measureText(r),a=Math.min(i-4,Math.max(24,n.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(r,0,0)}function yf(e,t,i,r,n){let a=gf(t);if(a.width<=0||a.height<=0)return;e.save(),e.translate(a.left+a.width/2,i-a.bottom-a.height/2),e.rotate(-a.rotationZ*Math.PI/180);let o=-a.width/2,s=-a.height/2;if(t.kind==="image"){e.save();let c=Math.max(0,q(t.width,a.width)),l=Math.max(0,q(t.height,a.height));e.scale(c?a.width/c:1,l?a.height/l:1);let u=t.enableFill?Yn(t,c,l):null;u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Fs(e,t,c,l,n),e.restore()}else if(t.kind==="textbox"||t.kind==="textwindow")Ns(e,t,a.width,a.height);else if(t.kind==="button")Os(e,t,a.width,a.height),gr(e,t.name||mr.button,a.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,s,a.width,a.height),e.strokeRect(o,s,a.width,a.height),gr(e,t.name||mr.cursor,a.width);else if(t.kind==="grid"){e.strokeStyle="rgba(106,146,189,0.55)",e.strokeRect(o,s,a.width,a.height),e.beginPath();for(let c=20;c<a.width;c+=20)e.moveTo(o+c,s),e.lineTo(o+c,s+a.height);for(let c=20;c<a.height;c+=20)e.moveTo(o,s+c),e.lineTo(o+a.width,s+c);e.stroke(),gr(e,t.name||mr.grid,a.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,s,a.width,a.height),gr(e,t.name||mr[t.kind]||t.kind,a.width)):(e.strokeStyle="rgba(78,165,230,0.42)",e.strokeRect(o,s,a.width,a.height));t.id===r&&t.kind!=="container"&&t.kind!=="server-container"&&(e.setLineDash([]),e.strokeStyle="#61b9ff",e.lineWidth=2,e.strokeRect(o,s,a.width,a.height)),e.restore()}function Gs(e,t={}){let{createCanvas:i}=Si(),r=e?.canvas||{},n=Rs(r.width||1600,r.height||900,t.scale),a=i(n.pixelWidth,n.pixelHeight),o=a.getContext("2d");o.scale(n.pixelRatio,n.pixelRatio),Ds(o,n.width,n.height,{checker:!0});let s=Array.isArray(e?.boxes)?e.boxes:[],c=e?.selectedId,l={images:t.images,imageMetadata:t.imageMetadata,tints:new Map};for(let u of s)!u||u.kind==="server-container"||u.visible===!1||yf(o,u,n.height,c,l);return{data:Ms(a),page:e?.asset?.type==="client-control-template"?"UI\u63A7\u4EF6-\u5BA2\u6237\u7AEF":"UI \u7F16\u8F91",width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight}}import{closeSync as bf,existsSync as br,openSync as vf,opendirSync as Sf,readSync as wf,realpathSync as Yt,statSync as Hs}from"node:fs";import{basename as If,dirname as Vs,isAbsolute as Xn,join as xf,relative as Ys,resolve as xi}from"node:path";var Cf="qxqy-simulator-save",Bs=new Set(["node_modules",".git","dist",".dsh","coverage"]),wi=50,Us=4096,Un=1e4,jn=1e3,Ln=8;function qn(e=""){let t=xi(String(e||process.cwd()));if(!br(t))throw new Error(`workspace does not exist: ${t}`);if(!Hs(t).isDirectory())throw new Error(`workspace is not a directory: ${t}`);return Yt(t)}function Ii(e,t,i=!1){let r=Ys(e,t);if(!i&&!r||r.startsWith("..")||Xn(r))throw new Error("path must stay inside the configured workspace");return r}function Bt(e,t){let i=String(t||"").trim();if(!i||Xn(i))throw new Error("path must be a non-empty workspace-relative path");let r=Yt(xi(e)),n=xi(r,i);if(Ii(r,n),!br(n))throw new Error(`file does not exist: ${i}`);let a=Yt(n);return Ii(r,a),a}function rt(e,t){let i=String(t||"").trim();if(!i||Xn(i))throw new Error("path must be a non-empty workspace-relative path");let r=Yt(xi(e)),n=xi(r,i);Ii(r,n);let a=Vs(n);for(;!br(a);){let o=Vs(a);if(o===a)throw new Error("unable to resolve output directory");a=o}return Ii(r,Yt(a),!0),br(n)&&Ii(r,Yt(n)),n}function kf(e,t=Us){let i=Buffer.alloc(t),r=vf(e,"r");try{let n=wf(r,i,0,t,0);return i.subarray(0,n).toString("utf8")}finally{bf(r)}}function js(e,t,i,r,n){if(r>Ln){n.depthLimitedDirectories+=1;return}if(n.scannedDirectories>=jn){n.directoryLimitReached=!0;return}let a;try{n.scannedDirectories+=1,a=Sf(e)}catch{n.unreadableEntries+=1;return}try{let o;for(;o=a.readSync();){if(n.scannedEntries>=Un){n.entryLimitReached=!0;return}if(n.scannedEntries+=1,o.name.startsWith(".")||o.isDirectory()&&Bs.has(o.name)){n.skippedEntries+=1,o.isDirectory()&&(n.skippedDirectories+=1);continue}let s=xf(e,o.name);if(o.isDirectory()){if(js(s,t,i,r+1,n),n.entryLimitReached||n.directoryLimitReached)return;continue}if(!(!o.isFile()||!/\.json$/i.test(o.name))){n.scannedJsonFiles+=1;try{let c=Hs(s),l=kf(s);if(!l.includes(Cf))continue;let u=l.match(/"name"\s*:\s*("(?:\\.|[^"\\])*")/)?.[1],d=If(o.name,".json");if(u)try{d=JSON.parse(u)||d}catch{}i.push({path:Ys(t,s).replaceAll("\\","/"),name:d,bytes:c.size,mtime:c.mtimeMs})}catch{n.unreadableEntries+=1}}}}catch{n.unreadableEntries+=1}finally{try{a.closeSync()}catch{n.unreadableEntries+=1}}}function vr(e){let t=qn(e),i=[],r={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:wi,entries:Un,directories:jn,depth:Ln,headBytes:Us},policy:{excludedDirectories:[...Bs],hiddenEntries:!1,symlinks:!1,validatesJson:!1}};return js(t,t,i,0,r),i.sort((n,a)=>a.mtime-n.mtime||n.path.localeCompare(a.path)),r.matchedArchives=i.length,i.length>wi&&r.warnings.push(`\u53D1\u73B0 ${i.length} \u4E2A\u5B58\u6863\uFF0C\u4EC5\u663E\u793A\u4FEE\u6539\u65F6\u95F4\u6700\u65B0\u7684 ${wi} \u4E2A\uFF1B\u5176\u4ED6\u5B58\u6863\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u3002`),(r.entryLimitReached||r.directoryLimitReached)&&r.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u8FBE\u5230\u626B\u63CF\u4E0A\u9650\uFF08${Un} \u9879 / ${jn} \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`),r.depthLimitedDirectories&&r.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u8DF3\u8FC7 ${r.depthLimitedDirectories} \u4E2A\u8D85\u8FC7 ${Ln} \u5C42\u7684\u76EE\u5F55\uFF1B\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u5176\u4E2D\u7684\u5B58\u6863\u3002`),r.skippedEntries&&r.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"),r.unreadableEntries&&r.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u65E0\u6CD5\u8BFB\u53D6 ${r.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`),r.truncated=i.length>wi||r.entryLimitReached||r.directoryLimitReached||r.depthLimitedDirectories>0,{bound:!0,workspace:t,archives:i.slice(0,wi),discovery:r}}import{readFileSync as Ef}from"node:fs";import{homedir as Af}from"node:os";import{join as _f}from"node:path";var Pf={"zh-cn":"LanguageChs",chs:"LanguageChs","zh-tw":"LanguageCht",cht:"LanguageCht",en:"LanguageEng","en-us":"LanguageEng",eng:"LanguageEng",ja:"LanguageJpn","ja-jp":"LanguageJpn",jp:"LanguageJpn",ko:"LanguageKor","ko-kr":"LanguageKor",kr:"LanguageKor",fr:"LanguageFra",fra:"LanguageFra",de:"LanguageDeu",deu:"LanguageDeu",es:"LanguageSpa",spa:"LanguageSpa",pt:"LanguagePor",por:"LanguagePor",ru:"LanguageRus",rus:"LanguageRus",th:"LanguageTha",tha:"LanguageTha",vi:"LanguageVie",vie:"LanguageVie",id:"LanguageInd",ind:"LanguageInd",tr:"LanguageTur",tur:"LanguageTur",it:"LanguageIta",ita:"LanguageIta"};function Tf(e){let i=[...String(e||"").matchAll(/Request to set language:([A-Za-z0-9_-]+)/g)].at(-1)?.[1]?.toLowerCase();return Pf[i]||null}function Rf(){return _f(Af(),"AppData","LocalLow","miHoYo","\u539F\u795E","output_log.txt")}function Ls(e=Rf()){try{return Tf(Ef(e,"utf8"))}catch{return null}}import{existsSync as Jn,lstatSync as Mf,mkdirSync as Xs,readFileSync as Sr,readdirSync as Nf,realpathSync as qs,renameSync as Of,rmSync as Ff,statSync as xr,writeFileSync as Ws}from"node:fs";import{createHash as Df,randomUUID as Ks}from"node:crypto";import{homedir as zf}from"node:os";import{basename as $f,dirname as wr,isAbsolute as Gf,join as Ir,relative as Vf}from"node:path";var je=e=>Df("sha256").update(e).digest("hex"),Wn=e=>Jn(e)?je(Sr(e)):null,Kn=(e,t)=>{let i=Vf(e,t);return!Gf(i)&&i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)};function Js(e,t){let i=rt(e,t),r=i;for(;r!==e;){try{if(Mf(r).isSymbolicLink())throw new Error("\u5B9E\u673A\u76EE\u6807\u4E0D\u80FD\u5305\u542B\u7B26\u53F7\u94FE\u63A5\u6216\u76EE\u5F55\u8054\u63A5")}catch(n){if(n.code!=="ENOENT")throw n}r=wr(r)}if(Jn(i)&&!xr(i).isFile())throw new Error("\u5B9E\u673A\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6");return i}function Zs(e=Ir(zf(),"AppData","LocalLow","miHoYo","\u539F\u795E","BeyondLocal")){let t=r=>{try{return Nf(r,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^\d+$/.test(n.name)).map(n=>n.name)}catch{return[]}},i=[];for(let r of t(e)){let n=Ir(e,r,"Beyond_Local_Save_Level");for(let a of t(n)){let o=Ir(n,a,"external_lua_file","default_import_file");Jn(o)&&xr(o).isDirectory()&&i.push({uid:r,editorId:a,path:o})}}return{candidates:i}}var Cr=class{constructor(t){this.controller=t,this.plan=null,this.lastResult=null}preview(){let t=this.controller,i=t.studio.archiveData(),r=Jt(i.scriptSync);if(!r)throw new Error("\u8BF7\u5148\u914D\u7F6E\u5B9E\u673A\u811A\u672C\u76EE\u5F55");let n=qs(t.activeWorkspacePath()),a=qs(r.clientImportRoot);if(!xr(a).isDirectory())throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u4E0D\u5B58\u5728");let o=r.workspaceDir?Bt(n,r.workspaceDir):n;if(!xr(o).isDirectory())throw new Error("\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E0D\u5B58\u5728");if(Kn(o,a)||Kn(a,o))throw new Error("\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E0E\u5B9E\u673A\u76EE\u5F55\u4E0D\u80FD\u91CD\u53E0");let s=new Map,c=i.assets.scripts.map(u=>{let d={id:u.id,path:u.path,sourceKind:u.source.trim()?"\u5B58\u6863\u6E90\u7801":"\u5DE5\u4F5C\u533A\u6587\u4EF6"};try{let h=_i(u.path);if(!/\.lua$/i.test(h))throw new Error("\u811A\u672C\u8DEF\u5F84\u5FC5\u987B\u4EE5 .lua \u7ED3\u5C3E");let p=r.workspaceDir?`${r.workspaceDir}/`:"";if(!h.startsWith(p))throw new Error("\u811A\u672C\u4E0D\u5728\u6240\u914D\u7F6E\u7684\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E2D");let m=[r.clientSubdir,h.slice(p.length)].filter(Boolean).join("/"),y=Js(a,m),x=y.toLowerCase();s.set(x,(s.get(x)||0)+1);let E=null,I="";try{E=Sr(Bt(n,h),"utf8")}catch(H){I=H.message}if(!u.source.trim()&&E===null)throw new Error(I);let O=u.source.trim()?u.source:E,N=Wn(y);return{...d,target:y,targetRelative:m,source:O,diskSource:E,diskError:I,sourceMismatch:!!(u.source.trim()&&E!==null&&u.source!==E),beforeSource:N===null?"":Sr(y,"utf8"),beforeHash:N,sourceHash:je(O),status:N===null?"\u65B0\u589E":N===je(O)?"\u672A\u53D8\u5316":"\u8986\u76D6"}}catch(h){return{...d,status:"\u9519\u8BEF",error:h.message}}});for(let u of c)u.target&&s.get(u.target.toLowerCase())>1&&(u.status="\u9519\u8BEF",u.error="\u591A\u4E2A\u811A\u672C\u6620\u5C04\u5230\u540C\u4E00\u76EE\u6807\u6587\u4EF6");let l=je(JSON.stringify({archive:i,workspace:n,root:a,rows:c}));return this.plan={id:Ks(),fingerprint:l,root:a,workspace:n,rows:c,pendingGuidChanges:i.controlGuidChanges.length,createdAt:new Date().toISOString()},this.plan}apply({planId:t,scriptIds:i,confirmed:r}){let n=this.plan;if(r!==!0||!n||n.id!==t)throw new Error("\u8BF7\u5148\u68C0\u67E5\u5DEE\u5F02\u5E76\u786E\u8BA4\u672C\u6B21\u590D\u5236");let a=this.preview();if(this.plan=null,a.fingerprint!==n.fingerprint)throw new Error("\u5185\u5BB9\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");if(n.pendingGuidChanges)throw new Error("\u8BF7\u5148\u6838\u5BF9\u5E76\u786E\u8BA4\u63A7\u4EF6\u7D22\u5F15\u7684 Lua \u5F15\u7528\u53D8\u66F4");if(!Array.isArray(i)||!i.length||new Set(i).size!==i.length)throw new Error("\u8BF7\u9009\u62E9\u8981\u590D\u5236\u7684\u811A\u672C");let o=i.map(u=>{let d=n.rows.find(h=>h.id===u);if(!d||d.error||d.status==="\u672A\u53D8\u5316")throw new Error("\u6240\u9009\u811A\u672C\u4E0D\u80FD\u590D\u5236\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");return d});this.controller.assertSavedArchive();let s=`.qxqy-script-sync-backups/${n.id}`,c=rt(n.workspace,s);if(Kn(n.root,c))throw new Error("\u5907\u4EFD\u76EE\u5F55\u4E0D\u80FD\u4F4D\u4E8E\u5B9E\u673A\u811A\u672C\u76EE\u5F55\u4E2D");let l=[];for(let u of o){let d="";try{let h=Js(n.root,u.targetRelative);if(Wn(h)!==u.beforeHash)throw new Error("\u76EE\u6807\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");if(u.beforeHash!==null){let p=rt(n.workspace,`${s}/${u.targetRelative}`);Xs(wr(p),{recursive:!0}),Ws(p,Sr(h),{flag:"wx"})}if(Xs(wr(h),{recursive:!0}),d=Ir(wr(h),`.${$f(h)}.${Ks()}.tmp`),Ws(d,u.source,{flag:"wx"}),Wn(h)!==u.beforeHash)throw new Error("\u76EE\u6807\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");Of(d,h),l.push({id:u.id,target:h,status:"\u6210\u529F"})}catch(h){l.push({id:u.id,target:u.target,status:"\u5931\u8D25",error:h.message})}finally{d&&Ff(d,{force:!0})}}return this.lastResult={completed:l.every(u=>u.status==="\u6210\u529F"),at:new Date().toISOString(),backupRoot:c,results:l},this.lastResult}};import{createHash as Hf,randomUUID as Yf}from"node:crypto";import{mkdir as Bf,open as Uf,readFile as jf,rename as Lf,rm as Zn,stat as Xf,writeFile as qf}from"node:fs/promises";import{homedir as Qn}from"node:os";import{join as Ut,resolve as Wf}from"node:path";import{setTimeout as Kf}from"node:timers/promises";var ea=e=>Hf("sha256").update(e).digest("hex");function kr(e){return Ut(process.platform==="win32"?process.env.LOCALAPPDATA||Ut(Qn(),"AppData","Local"):process.platform==="darwin"?Ut(Qn(),"Library","Caches"):process.env.XDG_CACHE_HOME||Ut(Qn(),".cache"),"beyond-simulator",e)}var nt=class{constructor({cacheDir:t,source:i,version:r,extension:n,accepts:a,fetch:o=globalThis.fetch,timeout:s=12e3}){this.directory=Ut(Wf(t),r,ea(i).slice(0,12)),Object.assign(this,{source:i,extension:n,accepts:a,fetcher:o,timeout:s}),this.pending=new Map,this.failures=new Map,this.active=0,this.waiters=[]}async limited(t){this.active>=4?await new Promise(i=>this.waiters.push(i)):this.active++;try{return await t()}finally{let i=this.waiters.shift();i?i():this.active--}}async download(t,i,r,n){let a=await this.fetcher(new URL(t,this.source),{signal:r,redirect:"error",cache:n?"no-cache":"default"});if(!a.ok)throw Object.assign(new Error(`Asset source returned HTTP ${a.status}`),{status:a.status});if(Number(a.headers.get("content-length"))>i)throw new Error("Asset response too large");let o=[],s=0;for await(let c of a.body){if(s+=c.length,s>i)throw new Error("Asset response too large");o.push(c)}return Buffer.concat(o)}async cached(t){try{let i=await jf(t);return{data:i,...await this.decode(i),etag:`"${ea(i)}"`}}catch(i){if(i.code==="ENOENT")return null;if(i.code==="EACCES"||i.code==="EPERM")throw i;return null}}async load(t,i=!1){let r=Ut(this.directory,`${t}.${this.extension}`),n=!i&&await this.cached(r);if(n)return n;await Bf(this.directory,{recursive:!0});let a=`${r}.lock`,o=Date.now()+3e4,s;for(;!s;)try{s=await Uf(a,"wx")}catch(l){if(l.code!=="EEXIST")throw l;let u=!i&&await this.cached(r);if(u)return u;try{Date.now()-(await Xf(a)).mtimeMs>6e4&&await Zn(a,{force:!0})}catch(d){if(d.code!=="ENOENT")throw d}if(Date.now()>o)throw new Error("Timed out waiting for asset cache writer");await Kf(80)}let c=`${r}.${Yf()}.tmp`;try{let l=!i&&await this.cached(r);if(l)return l;let u=new AbortController,d=setTimeout(()=>u.abort(),this.timeout),h;try{h=await this.produce(t,u.signal,i)}finally{clearTimeout(d),u.abort()}let p=await this.decode(h);return await qf(c,h,{flag:"wx"}),await Lf(c,r),{data:h,...p,etag:`"${ea(h)}"`}}finally{try{await Zn(c,{force:!0})}finally{await s.close(),await Zn(a,{force:!0})}}}get(t,{refresh:i=!1}={}){if(!this.accepts(t))return Promise.reject(Object.assign(new Error("Asset ID is not in the preview allowlist"),{status:404}));if(this.pending.has(t))return this.pending.get(t);let r=this.failures.get(t);if(!i&&r&&r.until>Date.now())return Promise.reject(r.error);let n=this.limited(()=>this.load(t,i)).then(a=>(this.failures.delete(t),a),a=>{throw i||this.failures.set(t,{until:Date.now()+6e4,error:a}),a}).finally(()=>this.pending.delete(t));return this.pending.set(t,n),n}async refresh(t){if(!this.accepts(t))throw Object.assign(new Error("Asset ID is not in the preview allowlist"),{status:404});return await this.pending.get(t)?.catch(()=>{}),this.failures.delete(t),this.get(t,{refresh:!0})}};import{createHash as Jf}from"node:crypto";import{createCanvas as Zf,loadImage as Qs}from"@napi-rs/canvas";var Er=class extends nt{constructor({cacheDir:t,source:i=Ti,fetch:r=globalThis.fetch}){super({cacheDir:t,source:i,fetch:r,version:"border-v1",extension:"json",accepts:n=>Xe(n)})}decode(t){let i=JSON.parse(t.toString("utf8"));if(i!==null&&(typeof i!="object"||Array.isArray(i)))throw new Error("Invalid image metadata");let r=_s(i);return{raw:i,meta:r}}async produce(t,i,r){try{return await this.download(`border/${t}.json`,128*1024,i,r)}catch(n){if(n.status===404)return Buffer.from("null");throw n}}};var ia=20*1024*1024,Qf=Buffer.from("89504e470d0a1a0a","hex");function el(e,t){return t.throwIfAborted(),new Promise((i,r)=>{let n=()=>r(t.reason);t.addEventListener("abort",n,{once:!0}),e.then(i,r).finally(()=>t.removeEventListener("abort",n))})}function ed(){return process.env.QXQY_IMAGE_CACHE_DIR||kr("images")}function ta(e){if(e.length<24||e.length>ia||!e.subarray(0,8).equals(Qf))throw new Error("Invalid sprite PNG");let t=e.readUInt32BE(16),i=e.readUInt32BE(20);if(!t||!i||t>8192||i>8192||t*i>16777216)throw new Error("Sprite PNG exceeds pixel limit")}var ra=class e extends nt{constructor({cacheDir:t=ed(),fetch:i=globalThis.fetch,source:r,imageSource:n="StaticReference"}={}){let a=Ie(n);if(!["StaticReference","Prefab"].includes(a))throw new Error(`Unsupported image source: ${a}`);super({cacheDir:t,fetch:i,source:r||(a==="Prefab"?va:Ti),version:a==="Prefab"?Zt:Rr,extension:"png",accepts:o=>Xe(o,a)}),this.imageSource=a,this.cacheDir=t,this.prefabStore=null,this.metadataStore=null}forSource(t){let i=Ie(t);if(i===this.imageSource)return this;if(i==="Prefab"&&this.imageSource==="StaticReference")return this.prefabStore||=new e({cacheDir:this.cacheDir,imageSource:"Prefab",fetch:(...r)=>this.fetcher(...r)});throw Object.assign(new Error(`Unsupported image source: ${i}`),{status:404})}get(t,{imageSource:i=this.imageSource,...r}={}){try{let n=this.forSource(i);return n===this?super.get(t,r):n.get(t,r)}catch(n){return Promise.reject(n)}}refresh(t,{imageSource:i=this.imageSource}={}){try{let r=this.forSource(i);return r===this?super.refresh(t):r.refresh(t)}catch(r){return Promise.reject(r)}}async decode(t){return ta(t),{image:await Qs(t)}}metadata(t,{imageSource:i=this.imageSource,refresh:r=!1}={}){try{let n=this.forSource(i);if(n!==this)return n.metadata(t,{refresh:r});if(!this.accepts(t))throw Object.assign(new Error("Image ID is not in the preview allowlist"),{status:404});return this.imageSource==="Prefab"?Promise.resolve({meta:null,raw:null}):(this.metadataStore||=new Er({cacheDir:this.cacheDir,source:this.source,fetch:(...a)=>this.fetcher(...a)}),r?this.metadataStore.refresh(t):this.metadataStore.get(t))}catch(n){return Promise.reject(n)}}async produce(t,i,r){if(this.imageSource==="Prefab"){let c=await this.download(`sprite/${t}.png`,ia,i,r);ta(c);let l=Pi(t);if(c.readUInt32BE(16)!==l||c.readUInt32BE(20)!==l)throw new Error("Prefab PNG does not match catalog dimensions");return c}let[n,a]=await Promise.all([this.download(`sprite/${t}.png`,ia,i,r),this.metadata(t,{refresh:r})]);ta(n);let o=await Qs(n),s=a.raw?Cs(o,a.raw,Zf):o;return a.raw?Buffer.from(s.toBuffer("image/png")):n}async prepare(t,i){let r=new Map,n=new Map,a=[],o=[...new Map((t||[]).filter(u=>u.kind==="image"&&u.visible!==!1&&Xe(u.imageId,u.imageSource)).map(u=>[Mi(u.imageId,u.imageSource),{imageId:u.imageId,imageSource:Ie(u.imageSource)}])).entries()];i?.throwIfAborted();let s=AbortSignal.timeout(45e3),c=i?AbortSignal.any([i,s]):s,l=0;await Promise.all(Array.from({length:Math.min(4,o.length)},async()=>{for(;l<o.length&&!c.aborted;){let[u,d]=o[l++];try{let h=await el(this.get(d.imageId,d),c);r.set(u,h.image);let p=await el(this.metadata(d.imageId,d),c);n.set(u,p.meta)}catch(h){a.push({...d,error:h.message})}}}));for(let[,u]of o.slice(l))a.push({...u,error:"Image preparation timed out"});return i?.throwIfAborted(),{images:r,imageMetadata:n,warnings:a}}},td;function na(){return td||=new ra}async function tl(e,t,i=na()){let r=new URL(e.url,"http://localhost");if(r.pathname!==Ri.slice(0,-1)&&!r.pathname.startsWith(Ri))return!1;try{if(!["GET","HEAD"].includes(e.method))throw Object.assign(new Error("GET or HEAD required"),{status:405});let n=r.pathname.match(new RegExp(`^${Ri}(${Rr}|${Zt})/([0-9]+)\\.(png|json)$`));if(!n)throw Object.assign(new Error("Unknown image resource"),{status:404});let a={imageSource:n[1]===Zt?"Prefab":"StaticReference"};if(n[3]==="json"){let{meta:c}=await i.metadata(Number(n[2]),a),l=JSON.stringify(c),u=`"${Jf("sha256").update(l).digest("hex")}"`,d={"content-type":"application/json; charset=utf-8","cache-control":"private, max-age=43200",etag:u,"x-content-type-options":"nosniff"};return e.headers["if-none-match"]===u?(t.writeHead(304,d),t.end()):(t.writeHead(200,d),t.end(e.method==="HEAD"?void 0:l)),!0}let o=await i.get(Number(n[2]),a),s={"content-type":"image/png","cache-control":"private, max-age=43200",etag:o.etag,"x-content-type-options":"nosniff"};e.headers["if-none-match"]===o.etag?(t.writeHead(304,s),t.end()):(t.writeHead(200,{...s,"content-length":o.data.length}),t.end(e.method==="HEAD"?void 0:o.data))}catch(n){t.writeHead(n.status||502,{"content-type":"text/plain; charset=utf-8","cache-control":"no-store","x-content-type-options":"nosniff"}),t.end(e.method==="HEAD"?void 0:n.message)}return!0}var ld=Math.max(1e3,Number(process.env.QXQY_PLAY_TIMEOUT_MS)||8e3),cd=8e3;function il(){let e=new Error("operation aborted");return e.name="AbortError",e}function oa(e){if(e!=="manual"&&e!=="realtime")throw new Error("clockMode must be manual or realtime");return e}var Ar=class{constructor(t="",{imageAssets:i=na(),clockMode:r="realtime"}={}){this.workspacePath=t?qn(t):"",this.studio=Hn(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="",this.archiveStamp="",this.savedArchive="",this.scriptSync=new Cr(this),this.imageAssets=i,this.defaultClockMode=oa(r),this.playClockMode=this.defaultClockMode}async exclusive(t){let i=this.lock,r;this.lock=new Promise(n=>{r=n}),await i;try{return await t()}finally{r()}}get(){return{...this.studio.get(),storage:{path:this.archivePath}}}scriptSyncAction(t,i={}){if(t==="discover")return Zs();if(t==="status")return{config:this.get().scriptSync,lastResult:this.scriptSync.lastResult};if(t==="configure"){if(!Number.isInteger(i.expectedRevision))throw new Error("expectedRevision is required");return this.patch({op:"setScriptSync",config:i.config,expectedRevision:i.expectedRevision})}if(t==="preview")return this.scriptSync.preview();throw new Error("unknown script sync action (AI \u53EF\u914D\u7F6E\u548C\u9884\u89C8\uFF1B\u590D\u5236\u9700\u5728\u7F16\u8F91\u5668\u4E2D\u786E\u8BA4)")}assertSavedArchive(){if(!this.archivePath||this.savedArchive!==JSON.stringify(this.studio.archiveData()))throw new Error("\u8BF7\u5148\u4FDD\u5B58\u5F53\u524D\u5B8C\u6574\u5B58\u6863\uFF0C\u518D\u786E\u8BA4\u590D\u5236");let t=Bt(this.activeWorkspacePath(),this.archivePath);if(je(aa(t))!==this.archiveStamp)throw new Error("\u5B58\u6863\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u5E76\u68C0\u67E5")}saveForScriptSync(t,i){if(i!==this.get().version)throw new Error("revision conflict: reload before saving");let r=rt(this.activeWorkspacePath(),t);if(rd(r)){let n=this.archivePath?rt(this.activeWorkspacePath(),this.archivePath):"";if(r!==n||je(aa(r))!==this.archiveStamp)throw new Error("File changed or already exists; load it again or save under a new path")}return this.saveArchive(t)}patch(t){return{...this.studio.patch(t),storage:{path:this.archivePath}}}listArchives(){return vr(this.workspacePath)}loadArchive(t){let i=this.activeWorkspacePath();if(!i)throw new Error("workspace is not bound");let r=Bt(i,t),n=aa(r),a=this.studio.importData("json",n.toString("base64"),od(r));return this.archivePath=String(t).trim().replaceAll("\\","/"),this.archiveStamp=je(n),this.savedArchive=JSON.stringify(this.studio.archiveData()),a}saveArchive(t=this.archivePath||"qxqy-simulator.save.json"){let i=String(t).trim(),r=this.activeWorkspacePath();if(!r)throw new Error("workspace is not bound");let n=rt(r,i);nd(sd(n),{recursive:!0});let a=Buffer.from(JSON.stringify(this.studio.archiveData(),null,2)+`
|
|
112
|
-
`,"utf8");return ad(n,a),this.archivePath=i.replaceAll("\\","/"),this.archiveStamp=je(a),this.savedArchive=JSON.stringify(this.studio.archiveData()),{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 id(new URL("./worker.js",import.meta.url),{type:"module"});return t.on("message",i=>{let r=this.pending.get(i?.id);r&&(this.pending.delete(i.id),i.ok?r.resolve(i.value):r.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,r,n=ld){let a=this.worker||this.createWorker(),o=this.sequence++;return new Promise((s,c)=>{let l=!1,u=(p,m)=>{l||(l=!0,clearTimeout(h),r?.removeEventListener("abort",d),p(m))},d=()=>{this.pending.delete(o),u(c,il()),this.terminateWorker(il())},h=setTimeout(()=>{this.pending.delete(o);let p=new Error(`play worker timed out after ${n}ms`);u(c,p),this.terminateWorker(p)},n);if(this.pending.set(o,{resolve:p=>u(s,p),reject:p=>u(c,p)}),r?.aborted)return d();r?.addEventListener("abort",d,{once:!0}),a.postMessage({id:o,action:t,args:i})})}async play(t,i={},r){if((t==="start"||t==="device")&&!i.language){let n=Ls();n&&(i={...i,language:n})}if(t==="start"){let n=oa(i.clockMode??this.defaultClockMode);return await this.terminateWorker(),this.playClockMode=n,this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i,clockMode:n},r)}if(t==="device"){let n=String(i.canvasId||"").trim();if(!J[n])throw new Error(`unknown canvas preset: ${n||"(empty)"} (available: ${Object.keys(J).join(", ")})`);let a=oa(i.clockMode??this.playClockMode);return await this.terminateWorker(),this.playClockMode=a,this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i,canvasId:n,clockMode:a},r)}if(t==="stop"){if(!this.worker)return{running:!1,tree:[],logs:[]};try{return await this.request("stop",i,r)}finally{await this.terminateWorker()}}if(!this.worker)throw new Error("play session has not started");return this.request(t,i,r)}async playScreenshot(t){if(!this.worker)throw new Error("play session has not started");let i=await this.request("get",{view:!0},t,cd),r=await this.imageAssets.prepare(i.scene?.nodes,t),n=zs(i.scene,i.canvasWidth,i.canvasHeight,r);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,clockMode:i.clockMode,width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight,assetWarnings:r.warnings}}async uiScreenshot(t){let i=this.studio.get(),r=await this.imageAssets.prepare(i.boxes,t),n=Gs(i,r);return{data:n.data,page:n.page,width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight,assetWarnings:r.warnings}}async dispose(){await this.terminateWorker()}};import{defineTool as wt}from"@deepseek-ai/dsh-tools";import{existsSync as al,realpathSync as rl}from"node:fs";import{isAbsolute as sa,relative as nl,resolve as _r}from"node:path";function ol(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 r=rl(_r(e)),n=sa(i)?_r(i):_r(r,i),a=nl(r,n);if(!a||a.startsWith("..")||sa(a))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");if(!al(n))throw new Error(`\u5B58\u6863\u4E0D\u5B58\u5728: ${i}`);let o=rl(n),s=nl(r,o);if(!s||s.startsWith("..")||sa(s))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");return o}function sl(e){if(!e)return{bound:!1,archives:[]};let t=_r(e);return al(t)?vr(t):{bound:!1,archives:[]}}var ll=32*1024*1024;function ud(e){if(e.length<8||e.length>ll)throw new Error("Invalid MP3 size");let t=0,i=0;if(e.subarray(0,3).toString()==="ID3"){if(e.length<10||e[3]<2||e[3]>4||e.subarray(6,10).some(r=>r>127))throw new Error("Invalid MP3 ID3 header");t=10+(e[6]<<21|e[7]<<14|e[8]<<7|e[9])+(e[5]&16&&e[3]===4?10:0)}for(;t+4<=e.length;){if(e.length-t===128&&e.subarray(t,t+3).toString()==="TAG"){t=e.length;break}let r=e[t+1],n=e[t+2],a=r>>3&3,o=n>>2&3,s=n>>4;if(e[t]!==255||(r&224)!==224||(r&6)!==2||a===1||o===3||s===0||s===15)throw new Error("Invalid MP3 frame");let c=(a===3?[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320]:[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160])[s],l=[44100,48e3,32e3][o]/(a===3?1:a===2?2:4),u=Math.floor((a===3?144e3:72e3)*c/l)+(n>>1&1);t+=u,i++}if(i<2||t!==e.length)throw new Error("Truncated or invalid MP3")}var la=class extends nt{constructor({cacheDir:t=process.env.QXQY_AUDIO_CACHE_DIR||kr("audio"),fetch:i=globalThis.fetch,source:r=Zo}={}){super({cacheDir:t,fetch:i,source:r,version:Sn,extension:"mp3",accepts:n=>rr(n)!==null,timeout:2e4})}decode(t){return ud(t),{}}produce(t,i,r){return this.download(`audio/${t}.mp3`,ll,i,r)}},fd;function dd(){return fd||=new la}async function cl(e,t,i=dd()){let r=new URL(e.url,"http://localhost");if(r.pathname!==ir.slice(0,-1)&&!r.pathname.startsWith(ir))return!1;try{if(!["GET","HEAD"].includes(e.method))throw Object.assign(new Error("GET or HEAD required"),{status:405});let n=r.pathname.match(new RegExp(`^${ir}${Sn}/([0-9]+)\\.mp3$`));if(!n)throw Object.assign(new Error("Unknown audio resource"),{status:404});let a=await i.get(Number(n[1])),o=a.data.length,s={"content-type":"audio/mpeg","cache-control":"private, max-age=43200",etag:a.etag,"accept-ranges":"bytes","x-content-type-options":"nosniff"};if(e.headers["if-none-match"]===a.etag)return t.writeHead(304,s),t.end(),!0;let c=e.headers.range,l=0,u=o-1,d=200;if(c&&(!e.headers["if-range"]||e.headers["if-range"]===a.etag)){let h=c.match(/^bytes=(\d*)-(\d*)$/);if(!h||!h[1]&&!h[2])throw Object.assign(new Error("Invalid byte range"),{status:416,size:o});if(h[1]?(l=Number(h[1]),u=h[2]?Math.min(o-1,Number(h[2])):u):l=Math.max(0,o-Number(h[2])),!Number.isSafeInteger(l)||!Number.isSafeInteger(u)||l>=o||u<l)throw Object.assign(new Error("Unsatisfiable byte range"),{status:416,size:o});d=206,s["content-range"]=`bytes ${l}-${u}/${o}`}t.writeHead(d,{...s,"content-length":u-l+1}),t.end(e.method==="HEAD"?void 0:a.data.subarray(l,u+1))}catch(n){t.writeHead(n.status||502,{"content-type":"text/plain; charset=utf-8","cache-control":"no-store",...n.status===416?{"content-range":`bytes */${n.size}`}:{}}),t.end(e.method==="HEAD"?void 0:n.message)}return!0}var bg="qxqy-simulator",vg=["tools","webServer"],ul="/qxqy-simulator/api",fl="/qxqy-simulator/play",pd="/qxqy-simulator/play-renderer.js",gd=8*1024*1024,yd=32,dl=6e4,fa=class extends Ar{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(Ci(t))}exportData(t,i){return this.touch(),this.studio.exportData(t,i)}importData(t,i,r){this.touch();let n=this.studio.importData(t,i,r);return this.archivePath="",this.archiveStamp="",this.savedArchive="",{...n,snapshot:this.get()}}listArchives(){return this.touch(),sl(this.studio.get().workspace?.path||"")}loadArchive(t){this.touch();let i=this.studio.get().workspace?.path||"",r=ol(i,t);return{...super.loadArchive(md(hd(i),r)),snapshot:this.get()}}async play(t,i={},r){return this.touch(),super.play(t,Ci(i)||{},r)}async requestScreenshot(t){return{...await super.playScreenshot(t),capturedAt:new Date().toISOString()}}async requestUiScreenshot(t){return this.touch(),{...await super.uiScreenshot(t),capturedAt:new Date().toISOString()}}async dispose(){await this.terminateWorker()}};function pl(e){let t=String(e||"").trim();if(!t||t.length>256)throw new Error("sessionId is required");return t}function Ci(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 It(e){return pl(e?.agent?.id)}function da(e){let t=e?.cwd;return typeof t=="string"&&t?t:""}function xt(e){return da(e?.agent?.session?.header)}async function bd(e,t={}){let i=t.sessions?.get?.(e),r=da(i?.header);if(r)return r;let n=t.sessionPersistence?.inspect;if(typeof n!="function")return"";try{let a=await n.call(t.sessionPersistence,e);return da(a?.meta)}catch{return""}}function vd(){let e=new Map,t=!1;function i(){if(e.size<yd)return;let r=[...e.entries()].sort((n,a)=>n[1].touchedAt-a[1].touchedAt)[0];r&&(e.delete(r[0]),r[1].dispose())}return{get(r,n=""){if(t)throw new Error("simulator plugin has been disposed");let a=pl(r),o=e.get(a);return o?n&&o.studio.setWorkspace(n):(i(),o=new fa(n),e.set(a,o)),o.touch(),o},async dispose(){t=!0;let r=[...e.values()];e.clear(),await Promise.all(r.map(n=>n.dispose()))}}}function Pr(e,t,i){let r=JSON.stringify(i);e.statusCode=t,e.setHeader("content-type","application/json; charset=utf-8"),e.setHeader("cache-control","no-store"),e.end(r)}function Sd(){if(!ca){let t=[new URL("./play.html",import.meta.url),new URL("../lib/play.html",import.meta.url)].find(i=>hl(i));if(!t)throw new Error("standalone play page is missing");ca=ml(t,"utf8")}return ca}var ca=null;function wd(){if(!ua){let t=[new URL("../dist/play-renderer.js",import.meta.url),new URL("./play-renderer.js",import.meta.url)].find(i=>hl(i));if(!t)throw new Error("standalone play renderer bundle is missing; run npm run build");ua=ml(t,"utf8")}return ua}var ua=null;function ki(e,t){return e.effect(()=>e.webServer.register(t),`qxqy-simulator: ${t.kind} ${t.path}`)}function Id(e){ki(e,{kind:"prefix",path:fl,handler(t,i){let r=new URL(t.url,"http://localhost").pathname.replace(/\/$/,"");if(t.method!=="GET"||r!==fl){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(Sd())}})}function xd(e){ki(e,{kind:"exact",path:pd,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(wd())}catch(r){i.statusCode=500,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(r?.message||String(r))}}})}function Cd(e){return new Promise((t,i)=>{let r=0,n=[];e.on("data",a=>{if(r+=a.length,r>gd){i(new Error("request body is too large")),e.destroy();return}n.push(a)}),e.on("end",()=>{try{let a=Buffer.concat(n).toString("utf8");t(a?JSON.parse(a):{})}catch{i(new Error("invalid JSON body"))}}),e.on("error",i)})}function kd(e,t){e.tools.register(wt({name:"qxqy_script_sync",description:"\u5B9E\u673A Lua \u76EE\u5F55\u590D\u5236\u540C\u6B65\uFF1Adiscover/status/configure/preview\u3002configure \u7684 args \u5305\u542B config(version:1, workspaceDir, clientImportRoot, clientSubdir) \u548C expectedRevision\uFF1B\u914D\u7F6E\u968F\u5B8C\u6574\u5B58\u6863\u4FDD\u5B58\u3002preview \u53EA\u68C0\u67E5\u5DEE\u5F02\uFF0C\u590D\u5236\u5FC5\u987B\u7531\u7528\u6237\u5728 Lua \u811A\u672C\u9875\u9762\u68C0\u67E5\u5E76\u786E\u8BA4\u3002",parameters:{action:{type:"string",enum:["discover","status","configure","preview"],required:!0},args:{type:"json"}},output:{schema:{type:"json"},render:(i,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:1e4,isConcurrencySafe:()=>!1,async execute(i,r){return t.get(It(r),xt(r)).scriptSyncAction(i.action,Ci(i.args)||{})}})),e.tools.register(wt({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,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!0,async execute(i,r){return t.get(It(r),xt(r)).get()}})),e.tools.register(wt({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,r)=>{let a=[{type:"text",text:`\u8BD5\u73A9\u622A\u56FE\uFF1A${r.canvasId||"unknown"}\uFF0CFrame ${r.frame??0}\uFF0C${r.width||0}\xD7${r.height||0}`+(r.assetWarnings?.length?`
|
|
113
|
-
\u7D20\u6750\u52A0\u8F7D\u5931\u8D25\uFF08\u753B\u9762\u4E2D\u4E3A\u5360\u4F4D\u6846\uFF09\uFF1A${JSON.stringify(r.assetWarnings)}`:"")}];return r.image&&
|
|
114
|
-
|
|
119
|
+
`)}`);return{buffer:r,warnings:[...new Set(e.warnings)]}}function Ea(t){return Ct.toObject(Ct.decode(vo(t)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function Wf(t){try{let i=Ea(t).graph||[];return i.length>0&&i.every(r=>Number(r.which)===zi)}catch{return!1}}function Kf(t){let e=[...t.graph||[],...t.accessories||[]].filter(n=>Number(n.which)===zi),i=[],r=e.map((n,o)=>{let s=n.script?.mapping||{},a=Number(n.id?.id)||0;a<=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 l=Number(s.id)||0;return l&&l!==a&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04 id(${l}) \u4E0E\u5355\u5143 id(${a}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:a,path:String(s.filePath||""),source:String(s.source||"")}});for(let[n,o]of r.entries())o.path&&!/\.lua$/iu.test(o.path)&&i.push(`\u7B2C ${n+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:r,warnings:i}}function Jf(t){let e=Ea(t),i=Kf(e);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 Qg(t){let e=[],i;try{i=Ea(t)}catch(n){return{valid:!1,errors:[n?.message||String(n)],scriptCount:0}}let r=i.graph||[];return r.length||e.push("Root.graph \u4E3A\u7A7A"),(i.accessories||[]).length&&e.push("script.gia \u4E0D\u5E94\u5305\u542B accessories"),r.forEach((n,o)=>{let s=`\u5355\u5143 ${o+1}`;Number(n.which)!==zi&&e.push(`${s}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${n.which}`),Number(n.id?.class)!==Hf&&e.push(`${s}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${n.id?.class}`),Number(n.id?.type??0)!==0&&e.push(`${s}: id.type \u5E94\u7F3A\u7701`);let a=n.script?.mapping;if(!a){e.push(`${s}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(n.id?.id)<=0&&e.push(`${s}: GraphUnit.id.id \u975E\u6CD5`),Number(a.id)!==Number(n.id?.id)&&e.push(`${s}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(a.name||"")!==String(n.name||"")&&e.push(`${s}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(a.filePath||"").trim()?/\.lua$/iu.test(String(a.filePath))||e.push(`${s}: 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`):e.push(`${s}: file_path \u4E3A\u7A7A`)}),{valid:e.length===0,errors:e,scriptCount:r.length}}function vo(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);if(e.length<wi+va)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(e.readUInt32BE(4)!==1||e.readUInt32BE(8)!==Ff||e.readUInt32BE(12)!==3)throw new Error("\u4E0D\u662F\u53D7\u652F\u6301\u7684 GIA v1 \u6587\u4EF6");let i=e.readUInt32BE(16);if(i!==e.length-wi-va)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(e.readUInt32BE(wi+i)!==Df)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return e.subarray(wi,wi+i)}function Ye(t,e){return t.ui?.content?.data?.find(i=>i.details?.[e])?.details?.[e]||null}function ey(t){let e=t.ui?.content?.data?.find(o=>o.field501===66&&o.field502===89||Object.hasOwn(o.details||{},"templateRefSlot")),i=Buffer.from(e?.details?.templateRefSlot||[]),r=i.toString("utf8"),n=Buffer.from(r,"utf8").equals(i)&&!/[\u0000-\u001f\u007f-\u009f]/u.test(r);return{referencedPrefabId:n?r:"",raw:{templateRefSlot:n?r:"",...n?{}:{templateRefSlotBase64:i.toString("base64")},...e?.empty76?.length?{templateRefOuterBase64:Buffer.from(e.empty76).toString("base64")}:{}}}}function ty(t){let e=Ye(t,"transform")?.multiPlatform,i={};for(let n of e?.platforms||[]){let o=Bg[n.platformType||0],s=n.transform||{};i[o]={scale:s.scale?{x:s.scale.x??0,y:s.scale.y??0,z:s.scale.z??0}:{x:1,y:1,z:1},rotation:{x:s.field508?.x??0,y:s.field508?.y??0,z:s.field508?.z??0},anchorMin:{x:s.anchorMin?.x??0,y:s.anchorMin?.y??0},anchorMax:{x:s.anchorMax?.x??0,y:s.anchorMax?.y??0},offset:{x:s.offset?.x??0,y:s.offset?.y??0},size:{x:s.size?.x??0,y:s.size?.y??0},pivot:s.pivot?{x:s.pivot.x??0,y:s.pivot.y??0}:{x:.5,y:.5}}}let r=i.KEYBOARD||i[Object.keys(i)[0]];if(!r)throw new Error(`GIA \u63A7\u4EF6 ${t.name||t.id?.id} \u7F3A\u5C11\u591A\u5E73\u53F0\u53D8\u6362`);for(let n of qe)i[n]||(i[n]=structuredClone(r));return i}function yo(t){let e=t.ui?.content?.data||[];return e.some(i=>i.details?.textConfig)?e.some(i=>i.field501===71)?"textwindow":"textbox":e.some(i=>i.details?.cursorConfig)?"cursor":e.some(i=>Object.hasOwn(i.details||{},"templateRefSlot")||i.field501===66&&i.field502===89)?"reference":e.some(i=>i.details?.gridView)?"grid":e.some(i=>i.details?.buttonPreset)?"button":e.some(i=>i.details?.keyHint)?"keyhint":e.some(i=>i.details?.image||i.details?.imageSlot)?"image":e.some(i=>Object.hasOwn(i.details||{},"effectSlot"))?"animation":e.some(i=>Object.hasOwn(i.details||{},"fullscreenEffectSlot"))?"fullscreen":(e.some(i=>Object.hasOwn(i.details||{},"containerNodeSlot")),"container")}function Pf(t,{reverseSiblings:e=!1,idOffset:i=0}={}){if(!t.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let r=new Map(t.map((u,c)=>[u.id?.id,`n${i+c+1}`])),n=new Map,o=new Map,s=[];for(let u of t){let c=yo(u),f=Ye(u,"textConfig"),h=Ye(u,"imageSlot"),m=Ye(u,"image"),g=Ye(u,"buttonPreset"),v=Ye(u,"gridView"),I=Ye(u,"genericSlot"),C=Ye(u,"footerSlot"),E=Ye(u,"cursorConfig"),D=Ye(u,"keyHint"),S=Ye(u,"containerNodeSlot"),z=c==="reference"?ey(u):null,L=Ye(u,"effectSlot"),j=Ye(u,"fullscreenEffectSlot"),B=we(c,{id:r.get(u.id?.id),guid:u.id?.id||0,giaInfoIndex:(u.ui?.content?.info||[]).find(_=>_.field501===2&&_.field502===6)?.index?.value,giaRelatedGuids:(u.ui?.content?.info||[]).find(_=>_.field501===4&&_.field502===4)?.related?.value||[],name:u.name||c,visible:Ye(u,"field14")?.field17?.initiallyHidden!==!0,active:Ye(u,"field14")?.initiallyInactive!==!0,canControllerFocus:C?.field505===1,scriptMappingIds:(I?.field502||[]).map(_=>Number(_?.field1?.id)).filter(_=>Number.isSafeInteger(_)&&_>0),transformByPlatform:ty(u),syncAllDevices:Ye(u,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:I?.field501??0,footerField505:C?.field505??0,...c==="textbox"||c==="textwindow"?{textField501:f?.field501??20,textField503:f?.field503??12,textAlign:f?.align??0,...[void 0,0,1,2].includes(f?.verticalAlign)?{}:{textVerticalAlign:f.verticalAlign},...c==="textwindow"?{textField511:f?.field511??1,textViewField502:f?.viewFlags?.field502??1,textViewField503:f?.viewFlags?.field503??1}:{}}:{},...c==="cursor"?{cursorField501:E?.field501??0}:{},...z?.raw||{},...c==="grid"?{gridField501:v?.field501??1,gridField507:v?.field507??1,gridField508:v?.field508??1,gridField509:v?.field509??1,gridField511:v?.field511??5,gridField512:v?.field512??1}:{},...c==="keyhint"?{keyHintField501:D?.field501??1,keyHintField502:D?.field502??1}:{},...c==="image"?{imageSlotType:h?.imageType??0,imageField502:m?.field502??1,imageField504:m?.field504??1,imageField505:m?.field505??1,imageField507:m?.field507??2,imageFillType:m?.fillType??1}:{},...c==="animation"?{effectSlot:L??""}:{},...c==="fullscreen"?{fullscreenEffectSlot:j??""}:{}},...c==="container"?{isolateNavigation:S?.isolateNavigation===!0,disableKeyEventPassthrough:S?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:S?.disableCursorEventPassthrough===!0,showCursor:S?.showCursor===!0}:{},...c==="cursor"?{raycastTarget:E?.field501===1}:{},...c==="textbox"||c==="textwindow"?{text:f?.text?.value??"",fontSize:f?.fontSize??20,minimumFontSize:f?.minimumFontSize??20,adaptiveFontSize:f?.adaptive===1,fontColor:f?.color??4294967295,bgColor:f?.color2??0,enableOutline:f?.outlineOff!==1,outlineColor:f?.color3??858993459,horizontalAlignment:f?.align===1?"Middle":f?.align===2?"Right":"Left",verticalAlignment:{0:"Top",1:"Middle",2:"Bottom"}[f?.verticalAlign??0]||"Top",...c==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...c==="image"?{imageSource:"StaticReference",imageId:h?.assetId??0,imageType:h?.imageType===1?"Stretch":"Basic",imageColor:Number.isFinite(h?.field502)?h.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}:{},...c==="button"?{interactable:g?.interactable===1,raycastTarget:g?.raycastTarget===1,clickAudioId:g?.clickAudioId??50888}:{},...c==="grid"?{cellSizeX:v?.cellSize?.field501??50,cellSizeY:v?.cellSize?.field502??50,spacingX:v?.gap?.field501??8,spacingY:v?.gap?.field502??8,padding1X:v?.padding1?.field501??20,padding1Y:v?.padding1?.field502??20,padding2X:v?.padding2?.field501??20,padding2Y:v?.padding2?.field502??20,previewCount:v?.field511??5}:{},...z?{referencedPrefabId:z.referencedPrefabId}:{},...c==="keyhint"?{keyboardKeyCode:D?.field502??null,controllerKeyCode:D?.field501??null}:{},...c==="animation"?{animationId:L??""}:{},...c==="fullscreen"?{animationId:j??""}:{}});n.set(u.id?.id,B),(z?.raw.templateRefSlotBase64||z?.raw.templateRefOuterBase64)&&s.push(`${B.name}: \u6A21\u677F\u5F15\u7528\u914D\u7F6E\u542B\u5C1A\u672A\u89E3\u6790\u7684\u4E8C\u8FDB\u5236\u5B57\u6BB5\uFF0C\u5DF2\u539F\u6837\u4FDD\u5B58\uFF1B\u5F15\u7528\u76EE\u6807\u672A\u63A8\u65AD\uFF0C\u9884\u89C8\u4E0D\u4F1A\u81EA\u52A8\u5C55\u5F00\u3002`),(c==="textbox"||c==="textwindow")&&![void 0,0,1,2].includes(f?.align)&&s.push(`${B.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${f.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(c==="textbox"||c==="textwindow")&&![void 0,0,1,2].includes(f?.verticalAlign)&&s.push(`${B.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${f.verticalAlign} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),c==="image"&&![void 0,0,1,2,3,4,5].includes(m?.fillType)&&s.push(`${B.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${m.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),c==="button"&&o.set(B.id,{unavailableChildId:g?.disabledChild,hoverChildId:g?.hoverChild,pressedChildId:g?.pressedChild,selectedChildId:g?.selectedChild})}let a=[],l=new Set;for(let u of t){let c=n.get(u.id?.id),f=(u.ui?.content?.children||[]).map(h=>n.get(h)).filter(Boolean);if(f.length){c.children=e?f.slice().reverse():f;for(let h of f)l.add(h.id)}}for(let u of t){let c=n.get(u.id?.id),f=u.ui?.content?.parent||0,h=n.get(f);h?l.has(c.id)||(e?h.children.unshift(c):h.children.push(c)):a.push(c)}for(let[u,c]of o){let f=[...n.values()].find(h=>h.id===u);for(let[h,m]of Object.entries(c))f[h]=r.get(m)||null}return{nodes:n,rootCandidates:a,warnings:s}}function Zf(t){let e=vo(t),i=Ct.toObject(Ct.decode(e),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),r=[...i.graph||[],...i.accessories||[]],n=C=>!!C.ui?.content&&[15,21,70].includes(Number(C.which)),o=(i.graph||[]).filter(n);if(!o.some(C=>C.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let s=o.find(C=>C.which===21)||null,a=o.filter(C=>Number(C.which)===70),l=(i.accessories||[]).filter(n),u=new Set((s?.relatedIds||[]).map(C=>C.id||0)),c=s?u.size?l.filter(C=>u.has(C.id?.id||0)):l:[],f=a.length?[...a,...l.filter(C=>!u.has(C.id?.id||0))]:s?[]:[...o,...l];if(!c.length&&!f.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let h=["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"],m=r.filter(C=>!n(C)&&Number(C.which)!==zi);m.length&&h.push(`\u8DF3\u8FC7 ${m.length} \u4E2A\u975E UI / \u975E\u811A\u672C\u4F9D\u8D56\u5355\u5143\uFF1B\u8FD9\u4E9B\u8D44\u6E90\u4E0D\u4F1A\u8FDB\u5165\u5B58\u6863\u6216\u91CD\u65B0\u5BFC\u51FA\u3002`);let g=Kf(i);h.push(...g.warnings);let v=null,I=null;if(c.length){let C=Pf(c,{reverseSiblings:!0,idOffset:0});h.push(...C.warnings);let E=C.rootCandidates.find(S=>S.kind==="container")||C.rootCandidates[0];if(!E)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let D=we("server-container",{id:"sc1",guid:s?.id?.id||0,name:s?.name||"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",giaRelatedGuids:(s?.ui?.content?.info||[]).find(S=>S.field501===4&&S.field502===4)?.related?.value||[]});D.children=[E],C.rootCandidates.length>1&&h.push(`\u68C0\u6D4B\u5230 ${C.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${E.name}\u201D\u4E3A\u6839\u7684\u6811\u3002`),v={version:1,layoutSchemaVersion:Ze,meta:{name:s?.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:E.id,script:{controlId:E.id,path:"",source:""},root:D}}if(f.length){let C=Pf(f,{reverseSiblings:!1,idOffset:1e3});if(h.push(...C.warnings),!C.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let E=we("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});E.children=C.rootCandidates,I={version:1,layoutSchemaVersion:Ze,meta:{name:C.rootCandidates.length===1?C.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:C.rootCandidates[0].id,script:{controlId:C.rootCandidates[0].id,path:"",source:""},root:E},Ht(I,{warnings:h});for(let D of C.rootCandidates)Ae(D,S=>S.children.reverse());v||(v=I)}return{project:v,clientProject:I&&v!==I?I:void 0,scripts:g.scripts,warnings:h,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(s&&a.length)}}}function Ca(t){let e=vo(t),i=Ct.toObject(Ct.decode(e),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),r=i.graph||[],n=i.accessories||[],o=[],s=(m,g)=>m!=null&&Object.prototype.hasOwnProperty.call(m,g),a=new Map,l=[];/^\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 u=r.filter(m=>m.which===70).map(m=>{let g=yo(m),v=m.ui?.content?.info||[],I=v.find(D=>D.field501===2&&D.field502===6)?.index?.value,C=v.find(D=>D.field501===4&&D.field502===4),E=C?.related?.value||[];return ct(I)||o.push(`${m.name}: Info.index=${I??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),C||o.push(`${m.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:m.id?.id||0,name:m.name||"",kind:g,actualIndex:I,relatedPresent:!!C,relatedGuids:E}}),c=new Map;for(let m of u){if(!ct(m.actualIndex))continue;let g=c.get(m.actualIndex);g?o.push(`${m.name}: \u72EC\u7ACB\u6A21\u677F\u8D44\u4EA7\u7F16\u53F7 ${m.actualIndex} \u4E0E ${g.name} \u91CD\u590D`):c.set(m.actualIndex,m)}u.length||o.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let f=0,h=0;for(let m of[...r,...n]){if(!m.ui?.content)continue;let g=m.id?.id||0,v=m.ui.content,I=yo(m),C=r.includes(m)&&m.which===70,E=`${m.name||"<unnamed>"}(${g||"<missing-guid>"})`;!Number.isSafeInteger(g)||g<=0||g>2147483647?o.push(`${E}: GraphUnit GUID \u975E\u6CD5`):a.has(g)?o.push(`${E}: GUID \u4E0E ${a.get(g).name||"<unnamed>"} \u91CD\u590D`):a.set(g,m),(m.id?.class!==1||m.id?.type!==8)&&o.push(`${E}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),v.guid!==g&&o.push(`${E}: content.guid=${v.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),C&&m.which!==70&&o.push(`${E}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!C&&m.which!==15&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let D=v.info||[],S=D.find(w=>w.field501===1&&w.field502===5),z=D.find(w=>w.field501===2&&w.field502===6);S?.guid?.value!==g&&o.push(`${E}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),ct(z?.index?.value)||o.push(`${E}: Info.index=${z?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let L=D.find(w=>w.field501===4&&w.field502===4);C&&!L&&o.push(`${E}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!C&&L&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let j=$f[I],B=v.data||[],_=B.map(w=>`${w.field501}/${w.field502}`),O=j?.map(([w])=>w)||[];j?JSON.stringify(_)!==JSON.stringify(O)&&o.push(`${E}: Data \u69FD\u4F4D\u987A\u5E8F ${_.join(",")}\uFF0C\u5E94\u4E3A ${O.join(",")}`):o.push(`${E}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${I}`);for(let w=0;w<Math.min(B.length,j?.length||0);w+=1){let F=B[w],[V,H,Z]=j[w];if(s(F,H)||o.push(`${E}: Data ${V} \u7F3A\u5C11 ${H} \u5206\u652F`),!Z)continue;s(F.details,Z)||o.push(`${E}: Details ${V} \u7F3A\u5C11 ${Z} \u5206\u652F`);let ne=Lf[V];(F.details?.field501!==ne||F.details?.field502!==F.field502||F.details?.field503!==1)&&o.push(`${E}: Details ${V} \u6807\u8BB0\u5E94\u4E3A ${ne}/${F.field502}/1`);let ve=F.details?.nodeRef;(ve?.class!==1||ve?.type!==8||ve?.id!==g)&&o.push(`${E}: Details ${V} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let y=(m.ui.content.data||[]).find(w=>w.field501===4&&w.field502===86);y&&(s(y.field14,"field17")?f+=1:o.push(`${E}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),s(y.details?.field14,"field17")?f+=1:o.push(`${E}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let N=(m.ui.content.data||[]).find(w=>w.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];N.length!==4&&o.push(`${E}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${N.length}\uFF0C\u5E94\u4E3A 4`);let x=N.map(w=>w.platformType||0);JSON.stringify(x)!==JSON.stringify([0,1,2,3])&&o.push(`${E}: \u5E73\u53F0\u987A\u5E8F ${x.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let d=(m.ui.content.data||[]).find(w=>w.details?.transform)?.details?.transform;d?.multiPlatform?.field502!==Jr[I]&&o.push(`${E}: \u53D8\u6362 preset=${d?.multiPlatform?.field502??"<missing>"}\uFF0C${I} \u5E94\u4E3A ${Jr[I]}`);for(let w of N)s(w.transform,"field508")?h+=1:o.push(`${E}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);l.push({id:g,name:m.name||"",kind:I,template:C,parent:v.parent||0,children:[...v.children||[]],relatedIds:(m.relatedIds||[]).map(w=>w.id||0),dataSignatures:_})}for(let m of l){let g=`${m.name||"<unnamed>"}(${m.id})`;if(JSON.stringify(m.relatedIds)!==JSON.stringify(m.children)&&o.push(`${g}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),m.template&&m.parent&&o.push(`${g}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!m.template){let v=a.get(m.parent);v?(v.ui?.content?.children||[]).includes(m.id)||o.push(`${g}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):o.push(`${g}: parent=${m.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let v of m.children){let I=a.get(v);I?(I.ui?.content?.parent||0)!==m.id&&o.push(`${g}: child=${v} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):o.push(`${g}: child=${v} \u4E0D\u5B58\u5728`)}}return{valid:o.length===0,errors:o,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:u.length,accessoryCount:n.length,templates:u,units:l,explicitEmpty:{field17:f,rectField508:h}}}function ka(t){let e=vo(t),i=Ct.toObject(Ct.decode(e),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),r=(i.graph||[]).filter(d=>d.ui?.content&&Number(d.which)===21),n=(i.graph||[]).filter(d=>Number(d.which)===70),o=(i.graph||[]).filter(d=>Number(d.which)===zi),s=(i.accessories||[]).filter(d=>d.ui?.content),a=[],l=(d,w)=>d!=null&&Object.prototype.hasOwnProperty.call(d,w);/^\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>"}`),r.length!==1&&a.push(`\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F UIControlGroup \u6570\u91CF=${r.length}\uFF0C\u5E94\u4E3A 1`);let u=(i.graph||[]).filter(d=>{let w=Number(d.which);return w===zi||w===70||w===21?!1:!d.ui?.content});u.length&&a.push(`Root.graph \u542B ${u.length} \u4E2A\u65E0\u6CD5\u8BC6\u522B\u7684\u975E\u63A7\u4EF6/\u975E\u811A\u672C\u5355\u5143`);let c=r[0];if(!c)return{valid:!1,errors:a,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:s.length,controls:[],scriptCount:o.length,explicitEmpty:{field17:0,rectField508:0}};let f=[c,...n,...s],h=new Map;for(let d of f){let w=d.id?.id||0,F=`${d.name||"<unnamed>"}(${w||"<missing-guid>"})`;!Number.isSafeInteger(w)||w<=0||w>2147483647?a.push(`${F}: GraphUnit GUID \u975E\u6CD5`):h.has(w)?a.push(`${F}: GUID \u91CD\u590D`):h.set(w,d),(d.id?.class!==1||d.id?.type!==8)&&a.push(`${F}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),d.ui?.content?.guid!==w&&a.push(`${F}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let m=c.id?.id||0,g=c.ui.content,v=`${c.name||"<unnamed>"}(${m})`;c.which!==21&&a.push(`${v}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let I=g.info||[];I.find(d=>d.field501===1&&d.field502===5)?.guid?.value!==m&&a.push(`${v}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),I.find(d=>d.field501===2&&d.field502===6)?.index?.value!==1&&a.push(`${v}: Info.index \u5FC5\u987B\u4E3A 1`);let C=I.find(d=>d.field501===4&&d.field502===4);C||a.push(`${v}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let E=0,D=0,S=(d,w,F,V=!1)=>{let H=d.id?.id||0,Z=`${d.name||"<unnamed>"}(${H})`,ne=d.ui.content.data||[],ve=ne.map(Re=>`${Re.field501}/${Re.field502}`),be=F.map(([Re])=>Re);JSON.stringify(ve)!==JSON.stringify(be)&&a.push(`${Z}: Data \u69FD\u4F4D\u987A\u5E8F ${ve.join(",")}\uFF0C\u5E94\u4E3A ${be.join(",")}`);for(let Re=0;Re<Math.min(ne.length,F.length);Re+=1){let ut=ne[Re],[gt,de,T]=F[Re];if(l(ut,de)||a.push(`${Z}: Data ${gt} \u7F3A\u5C11 ${de} \u5206\u652F`),!T)continue;l(ut.details,T)||a.push(`${Z}: Details ${gt} \u7F3A\u5C11 ${T} \u5206\u652F`);let A=Lf[gt];(ut.details?.field501!==A||ut.details?.field502!==ut.field502||ut.details?.field503!==1)&&a.push(`${Z}: Details ${gt} \u6807\u8BB0\u5E94\u4E3A ${A}/${ut.field502}/1`);let P=ut.details?.nodeRef;(P?.class!==1||P?.type!==8||P?.id!==H)&&a.push(`${Z}: Details ${gt} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let ge=ne.find(Re=>Re.field501===4&&Re.field502===(V?23:86)),ee=V?"empty15":"field17";l(ge?.field14,ee)?V||(E+=1):a.push(`${Z}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${ee} \u7A7A\u4E32`),l(ge?.details?.field14,ee)?V||(E+=1):a.push(`${Z}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${ee} \u7A7A\u4E32`);let ce=ne.find(Re=>Re.details?.transform)?.details?.transform,Se=ce?.multiPlatform?.platforms||[];Se.length!==4&&a.push(`${Z}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${Se.length}\uFF0C\u5E94\u4E3A 4`);let mt=Se.map(Re=>Re.platformType||0);JSON.stringify(mt)!==JSON.stringify([0,1,2,3])&&a.push(`${Z}: \u5E73\u53F0\u987A\u5E8F ${mt.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let qt=V?Jr["server-container"]:Jr[w];ce?.multiPlatform?.field502!==qt&&a.push(`${Z}: \u53D8\u6362 preset=${ce?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${qt}`);for(let Re of Se)l(Re.transform,"field508")?D+=1:a.push(`${Z}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return ve};S(c,"server-container",jg,!0);let z=(c.relatedIds||[]).map(d=>d.id||0),L=new Set(z),j=s.filter(d=>L.has(d.id?.id||0)),B=j.map(d=>d.id?.id||0);JSON.stringify(z)!==JSON.stringify(B)&&a.push(`${v}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let _=g.data?.find(d=>d.details?.rootChildRef)?.details?.rootChildRef?.guid||0,O=h.get(_);(!O||!j.includes(O))&&a.push(`${v}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),B[0]!==_&&a.push(`${v}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let y=[];for(let d of j){let w=d.id?.id||0,F=d.ui.content,V=`${d.name||"<unnamed>"}(${w})`,H=yo(d);d.which!==15&&a.push(`${V}: which \u5FC5\u987B\u4E3A UIControl(15)`);let Z=F.info||[];(Z.length!==1||Z[0]?.field501!==1||Z[0]?.field502!==5||Z[0]?.guid?.value!==w)&&a.push(`${V}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let ne=$f[H];ne||a.push(`${V}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${H}`);let ve=ne?S(d,H,ne):[];y.push({id:w,name:d.name||"",kind:H,parent:F.parent||0,children:[...F.children||[]],relatedIds:(d.relatedIds||[]).map(be=>be.id||0),dataSignatures:ve})}let N=y.find(d=>d.id===_);N&&(N.kind!=="container"&&a.push(`${N.name}(${_}): \u6839\u63A7\u4EF6\u5FC5\u987B\u4E3A\u5BB9\u5668\u8282\u70B9`),N.parent&&a.push(`${N.name}(${_}): \u6839\u63A7\u4EF6\u4E0D\u5E94\u6709 parent`));let x=new Map(y.map(d=>[d.id,d]));for(let d of y){let w=`${d.name}(${d.id})`;if(JSON.stringify(d.relatedIds)!==JSON.stringify(d.children)&&a.push(`${w}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),d.id!==_){let F=x.get(d.parent);F?F.children.includes(d.id)||a.push(`${w}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):a.push(`${w}: parent=${d.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let F of d.children){let V=x.get(F);V?V.parent!==d.id&&a.push(`${w}: child=${F} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):a.push(`${w}: child=${F} \u4E0D\u5B58\u5728`)}}if(n.length){let d=Ca(_a({...i,graph:n,accessories:s.filter(w=>!L.has(w.id?.id||0))}));a.push(...d.errors.map(w=>`\u5BA2\u6237\u7AEF\u6A21\u677F: ${w}`))}return{valid:a.length===0,errors:a,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:m,name:c.name||"",relatedGuids:C?.related?.value||[],rootGuid:_},accessoryCount:s.length,controls:y,scriptCount:o.length,explicitEmpty:{field17:E,rectField508:D}}}function Qf(t,e=[]){if(!t||t.layoutSchemaVersion===Ze)return t;if(t.layoutSchemaVersion!==void 0&&t.layoutSchemaVersion!==1)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=2 \u6216\u53EF\u8FC1\u79FB\u7684\u65E7\u5E03\u5C40\uFF0C\u6536\u5230 ${t.layoutSchemaVersion}`);if(!t.root)return{...t,layoutSchemaVersion:Ze};let i=structuredClone(t),r=0;return Ae(i.root,n=>{let o=n.transformByPlatform||{},s=n.transformByCanvas||{},a=n.name||n.id;for(let u of Object.keys(o))if(!qe.includes(u))throw new Error(`${a}: unknown platform ${u}`);let l={};for(let u of qe){let c=Ji[u],f=Ee[c].platform,h=Object.keys(Ee).filter(I=>Ee[I].platform===f&&s[I]),m=s[c]?c:h[0],g=u==="CONTROLLER_CONSOLE"?l.KEYBOARD:u==="CONTROLLER_MOBILE"?l.TOUCHSCREEN:null,v=o[u]??g??(m?s[m]:null);if(l[u]=v?Nt(v):ds(n.kind),v||e.push(`${a}: ${u} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!o[u]&&!g&&m&&m!==c&&e.push(`${a}: \u7F3A\u5C11 ${c}\uFF0C\u5DF2\u91C7\u7528 ${m} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!g)for(let I of h)JSON.stringify(l[u])!==JSON.stringify(Nt(s[I]))&&e.push(`${a}: ${I} \u4E0E ${u} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[u]?"\u5DF2\u6709\u5E73\u53F0":m}\u53C2\u6570`)}oi(l,`${a}.transformByPlatform`),n.transformByPlatform=l,delete n.transformByCanvas,r++}),i.layoutSchemaVersion=Ze,e.unshift(`\u5DF2\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E03\u5C40\uFF1A${r} \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 Aa(t){if(![1,2,3,4].includes(t))throw new Error(`\u4EC5\u652F\u6301 version=1\u20134 \u7684\u5B58\u6863\uFF0C\u6536\u5230 ${t}`)}function Ra(t,e,i,r=t.canvasId){let n=ai(t.root,e);return!n||n.kind==="server-container"?Qe(r):i[n.id]||Qe(r)}function Si(t,{warnings:e=[]}={}){if(!t)return Oi();if(t=Qf(t,e),(t.root||t.layoutSchemaVersion!==void 0)&&t.layoutSchemaVersion!==Ze)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${Ze} \u7684\u56DB\u5E73\u53F0\u5E03\u5C40\uFF0C\u4E0D\u652F\u6301\u65E7\u753B\u5E03\u5E03\u5C40\u6216\u5176\u4ED6\u7248\u672C`);let i=t.meta?.assetType==="client-control-template"?"client-control-template":"server-control-template",r=i==="client-control-template"?rr():Oi(),n={layoutSchemaVersion:Ze,version:Number.isSafeInteger(t.version)&&t.version>0?t.version:1,meta:{name:String(t.meta?.name||r.meta.name),assetType:i,sourceFormat:String(t.meta?.sourceFormat||r.meta.sourceFormat),sourceFile:String(t.meta?.sourceFile||""),...t.meta?.gameVersion?{gameVersion:String(t.meta.gameVersion)}:{},...t.meta?.giaFilePath?{giaFilePath:String(t.meta.giaFilePath)}:{},...Number.isSafeInteger(Number(t.meta?.giaOwnerUid))?{giaOwnerUid:Number(t.meta.giaOwnerUid)}:{},...Number.isSafeInteger(Number(t.meta?.giaTimestamp))?{giaTimestamp:Number(t.meta.giaTimestamp)}:{},...Number.isSafeInteger(Number(t.meta?.giaFileId))?{giaFileId:Number(t.meta.giaFileId)}:{},...t.meta?.giaFileName?{giaFileName:String(t.meta.giaFileName)}:{},...Number.isSafeInteger(t.meta?.giaNextAssetIndex)&&t.meta.giaNextAssetIndex>=2?{giaNextAssetIndex:t.meta.giaNextAssetIndex}:{},...Number.isSafeInteger(t.meta?.giaAssetIndexSchemaVersion)&&t.meta.giaAssetIndexSchemaVersion>0?{giaAssetIndexSchemaVersion:t.meta.giaAssetIndexSchemaVersion}:{},...Number.isSafeInteger(Number(t.meta?.giaModeFlag))&&Number(t.meta.giaModeFlag)>=0?{giaModeFlag:Number(t.meta.giaModeFlag)}:{}},canvasId:t.canvasId&&Ee[t.canvasId]?t.canvasId:Tn,selectedId:t.selectedId||r.selectedId,root:ms(t.root||r.root)};return nd(n),Ht(n,{warnings:e}),n}function nd(t){let e=new Set;Ae(t.root,i=>{if(typeof i.id!="string"||!i.id)throw new Error("node id must be a non-empty string");if(e.has(i.id))throw new Error(`duplicate node id: ${i.id}`);e.add(i.id)}),e.has(t.selectedId)||(t.selectedId=ps(t.root).id)}function ed(t){return si(ir(t))}function iy(t,e){let i=!1;return Ae(t,r=>{r.id===e&&(i=!0)}),i}function ry(t,e,i,r){let o=ui(t.root,t.canvasId).boxes[e.id],s=i.children.findIndex(f=>f.id===e.id);if(s<0)throw new Error("reparent: source node is not attached");if(i.children.splice(s,1),r.children.push(e),!o)return;let a=ui(t.root,t.canvasId),l=r.kind==="server-container"?Qe(t.canvasId):a.boxes[r.id]||Qe(t.canvasId),u=li(e.transformByPlatform,t.canvasId),c=ki(l,u,{posX:o.centerX,posY:o.centerY,width:o.width,height:o.height});br(t,e,c)}function ny(t,e){return t.meta.assetType!=="client-control-template"?Is(t.root,e):(t.root.children||[]).flatMap(i=>Is(i,e))}function od(t,e){let i=ku(t.root,e);if(t.meta.assetType!=="client-control-template")return i;let r=Lr(t),n=new Set;return r&&r.kind!=="server-container"&&Ae(r,o=>n.add(o.id)),i.filter(o=>n.has(o.id))}function sd(t){let{canvas:e,boxes:i}=ui(t.root,t.canvasId),r=Qr(t),n=Ve(t.root,t.selectedId),o=n?i[n.id]:null;return se({layoutSchemaVersion:Ze,version:t.version,meta:{...t.meta},canvasId:t.canvasId,canvas:{id:t.canvasId,width:e.width,height:e.height,platform:Ee[t.canvasId].platform,label:Ee[t.canvasId].label,presets:Object.values(Ee).map(s=>({id:s.id,label:s.label,width:s.width,height:s.height,platform:s.platform}))},selectedId:t.selectedId,asset:{type:t.meta.assetType,label:t.meta.assetType==="client-control-template"?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F",templateCount:t.meta.assetType==="client-control-template"?t.root.children.length:1,currentTemplateId:t.meta.assetType==="client-control-template"&&Lr(t)?.id||""},tree:ny(t,r),boxes:od(t,i),inspector:Au(n,t.canvasId,o||e,r),root:t.root})}function br(t,e,i){let r=ui(t.root,t.canvasId),n=Ra(t,e.id,r.boxes),o={};if(e.syncAllDevices!==!1)for(let s of qe){if(s===Ai(t.canvasId))continue;let a=Ji[s],l=ui(t.root,a,s);o[s]=Ra(t,e.id,l.boxes,a)}e.transformByPlatform=uu({transformByPlatform:e.transformByPlatform,source:i,canvasId:t.canvasId,syncAllDevices:e.syncAllDevices!==!1,sourceParentBox:n,targetParentBoxByPlatform:o})}var oy=new Set(["name","active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text","imageSource","imageType","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","itemPrefabId","layoutConstraintFixedCount"]),sy=new Set(["posX","posY","width","height"]),ay=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function ly(t){if(typeof t=="number"&&Number.isFinite(t))return t>>>0;if(typeof t=="string"){let e=t.trim();if(e.startsWith("#")){let r=e.slice(1);if(r.length===6)return(4278190080|parseInt(r,16))>>>0;if(r.length===8)return parseInt(r,16)>>>0}let i=Number(e);if(Number.isFinite(i))return i>>>0}throw new Error("color must be an ARGB integer or #RRGGBB/#AARRGGBB string")}function ei(t,e){let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e} must be a finite number`);return i}function td(t){if(t===!0||t===1||t==="1"||t==="true")return!0;if(t===!1||t===0||t==="0"||t==="false")return!1;throw new Error("boolean field requires true or false")}var uy=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode","itemPrefabId","layoutConstraintFixedCount"]),cy=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),fy=new Set(["name","imageSource","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),id=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),rd={imageSource:["StaticReference","Prefab"],imageType:["Basic","Stretch",null],scrollDirection:["Horizontal","Vertical"],layoutConstraint:["AutoWrap","Fixed"],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 dy(t,e){if(!e||typeof e!="object")throw new Error("patch requires op");let i=e.op;if(i==="select")return e.id&&Ve(t.root,e.id)&&(t.selectedId=e.id),t;if(i==="pick"){let{boxes:r}=ui(t.root,t.canvasId),n=od(t,r),o=Tu(n,Number(e.x),Number(e.y));return o&&(t.selectedId=o),t}if(i==="setCanvas")return e.canvasId&&Ee[e.canvasId]&&(t.canvasId=e.canvasId),t;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 r=e.assetType==="client-control-template"?rr():Oi();return t.version=r.version,t.meta=r.meta,t.canvasId=r.canvasId,t.selectedId=r.selectedId,t.root=r.root,t}if(i==="addTemplate"){if(t.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 r=we(e.kind,{id:hs(t.root),guid:ed(t.root),name:e.name||`\u65B0${e.kind==="container"?"\u5BB9\u5668\u8282\u70B9":e.kind}\u6A21\u677F`});return t.root.children.push(r),t.selectedId=r.id,t}if(i==="add"){let r=Ve(t.root,e.parentId||t.selectedId);if(!r)throw new Error("add: parent not found");let n=su(r,e.kind,{id:hs(t.root),guid:ed(t.root),name:e.name});return t.selectedId=n.id,t}if(i==="reparent"){if(t.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 r=Ve(t.root,e.id||t.selectedId),n=r?ai(t.root,r.id):null,o=Ve(t.root,e.parentId);if(!r||r.kind==="server-container"||!n)throw new Error("reparent: node not found");if(!o)throw new Error("reparent: parent not found");if(o.id===r.id||iy(r,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"&&n.kind==="server-container")return t;if(n.kind==="server-container"&&o.kind!=="server-container"&&t.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 ry(t,r,n,o),t.selectedId=r.id,t}if(i==="moveSibling"){let r=Ve(t.root,e.id||t.selectedId),n=r?ai(t.root,r.id):null;if(!r||!n)throw new Error("moveSibling: node not found");let o=n.children.findIndex(l=>l.id===r.id),s=e.direction==="up"?-1:e.direction==="down"?1:0,a=o+s;return!s||a<0||a>=n.children.length||(n.children.splice(o,1),n.children.splice(a,0,r),t.selectedId=r.id),t}if(i==="remove"){let r=e.id||t.selectedId,n=ai(t.root,r);if(n?.kind==="server-container"){if(t.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((t.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 au(t.root,r)&&(Ae(t.root,o=>{if(o.kind==="button")for(let s of id)o[s]&&!Ve(t.root,o[s])&&(o[s]=null)}),t.selectedId=n?n.id:t.root.id),t}if(i==="set"){let r=Ve(t.root,e.id||t.selectedId);if(!r)throw new Error("set: node not found");let n=e.key;n==="reverseMask"&&(n="reverseMaskArea");let o=e.value;if(r.kind==="reference"&&["referencedPrefabId","giaRaw.templateRefSlot"].includes(n)&&(r.giaRaw.templateRefSlotBase64||r.giaRaw.templateRefOuterBase64))throw new Error("\u8BE5\u6A21\u677F\u5F15\u7528\u542B\u5C1A\u672A\u89E3\u6790\u7684\u539F\u59CB\u914D\u7F6E\uFF0C\u6682\u4E0D\u80FD\u6539\u5199\u76EE\u6807\u7D22\u5F15\uFF1B\u8BF7\u5728\u5B98\u65B9\u7F16\u8F91\u5668\u4FEE\u6539\u540E\u91CD\u65B0\u5BFC\u5165");if(n.startsWith("giaRaw.")){let u=n.slice(7);if(!u||u.includes("."))throw new Error("invalid raw GIA field path");let c=ru(r.kind,u);if(!c)throw new Error(`unknown raw GIA field for ${r.kind}: ${u}`);if(r.giaRaw||={},r.giaRaw[u]=ls(c,o),u==="footerField505"&&[0,1].includes(r.giaRaw[u])&&(r.canControllerFocus=r.giaRaw[u]===1),r.kind==="cursor"&&u==="cursorField501"&&[0,1].includes(r.giaRaw[u])&&(r.raycastTarget=r.giaRaw[u]===1),(r.kind==="textbox"||r.kind==="textwindow")&&u==="textAlign"){let f={0:"Left",1:"Middle",2:"Right"}[r.giaRaw[u]];f&&(r.horizontalAlignment=f)}if(r.kind==="image"&&u==="imageFillType"){let f={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[r.giaRaw[u]];f&&(r.fillType=f)}return r.kind==="keyhint"&&u==="keyHintField502"&&(r.keyboardKeyCode=r.giaRaw[u]),r.kind==="keyhint"&&u==="keyHintField501"&&(r.controllerKeyCode=r.giaRaw[u]),t}if(n==="syncAllDevices"){if(r.syncAllDevices=td(o),r.syncAllDevices){let u=li(r.transformByPlatform,t.canvasId);br(t,r,u)}return t}if(oy.has(n)){if(n.endsWith("Color")&&(o=ly(o)),uy.has(n)){if(o=ei(o,n),o<0)throw new Error(`${n} must not be negative`);if((n==="imageId"||n==="clickAudioId"||n==="keyboardKeyCode"||n==="controllerKeyCode")&&(o=Math.trunc(o)),n==="fillAmount"&&o>1)throw new Error("fillAmount must be between 0 and 1")}if(cy.has(n)&&(o=td(o)),fy.has(n)&&(o=String(o??"")),n==="horizontalAlignment"&&!["Left","Middle","Right"].includes(o))throw new Error("invalid horizontalAlignment");if(n==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(o))throw new Error("invalid verticalAlignment");if(rd[n]&&!rd[n].includes(o))throw new Error(`invalid ${n}`);if(id.has(n))if(o===""||o===void 0||o===null)o=null;else{o=String(o);let u=Ve(t.root,o);if(!u||u===r||u.kind==="server-container"||!(r.children||[]).some(c=>c.id===o))throw new Error(`${n} must reference a direct child of this button`)}if(r.kind==="image"&&(n==="imageSource"||n==="imageId")&&r[n]!==o&&(r.imageType=null,r.giaRaw.imageSlotType=0),r[n]=o,r.kind==="image"&&n==="imageType"&&(r.giaRaw.imageSlotType=o==="Stretch"?1:0),n==="canControllerFocus"&&(r.giaRaw.footerField505=o?1:0),r.kind==="cursor"&&n==="raycastTarget"&&(r.giaRaw.cursorField501=o?1:0),(r.kind==="textbox"||r.kind==="textwindow")&&n==="horizontalAlignment"&&(r.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o]),(r.kind==="textbox"||r.kind==="textwindow")&&n==="verticalAlignment"&&delete r.giaRaw.textVerticalAlign,r.kind==="image"&&n==="fillType"){let u={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o];u&&(r.giaRaw.imageFillType=u)}return r.kind==="reference"&&n==="referencedPrefabId"&&(r.giaRaw.templateRefSlot=o),r.kind==="grid"&&n==="previewCount"&&(r.giaRaw.gridField511=Math.trunc(o)),r.kind==="keyhint"&&n==="keyboardKeyCode"&&(r.giaRaw.keyHintField502=Math.trunc(o)),r.kind==="keyhint"&&n==="controllerKeyCode"&&(r.giaRaw.keyHintField501=Math.trunc(o)),(r.kind==="animation"||r.kind==="fullscreen")&&n==="animationId"&&(r.giaRaw[r.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=o),t}let{boxes:s}=ui(t.root,t.canvasId),a=Ra(t,r.id,s),l=li(r.transformByPlatform,t.canvasId);if(n==="anchorType"){let u=Ta(s[r.id]),c=Zl(l,o);return c=ki(a,c,u),br(t,r,c),t}if(["rotationX","rotationY","rotationZ"].includes(n)){let u={...l,rotation:{...l.rotation,[n.slice(-1).toLowerCase()]:ei(o,n)}};return br(t,r,u),t}if(ay.has(n)){let u=Ta(s[r.id]),c={...l,anchorMin:{...l.anchorMin},anchorMax:{...l.anchorMax},pivot:{...l.pivot}};return n==="anchorMinX"&&(c.anchorMin.x=ei(o,n)),n==="anchorMinY"&&(c.anchorMin.y=ei(o,n)),n==="anchorMaxX"&&(c.anchorMax.x=ei(o,n)),n==="anchorMaxY"&&(c.anchorMax.y=ei(o,n)),n==="pivotX"&&(c.pivot.x=ei(o,n)),n==="pivotY"&&(c.pivot.y=ei(o,n)),br(t,r,ki(a,c,u)),t}if(sy.has(n)){let u=Ta(s[r.id]),c=ei(o,n);if((n==="width"||n==="height")&&c<0)throw new Error(`${n} must not be negative`);return u[n]=c,br(t,r,ki(a,l,u)),t}throw new Error(`set: unknown key ${n}`)}if(i==="replace"){let r=Si(e.project);return t.version=r.version,t.meta=r.meta,t.canvasId=r.canvasId,t.selectedId=r.selectedId,t.root=r.root,t}throw new Error(`unknown op ${i}`)}function Oa(t,e){if(!e||typeof e!="object")throw new Error("patch requires op");if(e.expectedRevision!==void 0&&Number(e.expectedRevision)!==t.version)throw new Error(`revision conflict: expected ${e.expectedRevision}, current ${t.version}`);let i=t.version,r=JSON.parse(JSON.stringify(t));return dy(r,e),nd(r),Ht(r),r.version=i+1,Object.keys(t).forEach(n=>{delete t[n]}),Object.assign(t,r),t}function Ta(t){return t?{posX:t.centerX,posY:t.centerY,width:t.width,height:t.height}:{posX:0,posY:0,width:0,height:0}}import hy from"fengari";var{lua:p,lauxlib:Ie,lualib:ad,to_luastring:bo,to_jsstring:py}=hy,my=p.LUA_TNIL,gy=p.LUA_TBOOLEAN,yy=p.LUA_TNUMBER,vy=p.LUA_TSTRING,ld=p.LUA_TTABLE,by=p.LUA_TFUNCTION,Na=p.LUA_TUSERDATA,kt=p.LUA_OK,ud=new WeakMap,Pa=Symbol("luaTableEntries"),Ma={__scriptHostKey:!0};function G(t){return bo(String(t))}function $i(t,e){ud.set(t,e)}function lt(t){return ud.get(t)}var en=class{constructor(e){this.value=e}};function Le(t,e,i){if(i instanceof en){p.lua_pushnumber(t,i.value);return}if(i==null){p.lua_pushnil(t);return}let r=typeof i;if(r==="boolean"){p.lua_pushboolean(t,i);return}if(r==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?p.lua_pushinteger(t,i):p.lua_pushnumber(t,i);return}if(r==="string"){p.lua_pushstring(t,G(i));return}if(r==="function"){xy(t,e,i);return}if(i&&i[Pa]){let n=i[Pa];p.lua_createtable(t,Array.isArray(i)?i.length:0,n.length);for(let[o,s]of n)Le(t,e,o),Le(t,e,s),p.lua_settable(t,-3);return}if(Array.isArray(i)){p.lua_createtable(t,i.length,0);for(let n=0;n<i.length;n++)Le(t,e,i[n]),p.lua_rawseti(t,-2,n+1);return}if(i&&i.__kind==="EnumItem"){e.pushEnumItem(t,i);return}if(i&&i.__kind==="CursorEventData"){e.pushCursor(t,i);return}if(i&&i.__kind==="Script"){e.pushScript(t,i);return}if(i&&i.typeofName){e.pushControl(t,i);return}if(i&&i.__kind==="ServerSignal"){e.pushSignal(t,i);return}if(i&&(i.SetEase||i.Append)){e.pushTween(t,i);return}if(r==="object"){p.lua_createtable(t,0,Object.keys(i).length);for(let[n,o]of Object.entries(i))Le(t,e,o),p.lua_setfield(t,-2,G(n));return}p.lua_pushnil(t)}function Ce(t,e){if(p.lua_isnil(t,e)||p.lua_type(t,e)===p.LUA_TNONE)return"";if(!p.lua_isstring(t,e)&&p.lua_type(t,e)!==p.LUA_TNUMBER)return`lua_type=${p.lua_type(t,e)}`;let i=p.lua_tostring(t,e);return i==null?"":py(i)}function ti(t,e){e=p.lua_absindex(t,e);let i=p.lua_type(t,e);if(i===Na)return lt(p.lua_touserdata(t,e));if(i===ld){p.lua_pushlightuserdata(t,Ma),p.lua_rawget(t,e);let r=p.lua_type(t,-1)===Na?p.lua_touserdata(t,-1):null;return p.lua_pop(t,1),r?lt(r):null}return null}function Xe(t,e,i){i=p.lua_absindex(t,i);let r=p.lua_type(t,i);if(r===my)return null;if(r===gy)return!!p.lua_toboolean(t,i);if(r===yy)return p.lua_isinteger(t,i)?p.lua_tointeger(t,i):p.lua_tonumber(t,i);if(r===vy)return Ce(t,i);if(r===Na){let n=p.lua_touserdata(t,i);return lt(n)??n}if(r===by)return wy(t,e,i);if(r===ld){let n=ti(t,i);if(n)return n;let o=[];for(p.lua_pushnil(t);p.lua_next(t,i)!==0;){let u=Xe(t,e,-2),c=Xe(t,e,-1);o.push([u,c]),p.lua_pop(t,1)}let s=new Map(o.filter(([u])=>Number.isInteger(u)&&u>=1)),a=0;for(;s.has(a+1);)a+=1;let l=a>0?[]:{};for(let[u,c]of o)Array.isArray(l)&&Number.isInteger(u)&&u>=1?l[u-1]=c:(typeof u=="string"||typeof u=="number")&&(l[u]=c);return Object.defineProperty(l,Pa,{value:o}),l}return null}function wy(t,e,i){e.luaFunctions||(e.luaFunctions=new Map);let r=typeof p.lua_topointer=="function"?p.lua_topointer(t,i):null;if(r!=null&&e.luaFunctions.has(r))return e.luaFunctions.get(r);p.lua_pushvalue(t,i);let n=Ie.luaL_ref(t,p.LUA_REGISTRYINDEX),o=Sy(t,e,n);return r!=null&&e.luaFunctions.set(r,o),o}function Sy(t,e,i){let r=(...n)=>{if(r.__luaRef==null)throw new Error("attempt to call a released Lua callback");let o=p.lua_gettop(t);p.lua_rawgeti(t,p.LUA_REGISTRYINDEX,r.__luaRef);for(let u of n)Le(t,e,u);if(p.lua_pcall(t,n.length,p.LUA_MULTRET,0)!==kt){let u=Ce(t,-1);throw p.lua_settop(t,o),new Error(u)}let a=p.lua_gettop(t)-o,l=[];for(let u=1;u<=a;u++)l.push(Xe(t,e,o+u));if(p.lua_settop(t,o),l.length!==0)return l.length===1?l[0]:l};return r.__luaRef=i,r.__luaState=t,r}function cd(t){t?.__luaRef!=null&&(t.__luaHolds=(t.__luaHolds||0)+1)}function fd(t,e){if(!e||e.__luaRef==null||!e.__luaState)return;if(e.__luaHolds>1){e.__luaHolds-=1;return}let i=e.__luaState;if((!t?.luaStates||t.luaStates.has(i))&&Ie.luaL_unref(i,p.LUA_REGISTRYINDEX,e.__luaRef),e.__luaRef=null,e.__luaState=null,t?.luaFunctions)for(let[r,n]of t.luaFunctions)n===e&&t.luaFunctions.delete(r)}function xy(t,e,i){p.lua_pushlightuserdata(t,i),p.lua_pushlightuserdata(t,e),p.lua_pushcclosure(t,function(n){let o=p.lua_touserdata(n,p.lua_upvalueindex(1)),s=p.lua_touserdata(n,p.lua_upvalueindex(2)),a=p.lua_gettop(n),l=[];for(let u=1;u<=a;u++)l.push(Xe(n,s,u));try{let u=o(...l);if(Array.isArray(u)&&u.__multi){for(let c of u)Le(n,s,c);return u.length}return u===void 0?0:(Le(n,s,u),1)}catch(u){return p.lua_pushstring(n,G(String(u&&u.message?u.message:u))),p.lua_error(n)}},2)}function dd(t){!t||typeof p.lua_close!="function"||p.lua_close(t)}function hd(t){if(Ie.luaL_loadstring(t,G(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
|
|
120
|
+
`)))===kt&&p.lua_pcall(t,0,0,0),p.lua_settop(t,0),p.lua_pushnil(t),p.lua_setglobal(t,G("_VERSION")),p.lua_getglobal(t,G("string")),!p.lua_isnil(t,-1))for(let i of["dump","pack","unpack"])p.lua_pushnil(t),p.lua_setfield(t,-2,G(i));if(p.lua_pop(t,1),p.lua_pushnil(t),p.lua_setglobal(t,G("io")),p.lua_getglobal(t,G("os")),!p.lua_isnil(t,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))p.lua_pushnil(t),p.lua_setfield(t,-2,G(i));p.lua_pop(t,1),p.lua_getglobal(t,G("debug")),p.lua_isnil(t,-1)?p.lua_pop(t,1):(p.lua_getfield(t,-1,G("traceback")),p.lua_newtable(t),p.lua_pushvalue(t,-2),p.lua_setfield(t,-2,G("traceback")),p.lua_setglobal(t,G("debug")),p.lua_pop(t,2)),p.lua_getglobal(t,G("math")),p.lua_isnil(t,-1)||(p.lua_pushcfunction(t,i=>{let r=p.lua_tonumber(i,1);return p.lua_pushboolean(i,Number.isNaN(r)),1}),p.lua_setfield(t,-2,G("isnan")),p.lua_pushcfunction(t,i=>{let r=p.lua_tonumber(i,1);return p.lua_pushboolean(i,r===1/0||r===-1/0),1}),p.lua_setfield(t,-2,G("isinf"))),p.lua_pop(t,1),p.lua_pushnil(t),p.lua_setglobal(t,G("package")),p.lua_pushnil(t),p.lua_setglobal(t,G("load")),p.lua_pushnil(t),p.lua_setglobal(t,G("loadfile")),p.lua_pushnil(t),p.lua_setglobal(t,G("dofile")),p.lua_pushnil(t),p.lua_setglobal(t,G("collectgarbage")),p.lua_pushnil(t),p.lua_setglobal(t,G("coroutine")),p.lua_pushnil(t),p.lua_setglobal(t,G("fengari"))}var ht=(t,e=0)=>Number.isFinite(Number(t))?Number(t):e,pd=t=>t?.Name||t,wo=t=>Math.max(0,Math.min(1,ht(t)));function tn(t){let e=t.parent?tn(t.parent):[t.runtime.canvasWidth,t.runtime.canvasHeight];return[Math.max(0,(t.anchorMaxX-t.anchorMinX)*e[0]+ht(t.sizeDeltaX)),Math.max(0,(t.anchorMaxY-t.anchorMinY)*e[1]+ht(t.sizeDeltaY))]}function rn(t){let[e,i]=tn(t),r=pd(t.scrollDirection)==="Horizontal",n=Math.max(1,ht(t.cellSizeX,50)),o=Math.max(1,ht(t.cellSizeY,50)),s=Math.max(0,ht(t.spacingX)),a=Math.max(0,ht(t.spacingY)),l=Math.max(0,ht(t.padding1X)),u=Math.max(0,ht(t.padding1Y)),c=Math.max(0,ht(t.padding2X)),f=Math.max(0,ht(t.padding2Y)),h=r?i-u-f:e-l-c,m=r?o:n,g=r?a:s,v=pd(t.layoutConstraint)==="Fixed"?Math.max(1,Math.floor(ht(t.layoutConstraintFixedCount,1))):Math.max(1,Math.floor((h+g)/(m+g))),I=Math.ceil(t.itemCount/v),C=I?r?l+c+I*n+(I-1)*s:u+f+I*o+(I-1)*a:0,E=r?e:i,D=Math.max(0,C-E);return{width:e,height:i,horizontal:r,cellW:n,cellH:o,gapX:s,gapY:a,left:l,top:u,right:c,bottom:f,lanes:v,length:C,viewport:E,max:D,offset:wo(t.scrollProgress)*D}}function wr(t){let e=rn(t);for(let i=0;i<(t._gridItems?.length||0);i+=1){let r=t._gridItems[i];if(!r.alive||r.parent!==t)continue;let n=Math.floor(i/e.lanes),o=i%e.lanes,s=e.horizontal?n:o,a=e.horizontal?o:n,l=e.left+s*(e.cellW+e.gapX)+e.cellW/2-(e.horizontal?e.offset:0),u=-e.top-a*(e.cellH+e.gapY)-e.cellH/2+(e.horizontal?0:e.offset),c={anchorMinX:0,anchorMaxX:0,anchorMinY:1,anchorMaxY:1,pivotX:.5,pivotY:.5,sizeDeltaX:e.cellW,sizeDeltaY:e.cellH,anchoredPositionX:l,anchoredPositionY:u};Object.entries(c).some(([f,h])=>r[f]!==h)&&(Object.assign(r,c),r.markPlayDirty(!0))}return e}var md={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},_y=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],So=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),Iy=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],Ey={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},Cy={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"]},ky=["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"],gd=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Ay={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:gd,cursor:gd,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function Da(t,e){return t.kind==="image"&&e==="imageType"&&t.runtime.canSelectImageType(t.imageId,t.imageSource)?"rw":_y.includes(e)||(Ey[t.kind]||[]).includes(e)?"ro":Iy.includes(e)||(Cy[t.kind]||[]).includes(e)?"rw":null}var Ty=["localRotationX","localRotationY","localRotationZ"],Sr=Math.PI/180;function yd(t,e){return[t[3]*e[0]+t[0]*e[3]+t[1]*e[2]-t[2]*e[1],t[3]*e[1]-t[0]*e[2]+t[1]*e[3]+t[2]*e[0],t[3]*e[2]+t[0]*e[1]-t[1]*e[0]+t[2]*e[3],t[3]*e[3]-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]}function Fa(t){if(Object.is(t,-0))return t;let e=(t%360+360)%360,i=Math.round(e*1e6)/1e6;return i>=360?0:i}function vd(t,e,i){let r=E=>[Math.sin(E*Sr/2),Math.cos(E*Sr/2)],[n,o]=r(t),[s,a]=r(e),[l,u]=r(i),[c,f,h,m]=yd(yd([0,s,0,a],[n,0,0,o]),[0,0,l,u]),g=Math.max(-1,Math.min(1,-2*(f*h-m*c))),v,I,C;return Math.abs(g)>.999999?(v=Math.sign(g)*90,I=2*Math.atan2(f,m)/Sr,C=0):(v=Math.asin(g)/Sr,I=Math.atan2(2*(m*f+c*h),1-2*(c*c+f*f))/Sr,C=Math.atan2(2*(m*h+c*f),1-2*(c*c+h*h))/Sr),[Fa(v),Fa(I),Fa(C)]}function bd(t,e){return ky.includes(e)||(Ay[t.kind]||[]).includes(e)}var Ry={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}},xi=class t{constructor(e,i){this.runtime=e,this.kind=i.kind||"container",this.typeofName=md[this.kind]||md.container,this.alive=!0,this.Id=i.Id??e.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,(this.kind==="grid"||this.kind==="textwindow")&&(this.runtime.scrollControls||=new Set,this.runtime.scrollControls.add(this));let r=Ry[this.kind]||{};for(let[n,o]of Object.entries(r))this[n]===void 0&&(this[n]=i[n]!==void 0?i[n]:o);if(this.kind==="grid"&&(this.scrollProgress=i.scrollProgress??0),i.children)for(let n of i.children){let o=n instanceof t?n:new t(e,n);this.addChild(o)}}get parent(){return this._parent}set parent(e){if(this._parent===e)return;if(e!==null&&!(e instanceof t))throw new Error("parent must be a Control or nil");if(e&&e.runtime!==this.runtime)throw new Error("parent must belong to the same runtime");if(e===this)throw new Error("cannot parent a control to itself or its descendant");for(let r=e;r;r=r._parent)if(r===this)throw new Error("cannot parent a control to itself or its descendant");let i=this._parent;if(i){let r=i.children.indexOf(this);r>=0&&i.children.splice(r,1),i.markPlayDirty(!0)}else{let r=this.runtime.roots.indexOf(this);r>=0&&this.runtime.roots.splice(r,1)}this._parent=e,this.markPlayDirty(!0),e&&!e.children.includes(this)?(e.children.push(this),e.markPlayDirty(!0)):!e&&this.alive&&!this.runtime.roots.includes(this)&&this.runtime.roots.push(this)}markPlayDirty(e=!1){this._playDirty=!0,e&&(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}get scrollProgress(){return this._scrollProgress??0}set scrollProgress(e){if(typeof e!="number"||!Number.isFinite(e))throw new Error("scrollProgress must be a finite number");this._scrollProgress=wo(e),this.markPlayDirty()}addChild(e){return e.parent=this,e}GetChildren(){return this.children.slice()}GetChild(e){return this.children.find(i=>i.name===e)||null}FindChild(e){if(!e)return null;if(!e.includes("/"))return this.GetChild(e);let i=e.split("/").filter(Boolean),r=this;for(let n of i)if(r=r.GetChild(n),!r)return null;return r}SetActive(e){let i=!!e;if(this.active!==i){if(typeof this.runtime?.onControlActiveChanging=="function"){this.runtime.onControlActiveChanging(this,i);return}this.active=i,this.markPlayDirty(!0)}}SetVisible(e){this.visible=!!e,this.markPlayDirty(!0)}GetSiblingIndex(){if(!this._parent)return-1;let e=this._parent.children,i=e.indexOf(this);return i<0?-1:e.length-1-i}SetSiblingIndex(e){if(!this._parent)return!1;let i=this._parent.children,r=i.indexOf(this);if(r<0)return!1;let n=i.length-1;return!Number.isInteger(e)||e<0||e>n?!1:(i.splice(r,1),i.splice(n-e,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(e,i){this.anchoredPositionX=e,this.anchoredPositionY=i,this.markPlayDirty()}GetSizeDelta(){return[this.sizeDeltaX,this.sizeDeltaY]}SetSizeDelta(e,i){this.sizeDeltaX=e,this.sizeDeltaY=i,this.markPlayDirty(!0)}GetAnchorMin(){return[this.anchorMinX,this.anchorMinY]}SetAnchorMin(e,i){this.anchorMinX=e,this.anchorMinY=i,this.markPlayDirty(!0)}GetAnchorMax(){return[this.anchorMaxX,this.anchorMaxY]}SetAnchorMax(e,i){this.anchorMaxX=e,this.anchorMaxY=i,this.markPlayDirty(!0)}GetPivot(){return[this.pivotX,this.pivotY]}SetPivot(e,i){this.pivotX=e,this.pivotY=i,this.markPlayDirty(!0)}GetLocalScale(){return[this.localScaleX,this.localScaleY,this.localScaleZ]}SetLocalScale(e,i,r){this.localScaleX=e,this.localScaleY=i,this.localScaleZ=r,this.markPlayDirty()}GetLocalRotation(){return vd(this.localRotationX,this.localRotationY,this.localRotationZ)}luaFieldValue(e){if(e==="imageType")return this.imageType??"Stretch";let i=Ty.indexOf(e);return i<0?this[e]:vd(this.localRotationX,this.localRotationY,this.localRotationZ)[i]}SetLocalRotation(e,i,r){this.localRotationX=e,this.localRotationY=i,this.localRotationZ=r,this.markPlayDirty()}GetScriptByPath(e){return this.scripts.find(i=>i.path===e)||null}GetScript(e){return this.scripts.find(i=>i.scriptMappingId===e)||null}GetScripts(){return this.scripts.slice()}_addListener(e,i,r){let n=e.get(i)||[];n.push(r),e.set(i,n),this.runtime.retainLuaCallback?.(r)}_removeListener(e,i,r){let n=e.get(i);if(!n)return;let o=n.filter(s=>s!==r);e.set(i,o);for(let s=o.length;s<n.length;s++)this.runtime.unrefLuaCallback?.(r)}_removeListeners(e,i){let r=e.get(i)||[];for(let n of r)this.runtime.unrefLuaCallback?.(n);e.delete(i)}_removeAllListeners(e){for(let i of e.values())for(let r of i)this.runtime.unrefLuaCallback?.(r);e.clear()}AddCursorEventListener(e,i){this._addListener(this.cursorListeners,e,i)}RemoveCursorEventListener(e,i){this._removeListener(this.cursorListeners,e,i)}RemoveCursorEventListeners(e){this._removeListeners(this.cursorListeners,e)}RemoveAllCursorEventListeners(){this._removeAllListeners(this.cursorListeners)}SimulateCursorClick(){let e=this.runtime.makeCursorEventData({x:0,y:0,pressX:0,pressY:0});this.emitCursor("CursorDown",e),this.emitCursor("CursorUp",e),this.emitCursor("CursorClick",e)}emitCursor(e,i){if(!this.runtime.cursorEventsEnabled(this))return;let r=this.cursorListeners.get(e)||[];for(let n of r)n(i)}AddKeyEventListener(e,i){this._addListener(this.keyListeners,e,i)}RemoveKeyEventListener(e,i){this._removeListener(this.keyListeners,e,i)}RemoveKeyEventListeners(e){this._removeListeners(this.keyListeners,e)}RemoveAllKeyEventListeners(){this._removeAllListeners(this.keyListeners)}emitKey(e){let i=this.keyListeners.get(e)||[];for(let r of i)if(r()===!0)return!0;return!1}AddNavigationEventListener(e,i){this._addListener(this.navListeners,e,i)}RemoveNavigationEventListener(e,i){this._removeListener(this.navListeners,e,i)}RemoveNavigationEventListeners(e){this._removeListeners(this.navListeners,e)}RemoveAllNavigationEventListeners(){this._removeAllListeners(this.navListeners)}SetControllerNavigation(e,i,r){this.navConfig.set(e,{mode:i,target:r})}GetControllerNavigation(e){let i=this.navConfig.get(e),r=i?[i.mode,i.target]:[null,null];return r.__multi=!0,r}SetImage(e,i){let r=this.imageSource?.Name||this.imageSource,n=e?.Name||e;(i!==this.imageId||r!==n)&&(this.imageType=null),this.imageSource=e,this.imageId=i,this.markPlayDirty()}SetSoftEdgeWidth(e,i){this.softEdgeWidthX=e,this.softEdgeWidthY=i,this.markPlayDirty()}SetFillUnused(){this.fillType="Unused",this.markPlayDirty()}SetFillHorizontal(e,i){this.fillType="Horizontal",this.fillHorizontalType=e,this.fillAmount=i,this.markPlayDirty()}SetFillVertical(e,i){this.fillType="Vertical",this.fillVerticalType=e,this.fillAmount=i,this.markPlayDirty()}SetFillRadial90(e,i){this.fillType="Radial90",this.fillRadial90Type=e,this.fillAmount=i,this.markPlayDirty()}SetFillRadial180(e,i){this.fillType="Radial180",this.fillRadialType=e,this.fillAmount=i,this.markPlayDirty()}SetFillRadial360(e,i){this.fillType="Radial360",this.fillRadialType=e,this.fillAmount=i,this.markPlayDirty()}PlayAnimation(){}StopAnimation(){}RefreshItems(e,i){if(!Number.isInteger(e)||e<0||e>2e3)throw new Error("RefreshItems: simulator supports 0..2000 items");if(typeof i!="function")throw new Error("RefreshItems: callback must be a function");if(!this.alive||this._refreshingGrid)throw new Error("RefreshItems: destroyed control or recursive refresh");if(e&&!this.runtime.templates.has(Number(this.itemPrefabIndex)))throw new Error("RefreshItems: item template not found");if(e&&["OnInit","OnDestroy"].includes(this.runtime.lifecyclePhase))throw new Error("RefreshItems: items cannot be created during OnInit/OnDestroy");this._refreshingGrid=!0;try{this._gridItems||=[];let r=[];for(let n of this._gridItems)n.alive&&n.parent===this&&n.prefabIndex===Number(this.itemPrefabIndex)&&r.length<e?r.push(n):n.alive&&n.parent===this&&this.runtime.destroyControl(n);for(this._gridItems=r;r.length<e;){let n=this.runtime.instantiate(this.itemPrefabIndex,this,this.runtime.lifecyclePhase);if(!n)throw new Error("RefreshItems: could not instantiate item");r.push(n),n.SetActive(!0)}this.itemCount=e,wr(this),this.markPlayDirty(!0);for(let n=0;n<r.length&&this.alive;n+=1)i(r[n],n)}finally{this._refreshingGrid=!1}}GetItemIndex(e){return e?.alive&&e.parent===this?this._gridItems?.indexOf(e)??-1:-1}GetItemSize(){return[this.cellSizeX,this.cellSizeY]}GetItemSpacing(){return[this.spacingX,this.spacingY]}GetPadding(){return[this.padding1Y,this.padding2Y,this.padding1X,this.padding2X]}ScrollToItemAt(e,i){if(!Number.isInteger(e)||e<0||e>=this.itemCount)throw new Error("ScrollToItemAt: item index out of range");let r=rn(this),n=r.horizontal?r.cellW:r.cellH,o=r.horizontal?r.gapX:r.gapY,s=(r.horizontal?r.left:r.top)+Math.floor(e/r.lanes)*(n+o),a=i?.Name||i;if(!["Top","Center","Bottom"].includes(a))throw new Error("ScrollToItemAt: invalid alignment");let l=s-(a==="Center"?(r.viewport-n)/2:a==="Bottom"?r.viewport-n:0);this.scrollProgress=r.max?wo(l/r.max):0,wr(this),this.markPlayDirty(!0)}GetContentLength(){return rn(this).length}};function Gt(t,e){e(t);for(let i of t.children)Gt(i,e)}function za(t,e=[],i=""){e.push(`${i}${t.name||"(unnamed)"} [${t.typeofName}] Id=${t.Id}`);for(let r of t.children)za(r,e,i+" ");return e}function xo(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}var wd={Linear:t=>t,InSine:t=>1-Math.cos(t*Math.PI/2),OutSine:t=>Math.sin(t*Math.PI/2),InOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,InQuad:t=>t*t,OutQuad:t=>1-(1-t)*(1-t),InOutQuad:t=>t<.5?2*t*t:1-(-2*t+2)**2/2,InCubic:t=>t*t*t,OutCubic:t=>1-(1-t)**3,InOutCubic:t=>t<.5?4*t*t*t:1-(-2*t+2)**3/2,InQuart:t=>t**4,OutQuart:t=>1-(1-t)**4,InOutQuart:t=>t<.5?8*t**4:1-(-2*t+2)**4/2,InQuint:t=>t**5,OutQuint:t=>1-(1-t)**5,InOutQuint:t=>t<.5?16*t**5:1-(-2*t+2)**5/2,InExpo:t=>t===0?0:2**(10*t-10),OutExpo:t=>t===1?1:1-2**(-10*t),InOutExpo:t=>t===0||t===1?t:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,InCirc:t=>1-Math.sqrt(1-t**2),OutCirc:t=>Math.sqrt(1-(t-1)**2),InOutCirc:t=>t<.5?(1-Math.sqrt(1-(2*t)**2))/2:(Math.sqrt(1-(-2*t+2)**2)+1)/2,InBack:t=>(1.70158+1)*t*t*t-1.70158*t*t,OutBack:t=>1+2.70158*(t-1)**3+1.70158*(t-1)**2,InOutBack:t=>{let i=2.5949095;return t<.5?(2*t)**2*((i+1)*2*t-i)/2:((2*t-2)**2*((i+1)*(t*2-2)+i)+2)/2},InElastic:t=>t===0||t===1?t:-(2**(10*t-10))*Math.sin((t*10-10.75)*(2*Math.PI/3)),OutElastic:t=>t===0||t===1?t:2**(-10*t)*Math.sin((t*10-.75)*(2*Math.PI/3))+1,InOutElastic:t=>{if(t===0||t===1)return t;let e=2*Math.PI/4.5;return t<.5?-(2**(20*t-10)*Math.sin((20*t-11.125)*e))/2:2**(-20*t+10)*Math.sin((20*t-11.125)*e)/2+1},InBounce:t=>1-xo(1-t),OutBounce:xo,InOutBounce:t=>t<.5?(1-xo(1-2*t))/2:(1+xo(2*t-1))/2};function Sd(t,e){let i=wd[t]||wd.Linear;return e<=0?0:e>=1?1:i(e)}function xr(t,e,i,r=255){let n=_o(t),o=_o(e),s=_o(i);return((r==null?255:_o(r))<<24|n<<16|o<<8|s)>>>0}function nn(t){let e=t>>>0;return[e>>>16&255,e>>>8&255,e&255,e>>>24&255]}function _o(t){let e=Number(t);return Number.isFinite(e)?Math.max(0,Math.min(255,Math.trunc(e))):0}function xd(t,e,i){let r=nn(t),n=nn(e);return xr(r[0]+(n[0]-r[0])*i,r[1]+(n[1]-r[1])*i,r[2]+(n[2]-r[2])*i,r[3]+(n[3]-r[3])*i)}var Oy=new Set(["fontColor","bgColor","outlineColor","imageColor"]),Ny=new Set(["fontSize","minimumFontSize"]),$a=1e-9;function Py(t,e){return typeof t?.luaFieldValue=="function"?t.luaFieldValue(e):t[e]}var on=class{constructor(e,i,r,n){this.runtime=e,this.object=i,this.data={...r},this.duration=Math.max(0,Number(n)||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,this.dead=!1,this.completed=!1}capture(){this.from={},this.to={};for(let[e,i]of Object.entries(this.data)){let r=Py(this.object,e);this.from[e]=r,this.to[e]=this.relative?Number(r)+Number(i):i}}restoreInitial(){this.from={...this.initialFrom},this.to={...this.initialTo}}SetEase(e){return this.easeName=typeof e=="string"?e:e?.Name||"Linear",this}SetRelative(e){return this.relative=!!e,this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._start(!1)}_begin(e){this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,this.completed=!1,e&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to})}_start(e){return this._begin(e),this.runtime.tweens.add(this),this.runtime.animations.add(this),this}get loopCount(){return this.loops>0?this.loops:1}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this.dead?this:this._start(!0)}Complete(){this.dead||this.completed||(this.initialFrom||this._begin(!1),this.apply(1),this.finish(!0))}Kill(e){e?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(e){return this.onComplete=e,this}SetOnStepComplete(e){return this.onStepComplete=e,this}SetLoops(e){return this.loops=e,this}apply(e){if(this.object?.alive===!1)return;let i=Sd(this.easeName,e),r=!1,n=!1;for(let o of Object.keys(this.to)){let s=this.from[o],a=this.to[o];if(Oy.has(o)&&typeof s=="number"&&typeof a=="number")this.object[o]=xd(s,a,i);else if(typeof s=="number"&&typeof a=="number"){let l=s+(a-s)*i;this.object[o]=Ny.has(o)?Math.trunc(l):l}else this.object[o]=i>=1?a:s;r=!0,So.has(o)&&(n=!0)}r&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(n)}_advance(e,i){this.elapsed+=e;let r=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);return this.apply(r),r<1?!1:i>=0&&this.loopIndex+1>=i?!0:(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.elapsed=0,this.restoreInitial(),!1)}step(e){!this.playing||this.paused||this.killed||this._advance(e,this.loops<0?-1:this.loopCount)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0))}finish(e){this.playing=!1,this.killed=!0,e&&(this.completed=!0),this.runtime.tweens.delete(this),this.runtime.animations.delete(this),e&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},_r=class{constructor(e){this.runtime=e,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.dead=!1,this.completed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._entries=null}Append(e){return this.steps.push({kind:"tween",tween:e,parallel:!1}),this}AppendInterval(e){return this.steps.push({kind:"interval",duration:e}),this}AppendCallback(e){return this.steps.push({kind:"callback",fn:e}),this}Join(e){return this.steps.push({kind:"tween",tween:e,parallel:!0}),this}Insert(e,i){return this.steps.push({kind:"insert",time:e,tween:i}),this}InsertCallback(e,i){return this.steps.push({kind:"insertCb",time:e,fn:i}),this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._play()}_play(){return this.playing=!0,this.paused=!1,this.killed=!1,this.completed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this.runtime.sequences.add(this),this.runtime.animations.add(this),this}_schedule(){let e=0,i=0,r=!1,n=[],o=s=>s.duration*s.loopCount;for(let s of this.steps)if(s.kind==="tween"&&s.parallel){let a=r?i:e;n.push({at:a,tween:s.tween}),e=Math.max(e,a+o(s.tween))}else s.kind==="tween"?(n.push({at:e,tween:s.tween}),i=e,r=!0,e+=o(s.tween)):s.kind==="interval"?(i=e,r=!0,e+=s.duration):s.kind==="callback"?n.push({at:e,fn:s.fn}):s.kind==="insert"?(n.push({at:s.time,tween:s.tween}),e=Math.max(e,s.time+o(s.tween))):s.kind==="insertCb"&&(n.push({at:s.time,fn:s.fn}),e=Math.max(e,s.time));this._entries=n.map((s,a)=>({...s,index:a,end:s.tween?s.at+o(s.tween):s.at})),this._end=e,this._resetEntries()}_resetEntries(){for(let e of this._entries)e.started=!1,e.done=!1}_startChild(e){e.started=!0,e.tween._begin(!!e.tween.initialFrom)}_finishChild(e){e.done=!0,e.tween.apply(1),e.tween.onStepComplete&&this.runtime.safeCall(e.tween.onStepComplete),e.tween.finish(!0)}_advanceTo(e,i){let r=this._entries,n=[];for(let s of r)!s.started&&s.at<=e+$a&&n.push({at:s.at,rank:s.fn?1:2,entry:s}),s.tween&&!s.done&&s.end<=e+$a&&n.push({at:s.end,rank:0,entry:s});n.sort((s,a)=>s.at-a.at||s.rank-a.rank||s.entry.index-a.entry.index);let o=new Set;for(let{rank:s,entry:a}of n)if(s===1){if(a.started=!0,this.runtime.safeCall(a.fn),!this.playing||this.killed||this._entries!==r)return!1}else a.started||(this._startChild(a),o.add(a)),s===0&&!a.done&&this._finishChild(a);for(let s of r)!s.tween||!s.started||s.done||(o.has(s)?s.tween._advance(e-s.at,s.tween.loopCount):s.tween._advance(i,s.tween.loopCount));return!0}step(e){!this.playing||this.paused||this.killed||(this.elapsed+=e,this._advanceTo(this.elapsed,e)&&(this.elapsed+$a<this._end||(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._resetEntries()):this.finish(!0))))}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){this.dead||this._play()}Complete(){this.dead||this.completed||(this._entries||this._schedule(),this.playing=!0,this.killed=!1,this._advanceTo(1/0,0)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0)))}Kill(e){e?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(e){return this.onComplete=e,this}SetOnStepComplete(e){return this.onStepComplete=e,this}SetLoops(e){return this.loops=e,this}finish(e){this.playing=!1,this.killed=!0,e&&(this.completed=!0),this.runtime.sequences.delete(this),this.runtime.animations.delete(this),e&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var Io={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"]},My=[...Array.from({length:43},(t,e)=>`CraftspersonKey${e+1}`),"MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","None"],Fy=[...Array.from({length:14},(t,e)=>`CraftspersonKey${e+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function Dy(){let t=[];for(let e of["Down","Up"]){for(let i=1;i<=43;i++)t.push(`KeyboardCraftspersonKey${i}${e}`);for(let i of["MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key"])t.push(`Keyboard${i}${e}`);for(let i=1;i<=14;i++)t.push(`ControllerCraftspersonKey${i}${e}`);for(let i of["SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey"])t.push(`Controller${i}${e}`)}return t}Io.KeyboardKeyCode=My;Io.ControllerKeyCode=Fy;Io.KeyEventType=Dy();var _d=new Map;function Li(t,e){let i=`${t}\0${e}`,r=_d.get(i);return r||(r={__kind:"EnumItem",Name:e,FullName:`Enum.${t}.${e}`,EnumType:t},_d.set(i,r)),r}function La(t,e){return e==null?e:e.__kind==="EnumItem"?Li(e.EnumType||t,e.Name):typeof e=="string"&&e?Li(t,e):e}function Ga(){let t={};for(let[e,i]of Object.entries(Io)){let r={};for(let n of i)r[n]=Li(e,n);t[e]=r}return t}var zy=new Set(["Id","prefabIndex","imageId","fontSize","minimumFontSize","clickAudioId","itemCount","itemPrefabIndex","animationId","referencedPrefabIndex"]),$y=new Set(["imageColor","fontColor","bgColor","outlineColor"]),Id={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",imageType:"ImageType",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},Gi=p.LUA_REGISTRYINDEX,Ed=p.LUA_MULTRET,Ly=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 et(t){return t==null?"":typeof t=="string"?t:t.Name||t.FullName||String(t)}var Eo=class{constructor(e={}){this.canvasWidth=e.canvasWidth??1600,this.canvasHeight=e.canvasHeight??900,this.device=e.device??"KeyboardAndMouse",this.language=e.language??"LanguageChs",this.stageMode=e.stageMode??"Classic",this.testPlay=e.testPlay!==!1,this.canSelectImageType=e.canSelectImageType||(()=>!1),this.clock={time:0,levelTime:0,paused:!1,frame:0},this.logs=[],this.mountErrors=[],this.tweens=new Set,this.sequences=new Set,this.animations=new Set,this.audios=new Map,this.nextAudioId=1,this.audioDuration=e.audioDuration||(()=>null),this.audioHistory=[],this.audioWarnings=new Set,this.audioRevision=0,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=Ga(),this.luaStates=new Set,this.L=null}nextControlId(){let e=this._nextControlId;return this._nextControlId+=1,e}resolveScriptMappingId(e){let i=Number(e);if(Number.isSafeInteger(i)&&i>0)return this._nextScriptMappingId=Math.max(this._nextScriptMappingId,i+1),i;let r=this._nextScriptMappingId;return this._nextScriptMappingId+=1,r}pushPackedColor(e,i){let r=i>>>0;(r|0)===r?p.lua_pushinteger(e,r):p.lua_pushnumber(e,r)}retainLuaCallback(e){cd(e)}unrefLuaCallback(e){fd(this,e)}log(e,...i){let r=i.map(n=>n==null?"nil":typeof n=="object"&&n!==null&&n.__kind==="EnumItem"?n.Name:String(n)).join(" ");this.logs.push({level:e,text:r,time:this.clock.time})}safeCall(e,...i){try{return e(...i)}catch(r){this.log("lua-error",r&&r.message?r.message:String(r))}}scriptCanRun(e){if(!e?.alive||!e.enabled)return!1;let i=e.object;return!i||i.alive&&i.activeInHierarchy}cursorEventsEnabled(e){for(let i=e;i;i=i.parent)if(i.kind==="container"&&i.showCursor===!0)return!0;return!1}registerTemplate(e,i){this.templates.set(Number(e),i)}registerScriptFile(e,i){let r=this.normalizeRequirePath(e);this.scriptFiles.set(r,i),r.startsWith("default_import_file/")||this.requireAliases.set(`default_import_file/${r}`,r)}normalizeRequirePath(e){let i=String(e).replace(/\\/g,"/");return i.endsWith(".lua")&&(i=i.slice(0,-4)),i=i.replace(/\./g,"/"),i}addRoot(e){let i=e instanceof xi?e:new xi(this,e);return this.roots.push(i),Gt(i,r=>this.controlsById.set(r.Id,r)),this.mountSpecScripts(e,i),i}mountSpecScripts(e,i){if(e instanceof xi)return;let r=o=>(o.scripts?.length||0)>0||(o.children||[]).some(r);if(!e||!r(e))return;let n=this.lifecyclePhase;try{let o=(s,a)=>{for(let u of s.scripts||[])try{this.mountScript({path:u.path,source:u.source,control:a,scriptMappingId:u.scriptMappingId})}catch(c){let f=c&&c.message?c.message:String(c);this.mountErrors.push(f),this.log("lua-error",f)}let l=s.children||[];for(let u=0;u<l.length;u+=1)o(l[u],a?.children?.[u])};o(e,i)}finally{this.lifecyclePhase=n}}makeCursorEventData({x:e=0,y:i=0,pressX:r=e,pressY:n=i,deltaX:o=e-r,deltaY:s=i-n,dragging:a=!1,touchId:l=-1}={}){let u=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:a,touchId:l,x:e,y:i,pressX:r,pressY:n,GetUIPos(){return[e,i]},GetPressUIPos(){return[r,n]},GetUIPosDelta(){return[o,s]}}}boot(){let e=this.newLuaThread();this.L=e}installGlobals(e){let i=this;p.lua_pushcfunction(e,r=>{let n=p.lua_gettop(r),o=[];for(let s=1;s<=n;s++)o.push(Xe(r,i,s));return i.log("info",...o),0}),p.lua_setglobal(e,G("print")),p.lua_pushcfunction(e,r=>{let n=p.lua_gettop(r),o=[];for(let s=1;s<=n;s++)o.push(Xe(r,i,s));return i.log("error",...o),0}),p.lua_setglobal(e,G("printerr")),p.lua_pushcfunction(e,r=>{if(p.lua_type(r,1)===p.LUA_TTABLE&&!ti(r,1))return p.lua_pushstring(r,G("table")),1;let n=Xe(r,i,1);return p.lua_pushstring(r,G(i.typeofOf(n))),1}),p.lua_setglobal(e,G("typeof")),this.pushColorLib(e),this.pushEnumLib(e),this.pushGameLib(e),p.lua_pushcfunction(e,r=>i.luaRequire(r)),p.lua_setglobal(e,G("require"))}typeofOf(e){return e==null?"nil":e.__kind==="Script"?"Script":e.__kind==="EnumItem"?"EnumItem":e.__kind==="CursorEventData"?"CursorEventData":e.__kind==="ServerSignal"?"ServerSignal":e instanceof _r?"TweenSequence":e instanceof on?"Tween":e.typeofName?e.typeofName:typeof e=="number"?"number":typeof e=="string"?"string":typeof e=="boolean"?"boolean":typeof e}pushColorLib(e){p.lua_newtable(e),p.lua_pushcfunction(e,i=>(this.pushPackedColor(i,xr(p.lua_tonumber(i,1),p.lua_tonumber(i,2),p.lua_tonumber(i,3),255)),1)),p.lua_setfield(e,-2,G("FromRGB")),p.lua_pushcfunction(e,i=>{let r=p.lua_isnoneornil(i,4)?255:p.lua_tonumber(i,4);return this.pushPackedColor(i,xr(p.lua_tonumber(i,1),p.lua_tonumber(i,2),p.lua_tonumber(i,3),r)),1}),p.lua_setfield(e,-2,G("FromRGBA")),p.lua_pushcfunction(e,i=>{let r=p.lua_tonumber(i,1)>>>0;for(let n of nn(r))p.lua_pushinteger(i,n);return 4}),p.lua_setfield(e,-2,G("ToRGBA")),p.lua_newtable(e),p.lua_pushcfunction(e,i=>{let r=p.lua_tonumber(i,2),n=p.lua_tonumber(i,3),o=p.lua_tonumber(i,4),s=p.lua_isnoneornil(i,5)?255:p.lua_tonumber(i,5);return this.pushPackedColor(i,xr(r,n,o,s)),1}),p.lua_setfield(e,-2,G("__call")),p.lua_setmetatable(e,-2),p.lua_setglobal(e,G("Color"))}pushEnumLib(e){p.lua_newtable(e);for(let[i,r]of Object.entries(this.enumTree)){p.lua_newtable(e);for(let[n,o]of Object.entries(r))this.pushEnumItem(e,o),p.lua_setfield(e,-2,G(n));p.lua_setfield(e,-2,G(i))}p.lua_setglobal(e,G("Enum"))}pushEnumItem(e,i){let r=p.lua_newuserdata(e,0);$i(r,i),Ie.luaL_setmetatable(e,G("EnumItem"))}pushControl(e,i){let r=p.lua_newuserdata(e,0);$i(r,i),Ie.luaL_setmetatable(e,G("Control"))}pushScript(e,i){p.lua_newtable(e),p.lua_pushlightuserdata(e,Ma);let r=p.lua_newuserdata(e,0);$i(r,i),p.lua_rawset(e,-3),Ie.luaL_getmetatable(e,G("Script")),p.lua_setmetatable(e,-2)}pushTween(e,i){let r=p.lua_newuserdata(e,0);$i(r,i);let n=i instanceof _r?"TweenSequence":"Tween";Ie.luaL_setmetatable(e,G(n))}pushSignal(e,i){let r=p.lua_newuserdata(e,0);$i(r,i),Ie.luaL_setmetatable(e,G("ServerSignal"))}pushCursor(e,i){let r=p.lua_newuserdata(e,0);$i(r,i),Ie.luaL_setmetatable(e,G("CursorEventData"))}pushGameLib(e){let i=this;p.lua_newtable(e);let r={InstantiateClientUIControl:n=>{let o=p.lua_tointeger(n,1),s=lt(p.lua_touserdata(n,2)),a=i.instantiate(o,s,i.lifecyclePhase);return a?(i.pushControl(n,a),1):(p.lua_pushnil(n),1)},DestroyClientUIControl:n=>{let o=lt(p.lua_touserdata(n,1));return o&&i.destroyControl(o),0},GetClientUIControl:n=>{let o=p.lua_tointeger(n,1),s=i.controlsById.get(o);return s?i.pushControl(n,s):p.lua_pushnil(n),1},FindClientUIRoot:n=>{let o=Ce(n,1),s=i.roots.find(a=>a.name===o);return s?i.pushControl(n,s):p.lua_pushnil(n),1},GetClientUIRoots:n=>(p.lua_createtable(n,i.roots.length,0),i.roots.forEach((o,s)=>{i.pushControl(n,o),p.lua_rawseti(n,-2,s+1)}),1),GetUICanvasSize:n=>(p.lua_pushnumber(n,i.canvasWidth),p.lua_pushnumber(n,i.canvasHeight),2),GetCursorUIPos:n=>(p.lua_pushnumber(n,i.cursor.x),p.lua_pushnumber(n,i.cursor.y),2),GetDevice:n=>(i.pushEnumItem(n,Li("Device",i.device)),1),SetControllerFocus:n=>(i.focus=lt(p.lua_touserdata(n,1)),0),GetControllerFocus:n=>(i.focus?i.pushControl(n,i.focus):p.lua_pushnil(n),1),GetControllerLeftStickAxis:n=>(p.lua_pushnumber(n,i.stick.left[0]),p.lua_pushnumber(n,i.stick.left[1]),2),GetControllerRightStickAxis:n=>(p.lua_pushnumber(n,i.stick.right[0]),p.lua_pushnumber(n,i.stick.right[1]),2),Tween:n=>{let o=lt(p.lua_touserdata(n,1))||Xe(n,i,1),s=Xe(n,i,2)||{},a=p.lua_tonumber(n,3),l=new on(i,o,s,a);return i.pushTween(n,l),1},TweenSequence:n=>(i.pushTween(n,new _r(i)),1),ServerSignal:n=>{let o=Ce(n,1);return i.pushSignal(n,i.makeServerSignal(o)),1},GetGlobalCustomVariableValue:n=>{let o=et(Xe(n,i,1)),s=Ce(n,2);return Le(n,i,i.getVar(o,s)),1},PauseLevelTime:n=>(i.clock.paused=!!p.lua_toboolean(n,1),0),IsLevelTimePaused:n=>(p.lua_pushboolean(n,i.clock.paused),1),PlayAudio2D:n=>{let o=i.playAudio(i.audioInteger(n));return p.lua_pushinteger(n,o),1},StopAudio:n=>(i.stopAudio(i.audioInteger(n)),0),IsAudioAlive:n=>{let o=i.audios.get(i.audioInteger(n));return p.lua_pushboolean(n,!!(o&&o.alive)),1},GetLanguageType:n=>(i.pushEnumItem(n,Li("LanguageType",i.language)),1),GetStageMode:n=>(i.pushEnumItem(n,Li("StageMode",i.stageMode)),1),IsTestPlay:n=>(p.lua_pushboolean(n,i.testPlay),1),GetText:n=>{let o=Ce(n,1);return p.lua_pushstring(n,G(o)),1},PrintClientUITree:n=>{for(let o of i.roots)i.log("info",za(o).join(`
|
|
121
|
+
`));return 0}};for(let[n,o]of Object.entries(r)){let s=Ly[n];if(s===void 0)throw new Error(`missing game arity for ${n}`);p.lua_pushcfunction(e,a=>{let l=p.lua_gettop(a);return l!==s?Ie.luaL_error(a,G(`bad argument count to '${n}' (${s} expected, got ${l})`)):o(a)}),p.lua_setfield(e,-2,G(n))}p.lua_setglobal(e,G("game"))}makeServerSignal(e){let i=[],r=this;return{__kind:"ServerSignal",name:e,AddParam(n,o){i.push({type:et(n),value:o})},AddInt(n){i.push({type:"Int",value:n})},AddIntList(n){i.push({type:"IntList",value:n})},AddFloat(n){i.push({type:"Float",value:n})},AddFloatList(n){i.push({type:"FloatList",value:n})},AddString(n){i.push({type:"String",value:n})},AddStringList(n){i.push({type:"StringList",value:n})},AddVector3(n){i.push({type:"Vector3",value:n})},AddVector3List(n){i.push({type:"Vector3List",value:n})},AddBool(n){i.push({type:"Bool",value:n})},AddBoolList(n){i.push({type:"BoolList",value:n})},AddGuid(n){i.push({type:"Guid",value:n})},AddGuidList(n){i.push({type:"GuidList",value:n})},AddEntity(n){i.push({type:"Entity",value:n})},AddEntityList(n){i.push({type:"EntityList",value:n})},AddPrefabId(n){i.push({type:"PrefabId",value:n})},AddPrefabIdList(n){i.push({type:"PrefabIdList",value:n})},AddConfigId(n){i.push({type:"ConfigId",value:n})},AddConfigIdList(n){i.push({type:"ConfigIdList",value:n})},SendSignal(){let n=i.slice();r.serverBridge&&typeof r.serverBridge.receiveFromClient=="function"&&r.serverBridge.receiveFromClient(e,n)}}}audioInteger(e){let i=p.lua_tonumber(e,1);return p.lua_type(e,1)!==p.LUA_TNUMBER||!Number.isSafeInteger(i)?Ie.luaL_error(e,G("audio argument must be an integer")):i}playAudio(e){this.audioRevision++;let i=this.nextAudioId++,r=this.audioDuration(e),n=Number.isFinite(r)&&r>0,o={instanceId:i,audioId:e,startedAt:this.clock.time,duration:n?r:0,alive:n,stopped:!1};return this.audioHistory.push(o),this.audioHistory.length>128&&this.audioHistory.shift(),n?(this.audios.size>=128&&this.stopAudio(this.audios.keys().next().value),this.audios.set(i,o)):this.audioWarnings.has(e)||(this.audioWarnings.size>=128&&this.audioWarnings.delete(this.audioWarnings.values().next().value),this.audioWarnings.add(e),this.log("warn",`\u97F3\u6548 ${e} \u672A\u5217\u5165\u6A21\u62DF\u5668\u97F3\u9891\u767D\u540D\u5355`)),i}stopAudio(e){let i=this.audios.get(e)||this.audioHistory.find(r=>r.instanceId===e);i&&!i.stopped&&(i.alive=!1,i.stopped=!0,this.audioRevision++),this.audios.delete(e)}audioSnapshot(){return{sequence:this.nextAudioId-1,revision:this.audioRevision,active:[...this.audios.values()].map(e=>({...e})),recent:this.audioHistory.map(e=>({...e}))}}instantiate(e,i,r){if(r==="OnInit"||r==="OnDestroy")return null;let n=this.templates.get(Number(e));if(!n||!i)return null;let o=new xi(this,{...n,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(e)});return i.addChild(o),o.SetAsLastSibling(),Gt(o,s=>this.controlsById.set(s.Id,s)),this.mountSpecScripts(n,o),o}destroyControl(e){if(!(!e||!e.alive)){if(e._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:${e.name}`);Gt(e,i=>{i._destroying=!0}),this._destroyControlTree(e)}}_destroyControlTree(e){this.releaseControlListeners(e);for(let i of e.scripts.slice())this.unmountScript(i);for(let i of e.children.slice())this._destroyControlTree(i);if(e.alive=!1,this.scrollControls?.delete(e),this._playRemoved.push(e.Id),e.parent){let i=e.parent,r=i.children.indexOf(e);r>=0&&i.children.splice(r,1),e._parent=null,i.markPlayDirty(!0)}else{let i=this.roots.indexOf(e);i>=0&&this.roots.splice(i,1)}this.controlsById.delete(e.Id),this.focus===e&&(this.focus=null);for(let i of[...this.tweens])i.object===e&&i.Kill(!1)}releaseControlListeners(e){for(let i of e.cursorListeners.values())for(let r of i)this.unrefLuaCallback(r);for(let i of e.keyListeners.values())for(let r of i)this.unrefLuaCallback(r);for(let i of e.navListeners.values())for(let r of i)this.unrefLuaCallback(r);e.cursorListeners.clear(),e.keyListeners.clear(),e.navListeners.clear(),e.navConfig.clear()}onControlActiveChanging(e,i){let r=[];Gt(e,n=>r.push({control:n,was:n.activeInHierarchy})),e.active=!!i,e.markPlayDirty(!0);for(let n of r){let o=n.control.activeInHierarchy;if(n.was!==o)for(let s of n.control.scripts.slice())o?this.enableScript(s):this.disableScript(s)}}bindScriptEnv(e){let i=e.env;return i?(this.pushScript(i,e),p.lua_setglobal(i,G("script")),i):null}disableScript(e){if(!e?.alive||!e.env||e.lifecyclePhase!=="running")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnDisable",e.lifecyclePhase="OnDisable",this.bindScriptEnv(e),this.callGlobal(e.env,"OnDisable"),e.lifecyclePhase="disabled",this.lifecyclePhase=i}enableScript(e){if(!e?.alive||!e.env||e.lifecyclePhase!=="disabled")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnEnable",e.lifecyclePhase="OnEnable",this.bindScriptEnv(e),this.callGlobal(e.env,"OnEnable"),e.lifecyclePhase="running",this.lifecyclePhase=i}unmountScript(e){if(!e||!e.alive)return;let i=e.env,r=this.lifecyclePhase;i&&(e.lifecyclePhase==="running"&&(this.lifecyclePhase="OnDisable",e.lifecyclePhase="OnDisable",this.bindScriptEnv(e),this.callGlobal(i,"OnDisable")),this.lifecyclePhase="OnDestroy",e.lifecyclePhase="OnDestroy",this.bindScriptEnv(e),this.callGlobal(i,"OnDestroy")),e.alive=!1,e.lifecyclePhase="destroyed",this.lifecyclePhase=r,this.mountedScripts=this.mountedScripts.filter(n=>n!==e),e.object&&(e.object.scripts=e.object.scripts.filter(n=>n!==e)),this.varHandlers=this.varHandlers.filter(n=>n.script!==e),this.signalHandlers=this.signalHandlers.filter(n=>n.script!==e),i&&i!==this.L&&this.closeTrackedLuaState(i),e.env=null}installMetatables(e){this.mtEnum(e),this.mtControl(e),this.mtScript(e),this.mtTween(e),this.mtSeq(e),this.mtSignal(e),this.mtCursor(e)}mtIndexNewindex(e,i,r,n,o,s){Ie.luaL_newmetatable(e,G(i)),p.lua_pushcfunction(e,a=>{let l=ti(a,1)||lt(p.lua_touserdata(a,1)),u=Ce(a,2);if(o[u]&&(!s||s(l,u)))return p.lua_pushcfunction(a,o[u]),1;let c;try{c=r(l,u)}catch(f){return Ie.luaL_error(a,G(String(f.message||f)))}return c===void 0?(p.lua_pushnil(a),1):(Le(a,this,c),1)}),p.lua_setfield(e,-2,G("__index")),p.lua_pushcfunction(e,a=>{try{let l=ti(a,1)||lt(p.lua_touserdata(a,1)),u=Ce(a,2),c=Xe(a,this,3);return n(l,u,c),0}catch(l){return p.lua_pushstring(a,G(String(l.message||l))),p.lua_error(a)}}),p.lua_setfield(e,-2,G("__newindex")),p.lua_pushcfunction(e,a=>{let l=ti(a,1)||lt(p.lua_touserdata(a,1)),u=ti(a,2)||lt(p.lua_touserdata(a,2));return p.lua_pushboolean(a,l===u),1}),p.lua_setfield(e,-2,G("__eq")),p.lua_pop(e,1)}method(e){let i=this;return r=>{let n=ti(r,1)||lt(p.lua_touserdata(r,1)),o=p.lua_gettop(r),s=[];for(let a=2;a<=o;a++)s.push(Xe(r,i,a));try{let a=e(n,...s);if(a===n)return p.lua_pushvalue(r,1),1;if(a===void 0)return 0;if(Array.isArray(a)&&a.__multi){for(let l of a)Le(r,i,l);return a.length}if(Array.isArray(a)&&!(a.length&&typeof a[0]=="object"&&a[0]?.typeofName)){if(a.__controls)return p.lua_createtable(r,a.length,0),a.forEach((l,u)=>{i.pushControl(r,l),p.lua_rawseti(r,-2,u+1)}),1;if(a.__scripts)return p.lua_createtable(r,a.length,0),a.forEach((l,u)=>{i.pushScript(r,l),p.lua_rawseti(r,-2,u+1)}),1;if(typeof a[0]=="number"&&a.length<=4){for(let l of a)p.lua_pushnumber(r,l);return a.length}}return Le(r,i,a),1}catch(a){return p.lua_pushstring(r,G(String(a.message||a))),p.lua_error(r)}}}mtEnum(e){let i=new Set(["Name","FullName","EnumType"]);this.mtIndexNewindex(e,"EnumItem",(r,n)=>i.has(n)?r[n]:void 0,(r,n)=>{throw new Error(`cannot set ${n}, no such field`)},{})}mtCursor(e){let i=new Set(["dragging","touchId"]);this.mtIndexNewindex(e,"CursorEventData",(r,n)=>i.has(n)?r[n]:void 0,(r,n)=>{throw new Error(`cannot set ${n}, no such field`)},{GetUIPos:this.method(r=>r.GetUIPos()),GetPressUIPos:this.method(r=>r.GetPressUIPos()),GetUIPosDelta:this.method(r=>r.GetUIPosDelta())})}mtControl(e){let i=this.method((n,o)=>n.SetVisible(o)),r={GetChildren:this.method(n=>{let o=n.GetChildren();return o.__controls=!0,o}),GetChild:this.method((n,o)=>n.GetChild(o)),FindChild:this.method((n,o)=>n.FindChild(o)),SetActive:this.method((n,o)=>n.SetActive(o)),SetVisible:n=>p.lua_isboolean(n,2)?i(n):Ie.luaL_error(n,G("bad argument #2 to 'SetVisible' (boolean expected, got %s)"),Ie.luaL_typename(n,2)),GetSiblingIndex:this.method(n=>n.GetSiblingIndex()),SetSiblingIndex:this.method((n,o)=>n.SetSiblingIndex(o)),SetAsFirstSibling:this.method(n=>n.SetAsFirstSibling()),SetAsLastSibling:this.method(n=>n.SetAsLastSibling()),GetAnchoredPosition:this.method(n=>n.GetAnchoredPosition()),SetAnchoredPosition:this.method((n,o,s)=>n.SetAnchoredPosition(o,s)),GetSizeDelta:this.method(n=>n.GetSizeDelta()),SetSizeDelta:this.method((n,o,s)=>n.SetSizeDelta(o,s)),GetAnchorMin:this.method(n=>n.GetAnchorMin()),SetAnchorMin:this.method((n,o,s)=>n.SetAnchorMin(o,s)),GetAnchorMax:this.method(n=>n.GetAnchorMax()),SetAnchorMax:this.method((n,o,s)=>n.SetAnchorMax(o,s)),GetPivot:this.method(n=>n.GetPivot()),SetPivot:this.method((n,o,s)=>n.SetPivot(o,s)),GetLocalScale:this.method(n=>n.GetLocalScale()),SetLocalScale:this.method((n,o,s,a)=>n.SetLocalScale(o,s,a)),GetLocalRotation:this.method(n=>n.GetLocalRotation()),SetLocalRotation:this.method((n,o,s,a)=>n.SetLocalRotation(o,s,a)),GetScriptByPath:this.method((n,o)=>n.GetScriptByPath(o)),GetScript:this.method((n,o)=>n.GetScript(o)),GetScripts:this.method(n=>{let o=n.GetScripts();return o.__scripts=!0,o}),AddCursorEventListener:this.method((n,o,s)=>n.AddCursorEventListener(et(o),s)),RemoveCursorEventListener:this.method((n,o,s)=>n.RemoveCursorEventListener(et(o),s)),RemoveCursorEventListeners:this.method((n,o)=>n.RemoveCursorEventListeners(et(o))),RemoveAllCursorEventListeners:this.method(n=>n.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(n=>n.SimulateCursorClick()),AddKeyEventListener:this.method((n,o,s)=>n.AddKeyEventListener(et(o),s)),RemoveKeyEventListener:this.method((n,o,s)=>n.RemoveKeyEventListener(et(o),s)),RemoveKeyEventListeners:this.method((n,o)=>n.RemoveKeyEventListeners(et(o))),RemoveAllKeyEventListeners:this.method(n=>n.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((n,o,s)=>n.AddNavigationEventListener(et(o),s)),RemoveNavigationEventListener:this.method((n,o,s)=>n.RemoveNavigationEventListener(et(o),s)),RemoveNavigationEventListeners:this.method((n,o)=>n.RemoveNavigationEventListeners(et(o))),RemoveAllNavigationEventListeners:this.method(n=>n.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((n,o,s,a)=>n.SetControllerNavigation(et(o),s,a)),GetControllerNavigation:this.method((n,o)=>n.GetControllerNavigation(et(o))),SetImage:this.method((n,o,s)=>n.SetImage(o,s)),SetSoftEdgeWidth:this.method((n,o,s)=>n.SetSoftEdgeWidth(o,s)),SetFillUnused:this.method(n=>n.SetFillUnused()),SetFillHorizontal:this.method((n,o,s)=>n.SetFillHorizontal(o,s)),SetFillVertical:this.method((n,o,s)=>n.SetFillVertical(o,s)),SetFillRadial90:this.method((n,o,s)=>n.SetFillRadial90(o,s)),SetFillRadial180:this.method((n,o,s)=>n.SetFillRadial180(o,s)),SetFillRadial360:this.method((n,o,s)=>n.SetFillRadial360(o,s)),PlayAnimation:this.method(n=>n.PlayAnimation()),StopAnimation:this.method(n=>n.StopAnimation()),RefreshItems:this.method((n,o,s)=>{this.retainLuaCallback(s);try{n.RefreshItems(o,s)}finally{this.unrefLuaCallback(s)}}),GetItemIndex:this.method((n,o)=>n.GetItemIndex(o)),GetItemSize:this.method(n=>n.GetItemSize()),GetItemSpacing:this.method(n=>n.GetItemSpacing()),GetPadding:this.method(n=>n.GetPadding()),ScrollToItemAt:this.method((n,o,s)=>n.ScrollToItemAt(o,s)),GetContentLength:this.method(n=>n.GetContentLength())};this.mtIndexNewindex(e,"Control",(n,o)=>{if(!Da(n,o))return;if(!n.alive&&o!=="alive")throw new Error(`attempt to read '${o}' of a destroyed control`);let s=n.luaFieldValue(o),a=Id[o];return a?La(a,s):typeof s=="number"&&!zy.has(o)&&!$y.has(o)?new en(s):s},(n,o,s)=>{if(Da(n,o)==="rw"){if((o==="fontSize"||o==="minimumFontSize")&&!Number.isInteger(s)){let u=s===null?"nil":typeof s;throw new Error(`bad argument #2 to '${o}' (integer expected, got ${u})`)}let l=Id[o];if(o==="imageType"&&(s?.EnumType!=="ImageType"||!["Basic","Stretch"].includes(s.Name)))throw new Error("imageType requires Enum.ImageType.Basic or Stretch");n[o]=l?La(l,s):s,typeof n.markPlayDirty=="function"&&n.markPlayDirty(So.has(o));return}throw new Error(`cannot set ${o}, no such field`)},r,bd)}mtScript(e){let i=this,r=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(e,"Script",(n,o)=>r.has(o)?n[o]:void 0,(n,o,s)=>{if(o==="enabled"){n.enabled=!!s;return}throw new Error(`cannot set ${o}, no such field`)},{GetParam:this.method((n,o)=>Object.prototype.hasOwnProperty.call(n.params,o)?n.params[o]:null),Invoke:n=>i.luaInvoke(n),EnableUpdate:this.method((n,o)=>{n.updateEnabled=!!o}),RegisterServerSignalHandler:this.method((n,o,s)=>{i.signalHandlers.push({script:n,name:o,fn:s})}),UnregisterServerSignalHandler:this.method((n,o)=>{i.signalHandlers=i.signalHandlers.filter(s=>!(s.script===n&&s.name===o))}),RegisterCustomVariableChangedHandler:this.method((n,o,s,a)=>{i.varHandlers.push({script:n,entityType:et(o),name:s,fn:a})}),UnregisterCustomVariableChangedHandler:this.method((n,o,s)=>{let a=et(o);i.varHandlers=i.varHandlers.filter(l=>!(l.script===n&&l.entityType===a&&l.name===s))})})}mtTween(e){this.mtIndexNewindex(e,"Tween",()=>{},()=>{},{SetEase:this.method((i,r)=>i.SetEase(r)),SetRelative:this.method((i,r)=>i.SetRelative(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,r)=>i.Kill(r)),SetOnComplete:this.method((i,r)=>i.SetOnComplete(r)),SetOnStepComplete:this.method((i,r)=>i.SetOnStepComplete(r)),SetLoops:this.method((i,r)=>i.SetLoops(r))})}mtSeq(e){this.mtIndexNewindex(e,"TweenSequence",()=>{},()=>{},{Append:this.method((i,r)=>i.Append(r)),AppendInterval:this.method((i,r)=>i.AppendInterval(r)),AppendCallback:this.method((i,r)=>i.AppendCallback(r)),Join:this.method((i,r)=>i.Join(r)),Insert:this.method((i,r,n)=>i.Insert(r,n)),InsertCallback:this.method((i,r,n)=>i.InsertCallback(r,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,r)=>i.Kill(r)),SetOnComplete:this.method((i,r)=>i.SetOnComplete(r)),SetOnStepComplete:this.method((i,r)=>i.SetOnStepComplete(r)),SetLoops:this.method((i,r)=>i.SetLoops(r))})}mtSignal(e){this.mtIndexNewindex(e,"ServerSignal",()=>{},()=>{},{AddParam:this.method((i,r,n)=>i.AddParam(r,n)),SendSignal:this.method(i=>i.SendSignal()),AddInt:this.method((i,r)=>i.AddInt(r)),AddIntList:this.method((i,r)=>i.AddIntList(r)),AddFloat:this.method((i,r)=>i.AddFloat(r)),AddFloatList:this.method((i,r)=>i.AddFloatList(r)),AddString:this.method((i,r)=>i.AddString(r)),AddStringList:this.method((i,r)=>i.AddStringList(r)),AddVector3:this.method((i,r)=>i.AddVector3(r)),AddVector3List:this.method((i,r)=>i.AddVector3List(r)),AddBool:this.method((i,r)=>i.AddBool(r)),AddBoolList:this.method((i,r)=>i.AddBoolList(r)),AddGuid:this.method((i,r)=>i.AddGuid(r)),AddGuidList:this.method((i,r)=>i.AddGuidList(r)),AddEntity:this.method((i,r)=>i.AddEntity(r)),AddEntityList:this.method((i,r)=>i.AddEntityList(r)),AddPrefabId:this.method((i,r)=>i.AddPrefabId(r)),AddPrefabIdList:this.method((i,r)=>i.AddPrefabIdList(r)),AddConfigId:this.method((i,r)=>i.AddConfigId(r)),AddConfigIdList:this.method((i,r)=>i.AddConfigIdList(r))})}luaRequire(e){let i=Ce(e,1),r=this.normalizeRequirePath(i),n=this.requireAliases.get(r)||r;p.lua_rawgeti(e,Gi,p.LUA_RIDX_MAINTHREAD);let o=p.lua_tothread(e,-1);p.lua_pop(e,1);let s=this.requireCache.get(o);s||(s=new Map,this.requireCache.set(o,s));let a=s.get(n);if(a?.loading)return p.lua_pushstring(e,G(`failed to load script '${r}': cyclic require`)),p.lua_error(e);if(a&&a.ref!=null)return p.lua_rawgeti(e,Gi,a.ref),1;let l=this.scriptFiles.get(n);if(l==null)return p.lua_pushstring(e,G(`failed to load script '${r}'`)),p.lua_error(e);let u=p.lua_gettop(e);s.set(n,{loading:!0});try{this.loadModule(e,o,n,l),p.lua_pushvalue(e,-1);let c=Ie.luaL_ref(e,Gi);return s.set(n,{ref:c}),1}catch(c){return s.delete(n),p.lua_settop(e,u),p.lua_pushstring(e,G(`failed to load script '${r}': ${c.message||c}`)),p.lua_error(e)}}newLuaThread(){let e=Ie.luaL_newstate();return ad.luaL_openlibs(e),hd(e),this.installMetatables(e),this.installGlobals(e),this.luaStates.add(e),p.lua_pushglobaltable(e),this.copyLuaEnvironment(e,-1),p.lua_remove(e,-2),this.moduleBaseEnvironments.set(e,Ie.luaL_ref(e,Gi)),e}copyLuaEnvironment(e,i){let r=p.lua_absindex(e,i);p.lua_newtable(e);let n=p.lua_absindex(e,-1);for(p.lua_pushnil(e);p.lua_next(e,r)!==0;)p.lua_pushvalue(e,-2),p.lua_pushvalue(e,-2),p.lua_rawset(e,n),p.lua_pop(e,1);p.lua_pushvalue(e,n),p.lua_setfield(e,n,G("_G"))}closeTrackedLuaState(e){if(!e||!this.luaStates.has(e))return;for(let r of this.requireCache.get(e)?.values()||[])r.ref!=null&&Ie.luaL_unref(e,Gi,r.ref);this.requireCache.delete(e);let i=this.moduleBaseEnvironments.get(e);if(i!=null&&Ie.luaL_unref(e,Gi,i),this.moduleBaseEnvironments.delete(e),this.luaStates.delete(e),this.luaFunctions)for(let[r,n]of this.luaFunctions)n.__luaState===e&&this.luaFunctions.delete(r);dd(e)}loadModule(e,i,r,n){let o={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:r,enabled:!0,updateEnabled:!1,params:{},env:e,invoke(){}},s=String(n).replace(/^\uFEFF/,""),a=bo(s);if(Ie.luaL_loadbuffer(e,a,a.length,G(`@${r}`))!==kt)throw new Error(Ce(e,-1));let u=p.lua_absindex(e,-1);if(p.lua_rawgeti(e,Gi,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(e,-1),p.lua_remove(e,-2),this.pushScript(e,o),p.lua_setfield(e,-2,G("script")),p.lua_setupvalue(e,u,1),p.lua_pcall(e,0,1,0)!==kt)throw new Error(Ce(e,-1))}mountScript({path:e,source:i,control:r,params:n={},scriptMappingId:o=void 0}){this.L||this.boot();let s=this.newLuaThread(),a={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(o),object:r,path:this.normalizeRequirePath(e),enabled:!0,updateEnabled:!1,params:n,env:s,lifecyclePhase:"idle"};a.invoke=(u,c)=>this.invokeOn(s,u,c),r&&r.scripts.push(a),this.mountedScripts.push(a),this.pushScript(s,a),p.lua_setglobal(s,G("script"));let l=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",a.lifecyclePhase="OnInit",this.runChunk(s,i,e);let u=this.callGlobal(s,"OnInit");u&&this.mountErrors.push(u),this.lifecyclePhase="OnEnable",a.lifecyclePhase="OnEnable";let c=this.callGlobal(s,"OnEnable");c&&this.mountErrors.push(c),this.lifecyclePhase="OnStart",a.lifecyclePhase="OnStart";let f=this.callGlobal(s,"OnStart");return f&&this.mountErrors.push(f),this.lifecyclePhase="running",a.lifecyclePhase="running",a}catch(u){throw a.alive=!1,a.lifecyclePhase="failed",this.mountedScripts=this.mountedScripts.filter(c=>c!==a),r&&(r.scripts=r.scripts.filter(c=>c!==a)),this.varHandlers=this.varHandlers.filter(c=>c.script!==a),this.signalHandlers=this.signalHandlers.filter(c=>c.script!==a),this.lifecyclePhase=l,s&&s!==this.L&&this.closeTrackedLuaState(s),a.env=null,u}}runChunk(e,i,r){let n=String(i).replace(/^\uFEFF/,""),o=bo(n),s=Ie.luaL_loadbuffer(e,o,o.length,G(`@${r}`));if(s!==kt){let l=Ce(e,-1)||`luaL_loadbuffer status ${s}`;throw p.lua_pop(e,1),new Error(l)}let a=p.lua_pcall(e,0,0,0);if(a!==kt){let l=Ce(e,-1)||`lua_pcall status ${a}`;throw p.lua_pop(e,1),new Error(l)}}callGlobal(e,i){if(p.lua_getglobal(e,G(i)),p.lua_isfunction(e,-1)){if(p.lua_pcall(e,0,0,0)!==kt){let n=Ce(e,-1);p.lua_pop(e,1);let o=`${i}: ${n}`;return this.log("lua-error",o),o}}else p.lua_pop(e,1);return null}callGlobalDt(e,i,r){if(p.lua_getglobal(e,G(i)),p.lua_isfunction(e,-1)){if(p.lua_pushnumber(e,r),p.lua_pcall(e,1,0,0)!==kt){let o=Ce(e,-1);p.lua_pop(e,1),this.log("lua-error",`${i}: ${o}`)}}else p.lua_pop(e,1)}luaInvoke(e){let i=ti(e,1);if(!i||i.__kind!=="Script")return Ie.luaL_error(e,G("bad self to 'Invoke' (Script expected)"));let r=Ce(e,2),n=i.env;if(!n||n.l_G!==e.l_G){let l=[];for(let f=3;f<=p.lua_gettop(e);f++)l.push(Xe(e,this,f));let u;try{u=i.invoke(r,l)}catch(f){return Ie.luaL_error(e,G(String(f.message||f)))}if(u===void 0)return 0;let c=Array.isArray(u)&&u.__multi?u:[u];for(let f of c)Le(e,this,f);return c.length}let o=2;if(p.lua_getglobal(e,G(r)),!p.lua_isfunction(e,-1))return 0;p.lua_replace(e,o),p.lua_remove(e,1);let s=p.lua_gettop(e)-1;return p.lua_pcall(e,s,Ed,0)!==kt?p.lua_error(e):p.lua_gettop(e)}invokeOn(e,i,r){let n=p.lua_gettop(e);if(p.lua_getglobal(e,G(i)),!p.lua_isfunction(e,-1)){p.lua_settop(e,n);return}for(let l of r)Le(e,this,l);if(p.lua_pcall(e,r.length,Ed,0)!==kt){let l=Ce(e,-1);throw p.lua_settop(e,n),new Error(l)}let s=p.lua_gettop(e)-n;if(s<=0){p.lua_settop(e,n);return}if(s===1){let l=Xe(e,this,-1);return p.lua_settop(e,n),l}let a=[];for(let l=1;l<=s;l++)a.push(Xe(e,this,n+l));return p.lua_settop(e,n),a.__multi=!0,a}runScriptPhase(e,i){for(let r of this.mountedScripts){if(!this.scriptCanRun(r))continue;let n=r.env;n&&(this.pushScript(n,r),p.lua_setglobal(n,G("script")),!(e==="OnUpdate"&&!r.updateEnabled)&&this.callGlobalDt(n,e,i))}}step(e=1/30){if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError("dt must be a finite non-negative number");this.clock.frame++,this.clock.time+=e;for(let[r,n]of this.audios)this.clock.time+1e-9>=n.startedAt+n.duration&&(n.alive=!1,this.audios.delete(r),this.audioRevision++);let i=!this.clock.paused;for(let r of[...this.animations])r.step(e);this.runScriptPhase("OnUpdate",e),i&&(this.clock.levelTime+=e,this.runScriptPhase("OnLevelUpdate",e))}injectKey(e){let i=r=>{if(!r.alive||!r.activeInHierarchy)return!1;if(r.keyListeners.has(e)&&r.emitKey(e))return!0;for(let n of[...r.children])if(i(n))return!0;return!1};for(let r of[...this.roots])i(r)}injectCursor(e,i,r){let n=r||this.makeCursorEventData({});Number.isFinite(n.x)&&Number.isFinite(n.y)&&(this.cursor.x=n.x,this.cursor.y=n.y),e.emitCursor(i,n)}getVar(e,i){if(this.serverBridge&&typeof this.serverBridge.getVar=="function")return this.serverBridge.getVar(e,i);let r=this.serverVars[e];return r?r[i]:void 0}notifyVarHandlers(e,i){for(let r of this.varHandlers)this.scriptCanRun(r.script)&&r.entityType===e&&r.name===i&&this.safeCall(r.fn,this.enumTree.CustomVariableEntityType[e],i)}setVar(e,i,r){if(this.serverBridge&&typeof this.serverBridge.setVar=="function"){this.serverBridge.setVar(e,i,r);return}let n=this.serverVars[e]||(this.serverVars[e]=Object.create(null));n[i]=r,this.notifyVarHandlers(e,i)}sendClientSignal(e,i){for(let r of this.signalHandlers)this.scriptCanRun(r.script)&&r.name===e&&this.safeCall(r.fn,e,i)}evalQueryScript(e,i){this.L||this.boot();let r=this.L;p.lua_createtable(r,0,5);let n=(o,s)=>{p.lua_pushcfunction(r,s),p.lua_setfield(r,-2,G(o))};return n("var",o=>(Le(o,this,i.var(Ce(o,1),Ce(o,2))),1)),n("logContains",o=>(p.lua_pushboolean(o,i.logContains(Ce(o,1))),1)),n("control",o=>(Le(o,this,i.control(Ce(o,1))),1)),n("logs",o=>(Le(o,this,i.logs()),1)),n("signals",o=>(Le(o,this,i.signals(Ce(o,1))),1)),n("serverLogs",o=>(Le(o,this,i.serverLogs?i.serverLogs():[]),1)),n("serverLogContains",o=>{let s=i.serverLogContains;return p.lua_pushboolean(o,s?!!s(Ce(o,1)):!1),1}),p.lua_setglobal(r,G("query")),this.runChunk(r,e,"autotest-assert"),!0}destroy(){for(let e of this.roots.slice())this.destroyControl(e);for(let e of this.mountedScripts.slice())this.unmountScript(e);this.lifecyclePhase="idle",this.mountedScripts=[],this.luaFunctions.clear();for(let e of[...this.luaStates])this.closeTrackedLuaState(e);this.L=null,this.audios.clear(),this.audioHistory.length=0,this.audioWarnings.clear()}};function sn(t){let e=new Eo(t);return e.boot(),e}var Bi=Object.freeze(Array.from({length:8},(t,e)=>`Player${e+1}`)),ja=Object.freeze(Array.from({length:8},(t,e)=>`Avatar${e+1}`)),Pd=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var qa=Object.freeze([...Pd,...Bi,...ja]),Md=Object.freeze(["PlayerSelf","AllPlayers",...Bi]),Gy=Object.freeze(["Level","PlayerSelf",...Bi]),Cd=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),qy=-2147483648,By=2147483647,jy=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 an(t){return`Player${Number(t)}`}function Co(t){return`Avatar${Number(t)}`}function kd(t){let e=String(t||"").match(/^(?:Player|Avatar)([1-8])$/);return e?Number(e[1]):0}function qi(t){if(t==null||t==="")return 1;let e=Number(t);if(!Number.isInteger(e)||e<1||e>8)throw new Error("playerCount must be an integer 1-8");return e}function ii(t,e=8){let i=qi(e);if(t==null||t==="")return 1;let r=Number(t);if(!Number.isInteger(r)||r<1||r>i)throw new Error(`playerIndex must be an integer 1-${i}`);return r}function Ad(){let t={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let e of Bi)t[e]=Object.create(null);for(let e of ja)t[e]=Object.create(null);return t}function Fd(t){let e=String(t||"");if(!qa.includes(e))throw new Error(`unknown CustomVariableEntityType: ${t}`);return e}function Vy(t,e){let i=Fd(t);if(!Gy.includes(i))throw new Error(`${e}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function ln(t){let e=String(t??"");if(!e)throw new Error("custom variable name is required");return e}function ko(t){let e=String(t??"");if(!e)throw new Error("signal name is required");return e}function Ba(t){let e=String(t||"PlayerSelf");if(!Md.includes(e))throw new Error(`unsupported client signal target: ${t}. use PlayerSelf, AllPlayers, or Player1-8`);return e}function un(t){if(t==null)return"";if(typeof t=="boolean")return"Bool";if(typeof t=="string")return"String";if(typeof t=="number")return Number.isInteger(t)?"Int":"Float";if(Array.isArray(t)){if(t.length===0)return"IntList";let e=un(t[0]);return e&&!e.endsWith("List")&&e!=="Dict"&&e!=="Struct"?`${e}List`:"IntList"}return t&&typeof t=="object"?"x"in t||"y"in t||"z"in t?"Vector3":"Dict":""}function ot(t){return t===void 0?null:JSON.parse(JSON.stringify(t))}function Td(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"value")&&"type"in e?e.value:e):[]}function Rd(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"value")&&"type"in e?{type:String(e.type||""),value:e.value}:{type:un(e),value:e}):[]}function Uy(t){return String(t?.kind||t?.type||t?.name||t?.id||"")}function Ao(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Dd(t,e){if(!Ao(t)||!Object.prototype.hasOwnProperty.call(t,"fromSignalParam"))return null;if(Object.keys(t).some(r=>r!=="fromSignalParam"))throw new Error(`${e}.fromSignalParam cannot be combined with literal fields`);let i=Number(t.fromSignalParam);if(!Number.isSafeInteger(i)||i<0)throw new Error(`${e}.fromSignalParam must be a non-negative integer`);return{fromSignalParam:i}}function Od(t,e){return Dd(t,e)||ot(t)}function Hy(t,e,i){if(!Ao(t))throw new Error(`serverLogic.rules[${e}].actions[${i}] must be an object`);let r=String(t.kind||t.type||""),n=`serverLogic.rules[${e}].actions[${i}]`;if(r==="setCustomVariable"){let o=Vy(t.entityType,n);if(!Object.prototype.hasOwnProperty.call(t,"value"))throw new Error(`${n}.value is required`);return{kind:r,entityType:o,name:ln(t.name),value:Od(t.value,`${n}.value`),...t.variableType?{variableType:String(t.variableType)}:{}}}if(r==="sendClientScriptSignal"){if(!Array.isArray(t.params))throw new Error(`${n}.params must be an array`);return{kind:r,target:Ba(t.target),signalName:ko(t.signalName),params:t.params.map((o,s)=>Od(o,`${n}.params[${s}]`))}}throw new Error(`${n}.kind must be setCustomVariable or sendClientScriptSignal`)}function cn(t){if(t==null)return{version:1,rules:[]};if(!Ao(t))throw new Error("serverLogic must be an object");let e=t.rules===void 0?[]:t.rules;if(!Array.isArray(e))throw new Error("serverLogic.rules must be an array");return{version:1,rules:e.map((i,r)=>{if(!Ao(i))throw new Error(`serverLogic.rules[${r}] must be an object`);if(!Array.isArray(i.actions)||i.actions.length===0)throw new Error(`serverLogic.rules[${r}].actions must be a non-empty array`);return{id:String(i.id||`signal-${r+1}`),signalName:ko(i.signalName),actions:i.actions.map((n,o)=>Hy(n,r,o))}})}}function Nd(t,e,{typed:i=!1}={}){let r=Dd(t,"server logic value");if(r){let n=i?e.params:e.values;if(r.fromSignalParam>=n.length)throw new Error(`signal ${e.name} has no parameter at index ${r.fromSignalParam}`);return ot(n[r.fromSignalParam])}return ot(t)}function Yy(t){return t==="Level"?"Level":Bi.includes(t)?"PlayerSelf":ja.includes(t)?"AvatarSelf":t}function zd(t={}){let e=Ad(),i=Ad(),r=[],n=[],o=[],s=[],a=Array.from({length:9},()=>null),l=1,u=0,c=Number(t.onlineLatencyMs||0);(!Number.isFinite(c)||c<0)&&(c=0);let f=cn(t.logic),h=qi(t.playerCount),m=ii(t.viewPlayerIndex,h);function g(_,O){s.push({source:"server",level:String(_||"engine"),text:String(O),time:u})}function v(_){let O=a[_||m],y=Number(O?.clock?.time);Number.isFinite(y)&&(u=y)}function I(_,O,y,N){e[_][O]=y,i[_][O]={type:N||un(y)||i[_][O]?.type||""}}function C(_,O,y){return typeof y!="number"||!Number.isInteger(y)?{ok:!0,value:y}:y>=qy&&y<=By?{ok:!0,value:y}:(g("engine",`Int custom variable ${_}.${O} out of range ${y}; keeping previous legal value`),{ok:!1,value:e[_][O]})}function E(_,O){let y=Fd(_),N=O||m;return y==="PlayerSelf"?an(N):y==="AvatarSelf"?Co(N):y}function D(_,O){let y=Yy(_);if(_==="Level"){for(let d=1;d<=h;d+=1){let w=a[d];w&&typeof w.notifyVarHandlers=="function"&&w.notifyVarHandlers("Level",O)}return}let N=kd(_);if(!N)return;let x=a[N];x&&typeof x.notifyVarHandlers=="function"&&x.notifyVarHandlers(y,O)}function S(_,O){let y=Ba(_);return y==="AllPlayers"?Array.from({length:h},(N,x)=>x+1):y==="PlayerSelf"?[O||m]:[kd(y)]}function z(_){for(let O of f.rules)if(O.signalName===_.name)for(let y of O.actions){if(y.kind==="setCustomVariable"){let N=Nd(y.value,_);B.setVar(y.entityType,y.name,N,{type:y.variableType,playerIndex:_.playerIndex}),g("info",`logic ${O.id}: set ${y.entityType}.${y.name}`);continue}if(y.kind==="sendClientScriptSignal"){let N=y.params.map(x=>Nd(x,_,{typed:!0}));B.sendToClient(y.signalName,N,{target:y.target,playerIndex:_.playerIndex}),g("info",`logic ${O.id}: sent ${y.signalName} to ${y.target}`)}}}function L(_,O){_&&(_.serverBridge={getVar:(y,N)=>B.getVar(y,N,{playerIndex:O}),setVar:(y,N,x)=>B.setVar(y,N,x,{playerIndex:O}),receiveFromClient:(y,N)=>B.receiveFromClient(y,N,{playerIndex:O})})}function j(_){_&&(_.serverBridge=null)}let B={ENTITY_TYPES:Pd,ALL_ENTITY_TYPES:qa,CLIENT_SIGNAL_TARGETS:Md,get clock(){return u},get playerCount(){return h},get viewPlayerIndex(){return m},setClock(_){u=Number(_)||0},setPlayerCount(_){return h=qi(_),m>h&&(m=h),h},setViewPlayerIndex(_){return m=ii(_,h),m},log(_,O){g(_,O)},defineVar(_,O,y={},{playerIndex:N}={}){let x=E(_,N),d=ln(O);if(Object.prototype.hasOwnProperty.call(e[x],d))throw new Error(`custom variable already exists: ${x}.${d}`);let w=y.type?String(y.type):un(y.value??y.defaultValue);if(w&&!Cd.includes(w))throw new Error(`unsupported custom variable type: ${w}`);let F=y.value!==void 0?y.value:y.defaultValue!==void 0?y.defaultValue:null;return I(x,d,F,w),B.getVar(x,d)},getVar(_,O,{playerIndex:y}={}){let N=E(_,y),x=ln(O);if(!Object.prototype.hasOwnProperty.call(e[N],x)){g("engine",`GetGlobalCustomVariableValue missing ${N}.${x}; returning nil (simulator policy)`);return}return e[N][x]},setVar(_,O,y,{notify:N=!0,type:x,playerIndex:d}={}){let w=E(_,d),F=ln(O),V=x||i[w][F]?.type||un(y);if(V&&!Cd.includes(V)&&V!=="")throw new Error(`unsupported custom variable type: ${V}`);let H=y;if(!((V==="Int"||V===""&&typeof y=="number"&&Number.isInteger(y))&&(H=C(w,F,y).value,H===void 0)))return I(w,F,H,V),N&&D(w,F),H},listVars(_){let O=_?[E(_)]:["Level",...Array.from({length:h},(N,x)=>an(x+1)),...Array.from({length:h},(N,x)=>Co(x+1))],y=[];for(let N of O)for(let x of Object.keys(e[N]))y.push({entityType:N,name:x,type:i[N][x]?.type||"",value:ot(e[N][x])});return y},receiveFromClient(_,O=[],{playerIndex:y}={}){let N=ii(y||m,h);v(N);let x=ko(_),d={id:l++,direction:"inbound",name:x,params:Rd(O),values:Td(O),time:u,playerIndex:N,from:an(N)};return r.push(d),z(d),d},sendToClient(_,O=[],{target:y="PlayerSelf",playerIndex:N}={}){let x=ko(_),d=Ba(y),F=S(d,N||m),V={id:l++,direction:"outbound",name:x,params:Rd(O),values:Td(O),time:u,target:d,players:F,deliverAt:u+c/1e3,delivered:!1};return n.push(V),c===0?B.deliver(V):o.push(V),V},getLogic(){return ot(f)},setLogic(_){return f=cn(_),B.getLogic()},deliver(_){if(!_||_.delivered)return;_.delivered=!0;let O=Array.isArray(_.players)&&_.players.length?_.players:S(_.target);for(let y of O){let N=a[y];N&&typeof N.sendClientSignal=="function"&&N.sendClientSignal(_.name,_.values)}},flush(_){_!==void 0&&(u=Number(_)||0);let O=[];for(let y=o.length-1;y>=0;y-=1)o[y].deliverAt<=u&&O.push(o.splice(y,1)[0]);O.sort((y,N)=>y.id-N.id);for(let y of O)B.deliver(y);return O},inbound(){return r.slice()},outbound(){return n.slice()},loadConfig(_){if(_!=null){if(typeof _!="object")throw new Error("server config must be an object");if(_.graph&&!Array.isArray(_.nodes))throw new Error("unsupported server node graph: v1 only accepts custom variables and signals");for(let O of _.nodes||[]){let y=Uy(O);if(!jy.has(y))throw new Error(`unsupported server node: ${y||JSON.stringify(O)}. v1 only supports custom variables and signals`)}if(_.onlineLatencyMs!==void 0){let O=Number(_.onlineLatencyMs);if(!Number.isFinite(O)||O<0)throw new Error("onlineLatencyMs must be a non-negative finite number");c=O}_.playerCount!==void 0&&B.setPlayerCount(_.playerCount),_.viewPlayerIndex!==void 0&&B.setViewPlayerIndex(_.viewPlayerIndex),(_.logic!==void 0||_.serverLogic!==void 0)&&B.setLogic(_.logic??_.serverLogic);for(let O of _.vars||[]){let y=E(O.entityType),N=ln(O.name);Object.prototype.hasOwnProperty.call(e[y],N)?B.setVar(y,N,O.value??O.defaultValue,{notify:!1,type:O.type}):B.defineVar(y,N,O)}}},attachRuntime(_,{playerIndex:O=1}={}){let y=ii(O,8);return a[y]&&a[y]!==_&&j(a[y]),a[y]=_||null,L(a[y],y),B},attachRuntimes(_){B.detachRuntime();let O=Array.isArray(_)?_:[];for(let y=0;y<O.length&&y<8;y+=1)a[y+1]=O[y]||null,L(a[y+1],y+1);return B},detachRuntime(){for(let _=1;_<=8;_+=1)j(a[_]),a[_]=null},snapshot(){let _=an(m),O=Co(m),y={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let N of Object.keys(e.Level))y.Level[N]={type:i.Level[N]?.type||"",value:ot(e.Level[N])};for(let N of Object.keys(e[_]))y.PlayerSelf[N]={type:i[_][N]?.type||"",value:ot(e[_][N])};for(let N of Object.keys(e[O]))y.AvatarSelf[N]={type:i[O][N]?.type||"",value:ot(e[O][N])};for(let N=1;N<=h;N+=1){let x=an(N),d=Co(N);y[x]={},y[d]={};for(let w of Object.keys(e[x]))y[x][w]={type:i[x][w]?.type||"",value:ot(e[x][w])};for(let w of Object.keys(e[d]))y[d][w]={type:i[d][w]?.type||"",value:ot(e[d][w])}}return{clock:u,onlineLatencyMs:c,playerCount:h,viewPlayerIndex:m,logic:B.getLogic(),vars:y,inbound:r.map(N=>({id:N.id,name:N.name,params:ot(N.params),values:ot(N.values),time:N.time,playerIndex:N.playerIndex,from:N.from})),outbound:n.map(N=>({id:N.id,name:N.name,params:ot(N.params),values:ot(N.values),time:N.time,target:N.target,players:Array.isArray(N.players)?N.players.slice():[],deliverAt:N.deliverAt,delivered:!!N.delivered})),logs:s.map(N=>({source:"server",level:N.level,text:N.text,time:N.time}))}},reset(){for(let _ of qa){for(let O of Object.keys(e[_]))delete e[_][O];for(let O of Object.keys(i[_]))delete i[_][O]}r.length=0,n.length=0,o.length=0,s.length=0,l=1,u=0},destroy(){B.detachRuntime(),B.reset()}};t.config&&B.loadConfig(t.config);for(let _ of t.vars||[])B.defineVar(_.entityType,_.name,_);return B}var Xy={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function Va(t,e,i=null){let r=li(t.transformByPlatform,e),n={authoringId:t.id,kind:Xy[t.kind]||"container",name:t.name,prefabIndex:t.guid||0,active:t.active!==!1,visible:t.visible!==!1,canControllerFocus:t.canControllerFocus===!0,anchoredPositionX:r.offset.x,anchoredPositionY:r.offset.y,sizeDeltaX:r.size.x,sizeDeltaY:r.size.y,anchorMinX:r.anchorMin.x,anchorMinY:r.anchorMin.y,anchorMaxX:r.anchorMax.x,anchorMaxY:r.anchorMax.y,pivotX:r.pivot.x,pivotY:r.pivot.y,localScaleX:r.scale.x,localScaleY:r.scale.y,localScaleZ:r.scale.z,localRotationX:r.rotation.x,localRotationY:r.rotation.y,localRotationZ:r.rotation.z,children:(t.children||[]).map(s=>Va(s,e,i))},o=i?.get(t.id);return o?.length&&(n.scripts=o.map(s=>{let a=Number(s.guid);return{path:s.path||s.id,source:s.source||"",...Number.isSafeInteger(a)&&a>0?{scriptMappingId:a}:{}}})),t.kind==="container"&&(n.isolateNavigation=t.isolateNavigation===!0,n.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,n.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,n.showCursor=t.showCursor===!0),(t.kind==="textbox"||t.kind==="textwindow")&&(n.text=t.text??"",n.fontSize=t.fontSize,n.adaptiveFontSize=t.adaptiveFontSize===!0,n.minimumFontSize=t.minimumFontSize,n.fontColor=t.fontColor,n.bgColor=t.bgColor,n.enableOutline=t.enableOutline!==!1,n.outlineColor=t.outlineColor,n.horizontalAlignment=t.horizontalAlignment||"Left",n.verticalAlignment=t.verticalAlignment||"Top",t.kind==="textwindow"&&(n.interactable=t.interactable!==!1,n.showScrollBar=t.showScrollBar!==!1)),t.kind==="image"&&(n.imageSource=t.imageSource,n.imageType=t.imageType??null,n.imageId=t.imageId??0,n.imageColor=t.imageColor,n.raycastTarget=t.raycastTarget===!0,n.enableMask=t.enableMask===!0,n.enableSoftEdge=t.enableSoftEdge===!0,n.softEdgeMode=t.softEdgeMode,n.softEdgeWidthX=t.softEdgeWidthX,n.softEdgeWidthY=t.softEdgeWidthY,n.horizontalSoftRange=t.horizontalSoftRange,n.verticalSoftRange=t.verticalSoftRange,n.enableFill=t.enableFill===!0,n.fillType=t.enableFill?t.fillType:"Unused",n.fillHorizontalType=t.fillHorizontalType,n.fillVerticalType=t.fillVerticalType,n.fillRadial90Type=t.fillRadial90Type,n.fillRadialType=t.fillRadialType,n.fillAmount=t.fillAmount,n.reverseMaskArea=t.reverseMaskArea===!0),t.kind==="button"&&(n.raycastTarget=t.raycastTarget!==!1,n.interactable=t.interactable!==!1,n.clickAudioId=t.clickAudioId,n.unavailableChildId=t.unavailableChildId??null,n.hoverChildId=t.hoverChildId??null,n.pressedChildId=t.pressedChildId??null,n.selectedChildId=t.selectedChildId??null),t.kind==="cursor"&&(n.raycastTarget=t.raycastTarget!==!1),t.kind==="reference"&&(n.referencedPrefabIndex=t.referencedPrefabId),t.kind==="grid"&&(n.itemPrefabIndex=t.itemPrefabId,n.raycastTarget=t.raycastTarget!==!1,n.interactable=t.interactable!==!1,n.showScrollBar=t.showScrollBar!==!1,n.scrollDirection=t.scrollDirection,n.layoutConstraint=t.layoutConstraint,n.layoutConstraintFixedCount=t.layoutConstraintFixedCount,n.cellSizeX=t.cellSizeX,n.cellSizeY=t.cellSizeY,n.spacingX=t.spacingX,n.spacingY=t.spacingY,n.padding1X=t.padding1X,n.padding1Y=t.padding1Y,n.padding2X=t.padding2X,n.padding2Y=t.padding2Y,n.previewCount=t.previewCount),t.kind==="keyhint"&&(n.keyboardKeyCode=t.keyboardKeyCode,n.controllerKeyCode=t.controllerKeyCode),(t.kind==="animation"||t.kind==="fullscreen")&&(n.raycastTarget=!1,n.animationId=t.animationId,n.playSoundEffect=t.playSoundEffect,t.kind==="animation"&&(n.layer=t.layer)),n}function Ua(t,e=[],i=""){let r=i&&Ee[i]?i:t.canvasId,n=Ee[r],o=Lr(t),s=new Map;for(let l of e){if(!l.controlId)continue;let u=s.get(l.controlId)||[];u.push(l),s.set(l.controlId,u)}let a=t.meta?.assetType==="client-control-template"?(t.root.children||[]).map(l=>Va(l,r,s)):[];return{canvasId:r,platform:n.platform,device:n.luaDevice,canvasWidth:n.width,canvasHeight:n.height,root:Va(o,r,s),templates:a}}var To="qxqy-autotest";var Vi=.03333333333333333,Wy=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),Ky=new Set(["log","control","var","signal","tree","lua"]);function ji(t,e){let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e} must be a finite number`);return i}function Ha(t){return JSON.parse(JSON.stringify(t??null))}function Ro(t,e){if(!t||typeof t!="object")throw new Error(`events[${e}] must be an object`);let i=String(t.kind||t.do||"");if(!Wy.has(i))throw new Error(`unsupported event kind: ${i||"(empty)"}`);let r=t.payload&&typeof t.payload=="object"?{...t.payload}:{};if(i==="pointer")!r.type&&t.type&&(r.type=t.type),r.x===void 0&&(r.x=t.x),r.y===void 0&&(r.y=t.y),r.x=ji(r.x,"pointer.x"),r.y=ji(r.y,"pointer.y"),r.type=String(r.type||"click"),r.type==="wheel"&&(r.deltaX=ji(r.deltaX??t.deltaX??0,"pointer.deltaX"),r.deltaY=ji(r.deltaY??t.deltaY??0,"pointer.deltaY"));else if(i==="key"){if(r.typeName=String(r.typeName||r.key||t.typeName||t.key||""),!r.typeName)throw new Error("key event requires typeName")}else if(i==="click"){if(r.name=String(r.name||t.name||""),!r.name)throw new Error("click event requires control name")}else if(i==="serverSet"){if(r.entityType=String(r.entityType||t.entityType||""),r.name=String(r.name||t.name||""),r.value===void 0&&(r.value=t.value),r.value===void 0&&(r.value=null),!r.entityType||!r.name)throw new Error("serverSet requires entityType and name")}else if(i==="serverSend"){if(r.name=String(r.name||t.name||""),r.params=Array.isArray(r.params)?r.params:Array.isArray(t.params)?t.params:[],r.target=String(r.target||t.target||"PlayerSelf"),!r.name)throw new Error("serverSend requires signal name")}else if(i==="view"&&(r.playerIndex=Number(r.playerIndex||r.viewPlayerIndex||t.playerIndex||t.viewPlayerIndex||0),!Number.isInteger(r.playerIndex)||r.playerIndex<1))throw new Error("view event requires playerIndex 1-8");return{t:ji(t.t??0,"event.t"),source:String(t.source||"user"),kind:i,payload:r}}function Ya(t,e){if(!t||typeof t!="object")throw new Error(`asserts[${e}] must be an object`);let i=String(t.kind||(t.check?"log":""));if(!Ky.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let r={kind:i};if(t.at!==void 0&&(r.at=ji(t.at,"assert.at")),i==="log"){if(r.contains=String(t.contains||t.check||t.text||""),r.source=t.source==="server"?"server":"client",t.level&&(r.level=String(t.level)),!r.contains)throw new Error("log assert requires contains")}else if(i==="control"){if(r.id=t.id?String(t.id):"",r.name=t.name?String(t.name):"",r.field=String(t.field||""),!r.field)throw new Error("control assert requires field");if(!r.id&&!r.name)throw new Error("control assert requires id or name");if(!Object.prototype.hasOwnProperty.call(t,"equals"))throw new Error("control assert requires equals");r.equals=Ha(t.equals)}else if(i==="var"){if(r.entityType=String(t.entityType||""),r.name=String(t.name||""),!r.entityType||!r.name)throw new Error("var assert requires entityType and name");if(!Object.prototype.hasOwnProperty.call(t,"equals"))throw new Error("var assert requires equals");r.equals=Ha(t.equals)}else if(i==="signal"){if(r.direction=t.direction==="outbound"?"outbound":"inbound",r.name=String(t.name||""),!r.name)throw new Error("signal assert requires name");t.values!==void 0&&(r.values=Ha(t.values))}else if(i==="tree"){if(r.name=String(t.name||""),r.exists=t.exists!==!1,!r.name)throw new Error("tree assert requires name")}else if(i==="lua"&&(r.source=String(t.source||""),!r.source.trim()))throw new Error("lua assert requires source");return r}function $d(t){let e=0,i=[],r=[];for(let n of t){if(!n||typeof n!="object")throw new Error("queue step must be an object");if(n.do!=="start"){if(n.do==="step"){e+=ji(n.dt??Vi,"step.dt");continue}if(n.do==="pointer"||n.do==="key"||n.do==="click"||n.do==="pause"||n.do==="resume"||n.do==="serverSet"||n.do==="serverSend"||n.do==="view"){i.push(Ro({...n,kind:n.do,t:e},i.length));continue}if(n.assert||n.check||n.kind){r.push(Ya({...n.assert||n,at:n.at??e},r.length));continue}throw new Error(`unsupported queue step: ${JSON.stringify(n)}`)}}return{events:i,asserts:r,dt:Vi}}function fn(t){if(Array.isArray(t)){let r=$d(t);return{format:To,version:1,name:"",dt:r.dt,events:r.events,asserts:r.asserts}}if(!t||typeof t!="object")throw new Error("autotest case must be an object or step array");if(Array.isArray(t.queue)||Array.isArray(t.steps)){let r=$d(t.queue||t.steps);return{format:To,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):r.dt,events:r.events,asserts:r.asserts}}let e=(t.events||[]).map((r,n)=>Ro(r,n)),i=(t.asserts||[]).map((r,n)=>Ya(r,n));return e.sort((r,n)=>r.t-n.t||0),{format:To,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):Vi,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:e,asserts:i}}function Ld(t,e={}){let i=(t||[]).map((r,n)=>Ro(r,n));return{format:To,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):Vi,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:i,asserts:(e.asserts||[]).map((r,n)=>Ya(r,n))}}function Gd(t,e,i){if(!t)return null;let r=Ro({...e,t:e.t??i??0},t.events.length);return t.events.push(r),r}var Oo=(t,e)=>Math.max(0,Math.min(e,Number.isFinite(t)?t:0));function qd(t,e,i){let r=Xt(t,e,i),n=Math.max(0,r.contentHeight-i),o=Oo(t._scrollOffset||0,n);return t._scrollOffset=o,{...r,length:r.contentHeight,max:n,offset:o,viewport:i,horizontal:!1,width:e,height:i}}function Ir(t,e,i){if(!t?.showBar||t.max<=0||e<=0||i<=0)return null;let r=t.horizontal===!0,n=r?e:i,o=Math.max(0,n-4),s=Math.min(o,Math.max(18,o*n/(n+t.max))),a=o-s,l=a*t.offset/t.max,u=Math.min(8,r?i:e),c=r?{x:-e/2+2,y:i/2-u-2,width:o,height:u}:{x:e/2-u-2,y:-i/2+2,width:u,height:o},f=r?{...c,x:c.x+l,width:s}:{...c,y:c.y+l,height:s};return{track:c,thumb:f,travel:a}}var Bd="https://oss.070077.xyz/",Xa="mp3-v1",No="/qxqy-audio/",Jy=[[10001,"ura.1ht4.2ag9.1hh5.jbb.k02.jcw.2tv.2wn.2xk.2r3.d5s.94l.ebv.kcr.b40.77k.9gp.97w.1hb5.jag.btu.jc9.hp5.bmj.blq.blq.ff9.ffk.o74.1owl.rp.mg.l3.lf.lh.qy.1a3z.2xk.2xk.2xk.2xk.2xk.17dc.1f2b.2bc.2bc.2bc.2bc.2bc.ffo.ffo.126.1fk.4mo.4mo.15e.1h2.237.2ba.2kd.2bc.4mo.4mo.4mo.4mo.1mc.1n6.2cu.1ud.2b1.2ee.1tj.1tk"],[20001,"o6.fh.kb.cr.og.sm.6x.8c.87.o7.vz.kt.qo.lg.ob.9w.mg.1kz.zc.1ex.1d5.ps.uu.su.qs.ys.zp.10k.15a.xc.uk.mx.1ax.nt.tu.19m.uj.1ku.tt.100.ie.d3.fp.ie.ie.d3.fp.ie.8p.7k.fw.h0.qc.ot.uc.ot.rk.gb.1c2.ff.cl.9v.wg.1ir.1lr.1b8.1ri.1p0.104.10n.mw.j6.jb.f1.dv.84.a0.cp.bx.1ko.1au.1ia.rs.rt.rs.t7.x6.wi.zc.16f.1i6.2jh.28d.qh.k8.1gz.1ko.2iv.1xp.1l4.1gk.10j.yo.1jk.1jk.xv.104.15o.1xg.1xg.1xi.25i.p1.t1.yh.1ak.1i6.1y2.xt.32u.3g6.1bz.2mn.14l.14c.1e1.op.s8.p2.v5.2ix.1a0.ry.16m.17n.13c.134.ys.yu.xr.sl.sr.sd.yh.z5.gd.gl.hx.h2.g8.fj.iy.hz.jj.th.12n.16r.d3.j9.dg.lj.fl.a7.f9.iw.el.27f.1dh.1rh.2ph.yd.w5.x5.tr.pq.zf.16h.1a5.17t.wy.vn.y8.wl.yv.2ye.2qt.1ah.163.19t.uf.119.2vv.1bm.13h.14p.1so.c3.as.9z.19w.1l4.1nl.rj.we"],[30001,"jo.my.ss.dw.c1.b4.hl.hl.hl.cz.dw.dw.b4.dw.fr.kd.qv.px.px.74.6u.8h.60.8q.8b.eo.eo.eo.8k.a5.99.12v.13y.lg.m4.qr.dw.ex.g0.ef.cd.br.11n.17h.1b8.1c9.9p.ag.9z.l9.m8.m8.lw.m8.cz.99.b4.8c.63.7f.6h.99.re.pp.pi.cq.c9.cp.ck.c6.b0.bd.al.f6.gl.ed.fs.lc.k6.kh.i6.cx.j1.hk.gb.d7.h7.g2.em.kj.kn.k4.j5.rh.t0.qt.mj.i7.ih.i2.hd.3r.8d.6u.6z.by.de.dg.cr.1a5.1ab.16c.18g.n2.ly.no.nt.f9.de.lr.fe.f0.fj.el.fo.t1.g9.ly.h3.g6.de.2ak.2f3.wf.kg.qn.11p.rg.uj.u6.11c.22o.2cs.3dp.3dq.3d5.3d6.1zx.18v"],[40001,"19x.215.2zt.1ex.2pj.7hy.1ur.1gn.1g7.1b1.u9.1tw.108.1ew.rs.1qu.w9.lk.244.qi.b6.tk.jg.jg.jg.y4.c1.b4.iv.hi.r4.n7.gy.ev.qe.12z.18n.dw.1l6.ou.wz.1un.19t.18k.yy.1hs.sl.dw.1vl.100.14k.1q8.209.1jk.1xr.ua.1j2.pr.26h.1gs.s9.px.15v.pf.1jk.xc.1hb.111.172.ut.285.1oh.149.zj.22r.2l9.14a.ok.23y.1eh.xe.1j0.1rp.1cz.wf.1mh.22k.334.1z2.1xo.1br.4ji.5nq.5nf.2za.18r.h3.eo.ia.1kn.dc.ss.s0.1bl.1oc.is.km.177.1ec.1ao.h4.hp.dx.l9.iw.i3.12w.n1.yq.12w.1ju.yx.14s.18b.22t.u3.my.2rb.36w.13u.z8.20r.18g.19r.2x9.w4.q2.1d2.wo.13a.v6.17w.ur.288.1b6.14m.1fi.1xx.1ee.kj.121.j2.1d2.2ad.1ri.2lc.1vk.138.12r.xj.1h5.1c5.2qx.1gj.t2.lv.rf.18q.1kz.dw.2aq.ia.1i9.k5.199.f4.10y.18a.xf.rk.1g9.1q3.10h.sj.15o.e3.dz.sv.135.w9.yg.aw.2a2.19m.22w.1c8.272.13o.104.1sr.rs.1pb.d5.df.kp.jq.1a7.s8.1ao.ba.rb.in.pz.q8.140.ij.1e7.jl.yk.117.10i.1tn.1oj.1sv.sj.1e3.2so.1c7.1gv.178.107.10n.1dx.1qi.1wp.2bc.218.16r.105.xc.z6.11w.1mc.1y9.17p.1cs.2ij.18c.1ie.nn.16c.1ce.xb.1ei.3j0.ve.14x.1sx.285.1b8.1at.v4.rv.rs.10z.xq.11o.15k.xq.u1.i2.pu.i4.l3.9u.oh.mc.nm.pw.1i3.1h4.pj.111.l4.lb.qq.qf.u0.h4.nk.yf.6h.ij.ds.oy.re.m8.1gl.cz.16z.a1.1f8.1x6.vp.dz.gp.g6.fr.vl.fr.gg.qc.aj.99.go.ij.fz.11a.x5.mo.1u9.h0.m8.10m.1an.2bc.3uw.2gk.124.xb.1uk.1b6.2xj.1os.11a.vs.1i9.1lr.2gv.265.668.1xg.45j.404.2x1.1io.3om.4q2.4mo.1d4.2bp.1pr.166.2y6.2bv.361.2nc.2bc.3g0.7g4.334.2bc.2xo.3uw.6ic.4ig.3uw.23v.1la.2zr.1jt.1cq.27a.1n1.19x.1qg.1jn.1ca.26y.2d6.4v4.4mo.4mo.7ps.1jk.153.1fo.1dm.1s2.1w1.oe.1lb.319.2eg.58p.4mo.3dw.2y2.2xm.1u8.1ko.12n.1e0.2sd.1md.2cl.1q2.372.4mo.48s.b14.3fu.334.334.34i.4nf.4ji.5eg.3uw.2u8.1g1.110.37x.2jo.su.334.3aj.3uw.63f.2bc.2bc.8v4.1ts.ax5.5du.34d.3oc.34j.4si.174.rt.1rp.2b0.37d.1ta.2gh.28a.22z.1nc.1a5.1pa.4dd.3ha.2cs.5mv.4mq.5c2.3uw.1gf.4md.113.10x.21o.2hj.1b3.1cx.1ol.3ar.1fv.17t.1a7.2uj.2we.1jk"],[50001,"1o8.1k1.mo.1wu.2c9.22d.1kb.23n.1b8.1ic.24c.2wz.1mq.1mu.1jx.1z1.o3.190.vp.1h7.th.4mo.1rp.4mo.4mo.7ps.zz.143.21v.1nf.34s.1s3.r9.18t.s1.r9.21w.277.ls.25k.5v1.2bc.1kh.wt.14i.1eq.15o.668.sh.rl.3wi.3vc.43c.3yn.17c.f5.xu.jg.176.19v.1xy.23m.18x.30c.10l.13k.v8.vp.17t.qj.17m.1wr.1la.8t.s7.18d.1l2.152.mx.1c8.1l4.1f5.1xe.rz.2hz.1et.13t.xb.14r.15o.z0.1zo.ur.257.1gb.li.12d.15a.132.1m1.3vu.296.1mg.11m.z0.159.mp.hd.x4.1go.ns.xh.2a7.tt.2vb.1bx.1kh.u3.11i.1y1.24e.2hp.2mn.1w6.3zm.166.14g.1mo.2v9.2rg.2f9.1r0.139.m1.k3.ys.1dy.29k.1mm.22m.3zx.4dr.2h7.22o.tv.rm.1et.2wv.2ar.1t7.ku.12s.10b.1v9.1gu.12m.1b3.tv.1c8.tk.10s.ul.1tt.ka.oi.qb.13f.13f.13k.17h.1uh.ez.en.2x7.2ln.2h8.3h8.ig.n9.27o.18b.hl.nm.uk.11a.1ta.1k4.1eh.wv.1go.1gg.sc.18u.1dz.2aq.vt.2l7.25h.1l5.1kn.1vc.1b4.28i.17t.1d6.1k2.18z.jy.jw.dh.1mx.fr.vp.35w.34z.35w.34z.4so.vf.yx.1bg.1d3.2yc.1tg.8q3.99g.am.2du.rm.rg.xa.2cw.xc.1j6.1if.18z.13a.yz.142.1z5.262.1bj.1y8.ur.u5.16j.1pf.1bi.l8.1il.3vz.2dr.jo.ls.18s.16l.18c.141.219.1yz.1fc.24t.27e.481.1vp.25h.1yq.1zn.1uw.11u.1jp.1pz.39o.t6.1mj.1u5.11l.1vd.1dk.1zb.1ic.3ql.14p.1wq.25x.267.zn.zn.1pf.13z.1j7.r9.1hb.4yp.1lt.1cw.1z4.19z.1og.1j4.1cl.1eg.u8.16s.1en.zu.1hr.1js.19g.303.22j.2oa.180.1v7.2ud.2d7.21s.3g9.vh.v1.284.3lg.3lg.17q.1h3.4mo.1cm.1rv.22i.2mc.2j3.27o.333.1q8.237.2ll.23b.2sp.2ll.2ox.2cf.2f8.2hz.1uo.y4.s9.w6.2dg.2q9.up.1m1.1vz.2n8.192.1eb.z7.2em.2q3.1sd.1gj.348.3vf.2iu.29x.1dc.7oj.4pq.5vb.4mx.5me.5sf.5yf.7ps.yj.q0.10w.13p.18b.2wd.11q.2vx.dd.iv.12p.jh.u9.1uy.w0.3f0.3bj.126.qo.1gj.11k.pu.22h.1z6.rp.y4.y0.xl.1d0.11s.wa.1a6.127.10m.12r.1nh.1fy.yo.1js.162.n4.174.1aj.y4.o8.qz.rh.qa.18s.mr.j3.ii.sr.sx.1jk.17l.mj.zr.uy.wa.19t.2bt.xe.1od.hs.xr.5b.12c.1ab.we.gz.mz.4y.sf.11s.e0.1l7.ew.h6.jz.l0.e8.1cx.p6.17u.bw.1ah.10r.10e.o9.1bc.uv.lq.tl.zb.100.jy.b8.bj.336.10n.na.sq.14r.yr.nm.123.tf.l1.zp.1xc.1vk.31l.zl.2bj.2b9.2fv.17p.y0.so.1ln.29c.1eh.nh.xn.131.qc.186.ff.fc.xq.1bm.la.l8.14f.243.111.xi.qw.1qn.11v.1ur.1jx.1ks.s9.nz.269.1zj.2zd.1pv.18n.2vk.p3.1fh.13v.1lf.1lu.2db.1sr.1k3.26o.1dl.1f3.187.2lh.166.v9.xh.1e3.119.s2.mt.1iu.1k6.1o2.12s.u4.2br.1q3.qv.1e4.1zu.1v4.1vk.1t3.3p7.1ob.14d.1ns.1ef.1e4.12w.2kk.1ba.2jx.1e0.1s5.12w.17r.14s.wz.1qp.183.3fb.188.1gr.2ot.168.1u7.w8.28o.1zd.32z.230.w7.vq.x8.1qh.19f.14o.2r9.qg.1ey.1qr.1p6.3a3.1ov.13d.tz.wk.22v.1qa.2l9.yw.yf.nw.p6.1ly.1jk.1nh.x9.q0.17r.17h.ux.uw.12y.p7.g7.kt.14c.ze.1kh.1eo.18a.1d8.26j.15k.19f.1ym.1j5.1c6.11k.1sd.1jp.1ws.13s.1o5.214.sx.px.20x.14h.1ja.s6.1q8.w8.1ks.so.ub.121.202.1ej.1g1.1s8.2bc.4t1.bih.3uw.3pb.avp.6c7.bko.5eg.79c.6wh.3wd.4pn.55j.4a5.3gg.bko.5ei.52p.578.bcv.6gr.2bc.4j9.5y7.9d2.2bb.2bc.668.73z.5pg.50f.5m7.788.267.642.8h2.8h2.49s.64g.5e8.5e8.2bb.3ih.5ur.6bk.578.4ck.3sg.5fe.23i.e9w.2b8.5oj.6bw.2al.2rk.2rk.5pj.n6e.350.6v9.70t.639.3uw.3uw.2bg.639.2bb.2bd.6gj.2bh.660.578.3bk.65e.359.3o0.44i.4tn.1zq.5ee.4a5.3zu.rs.639.33q.5eg.1k1.15o.dw.3uw.b7p.7qd.898.4l4.5uu.5uu.b4g.2yh.2yh.3uw.51a.51a.5kk.66f.iq9.3n7.4nb.46a.1wb.20p.bih.8xa.7ps.70t.70t.4rv.5p1.6aq.ts.63z.668.5v2.5nu.563.55s.55s.5p3.2ga.32x.42x.5cr.4c2.71b.5zp.5c2.66t.4c8.2bc.2bc.2gn.3ea.2kp.fz6.8hz.3e8.4an.bko.j7e.jag.7sr.2bc.3zx.7qd.5ut.5jp.2wk.5q7.3uw.334.4i3.3uw.4bd.5eu.46h.4i2.6t4.446.5s7.5cg.4bk.5nd.7bf.4rt.23b.2bc.2bc.2bc.2bc.2ba.4mo.4dv.3wn.2bc.1we.4he.2bc.4gz.3wn.3km.4xy.4hi.4mr.2bc.247.3yj.2c6.2bc.3aj.446.4ub.3uw.51.e0.86.is.i1.hg.mn.m4.2c.7h.sg.e3.jb.7r.eq.nf.u0.60.4o.ke.47.47.47.47.b8.4x.dr.dy.rw.rw.59.8j.5z.a5.l3.c0.ik.f7.li.lr.7x.dv.du.dd.5e.91.1b.ce.cc.59.bh.e6.8m.9n.cl.lt.7ip.4mr.4si.4kf.vo.we.13e.17n.1iw.2pi.lp.r6.gw.7x.xz.qt.bq.ls.q1.eh.bx.cr.3c.j7.b8.fz.4k.8p.bg.5w.iy.j3.12o.rs.cz.dp.yz.jk.63.63.7ps.7ps.7ps.40g.3jp.4tw.89k.88a.7s0.83d.668.7ps.2fw.2ev.2fp.7ps.2jb.2dh.2ud.25i.24c.2bt.1pa.17r.1a7.7ps.7pt.5rg.4nl.3vv.7qo.31a.2p0.2k0.49a.3v4.3nl.1ug.1ug.1l6.7s1.7ps.2cp.2f8.2i7.7ps.28q.2be.275.1ma.1oz.1q7.16s.1iq.1e0.78m.7ps.2bc.2bc.2bc.bko.2wu.2wu.2wu.3b4.38f.3uw.3uw.3uw.3uw.7ps.7qa.32n.2gg.2wk.7rv.1v3.1qq.1rb.1zk.1my.1zp.1yn.1oh.1uh.7st.9q.9q.9q.9q.9q.kk.kk.kk.kk.kk.dw.dp.dw.rs.rs.rs.rs.s4.sd.54j.5n8.2n6.21r.1nu.1o5.14u.t6.3f7.2j0.32c.304.189.1gf.18w.18j.1st.1vq.116.kw.3uw.3uw.vr.zx.xc.tc.7d.7r.9d.9w.8s.9p.3b.3b"]].map(([t,e])=>[t,e.split(".").map(i=>parseInt(i,36)/1e3)]);function Po(t){if(!Number.isSafeInteger(t))return null;for(let[e,i]of Jy)if(t>=e&&t<e+i.length)return i[t-e];return null}var Mo=t=>Number.isFinite(Number(t))?Math.max(0,Number(t)):0;function Fo(t,e){if(!t||t.kind!=="image"||t.enableMask!==!0||!e)return null;let i=Mo(t.sourceWidth??t.width),r=Mo(t.sourceHeight??t.height),n=t.enableSoftEdge===!0,o=t.softEdgeMode!=="Pixel",s=n?Mo(t.softEdgeWidthX):0,a=n?Mo(t.softEdgeWidthY):0;return{id:t.id,matrix:e,width:i,height:r,featherX:o?i*s/100:s,featherY:o?r*a/100:a}}function jd(t,e,i){let r=tt(t,e,i);return{a:t.a,b:t.b,c:t.c,d:t.d,tx:r.x,ty:r.y}}function Vd(t,e,i){let r=(n,o)=>n<=0?0:!(o>0)||n>=o?1:n/o;return Math.min(r(t+i.width/2,i.featherX),r(i.width/2-t,i.featherX),r(e+i.height/2,i.featherY),r(i.height/2-e,i.featherY))}function Ud(t){let e={children:[]},i=[e],r=[];for(let n of t||[]){if(!n||n.id==null)continue;let o=n.masks||[],s=o.map(l=>JSON.stringify([l.id,l.matrix,l.width,l.height,l.featherX,l.featherY])),a=0;for(;a<r.length&&a<s.length&&r[a]===s[a];)a++;i.length=a+1;for(let l=a;l<o.length;l++){let u={mask:o[l],children:[]};i.at(-1).children.push(u),i.push(u)}i.at(-1).children.push({item:n}),r=s}return e.children}import{randomUUID as Wd}from"node:crypto";function $o(t){for(let e of t.runtime.scrollControls||[]){let[i,r]=tn(e),n=e.kind==="grid"?wr(e):qd(e,i,r),o={offset:n.offset,max:n.max,horizontal:n.horizontal,showBar:e.showScrollBar!==!1,textWidth:n.textWidth??0,lines:n.lines||[],lineHeight:n.lineHeight||0,contentLength:n.length,...e.kind==="textwindow"?{fontSize:n.fontSize}:{}},s=JSON.stringify(o);e._scrollKey!==s&&(e._scrollKey=s,e._scroll=o,e.markPlayDirty())}}function Kd(t){return{...t._scroll?{scroll:t._scroll}:{},...t.parent?._gridItems?.includes(t)?{clipToParent:!0}:{}}}function Wa(t,e){let i=t._scroll?.max||0;t.kind==="grid"?t.scrollProgress=i?Oo(e,i)/i:0:t._scrollOffset=Oo(e,i),t.markPlayDirty()}var Zy=Object.freeze(Object.values(Ee).map(t=>Object.freeze({id:t.id,label:t.label,platform:t.platform,width:t.width,height:t.height})));function Lo(t){$o(t);let e=Qe({width:t.runtime.canvasWidth,height:t.runtime.canvasHeight}),i=new Map;function r(n,o,s){let a=Vt(o,n);a.activeInHierarchy=s&&n.active!==!1,i.set(n.Id,a);let l=a.activeInHierarchy;for(let u of n.children)r(u,a,l)}for(let n of t.runtime.roots)r(n,e,!0);return i}function Jd(t,e=Lo(t)){let i=new Map;function r(n,o){let s=e.get(n.Id);if(!s)return;let a=$r(o,s,n);i.set(n.Id,a);for(let l of n.children)r(l,a)}for(let n of t.runtime.roots)r(n,tr());return i}function Zd(t,e){let i=e.get(t.Id);return{id:t.Id,prefabId:t.prefabIndex,authoringId:t.authoringId,name:t.name,kind:t.kind,typeofName:t.typeofName,instantiated:!t.authoringId,active:!!t.active,visible:!!t.visible,activeInHierarchy:!!i?.activeInHierarchy,raycastTarget:t.raycastTarget!==!1,interactable:t.interactable!==!1,pressed:t.pressed===!0,...t._scroll?{scrollOffset:t._scroll.offset,scrollMax:t._scroll.max}:{},...t.kind==="grid"?{itemCount:t.itemCount,scrollProgress:t.scrollProgress}:{},anchoredPositionX:t.anchoredPositionX,anchoredPositionY:t.anchoredPositionY,sizeDeltaX:t.sizeDeltaX,sizeDeltaY:t.sizeDeltaY,localScaleX:t.localScaleX,localScaleY:t.localScaleY,localScaleZ:t.localScaleZ,localRotationZ:t.localRotationZ,text:t.kind==="textbox"||t.kind==="textwindow"?t.text??"":null,fontSize:t.kind==="textbox"||t.kind==="textwindow"?t.fontSize:null,adaptiveFontSize:t.kind==="textbox"||t.kind==="textwindow"?t.adaptiveFontSize===!0:null,minimumFontSize:t.kind==="textbox"||t.kind==="textwindow"?t.minimumFontSize:null,fontColor:t.kind==="textbox"||t.kind==="textwindow"?t.fontColor:null,bgColor:t.kind==="textbox"||t.kind==="textwindow"?t.bgColor:null,enableOutline:t.kind==="textbox"||t.kind==="textwindow"?t.enableOutline===!0:null,outlineColor:t.kind==="textbox"||t.kind==="textwindow"?t.outlineColor:null,imageId:t.kind==="image"?t.imageId??0:null,imageSource:t.kind==="image"?st(t.imageSource):null,imageType:t.kind==="image"?t.imageType==null?null:At(t.imageType):null,primitive:t.kind==="image"?Qi(t.imageId,t.imageSource):null,imageColor:t.kind==="image"?t.imageColor:null,enableMask:t.kind==="image"?t.enableMask===!0:null,enableSoftEdge:t.kind==="image"?t.enableSoftEdge===!0:null,softEdgeMode:t.kind==="image"?t.softEdgeMode:null,softEdgeWidthX:t.kind==="image"?t.softEdgeWidthX:null,softEdgeWidthY:t.kind==="image"?t.softEdgeWidthY:null,horizontalSoftRange:t.kind==="image"?t.horizontalSoftRange:null,verticalSoftRange:t.kind==="image"?t.verticalSoftRange:null,enableFill:t.kind==="image"?t.enableFill===!0:null,fillType:t.kind==="image"?t.fillType:null,fillHorizontalType:t.kind==="image"?t.fillHorizontalType:null,fillVerticalType:t.kind==="image"?t.fillVerticalType:null,fillRadial90Type:t.kind==="image"?t.fillRadial90Type:null,fillRadialType:t.kind==="image"?t.fillRadialType:null,reverseMaskArea:t.kind==="image"?t.reverseMaskArea===!0:null,fillAmount:t.kind==="image"?t.fillAmount:null,box:i?{left:i.left,bottom:i.bottom,width:i.width,height:i.height}:null,children:t.children.map(r=>Zd(r,e))}}function Qy(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,pointerScroll:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function e0(t,e,i,r){let n=sn({canvasWidth:t.canvasWidth,canvasHeight:t.canvasHeight,device:t.device,audioDuration:Po,canSelectImageType:Hl,...r?{language:r}:{}});for(let o of[...t.templates||[],...e?.templates||[]])Number.isSafeInteger(o.prefabIndex)&&o.prefabIndex>0&&n.registerTemplate(o.prefabIndex,o);for(let o of i){let s=o.path||o.id,a=o.source||"";s&&a&&n.registerScriptFile(s,a)}return n}var t0=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","pointerScroll","hoveredControl","selectedControl","stateRestores","viewCache"];function i0(t){Object.defineProperty(t,"runtime",{configurable:!0,enumerable:!0,get(){return t.runtimes[t.viewPlayerIndex-1]}});for(let e of t0)Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){return t.views[t.viewPlayerIndex-1][e]},set(i){t.views[t.viewPlayerIndex-1][e]=i}})}function Qd(t,{templatesProject:e=null,scripts:i=[],sceneScripts:r=null,templateScripts:n=null,serverConfig:o=null,canvasId:s="",playerCount:a=1,viewPlayerIndex:l=1,language:u=""}={}){let c=r||i,f=n||i,h=Ua(t,c,s),m=e?Ua(e,f,s):null,g=qi(a),v=ii(l,g),I=zd({playerCount:g,viewPlayerIndex:v});o&&I.loadConfig({...o,playerCount:g,viewPlayerIndex:v});let C=[];for(let S=0;S<g;S+=1)C.push(e0(h,m,i,u));I.attachRuntimes(C);for(let S of C)S.addRoot(h.root);let E={audioSessionId:Wd(),runtimes:C,views:C.map(()=>Qy()),playerCount:g,viewPlayerIndex:v,server:I,compiled:h,mountError:C.find(S=>S.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};i0(E);let D=E.viewPlayerIndex;for(let S=1;S<=g;S+=1)E.viewPlayerIndex=S,h0(E);return E.viewPlayerIndex=D,E}function Qa(t,e){if(!t)throw new Error("play session has not started");let i=ii(e,t.playerCount);return i===t.viewPlayerIndex||(_i(t,{kind:"view",payload:{playerIndex:i}}),t.viewPlayerIndex=i,t.viewCache=null,t.server&&t.server.setViewPlayerIndex(i)),i}function _i(t,e){!t?.recording||!t.history||Gd(t.history,{...e,source:e.source||"user"},t.runtime.clock.time)}function r0(t){return t?.history?.events||[]}var el=new Set(["image","textbox","textwindow","button","grid"]);function n0(t,e){let i=tt(e,t.centerX,t.centerY);return{centerX:i.x,centerY:i.y,scaleX:Math.hypot(e.a,e.b),scaleY:Math.hypot(e.c,e.d),rotationZ:Math.atan2(e.b,e.a)*180/Math.PI,matrix:{a:e.a,b:e.b,c:e.c,d:e.d,tx:i.x,ty:i.y}}}function At(t){return typeof t=="string"?t:t?.Name}function eh(t){return{fillType:At(t.fillType),fillHorizontalType:At(t.fillHorizontalType),fillVerticalType:At(t.fillVerticalType),fillAmount:t.fillAmount}}function o0(t,e,i){let r=Math.abs(e.width*i.scaleX),n=Math.abs(e.height*i.scaleY),o={id:t.Id,kind:t.kind,name:t.name,left:i.centerX-r/2,bottom:i.centerY-n/2,width:r,height:n,sourceWidth:e.width,sourceHeight:e.height,rotationZ:i.rotationZ,matrix:i.matrix,pressed:t.pressed===!0,...Kd(t)};return t.kind==="image"&&(o.imageSource=st(t.imageSource),o.imageType=t.imageType==null?null:At(t.imageType),o.primitive=Qi(t.imageId,o.imageSource),o.imageColor=t.imageColor,o.imageId=t.imageId,Object.assign(o,eh(t))),(t.kind==="textbox"||t.kind==="textwindow")&&(o.text=t.text??"",o.fontSize=t.fontSize,o.adaptiveFontSize=t.adaptiveFontSize===!0,o.minimumFontSize=t.minimumFontSize,o.textLayout=Xt(t,e.width,e.height),o.fontColor=t.fontColor,o.bgColor=t.bgColor,o.enableOutline=t.enableOutline===!0,o.outlineColor=t.outlineColor,o.horizontalAlignment=At(t.horizontalAlignment),o.verticalAlignment=At(t.verticalAlignment)),o}function s0(t,e=Lo(t)){let i=[],r=Jd(t,e);function n(o,s=[],a=[]){let l=e.get(o.Id);if(!l||o.visible===!1||!l.activeInHierarchy)return;let u=r.get(o.Id);if(!u)return;let c=n0(l,u),f=o.kind==="image"&&o.enableMask===!0?Fo({...th(o,l),id:o.Id},jd(u,l.centerX,l.centerY)):null,h=f?[...a,f]:a,m=()=>i.push({...o0(o,l,c),...s.length?{clipPolygons:s}:{},...h.length?{masks:h}:{}});el.has(o.kind)&&o.kind!=="grid"&&m();let g=o.children||[];for(let v=g.length-1;v>=0;v-=1){let I=o._gridItems?.includes(g[v])?[...s,[[l.left,l.bottom],[l.right,l.bottom],[l.right,l.top],[l.left,l.top]].map(([C,E])=>tt(u,C,E))]:s;n(g[v],I,h)}o.kind==="grid"&&m()}for(let o of t.runtime.roots)n(o);return i}function th(t,e){let i={kind:t.kind,name:t.name,sourceWidth:e.width,sourceHeight:e.height,pressed:t.pressed===!0,...Kd(t)};return t.kind==="image"&&(i.imageSource=st(t.imageSource),i.imageType=t.imageType==null?null:At(t.imageType),i.primitive=Qi(t.imageId,i.imageSource),i.imageColor=t.imageColor,i.imageId=t.imageId,Object.assign(i,eh(t),{enableMask:t.enableMask===!0,enableSoftEdge:t.enableSoftEdge===!0,softEdgeMode:At(t.softEdgeMode)||"Percentage",softEdgeWidthX:t.softEdgeWidthX,softEdgeWidthY:t.softEdgeWidthY})),(t.kind==="textbox"||t.kind==="textwindow")&&(i.text=t.text??"",i.fontSize=t.fontSize,i.adaptiveFontSize=t.adaptiveFontSize===!0,i.minimumFontSize=t.minimumFontSize,i.textLayout=Xt(t,e.width,e.height),i.fontColor=t.fontColor,i.bgColor=t.bgColor,i.enableOutline=t.enableOutline===!0,i.outlineColor=t.outlineColor,i.horizontalAlignment=At(t.horizontalAlignment),i.verticalAlignment=At(t.verticalAlignment)),i}function a0(t,e,i){let r=ss(t,e),n=tt(r,t.centerX,t.centerY);return{a:r.a,b:r.b,c:r.c,d:r.d,tx:n.x-(i?i.centerX:0),ty:n.y-(i?i.centerY:0)}}function ih(t){let e=t.matrix;return[t.parent,t.z,t.group?1:0,e.a,e.b,e.c,e.d,e.tx,e.ty,t.kind,t.name,t.sourceWidth,t.sourceHeight,t.pressed,t.primitive,t.imageColor,t.imageId,t.imageSource,t.imageType,t.fillType,t.fillHorizontalType,t.fillVerticalType,t.fillAmount,t.enableMask,t.enableSoftEdge,t.softEdgeMode,t.softEdgeWidthX,t.softEdgeWidthY,t.text,t.fontSize,t.fontColor,t.bgColor,t.adaptiveFontSize,t.minimumFontSize,JSON.stringify(t.textLayout),t.enableOutline,t.outlineColor,t.horizontalAlignment,t.verticalAlignment,JSON.stringify(t.scroll),t.clipToParent].join(" ")}function rh(t,e,i,r,n,o){return{id:t.Id,parent:e,z:n,group:o>=16,matrix:a0(r,t,i),...th(t,r)}}function l0(t){let e=Qe({width:t.runtime.canvasWidth,height:t.runtime.canvasHeight}),i=new Set,r=new Map,n=new Map;function o(l,u,c){let f=Vt(u,l);if(f.activeInHierarchy=c&&l.active!==!1,n.set(l.Id,f),l.visible===!1||!f.activeInHierarchy)return!1;let h=l.children||[],m=el.has(l.kind),g=0;for(let v=0;v<h.length;v+=1)o(h[v],f,f.activeInHierarchy)&&(m=!0,g+=1);return m?(i.add(l.Id),r.set(l.Id,g),!0):!1}function s(l,u,c,f){if(!i.has(l.Id))return;let h=n.get(l.Id);a.push(rh(l,u,c,h,f,r.get(l.Id)||0));let m=l.children||[];for(let g=0;g<m.length;g+=1)s(m[g],l.Id,h,g)}let a=[];for(let l=0;l<t.runtime.roots.length;l+=1)o(t.runtime.roots[l],e,!0),s(t.runtime.roots[l],null,null,l);return{nodes:a,childCounts:r}}function Ja(t){let e=t._playChildDirty===!0||t._playDeepDirty===!0;if(t._playDirty=!1,t._playChildDirty=!1,t._playDeepDirty=!1,!e)return;let i=t.children;for(let r=0;r<i.length;r+=1)Ja(i[r])}function u0(t,e){let i=Qe({width:t.runtime.canvasWidth,height:t.runtime.canvasHeight}),r=[],n=[],o=e.count,s=t.runtime._playRemoved||[];for(let u=0;u<s.length;u+=1){let c=s[u];e.fingerprints.has(c)&&(n.push(c),e.fingerprints.delete(c),e.childCounts.delete(c),o-=1)}t.runtime._playRemoved=[];function a(u){e.fingerprints.has(u.Id)&&(n.push(u.Id),e.fingerprints.delete(u.Id),e.childCounts.delete(u.Id),o-=1);let c=u.children;for(let f=0;f<c.length;f+=1)a(c[f])}function l(u,c,f,h,m,g){let v=g||u._playDeepDirty===!0,I=v||u._playDirty===!0,C=v||u._playChildDirty===!0;if(!I&&!C)return;if(!(m&&u.active!==!1)||u.visible===!1){a(u);return}let D=Vt(c,u),S=e.childCounts.get(u.Id)||0;if(C){S=0;let O=u.children;for(let y=0;y<O.length;y+=1)l(O[y],D,u.Id,y,!0,v),e.fingerprints.has(O[y].Id)&&(S+=1)}if(!(el.has(u.kind)||S>0)){e.fingerprints.has(u.Id)&&(n.push(u.Id),e.fingerprints.delete(u.Id),e.childCounts.delete(u.Id),o-=1);return}let L=e.childCounts.get(u.Id);e.childCounts.set(u.Id,S);let j=S>=16!=(L||0)>=16;if(!I&&!j&&e.fingerprints.has(u.Id))return;let B=rh(u,f,c===i?null:c,D,h,S),_=ih(B);e.fingerprints.get(B.id)!==_&&(e.fingerprints.has(B.id)||(o+=1),e.fingerprints.set(B.id,_),r.push(B))}for(let u=0;u<t.runtime.roots.length;u+=1)l(t.runtime.roots[u],i,null,u,!0,!1);return e.count=o,{changed:r,removed:n,count:o}}function c0(t,e){let i=t.viewCache||(t.viewCache={rev:0,fingerprints:new Map,childCounts:new Map,count:0}),r=Number(e);if(!(Number.isFinite(r)&&r===i.rev&&i.fingerprints.size>0)){let{nodes:l,childCounts:u}=l0(t);i.rev+=1,i.fingerprints=new Map(l.map(c=>[c.id,ih(c)])),i.childCounts=u,i.count=l.length;for(let c of t.runtime.roots)Ja(c);return{format:"tree-v1",revision:i.rev,reset:!0,count:l.length,nodes:l}}let{changed:o,removed:s,count:a}=u0(t,i);i.rev+=1;for(let l of t.runtime.roots)Ja(l);return{format:"tree-v1",revision:i.rev,reset:!1,count:a,changed:o,removed:s}}function tl(t,{inspect:e=!1,view:i=!1,paint:r=!1,sceneRev:n,compact:o=!1}={}){$o(t),t.audioSessionId||=Wd();let s=t.runtime,a=t.compiled,[l,u]=[s.canvasWidth,s.canvasHeight];t.server&&t.server.setClock(s.clock.time);let c=o?s.logs.slice(-100):s.logs,f=r0(t),h=t.server?t.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};o&&(h.inbound=h.inbound.slice(-100),h.outbound=h.outbound.slice(-100),h.logs=h.logs.slice(-100));let m={canvasId:a.canvasId,platform:a.platform,device:s.device,canvasWidth:l,canvasHeight:u,canvasPresets:Zy,playerCount:t.playerCount||1,viewPlayerIndex:t.viewPlayerIndex||1,players:Array.from({length:t.playerCount||1},(g,v)=>({index:v+1,label:`\u73A9\u5BB6${v+1}`,entityType:`Player${v+1}`})),time:s.clock.time,frame:s.clock.frame,paused:!!t.debugPaused,levelTimePaused:!!s.clock.paused,audio:{sessionId:t.audioSessionId,playerIndex:t.viewPlayerIndex||1,...s.audioSnapshot()},mountError:t.mountError||s.mountErrors[0]||null,logs:c.map(g=>({source:"client",level:g.level,text:g.text,time:g.time})),tree:[],paint:[],scene:null,server:h,history:(o?f.slice(-100):f).map(g=>({t:g.t,source:g.source||"user",kind:g.kind,payload:g.payload||{}}))};if(e||r){let g=Lo(t);e&&(m.tree=s.roots.map(v=>Zd(v,g))),r&&(m.paint=s0(t,g))}return i&&(m.scene=c0(t,n)),er(m),m}function Go(t,e=1/30){let i=t.runtimes||(t.runtime?[t.runtime]:[]);for(let r of i)r.step(e);t.server&&(t.server.setClock(t.runtime.clock.time),t.server.flush())}function il(t,e){_i(t,{kind:"key",payload:{typeName:String(e)}}),t.runtime.injectKey(e)}function f0(t,e){let i=null;for(let r of t.runtime.roots)Gt(r,n=>{!i&&n.name===e&&(i=n)});return i}function rl(t,e){_i(t,{kind:"click",payload:{name:String(e)}});let i=f0(t,e);i&&nl(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function d0(t,e){return!t||!e?null:t.children.find(i=>i.authoringId===e||i.Id===e)||null}var nh={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function oh(t,e){let i=[];for(let[r,n]of Object.entries(nh)){let o=e[n]?d0(e,e[n]):null;o&&i.push({state:r,child:o})}return i}function h0(t){for(let e of t.runtime.roots)Gt(e,i=>{if(i.kind==="button"){for(let{child:r}of oh(t,i))t.stateRestores.has(r.Id)||t.stateRestores.set(r.Id,{child:r,active:r.active,visible:r.visible}),r.active=!0,r.visible=!1,typeof r.markPlayDirty=="function"&&r.markPlayDirty(!0);dn(t,i)}})}function dn(t,e){if(!e||e.kind!=="button")return;let i=null;e.interactable===!1?i="unavailable":e.pressed===!0?i="pressed":t.hoveredControl===e?i="hover":t.selectedControl===e&&(i="selected");for(let r of oh(t,e))r.child.active=!0,r.child.visible=r.state===i,typeof r.child.markPlayDirty=="function"&&r.child.markPlayDirty(!0)}function Ka(t){if(!t)return null;let e=t.parent;return e?.kind==="button"&&Object.values(nh).map(r=>e[r]).filter(Boolean).includes(t.authoringId)?e:t}function nl(t){return t.kind==="button"?t.raycastTarget!==!1&&t.interactable!==!1:t.kind==="cursor"||t.kind==="grid"?t.raycastTarget!==!1:t.kind==="textwindow"?t.interactable!==!1:t.raycastTarget===!0}function sh(t){return t.kind==="container"||t.kind==="grid"||t.kind==="textwindow"||t.kind==="reference"||t.kind==="button"}function ah(t,e){let i=t.Id,r=e.get(i);if(r!==void 0)return r;let n=nl(t);if(!n&&sh(t)){let o=t.children;for(let s=0;s<o.length;s+=1)if(ah(o[s],e)){n=!0;break}}return e.set(i,n),n}function Do(t,e,i){$o(t);let r=Qe({width:t.runtime.canvasWidth,height:t.runtime.canvasHeight}),n=new Map;function o(a,l,u,c){if(!c||a.active===!1||a.visible===!1||!ah(a,n))return null;let f=Vt(l,a),h=$r(u,f,a),m=Ut(h);if(!m)return null;let g=tt(m,e,i);if(g.x<f.left||g.x>f.right||g.y<f.bottom||g.y>f.top)return null;if(zo(a)){let v=Ir(a._scroll,f.width,f.height)?.track,I=g.x-f.centerX,C=f.centerY-g.y;if(v&&I>=v.x&&I<=v.x+v.width&&C>=v.y&&C<=v.y+v.height)return a}if(sh(a))for(let v=0;v<a.children.length;v+=1){let I=o(a.children[v],f,h,!0);if(I)return I}return nl(a)?a:null}let s=tr();for(let a=t.runtime.roots.length-1;a>=0;a-=1){let l=o(t.runtime.roots[a],r,s,!0);if(l)return l}return null}function Er(t,e,i,{dragging:r=!1,press:n=null,previous:o=null}={}){let s=n||{x:e,y:i},a=o||{x:e,y:i};return t.runtime.makeCursorEventData({x:e,y:i,pressX:s.x,pressY:s.y,deltaX:e-a.x,deltaY:i-a.y,dragging:r})}function Za(t,e,i){e.kind==="grid"||e.kind==="textwindow"||(e.pressed=i,typeof e.markPlayDirty=="function"&&e.markPlayDirty(),dn(t,e))}function zo(t){if(!t?.alive||!t.activeInHierarchy||t.interactable===!1||t.raycastTarget===!1)return!1;for(let e=t;e;e=e.parent)if(e.visible===!1)return!1;return t._scroll?.max>0}function Hd(t){for(let e=t;e;e=e.parent)if(zo(e))return e;return null}function Yd(t,e,i,r){let n=Lo(t),o=n.get(e.Id),s=Jd(t,n).get(e.Id),a=s&&Ut(s);if(!o||!a)return null;let l=tt(a,i,r);return{x:l.x-o.centerX,y:o.centerY-l.y,width:o.width,height:o.height}}function Xd(t,e,i){let r=t.pointerDownControl;if(r?.alive){let n=Er(t,e,i,{dragging:t.pointerDragging,press:t.pointerDownPosition,previous:t.pointerLastPosition});t.runtime.injectCursor(r,"CursorUp",n),t.pointerDragging&&!t.pointerScroll&&t.runtime.injectCursor(r,"CursorEndDrag",n),Za(t,r,!1)}t.pointerDownControl=null,t.pointerScroll=null,t.pointerDownPosition=null,t.pointerDragging=!1,t.pointerLastPosition={x:e,y:i}}function hn(t,e,i,r,n={}){let o=Number(i),s=Number(r);if(!Number.isFinite(o)||!Number.isFinite(s))throw new Error("pointer coordinates must be finite");t.runtime.cursor.x=o,t.runtime.cursor.y=s;let a=Number(n.deltaX??0),l=Number(n.deltaY??0);if(e==="wheel"&&(!Number.isFinite(a)||!Number.isFinite(l)))throw new Error("wheel deltas must be finite");if(n.silent||_i(t,{kind:"pointer",payload:{type:e,x:o,y:s,...e==="wheel"?{deltaX:a,deltaY:l}:{}}}),e==="wheel"){let u=Do(t,o,s),c=Hd(u);if(c){let f=c._scroll.horizontal&&a||l;Wa(c,c._scroll.offset+f)}return u}if(e==="cancel")return Xd(t,o,s),null;if((e==="move"||e==="up")&&t.pointerScroll&&!zo(t.pointerScroll.control)&&Xd(t,o,s),e==="move"){let u=t.pointerLastPosition||{x:o,y:s},c=t.pointerHoverControl,f=Ka(Do(t,o,s)),h=Er(t,o,s,{previous:u});c&&c!==f&&t.runtime.injectCursor(c,"CursorExit",h),f&&c!==f&&t.runtime.injectCursor(f,"CursorEnter",h),t.pointerHoverControl=f;let m=t.hoveredControl;t.hoveredControl=f?.kind==="button"?f:null,m&&m!==t.hoveredControl&&dn(t,m),t.hoveredControl&&dn(t,t.hoveredControl);let g=t.pointerDownControl,v=t.pointerScroll;if(v)if(!zo(v.control))t.pointerScroll=null;else{let I=Yd(t,v.control,o,s);if(I){let C=v.control._scroll,E=C.horizontal?I.x-v.start.x:I.y-v.start.y,D=Ir(C,I.width,I.height)?.travel||0,S=v.bar?D?E*C.max/D:0:-E;Wa(v.control,v.offset+S)}}if(g?.alive){let I=t.pointerDownPosition||u,C=Math.hypot(o-I.x,s-I.y)>5;!t.pointerDragging&&C&&(v||t.runtime.injectCursor(g,"CursorBeginDrag",Er(t,o,s,{press:I,previous:u,dragging:!1})),t.pointerDragging=!0),t.pointerDragging&&!v&&t.runtime.injectCursor(g,"CursorDrag",Er(t,o,s,{press:I,previous:u,dragging:!0}))}return t.pointerLastPosition={x:o,y:s},f}if(e==="down"){let u=Ka(Do(t,o,s));t.pointerDownControl=u,t.pointerDownPosition={x:o,y:s},t.pointerLastPosition={x:o,y:s},t.pointerDragging=!1,t.pointerScroll=null;let c=Hd(u);if(c){let f=Yd(t,c,o,s),h=f&&Ir(c._scroll,f.width,f.height),m=v=>f.x>=v.x&&f.x<=v.x+v.width&&f.y>=v.y&&f.y<=v.y+v.height,g=h&&m(h.track);if(g&&!m(h.thumb)){let v=c._scroll.horizontal?f.x-h.track.x-h.thumb.width/2:f.y-h.track.y-h.thumb.height/2;Wa(c,h.travel?v/h.travel*c._scroll.max:0),$o(t)}f&&(t.pointerScroll={control:c,start:f,offset:c._scroll.offset,bar:!!g})}return u&&(Za(t,u,!0),t.runtime.injectCursor(u,"CursorDown",Er(t,o,s))),u}if(e==="up"){let u=t.pointerDownControl,c=Ka(Do(t,o,s));if(u?.alive){let f=Er(t,o,s,{press:t.pointerDownPosition,previous:t.pointerLastPosition,dragging:t.pointerDragging});if(t.runtime.injectCursor(u,"CursorUp",f),t.pointerDragging)t.pointerScroll||t.runtime.injectCursor(u,"CursorEndDrag",f);else if(c===u&&!t.pointerScroll?.bar){t.runtime.injectCursor(u,"CursorClick",f);let h=t.selectedControl;t.selectedControl=u.kind==="button"?u:null,h&&h!==t.selectedControl&&dn(t,h)}Za(t,u,!1)}return t.pointerDownControl=null,t.pointerDownPosition=null,t.pointerLastPosition={x:o,y:s},t.pointerDragging=!1,t.pointerScroll=null,c}if(e==="click")return hn(t,"down",o,s,{silent:!0}),hn(t,"up",o,s,{silent:!0});throw new Error(`unknown pointer type ${e}`)}function ol(t,e,i,r){if(!t?.server)throw new Error("play session has no server");return _i(t,{kind:"serverSet",payload:{entityType:e,name:i,value:r,playerIndex:t.viewPlayerIndex}}),t.server.setVar(e,i,r,{playerIndex:t.viewPlayerIndex})}function lh(t,e,i){if(!t?.server)throw new Error("play session has no server");let r=t.server.getVar(e,i,{playerIndex:t.viewPlayerIndex});return r===void 0?null:r}function sl(t,e,i=[],r="PlayerSelf"){if(!t?.server)throw new Error("play session has no server");return _i(t,{kind:"serverSend",payload:{name:e,params:i,target:r,playerIndex:t.viewPlayerIndex}}),t.server.sendToClient(e,i,{target:r,playerIndex:t.viewPlayerIndex})}function qo(t){return{snapshot:e=>tl(t,e),step:e=>Go(t,e),pointer:(e,i,r,n)=>hn(t,e,i,r,n),key:e=>il(t,e),click:e=>rl(t,e),view:e=>Qa(t,e),pause:()=>{_i(t,{kind:"pause",payload:{}}),t.debugPaused=!0},resume:()=>{_i(t,{kind:"resume",payload:{}}),t.debugPaused=!1},serverSet:(e,i,r)=>ol(t,e,i,r),serverSend:(e,i,r)=>sl(t,e,i,r)}}function al(t){t?.server&&t.server.destroy();let e=t?.runtimes||(t?.runtime?[t.runtime]:[]);for(let i of e)i.destroy()}function ll(t,e){return JSON.stringify(t)===JSON.stringify(e)}function uh(t,e){for(let i of t||[])e(i),i.children?.length&&uh(i.children,e)}function ul(t,{id:e,name:i}){let r=null;return uh(t,n=>{r||(e&&String(n.id)===String(e)||!e&&i&&n.name===i)&&(r=n)}),r}function p0(t,e){if(t){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];if(t.box&&Object.prototype.hasOwnProperty.call(t.box,e))return t.box[e]}}function m0(t){return{var(e,i){return t.server?.vars?.[e]?.[i]?.value??null},logs(){return(t.logs||[]).map(e=>e.text)},logContains(e){return(t.logs||[]).some(i=>String(i.text||"").includes(String(e)))},serverLogs(){return(t.server?.logs||t.serverLogs||[]).map(e=>e.text)},serverLogContains(e){return(t.server?.logs||t.serverLogs||[]).some(i=>String(i.text||"").includes(String(e)))},control(e){let i=ul(t.tree,{name:String(e)});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(e){let i=e==="outbound"?"outbound":"inbound";return(t.server?.[i]||[]).map(r=>({name:r.name,values:r.values}))}}}function g0(t,e){if(t.kind==="log"){let i=t.source==="server"?e.server?.logs||e.serverLogs||[]:e.logs||[];return i.some(n=>t.level&&n.level!==t.level?!1:String(n.text||"").includes(t.contains))?{ok:!0,actual:t.contains}:{ok:!1,actual:i.map(n=>n.text).slice(-8),expected:t.contains}}if(t.kind==="control"){let i=ul(e.tree,t);if(!i)return{ok:!1,actual:null,expected:t.equals,message:`control not found: ${t.id||t.name}`};let r=p0(i,t.field);return ll(r,t.equals)?{ok:!0,actual:r}:{ok:!1,actual:r,expected:t.equals}}if(t.kind==="var"){let i=e.server?.vars?.[t.entityType],n=!i||!Object.prototype.hasOwnProperty.call(i,t.name)?null:i[t.name].value;return ll(n,t.equals)?{ok:!0,actual:n}:{ok:!1,actual:n,expected:t.equals}}if(t.kind==="signal"){let i=t.direction==="outbound"?e.server?.outbound||[]:e.server?.inbound||[],r=i.find(n=>n.name===t.name&&(t.values===void 0||ll(n.values,t.values)));return r?{ok:!0,actual:r.values}:{ok:!1,actual:i.map(n=>({name:n.name,values:n.values})),expected:{name:t.name,values:t.values??null}}}if(t.kind==="tree"){let i=!!ul(e.tree,{name:t.name});return i===t.exists?{ok:!0,actual:i}:{ok:!1,actual:i,expected:t.exists}}return{ok:!1,message:`unsupported assert kind ${t.kind}`}}function y0(t,e){let i=sn();try{return i.evalQueryScript(t,m0(e)),{ok:!0,actual:!0}}catch(r){return{ok:!1,message:r?.message||String(r)}}finally{i.destroy()}}function ch(t,e){return t.kind==="lua"?y0(t.source,e):g0(t,e)}function v0(t,e){let i=e>0?e:Vi;return Math.round((t+i)*1e9)/1e9}function b0(t,e){let i=e.payload||{};if(e.kind==="pointer")t.pointer(i.type,i.x,i.y,i);else if(e.kind==="key")t.key(i.typeName);else if(e.kind==="click")t.click(i.name);else if(e.kind==="pause")t.pause();else if(e.kind==="resume")t.resume();else if(e.kind==="serverSet")t.serverSet(i.entityType,i.name,i.value);else if(e.kind==="serverSend")t.serverSend(i.name,i.params,i.target);else if(e.kind==="view")t.view(i.playerIndex);else throw new Error(`unsupported event kind: ${e.kind}`)}function w0(t,e){let i=ch(t,e);return{kind:t.kind,at:Number(t.at||0),ok:!!i.ok,actual:i.actual??null,expected:i.expected??null,message:i.message||""}}function fh(t,e){let i=fn(e),r=i.events.slice().sort((C,E)=>C.t-E.t),n=i.asserts.slice(),o=i.dt||Vi,s=r.reduce((C,E)=>Math.max(C,E.t),0),a=n.reduce((C,E)=>Math.max(C,Number(E.at||0)),0),l=Math.max(s,a),u=0,c=[],f=0,h=n.some(C=>C.kind==="control"||C.kind==="tree"||C.kind==="lua"),m=t.snapshot({inspect:h}),g=()=>{for(;u<r.length&&r[u].t<=f+1e-9;)b0(t,r[u]),u+=1,m=t.snapshot({inspect:h})},v=()=>{for(let C of n)if(!C._done&&Number(C.at||0)<=f+1e-9){let E=w0(C,m);if(c.push(E),C._done=!0,!E.ok)return{passed:!1,failedAt:f,frame:m.frame||0,results:c,snapshot:m}}return null};g();let I=v();if(I)return cl(i,I);for(;f+1e-9<l;){t.step(o),f=v0(f,o),m=t.snapshot({inspect:h}),g();let C=v();if(C)return cl(i,C)}return cl(i,{passed:c.every(C=>C.ok),failedAt:null,frame:m.frame||0,results:c,snapshot:m})}function cl(t,e){return se({format:t.format,name:t.name,passed:e.passed,failedAt:e.failedAt,frame:e.frame,results:e.results,snapshot:{time:e.snapshot?.time??0,frame:e.snapshot?.frame??0,logs:e.snapshot?.logs||[],serverLogs:e.snapshot?.serverLogs||e.snapshot?.server?.logs||[],server:e.snapshot?.server||{vars:{},inbound:[],outbound:[],logs:[]}}})}function fl(t){return Array.isArray(t)?t.slice():[]}import{createHash as S0}from"node:crypto";var dh=t=>S0("sha256").update(JSON.stringify(t.map(({id:e,path:i,source:r})=>({id:e,path:i,source:r})))).digest("hex");function hh(t){let e=new Map;for(let r of t){let n=`${r.controlAsset}:${r.controlId}`,o=e.get(n);if(o&&o.newGuid!==r.oldGuid)throw new Error("\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u4E0D\u8FDE\u7EED\uFF0C\u8BF7\u4EA4\u7ED9 AI \u6838\u5BF9");e.set(n,{oldGuid:o?.oldGuid??r.oldGuid,newGuid:r.newGuid})}let i=new Map;for(let{oldGuid:r,newGuid:n}of e.values()){if(i.has(r))throw new Error("\u591A\u4E2A\u63A7\u4EF6\u5171\u7528\u65E7\u7D22\u5F15\uFF0C\u8BF7\u4EA4\u7ED9 AI \u6309\u63A7\u4EF6\u8EAB\u4EFD\u6838\u5BF9");i.set(r,n)}return new Map([...i].filter(([r,n])=>r!==n))}function ph(t,e){let i=[],r=new Map([...e].map(([l,u])=>[String(l),u])),n=1,o=0,s=0;return{source:t.replace(/\d+/g,(l,u)=>{if(!r.has(l))return l;for(;o<u;o++)t[o]===`
|
|
122
|
+
`&&(n++,s=o+1);let c=r.get(l),f=u+l.length,h=t.indexOf(`
|
|
123
|
+
`,f);return i.push({start:u,end:f,oldGuid:Number(l),newGuid:c,line:n,before:t.slice(s,h<0?t.length:h).trim()}),String(c)}),edits:i,issues:[]}}var C0={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(Bi.map((t,e)=>[t,`\u73A9\u5BB6${e+1}`])),...Object.fromEntries(Array.from({length:8},(t,e)=>[`Avatar${e+1}`,`\u89D2\u8272${e+1}`]))};function k0(t,e=1){let i=t?.vars||{},r=[],n=Number(e)>0?Number(e):1,o=["Level","PlayerSelf","AvatarSelf"];if(n>1)for(let a=1;a<=n;a+=1)o.push(`Player${a}`,`Avatar${a}`);let s=new Set;for(let a of o){if(s.has(a)||!i[a])continue;s.add(a);let l=i[a]||{};for(let u of Object.keys(l))r.push(se({entityType:a,entityLabel:C0[a]||a,name:u,type:l[u]?.type||"",value:l[u]?.value??null}))}return r}var Hi="qxqy-simulator-save",A0="qxqy-simulator-scripts",Ge="server-control-template",fe="client-control-template",dl={[Ge]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[fe]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function Ui(t){return t===fe?"client":"server"}function Ar(t){if(!(typeof t=="number"||typeof t=="string"&&/^\d+$/.test(t.trim()))||!vt(t))throw new Error("\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F 1\u20132147483647 \u8303\u56F4\u5185\u7684\u6574\u6570");return Number(t)}function hl(t=[]){if(!Array.isArray(t))throw new Error("controlGuidChanges \u5FC5\u987B\u662F\u6570\u7EC4");let e=new Set;return t.map(i=>{if(!i||typeof i.id!="string"||!i.id||e.has(i.id)||![Ge,fe].includes(i.controlAsset)||typeof i.controlId!="string"||!i.controlId||typeof i.controlName!="string")throw new Error("controlGuidChanges \u5305\u542B\u65E0\u6548\u6216\u91CD\u590D\u7684\u53D8\u66F4\u8BB0\u5F55");if(e.add(i.id),i.batchId!==void 0&&(typeof i.batchId!="string"||!i.batchId))throw new Error("controlGuidChanges \u5305\u542B\u65E0\u6548\u7684 batchId");if(i.scriptSignature!==void 0&&!/^[a-f0-9]{64}$/.test(i.scriptSignature))throw new Error("controlGuidChanges \u5305\u542B\u65E0\u6548\u7684 scriptSignature");return{id:i.id,controlAsset:i.controlAsset,controlId:i.controlId,controlName:i.controlName,oldGuid:Ar(i.oldGuid),newGuid:Ar(i.newGuid),...i.batchId?{batchId:i.batchId}:{},...i.scriptSignature?{scriptSignature:i.scriptSignature}:{}}})}function T0(t){let e=[t?.guid,t?.id];for(let i of e){let r=Number(i);if(Number.isSafeInteger(r)&&r>0&&r<=2147483647)return r}return 0}function Bo(t){let e=String(t?.controlAsset||""),i=T0(t);return{id:String(i||t?.id||""),guid:i,path:String(t?.path||""),source:String(t?.source||""),controlId:String(t?.controlId||""),controlAsset:e===fe||e==="client"?fe:e===Ge||e==="server"?Ge:""}}function R0(t){let e=[],i=(r,n="")=>{if(r&&(r.path||r.source)){let o=Bo(r);e.push(n?{...o,controlAsset:n}:o)}};if(Array.isArray(t?.assets?.scripts)){for(let r of t.assets.scripts)r&&(r.path||r.source)&&e.push(Bo(r));return e}if(i(t?.assets?.server?.script,Ge),i(t?.assets?.client?.script,fe),t&&t.format!==Hi){i(t?.script);for(let r of t?.scripts||[])i(r)}return e}function pl(t){return Si(t===fe?rr():Oi())}var O0="\u672A\u7ED1\u5B9A",Cr="\u672A\u547D\u540D\u5B58\u6863",N0="\u672A\u547D\u540D\u754C\u9762";function P0(t){let e=t;for(let i=0;i<8;i++){if(pn(gh(e,"simulator","studio"))&&pn(gh(e,"lua")))return e;let r=I0(e);if(r===e)break;e=r}return t}function M0(t){return t?{name:kr(t),path:t,bound:!0}:{name:O0,path:"",bound:!1}}function F0(t,e=process.cwd()){if(E0(t)&&pn(t))return t;let i=e||process.cwd(),r=P0(i),n=yh(r,t);if(pn(n))return n;let o=yh(i,t);if(pn(o))return o;throw new Error("script file not found: "+t)}function mn(t,e={}){t?.format===Hi&&Aa(t.version);let i=[],r=typeof e.workspacePath=="string"&&e.workspacePath?e.workspacePath:"",n=t?.format===Hi&&t.assets,o=hl(t?.controlGuidChanges),s=Mr(t?.scriptSync),a=n?null:Si(t,{warnings:i}),l={server:n&&t.assets.server?Si(t.assets.server,{warnings:i}):pl(Ge),client:n&&t.assets.client?Si(t.assets.client,{warnings:i}):pl(fe)};a&&(l[Ui(a.meta.assetType)]=a);let u=n&&t.activeAssetType===fe?fe:a?.meta.assetType||Ge,c=n&&t.meta?.name?String(t.meta.name):"",f=()=>c||Cr;!t?.meta?.name&&l.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(l.server.meta.name=N0);let h=[],m=new Set;function g(){m.clear(),ir(l.server.root,m),ir(l.client.root,m,{skipServerContainer:!0});for(let b of h)vt(b.guid)&&m.add(Number(b.guid))}function v(b=0){g();let k=vt(b)&&!m.has(Number(b))?Number(b):si(m);return m.add(k),k}function I(b){let k=Bo(b),R=v(k.guid);return{...k,guid:R,id:String(R)}}A(R0(t));let C=cn(t?.serverLogic),E=null,D="",S=1,z=1;function L(b){let k=String(b||"").trim();if(!k)return"";if(!Ee[k])throw new Error(`unknown canvas preset: ${k} (available: ${Object.keys(Ee).join(", ")})`);return k}let j=()=>l[Ui(u)];function B(b){if(!b)return null;for(let[k,R]of[["server",l.server],["client",l.client]]){let q=Ve(R.root,b);if(q&&q.kind!=="server-container")return{key:k,node:q}}return null}function _(b){if(!b.controlId)return null;let k=b.controlAsset===fe?"client":b.controlAsset===Ge?"server":null;if(k){let R=Ve(l[k].root,b.controlId);return R&&R.kind!=="server-container"?{key:k,node:R}:null}return B(b.controlId)}function O(){for(let b of h)b.controlId&&!_(b)&&(b.controlId="",b.controlAsset="")}function y(b){if(!vt(b))return null;for(let[k,R]of[[Ge,l.server],[fe,l.client]]){let q="";if(Ae(R.root,Y=>{!q&&(Y.scriptMappingIds||[]).includes(Number(b))&&(q=Y.id)}),q)return{controlId:q,controlAsset:k}}return null}function N(b,k,R){let q=l[Ui(b.controlAsset)],Y=q&&Ve(q.root,b.controlId);Y&&(Y.scriptMappingIds=(Y.scriptMappingIds||[]).map(X=>Number(X)===Number(k)?Number(R):X))}O();function x(){return h.map(b=>{let k=_(b),R=k?k.key==="client"?fe:Ge:"";return se({id:b.id,guid:b.guid||0,path:b.path||"",source:b.source||"",controlId:b.controlId||"",controlAsset:b.controlAsset||R,controlName:k?.node.name||"",assetType:R,assetLabel:k?dl[R]:"",mounted:!!k})})}function d(){let b=[],k=(R,q)=>{Ae(R.root,Y=>{Y.kind!=="server-container"&&b.push(se({id:Y.id,name:Y.name,kind:Y.kind,assetType:q,assetLabel:dl[q]}))})};return k(l.server,Ge),k(l.client,fe),b}function w(b){let k=[];return Ae(b.root,R=>{R.kind!=="server-container"&&k.push(JSON.stringify({kind:R.kind,guid:R.guid,name:R.name,text:R.text??null,imageId:R.imageId??null,imageSource:R.imageSource??null,imageType:R.imageType??null,fontSize:R.fontSize??null,adaptiveFontSize:R.adaptiveFontSize??null,minimumFontSize:R.minimumFontSize??null,fontColor:R.fontColor??null,bgColor:R.bgColor??null,imageColor:R.imageColor??null,fillType:R.fillType??null,fillAmount:R.fillAmount??null,syncAllDevices:R.syncAllDevices!==!1,transformByPlatform:R.transformByPlatform||null}))}),k.join("/")}let F=w(rr()),V=w(Oi());function H(b){let k=w(b);return b.meta?.assetType===fe?k===F:k===V}function Z(b,k){return String(b||"").replace(/[\\/:*?"<>|]/g,"-").trim()||k}function ne(b){let k=Z(f(),Cr),R=b.meta?.assetType===fe?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${k} \xB7 ${R}`}function ve(){if(!((l.server.root.children||[]).find(k=>k.kind==="container")||l.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 Uf(l.server,l.client,{scripts:h,fileName:`${Z(f(),Cr)} \xB7 \u6574\u5408\u5305.gia`})}function be(){let b=k=>({type:k.meta.assetType,name:k.meta.name,sourceFile:k.meta.sourceFile||""});return{format:Hi,name:f(),activeAssetType:u,assets:{server:b(l.server),client:b(l.client),scripts:x()}}}function ge(){return se({format:Hi,version:4,meta:{name:f()},activeAssetType:u,serverLogic:C,controlGuidChanges:o,scriptSync:s,assets:{server:l.server,client:l.client,scripts:h.map(b=>se({id:b.id,guid:b.guid||0,path:b.path||"",source:b.source||"",controlId:b.controlId||"",controlAsset:b.controlAsset||""}))}})}function ee(){let b=j(),k=sd(b);if(k.workspace=M0(r),k.save=be(),k.scripts=x(),k.mountTargets=d(),k.serverLogic=C,k.migrationWarnings=[...i],k.controlGuidChanges=se(o),u===fe){let R=vr(b,!0);k.clientGuidAutofill={count:R.length,templateCount:R.filter(({parent:q})=>q?.kind==="server-container").length,selectedOffset:R.findIndex(({node:q})=>q.id===k.selectedId)}}return k.scriptSync=se(s),Wl(k),k}function ce(b){let k=j();if(b.expectedRevision!==void 0&&Number(b.expectedRevision)!==k.version)throw new Error(`revision conflict: expected ${b.expectedRevision}, current ${k.version}`);return k}function Se(b,k,R=""){let q=String(k||"");if(q){let Y=R===fe?fe:R===Ge?Ge:"";if(!_({controlId:q,controlAsset:Y}))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");b.controlAsset=Y}else b.controlAsset="";b.controlId=q}function mt(b){let k=ce(b);if(b.op==="addScript"){let R=I({path:String(b.path||""),source:String(b.source||""),controlId:"",controlAsset:""});b.controlId!==void 0&&b.controlId!==""&&Se(R,b.controlId,b.controlAsset),h.push(R)}else if(b.op==="updateScript"){let R=h.find(q=>q.id===b.id);if(!R)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${b.id}`);b.controlId!==void 0&&Se(R,b.controlId,b.controlAsset),b.path!==void 0&&(R.path=String(b.path)),b.source!==void 0&&(R.source=String(b.source))}else if(b.op==="removeScript"){let R=h.length;if(h=h.filter(q=>q.id!==b.id),h.length===R)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${b.id}`)}return k.version+=1,ee()}function qt(b){let k=ce(b),R=Ve(k.root,b.id??k.selectedId);if(!R||R.kind==="server-container")throw new Error("\u4EC5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5141\u8BB8\u4FEE\u6539\u7D22\u5F15");let q=Ar(b.guid);if(Ar(R.guid),b.autoFillClientGuids!==void 0&&typeof b.autoFillClientGuids!="boolean")throw new Error("autoFillClientGuids \u5FC5\u987B\u662F\u5E03\u5C14\u503C");let Y=b.autoFillClientGuids===!0;if(Y&&u!==fe)throw new Error("\u81EA\u52A8\u586B\u5145\u4EC5\u652F\u6301\u5BA2\u6237\u7AEF\u6A21\u677F\u5217\u8868\uFF1B\u670D\u52A1\u7AEF\u754C\u9762\u7684\u7D22\u5F15\u9700\u5355\u72EC\u586B\u5199");let X=Y?vr(k,!0).map(({node:Q})=>Q):[R],he=q-X.indexOf(R),xe=X.map((Q,Pe)=>({node:Q,oldGuid:Ar(Q.guid),newGuid:Ar(he+Pe)})),Bt=xe.filter(({oldGuid:Q,newGuid:Pe})=>Q!==Pe);if(!Bt.length)return ee();let Ne=new Map(xe.map(({oldGuid:Q,newGuid:Pe})=>[Q,Pe]));if(Ne.size!==xe.length)throw new Error("\u5BA2\u6237\u7AEF\u6A21\u677F\u5B58\u5728\u91CD\u590D\u65E7\u7D22\u5F15\uFF0C\u65E0\u6CD5\u81EA\u52A8\u586B\u5145\uFF1B\u8BF7\u5148\u6D88\u9664\u6B67\u4E49");let ri=new Set(X),We=[];for(let Q of Object.values(l))Ae(Q.root,Pe=>{Q===l.client&&Pe.kind==="server-container"||We.push({node:Pe,project:Q})});let Ci=new Map([...We.filter(Q=>!ri.has(Q.node)).map(({node:Q})=>[Number(Q.guid),Q.name]),...h.map(Q=>[Number(Q.guid),Q.path||"Lua \u811A\u672C"])]);for(let{newGuid:Q}of Bt)if(Ci.has(Q))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${Q} \u5DF2\u88AB\u300C${Ci.get(Q)}\u300D\u5360\u7528\uFF1B\u8BF7\u5148\u586B\u5199\u5B83\u7684\u5B9E\u9645\u7D22\u5F15\u3002\u672C\u6B21\u672A\u4FEE\u6539\u4EFB\u4F55\u7D22\u5F15\u3002`);let Ot=[],ke=(Q,Pe,jt)=>{let yt=Q?.[Pe];(typeof yt=="number"||typeof yt=="string"&&/^\d+$/.test(yt.trim()))&&Ne.has(Number(yt))&&Ne.get(Number(yt))!==Number(yt)&&Ot.push({owner:Q,key:Pe,project:jt.project,oldGuid:Number(yt),newGuid:Ne.get(Number(yt))})};for(let Q of We)ke(Q.node,"referencedPrefabId",Q),ke(Q.node,"itemPrefabId",Q),ke(Q.node.giaRaw,"templateRefSlot",Q);let Ke=new Map;for(let{node:Q}of We)Ke.set(Number(Q.guid),(Ke.get(Number(Q.guid))||0)+1);for(let{oldGuid:Q}of Ot)if(Ke.get(Q)!==1)throw new Error(`\u65E7\u7D22\u5F15 ${Q} \u5728\u591A\u68F5\u8D44\u4EA7\u6811\u4E2D\u91CD\u590D\uFF0C\u65E0\u6CD5\u786E\u5B9A\u6A21\u677F\u5F15\u7528\u5F52\u5C5E\uFF1B\u8BF7\u5148\u6D88\u9664\u6B67\u4E49\u540E\u4FEE\u6539`);let Pr=Y?mh():"",Je=dh(h);for(let{node:Q,oldGuid:Pe,newGuid:jt}of Bt)Q.guid=jt,o.push({id:mh(),controlAsset:u,controlId:Q.id,controlName:Q.name,oldGuid:Pe,newGuid:jt,scriptSignature:Je,...Pr?{batchId:Pr}:{}});let xn=new Set([k]);for(let{owner:Q,key:Pe,project:jt,newGuid:yt}of Ot)Q[Pe]=typeof Q[Pe]=="string"?String(yt):yt,xn.add(jt);for(let Q of xn)Q.version+=1;return ee()}function Re(b){let k=ce(b);if(!Array.isArray(b.changeIds)||!b.changeIds.length||b.changeIds.some(q=>typeof q!="string"||!o.some(Y=>Y.id===q)))throw new Error("\u8BF7\u660E\u786E\u6307\u5B9A\u5DF2\u6838\u5BF9 Lua \u5F15\u7528\u7684\u6709\u6548\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55 changeIds");let R=new Set(b.changeIds);return o=o.filter(q=>!R.has(q.id)),k.version+=1,ee()}function ut(b){if(!b||typeof b!="object")throw new Error("patch requires op");if(b.op==="setScriptSync"){let k=ce(b);return s=Mr(b.config),k.version+=1,ee()}if(b.op==="setControlGuid")return qt(b);if(b.op==="acknowledgeControlGuidChanges")return Re(b);if(b.op==="setServerLogic"){let k=ce(b);return C=cn(b.logic),k.version+=1,ee()}if(b.op==="addScript"||b.op==="updateScript"||b.op==="removeScript")return mt(b);if(b.op==="selectAsset")return u=b.assetType===fe?fe:Ge,ee();if(b.op==="renameSave"){let k=String(b.name||"").trim();if(!k)throw new Error("\u5B58\u6863\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");return c=k,ee()}if(b.op==="newAsset"){let k=ce(b);u=b.assetType===fe?fe:Ge;let R=pl(u);return R.version=k.version+1,l[Ui(u)]=R,o=o.filter(q=>q.controlAsset!==u),O(),ee()}return Oa(j(),b),O(),ee()}function gt(b){return h.filter(k=>{let R=_(k);return!!(R&&R.key==="client"==(b===fe))})}function de(b="json",k=""){let R=T(b,k);if(o.length&&!["save","archive"].includes(String(b).toLowerCase())){let q=o.map(Y=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${dl[Y.controlAsset]} / ${Y.controlName} (${Y.controlId})\uFF1A${Y.oldGuid} \u2192 ${Y.newGuid}\u3002\u8BF7\u6309\u8BED\u4E49\u66F4\u65B0\u811A\u672C\u4E2D\u7684\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\uFF0C\u6838\u5BF9\u540E\u786E\u8BA4\u53D8\u66F4\u8BB0\u5F55 ${Y.id}\uFF1B\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\u3002`);R.warnings=[...new Set([...R.warnings||[],...q])]}return R}function T(b="json",k=""){let R=String(b).toLowerCase();if(R==="save"||R==="archive"){let X=Buffer.from(JSON.stringify(ge(),null,2),"utf8");return se({filename:`${f().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:X.toString("base64"),warnings:[]})}if(R==="save-gia"||R==="archive-gia"){let X=[],he=[],xe=(Ne,ri="")=>{let We=de(Ne,ri);X.push(se({filename:We.filename,mimeType:We.mimeType,encoding:We.encoding,data:We.data,warnings:We.warnings||[]})),he.push(...We.warnings||[])},Bt=(Ne,ri)=>{let We=l[Ui(Ne)],Ci=Ne===u,Ot=h.some(ke=>ke.controlAsset===Ne&&ke.controlId);if(!Ci&&H(We)&&!Ot){he.push(ri);return}xe("gia",Ne)};if(Bt(Ge,"\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"),Bt(fe,"\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"),h.some(Ne=>Ne.path||Ne.source)&&xe("scripts-gia"),!X.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 se({format:"qxqy-gia-package",files:X,warnings:[...new Set(he)]})}if(R==="gia-combined"||R==="combined-gia"||R==="combined"){let X=ve();return se({filename:`${Z(f(),Cr)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:X.buffer.toString("base64"),warnings:[...new Set(X.warnings||[])]})}if(R==="scripts"){let X=se({format:A0,version:1,scripts:h.map(xe=>se({id:xe.id,guid:xe.guid||0,path:xe.path||"",source:xe.source||"",controlId:xe.controlId||"",controlAsset:xe.controlAsset||""}))}),he=Buffer.from(JSON.stringify(X,null,2),"utf8");return se({filename:`${Z(f(),Cr)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:he.toString("base64"),warnings:[]})}if(R==="scripts-gia"||R==="scriptsgia"){let X=Xf(h);return se({filename:`${Z(f(),Cr)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:X.buffer.toString("base64"),warnings:X.warnings})}if(R==="lua"){let X=h.find(xe=>xe.id===k)||h.find(xe=>xe.path===k);if(!X)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let he=kr(X.path||"")||`qxqy-script-${X.id}`;return se({filename:/\.lua$/i.test(he)?he:`${he}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(X.source||"","utf8").toString("base64"),warnings:[]})}let q=k?l[Ui(k)]:j(),Y=ne(q);if(R==="json"){let X=se({...q,scripts:gt(q.meta.assetType),controlGuidChanges:o.filter(xe=>xe.controlAsset===q.meta.assetType)}),he=Buffer.from(JSON.stringify(X,null,2),"utf8");return se({filename:`${Y}.json`,mimeType:"application/json",encoding:"base64",data:he.toString("base64"),warnings:[]})}if(R==="gia"){let X=Vf(q,q.meta.assetType===fe?{scripts:gt(fe)}:{}),he=q.meta.assetType===fe?[]:gt(Ge);return he.length&&X.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${he.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`),se({filename:`${Y}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:X.buffer.toString("base64"),warnings:X.warnings})}throw new Error(`unsupported export format: ${b}`)}function A(b){for(let k of b){let R=Bo(k);if(!R.path&&!R.source)continue;let q=R.controlId?null:y(R.guid),Y=I(q?{...R,...q}:R);q&&Y.guid!==R.guid&&N(q,R.guid,Y.guid),Y.controlId&&!_(Y)&&(Y.controlId="",Y.controlAsset=""),h.push(Y)}}function P(b,k,R=""){let q=String(b||"").toLowerCase();if(typeof k!="string"||!k)throw new Error("import data is required");let Y=Buffer.from(k,"base64"),X,he=[],xe={},Bt=[];if(q==="json"){try{X=JSON.parse(Y.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(X?.project&&(X=X.project),X?.format===Hi&&X?.assets){Aa(X.version);let ke=mn(X);he.push(...ke.get().migrationWarnings);let Ke=ke.archiveData();return l.server=Ke.assets.server,l.client=Ke.assets.client,i=[...he],u=X.activeAssetType===fe?fe:Ge,c=String(X.meta?.name||kr(R).replace(/\.json$/i,"")||c),C=Ke.serverLogic,h=Ke.assets.scripts,o=Ke.controlGuidChanges,s=Ke.scriptSync,m.clear(),se({snapshot:ee(),warnings:he,metadata:{format:Hi}})}}else{if(q==="lua")return h.push(I({path:kr(R||"imported.lua"),source:Y.toString("utf8"),controlId:""})),se({snapshot:ee(),warnings:he,metadata:{assetType:"lua-script"}});if(q==="gia"){if(Wf(Y)){let Je=Jf(Y);return A(Je.scripts),se({snapshot:ee(),warnings:Je.warnings,metadata:Je.metadata})}let ke=Zf(Y);X=ke.project,he=ke.warnings,xe=ke.metadata,ke.clientProject&&(l.client=Si(ke.clientProject),o=o.filter(Je=>Je.controlAsset!==fe),he.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 Ke=new Map,Pr=(Je,xn)=>{Je&&Ae(Je.root,Q=>{for(let Pe of Q.scriptMappingIds||[]){let jt=Ke.get(Number(Pe));if(jt){he.push(`\u811A\u672C GUID ${Pe} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${jt.controlAsset===Ge?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}Ke.set(Number(Pe),{controlId:Q.id,controlAsset:xn})}})};Pr(ke.project,ke.project.meta.assetType),Pr(ke.clientProject,fe),Bt=(ke.scripts||[]).map(Je=>Ke.has(Number(Je.guid))?{...Je,...Ke.get(Number(Je.guid))}:Je)}else throw new Error(`unsupported import format: ${b}`)}let Ne=Si(X,{warnings:he}),ri=hl(X?.controlGuidChanges);if(ri.some(ke=>ke.controlAsset!==Ne.meta.assetType))throw new Error("\u5355\u8D44\u4EA7 JSON \u7684\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u5BFC\u5165\u8D44\u4EA7");let We=hl([...o.filter(ke=>ke.controlAsset!==Ne.meta.assetType),...ri]);i=[...he];let Ci=Ui(Ne.meta.assetType);l[Ci]=Ne,o=We,u=Ne.meta.assetType;let Ot=l[Ci];return R&&(Ot.meta.name=kr(R).replace(/\.(json|gia)$/i,"")||Ot.meta.name,Ot.meta.sourceFile=kr(R),Ot.meta.sourceFormat=q),A(Bt),A(X?.scripts||[]),X?.script&&(X.script.path||X.script.source)&&A([X.script]),se({snapshot:ee(),warnings:he,metadata:xe})}function M(b,k){return Oa(j(),{op:"pick",x:b,y:k}),ee()}function U(b){let k=typeof b=="string"&&b?b:"";!k||k===r||(r=k)}function J(b){let k=b.source||"";if(!k.trim()&&b.path.trim())try{k=_0(F0(b.path,r),"utf8")}catch(R){throw new Error(`\u811A\u672C ${b.path} \u8BFB\u53D6\u5931\u8D25: ${R?.message||R}`)}return k}function re(b={}){let k=L(b.canvasId);k&&(D=k),b.playerCount!==void 0&&b.playerCount!==null&&b.playerCount!==""&&(S=qi(b.playerCount),z>S&&(z=1)),b.viewPlayerIndex!==void 0&&b.viewPlayerIndex!==null&&b.viewPlayerIndex!==""&&(z=ii(b.viewPlayerIndex,S)),E&&al(E);let R=h.map(Y=>{try{return{id:Y.id,guid:Y.guid||0,path:Y.path||Y.id,source:J(Y),controlId:Y.controlId||"",controlAsset:Y.controlAsset||""}}catch(X){return{id:Y.id,guid:Y.guid||0,path:Y.path||Y.id,source:`error([==[ ${String(X.message).replace(/]=+]/g,"] =]")} ])`,controlId:Y.controlId||"",controlAsset:Y.controlAsset||""}}}),q=Y=>R.filter(X=>{let he={controlId:X.controlId,controlAsset:X.controlAsset},xe=X.controlId?_(he):null;return!!(xe&&xe.key===Y)});return E=Qd(l.server,{templatesProject:l.client,scripts:R,sceneScripts:q("server"),templateScripts:q("client"),serverConfig:{logic:C},canvasId:D,playerCount:S,viewPlayerIndex:z,language:b.language||""}),ie(b)}function oe(b,k={}){let R=L(b);if(!R)throw new Error("playSetCanvas requires canvasId");return re({...k,canvasId:R})}function ie(b={}){if(!E)return se({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let k=tl(E,b);return k.running=!0,k.logs=fl(k.logs),k.serverLogs=fl(k.server?.logs||[]),k.serverVars=k0(k.server,k.playerCount||1),k}function Me(b,k={}){return E||re(),Go(E,b),k.observe===!1?se({running:!0,time:E.runtime.clock.time,frame:E.runtime.clock.frame,paused:!!E.debugPaused,levelTimePaused:!!E.runtime.clock.paused,playerCount:E.playerCount||1,viewPlayerIndex:E.viewPlayerIndex||1}):ie(k)}function Oe(b=0){re();let k=Math.max(0,Number(b)||0);for(let R=0;R<k;R++)Go(E,1/30);return ie()}function Rt(){return E&&al(E),E=null,D="",S=1,z=1,se({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function Sp(b,k={}){let R=Nr();return z=Qa(R,b),k.observe===!1?null:ie(k)}function xp(b,k={}){if(!E)throw new Error("play session has not started");return il(E,b),k.observe===!1?null:ie(k)}function _p(b,k={}){if(!E)throw new Error("play session has not started");return rl(E,b),k.observe===!1?null:ie(k)}function Ip(b,k,R,q={}){if(!E)throw new Error("play session has not started");return hn(E,b,k,R,q),q.observe===!1?null:ie(q)}function Ep(b={}){return E&&qo(E).pause(),b.observe===!1?null:ie(b)}function Cp(b={}){return E&&qo(E).resume(),b.observe===!1?null:ie(b)}function Nr(){if(!E)throw new Error("play session has not started");return E}function kp(b,k){let R=Nr();if(!b&&!k){let q=ie();return se({vars:q.serverVars||[]})}return se({entityType:String(b||""),name:String(k||""),value:lh(R,b,k)})}function Ap(b,k,R){let q=Nr();return ol(q,b,k,R),ie()}function Tp(b,k=[],R="PlayerSelf"){let q=Nr();return sl(q,b,k,R),ie()}function Rp(){let b=ie();return se({events:b.history||[],case:Ld(b.history||[],{playerCount:b.playerCount||1})})}function Op(b={}){let k=ie(),R=fn({name:b.name||"",dt:b.dt,playerCount:b.playerCount||k.playerCount||1,events:b.events||k.history||[],asserts:b.asserts||[]});return se(R)}function Np(b,k={}){let R=fn(b);re({...k,playerCount:k.playerCount||R.playerCount||1});let q=Nr();q.recording=!1;try{return fh(qo(q),b)}finally{q.recording=!0}}function Pp(){if(!E)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let b=E.runtime.clock;return{running:!0,paused:!!E.debugPaused,levelTimePaused:!!b.paused,time:b.time,frame:b.frame,playerCount:E.playerCount||1,viewPlayerIndex:E.viewPlayerIndex||1}}let ql={get:ee,patch:ut,setWorkspace:U,exportData:de,importData:P,pick:M,playStart:re,playSetCanvas:oe,playSetView:Sp,playGet:ie,playStatus:Pp,playStep:Me,playRun:Oe,playStop:Rt,playKey:xp,playClick:_p,playPointer:Ip,playPause:Ep,playResume:Cp,playServerGet:kp,playServerSet:Ap,playServerSend:Tp,playHistory:Rp,playSaveCase:Op,playRunCase:Np,archiveData:ge};return Object.defineProperty(ql,"_project",{enumerable:!1,get:j}),ql}import{createRequire as $0}from"node:module";function ml(t,e,i){if(t.fillType!=="Horizontal"&&t.fillType!=="Vertical")return null;let r=Number(t.fillAmount??1),n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1;if(t.fillType==="Horizontal"){let s=e*n;return{x:t.fillHorizontalType==="Right"?e/2-s:-e/2,y:-i/2,width:s,height:i}}let o=i*n;return{x:-e/2,y:t.fillVerticalType==="Top"?-i/2:i/2-o,width:e,height:o}}function vh(t,e,i){let r=e?.m_Rect,n=e?.m_RD?.textureRectOffset,o=e?.m_RD?.textureRect,s=Math.round(Number(r?.width)),a=Math.round(Number(r?.height)),l=Math.round(Number(n?.X)),u=Math.round(Number(n?.Y)),c=Math.round(Number(o?.width)),f=Math.round(Number(o?.height)),h=e?.m_RD?.settingsRaw?.packingRotation;if(![s,a,c,f].every(v=>Number.isInteger(v)&&v>0&&v<=8192)||s*a>16777216||!Number.isFinite(l)||!Number.isFinite(u)||l<0||u<0||l+c>s||u+f>a)throw new Error("Invalid sprite dimensions or trim offset");if(h&&h!=="None")throw new Error(`Unsupported sprite packing rotation: ${h}`);let m=i(s,a),g=m.getContext("2d");if(t.width===s&&t.height===a)g.drawImage(t,0,0);else{if(t.width!==c||t.height!==f)throw new Error("Sprite PNG does not match its trim metadata");g.drawImage(t,l,a-u-f)}return m}function bh(t,e,i){let r=Number(e??4294967295)>>>0;if((r&16777215)===16777215)return t;let n=i(t.width,t.height),o=n.getContext("2d");o.drawImage(t,0,0);let s=o.getImageData(0,0,n.width,n.height),a=r>>>16&255,l=r>>>8&255,u=r&255;for(let c=0;c<s.data.length;c+=4)s.data[c]=Math.round(s.data[c]*a/255),s.data[c+1]=Math.round(s.data[c+1]*l/255),s.data[c+2]=Math.round(s.data[c+2]*u/255);return o.putImageData(s,0,0),n}function D0(t){return!!t?.border&&Object.values(t.border).some(e=>Number.isFinite(e)&&e>0)}function Sh(t,e){let i=typeof e=="object"?e?.Name:e;return D0(t)&&i!=="Basic"?"Stretch":"Basic"}function xh(t){if(!t)return null;let e=Number(t.m_Rect?.width),i=Number(t.m_Rect?.height);if(![e,i].every(n=>Number.isFinite(n)&&n>0&&n<=8192)||e*i>16777216)throw new Error("Invalid image metadata dimensions");let r={};for(let[n,o]of[["left","X"],["bottom","Y"],["right","Z"],["top","W"]]){let s=Number(t.m_Border?.[o]??0);if(!Number.isFinite(s))throw new Error("Invalid image border");r[n]=Math.max(0,s)}return{width:e,height:i,border:r}}function z0(t,e,i,r){e=Number.isFinite(e)?Math.max(0,e):0,i=Number.isFinite(i)?Math.max(0,i):0;let n=Math.min(1,t/(e+i||1));e*=n,i*=n;let o=Math.min(1,r/(e+i||1));return{source:[0,e,t-i,t],target:[0,e*o,r-i*o,r]}}var wh=new WeakMap;function _h(t,e,i,r,n){let o=Math.max(0,i),s=Math.max(0,r),a=Math.min(1,4096/Math.max(1,o),4096/Math.max(1,s)),l=Math.max(1,Math.round(o*a)),u=Math.max(1,Math.round(s*a)),c=n(l,u),f=c.getContext("2d");if(!o||!s)return c;let h=wh.get(t);if(!h){let E=n(t.width,t.height),D=E.getContext("2d");D.drawImage(t,0,0),h=D.getImageData(0,0,t.width,t.height),wh.set(t,h)}let m=f.createImageData(l,u),g=h.data,v=(E,D,S,z,L,j)=>{let{source:B,target:_}=z0(D,S,z,L);return Array.from({length:j},(O,y)=>{let N=(y+.5)*L/j,x=N<_[1]?0:N<_[2]?1:2,d=_[x+1]>_[x]?(N-_[x])/(_[x+1]-_[x]):0,w=Math.max(0,Math.min(E-1,(B[x]+d*(B[x+1]-B[x]))*E/D-.5)),F=Math.floor(w);return[F,Math.min(E-1,F+1),w-F]})},I=v(t.width,e.width,e.border.left,e.border.right,o,l),C=v(t.height,e.height,e.border.top,e.border.bottom,s,u);for(let E=0;E<u;E++)for(let D=0;D<l;D++){let[S,z,L]=I[D],[j,B,_]=C[E],O=(j*t.width+S)*4,y=(j*t.width+z)*4,N=(B*t.width+S)*4,x=(B*t.width+z)*4,d=g[O+3]*(1-L)*(1-_),w=g[y+3]*L*(1-_),F=g[N+3]*(1-L)*_,V=g[x+3]*L*_,H=d+w+F+V,Z=(E*l+D)*4;m.data[Z+3]=Math.round(H);for(let ne=0;ne<3;ne++)m.data[Z+ne]=H?Math.round((g[O+ne]*d+g[y+ne]*w+g[N+ne]*F+g[x+ne]*V)/H):0}return f.putImageData(m,0,0),c}var L0=$0(import.meta.url),G0=[0,-.5,.5,.5,-.5,.5],q0=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],B0=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],gl=Buffer.from([137,80,78,71,13,10,26,10]),j0=new Set(["image","textbox","textwindow","button","grid"]),jo={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"},Vo=null;function gn(){if(Vo)return Vo;try{Vo=L0("@napi-rs/canvas")}catch(t){let e=t?.message||String(t);throw new Error(`Host screenshot renderer requires @napi-rs/canvas (${e})`)}return Vo}function me(t,e=0){let i=Number(t);return Number.isFinite(i)?i:e}function Ho(t,e=4294967295){let i=Number(t??e)>>>0;return{r:i>>>16&255,g:i>>>8&255,b:i&255,a:(i>>>24&255)/255}}function Yi(t,e=1){return`rgba(${t.r},${t.g},${t.b},${Math.max(0,Math.min(1,t.a*e))})`}function Eh(t,e,i=1){let r=Math.max(1,Math.round(me(t,1))),n=Math.max(1,Math.round(me(e,1))),o=Math.max(1,Math.min(2,me(i,1)));return{width:r,height:n,pixelWidth:Math.max(1,Math.round(r*o)),pixelHeight:Math.max(1,Math.round(n*o)),pixelRatio:o}}function Ch(t){let e=Buffer.from(t.toBuffer("image/png"));if(e.length<gl.length||!e.subarray(0,gl.length).equals(gl))throw new Error("Host screenshot renderer did not produce a PNG");return e}function V0(t){return t==="triangle"?G0:t==="fourstar"?q0:B0}function U0(t,e,i,r,n){let o=V0(e);t.beginPath();for(let s=0;s<o.length;s+=2){let a=o[s]*i,l=o[s+1]*r;s===0?t.moveTo(a,l):t.lineTo(a,l)}t.closePath(),t.fillStyle=Yi(n),t.fill()}function kh(t,e,i){let r=e?.matrix,n=r&&typeof r=="object"?[r.a,r.b,r.c,r.d,r.tx,r.ty].map(Number):null,o=e?.pressed?.98:1;if(n&&n.every(Number.isFinite)){let[s,a,l,u,c,f]=n;t.transform(s*o,-a*o,-l*o,u*o,c,i-f);return}t.translate(me(e.left)+me(e.width)/2,i-me(e.bottom)-me(e.height)/2),t.rotate(-me(e.rotationZ)*Math.PI/180),t.scale(o,o)}function H0(t,e,i,r,n,o){if(typeof t.roundRect=="function"){t.roundRect(e,i,r,n,o);return}let s=Math.max(0,Math.min(o,r/2,n/2));t.moveTo(e+s,i),t.arcTo(e+r,i,e+r,i+n,s),t.arcTo(e+r,i+n,e,i+n,s),t.arcTo(e,i+n,e,i,s),t.arcTo(e,i,e+r,i,s),t.closePath()}function Ah(t,e,i,r){let n=Ho(e.bgColor,16777215);t.fillStyle=Yi(n),t.fillRect(-i/2,-r/2,i,r);let o=e.textLayout||Xt(e,i,r),s=o.fontSize,a=Ho(e.fontColor,4294967295),l=e.horizontalAlignment==="Right"?1:e.horizontalAlignment==="Middle"?.5:0,u=e.verticalAlignment==="Bottom"?1:e.verticalAlignment==="Middle"?.5:0;t.save(),t.beginPath(),t.rect(-i/2,-r/2,i,r),t.clip(),t.font=`${s}px ${Gr()}`,t.fillStyle=Yi(a),t.textAlign=l===1?"right":l===.5?"center":"left";let c=e.kind==="textwindow"?e.scroll:null;if(t.textBaseline=c?"top":u===1?"bottom":u===.5?"middle":"top",e.enableOutline){let I=Ho(e.outlineColor,4278190080);t.strokeStyle=Yi(I),t.lineWidth=Math.max(2,s*.12),t.lineJoin="round"}let f=c?-i/2+2+l*c.textWidth:l===0?-i/2+2:l===1?i/2-2:0,h=u===0?-r/2:u===1?r/2:0,m=c?.lines||o.lines,g=c?.lineHeight||o.lineHeight,v=c?-r/2-c.offset+(c.max>0?0:u*(r-c.contentLength)):u===.5?h-(m.length-1)*g/2:u===1?h-(m.length-1)*g:h;for(let I=0;I<m.length;I+=1){let C=v+I*g;c&&(C+g<-r/2||C>r/2)||(e.enableOutline&&t.strokeText(m[I],f,C),t.fillText(m[I],f,C))}t.restore()}function Y0(t,e,i,r){let n=Ir(e.scroll,i,r);if(n)for(let[o,s]of[[n.track,"#263447"],[n.thumb,"#90aecb"]])t.fillStyle=s,t.fillRect(o.x,o.y,o.width,o.height)}function Th(t,e,i,r){t.beginPath(),H0(t,-i/2,-r/2,i,r,6),t.fillStyle="#3268cf",t.fill(),t.strokeStyle="rgba(112,160,255,0.8)",t.lineWidth=1,t.stroke(),e.pressed&&(t.fillStyle="rgba(0,0,0,0.28)",t.fill())}function Rh(t,e,i,r,n){let o=Ho(e.imageColor,4294967295),s=kn(e.imageId,e.imageSource),a=n?.images?.get(s);if(e.primitive==="sprite"&&a){let l=n.imageMetadata?.get(s),u=Sh(l,e.imageType),c=`${s}:${Number(e.imageColor??4294967295)&16777215}:${u}:${u==="Stretch"?`${i}:${r}`:""}`,f=n.tints.get(c);if(!f){let h=u==="Stretch"?_h(a,l,i,r,gn().createCanvas):a;f=bh(h,e.imageColor,gn().createCanvas),n.tints.set(c,f)}t.globalAlpha*=o.a,t.drawImage(f,-i/2,-r/2,i,r);return}if(e.primitive==="missing"||e.primitive==="sprite"){t.fillStyle="rgba(72,34,40,0.36)",t.fillRect(-i/2,-r/2,i,r),t.strokeStyle="#ff7481",t.lineWidth=1,t.strokeRect(-i/2+.5,-r/2+.5,Math.max(0,i-1),Math.max(0,r-1));return}if(e.primitive==="circle"){t.beginPath(),t.ellipse(0,0,i/2,r/2,0,0,Math.PI*2),t.fillStyle=Yi(o),t.fill();return}if(e.primitive==="ring"){t.beginPath(),t.ellipse(0,0,Math.max(1,i/2-3.5),Math.max(1,r/2-3.5),0,0,Math.PI*2),t.strokeStyle=Yi(o),t.lineWidth=7,t.stroke();return}if(e.primitive==="triangle"||e.primitive==="fourstar"||e.primitive==="fivestar"){U0(t,e.primitive,i,r,o);return}t.fillStyle=Yi(o),t.fillRect(-i/2,-r/2,i,r)}function X0(t,e,i,r){let n=Math.max(0,me(e.sourceWidth,me(e.width))),o=Math.max(0,me(e.sourceHeight,me(e.height)));t.save();for(let s of e.clipPolygons||[])t.beginPath(),s.forEach((a,l)=>l?t.lineTo(a.x,i-a.y):t.moveTo(a.x,i-a.y)),t.closePath(),t.clip();if(kh(t,e,i),e.kind==="textbox"||e.kind==="textwindow")Ah(t,e,n,o);else if(e.kind==="button")Th(t,e,n,o);else if(e.kind!=="grid"){let s=ml(e,n,o);s&&(t.beginPath(),t.rect(s.x,s.y,s.width,s.height),t.clip()),Rh(t,e,n,o,r)}Y0(t,e,n,o),t.restore()}function Oh(t,e,i,{checker:r=!1}={}){if(r){t.fillStyle="#28313e",t.fillRect(0,0,e,i);let o=16;for(let s=0;s<i;s+=o)for(let a=0;a<e;a+=o)(a/o+s/o)%2===0&&(t.fillStyle="rgba(255,255,255,0.04)",t.fillRect(a,s,o,o));t.strokeStyle="#40b8cf",t.lineWidth=1,t.strokeRect(.5,.5,e-1,i-1);return}let n=t.createRadialGradient(e/2,i*.45,8,e/2,i/2,Math.max(e,i)*.72);n.addColorStop(0,"#123a6b"),n.addColorStop(.72,"#061934"),n.addColorStop(1,"#071426"),t.fillStyle=n,t.fillRect(0,0,e,i)}function W0(t,e){return{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,tx:t.a*e.tx+t.c*e.ty+t.tx,ty:t.b*e.tx+t.d*e.ty+t.ty}}function Ih(t){let e=t?.matrix;return!e||typeof e!="object"?{a:1,b:0,c:0,d:1,tx:0,ty:0}:{a:me(e.a,1),b:me(e.b),c:me(e.c),d:me(e.d,1),tx:me(e.tx),ty:me(e.ty)}}function K0(t){let e=Array.isArray(t?.nodes)?t.nodes:[],i=new Map;for(let s of e){if(!s||s.id===void 0||s.id===null)continue;let a=s.parent==null?"":String(s.parent),l=i.get(a);l?l.push(s):i.set(a,[s])}for(let s of i.values())s.sort((a,l)=>me(a.z)-me(l.z));let r=[];function n(s,a,l,u){if(!j0.has(s.kind))return;let c=Math.abs(me(s.sourceWidth)*Math.hypot(a.a,a.b)),f=Math.abs(me(s.sourceHeight)*Math.hypot(a.c,a.d));r.push({...s,left:a.tx-c/2,bottom:a.ty-f/2,width:c,height:f,rotationZ:Math.atan2(a.b,a.a)*180/Math.PI,matrix:{a:a.a,b:a.b,c:a.c,d:a.d,tx:a.tx,ty:a.ty},...l.length?{clipPolygons:l}:{},...u.length?{masks:u}:{}})}function o(s,a,l=null,u=[],c=[]){let f=i.get(s)||[];for(let h=f.length-1;h>=0;h-=1){let m=f[h],g=a?W0(a,Ih(m)):Ih(m),v=u;if(m.clipToParent&&a&&l){let E=l.sourceWidth/2,D=l.sourceHeight/2;v=[...u,[[-E,-D],[E,-D],[E,D],[-E,D]].map(([S,z])=>({x:a.a*S+a.c*z+a.tx,y:a.b*S+a.d*z+a.ty}))]}let I=Fo(m,g),C=I?[...c,I]:c;m.kind!=="grid"&&n(m,g,v,C),o(String(m.id),g,m,v,C),m.kind==="grid"&&n(m,g,v,C)}}return o("",null),r}function Nh(t,e,i,r={}){return Q0(K0(t),e,i,r)}function J0(t,e,i){if(!(t.width>0&&t.height>0)||!Ut(t.matrix))return null;let r=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([l,u])=>{let c=tt(t.matrix,l*t.width/2,u*t.height/2);return{x:c.x*i.pixelRatio,y:(i.height-c.y)*i.pixelRatio}}),n=Math.max(e.x,Math.floor(Math.min(...r.map(l=>l.x)))),o=Math.max(e.y,Math.floor(Math.min(...r.map(l=>l.y)))),s=Math.min(e.x+e.canvas.width,Math.ceil(Math.max(...r.map(l=>l.x)))),a=Math.min(e.y+e.canvas.height,Math.ceil(Math.max(...r.map(l=>l.y))));return s>n&&a>o?{x:n,y:o,width:s-n,height:a-o}:null}function Z0(t,e,i,r){let n=e.canvas.width,o=e.canvas.height,s=e.ctx.getImageData(0,0,n,o).data,a=e.x-t.x,l=e.y-t.y,u=t.ctx.getImageData(a,l,n,o),c=u.data,f=Ut(i.matrix);for(let h=0;h<o;h++){let m=r.height-(e.y+h+.5)/r.pixelRatio;for(let g=0;g<n;g++){let v=(h*n+g)*4;if(!s[v+3])continue;let I=(e.x+g+.5)/r.pixelRatio,C=f.a*I+f.c*m+f.tx,E=f.b*I+f.d*m+f.ty,D=Vd(C,E,i),S=Math.round(s[v+3]*D)/255;if(!S)continue;let z=c[v+3]/255,L=S+z*(1-S);for(let j=0;j<3;j++)c[v+j]=Math.round((s[v+j]*S+c[v+j]*z*(1-S))/L);c[v+3]=Math.round(L*255)}}t.ctx.save(),t.ctx.setTransform(1,0,0,1,0,0),t.ctx.putImageData(u,a,l),t.ctx.restore()}function Ph(t,e,i,r){for(let n of e){if(n.item){X0(t.ctx,n.item,i.height,r);continue}let o=J0(n.mask,t,i);if(!o)continue;let s=gn().createCanvas(o.width,o.height),a=s.getContext("2d");a.setTransform(i.pixelRatio,0,0,i.pixelRatio,-o.x,-o.y);let l={canvas:s,ctx:a,x:o.x,y:o.y};Ph(l,n.children,i,r),Z0(t,l,n.mask,i)}}function Q0(t,e,i,r={}){let{createCanvas:n}=gn(),o=Eh(e,i,r.scale),s=n(o.pixelWidth,o.pixelHeight),a=s.getContext("2d");a.scale(o.pixelRatio,o.pixelRatio),r.background!=="transparent"&&Oh(a,o.width,o.height);let l=Array.isArray(t)?t:[],u={images:r.images,imageMetadata:r.imageMetadata,tints:new Map};return Ph({canvas:s,ctx:a,x:0,y:0},Ud(l),o,u),{data:Ch(s),width:o.width,height:o.height,pixelWidth:o.pixelWidth,pixelHeight:o.pixelHeight}}function e1(t){if(t.renderMatrix){let e=tt(t.renderMatrix,t.centerX,t.centerY);return{kind:t.kind,width:t.width,height:t.height,matrix:{...t.renderMatrix,tx:e.x,ty:e.y}}}return{kind:t.kind,left:me(t.renderLeft,t.left),bottom:me(t.renderBottom,t.bottom),width:Math.max(0,me(t.renderWidth,t.width)),height:Math.max(0,me(t.renderHeight,t.height)),rotationZ:me(t.renderRotationZ,t.rotationZ)}}function Uo(t,e,i){let r=String(e||"");if(!r)return;t.font=`10px ${Gr()}`,t.textAlign="center",t.textBaseline="middle";let n=t.measureText(r),o=Math.min(i-4,Math.max(24,n.width+8)),s=16;t.fillStyle="rgba(17,25,37,0.66)",t.fillRect(-o/2,-s/2,o,s),t.fillStyle="#e7edf5",t.fillText(r,0,0)}function t1(t,e,i,r,n){let o=e1(e);if(o.width<=0||o.height<=0)return;t.save(),kh(t,o,i);let s=-o.width/2,a=-o.height/2;if(e.kind==="image"){t.save();let l=Math.max(0,me(e.width,o.width)),u=Math.max(0,me(e.height,o.height));t.scale(l?o.width/l:1,u?o.height/u:1);let c=e.enableFill?ml(e,l,u):null;c&&(t.beginPath(),t.rect(c.x,c.y,c.width,c.height),t.clip()),Rh(t,e,l,u,n),t.restore()}else if(e.kind==="textbox"||e.kind==="textwindow")Ah(t,e,o.width,o.height);else if(e.kind==="button")Th(t,e,o.width,o.height),Uo(t,e.name||jo.button,o.width);else if(e.kind==="cursor")t.setLineDash([6,4]),t.strokeStyle="rgba(74,142,181,0.7)",t.fillStyle="rgba(74,142,181,0.1)",t.fillRect(s,a,o.width,o.height),t.strokeRect(s,a,o.width,o.height),Uo(t,e.name||jo.cursor,o.width);else if(e.kind==="grid"){t.strokeStyle="rgba(106,146,189,0.55)",t.strokeRect(s,a,o.width,o.height),t.beginPath();for(let l=20;l<o.width;l+=20)t.moveTo(s+l,a),t.lineTo(s+l,a+o.height);for(let l=20;l<o.height;l+=20)t.moveTo(s,a+l),t.lineTo(s+o.width,a+l);t.stroke(),Uo(t,e.name||jo.grid,o.width)}else e.kind!=="container"&&e.kind!=="server-container"?(t.setLineDash(e.kind==="reference"||e.kind==="animation"||e.kind==="fullscreen"?[4,4]:[]),t.strokeStyle="rgba(203,218,237,0.55)",t.strokeRect(s,a,o.width,o.height),Uo(t,e.name||jo[e.kind]||e.kind,o.width)):(t.strokeStyle="rgba(78,165,230,0.42)",t.strokeRect(s,a,o.width,o.height));e.id===r&&e.kind!=="container"&&e.kind!=="server-container"&&(t.setLineDash([]),t.strokeStyle="#61b9ff",t.lineWidth=2,t.strokeRect(s,a,o.width,o.height)),t.restore()}function Mh(t,e={}){let{createCanvas:i}=gn(),r=t?.canvas||{},n=Eh(r.width||1600,r.height||900,e.scale),o=i(n.pixelWidth,n.pixelHeight),s=o.getContext("2d");s.scale(n.pixelRatio,n.pixelRatio),Oh(s,n.width,n.height,{checker:!0});let a=Array.isArray(t?.boxes)?t.boxes:[],l=t?.selectedId,u={images:e.images,imageMetadata:e.imageMetadata,tints:new Map};for(let c of a)!c||c.kind==="server-container"||c.visible===!1||t1(s,c,n.height,l,u);return{data:Ch(o),page:t?.asset?.type==="client-control-template"?"UI\u63A7\u4EF6-\u5BA2\u6237\u7AEF":"UI \u7F16\u8F91",width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight}}import{closeSync as i1,existsSync as Yo,openSync as r1,opendirSync as n1,readSync as o1,realpathSync as Tr,statSync as Dh}from"node:fs";import{basename as s1,dirname as Fh,isAbsolute as vl,join as a1,relative as zh,resolve as bn}from"node:path";var l1="qxqy-simulator-save",$h=new Set(["node_modules",".git","dist",".dsh","coverage"]),yn=50,Lh=4096,yl=(t,e)=>{let i=Number(process.env[t]);return Number.isSafeInteger(i)&&i>0?i:e},u1=()=>({entries:yl("QXQY_SCAN_ENTRY_LIMIT",1e4),directories:yl("QXQY_SCAN_DIR_LIMIT",1e3),depth:yl("QXQY_SCAN_DEPTH_LIMIT",8)});function bl(t=""){let e=bn(String(t||process.cwd()));if(!Yo(e))throw new Error(`workspace does not exist: ${e}`);if(!Dh(e).isDirectory())throw new Error(`workspace is not a directory: ${e}`);return Tr(e)}function vn(t,e,i=!1){let r=zh(t,e);if(!i&&!r||r.startsWith("..")||vl(r))throw new Error("path must stay inside the configured workspace");return r}function Ii(t,e){let i=String(e||"").trim();if(!i||vl(i))throw new Error("path must be a non-empty workspace-relative path");let r=Tr(bn(t)),n=bn(r,i);if(vn(r,n),!Yo(n))throw new Error(`file does not exist: ${i}`);let o=Tr(n);return vn(r,o),o}function pt(t,e){let i=String(e||"").trim();if(!i||vl(i))throw new Error("path must be a non-empty workspace-relative path");let r=Tr(bn(t)),n=bn(r,i);vn(r,n);let o=Fh(n);for(;!Yo(o);){let s=Fh(o);if(s===o)throw new Error("unable to resolve output directory");o=s}return vn(r,Tr(o),!0),Yo(n)&&vn(r,Tr(n)),n}function c1(t,e=Lh){let i=Buffer.alloc(e),r=r1(t,"r");try{let n=o1(r,i,0,e,0);return i.subarray(0,n).toString("utf8")}finally{i1(r)}}function Gh(t,e,i,r,n){let o=n.limits;if(r>o.depth){n.depthLimitedDirectories+=1;return}if(n.scannedDirectories>=o.directories){n.directoryLimitReached=!0;return}let s;try{n.scannedDirectories+=1,s=n1(t)}catch{n.unreadableEntries+=1;return}try{let a;for(;a=s.readSync();){if(n.scannedEntries>=o.entries){n.entryLimitReached=!0;return}if(n.scannedEntries+=1,a.name.startsWith(".")||a.isDirectory()&&$h.has(a.name)){n.skippedEntries+=1,a.isDirectory()&&(n.skippedDirectories+=1);continue}let l=a1(t,a.name);if(a.isDirectory()){if(Gh(l,e,i,r+1,n),n.entryLimitReached||n.directoryLimitReached)return;continue}if(!(!a.isFile()||!/\.json$/i.test(a.name))){n.scannedJsonFiles+=1;try{let u=Dh(l),c=c1(l);if(!c.includes(l1))continue;let f=c.match(/"name"\s*:\s*("(?:\\.|[^"\\])*")/)?.[1],h=s1(a.name,".json");if(f)try{h=JSON.parse(f)||h}catch{}i.push({path:zh(e,l).replaceAll("\\","/"),name:h,bytes:u.size,mtime:u.mtimeMs})}catch{n.unreadableEntries+=1}}}}catch{n.unreadableEntries+=1}finally{try{s.closeSync()}catch{n.unreadableEntries+=1}}}function Xo(t){let e=bl(t),i=[],r={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:yn,headBytes:Lh,...u1()},policy:{excludedDirectories:[...$h],hiddenEntries:!1,symlinks:!1,validatesJson:!1}};return Gh(e,e,i,0,r),i.sort((n,o)=>o.mtime-n.mtime||n.path.localeCompare(o.path)),r.matchedArchives=i.length,i.length>yn&&r.warnings.push(`\u53D1\u73B0 ${i.length} \u4E2A\u5B58\u6863\uFF0C\u4EC5\u663E\u793A\u4FEE\u6539\u65F6\u95F4\u6700\u65B0\u7684 ${yn} \u4E2A\uFF1B\u5176\u4ED6\u5B58\u6863\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u3002`),(r.entryLimitReached||r.directoryLimitReached)&&r.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u8FBE\u5230\u626B\u63CF\u4E0A\u9650\uFF08${r.limits.entries} \u9879 / ${r.limits.directories} \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`),r.depthLimitedDirectories&&r.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u8DF3\u8FC7 ${r.depthLimitedDirectories} \u4E2A\u8D85\u8FC7 ${r.limits.depth} \u5C42\u7684\u76EE\u5F55\uFF1B\u53EF\u901A\u8FC7\u6307\u5B9A\u8DEF\u5F84\u6253\u5F00\u5176\u4E2D\u7684\u5B58\u6863\u3002`),r.skippedEntries&&r.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"),r.unreadableEntries&&r.warnings.push(`\u81EA\u52A8\u53D1\u73B0\u65E0\u6CD5\u8BFB\u53D6 ${r.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`),r.truncated=i.length>yn||r.entryLimitReached||r.directoryLimitReached||r.depthLimitedDirectories>0,{bound:!0,workspace:e,archives:i.slice(0,yn),discovery:r}}import{readFileSync as f1}from"node:fs";import{homedir as d1}from"node:os";import{join as h1}from"node:path";var p1={"zh-cn":"LanguageChs",chs:"LanguageChs","zh-tw":"LanguageCht",cht:"LanguageCht",en:"LanguageEng","en-us":"LanguageEng",eng:"LanguageEng",ja:"LanguageJpn","ja-jp":"LanguageJpn",jp:"LanguageJpn",ko:"LanguageKor","ko-kr":"LanguageKor",kr:"LanguageKor",fr:"LanguageFra",fra:"LanguageFra",de:"LanguageDeu",deu:"LanguageDeu",es:"LanguageSpa",spa:"LanguageSpa",pt:"LanguagePor",por:"LanguagePor",ru:"LanguageRus",rus:"LanguageRus",th:"LanguageTha",tha:"LanguageTha",vi:"LanguageVie",vie:"LanguageVie",id:"LanguageInd",ind:"LanguageInd",tr:"LanguageTur",tur:"LanguageTur",it:"LanguageIta",ita:"LanguageIta"};function m1(t){let i=[...String(t||"").matchAll(/Request to set language:([A-Za-z0-9_-]+)/g)].at(-1)?.[1]?.toLowerCase();return p1[i]||null}function g1(){return h1(d1(),"AppData","LocalLow","miHoYo","\u539F\u795E","output_log.txt")}function qh(t=g1()){try{return m1(f1(t,"utf8"))}catch{return null}}import{existsSync as xl,lstatSync as y1,mkdirSync as Bh,readFileSync as Wo,readdirSync as v1,realpathSync as jh,renameSync as b1,rmSync as w1,statSync as Zo,writeFileSync as Vh}from"node:fs";import{createHash as S1,randomUUID as Uh}from"node:crypto";import{homedir as x1}from"node:os";import{basename as _1,dirname as Ko,isAbsolute as I1,join as Jo,relative as E1}from"node:path";var Tt=t=>S1("sha256").update(t).digest("hex"),wl=t=>xl(t)?Tt(Wo(t)):null,Sl=(t,e)=>{let i=E1(t,e);return!I1(i)&&i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)};function Hh(t,e){let i=pt(t,e),r=i;for(;r!==t;){try{if(y1(r).isSymbolicLink())throw new Error("\u5B9E\u673A\u76EE\u6807\u4E0D\u80FD\u5305\u542B\u7B26\u53F7\u94FE\u63A5\u6216\u76EE\u5F55\u8054\u63A5")}catch(n){if(n.code!=="ENOENT")throw n}r=Ko(r)}if(xl(i)&&!Zo(i).isFile())throw new Error("\u5B9E\u673A\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6");return i}function Yh(t=Jo(x1(),"AppData","LocalLow","miHoYo","\u539F\u795E","BeyondLocal")){let e=r=>{try{return v1(r,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^\d+$/.test(n.name)).map(n=>n.name)}catch{return[]}},i=[];for(let r of e(t)){let n=Jo(t,r,"Beyond_Local_Save_Level");for(let o of e(n)){let s=Jo(n,o,"external_lua_file","default_import_file");xl(s)&&Zo(s).isDirectory()&&i.push({uid:r,editorId:o,path:s})}}return{candidates:i}}var Qo=class{constructor(e){this.controller=e,this.plan=null,this.lastResult=null}preview(){let e=this.controller,i=e.studio.archiveData(),r=Mr(i.scriptSync);if(!r)throw new Error("\u8BF7\u5148\u914D\u7F6E\u5B9E\u673A\u811A\u672C\u76EE\u5F55");let n=jh(e.activeWorkspacePath()),o=jh(r.clientImportRoot);if(!Zo(o).isDirectory())throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u4E0D\u5B58\u5728");let s=r.workspaceDir?Ii(n,r.workspaceDir):n;if(!Zo(s).isDirectory())throw new Error("\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E0D\u5B58\u5728");if(Sl(s,o)||Sl(o,s))throw new Error("\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E0E\u5B9E\u673A\u76EE\u5F55\u4E0D\u80FD\u91CD\u53E0");let a=new Map,l=i.assets.scripts.map(c=>{let f={id:c.id,path:c.path,sourceKind:c.source.trim()?"\u5B58\u6863\u6E90\u7801":"\u5DE5\u4F5C\u533A\u6587\u4EF6"};try{let h=_n(c.path);if(!/\.lua$/i.test(h))throw new Error("\u811A\u672C\u8DEF\u5F84\u5FC5\u987B\u4EE5 .lua \u7ED3\u5C3E");let m=r.workspaceDir?`${r.workspaceDir}/`:"";if(!h.startsWith(m))throw new Error("\u811A\u672C\u4E0D\u5728\u6240\u914D\u7F6E\u7684\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E2D");let g=[r.clientSubdir,h.slice(m.length)].filter(Boolean).join("/"),v=Hh(o,g),I=v.toLowerCase();a.set(I,(a.get(I)||0)+1);let C=null,E="";try{C=Wo(Ii(n,h),"utf8")}catch(z){E=z.message}if(!c.source.trim()&&C===null)throw new Error(E);let D=c.source.trim()?c.source:C,S=wl(v);return{...f,target:v,targetRelative:g,source:D,diskSource:C,diskError:E,sourceMismatch:!!(c.source.trim()&&C!==null&&c.source!==C),beforeSource:S===null?"":Wo(v,"utf8"),beforeHash:S,sourceHash:Tt(D),status:S===null?"\u65B0\u589E":S===Tt(D)?"\u672A\u53D8\u5316":"\u8986\u76D6"}}catch(h){return{...f,status:"\u9519\u8BEF",error:h.message}}});for(let c of l)c.target&&a.get(c.target.toLowerCase())>1&&(c.status="\u9519\u8BEF",c.error="\u591A\u4E2A\u811A\u672C\u6620\u5C04\u5230\u540C\u4E00\u76EE\u6807\u6587\u4EF6");let u=Tt(JSON.stringify({archive:i,workspace:n,root:o,rows:l}));return this.plan={id:Uh(),fingerprint:u,root:o,workspace:n,rows:l,pendingGuidChanges:i.controlGuidChanges.length,createdAt:new Date().toISOString()},this.plan}apply({planId:e,scriptIds:i,confirmed:r}){let n=this.plan;if(r!==!0||!n||n.id!==e)throw new Error("\u8BF7\u5148\u68C0\u67E5\u5DEE\u5F02\u5E76\u786E\u8BA4\u672C\u6B21\u590D\u5236");let o=this.preview();if(this.plan=null,o.fingerprint!==n.fingerprint)throw new Error("\u5185\u5BB9\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");if(n.pendingGuidChanges)throw new Error("\u8BF7\u5148\u6838\u5BF9\u5E76\u786E\u8BA4\u63A7\u4EF6\u7D22\u5F15\u7684 Lua \u5F15\u7528\u53D8\u66F4");if(!Array.isArray(i)||!i.length||new Set(i).size!==i.length)throw new Error("\u8BF7\u9009\u62E9\u8981\u590D\u5236\u7684\u811A\u672C");let s=i.map(c=>{let f=n.rows.find(h=>h.id===c);if(!f||f.error||f.status==="\u672A\u53D8\u5316")throw new Error("\u6240\u9009\u811A\u672C\u4E0D\u80FD\u590D\u5236\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");return f});this.controller.assertSavedArchive();let a=`.qxqy-script-sync-backups/${n.id}`,l=pt(n.workspace,a);if(Sl(n.root,l))throw new Error("\u5907\u4EFD\u76EE\u5F55\u4E0D\u80FD\u4F4D\u4E8E\u5B9E\u673A\u811A\u672C\u76EE\u5F55\u4E2D");let u=[];for(let c of s){let f="";try{let h=Hh(n.root,c.targetRelative);if(wl(h)!==c.beforeHash)throw new Error("\u76EE\u6807\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");if(c.beforeHash!==null){let m=pt(n.workspace,`${a}/${c.targetRelative}`);Bh(Ko(m),{recursive:!0}),Vh(m,Wo(h),{flag:"wx"})}if(Bh(Ko(h),{recursive:!0}),f=Jo(Ko(h),`.${_1(h)}.${Uh()}.tmp`),Vh(f,c.source,{flag:"wx"}),wl(h)!==c.beforeHash)throw new Error("\u76EE\u6807\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");b1(f,h),u.push({id:c.id,target:h,status:"\u6210\u529F"})}catch(h){u.push({id:c.id,target:c.target,status:"\u5931\u8D25",error:h.message})}finally{f&&w1(f,{force:!0})}}return this.lastResult={completed:u.every(c=>c.status==="\u6210\u529F"),at:new Date().toISOString(),backupRoot:l,results:u},this.lastResult}};import{createHash as C1,randomUUID as k1}from"node:crypto";import{mkdir as A1,open as T1,readFile as R1,rename as O1,rm as _l,stat as N1,writeFile as P1}from"node:fs/promises";import{homedir as Il}from"node:os";import{join as Rr,resolve as M1}from"node:path";import{setTimeout as F1}from"node:timers/promises";var El=t=>C1("sha256").update(t).digest("hex");function es(t){return Rr(process.platform==="win32"?process.env.LOCALAPPDATA||Rr(Il(),"AppData","Local"):process.platform==="darwin"?Rr(Il(),"Library","Caches"):process.env.XDG_CACHE_HOME||Rr(Il(),".cache"),"beyond-simulator",t)}var Ei=class{constructor({cacheDir:e,source:i,version:r,extension:n,accepts:o,fetch:s=globalThis.fetch,timeout:a=12e3}){this.directory=Rr(M1(e),r,El(i).slice(0,12)),Object.assign(this,{source:i,extension:n,accepts:o,fetcher:s,timeout:a}),this.pending=new Map,this.failures=new Map,this.active=0,this.waiters=[]}async limited(e){this.active>=4?await new Promise(i=>this.waiters.push(i)):this.active++;try{return await e()}finally{let i=this.waiters.shift();i?i():this.active--}}async download(e,i,r,n){let o=await this.fetcher(new URL(e,this.source),{signal:r,redirect:"error",cache:n?"no-cache":"default"});if(!o.ok)throw Object.assign(new Error(`Asset source returned HTTP ${o.status}`),{status:o.status});if(Number(o.headers.get("content-length"))>i)throw new Error("Asset response too large");let s=[],a=0;for await(let l of o.body){if(a+=l.length,a>i)throw new Error("Asset response too large");s.push(l)}return Buffer.concat(s)}async cached(e){try{let i=await R1(e);return{data:i,...await this.decode(i),etag:`"${El(i)}"`}}catch(i){if(i.code==="ENOENT")return null;if(i.code==="EACCES"||i.code==="EPERM")throw i;return null}}async load(e,i=!1){let r=Rr(this.directory,`${e}.${this.extension}`),n=!i&&await this.cached(r);if(n)return n;await A1(this.directory,{recursive:!0});let o=`${r}.lock`,s=Date.now()+3e4,a;for(;!a;)try{a=await T1(o,"wx")}catch(u){if(u.code!=="EEXIST")throw u;let c=!i&&await this.cached(r);if(c)return c;try{Date.now()-(await N1(o)).mtimeMs>6e4&&await _l(o,{force:!0})}catch(f){if(f.code!=="ENOENT")throw f}if(Date.now()>s)throw new Error("Timed out waiting for asset cache writer");await F1(80)}let l=`${r}.${k1()}.tmp`;try{let u=!i&&await this.cached(r);if(u)return u;let c=new AbortController,f=setTimeout(()=>c.abort(),this.timeout),h;try{h=await this.produce(e,c.signal,i)}finally{clearTimeout(f),c.abort()}let m=await this.decode(h);return await P1(l,h,{flag:"wx"}),await O1(l,r),{data:h,...m,etag:`"${El(h)}"`}}finally{try{await _l(l,{force:!0})}finally{await a.close(),await _l(o,{force:!0})}}}get(e,{refresh:i=!1}={}){if(!this.accepts(e))return Promise.reject(Object.assign(new Error("Asset ID is not in the preview allowlist"),{status:404}));if(this.pending.has(e))return this.pending.get(e);let r=this.failures.get(e);if(!i&&r&&r.until>Date.now())return Promise.reject(r.error);let n=this.limited(()=>this.load(e,i)).then(o=>(this.failures.delete(e),o),o=>{throw i||this.failures.set(e,{until:Date.now()+6e4,error:o}),o}).finally(()=>this.pending.delete(e));return this.pending.set(e,n),n}async refresh(e){if(!this.accepts(e))throw Object.assign(new Error("Asset ID is not in the preview allowlist"),{status:404});return await this.pending.get(e)?.catch(()=>{}),this.failures.delete(e),this.get(e,{refresh:!0})}};import{createHash as D1}from"node:crypto";import{createCanvas as z1,loadImage as Xh}from"@napi-rs/canvas";var ts=class extends Ei{constructor({cacheDir:e,source:i=En,fetch:r=globalThis.fetch}){super({cacheDir:e,source:i,fetch:r,version:"border-v1",extension:"json",accepts:n=>ni(n)})}decode(e){let i=JSON.parse(e.toString("utf8"));if(i!==null&&(typeof i!="object"||Array.isArray(i)))throw new Error("Invalid image metadata");let r=xh(i);return{raw:i,meta:r}}async produce(e,i,r){try{return await this.download(`border/${e}.json`,128*1024,i,r)}catch(n){if(n.status===404)return Buffer.from("null");throw n}}};var kl=20*1024*1024,$1=Buffer.from("89504e470d0a1a0a","hex");function Wh(t,e){return e.throwIfAborted(),new Promise((i,r)=>{let n=()=>r(e.reason);e.addEventListener("abort",n,{once:!0}),t.then(i,r).finally(()=>e.removeEventListener("abort",n))})}function L1(){return process.env.QXQY_IMAGE_CACHE_DIR||es("images")}function Cl(t){if(t.length<24||t.length>kl||!t.subarray(0,8).equals($1))throw new Error("Invalid sprite PNG");let e=t.readUInt32BE(16),i=t.readUInt32BE(20);if(!e||!i||e>8192||i>8192||e*i>16777216)throw new Error("Sprite PNG exceeds pixel limit")}var Al=class t extends Ei{constructor({cacheDir:e=L1(),fetch:i=globalThis.fetch,source:r,imageSource:n="StaticReference"}={}){let o=st(n);if(!["StaticReference","Prefab"].includes(o))throw new Error(`Unsupported image source: ${o}`);super({cacheDir:e,fetch:i,source:r||(o==="Prefab"?Ul:En),version:o==="Prefab"?Fr:os,extension:"png",accepts:s=>ni(s,o)}),this.imageSource=o,this.cacheDir=e,this.prefabStore=null,this.metadataStore=null}forSource(e){let i=st(e);if(i===this.imageSource)return this;if(i==="Prefab"&&this.imageSource==="StaticReference")return this.prefabStore||=new t({cacheDir:this.cacheDir,imageSource:"Prefab",fetch:(...r)=>this.fetcher(...r)});throw Object.assign(new Error(`Unsupported image source: ${i}`),{status:404})}get(e,{imageSource:i=this.imageSource,...r}={}){try{let n=this.forSource(i);return n===this?super.get(e,r):n.get(e,r)}catch(n){return Promise.reject(n)}}refresh(e,{imageSource:i=this.imageSource}={}){try{let r=this.forSource(i);return r===this?super.refresh(e):r.refresh(e)}catch(r){return Promise.reject(r)}}async decode(e){return Cl(e),{image:await Xh(e)}}metadata(e,{imageSource:i=this.imageSource,refresh:r=!1}={}){try{let n=this.forSource(i);if(n!==this)return n.metadata(e,{refresh:r});if(!this.accepts(e))throw Object.assign(new Error("Image ID is not in the preview allowlist"),{status:404});return this.imageSource==="Prefab"?Promise.resolve({meta:null,raw:null}):(this.metadataStore||=new ts({cacheDir:this.cacheDir,source:this.source,fetch:(...o)=>this.fetcher(...o)}),r?this.metadataStore.refresh(e):this.metadataStore.get(e))}catch(n){return Promise.reject(n)}}async produce(e,i,r){if(this.imageSource==="Prefab"){let l=await this.download(`sprite/${e}.png`,kl,i,r);Cl(l);let u=In(e);if(l.readUInt32BE(16)!==u||l.readUInt32BE(20)!==u)throw new Error("Prefab PNG does not match catalog dimensions");return l}let[n,o]=await Promise.all([this.download(`sprite/${e}.png`,kl,i,r),this.metadata(e,{refresh:r})]);Cl(n);let s=await Xh(n),a=o.raw?vh(s,o.raw,z1):s;return o.raw?Buffer.from(a.toBuffer("image/png")):n}async prepare(e,i){let r=new Map,n=new Map,o=[],s=[...new Map((e||[]).filter(c=>c.kind==="image"&&c.visible!==!1&&ni(c.imageId,c.imageSource)).map(c=>[kn(c.imageId,c.imageSource),{imageId:c.imageId,imageSource:st(c.imageSource)}])).entries()];i?.throwIfAborted();let a=AbortSignal.timeout(45e3),l=i?AbortSignal.any([i,a]):a,u=0;await Promise.all(Array.from({length:Math.min(4,s.length)},async()=>{for(;u<s.length&&!l.aborted;){let[c,f]=s[u++];try{let h=await Wh(this.get(f.imageId,f),l);r.set(c,h.image);let m=await Wh(this.metadata(f.imageId,f),l);n.set(c,m.meta)}catch(h){o.push({...f,error:h.message})}}}));for(let[,c]of s.slice(u))o.push({...c,error:"Image preparation timed out"});return i?.throwIfAborted(),{images:r,imageMetadata:n,warnings:o}}},G1;function Tl(){return G1||=new Al}async function Kh(t,e,i=Tl()){let r=new URL(t.url,"http://localhost");if(r.pathname!==Cn.slice(0,-1)&&!r.pathname.startsWith(Cn))return!1;try{if(!["GET","HEAD"].includes(t.method))throw Object.assign(new Error("GET or HEAD required"),{status:405});let n=r.pathname.match(new RegExp(`^${Cn}(${os}|${Fr})/([0-9]+)\\.(png|json)$`));if(!n)throw Object.assign(new Error("Unknown image resource"),{status:404});let o={imageSource:n[1]===Fr?"Prefab":"StaticReference"};if(n[3]==="json"){let{meta:l}=await i.metadata(Number(n[2]),o),u=JSON.stringify(l),c=`"${D1("sha256").update(u).digest("hex")}"`,f={"content-type":"application/json; charset=utf-8","cache-control":"private, max-age=43200",etag:c,"x-content-type-options":"nosniff"};return t.headers["if-none-match"]===c?(e.writeHead(304,f),e.end()):(e.writeHead(200,f),e.end(t.method==="HEAD"?void 0:u)),!0}let s=await i.get(Number(n[2]),o),a={"content-type":"image/png","cache-control":"private, max-age=43200",etag:s.etag,"x-content-type-options":"nosniff"};t.headers["if-none-match"]===s.etag?(e.writeHead(304,a),e.end()):(e.writeHead(200,{...a,"content-length":s.data.length}),e.end(t.method==="HEAD"?void 0:s.data))}catch(n){e.writeHead(n.status||502,{"content-type":"text/plain; charset=utf-8","cache-control":"no-store","x-content-type-options":"nosniff"}),e.end(t.method==="HEAD"?void 0:n.message)}return!0}import{existsSync as q1,mkdirSync as Jh,readFileSync as B1,renameSync as j1,rmSync as V1,writeFileSync as Rl}from"node:fs";import{randomUUID as ep}from"node:crypto";import{dirname as Zh,join as U1}from"node:path";function Qh(t,e){let i=`${t}.${ep()}.tmp`;try{Rl(i,e,{flag:"wx"}),j1(i,t)}finally{V1(i,{force:!0})}}var is=class{constructor(e){this.controller=e,this.plan=null}inspect(){let e=this.controller.studio.archiveData(),i=e.controlGuidChanges||[],r=e.assets.scripts,n=[],o=new Map;i.length||n.push("\u6CA1\u6709\u5F85\u540C\u6B65\u7684\u7D22\u5F15\u53D8\u66F4");try{o=hh(i)}catch(c){n.push(c.message)}let s=this.controller.activeWorkspacePath();s||n.push("\u8BF7\u5148\u7ED1\u5B9A\u5DE5\u4F5C\u533A\uFF0C\u4EE5\u4FDD\u5B58\u540C\u6B65\u524D\u7684\u5907\u4EFD");let a=new Map,l=r.map(c=>{let f={id:c.id,path:c.path,source:c.source,file:"",fileBefore:null,edits:[],issues:[]};if(c.path)try{if(!s)throw new Error("\u5DE5\u4F5C\u533A\u5C1A\u672A\u7ED1\u5B9A\uFF0C\u65E0\u6CD5\u6838\u5BF9\u9879\u76EE\u811A\u672C\u6587\u4EF6");let m=pt(s,c.path);if(q1(m)){f.file=Ii(s,c.path);let g=B1(f.file);if(f.fileBefore=g.toString("utf8"),!g.equals(Buffer.from(f.fileBefore)))throw new Error("\u9879\u76EE\u811A\u672C\u4E0D\u662F\u6709\u6548 UTF-8\uFF0C\u8BF7\u4EA4\u7ED9 AI \u6838\u5BF9\u7F16\u7801");if(c.source.trim()&&f.fileBefore!==c.source)throw new Error("\u5B58\u6863\u6E90\u7801\u4E0E\u9879\u76EE\u6587\u4EF6\u4E0D\u540C\uFF0C\u8BF7\u4EA4\u7ED9 AI \u5408\u5E76\u540E\u540C\u6B65");if(c.source.trim()||(f.source=f.fileBefore),a.has(f.file))throw new Error("\u591A\u4E2A\u811A\u672C\u6307\u5411\u540C\u4E00\u4E2A\u9879\u76EE\u6587\u4EF6\uFF0C\u8BF7\u4EA4\u7ED9 AI \u6838\u5BF9");a.set(f.file,c.id)}}catch(m){f.issues.push({line:0,reason:m.message})}!f.source.trim()&&c.path&&!f.file&&f.issues.push({line:0,reason:"\u627E\u4E0D\u5230\u6B64\u811A\u672C\u7684\u6E90\u7801\uFF0C\u8BF7\u4EA4\u7ED9 AI \u6838\u5BF9\u6587\u4EF6\u8DEF\u5F84"});let h=ph(f.source,o);return f.source=h.source,f.edits=h.edits,f.issues.push(...h.issues),f}),u=Tt(JSON.stringify({archive:e,files:l.map(c=>[c.file,c.fileBefore])}));return{archive:e,rows:l,issues:n,fingerprint:u}}preview(){let e=this.inspect();return e.id=ep(),this.plan=e,{id:e.id,canApply:!e.issues.length&&e.rows.every(i=>!i.issues.length),issues:e.issues,changes:e.archive.controlGuidChanges.length,replacements:e.rows.reduce((i,r)=>i+r.edits.length,0),rows:e.rows.map(({id:i,path:r,file:n,edits:o,issues:s})=>({id:i,path:r,file:n,edits:o,issues:s}))}}apply({planId:e,expectedRevision:i}){let r=this.plan;if(!r||r.id!==e)throw new Error("\u8BF7\u5148\u9884\u89C8 Lua \u7D22\u5F15\u540C\u6B65");if(i!==this.controller.get().version)throw new Error("revision conflict: \u8BF7\u91CD\u65B0\u9884\u89C8");if(this.inspect().fingerprint!==r.fingerprint)throw new Error("\u6E90\u7801\u3001\u6587\u4EF6\u6216\u7D22\u5F15\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8");if(r.issues.length||r.rows.some(f=>f.issues.length))throw new Error("\u6E90\u7801\u6587\u4EF6\u6216\u7D22\u5F15\u6620\u5C04\u5B58\u5728\u51B2\u7A81\uFF0C\u8BF7\u4EA4\u7ED9 AI \u6838\u5BF9\uFF1B\u672C\u6B21\u6CA1\u6709\u4FEE\u6539\u811A\u672C");let o=mn(r.archive);for(let f of r.rows.filter(h=>h.edits.length))o.patch({op:"updateScript",id:f.id,source:f.source});o.patch({op:"acknowledgeControlGuidChanges",changeIds:r.archive.controlGuidChanges.map(f=>f.id)});let s=Buffer.from(JSON.stringify(o.archiveData())).toString("base64"),a=r.rows.filter(f=>f.edits.length&&f.file),l=this.controller.activeWorkspacePath(),u=a.length?pt(l,`.qxqy-guid-sync-backups/${r.id}`):"",c=[];try{for(let h of a){let m=U1(u,`${h.id}.lua`);Jh(Zh(m),{recursive:!0}),Rl(m,h.fileBefore,{flag:"wx"})}let f=pt(l,`.qxqy-guid-sync-backups/${r.id}/before.save.json`);Jh(Zh(f),{recursive:!0}),Rl(f,JSON.stringify(r.archive),{flag:"wx"});for(let h of a)Qh(h.file,h.source),c.push(h);this.controller.studio.importData("json",s)}catch(f){let h=[];for(let m of c.reverse())try{Qh(m.file,m.fileBefore)}catch{h.push(m.file)}throw this.plan=null,new Error(`${f.message}${h.length?`\uFF1B\u56DE\u6EDA\u5931\u8D25\uFF0C\u8BF7\u4ECE ${u} \u6062\u590D\uFF1A${h.join("\u3001")}`:"\uFF1B\u5B58\u6863\u672A\u63D0\u4EA4\uFF0C\u5DF2\u5199\u5165\u7684\u9879\u76EE\u6587\u4EF6\u5DF2\u56DE\u6EDA"}`)}return this.plan=null,{...this.controller.get(),controlGuidSyncResult:{replacements:r.rows.reduce((f,h)=>f+h.edits.length,0),scripts:r.rows.filter(f=>f.edits.length).length,projectFiles:a.length,backupRoot:`.qxqy-guid-sync-backups/${r.id}`}}}};var Z1=Math.max(1e3,Number(process.env.QXQY_PLAY_TIMEOUT_MS)||8e3),Q1=8e3;function tp(){let t=new Error("operation aborted");return t.name="AbortError",t}function Nl(t){if(t!=="manual"&&t!=="realtime")throw new Error("clockMode must be manual or realtime");return t}var rs=class{constructor(e="",{imageAssets:i=Tl(),clockMode:r="realtime"}={}){Yt(),this.workspacePath=e?bl(e):"",this.studio=mn(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="",this.archiveStamp="",this.savedArchive="",this.scriptSync=new Qo(this),this.controlGuidSync=new is(this),this.imageAssets=i,this.defaultClockMode=Nl(r),this.playClockMode=this.defaultClockMode}async exclusive(e){let i=this.lock,r;this.lock=new Promise(n=>{r=n}),await i;try{return await e()}finally{r()}}get(){return{...this.studio.get(),storage:{path:this.archivePath}}}scriptSyncAction(e,i={}){if(e==="discover")return Yh();if(e==="status")return{config:this.get().scriptSync,lastResult:this.scriptSync.lastResult};if(e==="configure"){if(!Number.isInteger(i.expectedRevision))throw new Error("expectedRevision is required");return this.patch({op:"setScriptSync",config:i.config,expectedRevision:i.expectedRevision})}if(e==="preview")return this.scriptSync.preview();throw new Error("unknown script sync action (AI \u53EF\u914D\u7F6E\u548C\u9884\u89C8\uFF1B\u590D\u5236\u9700\u5728\u7F16\u8F91\u5668\u4E2D\u786E\u8BA4)")}assertSavedArchive(){if(!this.archivePath||this.savedArchive!==JSON.stringify(this.studio.archiveData()))throw new Error("\u8BF7\u5148\u4FDD\u5B58\u5F53\u524D\u5B8C\u6574\u5B58\u6863\uFF0C\u518D\u786E\u8BA4\u590D\u5236");let e=Ii(this.activeWorkspacePath(),this.archivePath);if(Tt(Ol(e))!==this.archiveStamp)throw new Error("\u5B58\u6863\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u5E76\u68C0\u67E5")}saveForScriptSync(e,i){if(i!==this.get().version)throw new Error("revision conflict: reload before saving");let r=pt(this.activeWorkspacePath(),e);if(Y1(r)){let n=this.archivePath?pt(this.activeWorkspacePath(),this.archivePath):"";if(r!==n||Tt(Ol(r))!==this.archiveStamp)throw new Error("File changed or already exists; load it again or save under a new path")}return this.saveArchive(e)}patch(e){return e?.op==="previewControlGuidSync"?{...this.get(),controlGuidSyncPreview:this.controlGuidSync.preview()}:e?.op==="syncControlGuidReferences"?this.controlGuidSync.apply(e):{...this.studio.patch(e),storage:{path:this.archivePath}}}listArchives(){return Xo(this.workspacePath)}loadArchive(e){let i=this.activeWorkspacePath();if(!i)throw new Error("workspace is not bound");let r=Ii(i,e),n=Ol(r),o=this.studio.importData("json",n.toString("base64"),K1(r));return this.archivePath=String(e).trim().replaceAll("\\","/"),this.archiveStamp=Tt(n),this.savedArchive=JSON.stringify(this.studio.archiveData()),o}saveArchive(e=this.archivePath||"qxqy-simulator.save.json"){let i=String(e).trim(),r=this.activeWorkspacePath();if(!r)throw new Error("workspace is not bound");let n=pt(r,i);X1(J1(n),{recursive:!0});let o=Buffer.from(JSON.stringify(this.studio.archiveData(),null,2)+`
|
|
124
|
+
`,"utf8");return W1(n,o),this.archivePath=i.replaceAll("\\","/"),this.archiveStamp=Tt(o),this.savedArchive=JSON.stringify(this.studio.archiveData()),{path:this.archivePath,bytes:o.length,revision:this.studio.get().version,name:this.studio.get().save?.name||""}}activeWorkspacePath(){let e=this.studio.get().workspace;return e?.bound&&e.path?String(e.path):this.workspacePath}createWorker(){let e=new H1(new URL("./worker.js",import.meta.url),{type:"module",workerData:{localFont:Yt()?.data??null}});return e.on("message",i=>{let r=this.pending.get(i?.id);r&&(this.pending.delete(i.id),i.ok?r.resolve(i.value):r.reject(new Error(i.error||"play worker failed")))}),e.on("error",i=>{this.worker===e&&(this.worker=null),this.rejectPending(i)}),e.on("exit",i=>{this.worker===e&&(this.worker=null),i!==0&&this.rejectPending(new Error(`play worker exited with code ${i}`))}),this.worker=e,e}rejectPending(e){for(let i of this.pending.values())i.reject(e);this.pending.clear()}async terminateWorker(e=new Error("play worker terminated")){let i=this.worker;this.worker=null,this.rejectPending(e),i&&await i.terminate().catch(()=>{})}request(e,i,r,n=Z1){let o=this.worker||this.createWorker(),s=this.sequence++;return new Promise((a,l)=>{let u=!1,c=(m,g)=>{u||(u=!0,clearTimeout(h),r?.removeEventListener("abort",f),m(g))},f=()=>{this.pending.delete(s),c(l,tp()),this.terminateWorker(tp())},h=setTimeout(()=>{this.pending.delete(s);let m=new Error(`play worker timed out after ${n}ms`);c(l,m),this.terminateWorker(m)},n);if(this.pending.set(s,{resolve:m=>c(a,m),reject:m=>c(l,m)}),r?.aborted)return f();r?.addEventListener("abort",f,{once:!0}),o.postMessage({id:s,action:e,args:i})})}async play(e,i={},r){if((e==="start"||e==="device")&&!i.language){let n=qh();n&&(i={...i,language:n})}if(e==="start"){let n=Nl(i.clockMode??this.defaultClockMode);return await this.terminateWorker(),this.playClockMode=n,this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i,clockMode:n},r)}if(e==="device"){let n=String(i.canvasId||"").trim();if(!Ee[n])throw new Error(`unknown canvas preset: ${n||"(empty)"} (available: ${Object.keys(Ee).join(", ")})`);let o=Nl(i.clockMode??this.playClockMode);return await this.terminateWorker(),this.playClockMode=o,this.request("start",{archive:this.studio.archiveData(),workspacePath:this.activeWorkspacePath(),...i,canvasId:n,clockMode:o},r)}if(e==="stop"){if(!this.worker)return{running:!1,tree:[],logs:[]};try{return await this.request("stop",i,r)}finally{await this.terminateWorker()}}if(!this.worker)throw new Error("play session has not started");return this.request(e,i,r)}async playScreenshot(e){if(!this.worker)throw new Error("play session has not started");let i=await this.request("get",{view:!0},e,Q1),r=await this.imageAssets.prepare(i.scene?.nodes,e),n=Nh(i.scene,i.canvasWidth,i.canvasHeight,r);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,clockMode:i.clockMode,width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight,assetWarnings:r.warnings}}async uiScreenshot(e){let i=this.studio.get(),r=await this.imageAssets.prepare(i.boxes,e),n=Mh(i,r);return{data:n.data,page:n.page,width:n.width,height:n.height,pixelWidth:n.pixelWidth,pixelHeight:n.pixelHeight,assetWarnings:r.warnings}}async dispose(){await this.terminateWorker()}};import{defineTool as Xi}from"@deepseek-ai/dsh-tools";import{existsSync as np,realpathSync as ip}from"node:fs";import{isAbsolute as Pl,relative as rp,resolve as ns}from"node:path";function op(t,e){if(!t)throw new Error("\u5DE5\u4F5C\u533A\u672A\u7ED1\u5B9A\uFF0C\u65E0\u6CD5\u4ECE\u78C1\u76D8\u62C9\u53D6\u5B58\u6863");let i=String(e||"").trim();if(!i)throw new Error("path is required");let r=ip(ns(t)),n=Pl(i)?ns(i):ns(r,i),o=rp(r,n);if(!o||o.startsWith("..")||Pl(o))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");if(!np(n))throw new Error(`\u5B58\u6863\u4E0D\u5B58\u5728: ${i}`);let s=ip(n),a=rp(r,s);if(!a||a.startsWith("..")||Pl(a))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");return s}function sp(t){if(!t)return{bound:!1,archives:[]};let e=ns(t);return np(e)?Xo(e):{bound:!1,archives:[]}}var ap=32*1024*1024;function ev(t){if(t.length<8||t.length>ap)throw new Error("Invalid MP3 size");let e=0,i=0;if(t.subarray(0,3).toString()==="ID3"){if(t.length<10||t[3]<2||t[3]>4||t.subarray(6,10).some(r=>r>127))throw new Error("Invalid MP3 ID3 header");e=10+(t[6]<<21|t[7]<<14|t[8]<<7|t[9])+(t[5]&16&&t[3]===4?10:0)}for(;e+4<=t.length;){if(t.length-e===128&&t.subarray(e,e+3).toString()==="TAG"){e=t.length;break}let r=t[e+1],n=t[e+2],o=r>>3&3,s=n>>2&3,a=n>>4;if(t[e]!==255||(r&224)!==224||(r&6)!==2||o===1||s===3||a===0||a===15)throw new Error("Invalid MP3 frame");let l=(o===3?[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320]:[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160])[a],u=[44100,48e3,32e3][s]/(o===3?1:o===2?2:4),c=Math.floor((o===3?144e3:72e3)*l/u)+(n>>1&1);e+=c,i++}if(i<2||e!==t.length)throw new Error("Truncated or invalid MP3")}var Ml=class extends Ei{constructor({cacheDir:e=process.env.QXQY_AUDIO_CACHE_DIR||es("audio"),fetch:i=globalThis.fetch,source:r=Bd}={}){super({cacheDir:e,fetch:i,source:r,version:Xa,extension:"mp3",accepts:n=>Po(n)!==null,timeout:2e4})}decode(e){return ev(e),{}}produce(e,i,r){return this.download(`audio/${e}.mp3`,ap,i,r)}},tv;function iv(){return tv||=new Ml}async function lp(t,e,i=iv()){let r=new URL(t.url,"http://localhost");if(r.pathname!==No.slice(0,-1)&&!r.pathname.startsWith(No))return!1;try{if(!["GET","HEAD"].includes(t.method))throw Object.assign(new Error("GET or HEAD required"),{status:405});let n=r.pathname.match(new RegExp(`^${No}${Xa}/([0-9]+)\\.mp3$`));if(!n)throw Object.assign(new Error("Unknown audio resource"),{status:404});let o=await i.get(Number(n[1])),s=o.data.length,a={"content-type":"audio/mpeg","cache-control":"private, max-age=43200",etag:o.etag,"accept-ranges":"bytes","x-content-type-options":"nosniff"};if(t.headers["if-none-match"]===o.etag)return e.writeHead(304,a),e.end(),!0;let l=t.headers.range,u=0,c=s-1,f=200;if(l&&(!t.headers["if-range"]||t.headers["if-range"]===o.etag)){let h=l.match(/^bytes=(\d*)-(\d*)$/);if(!h||!h[1]&&!h[2])throw Object.assign(new Error("Invalid byte range"),{status:416,size:s});if(h[1]?(u=Number(h[1]),c=h[2]?Math.min(s-1,Number(h[2])):c):u=Math.max(0,s-Number(h[2])),!Number.isSafeInteger(u)||!Number.isSafeInteger(c)||u>=s||c<u)throw Object.assign(new Error("Unsatisfiable byte range"),{status:416,size:s});f=206,a["content-range"]=`bytes ${u}-${c}/${s}`}e.writeHead(f,{...a,"content-length":c-u+1}),e.end(t.method==="HEAD"?void 0:o.data.subarray(u,c+1))}catch(n){e.writeHead(n.status||502,{"content-type":"text/plain; charset=utf-8","cache-control":"no-store",...n.status===416?{"content-range":`bytes */${n.size}`}:{}}),e.end(t.method==="HEAD"?void 0:n.message)}return!0}var rv="https://github.com/1475505/miliastra-beyond-simulator",nv="https://api.github.com/repos/1475505/miliastra-beyond-simulator/releases?per_page=100",ov=t=>/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(t),cp=(t,e)=>{let i=t.split(/[.-]/).slice(0,3).map(Number),r=e.split(/[.-]/).slice(0,3).map(Number);for(let n=0;n<3;n++)if(i[n]!==r[n])return Math.sign(i[n]-r[n]);return e.includes("-")&&!t.includes("-")?1:t.includes("-")&&!e.includes("-")?-1:0};function up(t,e){try{let i=new URL(t);return i.protocol==="https:"&&i.origin==="https://github.com"&&i.pathname.startsWith(`/1475505/miliastra-beyond-simulator/releases/${e}/`)?i.href:null}catch{return null}}function sv(t,e){if(!Array.isArray(t))throw new Error("Invalid release response");let i=[];for(let r of t)if(!(r.draft||r.prerelease||!Array.isArray(r.assets)))for(let n of r.assets){if(typeof n.name!="string"||!n.name.startsWith(e+"-")||!n.name.endsWith(".tgz"))continue;let o=n.name.slice(e.length+1,-4),s=up(r.html_url,"tag"),a=up(n.browser_download_url,"download");!ov(o)||!s||!a||i.push({version:o,url:s,downloadUrl:a,publishedAt:r.published_at||null})}return i.sort((r,n)=>cp(n.version,r.version))[0]||null}function fp({packageName:t,currentVersion:e,fetch:i=globalThis.fetch,now:r=Date.now}){let n=null,o=null;return async function(){return n&&r()-n.checkedAt<5*6e4?n:o||(o=(async()=>{let a=await i(nv,{headers:{accept:"application/vnd.github+json","user-agent":"beyond-simulator-update-check","x-github-api-version":"2022-11-28"},signal:AbortSignal.timeout(8e3)});if(!a.ok)throw new Error(`Update check failed (HTTP ${a.status})`);let l=sv(await a.json(),t),u=l?cp(l.version,e):0;return n={packageName:t,currentVersion:e,latestVersion:l?.version||null,status:l?u>0?"available":u<0?"ahead":"current":"unavailable",url:l?.url||`${rv}/releases`,downloadUrl:l?.downloadUrl||null,checkedAt:r(),publishedAt:l?.publishedAt||null},n})().finally(()=>{o=null}),o)}}import{execFile as av}from"node:child_process";import{win32 as lv}from"node:path";import{promisify as uv}from"node:util";var cv=uv(av),dp=t=>["localhost","127.0.0.1","::1","[::1]","::ffff:127.0.0.1"].includes(t);function Fl(t){if(typeof t!="string")return"";let e=t.trim().replace(/^\uFEFF/,"").split(/[.@]/)[0].replaceAll("_","-");if(!e||/^(?:C|POSIX)$/i.test(e)||e.length>80)return"";try{return Intl.getCanonicalLocales(e)[0]||""}catch{return""}}function hp(t){try{return dp(t.socket?.remoteAddress)&&dp(new URL("http://"+t.headers.host).hostname)&&!t.headers.forwarded&&!t.headers["x-forwarded-for"]&&!t.headers["x-forwarded-host"]&&!t.headers.via&&t.headers["sec-fetch-site"]!=="cross-site"&&(!t.headers.origin||new URL(t.headers.origin).host===t.headers.host)}catch{return!1}}function fv({platform:t=process.platform,env:e=process.env,execFile:i=cv}={}){let r;return()=>r||=(async()=>{try{let n="",o="browser",s={windowsHide:!0,timeout:2500,maxBuffer:4096,encoding:"utf8"};if(t==="win32"){let a=lv.join(e.SystemRoot||"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),{stdout:l}=await i(a,["-NoLogo","-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;(Get-UICulture).Name"],s);n=Fl(l),o="windows-ui"}else if(t==="darwin"){let{stdout:a}=await i("/usr/bin/defaults",["read","-g","AppleLanguages"],s);n=(a.match(/\b[a-z]{2,3}(?:[-_][a-zA-Z0-9]{2,8})*\b/g)||[]).map(Fl).find(Boolean)||"",o="macos-ui"}else n=[e.LANGUAGE?.split(":")[0],e.LC_ALL,e.LC_MESSAGES,e.LANG].map(Fl).find(Boolean)||"",o="host-locale";return{language:n,source:n?o:"browser"}}catch{return{language:"",source:"browser"}}})()}var pp=fv();var Dl={name:"dsh-plugin-beyond-simulator",version:"2.2.0",description:"\u5343\u661F\u5947\u57DF\u5BA2\u6237\u7AEF UI \u7F16\u8F91\u4E0E\u8BD5\u73A9\u6A21\u62DF\u5668 for DeepSeek Harness",private:!0,type:"module",packageManager:"pnpm@10.15.0",engines:{node:">=22"},main:"dsh-plugin/dist/index.js",exports:{".":"./dsh-plugin/dist/index.js","./skill":"./dsh-plugin/dist/skill.js","./preset":"./dsh-plugin/dist/preset.js","./client":"./dsh-plugin/dist/client.js","./cordis.patch.yml":"./dsh-plugin/cordis.patch.yml","./package.json":"./package.json"},files:["dsh-plugin/dist","dsh-plugin/lib/play.html","dsh-plugin/skill.md","dsh-plugin/presets","dsh-plugin/cordis.patch.yml","README.md","LICENSE"],repository:{type:"git",url:"git+https://github.com/1475505/miliastra-beyond-simulator.git"},dsh:{bundle:{patch:"./dsh-plugin/cordis.patch.yml"},client:{inject:["@deepseek-ai/dsh-client-runtime","@deepseek-ai/dsh-client-ui-slots","@deepseek-ai/dsh-client-ui-conversation"],platform:"web"}},scripts:{prepare:"node scripts/build.mjs dsh-plugin",build:"node scripts/build.mjs",test:"node scripts/test.mjs","pack:release":"node scripts/pack.mjs","test:packages":"node scripts/smoke-packages.mjs","test:git-install":"node scripts/smoke-git-install.mjs","test:harness":"node scripts/smoke-harness.mjs","dev:web":"node scripts/build.mjs web && node web/server.js","start:web":"node web/dist/server.js"},dependencies:{"@napi-rs/canvas":"0.1.100",fengari:"0.1.5",protobufjs:"8.7.2"},peerDependencies:{"@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-tools":"^0.1.0-rc.6 || ^0.2.0-rc.1 || ^0.2.1-rc.1"},devDependencies:{"@deepseek-ai/dsh-tools":"0.1.0-rc.6",esbuild:"0.25.12"},license:"GPL-3.0-only"};var e_="qxqy-simulator",t_=["tools","webServer"],mp="/qxqy-simulator/api",gp="/qxqy-simulator/play",mv="/qxqy-simulator/play-renderer.js",gv=8*1024*1024,yv=32,yp=6e4,Ll=class extends rs{constructor(e=""){super(e),this.touchedAt=Date.now()}touch(){this.touchedAt=Date.now()}get(){return this.touch(),super.get()}patch(e){return this.touch(),super.patch(Sn(e))}exportData(e,i){return this.touch(),this.studio.exportData(e,i)}importData(e,i,r){this.touch();let n=this.studio.importData(e,i,r);return this.archivePath="",this.archiveStamp="",this.savedArchive="",{...n,snapshot:this.get()}}listArchives(){return this.touch(),sp(this.studio.get().workspace?.path||"")}loadArchive(e){this.touch();let i=this.studio.get().workspace?.path||"",r=op(i,e);return{...super.loadArchive(pv(hv(i),r)),snapshot:this.get()}}async play(e,i={},r){return this.touch(),super.play(e,Sn(i)||{},r)}async requestScreenshot(e){return{...await super.playScreenshot(e),capturedAt:new Date().toISOString()}}async requestUiScreenshot(e){return this.touch(),{...await super.uiScreenshot(e),capturedAt:new Date().toISOString()}}async dispose(){await this.terminateWorker()}};function wp(t){let e=String(t||"").trim();if(!e||e.length>256)throw new Error("sessionId is required");return e}function Sn(t){if(t!=null){if(typeof t!="string")return t;try{let e=JSON.parse(t);return e&&typeof e=="object"?e:void 0}catch{return}}}function Wi(t){return wp(t?.agent?.id)}function Gl(t){let e=t?.cwd;return typeof e=="string"&&e?e:""}function Ki(t){return Gl(t?.agent?.session?.header)}async function vv(t,e={}){let i=e.sessions?.get?.(t),r=Gl(i?.header);if(r)return r;let n=e.sessionPersistence?.inspect;if(typeof n!="function")return"";try{let o=await n.call(e.sessionPersistence,t);return Gl(o?.meta)}catch{return""}}function bv(){let t=new Map,e=!1;function i(){if(t.size<yv)return;let r=[...t.entries()].sort((n,o)=>n[1].touchedAt-o[1].touchedAt)[0];r&&(t.delete(r[0]),r[1].dispose())}return{get(r,n=""){if(e)throw new Error("simulator plugin has been disposed");let o=wp(r),s=t.get(o);return s?n&&s.studio.setWorkspace(n):(i(),s=new Ll(n),t.set(o,s)),s.touch(),s},async dispose(){e=!0;let r=[...t.values()];t.clear(),await Promise.all(r.map(n=>n.dispose()))}}}function wn(t,e,i){let r=JSON.stringify(i);t.statusCode=e,t.setHeader("content-type","application/json; charset=utf-8"),t.setHeader("cache-control","no-store"),t.end(r)}function wv(){if(!zl){let e=[new URL("./play.html",import.meta.url),new URL("../lib/play.html",import.meta.url)].find(i=>vp(i));if(!e)throw new Error("standalone play page is missing");zl=bp(e,"utf8")}return zl}var zl=null;function Sv(){if(!$l){let e=[new URL("../dist/play-renderer.js",import.meta.url),new URL("./play-renderer.js",import.meta.url)].find(i=>vp(i));if(!e)throw new Error("standalone play renderer bundle is missing; run npm run build");$l=bp(e,"utf8")}return $l}var $l=null;function Or(t,e){return t.effect(()=>t.webServer.register(e),`qxqy-simulator: ${e.kind} ${e.path}`)}function xv(t){Or(t,{kind:"prefix",path:gp,handler(e,i){let r=new URL(e.url,"http://localhost").pathname.replace(/\/$/,"");if(e.method!=="GET"||r!==gp){i.statusCode=e.method==="GET"?404:405,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(e.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(wv())}})}function _v(t){Or(t,{kind:"exact",path:mv,handler(e,i){if(e.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(Sv())}catch(r){i.statusCode=500,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(r?.message||String(r))}}})}function Iv(t){return new Promise((e,i)=>{let r=0,n=[];t.on("data",o=>{if(r+=o.length,r>gv){i(new Error("request body is too large")),t.destroy();return}n.push(o)}),t.on("end",()=>{try{let o=Buffer.concat(n).toString("utf8");e(o?JSON.parse(o):{})}catch{i(new Error("invalid JSON body"))}}),t.on("error",i)})}function Ev(t,e){t.tools.register(Xi({name:"qxqy_script_sync",description:"\u5B9E\u673A Lua \u76EE\u5F55\u590D\u5236\u540C\u6B65\uFF1Adiscover/status/configure/preview\u3002configure \u7684 args \u5305\u542B config(version:1, workspaceDir, clientImportRoot, clientSubdir) \u548C expectedRevision\uFF1B\u914D\u7F6E\u968F\u5B8C\u6574\u5B58\u6863\u4FDD\u5B58\u3002preview \u53EA\u68C0\u67E5\u5DEE\u5F02\uFF0C\u590D\u5236\u5FC5\u987B\u7531\u7528\u6237\u5728 Lua \u811A\u672C\u9875\u9762\u68C0\u67E5\u5E76\u786E\u8BA4\u3002",parameters:{action:{type:"string",enum:["discover","status","configure","preview"],required:!0},args:{type:"json"}},output:{schema:{type:"json"},render:(i,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:1e4,isConcurrencySafe:()=>!1,async execute(i,r){return e.get(Wi(r),Ki(r)).scriptSyncAction(i.action,Sn(i.args)||{})}})),t.tools.register(Xi({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,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!0,async execute(i,r){return e.get(Wi(r),Ki(r)).get()}})),t.tools.register(Xi({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,r)=>{let o=[{type:"text",text:`\u8BD5\u73A9\u622A\u56FE\uFF1A${r.canvasId||"unknown"}\uFF0CFrame ${r.frame??0}\uFF0C${r.width||0}\xD7${r.height||0}`+(r.assetWarnings?.length?`
|
|
125
|
+
\u7D20\u6750\u52A0\u8F7D\u5931\u8D25\uFF08\u753B\u9762\u4E2D\u4E3A\u5360\u4F4D\u6846\uFF09\uFF1A${JSON.stringify(r.assetWarnings)}`:"")}];return r.image&&o.push({type:"image",attachment:r.image}),o}},timeoutMs:yp+1e3,isConcurrencySafe:()=>!1,async execute(i,r){let o=await e.get(Wi(r),Ki(r)).requestScreenshot(r.signal),s=t.get?.("attachments");if(!s?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let a=await s.saveImage({data:o.data,mediaType:"image/png",name:`qxqy-play-${o.canvasId||"canvas"}-f${o.frame}.png`}),{data:l,...u}=o;return{...u,image:{attachmentId:a.attachmentId,mediaType:a.mediaType,bytes:a.bytes,width:a.width,height:a.height,...a.name===void 0?{}:{name:a.name}}}}})),t.tools.register(Xi({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,r)=>{let s=[{type:"text",text:`\u7F16\u8F91\u5668\u622A\u56FE\uFF1A${r.page||"\u6A21\u62DF\u5668"}\uFF0C${r.width||0}\xD7${r.height||0}`+(r.assetWarnings?.length?`
|
|
126
|
+
\u7D20\u6750\u52A0\u8F7D\u5931\u8D25\uFF08\u753B\u9762\u4E2D\u4E3A\u5360\u4F4D\u6846\uFF09\uFF1A${JSON.stringify(r.assetWarnings)}`:"")}];return r.image&&s.push({type:"image",attachment:r.image}),s}},timeoutMs:yp+1e3,isConcurrencySafe:()=>!1,async execute(i,r){let o=await e.get(Wi(r),Ki(r)).requestUiScreenshot(r.signal),s=t.get?.("attachments");if(!s?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let a=await s.saveImage({data:o.data,mediaType:"image/png",name:`qxqy-ui-${o.page||"editor"}.png`}),{data:l,...u}=o;return{...u,image:{attachmentId:a.attachmentId,mediaType:a.mediaType,bytes:a.bytes,width:a.width,height:a.height,...a.name===void 0?{}:{name:a.name}}}}})),t.tools.register(Xi({name:"qxqy_studio_patch",description:"\u4FEE\u6539\u5F53\u524D\u4F1A\u8BDD\u7684\u5343\u661F UI \u5DE5\u7A0B\u3002op \u5FC5\u987B\u643A\u5E26 expectedRevision\u3002\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7D22\u5F15\u7528 setControlGuid\uFF08id\u3001guid\uFF09\uFF1B\u5FC5\u987B\u6839\u636E\u5FEB\u7167 controlGuidChanges \u66F4\u65B0\u5B58\u6863 Lua source \u548C\u76F8\u5173\u6E90\u6587\u4EF6\u7684\u7D22\u5F15\u5F15\u7528\u5E76\u6838\u5BF9\uFF0C\u5B8C\u6210\u540E\u7528 acknowledgeControlGuidChanges\uFF08changeIds\uFF09\u786E\u8BA4\uFF0C\u7981\u6B62\u76F2\u76EE\u66FF\u6362\u5168\u90E8\u540C\u503C\u6570\u5B57\u3002",parameters:{op:{type:"json",required:!0,description:"\u7F16\u8F91\u5668 patch \u5BF9\u8C61\u3002"}},output:{schema:{type:"json"},render:(i,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:5e3,isConcurrencySafe:()=>!1,async execute(i,r){let n=Sn(i.op);if(!n)throw new Error("patch requires op");return e.get(Wi(r),Ki(r)).patch(n)}})),t.tools.register(Xi({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,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:1e4,isConcurrencySafe:()=>!1,async execute(i,r){let n=Sn(i.args)||{};return e.get(Wi(r),Ki(r)).play(i.action,n,r.signal)}})),t.tools.register(Xi({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,r)=>[{type:"text",text:JSON.stringify(r,null,2)}]},timeoutMs:8e3,isConcurrencySafe:()=>!1,async execute(i,r){let n=e.get(Wi(r),Ki(r));return i.path?n.loadArchive(i.path):n.listArchives()}}))}function Cv(t,e,i){Or(t,{kind:"prefix",path:mp,async handler(r,n){if(r.method!=="POST"){wn(n,405,{ok:!1,value:null,error:"POST required"});return}let s=new URL(r.url,"http://localhost").pathname.slice(mp.length).replace(/^\/+/,"");if(s==="health"){wn(n,200,{ok:!0,value:{status:"ok"},error:null});return}let a=new AbortController;r.once("aborted",()=>a.abort());try{let l=await Iv(r);if(s==="locale"){wn(n,200,{ok:!0,value:hp(r)?await pp():{language:"",source:"browser"},error:null});return}let u=await vv(l.sessionId,{sessions:t.get?.("sessions"),sessionPersistence:t.get?.("sessionPersistence")}),c=e.get(l.sessionId,u),f;if(s==="updates")f=await i();else if(s==="get")f=c.get();else if(s==="patch")f=c.patch(l.op);else if(s==="export")f=c.exportData(l.format,l.assetType);else if(s==="import")f=c.importData(l.format,l.data,l.filename);else if(s==="archives")f=c.listArchives();else if(s==="load-archive")f=c.loadArchive(l.path);else if(s==="save")f=c.saveForScriptSync(l.path,l.expectedRevision);else if(s==="script-sync")f=c.scriptSyncAction(l.action,l.args||{});else if(s==="script-sync-apply")f=c.scriptSync.apply(l);else if(s==="image-refresh")await c.imageAssets.refresh(l.imageId,{imageSource:l.imageSource}),f={imageId:l.imageId,imageSource:l.imageSource||"StaticReference",refreshed:!0};else if(s==="play")f=await c.play(l.action,l.args||{},a.signal);else throw new Error("unknown API action");wn(n,200,{ok:!0,value:f,error:null})}catch(l){wn(n,400,{ok:!1,value:null,error:l?.message||String(l)})}}})}function i_(t){Yt();let e=bv();t.effect(()=>()=>e.dispose(),"qxqy-simulator: dispose sessions"),Ev(t,e),Cv(t,e,fp({packageName:Dl.name,currentVersion:Dl.version})),xv(t),_v(t),Or(t,{kind:"prefix",path:"/qxqy-assets",handler:(i,r)=>Kh(i,r)}),Or(t,{kind:"prefix",path:"/qxqy-audio",handler:(i,r)=>lp(i,r)}),Or(t,{kind:"prefix",path:"/qxqy-font",handler:Iu})}export{Ll as SimulatorController,i_ as apply,Gl as headerWorkspace,t_ as inject,Sn as jsonParam,vv as lookupSessionWorkspace,e_ as name,Ki as sessionWorkspace};
|
|
127
|
+
/*! Bundled license information:
|
|
128
|
+
|
|
129
|
+
long/umd/index.js:
|
|
130
|
+
(**
|
|
131
|
+
* @license
|
|
132
|
+
* Copyright 2009 The Closure Library Authors
|
|
133
|
+
* Copyright 2020 Daniel Wirtz / The long.js Authors.
|
|
134
|
+
*
|
|
135
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
136
|
+
* you may not use this file except in compliance with the License.
|
|
137
|
+
* You may obtain a copy of the License at
|
|
138
|
+
*
|
|
139
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
140
|
+
*
|
|
141
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
142
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
143
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
144
|
+
* See the License for the specific language governing permissions and
|
|
145
|
+
* limitations under the License.
|
|
146
|
+
*
|
|
147
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
148
|
+
*)
|
|
149
|
+
*/
|