dsh-plugin-beyond-simulator 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,20 @@
1
- import{existsSync as Al,readFileSync as _l,realpathSync as Td}from"node:fs";import{relative as Rd}from"node:path";import{Worker as vd}from"node:worker_threads";import{existsSync as Sd,mkdirSync as wd,readFileSync as mo,writeFileSync as Id}from"node:fs";import{basename as xd,dirname as Cd}from"node:path";import{existsSync as Ai,readFileSync as Ku}from"node:fs";import{randomUUID as Ts}from"node:crypto";import{isAbsolute as Co,win32 as ko}from"node:path";function zi(e,t=!1){let i=String(e??"").trim().replaceAll("\\","/");if(t&&(!i||i==="."))return"";if(!i||Co(i)||ko.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 oi(e){if(e==null)return null;if(e.version!==1)throw new Error("unsupported scriptSync version");let t=String(e.clientImportRoot||"").trim();if(!Co(t)&&!ko.isAbsolute(t))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:zi(e.workspaceDir,!0),clientImportRoot:t,clientSubdir:zi(e.clientSubdir,!0)}}import{basename as qt,dirname as Ju,isAbsolute as Zu,join as Rs,resolve as Ms}from"node:path";var Eo="https://oss.070077.xyz/prefabs/",ai="prefab-v1",Kl=[[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 $i(e){return!Number.isSafeInteger(e)||!Kl.some(([t,i])=>e>=t&&e<=i)?null:e===10003004||e===10008001?128:256}var Gi="https://oss.070077.xyz/images/",Vr="sprite-v1",Vi="/qxqy-assets/",Jl=[[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 Ce(e){return e==null||e===""?"StaticReference":typeof e=="string"?e:typeof e.Name=="string"?e.Name:"Unknown"}function Yi(e,t){return`${Ce(t)}:${e}`}function Ao(e,t){return Ce(t)==="StaticReference"&&Ke(e,t)}function Ke(e,t){let i=Ce(t);return i==="Prefab"?$i(e)!==null:i==="StaticReference"&&Number.isSafeInteger(e)&&e>100006&&Jl.some(([r,n])=>e>=r&&e<=n)}var Hi="7.1.0",ue=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"}}),Bi="pc-16-9",ve=2,Rt=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),Mt=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"}),Ui=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),_o=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}),Zl=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"});function Nt(e,t){return Ce(t)==="StaticReference"&&Zl[e]||(Ke(e,t)?"sprite":"missing")}var Po=50888,si=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function Ot(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)=>Ot(r,`${t}[${n}]`,i));else for(let[r,n]of Object.entries(e))Ot(n,`${t}.${r}`,i);i.delete(e)}}function V(e){return Ot(e),JSON.parse(JSON.stringify(e))}function To(e,t="$"){Ot(e,t)}function Ro(e){return J[e]||J[Bi]}function li(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 Ql(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 ec(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 ji({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 Ge(e){let t=e||ji();return{scale:Ql(t.scale),rotation:ec(t.rotation),anchorMin:li(t.anchorMin??t.anchor_min,.5,.5),anchorMax:li(t.anchorMax??t.anchor_max,.5,.5),offset:li(t.offset,0,0),size:li(t.size,0,0),pivot:li(t.pivot,.5,.5)}}function he(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Be(e,t){let i=e.width,r=e.height,n=e.left,o=e.bottom,a=t.anchorMin||{x:t.anchorMinX,y:t.anchorMinY},s=t.anchorMax||{x:t.anchorMaxX,y:t.anchorMaxY},c=t.offset||{x:t.anchoredPositionX,y:t.anchoredPositionY},l=t.size||{x:t.sizeDeltaX,y:t.sizeDeltaY},u=t.pivot||{x:t.pivotX,y:t.pivotY},f=he(a?.x,.5)*i,h=he(a?.y,.5)*r,p=he(s?.x,.5)*i,m=he(s?.y,.5)*r,y=he(l?.x),x=he(l?.y),k=he(u?.x,.5),w=he(u?.y,.5),N=p-f+y,M=m-h+x,Y=n+f+he(c?.x)-y*k,U=o+h+he(c?.y)-x*w;return{left:Y,bottom:U,width:N,height:M,right:Y+N,top:U+M,centerX:Y+N/2,centerY:U+M/2}}function Ft(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function tc(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 Ie(e,t,i){return{x:e.a*t+e.c*i+e.tx,y:e.b*t+e.d*i+e.ty}}function Ue(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 Yr(e,t){let i=t.rotation||{x:t.localRotationX,y:t.localRotationY,z:t.localRotationZ},r=t.scale||{x:t.localScaleX,y:t.localScaleY},n=t.pivot||{x:t.pivotX,y:t.pivotY},o=he(i?.z)*Math.PI/180,a=Math.cos(o),s=Math.sin(o),c=he(i?.x)*Math.PI/180,l=he(i?.y)*Math.PI/180,u=Math.cos(c),f=Math.sin(c),h=Math.cos(l),p=Math.sin(l),m=H=>Math.abs(H)<1e-12?0:H,y=he(r?.x,1),x=he(r?.y,1),k=e.left+e.width*he(n?.x,.5),w=e.bottom+e.height*he(n?.y,.5),N=m(h*a+p*f*s)*y,M=m(u*s)*y,Y=m(-h*s+p*f*a)*x,U=m(u*a)*x;return{a:N,b:M,c:Y,d:U,tx:k-N*k-Y*w,ty:w-M*k-U*w}}function ci(e,t,i){return tc(e||Ft(),Yr(t,i))}function Mo(e,t){let i=Ie(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 Se(e){let t=typeof e=="string"?Ro(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 Hr(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function ut(e,t,i){let r=Ge(t),n=e.width,o=e.height,a=r.anchorMin.x*n,s=r.anchorMin.y*o,c=r.anchorMax.x*n,l=r.anchorMax.y*o,u=Number(i.width),f=Number(i.height),h=Number(i.posX),p=Number(i.posY),m=h-u/2,y=p-f/2;return r.size={x:u-(c-a),y:f-(l-s)},r.offset={x:m-e.left-a+r.size.x*r.pivot.x,y:y-e.bottom-s+r.size.y*r.pivot.y},r}function No(e,t){let i=Ge(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 Oo(e){let t=Ge(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,o=[[0,0,"bottom-left"],[.5,0,"bottom"],[1,0,"bottom-right"],[0,.5,"left"],[.5,.5,"center"],[1,.5,"right"],[0,1,"top-left"],[.5,1,"top"],[1,1,"top-right"]];for(let a of o)if(i(r,a[0])&&i(n,a[1]))return a[2]}return"custom"}function ft(e){return Ro(e).platform}function Fo(e){let t={};for(let i of ue)t[i]=e(i);return t}var ic={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function Do(e,t){for(let[i,r]of Object.entries(ic))for(let n of r)if(!Number.isFinite(e?.[i]?.[n]))throw new Error(`${t}.${i}.${n} must be a finite number`)}function Je(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(!ue.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of ue)Do(e[i],`${t}.${i}`)}function dt(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`);Je(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function ht(e,t){if(!ue.includes(t))throw new Error(`unknown platform ${t}`);return Do(e?.[t],`transformByPlatform.${t}`),Ge(e[t])}var rc=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"}]),nc=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 zo(e){return[...rc,...nc[e]||[]]}function $o(e,t){return zo(e).find(i=>i.key===t)||null}function Br(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 Go(e,t={}){let i={};for(let r of zo(e)){let n=Object.hasOwn(t||{},r.key)?t[r.key]:r.defaultValue;i[r.key]=Br(r,n)}return i}function Me(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Ur(e,t){if(e){t(e);for(let i of e.children||[])Ur(i,t)}}function Dt(e,t=new Set,{skipServerContainer:i=!1}={}){return Ur(e,r=>{i&&r.kind==="server-container"||Me(r.guid)&&t.add(Number(r.guid))}),t}function Ze(e,t=1073741850){let i=Number.isSafeInteger(t)&&t>0?t:1073741850;i<1073741850&&(i=1073741850);for(let r of e)Me(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 Vo(e,t=new Set,{skipServerContainer:i=!1}={}){let r=[];Ur(e,n=>{if(i&&n.kind==="server-container")return;let o=Number(n.guid);if(Me(o)&&!t.has(o)){t.add(o),n.guid=o;return}r.push(n)});for(let n of r){let o=Ze(t);n.guid=o,t.add(o)}return t}function Ae(e){return Number.isSafeInteger(e)&&e>0&&e<=2147483647}function je(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,o=new Map;for(let m of i){if(!Ae(m.giaInfoIndex))continue;let y=n.get(m.giaInfoIndex)||[];y.push(m),n.set(m.giaInfoIndex,y);let x=o.get(m.kind)||new Set;x.add(m.giaInfoIndex),o.set(m.kind,x)}let a=(e.root.children||[]).filter(m=>m.kind!=="server-container"),s=new Set(a),c=a.some((m,y)=>Ae(m.giaInfoIndex)&&a.slice(0,y).some(x=>x.giaInfoIndex===m.giaInfoIndex)),l=!e.meta.giaAssetIndexSchemaVersion&&c&&i.every(m=>m.giaInfoIndexSource!=="authoring")&&[...o.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 f=new Map,h=Number.isSafeInteger(e.meta.giaNextAssetIndex)&&e.meta.giaNextAssetIndex>=2?e.meta.giaNextAssetIndex:2;for(let m of i){if(!Ae(m.giaInfoIndex)||(h=Math.max(h,m.giaInfoIndex+1),u.has(m)))continue;let y=f.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}`);f.set(m.giaInfoIndex,m)}l&&(h=Math.max(h,13));let p=l?[...a,...i.filter(m=>!s.has(m))].filter(m=>u.has(m)||!Ae(m.giaInfoIndex)):i.filter(m=>!Ae(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 jr=1;function Lr(e="n"){let t=`${e}${jr}`;return jr+=1,t}function Li(e=1){jr=e}function Xr(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return ji({layout:"stretch"});let i=_o[e]||[80,80];return ji({layout:"center",size:i})}function oc(e,t){return Fo(()=>Xr(e,t))}function ac(e){Je(e);let t={};for(let i of ue)t[i]=ht(e,i);return t}function W(e,t={}){if(!Mt[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&&dt(t);let i=t.isRootContainer===!0,r=t.id||Lr(e==="server-container"?"sc":"n"),n=Object.hasOwn(t,"transformByPlatform")?ac(t.transformByPlatform):oc(e,{isRootContainer:i}),o={id:r,kind:e,name:t.name||Mt[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[],...Ae(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:Go(e,t.giaRaw),transformByPlatform:n,children:[],scriptMappingIds:Array.isArray(t.scriptMappingIds)?t.scriptMappingIds.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[]};if(e==="container"&&(o.isolateNavigation=t.isolateNavigation===!0,o.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,o.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,o.showCursor=t.showCursor===!0),(e==="textbox"||e==="textwindow")&&(o.fontSize=t.fontSize??20,o.adaptiveFontSize=t.adaptiveFontSize===!0,o.minimumFontSize=t.minimumFontSize??20,o.fontColor=t.fontColor??si.font,o.bgColor=t.bgColor??si.bg,o.enableOutline=t.enableOutline!==!1,o.outlineColor=t.outlineColor??si.outline,o.horizontalAlignment=t.horizontalAlignment||"Left",o.verticalAlignment=t.verticalAlignment||"Top",Number.isInteger(t.giaRaw?.textVerticalAlign)&&![0,1,2].includes(t.giaRaw.textVerticalAlign)&&(o.giaRaw.textVerticalAlign=t.giaRaw.textVerticalAlign),o.text=t.text??"",Object.hasOwn(t.giaRaw||{},"textAlign")||(o.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o.horizontalAlignment]??o.giaRaw.textAlign),e==="textwindow"&&(o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1)),e==="image"&&(o.imageSource=t.imageSource||"StaticReference",o.imageType=["Basic","Stretch"].includes(t.imageType)?t.imageType:null,o.imageId=t.imageId??100001,o.imageColor=t.imageColor??si.image,o.enableMask=t.enableMask===!0,o.enableSoftEdge=t.enableSoftEdge===!0,o.softEdgeMode=t.softEdgeMode||"Percentage",o.softEdgeWidthX=t.softEdgeWidthX??8,o.softEdgeWidthY=t.softEdgeWidthY??8,o.horizontalSoftRange=t.horizontalSoftRange??85,o.verticalSoftRange=t.verticalSoftRange??85,o.enableFill=t.enableFill===!0,o.fillType=t.fillType||"Horizontal",o.fillHorizontalType=t.fillHorizontalType||"Left",o.fillVerticalType=t.fillVerticalType||"Bottom",o.fillRadial90Type=t.fillRadial90Type||"BottomLeft",o.fillRadialType=t.fillRadialType||"Bottom",o.fillAmount=t.fillAmount??1,o.reverseMaskArea=t.reverseMaskArea===!0||t.reverseMask===!0,Object.hasOwn(t.giaRaw||{},"imageFillType")||(o.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o.fillType]??o.giaRaw.imageFillType)),e==="button"&&(o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.clickAudioId=t.clickAudioId??Po,o.unavailableChildId=t.unavailableChildId??null,o.hoverChildId=t.hoverChildId??null,o.pressedChildId=t.pressedChildId??null,o.selectedChildId=t.selectedChildId??null),e==="cursor"&&(o.raycastTarget=t.raycastTarget??t.giaRaw?.cursorField501!==0),e==="reference"&&(o.referencedPrefabId=t.referencedPrefabId??t.giaRaw?.templateRefSlot??null,Object.hasOwn(t.giaRaw||{},"templateRefSlot")||(o.giaRaw.templateRefSlot=String(o.referencedPrefabId??""))),e==="grid"&&(o.itemPrefabId=t.itemPrefabId??null,o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1,o.scrollDirection=t.scrollDirection||"Vertical",o.layoutConstraint=t.layoutConstraint||"AutoWrap",o.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,o.cellSizeX=t.cellSizeX??50,o.cellSizeY=t.cellSizeY??50,o.spacingX=t.spacingX??8,o.spacingY=t.spacingY??8,o.padding1X=t.padding1X??20,o.padding1Y=t.padding1Y??20,o.padding2X=t.padding2X??20,o.padding2Y=t.padding2Y??20,o.previewCount=t.previewCount??t.giaRaw?.gridField511??5,Object.hasOwn(t.giaRaw||{},"gridField511")||(o.giaRaw.gridField511=Math.trunc(o.previewCount))),e==="keyhint"&&(o.keyboardKeyCode=t.keyboardKeyCode??t.giaRaw?.keyHintField502??null,o.controllerKeyCode=t.controllerKeyCode??t.giaRaw?.keyHintField501??null,Object.hasOwn(t.giaRaw||{},"keyHintField502")||(o.giaRaw.keyHintField502=Math.trunc(o.keyboardKeyCode??1)),Object.hasOwn(t.giaRaw||{},"keyHintField501")||(o.giaRaw.keyHintField501=Math.trunc(o.controllerKeyCode??1))),e==="animation"||e==="fullscreen"){let a=e==="animation"?t.giaRaw?.effectSlot:t.giaRaw?.fullscreenEffectSlot;o.animationId=t.animationId??a??null,o.playSoundEffect=t.playSoundEffect??null,e==="animation"&&(o.layer=t.layer??null);let s=e==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(t.giaRaw||{},s)||(o.giaRaw[s]=String(o.animationId??""))}if(t.children)for(let a of t.children)o.children.push(a);return o}function pt(){Li(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"}),o=W("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),a=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"}),f=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(o,-300,-100),h(a,0,0),h(s,300,250),h(c,300,140),h(l,300,30),h(u,300,-100),t.children.push(i,r,n,o,a,s,c,l,u,f),e.children.push(t),Li(12),Vo(e),{version:1,layoutSchemaVersion:ve,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 zt(){Li(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"}),o=W("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),a=(l,u,f)=>{for(let h of Object.values(l.transformByPlatform))h.offset={x:u,y:f}};((l,u,f)=>{for(let h of Object.values(l.transformByPlatform))h.size={x:u,y:f}})(t,520,320),a(i,0,110),a(r,0,0),a(n,0,-110),n.children.push(o),t.children.push(i,r,n),e.children.push(t),Li(6);let c={version:1,layoutSchemaVersion:ve,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:Hi,giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:e};return je(c),c}function Q(e,t,i=null){t(e,i);for(let r of e.children||[])Q(r,t,e)}function pe(e,t){let i=null;return Q(e,r=>{r.id===t&&(i=r)}),i}function qr(e,t="n"){let i=Lr(t);for(;pe(e,i);)i=Lr(t);return i}function Qe(e,t){let i=null;return Q(e,(r,n)=>{r.id===t&&(i=n)}),i}function Wr(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function ui(e){if(e.meta?.assetType!=="client-control-template")return Wr(e);let t=pe(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=Qe(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=Qe(e.root,t.id);return t}function Kr(e){dt(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"&&sc(e.transformByPlatform);let i=W(e.kind,t);return i.children=(e.children||[]).map(r=>Kr(r)),i}function sc(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 Yo(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 Ho(e,t){if(e.id===t)throw new Error("cannot remove root");let i=Qe(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 Bo=1e-4;function lc(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>Bo&&Math.abs(e.size[t])<=Bo}function cc(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=Be(t,e),n=(r.centerX-t.left)/t.width,o=(r.centerY-t.bottom)/t.height,a=ut(i,e,{posX:i.left+n*i.width,posY:i.bottom+o*i.height,width:r.width,height:r.height});for(let s of["x","y"])lc(e,s)&&(a.offset[s]=e.offset[s],a.size[s]=e.size[s]);return a}function Uo({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:r,sourceParentBox:n=Se(i),targetParentBoxByPlatform:o={}}){Je(e);let a=ft(i),s={};for(let c of ue)c===a?s[c]=Ge(t):r!==!1?s[c]=cc(t,n,o[c]||Se(Rt[c])):s[c]=ht(e,c);return Je(s),s}function et(e,t){return ht(e,ft(t))}function jo(e,t){let i=[];function r(n){t[n.id]&&i.push(t[n.id]);let o=n.children||[];for(let a=o.length-1;a>=0;a-=1)r(o[a])}return r(e),i}function tt(e,t,i=ft(t)){let r=Se(t),n={};function o(a,s,c){let l=ht(a.transformByPlatform,i),u=Be(s,l),f=a.kind==="server-container"?c:ci(c,u,l),h=Mo(u,f);n[a.id]={...u,...Hr(u),id:a.id,kind:a.kind,name:a.name,visible:a.visible!==!1,active:a.active!==!1,rotationX:l.rotation.x,rotationY:l.rotation.y,rotationZ:l.rotation.z,renderLeft:h.left,renderBottom:h.bottom,renderWidth:h.width,renderHeight:h.height,renderRotationZ:h.rotationZ,renderMatrix:f,primitive:a.kind==="image"?Nt(a.imageId,a.imageSource):null,...a.kind==="textbox"||a.kind==="textwindow"?{text:a.text??"",fontSize:a.fontSize,fontColor:a.fontColor,bgColor:a.bgColor,enableOutline:a.enableOutline!==!1,outlineColor:a.outlineColor,horizontalAlignment:a.horizontalAlignment,verticalAlignment:a.verticalAlignment}:{},...a.kind==="image"?{imageSource:a.imageSource,imageType:a.imageType??null,imageId:a.imageId,imageColor:a.imageColor,enableMask:a.enableMask===!0,enableSoftEdge:a.enableSoftEdge===!0,softEdgeMode:a.softEdgeMode,softEdgeWidthX:a.softEdgeWidthX,softEdgeWidthY:a.softEdgeWidthY,horizontalSoftRange:a.horizontalSoftRange,verticalSoftRange:a.verticalSoftRange,enableFill:a.enableFill===!0,fillType:a.fillType,fillHorizontalType:a.fillHorizontalType,fillVerticalType:a.fillVerticalType,fillRadial90Type:a.fillRadial90Type,fillRadialType:a.fillRadialType,fillAmount:a.fillAmount,reverseMaskArea:a.reverseMaskArea===!0}:{},...a.kind==="button"?{raycastTarget:a.raycastTarget!==!1,interactable:a.interactable!==!1,clickAudioId:a.clickAudioId,unavailableChildId:a.unavailableChildId??null,hoverChildId:a.hoverChildId??null,pressedChildId:a.pressedChildId??null,selectedChildId:a.selectedChildId??null}:{}};let p=a.kind==="server-container"?s:u;for(let m of a.children||[])o(m,p,f)}return o(e,r,Ft()),{canvas:r,boxes:n}}function Jr(e,t){let i=[];function r(n,o,a=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:Mt[n.kind]||n.kind,depth:o,parentId:a,ancestorIds:s,siblingIndex:c,siblingCount:l,templateId:u,childCount:(n.children||[]).length,incomplete:!Ui.includes(n.kind)});let f=n.children||[];for(let h=0;h<f.length;h+=1)r(f[h],o+1,n.id,[...s,n.id],h,f.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 Lo(e,t,i,r){if(!e)return null;let n=et(e.transformByPlatform,t),o=Hr(i),a=[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",o.posX,{computed:!0}),P("posY","\u4F4D\u7F6E Y","number",o.posY,{computed:!0}),P("width","\u5927\u5C0F W","number",o.width,{computed:!0}),P("height","\u5927\u5C0F H","number",o.height,{computed:!0}),P("rotationX","\u65CB\u8F6C X","number",n.rotation.x),P("rotationY","\u65CB\u8F6C Y","number",n.rotation.y),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",Oo(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"&&a.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}`;a.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}`;a.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}`}))];a.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"&&a.push(P("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),(e.kind==="textwindow"||e.kind==="grid")&&a.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"&&a.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"&&a.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")&&a.push(P("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),(!Ui.includes(e.kind)||e.kind==="textwindow"||e.kind==="grid")&&a.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:Mt[e.kind]||e.kind,incomplete:!Ui.includes(e.kind),fields:a}}function Xo(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 o=r[n];if(!o.visible||!o.active)continue;let a=o.renderMatrix&&Ue(o.renderMatrix),s=a&&Ie(a,t,i);if(s&&s.x>=o.left&&s.x<=o.right&&s.y>=o.bottom&&s.y<=o.top)return o.id}return null}import uc from"protobufjs";function $t(e,t=!1){let i=[],r=(n,o)=>{n.kind!=="server-container"&&i.push({node:n,parent:o});let a=t&&n.kind!=="server-container"?[...n.children||[]].reverse():n.children||[];for(let s of a)r(s,n)};return r(e.root,null),i}var fc=String.raw`
1
+ var jp=Object.create;var Ql=Object.defineProperty;var Vp=Object.getOwnPropertyDescriptor;var Up=Object.getOwnPropertyNames;var Hp=Object.getPrototypeOf,Yp=Object.prototype.hasOwnProperty;var Xp=(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 Wp=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Up(e))!Yp.call(t,n)&&n!==i&&Ql(t,n,{get:()=>e[n],enumerable:!(r=Vp(e,n))||r.enumerable});return t};var Kp=(t,e,i)=>(i=t!=null?jp(Hp(t)):{},Wp(e||!t||!t.__esModule?Ql(i,"default",{value:t,enumerable:!0}):i,t));var Ms=te((Bb,Gu)=>{"use strict";Gu.exports=Nm;function Nm(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 ju=te(Bu=>{"use strict";var Un=Bu;Un.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 fr=new Array(64),Hn=new Array(123);for(bt=0;bt<64;)Hn[fr[bt]=bt<26?bt+65:bt<52?bt+71:bt<62?bt-4:bt-59|43]=bt++;var bt;Hn[45]=62;Hn[95]=63;Un.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++]=fr[u>>2],l=(u&3)<<4,a=1;break;case 1:o[s++]=fr[l|u>>4],l=(u&15)<<2,a=2;break;case 2:o[s++]=fr[l|u>>6],o[s++]=fr[u&63],a=0;break}s>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,o)),s=0)}return a&&(o[s++]=fr[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 qu="invalid encoding";Un.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=Hn[l])===void 0)throw Error(qu);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(qu);return r-n};var Pm=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Mm=/[-_]/,Fm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;Un.test=function(e){return Pm.test(e)||Mm.test(e)&&Fm.test(e)}});var Uu=te((Vb,Vu)=>{"use strict";Vu.exports=Yn;function Yn(){this._listeners=Object.create(null)}Yn.prototype.on=function(e,i,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:i,ctx:r||this}),this};Yn.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};Yn.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 Zu=te((Ub,Ju)=>{"use strict";Ju.exports=Hu(Hu);function Hu(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,Yu),t.writeFloatBE=e.bind(null,Xu);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,Wu),t.readFloatBE=i.bind(null,Ku)})(),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,Yu,0,4),t.writeDoubleBE=e.bind(null,Xu,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,Wu,0,4),t.readDoubleBE=i.bind(null,Ku,4,0)})(),t}function Yu(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 Xu(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 Wu(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function Ku(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}});var tc=te(ec=>{"use strict";var Wn=ec,Xn=new TextDecoder("utf-8",{ignoreBOM:!0}),Hr,Qu=64;try{Hr=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}catch{Hr=Xn}Wn.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 dr(t,e,i,r){var n=i===0&&r===e.length?e:e.subarray(i,r);return t.decode(n)}Wn.read=function(e,i,r){if(r-i<1)return"";if(r-i>=Qu)return dr(Xn,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+dr(Xn,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+dr(Xn,e,o,r);n+=String.fromCharCode(s)}return n};Wn.readStrict=function(e,i,r){if(r-i<1)return"";if(r-i>=Qu)return dr(Hr,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+dr(Hr,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+dr(Hr,e,o,r);n+=String.fromCharCode(s)}return n};Wn.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 rc=te((Yb,ic)=>{"use strict";ic.exports=Dm;function Dm(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 oc=te((Xb,nc)=>{"use strict";nc.exports=Fe;var Yr;function Fe(t,e){this.lo=t>>>0,this.hi=e>>>0}var Fi=Fe.zero=new Fe(0,0);Fi.toNumber=function(){return 0};Fi.zzEncode=Fi.zzDecode=function(){return this};Fi.length=function(){return 1};var zm=Fe.zeroHash="\0\0\0\0\0\0\0\0";Fe.fromNumber=function(e){if(e===0)return Fi;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(Yr)e=Yr.fromString(e);else return Fe.fromNumber(parseInt(e,10));return e.low||e.high?new Fe(e.low>>>0,e.high>>>0):Fi};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 Yr?new Yr(this.lo|0,this.hi|0,!!e):{low:this.lo|0,high:this.hi|0,unsigned:!!e}};var fi=String.prototype.charCodeAt;Fe.fromHash=function(e){return e===zm?Fi:new Fe((fi.call(e,0)|fi.call(e,1)<<8|fi.call(e,2)<<16|fi.call(e,3)<<24)>>>0,(fi.call(e,4)|fi.call(e,5)<<8|fi.call(e,6)<<16|fi.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){Yr=t}});var sc=te((Xr,Fs)=>{(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 Xr=="object"?(e(Xr),typeof Fs=="object"&&(Fs.exports=i(Xr))):(function(){var r={};e(r),t.Long=i(r)})()})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:Xr,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(C,d,E){this.low=C|0,this.high=d|0,this.unsigned=!!E}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0});function r(C){return(C&&C.__isLong__)===!0}function n(C){var d=Math.clz32(C&-C);return C?31-d:d}i.isLong=r;var o={},s={};function a(C,d){var E,D,V;return d?(C>>>=0,(V=0<=C&&C<256)&&(D=s[C],D)?D:(E=u(C,0,!0),V&&(s[C]=E),E)):(C|=0,(V=-128<=C&&C<128)&&(D=o[C],D)?D:(E=u(C,C<0?-1:0,!1),V&&(o[C]=E),E))}i.fromInt=a;function l(C,d){if(isNaN(C))return d?I:F;if(d){if(C<0)return I;if(C>=w)return _}else{if(C<=-S)return T;if(C+1>=S)return G}return C<0?l(-C,d).neg():u(C%v|0,C/v|0,d)}i.fromNumber=l;function u(C,d,E){return new i(C,d,E)}i.fromBits=u;var c=Math.pow;function f(C,d,E){if(C.length===0)throw Error("empty string");if(typeof d=="number"?(E=d,d=!1):d=!!d,C==="NaN"||C==="Infinity"||C==="+Infinity"||C==="-Infinity")return d?I:F;if(E=E||10,E<2||36<E)throw RangeError("radix");var D;if((D=C.indexOf("-"))>0)throw Error("interior hyphen");if(D===0)return f(C.substring(1),d,E).neg();for(var V=l(c(E,8)),H=F,Z=0;Z<C.length;Z+=8){var ne=Math.min(8,C.length-Z),ve=parseInt(C.substring(Z,Z+ne),E);if(ne<8){var be=l(c(E,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(C,d){return typeof C=="number"?l(C,d):typeof C=="string"?f(C,d):u(C.low,C.high,typeof d=="boolean"?d:C.unsigned)}i.fromValue=h;var m=65536,g=1<<24,v=m*m,w=v*v,S=w/2,x=a(g),F=a(0);i.ZERO=F;var I=a(0,!0);i.UZERO=I;var z=a(1);i.ONE=z;var $=a(1,!0);i.UONE=$;var j=a(-1);i.NEG_ONE=j;var G=u(-1,2147483647,!1);i.MAX_VALUE=G;var _=u(-1,-1,!0);i.MAX_UNSIGNED_VALUE=_;var T=u(0,-2147483648,!1);i.MIN_VALUE=T;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(T)){var E=l(d),D=this.div(E),V=D.mul(E).sub(this);return D.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(T)?64:this.neg().getNumBitsAbs();for(var d=this.high!=0?this.high:this.low,E=31;E>0&&(d&1<<E)==0;E--);return this.high!=0?E+33:E+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 E=this.isNegative(),D=d.isNegative();return E&&!D?-1:!E&&D?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(T)?T:this.not().add(z)},y.neg=y.negate,y.add=function(d){r(d)||(d=h(d));var E=this.high>>>16,D=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+=D+ne,ge+=ee>>>16,ee&=65535,ge+=E+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 E=e.mul(this.low,this.high,d.low,d.high);return u(E,e.get_high(),this.unsigned)}if(d.isZero())return this.unsigned?I:F;if(this.eq(T))return d.isOdd()?T:F;if(d.eq(T))return this.isOdd()?T:F;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(x)&&d.lt(x))return l(this.toNumber()*d.toNumber(),this.unsigned);var D=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,gt=0;return gt+=Z*ge,Se+=gt>>>16,gt&=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+=D*ge+V*be+H*ve+Z*ne,ee&=65535,u(Se<<16|gt,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 E=(this.unsigned?e.div_u:e.div_s)(this.low,this.high,d.low,d.high);return u(E,e.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?I:F;var D,V,H;if(this.unsigned){if(d.unsigned||(d=d.toUnsigned()),d.gt(this))return I;if(d.gt(this.shru(1)))return $;H=I}else{if(this.eq(T)){if(d.eq(z)||d.eq(j))return T;if(d.eq(T))return z;var Z=this.shr(1);return D=Z.div(d).shl(1),D.eq(F)?d.isNegative()?z:j:(V=this.sub(d.mul(D)),H=D.add(V.div(d)),H)}else if(d.eq(T))return this.unsigned?I:F;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=F}for(V=this;V.gte(d);){D=Math.max(1,Math.floor(V.toNumber()/d.toNumber()));for(var ne=Math.ceil(Math.log(D)/Math.LN2),ve=ne<=48?1:c(2,ne-48),be=l(D),ge=be.mul(d);ge.isNegative()||ge.gt(V);)D-=ve,be=l(D,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 E=(this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,d.low,d.high);return u(E,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 E;return r(d)&&(d=d.toInt()),(d&=63)===0?this:d===32?u(this.high,this.low,this.unsigned):d<32?(E=32-d,u(this.low<<d|this.high>>>E,this.high<<d|this.low>>>E,this.unsigned)):(d-=32,E=32-d,u(this.high<<d|this.low>>>E,this.low<<d|this.high>>>E,this.unsigned))},y.rotl=y.rotateLeft,y.rotateRight=function(d){var E;return r(d)&&(d=d.toInt()),(d&=63)===0?this:d===32?u(this.high,this.low,this.unsigned):d<32?(E=32-d,u(this.high<<E|this.low>>>d,this.low<<E|this.high>>>d,this.unsigned)):(d-=32,E=32-d,u(this.low<<E|this.high>>>d,this.high<<E|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,E=this.low;return[E&255,E>>>8&255,E>>>16&255,E>>>24,d&255,d>>>8&255,d>>>16&255,d>>>24]},y.toBytesBE=function(){var d=this.high,E=this.low;return[d>>>24,d>>>16&255,d>>>8&255,d&255,E>>>24,E>>>16&255,E>>>8&255,E&255]},i.fromBytes=function(d,E,D){return D?i.fromBytesLE(d,E):i.fromBytesBE(d,E)},i.fromBytesLE=function(d,E){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,E)},i.fromBytesBE=function(d,E){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],E)},typeof BigInt=="function"&&(i.fromBigInt=function(d,E){var D=Number(BigInt.asIntN(32,d)),V=Number(BigInt.asIntN(32,d>>BigInt(32)));return u(D,V,E)},i.fromValue=function(d,E){return typeof d=="bigint"?i.fromBigInt(d,E):h(d,E)},y.toBigInt=function(){var d=BigInt(this.low>>>0),E=BigInt(this.unsigned?this.high>>>0:this.high);return E<<BigInt(32)|d});var N=t.default=i})});var Pt=te(Ds=>{"use strict";var W=Ds;W.asPromise=Ms();W.base64=ju();W.EventEmitter=Uu();W.float=Zu();W.utf8=tc();W.pool=rc();W.LongBits=oc();function ac(t){return t==="__proto__"||t==="prototype"||t==="constructor"}W.isUnsafeProperty=ac;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||Ds;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=sc();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 lc(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)!ac(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=lc;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 uc(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&&lc(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=uc;W.ProtocolError=uc("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 Jn=te((Kb,pc)=>{"use strict";pc.exports=K;var Mt=Pt(),$s,Kt=Mt.LongBits,cc=Mt.base64,zs=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 fc=function(){return Mt.Buffer?function(){return(K.create=function(){return new $s})()}:function(){return new K}};K.create=fc();K.alloc=function(e){return new Uint8Array(e)};K.alloc=Mt.pool(K.alloc,Uint8Array.prototype.subarray);function Ls(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 $m(t,e,i){for(var r=0;r<t.length;)e[i++]=t.charCodeAt(r++)}function Di(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=Di(e,this.buf,i),this};K.prototype.int32=function(e){return(e|=0)<0?(this._reserve(10),pr(Kt.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 pr(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=Kt.from(e);this._reserve(10);var r=this.pos;return this.pos=pr(i,this.buf,r),this};K.prototype.int64=K.prototype.uint64;K.prototype.sint64=function(e){var i=Kt.from(e).zzEncode();this._reserve(10);var r=this.pos;return this.pos=pr(i,this.buf,r),this};K.prototype.bool=function(e){return this._reserve(1),this.buf[this.pos++]=e?1:0,this};function hr(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),hr(e>>>0,this.buf,this.pos),this.pos+=4,this};K.prototype.sfixed32=K.prototype.fixed32;K.prototype.fixed64=function(e){var i=Kt.from(e);return this._reserve(8),hr(i.lo,this.buf,this.pos),hr(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=cc.length(e));cc.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=Ls(i);return r>1&&this.buf.copyWithin(e+r,e+1,e+1+i),Di(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,zs.write(e,this.buf,r+1))}var n=zs.length(e);return this.uint32(n),this._reserve(n),n===e.length?$m(e,this.buf,this.pos):zs.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=Di(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=pr(Kt.fromNumber(s),r,o):o=Di(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=Di((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=pr(Kt.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=pr(Kt.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 dc=16,hc=128;function Kn(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=Kn(this,i,hc);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)hr(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=Kn(this,i,hc);if(a)for(o=0;o<i;++o)s=Kt.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=Kt.from(e[o]),hr(s.lo,l,n),hr(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=Kn(this,i,dc);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=Kn(this,i,dc);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=Ls(i),r>1?(this._reserve(r-1),this.buf.copyWithin(n+r,n+1,n+1+i),this.pos+=r-1,Di(i,this.buf,n)):this.buf[n]=i}else i=this.pos,r=Ls(i),this._reserve(r),this.buf.copyWithin(r,0,i),Di(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){$s=t,K.create=fc(),$s._configure()}});var yc=te((Jb,gc)=>{"use strict";gc.exports=hi;var mc=Jn();hi.prototype=Object.create(mc.prototype,{constructor:{value:hi,writable:!0,enumerable:!1,configurable:!0}});var di=Pt();function hi(){mc.call(this)}var Gs;hi._configure=function(){hi.alloc=di.Buffer&&di.Buffer.allocUnsafe,Gs=di.Buffer&&di.Buffer.prototype.utf8Write?function(e,i,r){return i.utf8Write(e,r)}:function(e,i,r){return i.write(e,r)}};hi.prototype.bytes=function(e){di.isString(e)&&(e=di.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};hi.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?di.utf8.write(e,n,r+1):Gs(e,n,r+1))}var o=di.Buffer.byteLength(e);return this.uint32(o),this._reserve(o),Gs(e,this.buf,this.pos),this.pos+=o,this};hi._configure()});var Qn=te((Zb,Ec)=>{"use strict";Ec.exports=ae;var wt=Pt(),Bs,wc=wt.LongBits,Sc=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 vc(t){if(Array.isArray(t)&&(t=new Uint8Array(t)),t instanceof Uint8Array)return new ae(t);throw Error("illegal buffer")}var xc=function(){return wt.Buffer?function(i){return(ae.create=function(n){return wt.Buffer.isBuffer(n)?new Bs(n):vc(n)})(i)}:vc};ae.create=xc();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 qs(){var t=new wc(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 mr(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 mr(this.buf,this.pos+=4)};ae.prototype.sfixed32=function(){if(this.pos+4>this.len)throw ye(this,4);return mr(this.buf,this.pos+=4)|0};function bc(){if(this.pos+8>this.len)throw ye(this,8);return new wc(mr(this.buf,this.pos+=4),mr(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 Ic=8,_c=128;function Zn(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=Zn(this,n,_c);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++]=mr(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=Zn(this,n,_c);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++]=mr(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=Zn(this,n,Ic);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=Zn(this,n,Ic);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,Sc.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,Sc.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){Bs=t,ae.create=xc(),Bs._configure();var e=wt.Long?"toLong":"toNumber";wt.merge(ae.prototype,{int64:function(){return qs.call(this)[e](!1)},uint64:function(){return qs.call(this)[e](!0)},sint64:function(){return qs.call(this).zzDecode()[e](!1)},fixed64:function(){return bc.call(this)[e](!0)},sfixed64:function(){return bc.call(this)[e](!1)}})}});var Tc=te((Qb,Ac)=>{"use strict";Ac.exports=pi;var kc=Qn();pi.prototype=Object.create(kc.prototype,{constructor:{value:pi,writable:!0,enumerable:!1,configurable:!0}});var Cc=Pt();function pi(t){kc.call(this,t)}pi._configure=function(){Cc.Buffer&&(pi.prototype._slice=Cc.Buffer.prototype.slice)};pi.prototype.raw=function(e,i){return this._slice.call(this.buf,e,i)};pi.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)};pi._configure()});var Oc=te((ew,Rc)=>{"use strict";Rc.exports=Wr;var js=Pt();Wr.prototype=Object.create(js.EventEmitter.prototype,{constructor:{value:Wr,writable:!0,enumerable:!1,configurable:!0}});function Wr(t,e,i){if(typeof t!="function")throw TypeError("rpcImpl must be a function");js.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!e,this.responseDelimited=!!i}Wr.prototype.rpcCall=function t(e,i,r,n,o){if(!n)throw TypeError("request must be specified");var s=this;if(!o)return js.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}};Wr.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var Vs=te(Nc=>{"use strict";var Lm=Nc;Lm.Service=Oc()});var Us=te((iw,Pc)=>{"use strict";Pc.exports=Object.create(null)});var Fc=te(He=>{"use strict";He.build="minimal";He.Writer=Jn();He.BufferWriter=yc();He.Reader=Qn();He.BufferReader=Tc();He.util=Pt();He.rpc=Vs();He.roots=Us();He.configure=Mc;function Mc(){He.util.LongBits._configure(He.util.Long),He.Writer._configure(He.BufferWriter),He.Reader._configure(He.BufferReader)}Mc()});var Ys=te(Dc=>{"use strict";var Hs=Dc;Hs.numberRe=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;Hs.typeRefRe=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;Hs.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 $c=te((ow,zc)=>{"use strict";zc.exports=Xs;var Gm=Ys(),qm=Gm.reservedRe;function Xs(t,e){typeof t=="string"&&(e=t,t=void 0);var i=[];function r(o){if(typeof o!="string"){var s=n();if(Xs.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 w=f[h++];switch(v){case"d":case"f":return w=Number(w),Object.is(w,-0)?"-0":String(w);case"i":return String(Math.floor(w));case"j":return JSON.stringify(w);case"s":return String(w)}return"%"}),h!==f.length)throw Error("parameter count mismatch");return i.push(o),r}function n(o){return"function "+Bm(o||e)+"("+(t&&t.join(",")||"")+`){
2
+ `+i.join(`
3
+ `)+`
4
+ }`}return Object.defineProperty(r,"toString",{value:n,writable:!0,enumerable:!0,configurable:!0}),r}Xs.verbose=!1;function Bm(t){return!t||(t=String(t).replace(/[^\w$]/g,""),!t)?"":(/^\d/.test(t)&&(t="_"+t),qm.test(t)?t+"_":t)}});var Ws=te((sw,Lc)=>{"use strict";var gr=null;try{gr=Xp("fs"),(!gr||!gr.readFile||!gr.readFileSync)&&(gr=null)}catch{}Lc.exports=gr});var qc=te((aw,Gc)=>{"use strict";Gc.exports=Kr;var jm=Ms(),Ks=Ws();function Kr(t,e,i){return typeof e=="function"?(i=e,e={}):e||(e={}),i?!e.xhr&&Ks&&Ks.readFile?Ks.readFile(t,function(n,o){return n&&typeof XMLHttpRequest<"u"?Kr.xhr(t,e,i):n?i(n):i(null,e.binary?o:o.toString("utf8"))}):Kr.xhr(t,e,i):jm(Kr,this,t,e)}Kr.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 Vc=te(jc=>{"use strict";var Qs=jc,Zs=/^[a-zA-Z][a-zA-Z0-9+.-]+:\/\//;function Vm(t){if(typeof URL>"u"||!Zs.test(t))return null;try{return new URL(t).href}catch{return null}}function Um(t,e){if(typeof URL>"u"||!Zs.test(t)||Zs.test(e))return null;try{return new URL(e,t).href}catch{return null}}var Bc=Qs.isAbsolute=function(e){return/^(?:\/|\w+:|\\\\\w+)/.test(e)},Js=Qs.normalize=function(e){var i=Vm(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=Bc(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("/")};Qs.resolve=function(e,i,r){var n=Um(e,i);return n||(r||(i=Js(i)),Bc(i)?i:(r||(e=Js(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?Js(e+"/"+i):i))}});var vr=te((uw,Yc)=>{"use strict";Yc.exports=ue;var eo=yi();ue.prototype=Object.create(eo.prototype,{constructor:{value:ue,writable:!0,enumerable:!1,configurable:!0}});ue.className="Namespace";var ea=gi(),mi=Be(),Hm=Li(),zi,yr,$i;ue.fromJSON=function(e,i,r){if(r===void 0&&(r=0),r>mi.recursionLimit)throw Error("max depth exceeded");return new ue(e,i.options).addJSON(i.nested,r)};function Uc(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=Uc;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){eo.call(this,t,e),this.nested=void 0,this._nestedArray=null,this._lookupCache=Object.create(null),this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0}function Hc(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=mi.toArray(this.nested))}});ue.prototype.toJSON=function(e){return mi.toObject(["options",this.options,"nested",Uc(this.nestedArray,e)])};ue.prototype.addJSON=function(e,i){if(i===void 0&&(i=0),i>mi.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?zi.fromJSON:s.values!==void 0?$i.fromJSON:s.methods!==void 0?yr.fromJSON:s.id!==void 0?ea.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 $i)return this.nested[e].values;throw Error("no such enum: "+e)};ue.prototype.add=function(e){if(!(e instanceof ea&&e.extend!==void 0||e instanceof zi||e instanceof Hm||e instanceof $i||e instanceof yr||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 zi||i instanceof yr)){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 zi||this instanceof yr||this instanceof $i||this instanceof ea||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),Hc(this)};ue.prototype.remove=function(e){if(!(e instanceof eo))throw TypeError("object must be a ReflectionObject");if(e.parent!==this)throw Error(e+" is not a member of "+this);if(!mi.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),Hc(this)};ue.prototype.define=function(e,i){if(mi.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>mi.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,eo.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]),mi.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,[zi]);if(!i)throw Error("no such type: "+e);return i};ue.prototype.lookupEnum=function(e){var i=this.lookup(e,[$i]);if(!i)throw Error("no such Enum '"+e+"' in "+this);return i};ue.prototype.lookupTypeOrEnum=function(e){var i=this.lookup(e,[zi,$i]);if(!i)throw Error("no such Type or Enum '"+e+"' in "+this);return i};ue.prototype.lookupService=function(e){var i=this.lookup(e,[yr]);if(!i)throw Error("no such Service '"+e+"' in "+this);return i};ue._configure=function(t,e,i){zi=t,yr=e,$i=i}});var to=te((cw,Xc)=>{"use strict";Xc.exports=Ft;var ta=gi();Ft.prototype=Object.create(ta.prototype,{constructor:{value:Ft,writable:!0,enumerable:!1,configurable:!0}});Ft.className="MapField";var Ym=vi(),br=Be();function Ft(t,e,i,r,n,o){if(ta.call(this,t,e,r,void 0,void 0,n,o),!br.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 br.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!==br.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(Ym.mapKey[this.keyType]===void 0)throw Error("invalid key type: "+this.keyType);return ta.prototype.resolve.call(this)};Ft.d=function(e,i,r){return typeof r=="function"?r=br.decorateType(r).name:r&&typeof r=="object"&&(r=br.decorateEnum(r).name),function(o,s){br.decorateType(o.constructor).add(new Ft(s,e,i,r))}}});var io=te((fw,Wc)=>{"use strict";Wc.exports=bi;var ia=yi();bi.prototype=Object.create(ia.prototype,{constructor:{value:bi,writable:!0,enumerable:!1,configurable:!0}});bi.className="Method";var wr=Be();function bi(t,e,i,r,n,o,s,a,l){if(wr.isObject(n)?(s=n,n=o=void 0):wr.isObject(o)&&(s=o,o=void 0),!(e===void 0||wr.isString(e)))throw TypeError("type must be a string");if(!wr.isString(i))throw TypeError("requestType must be a string");if(!wr.isString(r))throw TypeError("responseType must be a string");ia.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}bi.fromJSON=function(e,i){return new bi(e,i.type,i.requestType,i.responseType,i.requestStream,i.responseStream,i.options,i.comment,i.parsedOptions)};bi.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return wr.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])};bi.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),ia.prototype.resolve.call(this)}});var no=te((dw,Zc)=>{"use strict";Zc.exports=it;var Jt=vr();it.prototype=Object.create(Jt.prototype,{constructor:{value:it,writable:!0,enumerable:!1,configurable:!0}});it.className="Service";var ra=io(),ro=Be(),Kc=Vs();function it(t,e){Jt.call(this,t,e),this.methods={},this._methodsArray=null}it.fromJSON=function(e,i,r){if(r===void 0&&(r=0),r>ro.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(ra.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=Jt.prototype.toJSON.call(this,e),r=e?!!e.keepComments:!1;return ro.toObject(["edition",this._editionToJSON(),"options",i&&i.options||void 0,"methods",Jt.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=ro.toArray(this.methods))}});function Jc(t){return t._methodsArray=null,t}it.prototype.get=function(e){return Object.prototype.hasOwnProperty.call(this.methods,e)?this.methods[e]:Jt.prototype.get.call(this,e)};it.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;Jt.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,Jt.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 ra?e.name==="__proto__"?this:(this.methods[e.name]=e,e.parent=this,Jc(this)):Jt.prototype.add.call(this,e)};it.prototype.remove=function(e){if(e instanceof ra){if(this.methods[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.methods[e.name],e.parent=null,Jc(this)}return Jt.prototype.remove.call(this,e)};it.prototype.create=function(e,i,r){for(var n=new Kc.Service(e,i,r),o=0,s;o<this.methodsArray.length;++o){var a=ro.lcFirst((s=this._methodsArray[o]).resolve().name).replace(/[^$\w_]/g,"");n[a]=(function(l,u,c){return function(h,m){return Kc.Service.prototype.rpcCall.call(this,l,u,c,h,m)}})(s,s.resolvedRequestType.ctor,s.resolvedResponseType.ctor)}return n}});var oo=te((hw,Qc)=>{"use strict";Qc.exports=Dt;var Xm=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,Xm.toJSONOptions)}});var na=te((pw,ef)=>{"use strict";ef.exports=Km;var so=St(),De=vi(),ao=Be();function Wm(t){return"missing required '"+t.name+"'"}function Jr(t){return t._features.utf8_validation==="VERIFY"?"stringVerify":"string"}function Sr(t,e){return t("if(!r.discardUnknown){")('util.makeProp(m,"$unknowns",false);')("(m.$unknowns||(m.$unknowns=[])).push(%s)",e)("}")}function Km(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 so||!n.repeated&&!n.map&&!n.hasPresence)&&(i=!0)}var o=ao.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 so?"int32":s.type,l="m"+ao.safeProp(s.name),u=s.resolvedType instanceof so&&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"?Jr(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"?Jr(s):a),o("continue")("}")("r.skipType(u,q,t2)")("}"),u&&(o("if(types[%i].valuesById[v]===undefined){",r),Sr(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"),Sr(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"),Sr(o,"r.raw(s,r.pos)")):o("%s.push(r.%s())",l,a==="string"?Jr(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",ao.safeProp(s.partOf.name),s.name),o("}else"),Sr(o,"r.raw(s,r.pos)")):o("%s=r.%s()",l,a==="string"?Jr(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{"),Sr(o,"r.raw(s,r.pos)")("}")):(s.resolvedType instanceof so&&s.typeDefault!==0?o("if((v=r.%s())!==%j)",a,s.typeDefault):a==="string"?o("if((v=r.%s()).length)",Jr(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",ao.safeProp(s.partOf.name),s.name),o("continue")("}")}for(r&&o("}"),o("r.skipType(%s,q,t)",r?"u":"t&7"),Sr(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})",Wm(f))}return o("return m")}});var aa=te((mw,tf)=>{"use strict";tf.exports=Qm;var Jm=St(),oa=Be();function at(t,e){return t.name+": "+e+(t.repeated&&e!=="array"?"[]":t.map&&e!=="object"?"{k:"+t.keyType+"}":"")+" expected"}function sa(t,e,i,r){var n=e.resolvedType;if(n)if(n instanceof Jm)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 Zm(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=oa.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"+oa.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){"),Zm(e,o,"k[i]"),sa(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),sa(e,o,n,s+"[i]")("}");else{if(o.partOf){var a=oa.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)}sa(e,o,n,s)}o.optional&&e("}")}return e("return null")}});var fa=te(nf=>{"use strict";var rf=nf,Zt=St(),ca=vi(),xt=Be();function la(t,e,i,r,n){if(e.resolvedType)if(e.resolvedType instanceof Zt){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}rf.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 Zt||ca.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),la(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 Zt?r("m%s=[]",s):r("m%s=Array(d%s.length)",s,s),r("for(var i=0;i<d%s.length;++i){",s),la(r,o,n,s+"[i]",o.resolvedType instanceof Zt?s:void 0)("}")("}")):(o.resolvedType instanceof Zt||r("if(d%s!=null){",s),a&&(o.resolvedType instanceof Zt?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):ca.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)),la(r,o,n,s),a&&r("}"),o.resolvedType instanceof Zt||r("}"))}return r("return m")};function ua(t,e,i,r,n){if(n||(n=r),e.resolvedType)e.resolvedType instanceof Zt?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}rf.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 Zt)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=ca.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),ua(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),ua(r,l,h,u+"[j]")("}")):(r("if(m%s!=null&&Object.hasOwnProperty.call(m,%j)){",u,l.name),ua(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 da=te(of=>{"use strict";var eg=of,tg=oo(),ig=Pt();eg[".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>ig.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 tg){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 co=te((vw,lf)=>{"use strict";lf.exports=pe;var dt=vr();pe.prototype=Object.create(dt.prototype,{constructor:{value:pe,writable:!0,enumerable:!1,configurable:!0}});pe.className="Type";var rg=St(),ma=Li(),lo=gi(),ng=to(),og=no(),ha=oo(),pa=Qn(),af=Jn(),ze=Be(),sg=ga(),ag=na(),lg=aa(),sf=fa(),ug=da();function pe(t,e){t=t.replace(/\W/g,""),dt.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 ha||(t.prototype=new ha,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,ha,!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 uo(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"?ng.fromJSON:lo.fromJSON)(o[s],i.fields[o[s]]));if(i.oneofs)for(o=Object.keys(i.oneofs),s=0;s<o.length;++s)n.add(ma.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?lo.fromJSON:a.fields!==void 0?pe.fromJSON:a.values!==void 0?rg.fromJSON:a.methods!==void 0?og.fromJSON:dt.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=dt.prototype.toJSON.call(this,e),r=e?!!e.keepComments:!1;return ze.toObject(["edition",this._editionToJSON(),"options",i&&i.options||void 0,"oneofs",dt.arrayToJSON(this.oneofsArray,e),"fields",dt.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;dt.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,dt.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 lo&&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),uo(this))}if(e instanceof ma){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),uo(this))}return dt.prototype.add.call(this,e)};pe.prototype.remove=function(e){if(e instanceof lo&&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),uo(this)}if(e instanceof ma){if(!ze.remove(this.oneofs,e,e.name))throw Error(e+" is not a member of "+this);return e.parent=null,e.onRemove(this),uo(this)}return dt.prototype.remove.call(this,e)};pe.prototype.isReservedId=function(e){return dt.isReservedId(this.reserved,e)};pe.prototype.isReservedName=function(e){return dt.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=sg(this)({Writer:af,types:n,util:ze}),this.decode=ag(this)({Reader:pa,types:n,util:ze,C:this.ctor}),this.verify=lg(this)({types:n,util:ze}),this.fromObject=sf.fromObject(this)({types:n,util:ze,C:this.ctor}),this.toObject=sf.toObject(this)({types:n,util:ze});var s=ug[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||af.create()).fork()).ldelim()};pe.prototype.decode=function(e,i){return this.setup().decode.apply(this,arguments)};pe.prototype.decodeDelimited=function(e){return e instanceof pa||(e=pa.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 mo=te((bw,ff)=>{"use strict";ff.exports=rt;var po=vr();rt.prototype=Object.create(po.prototype,{constructor:{value:rt,writable:!0,enumerable:!1,configurable:!0}});rt.className="Root";var fo=gi(),ya=St(),cg=Li(),zt=Be(),va,ba,xr;function rt(t){po.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 cf(){}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===cf;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(xr,v))return v}return Object.prototype.hasOwnProperty.call(xr,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{ba.filename=m;var w=ba(g,n,i),S,x=0;if(w.imports)for(;x<w.imports.length;++x)(S=a(w.imports[x])||n.resolvePath(m,w.imports[x]))&&u(S,!1,v+1);if(w.weakImports)for(x=0;x<w.weakImports.length;++x)(S=a(w.weakImports[x])||n.resolvePath(m,w.weakImports[x]))&&u(S,!0,v+1)}}catch(F){s(F)}!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(xr,m)){o?l(m,xr[m],v):(++c,setTimeout(function(){--c,l(m,xr[m],v)}));return}if(o){var w;try{w=zt.fs.readFileSync(m).toString("utf8")}catch(S){g||s(S);return}l(m,w,v)}else++c,n.fetch(m,function(S,x){if(--c,!!r){if(S){g?c||s(null,n):s(S);return}l(m,x,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,cf)};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 po.prototype.resolveAll.call(this)};var ho=/^[A-Z]/;function uf(t,e){var i=e.parent.lookup(e.extend);if(i){var r=new fo(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 fo)e.extend!==void 0&&!e.extensionField&&(uf(this,e)||this.deferred.push(e));else if(e instanceof ya)ho.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof cg)){if(e instanceof va)for(var i=0;i<this.deferred.length;)uf(this,this.deferred[i])?this.deferred.splice(i,1):++i;for(var r=0;r<e.nestedArray.length;++r)this._handleAdd(e._nestedArray[r]);ho.test(e.name)&&(e.parent[e.name]=e)}(e instanceof va||e instanceof ya||e instanceof fo)&&(this._fullyQualifiedObjects[e.fullName]=e)};rt.prototype._handleRemove=function(e){if(e instanceof fo){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 ya)ho.test(e.name)&&delete e.parent[e.name];else if(e instanceof po){for(var r=0;r<e.nestedArray.length;++r)this._handleRemove(e._nestedArray[r]);ho.test(e.name)&&delete e.parent[e.name]}delete this._fullyQualifiedObjects[e.fullName]};rt._configure=function(t,e,i){va=t,ba=e,xr=i}});var Be=te((ww,pf)=>{"use strict";var Ie=pf.exports=Pt(),df=Us(),wa,Sa;Ie.codegen=$c();Ie.fetch=qc();Ie.path=Vc();Ie.patterns=Ys();var hf=Ie.patterns.reservedRe;Ie.fs=Ws();Ie.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[]};Ie.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};Ie.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};Ie.isReserved=function(e){return hf.test(e)};Ie.safeProp=function(e){return!/^[$\w_]+$/.test(e)||hf.test(e)?"["+JSON.stringify(e)+"]":"."+e};Ie.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var fg=/_([a-z])/g;Ie.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(fg,function(i,r){return r.toUpperCase()})};Ie.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};Ie.compareFieldsById=function(e,i){return e.id-i.id};Ie.decorateType=function(e,i){if(e.$type)return i&&e.$type.name!==i&&(Ie.decorateRoot.remove(e.$type),e.$type.name=i,Ie.decorateRoot.add(e.$type)),e.$type;wa||(wa=co());var r=new wa(i||e.name);return Ie.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 dg=0;Ie.decorateEnum=function(e){if(e.$type)return e.$type;Sa||(Sa=St());var i=new Sa("Enum"+dg++,e);return Ie.decorateRoot.add(i),Object.defineProperty(e,"$type",{value:i,enumerable:!1}),i};Ie.setProperty=function(e,i,r,n){function o(s,a,l){var u=a.shift();if(Ie.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>Ie.recursionLimit)throw Error("max depth exceeded");return o(e,i,r)};Object.defineProperty(Ie,"decorateRoot",{get:function(){return df.decorated||(df.decorated=new(mo()))}})});var vi=te(mf=>{"use strict";var Zr=mf,hg=Be(),pg=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function Qr(t,e){var i=0,r=Object.create(null);for(e|=0;i<t.length;)r[pg[i+e]]=t[i++];return r}Zr.basic=Qr([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]);Zr.defaults=Qr([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",hg.emptyArray,null]);Zr.long=Qr([0,0,0,1,1],7);Zr.mapKey=Qr([0,0,0,5,5,0,0,0,1,1,0,2],2);Zr.packed=Qr([1,5,0,0,0,5,5,0,0,0,1,1,0])});var gi=te((xw,yf)=>{"use strict";yf.exports=$e;var tn=yi();$e.prototype=Object.create(tn.prototype,{constructor:{value:$e,writable:!0,enumerable:!1,configurable:!0}});$e.className="Field";var gf=St(),go=vi(),Te=Be(),en,mg=/^(?: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),tn.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&&!mg.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?go.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 en&&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 tn.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=go.defaults[this.type])===void 0?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof en?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 gf&&typeof this.typeDefault=="string"&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(this.options.packed!==void 0&&this.resolvedType&&!(this.resolvedType instanceof gf)&&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(go.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 en&&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)),tn.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&&go.defaults[this.type]===void 0){var r=this.parent.get(this.type.split(".").pop());r&&r instanceof en&&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 tn.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){en=e}});var Li=te((Iw,wf)=>{"use strict";wf.exports=nt;var vo=yi();nt.prototype=Object.create(vo.prototype,{constructor:{value:nt,writable:!0,enumerable:!1,configurable:!0}});nt.className="OneOf";var vf=gi(),yo=Be();function nt(t,e,i,r){if(Array.isArray(e)||(i=e,e=void 0),vo.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 yo.toObject(["options",this.options,"oneof",this.oneof,"comment",i?this.comment:void 0])};function bf(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 vf))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,bf(this),this};nt.prototype.remove=function(e){if(!(e instanceof vf))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){vo.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))}bf(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);vo.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){yo.decorateType(n.constructor).add(new nt(o,e)),Object.defineProperty(n,o,{get:yo.oneOfGetter(e),set:yo.oneOfSetter(e)})}}});var yi=te((_w,Sf)=>{"use strict";Sf.exports=Ue;Ue.className="ReflectionObject";var gg=Li(),It=Be(),bo,yg={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"},vg={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"},bg={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"},wg={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(!It.isString(t))throw TypeError("name must be a string");if(e&&!It.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 bo&&i._handleAdd(this)};Ue.prototype.onRemove=function(e){var i=e.root;i instanceof bo&&i._handleRemove(this),this.parent=null,this.resolved=!1};Ue.prototype.resolve=function(){return this.resolved?this:(this.root instanceof bo&&(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=It.merge({},this.options&&this.options.features,this._inferLegacyProtoFeatures(e));if(this._edition){if(e==="proto2")i=Object.assign({},bg);else if(e==="proto3")i=Object.assign({},wg);else if(e==="2023")i=Object.assign({},vg);else if(e==="2024")i=Object.assign({},yg);else throw new Error("Unknown edition: "+e);this._features=It.merge(i,r)}else if(this.partOf instanceof gg){var n=It.merge({},this.partOf._features);this._features=It.merge(n,r)}else if(!this.declaringField)if(this.parent){var o=It.merge({},this.parent._features);this._features=It.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))It.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];It.setProperty(s,r,i)}else o={},o[e]=It.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){bo=t}});var St=te((Ew,If)=>{"use strict";If.exports=ht;var xa=yi();ht.prototype=Object.create(xa.prototype,{constructor:{value:ht,writable:!0,enumerable:!1,configurable:!0}});ht.className="Enum";var xf=vr(),Ir=Be();function ht(t,e,i,r,n,o){if(xa.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]))}ht.prototype._resolveFeatures=function(e){return e=this._edition||e,xa.prototype._resolveFeatures.call(this,e),Object.keys(this.values).forEach(i=>{var r=Ir.merge({},this._features);this._valuesFeatures[i]=Ir.merge(r,this.valuesOptions&&this.valuesOptions[i]&&this.valuesOptions[i].features||{})}),this};ht.fromJSON=function(e,i){var r=new ht(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};ht.prototype.toJSON=function(e){var i=e?!!e.keepComments:!1;return Ir.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])};ht.prototype.add=function(e,i,r,n){if(!Ir.isString(e))throw TypeError("name must be a string");if(!Ir.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};ht.prototype.remove=function(e){if(!Ir.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};ht.prototype.isReservedId=function(e){return xf.isReservedId(this.reserved,e)};ht.prototype.isReservedName=function(e){return xf.isReservedName(this.reserved,e)}});var ga=te((Cw,Ef)=>{"use strict";Ef.exports=Sg;var Ia=St(),wi=vi(),_a=Be();function _f(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 Sg(t){for(var e=_a.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(_a.compareFieldsById),i=0;i<n.length;++i){var o=n[i].resolve(),s=t._fieldsArray.indexOf(o),a=o.resolvedType instanceof Ia?"int32":o.type,l=wi.basic[a];r="m"+_a.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|wi.mapKey[o.keyType]):wi.long[o.keyType]!==void 0?e("w.uint32(%i).fork().uint32(%i).%s(util.longFromKey(ks[i],%j))",(o.id<<3|2)>>>0,8|wi.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|wi.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&&wi.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?_f(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 Ia||wi.basic[a]!==void 0)?e("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",r,o.name):o.resolvedType instanceof Ia?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):wi.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?_f(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 kf=te((le,Cf)=>{"use strict";le=Cf.exports=Fc();le.build="light";function xg(t,e,i){return typeof e=="function"?(i=e,e=new le.Root):e||(e=new le.Root),e.load(t,i)}le.load=xg;function Ig(t,e){return e||(e=new le.Root),e.loadSync(t)}le.loadSync=Ig;le.encoder=ga();le.decoder=na();le.verifier=aa();le.converter=fa();le.ReflectionObject=yi();le.Namespace=vr();le.Root=mo();le.Enum=St();le.Type=co();le.Field=gi();le.OneOf=Li();le.MapField=to();le.Service=no();le.Method=io();le.Message=oo();le.wrappers=da();le.types=vi();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 Ca=te((kw,Rf)=>{"use strict";Rf.exports=Tf;var Ea=/[\s{}=;:[\],'"()<>]/g,_g=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,Eg=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,Cg=/^ *[*/]+ */,kg=/^\s*\*?\/*/,Ag=/\n/g,Tg=/\s/,Rg=/\\(.?)/g,Og={0:"\0",r:"\r",n:`
5
+ `,t:" "};function Af(t){return t.replace(Rg,function(e,i){switch(i){case"\\":case"":return i;default:return Og[i]||""}})}Tf.unescape=Af;function Tf(t,e){t=t.toString();var i=0,r=t.length,n=1,o=0,s={},a=[],l=null;function u(I){return Error("illegal "+I+" (line "+n+")")}function c(){var I=l==="'"?Eg:_g;I.lastIndex=i-1;var z=I.exec(t);if(!z)throw u("string");return i=I.lastIndex,w(l),l=null,Af(z[1])}function f(I){return t.charAt(I)}function h(I,z,$){var j={type:t.charAt(I++),lineEmpty:!1,leading:$},G;e?G=2:G=3;var _=I-G,T;do if(--_<0||(T=t.charAt(_))===`
6
+ `){j.lineEmpty=!0;break}while(T===" "||T===" ");for(var y=t.substring(I,z).split(Ag),N=0;N<y.length;++N)y[N]=y[N].replace(e?kg:Cg,"").trim();j.text=y.join(`
7
+ `).trim(),s[n]=j,o=n}function m(I){var z=g(I),$=t.substring(I,z),j=/^\s*\/\//.test($);return j}function g(I){for(var z=I;z<r&&f(z)!==`
8
+ `;)z++;return z}function v(){if(a.length>0)return a.shift();if(l)return c();var I,z,$,j,G,_,T=i===0;do{if(i===r)return null;for(I=!1;Tg.test($=f(i));)if($===`
9
+ `&&(T=!0,++n),++i===r)return null;if(f(i)==="/"){if(++i===r)throw u("comment");if(f(i)==="/")if(e){if(j=i,G=!1,m(i-1)){G=!0;do{if(i=g(i),i===r||(i++,!T))break;_=m(i),_&&n++}while(_)}else i=Math.min(r,g(i)+1);G&&(h(j,i,T),T=!0),n++,I=!0}else{for(G=f(j=i+1)==="/";f(++i)!==`
10
+ `;)if(i===r)return null;++i,G&&(h(j,i-1,T),T=!0),++n,I=!0}else if(($=f(i))==="*"){j=i+1,G=e||f(j)==="*";do{if($===`
11
+ `&&++n,++i===r)throw u("comment");z=$,$=f(i)}while(z!=="*"||$!=="/");++i,G&&(h(j,i-2,T),T=!0),I=!0}else return"/"}}while(I);var y=i;Ea.lastIndex=0;var N=Ea.test(f(y++));if(!N)for(;y<r&&!Ea.test(f(y));)++y;var C=t.substring(i,i=y);return(C==='"'||C==="'")&&(l=C),C}function w(I){a.push(I)}function S(){if(!a.length){var I=v();if(I===null)return null;w(I)}return a[0]}function x(I,z){var $=S(),j=$===I;if(j)return v(),!0;if(!z)throw u("token '"+$+"', '"+I+"' expected");return!1}function F(I){var z=null,$;return I===void 0?($=s[n-1],delete s[n-1],$&&(e||$.type==="*"||$.lineEmpty)&&(z=$.leading?$.text:null)):(o<I&&S(),$=s[I],delete s[I],$&&!$.lineEmpty&&(e||$.type==="/")&&(z=$.leading?null:$.text)),z}return Object.defineProperty({next:v,peek:S,push:w,skip:x,cmnt:F},"line",{get:function(){return n}})}});var Ff=te((Aw,Mf)=>{"use strict";Mf.exports=ei;ei.filename=null;ei.defaults={keepCase:!1};var Ng=Ca(),Of=mo(),Nf=co(),wo=gi(),Pg=to(),Pf=Li(),Mg=St(),Fg=no(),Dg=io(),zg=yi(),$g=vi(),Qt=Be(),Lg=/^[1-9][0-9]*$/,Gg=/^-?[1-9][0-9]*$/,qg=/^0[x][0-9a-fA-F]+$/,Bg=/^-?0[x][0-9a-fA-F]+$/,jg=/^0[0-7]+$/,Vg=/^-?0[0-7]+$/,Ug=/^(?:u?int|sint|s?fixed)(?:32|64)$/,Hg=/^(?:uint|fixed)(?:32|64)$/,Yg=Qt.patterns.numberRe,$t=/^[a-zA-Z_][a-zA-Z_0-9]*$/,_t=Qt.patterns.typeRefRe,Xg=536870911,Wg=2147483647;function ei(t,e,i){e instanceof Of||(i=e,e=new Of),i||(i=ei.defaults);var r=i.preferTrailingComment||!1,n=Ng(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,w=[],S={},x=i.keepCase?function(R){return R}:Qt.camelCase;function F(){w.forEach(R=>{R._edition=g,Object.keys(S).forEach(A=>{R.getOption(A)===void 0&&R.setOption(A,S[A],!0)})})}function I(R,A,P){var M=ei.filename;return P||(ei.filename=null),Error("illegal "+(A||"token")+" '"+R+"' ("+(M?M+", ":"")+"line "+n.line+")")}function z(){var R=[],A;do{if((A=o())!=='"'&&A!=="'")throw I(A);R.push(o()),l(A),A=a()}while(A==='"'||A==="'");return R.join("")}function $(R){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 G(A,!0)}catch{if(R&&_t.test(A))return A;throw I(A,"value")}}function j(R,A,P,M){var U,J;do if(A&&((U=a())==='"'||U==="'")){var re=z();if(R.push(re),g>=2023)throw I(re,"id")}else try{R.push([J=T(o(),M,P),l("to",!0)?T(o(),M,P):J])}catch(ie){if(A&&_t.test(U)&&g>=2023)R.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},D(oe,function(Me){if(Me==="option")ee(oe,Me),l(";");else throw I(Me)},function(){qt(oe)})}function G(R,A){var P=1;switch(R.charAt(0)==="-"&&(P=-1,R=R.substring(1)),R){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(Lg.test(R))return P*parseInt(R,10);if(qg.test(R))return P*parseInt(R,16);if(jg.test(R))return P*parseInt(R,8);if(Yg.test(R))return P*parseFloat(R);throw I(R,"number",A)}function _(R,A,P){if(R===null)throw I(R,"end of input");if(!A&&R.charAt(0)==="-")throw I(R,P||"integer");if(R==="0"||R==="-0")return 0;var M;if(Gg.test(R))M=parseInt(R,10);else if(Bg.test(R))M=parseInt(R,16);else if(Vg.test(R))M=parseInt(R,8);else throw I(R,P||"integer");return M||0}function T(R,A,P){switch(R){case"max":case"MAX":case"Max":return P||Xg}return _(R,A,"id")}function y(){if(f!==void 0)throw I("package");if(f=o(),f===null||!_t.test(f))throw I(f,"name");v=v.define(f),l(";")}function N(){var R=a(),A;switch(R){case"option":if(g<"2024")throw I("option");o(),z(),l(";");return;case"weak":A=m||(m=[]),o();break;case"public":o();default:A=h||(h=[]);break}R=z(),l(";"),A.push(R)}function C(){if(l("="),g=z(),g<2023)throw I(g,"syntax");l(";")}function d(){if(l("="),g=z(),!["2023","2024"].includes(g))throw I(g,"edition");l(";")}function E(R,A,P){switch(P===void 0&&(P=0),A){case"option":return ee(R,A),l(";"),!0;case"message":return V(R,A,P+1),!0;case"enum":return be(R,A),!0;case"export":case"local":return g<"2024"||(A=o(),A==="export"||A==="local")||A!=="message"&&A!=="enum"?!1:E(R,A,P);case"service":return Re(R,A,P+1),!0;case"extend":return yt(R,A,P),!0}return!1}function D(R,A,P){var M=n.line;if(R&&(typeof R.comment!="string"&&(R.comment=u()),R.filename=ei.filename),l("{",!0)){for(var U;(U=o())!=="}";)A(U);l(";",!0)}else P&&P(),l(";"),R&&(typeof R.comment!="string"||r)&&(R.comment=u(M)||R.comment)}function V(R,A,P){if(P===void 0&&(P=0),P>Qt.nestingLimit)throw Error("max depth exceeded");if((A=o())===null||!$t.test(A))throw I(A,"type name");var M=new Nf(A);D(M,function(J){if(!E(M,J,P))switch(J){case";":break;case"map":ne(M,J);break;case"required":if(g!=="proto2")throw I(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 I(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"||!_t.test(J))throw I(J);s(J),H(M,"optional",void 0,P+1);break}}),R.add(M),R===v&&w.push(M)}function H(R,A,P,M){var U=o();if(U===null)throw I(U,"end of input");if(U==="group"){Z(R,A,P,M);return}for(;U.endsWith(".")||(a()||"").startsWith(".");){var J=o();if(J===null)throw I(J,"end of input");U+=J}if(!_t.test(U))throw I(U,"type");var re=o();if(re===null)throw I(re,"end of input");if(!$t.test(re))throw I(re,"name");var oe=re;re=x(re),l("=");var ie=new wo(re,T(o()),U,A==="proto3_optional"?"optional":A,P);if(oe!==re&&(ie.protoName=oe),D(ie,function(Rt){if(Rt==="option")ee(ie,Rt),l(";");else throw I(Rt)},function(){qt(ie)}),A==="proto3_optional"){var Me=new Pf("_"+re);ie.setOption("proto3_optional",!0),Me.add(ie),R.add(Me)}else R.add(ie);R===v&&w.push(ie)}function Z(R,A,P,M){if(M===void 0&&(M=0),M>Qt.nestingLimit)throw Error("max depth exceeded");if(g>=2023)throw I("group");var U=o();if(U===null||!$t.test(U))throw I(U,"name");var J=Qt.lcFirst(U);U===J&&(U=Qt.ucFirst(U)),l("=");var re=T(o()),oe=new Nf(U);oe.group=!0;var ie=new wo(J,re,U,A,P);ie.filename=ei.filename,D(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 I(Oe);switch(Oe=o(),Oe){case"message":V(oe,Oe,M+1);break;case"enum":V(oe,Oe,M+1);break;default:throw I(Oe)}break;default:throw I(Oe)}}),R.add(oe).add(ie),R===v&&(w.push(oe),w.push(ie))}function ne(R){l("<");var A=o();if($g.mapKey[A]===void 0)throw I(A,"type");l(",");var P=o();if(!_t.test(P))throw I(P,"type");l(">");var M=o();if(M===null||!$t.test(M))throw I(M,"name");l("=");var U=M;M=x(M);var J=new Pg(M,T(o()),A,P);U!==M&&(J.protoName=U),D(J,function(oe){if(oe==="option")ee(J,oe),l(";");else throw I(oe)},function(){qt(J)}),R.add(J)}function ve(R,A,P){if((A=o())===null||!$t.test(A))throw I(A,"name");var M=new Pf(x(A));D(M,function(J){J==="option"?(ee(M,J),l(";")):(s(J),H(M,"optional",void 0,P))}),R.add(M)}function be(R,A){if((A=o())===null||!$t.test(A))throw I(A,"name");var P=new Mg(A),M=[];D(P,function(re){switch(re){case";":break;case"option":ee(P,re),l(";");break;case"reserved":j(P.reserved||(P.reserved=[]),!0,Wg,!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);R.add(P),R===v&&w.push(P)}function ge(R){if(!$t.test(R))throw I(R,"name");l("=");var A=T(o(),!0),P={options:void 0};return P.getOption=function(M){return this.options[M]},P.setOption=function(M,U){zg.prototype.setOption.call(P,M,U)},P.setParsedOption=function(){},D(P,function(U){if(U==="option")ee(P,U),l(";");else throw I(U)},function(){qt(P)}),{name:R,id:A,comment:P.comment,options:P.parsedOptions||P.options}}function ee(R,A){var P,M,U=!0;for(A==="option"&&(A=o());A!=="=";){if(A===null)throw I(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(R,oe);M=M&&M[0]==="."?M.slice(1):M,P=P&&P[P.length-1]==="."?P.slice(0,-1):P,gt(R,P,ie,M)}function ce(R,A,P){if(P===void 0&&(P=0),P>Qt.recursionLimit)throw Error("max depth exceeded");if(l("{",!0)){for(var M={};!l("}",!0);){de=o();var U;if(de===null)throw I(de,"end of input");if(de==="["){de=o();var J=de===null?-1:de.lastIndexOf("/");if(de===null||!_t.test(J<0?de:de.slice(J+1)))throw I(de,"name");U="["+de+"]",l("]")}else{if(!$t.test(de))throw I(de,"name");U=de}var re;if(l(":",!0),a()==="{")re=ce(R,A+"."+U,P+1);else if(a()==="["){re=[];var oe,ie;if(l("[",!0)&&!l("]",!0)){do ie=a()==="{",oe=ie?ce(R,A+"."+U,P+1):$(!0),re.push(oe);while(l(",",!0));l("]"),typeof oe<"u"&&(ie||Se(R,A+"."+U,oe))}}else re=$(!0),Se(R,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"&&R instanceof wo&&Ug.test(R.type)?_(o(),!Hg.test(R.type)):$(!0);return Se(R,A,Oe),Oe}function Se(R,A,P){if(v===R&&/^features\./.test(A)){S[A]=P;return}A==="json_name"&&R instanceof wo&&(R.jsonName=P),R.setOption&&R.setOption(A,P)}function gt(R,A,P,M){R.setParsedOption&&R.setParsedOption(A,P,M)}function qt(R){if(l("[",!0)){do ee(R,"option");while(l(",",!0));l("]")}return R}function Re(R,A,P){if(P===void 0&&(P=0),P>Qt.recursionLimit)throw Error("max depth exceeded");if((A=o())===null||!$t.test(A))throw I(A,"service name");var M=new Fg(A);D(M,function(J){if(!E(M,J,P)&&J!==";")if(J==="rpc")ut(M,J);else throw I(J)}),R.add(M),R===v&&w.push(M)}function ut(R,A){var P=u(),M=A;if(!$t.test(A=o()))throw I(A,"name");var U=A,J,re,oe,ie;if(l("("),l("stream",!0)&&(re=!0),!_t.test(A=o())||(J=A,l(")"),l("returns"),l("("),l("stream",!0)&&(ie=!0),!_t.test(A=o())))throw I(A);oe=A,l(")");var Me=new Dg(U,M,J,oe,re,ie);Me.comment=P,D(Me,function(Rt){if(Rt!==";")if(Rt==="option")ee(Me,Rt),l(";");else throw I(Rt)}),R.add(Me)}function yt(R,A,P){if((A=o())===null||!_t.test(A))throw I(A,"reference");var M=A;D(null,function(J){switch(J){case"required":case"repeated":H(R,J,M,P+1);break;case"optional":g==="proto3"?H(R,"proto3_optional",M,P+1):H(R,"optional",M,P+1);break;default:if(g==="proto2"||!_t.test(J))throw I(J);s(J),H(R,"optional",M,P+1);break}})}for(var de;(de=o())!==null;)switch(de){case";":break;case"package":if(!c)throw I(de);y();break;case"import":N();break;case"syntax":if(!c)throw I(de);C();break;case"edition":if(!c)throw I(de);d();break;case"option":ee(v,de),l(";",!0);break;default:if(E(v,de,0)){c=!1;continue}throw I(de)}return F(),ei.filename=null,{package:f,imports:h,weakImports:m,root:e}}});var $f=te((Tw,zf)=>{"use strict";zf.exports=Et;var Kg=/\/|\./;function Et(t,e){Kg.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 Df;Et("duration",{Duration:Df={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});Et("timestamp",{Timestamp:Df});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 Gf=te((Lt,Lf)=>{"use strict";Lt=Lf.exports=kf();Lt.build="full";Lt.tokenize=Ca();Lt.parse=Ff();Lt.common=$f();Lt.Root._configure(Lt.Type,Lt.parse,Lt.common)});var Bf=te((Rw,qf)=>{"use strict";qf.exports=Gf()});import{existsSync as kp,readFileSync as Ap,realpathSync as Cv}from"node:fs";import{relative as kv}from"node:path";import{Worker as ov}from"node:worker_threads";import{existsSync as sv,mkdirSync as av,readFileSync as Bl,writeFileSync as lv}from"node:fs";import{basename as uv,dirname as cv}from"node:path";import{existsSync as bn,readFileSync as z0}from"node:fs";import{randomUUID as xh}from"node:crypto";import{isAbsolute as eu,win32 as tu}from"node:path";function An(t,e=!1){let i=String(t??"").trim().replaceAll("\\","/");if(e&&(!i||i==="."))return"";if(!i||eu(i)||tu.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 Lr(t){if(t==null)return null;if(t.version!==1)throw new Error("unsupported scriptSync version");let e=String(t.clientImportRoot||"").trim();if(!eu(e)&&!tu.isAbsolute(e))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:An(t.workspaceDir,!0),clientImportRoot:e,clientSubdir:An(t.clientSubdir,!0)}}import{basename as Pr,dirname as $0,isAbsolute as L0,join as Ih,resolve as _h}from"node:path";var iu="https://oss.070077.xyz/prefabs/",Gr="prefab-v1",Jp=[[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 Tn(t){return!Number.isSafeInteger(t)||!Jp.some(([e,i])=>t>=e&&t<=i)?null:t===10003004||t===10008001?128:256}var Rn="https://oss.070077.xyz/images/",fs="sprite-v1",On="/qxqy-assets/",Zp=[[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 Nn(t,e){return`${st(e)}:${t}`}function ru(t,e){return st(e)==="StaticReference"&&oi(t,e)}function oi(t,e){let i=st(e);return i==="Prefab"?Tn(t)!==null:i==="StaticReference"&&Number.isSafeInteger(t)&&t>100006&&Zp.some(([r,n])=>t>=r&&t<=n)}var Pn="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"}}),Mn="pc-16-9",Ze=2,er=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),tr=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"}),Fn=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),nu=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}),Qp=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"});function ir(t,e){return st(e)==="StaticReference"&&Qp[t]||(oi(t,e)?"sprite":"missing")}var ou=50888,qr=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function rr(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)=>rr(r,`${e}[${n}]`,i));else for(let[r,n]of Object.entries(t))rr(n,`${e}.${r}`,i);i.delete(t)}}function se(t){return rr(t),JSON.parse(JSON.stringify(t))}function su(t,e="$"){rr(t,e)}function au(t){return Ee[t]||Ee[Mn]}function Br(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 em(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 tm(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 Dn({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||Dn();return{scale:em(e.scale),rotation:tm(e.rotation),anchorMin:Br(e.anchorMin??e.anchor_min,.5,.5),anchorMax:Br(e.anchorMax??e.anchor_max,.5,.5),offset:Br(e.offset,0,0),size:Br(e.size,0,0),pivot:Br(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),w=je(u?.y),S=je(c?.x,.5),x=je(c?.y,.5),F=m-f+v,I=g-h+w,z=n+f+je(l?.x)-v*S,$=o+h+je(l?.y)-w*x;return{left:z,bottom:$,width:F,height:I,right:z+F,top:$+I,centerX:z+F/2,centerY:$+I/2}}function nr(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function im(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 ds(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),w=je(r?.y,1),S=t.left+t.width*je(n?.x,.5),x=t.bottom+t.height*je(n?.y,.5),F=g(h*s+m*f*a)*v,I=g(c*a)*v,z=g(-h*a+m*f*s)*w,$=g(c*s)*w;return{a:F,b:I,c:z,d:$,tx:S-F*S-z*x,ty:x-I*S-$*x}}function jr(t,e,i){return im(t||nr(),ds(e,i))}function lu(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"?au(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 hs(t){return{posX:t.centerX,posY:t.centerY,width:t.width,height:t.height}}function Ai(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 uu(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 cu(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 Ti(t){return au(t).platform}function fu(t){let e={};for(let i of qe)e[i]=t(i);return e}var rm={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function du(t,e){for(let[i,r]of Object.entries(rm))for(let n of r)if(!Number.isFinite(t?.[i]?.[n]))throw new Error(`${e}.${i}.${n} must be a finite number`)}function si(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)du(t[i],`${e}.${i}`)}function Ri(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`);si(t.transformByPlatform,`${t.name||t.id||"\u63A7\u4EF6"}.transformByPlatform`)}function Oi(t,e){if(!qe.includes(e))throw new Error(`unknown platform ${e}`);return du(t?.[e],`transformByPlatform.${e}`),Nt(t[e])}var nm=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"}]),om=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 hu(t){return[...nm,...om[t]||[]]}function pu(t,e){return hu(t).find(i=>i.key===e)||null}function ps(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 mu(t,e={}){let i={};for(let r of hu(t)){let n=Object.hasOwn(e||{},r.key)?e[r.key]:r.defaultValue;i[r.key]=ps(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 ct(t){let e=Number(t);return Number.isSafeInteger(e)&&e>=1073741824&&e<=1077936127}function Ht(t){let e=Number(t);return Number.isSafeInteger(e)&&e>0&&e<=2147483647}function ms(t,e){if(Ht(t)&&!ct(t))throw new Error(`${e||"\u8D44\u4EA7"}: \u7D22\u5F15 ${t} \u8D85\u51FA 1073741824\u20131077936127\uFF1B\u8BF7\u5148\u6821\u51C6\u7D22\u5F15\u5E76\u6838\u5BF9 Lua \u5F15\u7528\uFF0C\u5BFC\u51FA\u4E0D\u4F1A\u81EA\u52A8\u91CD\u7F16\u53F7\u3002`)}function gs(t,e){if(t){e(t);for(let i of t.children||[])gs(i,e)}}function or(t,e=new Set,{skipServerContainer:i=!1}={}){return gs(t,r=>{i&&r.kind==="server-container"||ct(r.guid)&&e.add(Number(r.guid))}),e}function ai(t,e=1073741850){let i=Number.isSafeInteger(e)&&e>0?e:1073741850;i<1073741850&&(i=1073741850);for(let r of t)ct(r)&&r>=i&&(i=Number(r)+1);for(;t.has(i);)i+=1;if(i>1077936127)throw new Error("GUID space exhausted");return i}function gu(t,e=new Set,{skipServerContainer:i=!1}={}){let r=[];gs(t,n=>{if(i&&n.kind==="server-container")return;let o=Number(n.guid);if(ct(o)&&!e.has(o)){e.add(o),n.guid=o;return}r.push(n)});for(let n of r){let o=ai(e);n.guid=o,e.add(o)}return e}function ft(t){return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Yt(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(!ft(g.giaInfoIndex))continue;let v=n.get(g.giaInfoIndex)||[];v.push(g),n.set(g.giaInfoIndex,v);let w=o.get(g.kind)||new Set;w.add(g.giaInfoIndex),o.set(g.kind,w)}let s=(t.root.children||[]).filter(g=>g.kind!=="server-container"),a=new Set(s),l=s.some((g,v)=>ft(g.giaInfoIndex)&&s.slice(0,v).some(w=>w.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(w=>a.has(w))||g[0];for(let w of g)w!==v&&c.add(w)}let f=new Map,h=Number.isSafeInteger(t.meta.giaNextAssetIndex)&&t.meta.giaNextAssetIndex>=2?t.meta.giaNextAssetIndex:2;for(let g of i){if(!ft(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)||!ft(g.giaInfoIndex)):i.filter(g=>!ft(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 ys=1;function vs(t="n"){let e=`${t}${ys}`;return ys+=1,e}function zn(t=1){ys=t}function bs(t,{isRootContainer:e=!1}={}){if(t==="server-container"||t==="fullscreen"||t==="container"&&e)return Dn({layout:"stretch"});let i=nu[t]||[80,80];return Dn({layout:"center",size:i})}function sm(t,e){return fu(()=>bs(t,e))}function am(t){si(t);let e={};for(let i of qe)e[i]=Oi(t,i);return e}function we(t,e={}){if(!tr[t])throw new Error(`unknown kind: ${t}`);Object.hasOwn(e,"transformByCanvas")&&Ri(e);let i=e.isRootContainer===!0,r=e.id||vs(t==="server-container"?"sc":"n"),n=Object.hasOwn(e,"transformByPlatform")?am(e.transformByPlatform):sm(t,{isRootContainer:i}),o={id:r,kind:t,name:e.name||tr[t],guid:e.guid??0,giaRelatedGuids:Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(s=>Number.isSafeInteger(Number(s))&&Number(s)>0).map(Number):[],...ft(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:mu(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??qr.font,o.bgColor=e.bgColor??qr.bg,o.enableOutline=e.enableOutline!==!1,o.outlineColor=e.outlineColor??qr.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??qr.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??ou,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 Ni(){zn(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 w of Object.values(m.transformByPlatform))w.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),zn(12),gu(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 sr(){zn(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),zn(6);let l={version:1,layoutSchemaVersion:Ze,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:Pn,giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:t};return Yt(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 ws(t,e="n"){let i=vs(e);for(;Ve(t,i);)i=vs(e);return i}function li(t,e){let i=null;return Ae(t,(r,n)=>{r.id===e&&(i=n)}),i}function Ss(t){let e=t.root||t;return e.kind==="container"?e:(e.children||[]).find(i=>i.kind==="container")||(e.children||[])[0]||e}function Vr(t){if(t.meta?.assetType!=="client-control-template")return Ss(t);let e=Ve(t.root,t.selectedId);if(!e||e.kind==="server-container")return t.root.children?.[0]||t.root;let i=li(t.root,e.id);for(;i&&i.kind!=="server-container";)e=i,i=li(t.root,e.id);return e}function xs(t){Ri(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"&&lm(t.transformByPlatform);let i=we(t.kind,e);return i.children=(t.children||[]).map(r=>xs(r)),i}function lm(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 yu(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 vu(t,e){if(t.id===e)throw new Error("cannot remove root");let i=li(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 bu=1e-4;function um(t,e){return Math.abs(t.anchorMax[e]-t.anchorMin[e])>bu&&Math.abs(t.size[e])<=bu}function cm(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=Ai(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"])um(t,a)&&(s.offset[a]=t.offset[a],s.size[a]=t.size[a]);return s}function wu({transformByPlatform:t,source:e,canvasId:i,syncAllDevices:r,sourceParentBox:n=Qe(i),targetParentBoxByPlatform:o={}}){si(t);let s=Ti(i),a={};for(let l of qe)l===s?a[l]=Nt(e):r!==!1?a[l]=cm(e,n,o[l]||Qe(er[l])):a[l]=Oi(t,l);return si(a),a}function ui(t,e){return Oi(t,Ti(e))}import{createCanvas as Rm}from"@napi-rs/canvas";import{existsSync as bm,openSync as wm,closeSync as Sm,fstatSync as xm,readFileSync as Im}from"node:fs";import{extname as _m,isAbsolute as Em}from"node:path";import{createHash as Cm}from"node:crypto";import{workerData as Gn}from"node:worker_threads";import{GlobalFonts as _u}from"@napi-rs/canvas";var Ur='"Microsoft YaHei UI","Microsoft YaHei","HarmonyOS Sans SC","Noto Sans CJK SC",sans-serif',ar="/qxqy-font";var Is=t=>`QxqyLocal_${t}`,Su=t=>t?`"${Is(t)}",${Ur}`:Ur;import{existsSync as fm,mkdirSync as dm,readFileSync as hm,renameSync as pm,rmSync as mm,writeFileSync as gm}from"node:fs";import{randomUUID as ym}from"node:crypto";import{homedir as _s}from"node:os";import{dirname as vm,join as $n,win32 as Ln}from"node:path";function Es(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([Ln.join(r,"Genshin Impact","Genshin Impact Game",n),Ln.join(i+"\\","Mihoyo","Genshin Impact","Genshin Impact Game",n),Ln.join(r,"HoYoPlay","games","Genshin Impact game",n),Ln.join(r,"miHoYo Launcher","games","Genshin Impact Game",n)])]}function xu(){if(process.env.QXQY_FONT_CONFIG_PATH)return process.env.QXQY_FONT_CONFIG_PATH;let t=process.platform==="win32"?process.env.APPDATA||$n(_s(),"AppData","Roaming"):process.platform==="darwin"?$n(_s(),"Library","Application Support"):process.env.XDG_CONFIG_HOME||$n(_s(),".config");return $n(t,"beyond-simulator","font.json")}function Cs(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=t.scope===void 0?"all":t.scope;if(!["game","all"].includes(e))throw new Error("\u8BF7\u9009\u62E9\u5B57\u4F53\u5E94\u7528\u8303\u56F4");let i=typeof t.path=="string"?t.path.trim():"";if(i.length>4096)throw new Error("\u5B57\u4F53\u8DEF\u5F84\u8FC7\u957F");if((i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),t.mode==="custom"&&!i)throw new Error("\u8BF7\u586B\u5199\u5B57\u4F53\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");return{mode:t.mode,path:t.mode==="custom"?i:"",scope:e}}function ks(t=xu()){if(!fm(t))return{mode:"auto",path:"",scope:"all"};try{return Cs(JSON.parse(hm(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 Iu(t,e=xu()){let i=`${e}.${ym()}.tmp`;try{dm(vm(e),{recursive:!0}),gm(i,JSON.stringify(t,null,2)+`
12
+ `,{flag:"wx",mode:384}),pm(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{mm(i,{force:!0})}}function Tu(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=Cm("sha256").update(e).digest("hex"),n=Is(r);try{if(!_u.has(n)&&!_u.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 As(t){if(!t)return null;if(!Em(t)||![".ttf",".otf"].includes(_m(t).toLowerCase()))throw new Error("QXQY_FONT_PATH must be an absolute path to a TTF or OTF font");let e,i;try{e=wm(t,"r");let r=xm(e);if(!r.isFile()||r.size<12||r.size>33554432)throw new Error("invalid size");i=Im(e)}catch{throw new Error("QXQY_FONT_PATH must point to a readable font file of at most 32 MiB")}finally{e!==void 0&&Sm(e)}return Tu(i)}var Eu=!1,qn=null,Pi={path:"",source:"system",scope:"all"},lr=null,Ts="",Ru=!1;function Ou(t){if(t.mode==="custom")return{font:As(t.path),path:t.path,source:"custom"};if(t.mode==="auto"){let e;for(let i of Es())if(bm(i))try{return{font:As(i),path:i,source:"auto"}}catch(r){e=r}if(e)throw e}return{font:null,path:"",source:"system"}}function Xt(){if(!Eu){if(Gn&&Object.hasOwn(Gn,"localFont"))qn=Gn.localFont?Tu(Gn.localFont):null;else{try{lr=ks()}catch(t){Ts=t.message}if(Pi.scope=lr?.scope||"all",process.env.QXQY_FONT_PATH)qn=As(process.env.QXQY_FONT_PATH),Pi={...Pi,path:process.env.QXQY_FONT_PATH,source:"environment"};else if(lr)try{let t=Ou(lr);qn=t.font,Pi={...Pi,path:t.path,source:t.source}}catch(t){Ts=t.message}}Eu=!0}return qn}function Rs(){Xt();let t={mode:"auto",path:"",scope:"all"},e=Ts;try{t=ks()}catch(i){e=i.message}return{...t,active:{...Pi},error:e,environmentPath:process.env.QXQY_FONT_PATH||"",defaultPaths:Es(),restartRequired:Ru||lr!==null&&JSON.stringify(lr)!==JSON.stringify(t)}}function km(t){Xt();let e=process.env.QXQY_FONT_PATH;if(e&&(!t||!Object.hasOwn(t,"scope")||Object.hasOwn(t,"mode")||Object.hasOwn(t,"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 i=Cs(e?{...Rs(),scope:t.scope}:t),r=e?{path:e,source:"environment"}:Ou(i);return Iu(i),Ru=!0,{...Rs(),nextFont:{path:r.path,source:r.source}}}var ur=()=>Su(Xt()?.id),Cu=t=>["127.0.0.1","localhost","::1","[::1]","::ffff:127.0.0.1"].includes(t);function ku(t){try{let e=t.headers.host;return Cu(t.socket.remoteAddress)&&Cu(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 Nu(t,e,{settingsEnabled:i=!0}={}){let r=new URL(t.url||"/","http://localhost");if(r.pathname!==ar&&!r.pathname.startsWith(`${ar}/`))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===`${ar}/settings`)return!i||!ku(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=Rs();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=km(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=Xt();return o&&!ku(t)?n(403,"text/plain","Local font access requires a direct loopback connection"):r.pathname===`${ar}/manifest`?n(200,"application/json",JSON.stringify({id:o?.id??null,scope:Pi.scope})):o&&r.pathname===`${ar}/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 Os=Object.freeze({aqua:"00ffff",black:"000000",blue:"0000ff",brown:"a52a2a",cyan:"00ffff",darkblue:"0000a0",fuchsia:"ff00ff",green:"008000",grey:"808080",lightblue:"add8e6",lime:"00ff00",magenta:"ff00ff",maroon:"800000",navy:"000080",olive:"808000",orange:"ffa500",purple:"800080",red:"ff0000",silver:"c0c0c0",teal:"008080",white:"ffffff",yellow:"ffff00"});function Am(t){let e=Object.hasOwn(Os,t.toLowerCase())?Os[t.toLowerCase()]:t.slice(1);return!Object.hasOwn(Os,t.toLowerCase())&&!/^#[\da-f]{6}([\da-f]{2})?$/i.test(t)?null:(parseInt(e.slice(6)||"ff",16)<<24|parseInt(e.slice(0,6),16))>>>0}function Tm(t){let e=/^<\/(b|i|color|size)>$/i.exec(t);if(e)return{name:e[1].toLowerCase(),close:!0};let i=/^<(b|i)>$/i.exec(t);if(i)return{name:i[1].toLowerCase(),value:!0};let r=/^<(color|size)=(?:"([^"\s<>]+)"|'([^'\s<>]+)'|([^\s'"<>]+))>$/i.exec(t);if(!r)return null;let n=r[1].toLowerCase(),o=r[2]??r[3]??r[4];if(n==="color"){let a=Am(o);return a===null?null:{name:n,value:a}}let s=Number(o);return/^\d+$/.test(o)&&Number.isSafeInteger(s)&&s>0?{name:n,value:s}:null}function Pu(t){let e=String(t??"").replace(/\r\n?/g,`
13
+ `),i=[],r=[],n=0;for(let l of e.matchAll(/<[^<>\r\n]*>/g)){l.index>n&&i.push({text:e.slice(n,l.index)});let u={text:l[0],tag:Tm(l[0]),paired:!1};i.push(u),n=l.index+l[0].length,u.tag&&(u.tag.close?r.at(-1)?.tag.name===u.tag.name?r.pop().paired=u.paired=!0:r.length=0:r.push(u))}n<e.length&&i.push({text:e.slice(n)});let o=[],s=[{bold:!1,italic:!1,size:null,color:null}],a=!1;for(let l of i)if(l.paired)if(a=!0,l.tag.close)s.pop();else{let u={b:"bold",i:"italic",size:"size",color:"color"}[l.tag.name];s.push({...s.at(-1),[u]:l.tag.value})}else if(l.text){let u=s.at(-1),c=o.at(-1);c&&["bold","italic","size","color"].every(f=>c[f]===u[f])?c.text+=l.text:o.push({text:l.text,...u})}return{rich:a,text:o.map(l=>l.text).join(""),runs:o}}function Bn(t,e){return`${t.italic?"italic ":""}${t.bold?"bold ":""}${t.fontSize}px ${e}`}var Mi=Rm(1,1).getContext("2d"),Mu=new WeakMap,Fu=(t,e)=>Math.max(1,Math.trunc(Number.isFinite(Number(t))?Number(t):e));function Om(t,e,i,r,n,o){let s=[],a=[],l=0,u=e,c=0,f=()=>{let w=a.length?a.reduce((z,$)=>Math.max(z,$.fontSize),0):u,S=w*1.2,x=a.length?a.reduce((z,$)=>Math.max(z,$.ascent),0):w*.8,F=a.length?a.reduce((z,$)=>Math.max(z,$.descent),0):w*.2,I=(S-x-F)/2+x;s.push({runs:a,width:l,top:c,height:S,baseline:I,fontSize:w}),c+=S,a=[],l=0};for(let w of t.runs){let S={fontSize:w.size??e,bold:w.bold,italic:w.italic,color:w.color};Mi.font=Bn(S,r);let x=Mi.measureText("Mg"),F=x.fontBoundingBoxAscent??x.emHeightAscent??S.fontSize*.8,I=x.fontBoundingBoxDescent??x.emHeightDescent??S.fontSize*.2;u=S.fontSize;for(let z of w.text){if(z===`
14
+ `){f();continue}let $=a.at(-1),j=$&&["fontSize","bold","italic","color"].every(T=>$[T]===S[T]),G=Mi.measureText((j?$.text:"")+z).width,_=l+G-(j?$.width:0);a.length&&_>i&&(f(),$=null,G=Mi.measureText(z).width,_=G),$&&j?($.text+=z,$.width=G):a.push({text:z,...S,x:l,width:G,ascent:F,descent:I}),l=_}}f();let h=s.map(w=>w.runs.map(S=>S.text).join("")),m=s.reduce((w,S)=>Math.max(w,S.fontSize),0),g=n==="textbox"&&t.text?m*.25+4:0,v=t.text?c+g:0;return{fontSize:e,lines:h,lineHeight:e*1.2,contentHeight:c,blockInset:g,requiredHeight:v,textWidth:i,fits:v<=o+1e-6&&s.every(w=>w.width<=i+1e-6),richLines:s}}function Wt(t,e,i){let r=String(t.text??"").replace(/\r\n?/g,`
15
+ `),n=Fu(t.fontSize,20),o=Math.min(n,Fu(t.minimumFontSize,10)),s=t.adaptiveFontSize===!0,a=ur(),l=JSON.stringify([r,e,i,n,o,s,t.kind,t.showScrollBar,a]),u=Mu.get(t);if(u?.key===l)return u.value;let c=Pu(r),f=(w,S)=>{if(c.rich)return Om(c,w,S,a,t.kind,i);Mi.font=`${w}px ${a}`;let x=[];for(let G of r.split(`
16
+ `)){let _="";for(let T of G)_&&Mi.measureText(_+T).width>S&&(x.push(_),_=""),_+=T;x.push(_)}let F=w*1.2,I=x.length*F,z=t.kind==="textbox"&&r?w*.25+4:0,$=r?I+z:0,j=$<=i+1e-6&&x.every(G=>Mi.measureText(G).width<=S+1e-6);return{fontSize:w,lines:x,lineHeight:F,contentHeight:I,blockInset:z,requiredHeight:$,textWidth:S,fits:j}},h=Math.max(0,e-4),m=f(n,h);if(s&&!m.fits&&o<n){m=f(o,h);let w=o+1,S=n-1;for(;w<=S;){let x=Math.floor((w+S)/2),F=f(x,h);F.fits?(m=F,w=x+1):S=x-1}}t.kind==="textwindow"&&t.showScrollBar!==!1&&m.contentHeight>i&&(m=f(m.fontSize,Math.max(0,h-12)));let g=m.lines.length,v=m.contentHeight;if(t.kind==="textbox"&&(g=0,v=0,m.lines.join(`
17
+ `)))for(let w=0;w<m.lines.length;w++){let S=m.richLines?.[w],x=S?S.top+S.height:(w+1)*m.lineHeight;if(x+m.blockInset>i+1e-6)break;g=w+1,v=x}return m={...m,visibleLineCount:g,visibleContentHeight:v},Mu.set(t,{key:l,value:m}),m}var jn=t=>Number.isFinite(Number(t))?Math.max(0,Number(t)):0;function cr(t,e){if(!t||t.kind!=="image"||t.enableMask!==!0||!e)return null;let i=jn(t.sourceWidth??t.width),r=jn(t.sourceHeight??t.height),n=t.enableSoftEdge===!0,o=t.softEdgeMode!=="Pixel",s=n?jn(t.softEdgeWidthX):0,a=n?jn(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 Vn(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 Du(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 Ns(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}function zu(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 ci(t,e,i=Ti(e)){let r=Qe(e),n={};function o(s,a,l,u=!0,c=[]){let f=Oi(s.transformByPlatform,i),h=Vt(a,f),m=s.kind==="server-container"?l:jr(l,h,f),g=lu(h,m),v=u&&s.visible!==!1,w=s.kind==="image"&&s.enableMask===!0?cr({...s,width:h.width,height:h.height},Vn(m,h.centerX,h.centerY)):null,S=w?[...c,w]:c;n[s.id]={...h,...hs(h),id:s.id,kind:s.kind,name:s.name,visible:s.visible!==!1,visibleInHierarchy:v,active:s.active!==!1,rotationX:f.rotation.x,rotationY:f.rotation.y,rotationZ:f.rotation.z,renderLeft:g.left,renderBottom:g.bottom,renderWidth:g.width,renderHeight:g.height,renderRotationZ:g.rotationZ,renderMatrix:m,...S.length?{masks:S}:{},primitive:s.kind==="image"?ir(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:Wt(s,h.width,h.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 x=s.kind==="server-container"?a:h;for(let F of s.children||[])o(F,x,m,v,S)}return o(t,r,nr()),{canvas:r,boxes:n}}function Ps(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:tr[n.kind]||n.kind,depth:o,parentId:s,ancestorIds:a,siblingIndex:l,siblingCount:u,templateId:c,childCount:(n.children||[]).length,incomplete:!Fn.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 L(t,e,i,r,n={}){return{key:t,label:e,type:i,value:r,...n}}function $u(t,e,i,r){if(!t)return null;let n=ui(t.transformByPlatform,e),o=hs(i),s=[L("name","\u540D\u79F0","string",t.name),L("active","\u521D\u59CB\u6FC0\u6D3B","bool",t.active!==!1),L("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",t.visible!==!1),L("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",t.canControllerFocus===!0),L("posX","\u4F4D\u7F6E X","number",o.posX,{computed:!0}),L("posY","\u4F4D\u7F6E Y","number",o.posY,{computed:!0}),L("width","\u5927\u5C0F W","number",o.width,{computed:!0}),L("height","\u5927\u5C0F H","number",o.height,{computed:!0}),L("rotationX","\u65CB\u8F6C X","number",n.rotation.x),L("rotationY","\u65CB\u8F6C Y","number",n.rotation.y),L("rotationZ","\u65CB\u8F6C Z","number",n.rotation.z),L("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",t.syncAllDevices!==!1),L("anchorType","\u951A\u70B9\u7C7B\u578B","enum",cu(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"}]}),L("anchorMinX","\u951A\u70B9 Min X","number",n.anchorMin.x),L("anchorMinY","\u951A\u70B9 Min Y","number",n.anchorMin.y),L("anchorMaxX","\u951A\u70B9 Max X","number",n.anchorMax.x),L("anchorMaxY","\u951A\u70B9 Max Y","number",n.anchorMax.y),L("pivotX","\u4E2D\u5FC3 X","number",n.pivot.x),L("pivotY","\u4E2D\u5FC3 Y","number",n.pivot.y)];if(t.kind==="container"&&s.push(L("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",t.isolateNavigation===!0),L("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",t.disableKeyEventPassthrough===!0),L("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",t.disableCursorEventPassthrough===!0),L("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(L("fontSize","\u5B57\u53F7","number",t.fontSize),L("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",t.adaptiveFontSize===!0),L("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",t.minimumFontSize),L("fontColor","\u6587\u672C\u8272","color",t.fontColor),L("bgColor","\u80CC\u666F\u8272","color",t.bgColor),L("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",t.enableOutline!==!1),L("outlineColor","\u63CF\u8FB9\u8272","color",t.outlineColor),L("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"}]}),L("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"}]}),L("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(L("imageSource","\u56FE\u7247\u6E90","enum",t.imageSource,{options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"},{value:"Prefab",label:"\u5143\u4EF6"}]}),L("imageId","imageId","number",t.imageId??0),L("imageType","\u56FE\u7247\u7C7B\u578B","enum",t.imageType??null,{options:[{value:"Basic",label:"\u57FA\u7840"},{value:"Stretch",label:"\u62C9\u4F38"}]}),L("imageColor","\u586B\u5145\u8272","color",t.imageColor),L("enableMask","\u5F00\u542F\u906E\u7F69","bool",t.enableMask===!0),L("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",t.enableSoftEdge===!0,{gia:"W"}),L("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",t.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),L("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",t.softEdgeWidthX),L("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",t.softEdgeWidthY),L("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",t.horizontalSoftRange),L("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",t.verticalSoftRange),L("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",t.enableFill===!0,{gia:"W"}),L("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"}]}),L("fillHorizontalType","\u65B9\u5411","enum",t.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),L("fillVerticalType","\u65B9\u5411","enum",t.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),L("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"}]}),L("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"}]}),L("fillAmount","\u8FDB\u5EA6","percent",t.fillAmount),L("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(L("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",t.raycastTarget!==!1),L("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",t.interactable!==!1),L("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",t.unavailableChildId,{options:a,gia:"W"}),L("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",t.hoverChildId,{options:a,gia:"W"}),L("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",t.pressedChildId,{options:a,gia:"W"}),L("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",t.selectedChildId,{options:a,gia:"W"}),L("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",t.clickAudioId))}return t.kind==="reference"&&s.push(L("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",t.referencedPrefabId??"")),(t.kind==="textwindow"||t.kind==="grid")&&s.push(L("interactable","\u5141\u8BB8\u6EDA\u52A8\u4EA4\u4E92","bool",t.interactable!==!1),L("showScrollBar","\u663E\u793A\u6EDA\u52A8\u6761","bool",t.showScrollBar!==!1)),t.kind==="grid"&&s.push(L("itemPrefabId","\u5217\u8868\u9879\u6A21\u677F\u7D22\u5F15","number",t.itemPrefabId??0),L("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",t.raycastTarget!==!1),L("scrollDirection","\u6EDA\u52A8\u65B9\u5411","enum",t.scrollDirection,{options:[{value:"Vertical",label:"\u7EB5\u5411"},{value:"Horizontal",label:"\u6A2A\u5411"}]}),L("layoutConstraint","\u6392\u5217\u9650\u5236","enum",t.layoutConstraint,{options:[{value:"AutoWrap",label:"\u81EA\u52A8\u6362\u884C"},{value:"Fixed",label:"\u56FA\u5B9A\u884C\u5217\u6570"}]}),L("layoutConstraintFixedCount","\u6BCF\u884C\u6216\u6BCF\u5217\u6570\u91CF","number",t.layoutConstraintFixedCount??1),L("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",t.cellSizeX,{evidence:"W"}),L("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",t.cellSizeY,{evidence:"W"}),L("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",t.spacingX,{evidence:"W"}),L("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",t.spacingY,{evidence:"W"}),L("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",t.padding1X,{evidence:"W"}),L("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",t.padding1Y,{evidence:"W"}),L("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",t.padding2X,{evidence:"W"}),L("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",t.padding2Y,{evidence:"W"}),L("previewCount","\u9884\u89C8\u6570\u91CF","number",t.previewCount)),t.kind==="keyhint"&&s.push(L("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",t.keyboardKeyCode??t.giaRaw?.keyHintField502??1,{gia:"W"}),L("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",t.controllerKeyCode??t.giaRaw?.keyHintField501??1)),(t.kind==="animation"||t.kind==="fullscreen")&&s.push(L("animationId",t.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",t.animationId??"")),(!Fn.includes(t.kind)||t.kind==="textwindow"||t.kind==="grid")&&s.push(L("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:tr[t.kind]||t.kind,incomplete:!Fn.includes(t.kind),fields:s}}function Lu(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.visibleInHierarchy===!1||!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 Vf=Kp(Bf(),1);function _r(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 Jg=String.raw`
2
18
  syntax = "proto3";
3
19
  // Root.graph is singular in the game's canonical schema, but template-list
4
20
  // assets legally emit field 1 more than once. Model it as repeated here so
@@ -24,7 +40,7 @@ message UiControlGroup {
24
40
  oneof value {
25
41
  Transform transform = 11; WrapperString name = 12; Field14 field14 = 14;
26
42
  string empty72 = 72; string empty73 = 73; string empty74 = 74; string empty75 = 75;
27
- string empty76 = 76; string empty77 = 77; string empty78 = 78; string empty79 = 79;
43
+ bytes empty76 = 76; string empty77 = 77; string empty78 = 78; string empty79 = 79;
28
44
  string empty80 = 80; string empty81 = 81; string empty82 = 82; string empty83 = 83;
29
45
  string empty84 = 84; string empty85 = 85; string empty86 = 86;
30
46
  }
@@ -34,7 +50,7 @@ message UiControlGroup {
34
50
  oneof value {
35
51
  Transform transform = 13; Field14 field14 = 14; RootChildRef rootChildRef = 73;
36
52
  GenericSlot genericSlot = 74; TextConfig textConfig = 75; CursorConfig cursorConfig = 76;
37
- string templateRefSlot = 77; FooterSlot footerSlot = 78; ContainerNodeConfig containerNodeSlot = 79;
53
+ bytes templateRefSlot = 77; FooterSlot footerSlot = 78; ContainerNodeConfig containerNodeSlot = 79;
38
54
  GridViewConfig gridView = 80; ButtonPresetConfig buttonPreset = 81; KeyHintConfig keyHint = 83;
39
55
  ImageSlotConfig imageSlot = 84; ImageConfig image = 85; string effectSlot = 86;
40
56
  string fullscreenEffectSlot = 87;
@@ -99,18 +115,38 @@ message ImageConfig {
99
115
  message SliceVector { float field501 = 501; float field502 = 502; }
100
116
  }
101
117
  message FooterSlot { int32 field505 = 505; }
102
- `,{root:dc}=uc.parse(fc,{keepCase:!1}),Ne=dc.lookupType("Root"),it=20,Zr=4,Wo=806,Ko=1657,fi={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},Jo={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},hc="server-control-template",qi="client-control-template";function Xi(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var pc=Object.fromEntries(Object.entries(Jo).map(([e,t])=>[t,e])),Zo=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"]]}),Qo=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}),mc=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Qr(e){return{class:1,type:8,id:e}}function di(e,t,i,r){return{...r,field501:t,field502:i,field503:1,nodeRef:Qr(e)}}function gc(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 hi(e,t=new Set){let i=new Map,r=[];for(let n of gc(e)){let o=Number(n.guid);Me(o)&&!t.has(o)?(t.add(o),n.guid=o,i.set(n.id,o)):r.push(n)}for(let n of r){let o=Ze(t);t.add(o),n.guid=o,i.set(n.id,o)}return i}function yc(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:Object.fromEntries(Object.entries(e.rotation).filter(([,t])=>t!==0))}}function bc(e,t){let r={multiPlatform:{platforms:ue.map(n=>({platformType:Jo[n],transform:yc(e.transformByPlatform[n])})),field502:fi[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:di(t,4,12,{transform:r})}}function vc(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:di(t,5,i?23:86,{field14:n})},bc(e,t)]}function Sc(e,t,i,r){let n=(l,u,f,h,p)=>({[f]:"",field501:l,field502:u,details:di(t,l+2,u,{[h]:p})}),o=e.giaRaw||{},a=Array.isArray(e.scriptMappingIds)&&e.scriptMappingIds.length?{field501:o.genericField501||1,field502:e.scriptMappingIds.map(l=>({field1:{id:Number(l)}}))}:{field501:o.genericField501??0},s=n(63,83,"empty73","genericSlot",a),c=n(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(o.footerField505)?e.canControllerFocus?1:0:o.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(o.textAlign)?Math.trunc(o.textAlign):l,f={field501:o.textField501??20,field503:o.textField503??12,color:e.fontColor>>>0,color2:e.bgColor>>>0,color3:e.outlineColor>>>0,text:{value:e.text||""},fontSize:Math.trunc(e.fontSize),minimumFontSize:Math.trunc(e.minimumFontSize),...e.adaptiveFontSize?{adaptive:1}:{},...e.enableOutline===!1?{outlineOff:1}:{},...u?{align:u}:{},verticalAlign:o.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`),f.field511=o.textField511??1,f.viewFlags={field502:o.textViewField502??1,field503:o.textViewField503??1},[s,{empty81:"",field501:71,field502:94,details:di(t,66,94,{textConfig:f})},c]):[s,n(64,84,"empty74","textConfig",f),c]}if(e.kind==="image"){let l=[0,1].includes(o.imageSlotType??0)?e.imageType==="Stretch"?1:0:o.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],f=Number.isFinite(o.imageFillType)?Math.trunc(o.imageFillType):u||1;e.enableFill&&!f&&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:o.imageField502??1,field504:o.imageField504??1,field505:o.imageField505??1,field507:o.imageField507??2,field508:Math.round(Math.max(0,Math.min(1,Number(e.fillAmount)||0))*100),border:{field501:Xi(e.softEdgeWidthX,8),field502:Xi(e.softEdgeWidthY,8)},field512:Xi(e.horizontalSoftRange,85),field513:Xi(e.verticalSoftRange,85),fillType:f,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&f?{enableFill:1}:{},...e.reverseMaskArea?{reverseMask:1}:{}};return[s,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(k=>k.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"),f=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}:{},...f?{hoverChild:f}:{},...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(o.cursorField501)?e.raycastTarget!==!1?1:0:o.cursorField501}),c]:e.kind==="reference"?[s,n(66,89,"empty76","templateRefSlot",o.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:o.gridField501??1,cellSize:{field501:e.cellSizeX,field502:e.cellSizeY},gap:{field501:e.spacingX,field502:e.spacingY},padding1:{field501:e.padding1X,field502:e.padding1Y},padding2:{field501:e.padding2X,field502:e.padding2Y},field507:o.gridField507??1,field508:o.gridField508??1,field509:o.gridField509??1,field511:o.gridField511??5,field512:o.gridField512??1}),c]):e.kind==="keyhint"?[s,n(72,95,"empty82","keyHint",{field501:Number.isFinite(o.keyHintField501)?Math.trunc(o.keyHintField501):e.controllerKeyCode??1,field502:Number.isFinite(o.keyHintField502)?Math.trunc(o.keyHintField502):e.keyboardKeyCode??1}),c]:e.kind==="animation"?[s,n(75,98,"empty85","effectSlot",o.effectSlot??""),c]:e.kind==="fullscreen"?[s,n(76,99,"empty86","fullscreenEffectSlot",o.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 wc(e,t){if(t)return 1;if(!Ae(e.giaInfoIndex))throw new Error(`${e.name}: \u7F3A\u5C11\u5408\u6CD5\u7684\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7`);return e.giaInfoIndex}function Ic(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 en(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),o=r(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),a=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}-${o}-${a}-\\${c}.gia`}function Wi(e,t,i,r,n,o=!1,a=!1,s=a,c=!1){let l=i.get(e.id),f=(c?[...e.children||[]].reverse():e.children||[]).map(m=>i.get(m.id)),h=o?r:f,p=vc(e,l,o);if(o){let m=e.children?.[0];m&&p.push({empty72:"",field501:62,field502:82,details:di(l,64,82,{rootChildRef:{guid:i.get(m.id)}})})}else p.push(...Sc(e,l,i,n));return{id:Qr(l),relatedIds:h.map(m=>Qr(m)),name:e.name,which:o?21:a?70:15,ui:{content:{guid:l,info:[{guid:{value:l},field501:1,field502:5},...o||s?[{index:{value:wc(e,o)},field501:2,field502:6}]:[],...o||a?[{related:{value:Ic(e,n,o?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:o?[]:f,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:p}}}}function xc(e,t){let i=new Map;for(let r of e||[]){if(!r.controlId||!(t===qi?r.controlAsset===qi:r.controlAsset!==qi))continue;let o=i.get(r.controlId)||[];o.push(r.guid),i.set(r.controlId,o)}return i}function ea(e,t,i,r){let n=xc(t,i),o=new Map;Q(e.root,a=>{n.has(a.id)&&(o.set(a,a.scriptMappingIds),a.scriptMappingIds=n.get(a.id))});try{return r()}finally{for(let[a,s]of o)s===void 0?delete a.scriptMappingIds:a.scriptMappingIds=s}}function tn(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function rn(e){let t=e.meta?.gameVersion;return!t||t==="7.0.50"?Hi:t}function ta(e,t,i,r,n=[]){let o=$t(e,!0),a=o.filter(({parent:u})=>u?.kind==="server-container");if(!a.length)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u6A21\u677F");let s=new Set(a.map(({node:u})=>u.id)),c=o.filter(({node:u})=>!s.has(u.id)),l=o.map(({node:u})=>t.get(u.id));return ea(e,n,qi,()=>({graph:a.map(({node:u,parent:f})=>Wi(u,f,t,l,i,!1,!0,!0,!0)),accessories:c.map(({node:u,parent:f})=>Wi(u,f,t,l,i,!1,!1,!0,!0)),filePath:r||en(e,!0),gameVersion:rn(e),...tn(e)}))}function ia(e,t,i,r,n){let o=$t(e),a=[o[0],...o.slice(1).reverse()],s=a.map(({node:c})=>t.get(c.id));return ea(e,i.scripts,hc,()=>({graph:[Wi(e.root,null,t,s,r,!0,!1,!1,!0),...i.units||[]],accessories:a.map(({node:c,parent:l})=>Wi(c,l,t,s,r,!1,!1,!1,!0)),filePath:n||en(e,!1),gameVersion:rn(e),...tn(e)}))}function ra(e,t){let i=nn(e),r=t(i);if(!r.valid)throw new Error(`GIA compatibility validation failed:
118
+ `,{root:Zg}=Vf.default.parse(Jg,{keepCase:!1}),Ct=Zg.lookupType("Root"),Si=20,ka=4,Uf=806,Hf=1657,rn={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},Yf={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},Qg="server-control-template",xo="client-control-template";function So(t,e){let i=Number(t);return Number.isFinite(i)?i:e}var ey=Object.fromEntries(Object.entries(Yf).map(([t,e])=>[e,t])),Xf=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"]]}),Wf=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}),ty=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Aa(t){return{class:1,type:8,id:t}}function nn(t,e,i,r){return{...r,field501:e,field502:i,field503:1,nodeRef:Aa(t)}}function iy(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 on(t,e=new Set,{preserveLegacy:i=!1}={}){let r=new Map,n=[],o=iy(t);if(!i)for(let s of o)ms(s.guid,s.name);for(let s of o){let a=Number(s.guid);(i?Ht(a):ct(a))&&!e.has(a)?(e.add(a),s.guid=a,r.set(s.id,a)):n.push(s)}for(let s of n){let a=ai(e);e.add(a),s.guid=a,r.set(s.id,a)}return r}function ry(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 ny(t,e){let r={multiPlatform:{platforms:qe.map(n=>({platformType:Yf[n],transform:ry(t.transformByPlatform[n])})),field502:rn[t.kind]||25,...t.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:nn(e,4,12,{transform:r})}}function oy(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:nn(e,5,i?23:86,{field14:n})},ny(t,e)]}function sy(t,e,i,r){let n=(u,c,f,h,m)=>({[f]:"",field501:u,field502:c,details:nn(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:nn(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:So(t.softEdgeWidthX,8),field502:So(t.softEdgeWidthY,8)},field512:So(t.horizontalSoftRange,85),field513:So(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 w=t[g];return w?(t.children||[]).some(S=>S.id===w)?i.get(w)||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 ay(t,e){if(e)return 1;if(!ft(t.giaInfoIndex))throw new Error(`${t.name}: \u7F3A\u5C11\u5408\u6CD5\u7684\u5BA2\u6237\u7AEF\u8D44\u4EA7\u7F16\u53F7`);return t.giaInfoIndex}function ly(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 Ta(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 Io(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=oy(t,u,o);if(o){let g=t.children?.[0];g&&m.push({empty72:"",field501:62,field502:82,details:nn(u,64,82,{rootChildRef:{guid:i.get(g.id)}})})}else m.push(...sy(t,u,i,n));return{id:Aa(u),relatedIds:h.map(g=>Aa(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:ay(t,o)},field501:2,field502:6}]:[],...o||s?[{related:{value:ly(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 uy(t,e){let i=new Map;for(let r of t||[]){if(!r.controlId||!(e===xo?r.controlAsset===xo:r.controlAsset!==xo))continue;let o=i.get(r.controlId)||[];o.push(r.guid),i.set(r.controlId,o)}return i}function Kf(t,e,i,r){let n=uy(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 Ra(t){let e=Number(t.meta?.giaModeFlag);return Number.isSafeInteger(e)&&e>=0?{modeFlag:e}:{}}function Oa(t){let e=t.meta?.gameVersion;return!e||e==="7.0.50"?Pn:e}function Jf(t,e,i,r,n=[]){let o=_r(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 Kf(t,n,xo,()=>({graph:s.map(({node:c,parent:f})=>Io(c,f,e,u,i,!1,!0,!0,!0)),accessories:l.map(({node:c,parent:f})=>Io(c,f,e,u,i,!1,!1,!0,!0)),filePath:r||Ta(t,!0),gameVersion:Oa(t),...Ra(t)}))}function Zf(t,e,i,r,n){let o=_r(t),s=[o[0],...o.slice(1).reverse()],a=s.map(({node:l})=>e.get(l.id));return Kf(t,i.scripts,Qg,()=>({graph:[Io(t.root,null,e,a,r,!0,!1,!1,!0),...i.units||[]],accessories:s.map(({node:l,parent:u})=>Io(l,u,e,a,r,!1,!1,!1,!0)),filePath:n||Ta(t,!1),gameVersion:Oa(t),...Ra(t)}))}function Qf(t,e){let i=Na(t),r=e(i);if(!r.valid)throw new Error(`GIA compatibility validation failed:
103
119
  ${r.errors.join(`
104
- `)}`);return i}function na(e,t={}){Q(e.root,dt);let i=[];je(e,{warnings:i});let r=hi(V(e)),n=e.meta?.assetType==="client-control-template",o;if(n)o=ta(e,r,i,void 0,t.scripts||[]);else{let s=on(t.scripts||[],new Set(r.values()));i.push(...s.warnings),o=ia(e,r,s,i)}return{buffer:ra(o,n?sn:ln),warnings:[...new Set(i)]}}function oa(e,t,i={}){Q(e.root,dt),t&&Q(t.root,dt);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"];t&&je(t,{warnings:r});let n=t?.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,a=V(e),s=t?V(t):null,c=hi(a,o),l=on(i.scripts||[],o);r.push(...l.warnings.filter(x=>x!==sa));let u=String(i.fileName||`${a.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),f=en({...a,meta:{...a.meta,giaFileName:u}},!1),h=ia(a,c,l,r,f),p={graph:[],accessories:[]};if(n.length&&s){let x=hi({...s,meta:{...s.meta,assetType:"client-control-template"}},o);p=ta(s,x,r,f,l.scripts)}let m={graph:[...h.graph,...p.graph],accessories:[...h.accessories,...p.accessories],filePath:f,gameVersion:rn({meta:{gameVersion:e.meta?.gameVersion||t?.meta?.gameVersion}}),...tn(e)};return{buffer:ra(m,ln),warnings:[...new Set(r)]}}var Gt=69,aa=30,sa="\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 Cc(e){return(String(e.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${e.id||""}`}function nn(e){let t=Ne.verify(e);if(t)throw new Error(`GIA encode validation failed: ${t}`);let i=Ne.encode(Ne.create(e)).finish(),r=Buffer.alloc(it+i.length+Zr);return r.writeUInt32BE(r.length-4,0),r.writeUInt32BE(1,4),r.writeUInt32BE(Wo,8),r.writeUInt32BE(3,12),r.writeUInt32BE(i.length,16),Buffer.from(i).copy(r,it),r.writeUInt32BE(Ko,it+i.length),r}function on(e,t=new Set){let i=(e||[]).filter(a=>a.path||a.source).map(a=>({...a})),r=[];for(let a of i){let s=Number(a.guid);Me(s)&&!t.has(s)?(t.add(s),a.guid=s):r.push(a)}for(let a of r){let s=Ze(t);t.add(s),a.guid=s}let n=[];return(e||[]).some(a=>a.controlId)&&n.push(sa),{units:i.map(a=>{let s=Cc(a),c=String(a.path||"").replace(/\\/g,"/"),l=/\.lua$/iu.test(c)?c:`${c||s}.lua`,u={id:a.guid,name:s,filePath:l};return String(a.source||"")&&(u.source=String(a.source)),{id:{class:aa,id:a.guid},name:s,which:Gt,script:{mapping:u}}}),warnings:n,scripts:i}}function la(e){let t=on(e);if(!t.units.length)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let i={graph:t.units,filePath:`114514-${Math.floor(Date.now()/1e3)}-1073741832-\\script.gia`,gameVersion:"7.0.51"},r=nn(i),n=kc(r);if(!n.valid)throw new Error(`GIA compatibility validation failed:
120
+ `)}`);return i}function ed(t,e={}){Ae(t.root,Ri);let i=[];Yt(t,{warnings:i});let r=on(se(t)),n=t.meta?.assetType==="client-control-template",o;if(n)o=Jf(t,r,i,void 0,e.scripts||[]);else{let a=Pa(e.scripts||[],new Set(r.values()));i.push(...a.warnings),o=Zf(t,r,a,i)}return{buffer:Qf(o,n?Fa:Da),warnings:[...new Set(i)]}}function td(t,e,i={}){Ae(t.root,Ri),e&&Ae(e.root,Ri);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&&Yt(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=on(s,o),u=Pa(i.scripts||[],o);r.push(...u.warnings.filter(w=>w!==rd));let c=String(i.fileName||`${s.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),f=Ta({...s,meta:{...s.meta,giaFileName:c}},!1),h=Zf(s,l,u,r,f),m={graph:[],accessories:[]};if(n.length&&a){let w=on({...a,meta:{...a.meta,assetType:"client-control-template"}},o);m=Jf(a,w,r,f,u.scripts)}let g={graph:[...h.graph,...m.graph],accessories:[...h.accessories,...m.accessories],filePath:f,gameVersion:Oa({meta:{gameVersion:t.meta?.gameVersion||e?.meta?.gameVersion}}),...Ra(t)};return{buffer:Qf(g,Da),warnings:[...new Set(r)]}}var Gi=69,id=30,rd="\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 cy(t){return(String(t.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${t.id||""}`}function Na(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(Si+i.length+ka);return r.writeUInt32BE(r.length-4,0),r.writeUInt32BE(1,4),r.writeUInt32BE(Uf,8),r.writeUInt32BE(3,12),r.writeUInt32BE(i.length,16),Buffer.from(i).copy(r,Si),r.writeUInt32BE(Hf,Si+i.length),r}function Pa(t,e=new Set){let i=(t||[]).filter(s=>s.path||s.source).map(s=>({...s})),r=[];for(let s of i)ms(s.guid,s.path||s.id);for(let s of i){let a=Number(s.guid);ct(a)&&!e.has(a)?(e.add(a),s.guid=a):r.push(s)}for(let s of r){let a=ai(e);e.add(a),s.guid=a}let n=[];return(t||[]).some(s=>s.controlId)&&n.push(rd),{units:i.map(s=>{let a=cy(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:id,id:s.guid},name:a,which:Gi,script:{mapping:c}}}),warnings:n,scripts:i}}function nd(t){let e=Pa(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=Na(i),n=fy(r);if(!n.valid)throw new Error(`GIA compatibility validation failed:
105
121
  ${n.errors.join(`
106
- `)}`);return{buffer:r,warnings:[...new Set(t.warnings)]}}function an(e){return Ne.toObject(Ne.decode(Ji(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function ca(e){try{let i=an(e).graph||[];return i.length>0&&i.every(r=>Number(r.which)===Gt)}catch{return!1}}function ua(e){let t=(e.graph||[]).filter(n=>Number(n.which)===Gt),i=[],r=t.map((n,o)=>{let a=n.script?.mapping||{},s=Number(n.id?.id)||0;s<=0&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04\u7F3A\u5C11 GraphUnit.id.id\uFF0C\u5DF2\u6309 0 \u5904\u7406\uFF08\u5BFC\u51FA\u65F6\u4F1A\u91CD\u65B0\u5206\u914D\uFF09\u3002`);let c=Number(a.id)||0;return c&&c!==s&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04 id(${c}) \u4E0E\u5355\u5143 id(${s}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:s,path:String(a.filePath||""),source:String(a.source||"")}});for(let[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 fa(e){let t=an(e),i=ua(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 kc(e){let t=[],i;try{i=an(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,o)=>{let a=`\u5355\u5143 ${o+1}`;Number(n.which)!==Gt&&t.push(`${a}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${n.which}`),Number(n.id?.class)!==aa&&t.push(`${a}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${n.id?.class}`),Number(n.id?.type??0)!==0&&t.push(`${a}: id.type \u5E94\u7F3A\u7701`);let s=n.script?.mapping;if(!s){t.push(`${a}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(n.id?.id)<=0&&t.push(`${a}: GraphUnit.id.id \u975E\u6CD5`),Number(s.id)!==Number(n.id?.id)&&t.push(`${a}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(s.name||"")!==String(n.name||"")&&t.push(`${a}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(s.filePath||"").trim()?/\.lua$/iu.test(String(s.filePath))||t.push(`${a}: file_path \u5E94\u4EE5 .lua \u7ED3\u5C3E\uFF08\u5B98\u65B9 script.gia \u6837\u672C\u5747\u4E3A \u540D\u79F0.lua\uFF0C\u771F\u673A require \u65F6\u624D\u53BB\u6269\u5C55\u540D\uFF09`):t.push(`${a}: file_path \u4E3A\u7A7A`)}),{valid:t.length===0,errors:t,scriptCount:r.length}}function Ji(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<it+Zr)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==Wo||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-it-Zr)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(it+i)!==Ko)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(it,it+i)}function me(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function Ec(e){let t=me(e,"transform")?.multiPlatform,i={};for(let n of t?.platforms||[]){let o=pc[n.platformType||0],a=n.transform||{};i[o]={scale:a.scale?{x:a.scale.x??0,y:a.scale.y??0,z:a.scale.z??0}:{x:1,y:1,z:1},rotation:{x:a.field508?.x??0,y:a.field508?.y??0,z:a.field508?.z??0},anchorMin:{x:a.anchorMin?.x??0,y:a.anchorMin?.y??0},anchorMax:{x:a.anchorMax?.x??0,y:a.anchorMax?.y??0},offset:{x:a.offset?.x??0,y:a.offset?.y??0},size:{x:a.size?.x??0,y:a.size?.y??0},pivot:a.pivot?{x:a.pivot.x??0,y:a.pivot.y??0}:{x:.5,y:.5}}}let 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 ue)i[n]||(i[n]=structuredClone(r));return i}function Ki(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 qo(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,o=new Map,a=[];for(let l of e){let u=Ki(l),f=me(l,"textConfig"),h=me(l,"imageSlot"),p=me(l,"image"),m=me(l,"buttonPreset"),y=me(l,"gridView"),x=me(l,"genericSlot"),k=me(l,"footerSlot"),w=me(l,"cursorConfig"),N=me(l,"keyHint"),M=me(l,"containerNodeSlot"),Y=me(l,"templateRefSlot"),U=me(l,"effectSlot"),H=me(l,"fullscreenEffectSlot"),$=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:me(l,"field14")?.field17?.initiallyHidden!==!0,active:me(l,"field14")?.initiallyInactive!==!0,canControllerFocus:k?.field505===1,scriptMappingIds:(x?.field502||[]).map(b=>Number(b?.field1?.id)).filter(b=>Number.isSafeInteger(b)&&b>0),transformByPlatform:Ec(l),syncAllDevices:me(l,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:x?.field501??0,footerField505:k?.field505??0,...u==="textbox"||u==="textwindow"?{textField501:f?.field501??20,textField503:f?.field503??12,textAlign:f?.align??0,...[void 0,0,1,2].includes(f?.verticalAlign)?{}:{textVerticalAlign:f.verticalAlign},...u==="textwindow"?{textField511:f?.field511??1,textViewField502:f?.viewFlags?.field502??1,textViewField503:f?.viewFlags?.field503??1}:{}}:{},...u==="cursor"?{cursorField501:w?.field501??0}:{},...u==="reference"?{templateRefSlot:Y??""}:{},...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:N?.field501??1,keyHintField502:N?.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:U??""}:{},...u==="fullscreen"?{fullscreenEffectSlot:H??""}:{}},...u==="container"?{isolateNavigation:M?.isolateNavigation===!0,disableKeyEventPassthrough:M?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:M?.disableCursorEventPassthrough===!0,showCursor:M?.showCursor===!0}:{},...u==="cursor"?{raycastTarget:w?.field501===1}:{},...u==="textbox"||u==="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",...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:Y??""}:{},...u==="keyhint"?{keyboardKeyCode:N?.field502??null,controllerKeyCode:N?.field501??null}:{},...u==="animation"?{animationId:U??""}:{},...u==="fullscreen"?{animationId:H??""}:{}});n.set(l.id?.id,$),(u==="textbox"||u==="textwindow")&&![void 0,0,1,2].includes(f?.align)&&a.push(`${$.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${f.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(u==="textbox"||u==="textwindow")&&![void 0,0,1,2].includes(f?.verticalAlign)&&a.push(`${$.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${f.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)&&a.push(`${$.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${p.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),u==="button"&&o.set($.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),f=(l.ui?.content?.children||[]).map(h=>n.get(h)).filter(Boolean);if(f.length){u.children=t?f.slice().reverse():f;for(let h of f)c.add(h.id)}}for(let l of e){let u=n.get(l.id?.id),f=l.ui?.content?.parent||0,h=n.get(f);h?c.has(u.id)||(t?h.children.unshift(u):h.children.push(u)):s.push(u)}for(let[l,u]of o){let f=[...n.values()].find(h=>h.id===l);for(let[h,p]of Object.entries(u))f[h]=r.get(p)||null}return{nodes:n,rootCandidates:s,warnings:a}}function da(e){let t=Ji(e),i=Ne.toObject(Ne.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,o=r.filter(m=>Number(m.which)===70),a=i.accessories||[],s=new Set((n?.relatedIds||[]).map(m=>m.id||0)),c=n?s.size?a.filter(m=>s.has(m.id?.id||0)):a:[],l=o.length?[...o,...a.filter(m=>!s.has(m.id?.id||0))]:n?[]:[...r,...a];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"],f=ua(i);u.push(...f.warnings);let h=null,p=null;if(c.length){let m=qo(c,{reverseSiblings:!0,idOffset:0});u.push(...m.warnings);let y=m.rootCandidates.find(k=>k.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(k=>k.field501===4&&k.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:ve,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=qo(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:ve,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},je(p,{warnings:u});for(let x of m.rootCandidates)Q(x,k=>k.children.reverse());h||(h=p)}return{project:h,clientProject:p&&h!==p?p:void 0,scripts:f.scripts,warnings:u,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(n&&o.length)}}}function sn(e){let t=Ji(e),i=Ne.toObject(Ne.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),r=i.graph||[],n=i.accessories||[],o=[],a=(p,m)=>p!=null&&Object.prototype.hasOwnProperty.call(p,m),s=new Map,c=[];/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||o.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`);let l=r.filter(p=>p.which===70).map(p=>{let m=Ki(p),y=p.ui?.content?.info||[],x=y.find(N=>N.field501===2&&N.field502===6)?.index?.value,k=y.find(N=>N.field501===4&&N.field502===4),w=k?.related?.value||[];return Ae(x)||o.push(`${p.name}: Info.index=${x??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),k||o.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:!!k,relatedGuids:w}}),u=new Map;for(let p of l){if(!Ae(p.actualIndex))continue;let m=u.get(p.actualIndex);m?o.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||o.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let f=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=Ki(p),k=r.includes(p)&&p.which===70,w=`${p.name||"<unnamed>"}(${m||"<missing-guid>"})`;!Number.isSafeInteger(m)||m<=0||m>2147483647?o.push(`${w}: GraphUnit GUID \u975E\u6CD5`):s.has(m)?o.push(`${w}: GUID \u4E0E ${s.get(m).name||"<unnamed>"} \u91CD\u590D`):s.set(m,p),(p.id?.class!==1||p.id?.type!==8)&&o.push(`${w}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),y.guid!==m&&o.push(`${w}: content.guid=${y.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),k&&p.which!==70&&o.push(`${w}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!k&&p.which!==15&&o.push(`${w}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let N=y.info||[],M=N.find(_=>_.field501===1&&_.field502===5),Y=N.find(_=>_.field501===2&&_.field502===6);M?.guid?.value!==m&&o.push(`${w}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),Ae(Y?.index?.value)||o.push(`${w}: Info.index=${Y?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let U=N.find(_=>_.field501===4&&_.field502===4);k&&!U&&o.push(`${w}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!k&&U&&o.push(`${w}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let H=Zo[x],$=y.data||[],b=$.map(_=>`${_.field501}/${_.field502}`),A=H?.map(([_])=>_)||[];H?JSON.stringify(b)!==JSON.stringify(A)&&o.push(`${w}: Data \u69FD\u4F4D\u987A\u5E8F ${b.join(",")}\uFF0C\u5E94\u4E3A ${A.join(",")}`):o.push(`${w}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${x}`);for(let _=0;_<Math.min($.length,H?.length||0);_+=1){let G=$[_],[B,ie,L]=H[_];if(a(G,ie)||o.push(`${w}: Data ${B} \u7F3A\u5C11 ${ie} \u5206\u652F`),!L)continue;a(G.details,L)||o.push(`${w}: Details ${B} \u7F3A\u5C11 ${L} \u5206\u652F`);let te=Qo[B];(G.details?.field501!==te||G.details?.field502!==G.field502||G.details?.field503!==1)&&o.push(`${w}: Details ${B} \u6807\u8BB0\u5E94\u4E3A ${te}/${G.field502}/1`);let Te=G.details?.nodeRef;(Te?.class!==1||Te?.type!==8||Te?.id!==m)&&o.push(`${w}: Details ${B} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let S=(p.ui.content.data||[]).find(_=>_.field501===4&&_.field502===86);S&&(a(S.field14,"field17")?f+=1:o.push(`${w}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),a(S.details?.field14,"field17")?f+=1:o.push(`${w}: \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&&o.push(`${w}: \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])&&o.push(`${w}: \u5E73\u53F0\u987A\u5E8F ${F.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let E=(p.ui.content.data||[]).find(_=>_.details?.transform)?.details?.transform;E?.multiPlatform?.field502!==fi[x]&&o.push(`${w}: \u53D8\u6362 preset=${E?.multiPlatform?.field502??"<missing>"}\uFF0C${x} \u5E94\u4E3A ${fi[x]}`);for(let _ of C)a(_.transform,"field508")?h+=1:o.push(`${w}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);c.push({id:m,name:p.name||"",kind:x,template:k,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)&&o.push(`${m}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),p.template&&p.parent&&o.push(`${m}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!p.template){let y=s.get(p.parent);y?(y.ui?.content?.children||[]).includes(p.id)||o.push(`${m}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):o.push(`${m}: parent=${p.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let y of p.children){let x=s.get(y);x?(x.ui?.content?.parent||0)!==p.id&&o.push(`${m}: child=${y} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):o.push(`${m}: child=${y} \u4E0D\u5B58\u5728`)}}return{valid:o.length===0,errors:o,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:l.length,accessoryCount:n.length,templates:l,units:c,explicitEmpty:{field17:f,rectField508:h}}}function ln(e){let t=Ji(e),i=Ne.toObject(Ne.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),r=(i.graph||[]).filter(E=>E.ui?.content&&Number(E.which)===21),n=(i.graph||[]).filter(E=>Number(E.which)===70),o=(i.graph||[]).filter(E=>Number(E.which)===Gt),a=(i.accessories||[]).filter(E=>E.ui?.content),s=[],c=(E,_)=>E!=null&&Object.prototype.hasOwnProperty.call(E,_);/^\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(E=>{let _=Number(E.which);return _===Gt||_===70||_===21?!1:!E.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:a.length,controls:[],scriptCount:o.length,explicitEmpty:{field17:0,rectField508:0}};let f=[u,...n,...a],h=new Map;for(let E of f){let _=E.id?.id||0,G=`${E.name||"<unnamed>"}(${_||"<missing-guid>"})`;!Number.isSafeInteger(_)||_<=0||_>2147483647?s.push(`${G}: GraphUnit GUID \u975E\u6CD5`):h.has(_)?s.push(`${G}: GUID \u91CD\u590D`):h.set(_,E),(E.id?.class!==1||E.id?.type!==8)&&s.push(`${G}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),E.ui?.content?.guid!==_&&s.push(`${G}: 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(E=>E.field501===1&&E.field502===5)?.guid?.value!==p&&s.push(`${y}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),x.find(E=>E.field501===2&&E.field502===6)?.index?.value!==1&&s.push(`${y}: Info.index \u5FC5\u987B\u4E3A 1`);let k=x.find(E=>E.field501===4&&E.field502===4);k||s.push(`${y}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let w=0,N=0,M=(E,_,G,B=!1)=>{let ie=E.id?.id||0,L=`${E.name||"<unnamed>"}(${ie})`,te=E.ui.content.data||[],Te=te.map(oe=>`${oe.field501}/${oe.field502}`),_t=G.map(([oe])=>oe);JSON.stringify(Te)!==JSON.stringify(_t)&&s.push(`${L}: Data \u69FD\u4F4D\u987A\u5E8F ${Te.join(",")}\uFF0C\u5E94\u4E3A ${_t.join(",")}`);for(let oe=0;oe<Math.min(te.length,G.length);oe+=1){let $e=te[oe],[Ye,Qt,ei]=G[oe];if(c($e,Qt)||s.push(`${L}: Data ${Ye} \u7F3A\u5C11 ${Qt} \u5206\u652F`),!ei)continue;c($e.details,ei)||s.push(`${L}: Details ${Ye} \u7F3A\u5C11 ${ei} \u5206\u652F`);let We=Qo[Ye];($e.details?.field501!==We||$e.details?.field502!==$e.field502||$e.details?.field503!==1)&&s.push(`${L}: Details ${Ye} \u6807\u8BB0\u5E94\u4E3A ${We}/${$e.field502}/1`);let ti=$e.details?.nodeRef;(ti?.class!==1||ti?.type!==8||ti?.id!==ie)&&s.push(`${L}: Details ${Ye} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let Zt=te.find(oe=>oe.field501===4&&oe.field502===(B?23:86)),re=B?"empty15":"field17";c(Zt?.field14,re)?B||(w+=1):s.push(`${L}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${re} \u7A7A\u4E32`),c(Zt?.details?.field14,re)?B||(w+=1):s.push(`${L}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${re} \u7A7A\u4E32`);let ze=te.find(oe=>oe.details?.transform)?.details?.transform,lt=ze?.multiPlatform?.platforms||[];lt.length!==4&&s.push(`${L}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${lt.length}\uFF0C\u5E94\u4E3A 4`);let Fi=lt.map(oe=>oe.platformType||0);JSON.stringify(Fi)!==JSON.stringify([0,1,2,3])&&s.push(`${L}: \u5E73\u53F0\u987A\u5E8F ${Fi.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let Di=B?fi["server-container"]:fi[_];ze?.multiPlatform?.field502!==Di&&s.push(`${L}: \u53D8\u6362 preset=${ze?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${Di}`);for(let oe of lt)c(oe.transform,"field508")?N+=1:s.push(`${L}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return Te};M(u,"server-container",mc,!0);let Y=(u.relatedIds||[]).map(E=>E.id||0),U=new Set(Y),H=a.filter(E=>U.has(E.id?.id||0)),$=H.map(E=>E.id?.id||0);JSON.stringify(Y)!==JSON.stringify($)&&s.push(`${y}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let b=m.data?.find(E=>E.details?.rootChildRef)?.details?.rootChildRef?.guid||0,A=h.get(b);(!A||!H.includes(A))&&s.push(`${y}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),$[0]!==b&&s.push(`${y}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let S=[];for(let E of H){let _=E.id?.id||0,G=E.ui.content,B=`${E.name||"<unnamed>"}(${_})`,ie=Ki(E);E.which!==15&&s.push(`${B}: which \u5FC5\u987B\u4E3A UIControl(15)`);let L=G.info||[];(L.length!==1||L[0]?.field501!==1||L[0]?.field502!==5||L[0]?.guid?.value!==_)&&s.push(`${B}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let te=Zo[ie];te||s.push(`${B}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${ie}`);let Te=te?M(E,ie,te):[];S.push({id:_,name:E.name||"",kind:ie,parent:G.parent||0,children:[...G.children||[]],relatedIds:(E.relatedIds||[]).map(_t=>_t.id||0),dataSignatures:Te})}let C=S.find(E=>E.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(E=>[E.id,E]));for(let E of S){let _=`${E.name}(${E.id})`;if(JSON.stringify(E.relatedIds)!==JSON.stringify(E.children)&&s.push(`${_}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),E.id!==b){let G=F.get(E.parent);G?G.children.includes(E.id)||s.push(`${_}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):s.push(`${_}: parent=${E.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let G of E.children){let B=F.get(G);B?B.parent!==E.id&&s.push(`${_}: child=${G} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):s.push(`${_}: child=${G} \u4E0D\u5B58\u5728`)}}if(n.length){let E=sn(nn({...i,graph:n,accessories:a.filter(_=>!U.has(_.id?.id||0))}));s.push(...E.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:k?.related?.value||[],rootGuid:b},accessoryCount:a.length,controls:S,scriptCount:o.length,explicitEmpty:{field17:w,rectField508:N}}}function ha(e,t=[]){if(!e||e.layoutSchemaVersion===ve)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:ve};let i=structuredClone(e),r=0;return Q(i.root,n=>{let o=n.transformByPlatform||{},a=n.transformByCanvas||{},s=n.name||n.id;for(let l of Object.keys(o))if(!ue.includes(l))throw new Error(`${s}: unknown platform ${l}`);let c={};for(let l of ue){let u=Rt[l],f=J[u].platform,h=Object.keys(J).filter(x=>J[x].platform===f&&a[x]),p=a[u]?u:h[0],m=l==="CONTROLLER_CONSOLE"?c.KEYBOARD:l==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,y=o[l]??m??(p?a[p]:null);if(c[l]=y?Ge(y):Xr(n.kind),y||t.push(`${s}: ${l} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!o[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(Ge(a[x]))&&t.push(`${s}: ${x} \u4E0E ${l} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[l]?"\u5DF2\u6709\u5E73\u53F0":p}\u53C2\u6570`)}Je(c,`${s}.transformByPlatform`),n.transformByPlatform=c,delete n.transformByCanvas,r++}),i.layoutSchemaVersion=ve,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 cn(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 fn(e,t,i,r=e.canvasId){let n=Qe(e.root,t);return!n||n.kind==="server-container"?Se(r):i[n.id]||Se(r)}function rt(e,{warnings:t=[]}={}){if(!e)return pt();if(e=ha(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==ve)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${ve} \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"?zt():pt(),n={layoutSchemaVersion:ve,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:Bi,selectedId:e.selectedId||r.selectedId,root:Kr(e.root||r.root)};return ba(n),je(n,{warnings:t}),n}function ba(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=Wr(e.root).id)}function pa(e){return Ze(Dt(e))}function Ac(e,t){let i=!1;return Q(e,r=>{r.id===t&&(i=!0)}),i}function _c(e,t,i,r){let o=tt(e.root,e.canvasId).boxes[t.id],a=i.children.findIndex(f=>f.id===t.id);if(a<0)throw new Error("reparent: source node is not attached");if(i.children.splice(a,1),r.children.push(t),!o)return;let s=tt(e.root,e.canvasId),c=r.kind==="server-container"?Se(e.canvasId):s.boxes[r.id]||Se(e.canvasId),l=et(t.transformByPlatform,e.canvasId),u=ut(c,l,{posX:o.centerX,posY:o.centerY,width:o.width,height:o.height});Vt(e,t,u)}function Pc(e,t){return e.meta.assetType!=="client-control-template"?Jr(e.root,t):(e.root.children||[]).flatMap(i=>Jr(i,t))}function va(e,t){let i=jo(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let r=ui(e),n=new Set;return r&&r.kind!=="server-container"&&Q(r,o=>n.add(o.id)),i.filter(o=>n.has(o.id))}function Sa(e){let{canvas:t,boxes:i}=tt(e.root,e.canvasId),r=hi(e),n=pe(e.root,e.selectedId),o=n?i[n.id]:null;return V({layoutSchemaVersion:ve,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(a=>({id:a.id,label:a.label,width:a.width,height:a.height,platform:a.platform}))},selectedId:e.selectedId,asset:{type:e.meta.assetType,label:e.meta.assetType==="client-control-template"?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F",templateCount:e.meta.assetType==="client-control-template"?e.root.children.length:1,currentTemplateId:e.meta.assetType==="client-control-template"&&ui(e)?.id||""},tree:Pc(e,r),boxes:va(e,i),inspector:Lo(n,e.canvasId,o||t,r),root:e.root})}function Vt(e,t,i){let r=tt(e.root,e.canvasId),n=fn(e,t.id,r.boxes),o={};if(t.syncAllDevices!==!1)for(let a of ue){if(a===ft(e.canvasId))continue;let s=Rt[a],c=tt(e.root,s,a);o[a]=fn(e,t.id,c.boxes,s)}t.transformByPlatform=Uo({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:n,targetParentBoxByPlatform:o})}var Tc=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"]),Rc=new Set(["posX","posY","width","height"]),Mc=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function Nc(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 Le(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function ma(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 Oc=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode","itemPrefabId","layoutConstraintFixedCount"]),Fc=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),Dc=new Set(["name","imageSource","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),ga=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),ya={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 zc(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&pe(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:r}=tt(e.root,e.canvasId),n=va(e,r),o=Xo(n,Number(t.x),Number(t.y));return o&&(e.selectedId=o),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"?zt():pt();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:qr(e.root),guid:pa(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=pe(e.root,t.parentId||e.selectedId);if(!r)throw new Error("add: parent not found");let n=Yo(r,t.kind,{id:qr(e.root),guid:pa(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=pe(e.root,t.id||e.selectedId),n=r?Qe(e.root,r.id):null,o=pe(e.root,t.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||Ac(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 e;if(n.kind==="server-container"&&o.kind!=="server-container"&&e.root.children.length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u9876\u5C42\u6A21\u677F");return _c(e,r,n,o),e.selectedId=r.id,e}if(i==="moveSibling"){let r=pe(e.root,t.id||e.selectedId),n=r?Qe(e.root,r.id):null;if(!r||!n)throw new Error("moveSibling: node not found");let o=n.children.findIndex(c=>c.id===r.id),a=t.direction==="up"?-1:t.direction==="down"?1:0,s=o+a;return!a||s<0||s>=n.children.length||(n.children.splice(o,1),n.children.splice(s,0,r),e.selectedId=r.id),e}if(i==="remove"){let r=t.id||e.selectedId,n=Qe(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 Ho(e.root,r)&&(Q(e.root,o=>{if(o.kind==="button")for(let a of ga)o[a]&&!pe(e.root,o[a])&&(o[a]=null)}),e.selectedId=n?n.id:e.root.id),e}if(i==="set"){let r=pe(e.root,t.id||e.selectedId);if(!r)throw new Error("set: node not found");let n=t.key;n==="reverseMask"&&(n="reverseMaskArea");let o=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=$o(r.kind,l);if(!u)throw new Error(`unknown raw GIA field for ${r.kind}: ${l}`);if(r.giaRaw||={},r.giaRaw[l]=Br(u,o),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 f={0:"Left",1:"Middle",2:"Right"}[r.giaRaw[l]];f&&(r.horizontalAlignment=f)}if(r.kind==="image"&&l==="imageFillType"){let f={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[r.giaRaw[l]];f&&(r.fillType=f)}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=ma(o),r.syncAllDevices){let l=et(r.transformByPlatform,e.canvasId);Vt(e,r,l)}return e}if(Tc.has(n)){if(n.endsWith("Color")&&(o=Nc(o)),Oc.has(n)){if(o=Le(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(Fc.has(n)&&(o=ma(o)),Dc.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(ya[n]&&!ya[n].includes(o))throw new Error(`invalid ${n}`);if(ga.has(n))if(o===""||o===void 0||o===null)o=null;else{o=String(o);let l=pe(e.root,o);if(!l||l===r||l.kind==="server-container"||!(r.children||[]).some(u=>u.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 l={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o];l&&(r.giaRaw.imageFillType=l)}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),e}let{boxes:a}=tt(e.root,e.canvasId),s=fn(e,r.id,a),c=et(r.transformByPlatform,e.canvasId);if(n==="anchorType"){let l=un(a[r.id]),u=No(c,o);return u=ut(s,u,l),Vt(e,r,u),e}if(["rotationX","rotationY","rotationZ"].includes(n)){let l={...c,rotation:{...c.rotation,[n.slice(-1).toLowerCase()]:Le(o,n)}};return Vt(e,r,l),e}if(Mc.has(n)){let l=un(a[r.id]),u={...c,anchorMin:{...c.anchorMin},anchorMax:{...c.anchorMax},pivot:{...c.pivot}};return n==="anchorMinX"&&(u.anchorMin.x=Le(o,n)),n==="anchorMinY"&&(u.anchorMin.y=Le(o,n)),n==="anchorMaxX"&&(u.anchorMax.x=Le(o,n)),n==="anchorMaxY"&&(u.anchorMax.y=Le(o,n)),n==="pivotX"&&(u.pivot.x=Le(o,n)),n==="pivotY"&&(u.pivot.y=Le(o,n)),Vt(e,r,ut(s,u,l)),e}if(Rc.has(n)){let l=un(a[r.id]),u=Le(o,n);if((n==="width"||n==="height")&&u<0)throw new Error(`${n} must not be negative`);return l[n]=u,Vt(e,r,ut(s,c,l)),e}throw new Error(`set: unknown key ${n}`)}if(i==="replace"){let r=rt(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 dn(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 zc(r,t),ba(r),je(r),r.version=i+1,Object.keys(e).forEach(n=>{delete e[n]}),Object.assign(e,r),e}function un(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import $c from"fengari";var{lua:d,lauxlib:ee,lualib:wa,to_luastring:Zi,to_jsstring:Gc}=$c,Vc=d.LUA_TNIL,Yc=d.LUA_TBOOLEAN,Hc=d.LUA_TNUMBER,Bc=d.LUA_TSTRING,Ia=d.LUA_TTABLE,Uc=d.LUA_TFUNCTION,hn=d.LUA_TUSERDATA,Oe=d.LUA_OK,xa=new WeakMap,pn=Symbol("luaTableEntries"),mn={__scriptHostKey:!0};function T(e){return Zi(String(e))}function mt(e,t){xa.set(e,t)}function ke(e){return xa.get(e)}var pi=class{constructor(t){this.value=t}};function le(e,t,i){if(i instanceof pi){d.lua_pushnumber(e,i.value);return}if(i==null){d.lua_pushnil(e);return}let r=typeof i;if(r==="boolean"){d.lua_pushboolean(e,i);return}if(r==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?d.lua_pushinteger(e,i):d.lua_pushnumber(e,i);return}if(r==="string"){d.lua_pushstring(e,T(i));return}if(r==="function"){Xc(e,t,i);return}if(i&&i[pn]){let n=i[pn];d.lua_createtable(e,Array.isArray(i)?i.length:0,n.length);for(let[o,a]of n)le(e,t,o),le(e,t,a),d.lua_settable(e,-3);return}if(Array.isArray(i)){d.lua_createtable(e,i.length,0);for(let n=0;n<i.length;n++)le(e,t,i[n]),d.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"){d.lua_createtable(e,0,Object.keys(i).length);for(let[n,o]of Object.entries(i))le(e,t,o),d.lua_setfield(e,-2,T(n));return}d.lua_pushnil(e)}function Z(e,t){if(d.lua_isnil(e,t)||d.lua_type(e,t)===d.LUA_TNONE)return"";if(!d.lua_isstring(e,t)&&d.lua_type(e,t)!==d.LUA_TNUMBER)return`lua_type=${d.lua_type(e,t)}`;let i=d.lua_tostring(e,t);return i==null?"":Gc(i)}function Xe(e,t){t=d.lua_absindex(e,t);let i=d.lua_type(e,t);if(i===hn)return ke(d.lua_touserdata(e,t));if(i===Ia){d.lua_pushlightuserdata(e,mn),d.lua_rawget(e,t);let r=d.lua_type(e,-1)===hn?d.lua_touserdata(e,-1):null;return d.lua_pop(e,1),r?ke(r):null}return null}function be(e,t,i){i=d.lua_absindex(e,i);let r=d.lua_type(e,i);if(r===Vc)return null;if(r===Yc)return!!d.lua_toboolean(e,i);if(r===Hc)return d.lua_isinteger(e,i)?d.lua_tointeger(e,i):d.lua_tonumber(e,i);if(r===Bc)return Z(e,i);if(r===hn){let n=d.lua_touserdata(e,i);return ke(n)??n}if(r===Uc)return jc(e,t,i);if(r===Ia){let n=Xe(e,i);if(n)return n;let o=[];for(d.lua_pushnil(e);d.lua_next(e,i)!==0;){let l=be(e,t,-2),u=be(e,t,-1);o.push([l,u]),d.lua_pop(e,1)}let a=new Map(o.filter(([l])=>Number.isInteger(l)&&l>=1)),s=0;for(;a.has(s+1);)s+=1;let c=s>0?[]:{};for(let[l,u]of o)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,pn,{value:o}),c}return null}function jc(e,t,i){t.luaFunctions||(t.luaFunctions=new Map);let r=typeof d.lua_topointer=="function"?d.lua_topointer(e,i):null;if(r!=null&&t.luaFunctions.has(r))return t.luaFunctions.get(r);d.lua_pushvalue(e,i);let n=ee.luaL_ref(e,d.LUA_REGISTRYINDEX),o=Lc(e,t,n);return r!=null&&t.luaFunctions.set(r,o),o}function Lc(e,t,i){let r=(...n)=>{if(r.__luaRef==null)throw new Error("attempt to call a released Lua callback");let o=d.lua_gettop(e);d.lua_rawgeti(e,d.LUA_REGISTRYINDEX,r.__luaRef);for(let l of n)le(e,t,l);if(d.lua_pcall(e,n.length,d.LUA_MULTRET,0)!==Oe){let l=Z(e,-1);throw d.lua_settop(e,o),new Error(l)}let s=d.lua_gettop(e)-o,c=[];for(let l=1;l<=s;l++)c.push(be(e,t,o+l));if(d.lua_settop(e,o),c.length!==0)return c.length===1?c[0]:c};return r.__luaRef=i,r.__luaState=e,r}function Ca(e){e?.__luaRef!=null&&(e.__luaHolds=(e.__luaHolds||0)+1)}function ka(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,d.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 Xc(e,t,i){d.lua_pushlightuserdata(e,i),d.lua_pushlightuserdata(e,t),d.lua_pushcclosure(e,function(n){let o=d.lua_touserdata(n,d.lua_upvalueindex(1)),a=d.lua_touserdata(n,d.lua_upvalueindex(2)),s=d.lua_gettop(n),c=[];for(let l=1;l<=s;l++)c.push(be(n,a,l));try{let l=o(...c);if(Array.isArray(l)&&l.__multi){for(let u of l)le(n,a,u);return l.length}return l===void 0?0:(le(n,a,l),1)}catch(l){return d.lua_pushstring(n,T(String(l&&l.message?l.message:l))),d.lua_error(n)}},2)}function Ea(e){!e||typeof d.lua_close!="function"||d.lua_close(e)}function Aa(e){if(ee.luaL_loadstring(e,T(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
107
- `)))===Oe&&d.lua_pcall(e,0,0,0),d.lua_settop(e,0),d.lua_pushnil(e),d.lua_setglobal(e,T("_VERSION")),d.lua_getglobal(e,T("string")),!d.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])d.lua_pushnil(e),d.lua_setfield(e,-2,T(i));if(d.lua_pop(e,1),d.lua_pushnil(e),d.lua_setglobal(e,T("io")),d.lua_getglobal(e,T("os")),!d.lua_isnil(e,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))d.lua_pushnil(e),d.lua_setfield(e,-2,T(i));d.lua_pop(e,1),d.lua_getglobal(e,T("debug")),d.lua_isnil(e,-1)?d.lua_pop(e,1):(d.lua_getfield(e,-1,T("traceback")),d.lua_newtable(e),d.lua_pushvalue(e,-2),d.lua_setfield(e,-2,T("traceback")),d.lua_setglobal(e,T("debug")),d.lua_pop(e,2)),d.lua_getglobal(e,T("math")),d.lua_isnil(e,-1)||(d.lua_pushcfunction(e,i=>{let r=d.lua_tonumber(i,1);return d.lua_pushboolean(i,Number.isNaN(r)),1}),d.lua_setfield(e,-2,T("isnan")),d.lua_pushcfunction(e,i=>{let r=d.lua_tonumber(i,1);return d.lua_pushboolean(i,r===1/0||r===-1/0),1}),d.lua_setfield(e,-2,T("isinf"))),d.lua_pop(e,1),d.lua_pushnil(e),d.lua_setglobal(e,T("package")),d.lua_pushnil(e),d.lua_setglobal(e,T("load")),d.lua_pushnil(e),d.lua_setglobal(e,T("loadfile")),d.lua_pushnil(e),d.lua_setglobal(e,T("dofile")),d.lua_pushnil(e),d.lua_setglobal(e,T("collectgarbage")),d.lua_pushnil(e),d.lua_setglobal(e,T("coroutine")),d.lua_pushnil(e),d.lua_setglobal(e,T("fengari"))}var _e=(e,t=0)=>Number.isFinite(Number(e))?Number(e):t,_a=e=>e?.Name||e,Qi=e=>Math.max(0,Math.min(1,_e(e)));function mi(e){let t=e.parent?mi(e.parent):[e.runtime.canvasWidth,e.runtime.canvasHeight];return[Math.max(0,(e.anchorMaxX-e.anchorMinX)*t[0]+_e(e.sizeDeltaX)),Math.max(0,(e.anchorMaxY-e.anchorMinY)*t[1]+_e(e.sizeDeltaY))]}function gi(e){let[t,i]=mi(e),r=_a(e.scrollDirection)==="Horizontal",n=Math.max(1,_e(e.cellSizeX,50)),o=Math.max(1,_e(e.cellSizeY,50)),a=Math.max(0,_e(e.spacingX)),s=Math.max(0,_e(e.spacingY)),c=Math.max(0,_e(e.padding1X)),l=Math.max(0,_e(e.padding1Y)),u=Math.max(0,_e(e.padding2X)),f=Math.max(0,_e(e.padding2Y)),h=r?i-l-f:t-c-u,p=r?o:n,m=r?s:a,y=_a(e.layoutConstraint)==="Fixed"?Math.max(1,Math.floor(_e(e.layoutConstraintFixedCount,1))):Math.max(1,Math.floor((h+m)/(p+m))),x=Math.ceil(e.itemCount/y),k=x?r?c+u+x*n+(x-1)*a:l+f+x*o+(x-1)*s:0,w=r?t:i,N=Math.max(0,k-w);return{width:t,height:i,horizontal:r,cellW:n,cellH:o,gapX:a,gapY:s,left:c,top:l,right:u,bottom:f,lanes:y,length:k,viewport:w,max:N,offset:Qi(e.scrollProgress)*N}}function Yt(e){let t=gi(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),o=i%t.lanes,a=t.horizontal?n:o,s=t.horizontal?o:n,c=t.left+a*(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(([f,h])=>r[f]!==h)&&(Object.assign(r,u),r.markPlayDirty(!0))}return t}var Pa={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},qc=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],er=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),Wc=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],Kc={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},Jc={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"]},Zc=["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"],Ta=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Qc={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:Ta,cursor:Ta,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function yn(e,t){return e.kind==="image"&&t==="imageType"&&e.runtime.canSelectImageType(e.imageId,e.imageSource)?"rw":qc.includes(t)||(Kc[e.kind]||[]).includes(t)?"ro":Wc.includes(t)||(Jc[e.kind]||[]).includes(t)?"rw":null}var eu=["localRotationX","localRotationY","localRotationZ"],Ht=Math.PI/180;function Ra(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 gn(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 Ma(e,t,i){let r=w=>[Math.sin(w*Ht/2),Math.cos(w*Ht/2)],[n,o]=r(e),[a,s]=r(t),[c,l]=r(i),[u,f,h,p]=Ra(Ra([0,a,0,s],[n,0,0,o]),[0,0,c,l]),m=Math.max(-1,Math.min(1,-2*(f*h-p*u))),y,x,k;return Math.abs(m)>.999999?(y=Math.sign(m)*90,x=2*Math.atan2(f,p)/Ht,k=0):(y=Math.asin(m)/Ht,x=Math.atan2(2*(p*f+u*h),1-2*(u*u+f*f))/Ht,k=Math.atan2(2*(p*h+u*f),1-2*(u*u+h*h))/Ht),[gn(y),gn(x),gn(k)]}function Na(e,t){return Zc.includes(t)||(Qc[e.kind]||[]).includes(t)}var tu={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}},nt=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=Pa[this.kind]||Pa.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=tu[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 e?n:new e(t,n);this.addChild(o)}}get parent(){return this._parent}set parent(t){if(this._parent===t)return;if(t!==null&&!(t instanceof e))throw new Error("parent must be a Control or nil");if(t&&t.runtime!==this.runtime)throw new Error("parent must belong to the same runtime");if(t===this)throw new Error("cannot parent a control to itself or its descendant");for(let 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=Qi(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 Ma(this.localRotationX,this.localRotationY,this.localRotationZ)}luaFieldValue(t){if(t==="imageType")return this.imageType??"Stretch";let i=eu.indexOf(t);return i<0?this[t]:Ma(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 o=n.filter(a=>a!==r);t.set(i,o);for(let a=o.length;a<n.length;a++)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,Yt(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=gi(this),n=r.horizontal?r.cellW:r.cellH,o=r.horizontal?r.gapX:r.gapY,a=(r.horizontal?r.left:r.top)+Math.floor(t/r.lanes)*(n+o),s=i?.Name||i;if(!["Top","Center","Bottom"].includes(s))throw new Error("ScrollToItemAt: invalid alignment");let c=a-(s==="Center"?(r.viewport-n)/2:s==="Bottom"?r.viewport-n:0);this.scrollProgress=r.max?Qi(c/r.max):0,Yt(this),this.markPlayDirty(!0)}GetContentLength(){return gi(this).length}};function Ve(e,t){t(e);for(let i of e.children)Ve(i,t)}function bn(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let r of e.children)bn(r,t,i+" ");return t}function tr(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 Oa={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-tr(1-e),OutBounce:tr,InOutBounce:e=>e<.5?(1-tr(1-2*e))/2:(1+tr(2*e-1))/2};function Fa(e,t){let i=Oa[e]||Oa.Linear;return t<=0?0:t>=1?1:i(t)}function Bt(e,t,i,r=255){let n=ir(e),o=ir(t),a=ir(i);return((r==null?255:ir(r))<<24|n<<16|o<<8|a)>>>0}function yi(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function ir(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function Da(e,t,i){let r=yi(e),n=yi(t);return Bt(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 iu=new Set(["fontColor","bgColor","outlineColor","imageColor"]),ru=new Set(["fontSize","minimumFontSize"]),vn=1e-9;function nu(e,t){return typeof e?.luaFieldValue=="function"?e.luaFieldValue(t):e[t]}var bi=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=nu(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=Fa(this.easeName,t),r=!1,n=!1;for(let o of Object.keys(this.to)){let a=this.from[o],s=this.to[o];if(iu.has(o)&&typeof a=="number"&&typeof s=="number")this.object[o]=Da(a,s,i);else if(typeof a=="number"&&typeof s=="number"){let c=a+(s-a)*i;this.object[o]=ru.has(o)?Math.trunc(c):c}else this.object[o]=i>=1?s:a;r=!0,er.has(o)&&(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)}},Ut=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=[],o=a=>a.duration*a.loopCount;for(let a of this.steps)if(a.kind==="tween"&&a.parallel){let s=r?i:t;n.push({at:s,tween:a.tween}),t=Math.max(t,s+o(a.tween))}else a.kind==="tween"?(n.push({at:t,tween:a.tween}),i=t,r=!0,t+=o(a.tween)):a.kind==="interval"?(i=t,r=!0,t+=a.duration):a.kind==="callback"?n.push({at:t,fn:a.fn}):a.kind==="insert"?(n.push({at:a.time,tween:a.tween}),t=Math.max(t,a.time+o(a.tween))):a.kind==="insertCb"&&(n.push({at:a.time,fn:a.fn}),t=Math.max(t,a.time));this._entries=n.map((a,s)=>({...a,index:s,end:a.tween?a.at+o(a.tween):a.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 a of r)!a.started&&a.at<=t+vn&&n.push({at:a.at,rank:a.fn?1:2,entry:a}),a.tween&&!a.done&&a.end<=t+vn&&n.push({at:a.end,rank:0,entry:a});n.sort((a,s)=>a.at-s.at||a.rank-s.rank||a.entry.index-s.entry.index);let o=new Set;for(let{rank:a,entry:s}of n)if(a===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),o.add(s)),a===0&&!s.done&&this._finishChild(s);for(let a of r)!a.tween||!a.started||a.done||(o.has(a)?a.tween._advance(t-a.at,a.tween.loopCount):a.tween._advance(i,a.tween.loopCount));return!0}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._advanceTo(this.elapsed,t)&&(this.elapsed+vn<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 rr={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"]},ou=[...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"],au=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function su(){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}rr.KeyboardKeyCode=ou;rr.ControllerKeyCode=au;rr.KeyEventType=su();var za=new Map;function gt(e,t){let i=`${e}\0${t}`,r=za.get(i);return r||(r={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},za.set(i,r)),r}function Sn(e,t){return t==null?t:t.__kind==="EnumItem"?gt(t.EnumType||e,t.Name):typeof t=="string"&&t?gt(e,t):t}function wn(){let e={};for(let[t,i]of Object.entries(rr)){let r={};for(let n of i)r[n]=gt(t,n);e[t]=r}return e}var lu=new Set(["Id","prefabIndex","imageId","fontSize","minimumFontSize","clickAudioId","itemCount","itemPrefabIndex","animationId","referencedPrefabIndex"]),cu=new Set(["imageColor","fontColor","bgColor","outlineColor"]),$a={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"},yt=d.LUA_REGISTRYINDEX,Ga=d.LUA_MULTRET,uu=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 we(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}var nr=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=wn(),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?d.lua_pushinteger(t,r):d.lua_pushnumber(t,r)}retainLuaCallback(t){Ca(t)}unrefLuaCallback(t){ka(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 nt?t:new nt(this,t);return this.roots.push(i),Ve(i,r=>this.controlsById.set(r.Id,r)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof nt)return;let r=o=>(o.scripts?.length||0)>0||(o.children||[]).some(r);if(!t||!r(t))return;let n=this.lifecyclePhase;try{let o=(a,s)=>{for(let l of a.scripts||[])try{this.mountScript({path:l.path,source:l.source,control:s,scriptMappingId:l.scriptMappingId})}catch(u){let f=u&&u.message?u.message:String(u);this.mountErrors.push(f),this.log("lua-error",f)}let c=a.children||[];for(let l=0;l<c.length;l+=1)o(c[l],s?.children?.[l])};o(t,i)}finally{this.lifecyclePhase=n}}makeCursorEventData({x:t=0,y:i=0,pressX:r=t,pressY:n=i,deltaX:o=t-r,deltaY:a=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[o,a]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;d.lua_pushcfunction(t,r=>{let n=d.lua_gettop(r),o=[];for(let a=1;a<=n;a++)o.push(be(r,i,a));return i.log("info",...o),0}),d.lua_setglobal(t,T("print")),d.lua_pushcfunction(t,r=>{let n=d.lua_gettop(r),o=[];for(let a=1;a<=n;a++)o.push(be(r,i,a));return i.log("error",...o),0}),d.lua_setglobal(t,T("printerr")),d.lua_pushcfunction(t,r=>{if(d.lua_type(r,1)===d.LUA_TTABLE&&!Xe(r,1))return d.lua_pushstring(r,T("table")),1;let n=be(r,i,1);return d.lua_pushstring(r,T(i.typeofOf(n))),1}),d.lua_setglobal(t,T("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),d.lua_pushcfunction(t,r=>i.luaRequire(r)),d.lua_setglobal(t,T("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 Ut?"TweenSequence":t instanceof bi?"Tween":t.typeofName?t.typeofName:typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t}pushColorLib(t){d.lua_newtable(t),d.lua_pushcfunction(t,i=>(this.pushPackedColor(i,Bt(d.lua_tonumber(i,1),d.lua_tonumber(i,2),d.lua_tonumber(i,3),255)),1)),d.lua_setfield(t,-2,T("FromRGB")),d.lua_pushcfunction(t,i=>{let r=d.lua_isnoneornil(i,4)?255:d.lua_tonumber(i,4);return this.pushPackedColor(i,Bt(d.lua_tonumber(i,1),d.lua_tonumber(i,2),d.lua_tonumber(i,3),r)),1}),d.lua_setfield(t,-2,T("FromRGBA")),d.lua_pushcfunction(t,i=>{let r=d.lua_tonumber(i,1)>>>0;for(let n of yi(r))d.lua_pushinteger(i,n);return 4}),d.lua_setfield(t,-2,T("ToRGBA")),d.lua_newtable(t),d.lua_pushcfunction(t,i=>{let r=d.lua_tonumber(i,2),n=d.lua_tonumber(i,3),o=d.lua_tonumber(i,4),a=d.lua_isnoneornil(i,5)?255:d.lua_tonumber(i,5);return this.pushPackedColor(i,Bt(r,n,o,a)),1}),d.lua_setfield(t,-2,T("__call")),d.lua_setmetatable(t,-2),d.lua_setglobal(t,T("Color"))}pushEnumLib(t){d.lua_newtable(t);for(let[i,r]of Object.entries(this.enumTree)){d.lua_newtable(t);for(let[n,o]of Object.entries(r))this.pushEnumItem(t,o),d.lua_setfield(t,-2,T(n));d.lua_setfield(t,-2,T(i))}d.lua_setglobal(t,T("Enum"))}pushEnumItem(t,i){let r=d.lua_newuserdata(t,0);mt(r,i),ee.luaL_setmetatable(t,T("EnumItem"))}pushControl(t,i){let r=d.lua_newuserdata(t,0);mt(r,i),ee.luaL_setmetatable(t,T("Control"))}pushScript(t,i){d.lua_newtable(t),d.lua_pushlightuserdata(t,mn);let r=d.lua_newuserdata(t,0);mt(r,i),d.lua_rawset(t,-3),ee.luaL_getmetatable(t,T("Script")),d.lua_setmetatable(t,-2)}pushTween(t,i){let r=d.lua_newuserdata(t,0);mt(r,i);let n=i instanceof Ut?"TweenSequence":"Tween";ee.luaL_setmetatable(t,T(n))}pushSignal(t,i){let r=d.lua_newuserdata(t,0);mt(r,i),ee.luaL_setmetatable(t,T("ServerSignal"))}pushCursor(t,i){let r=d.lua_newuserdata(t,0);mt(r,i),ee.luaL_setmetatable(t,T("CursorEventData"))}pushGameLib(t){let i=this;d.lua_newtable(t);let r={InstantiateClientUIControl:n=>{let o=d.lua_tointeger(n,1),a=ke(d.lua_touserdata(n,2)),s=i.instantiate(o,a,i.lifecyclePhase);return s?(i.pushControl(n,s),1):(d.lua_pushnil(n),1)},DestroyClientUIControl:n=>{let o=ke(d.lua_touserdata(n,1));return o&&i.destroyControl(o),0},GetClientUIControl:n=>{let o=d.lua_tointeger(n,1),a=i.controlsById.get(o);return a?i.pushControl(n,a):d.lua_pushnil(n),1},FindClientUIRoot:n=>{let o=Z(n,1),a=i.roots.find(s=>s.name===o);return a?i.pushControl(n,a):d.lua_pushnil(n),1},GetClientUIRoots:n=>(d.lua_createtable(n,i.roots.length,0),i.roots.forEach((o,a)=>{i.pushControl(n,o),d.lua_rawseti(n,-2,a+1)}),1),GetUICanvasSize:n=>(d.lua_pushnumber(n,i.canvasWidth),d.lua_pushnumber(n,i.canvasHeight),2),GetCursorUIPos:n=>(d.lua_pushnumber(n,i.cursor.x),d.lua_pushnumber(n,i.cursor.y),2),GetDevice:n=>(i.pushEnumItem(n,gt("Device",i.device)),1),SetControllerFocus:n=>(i.focus=ke(d.lua_touserdata(n,1)),0),GetControllerFocus:n=>(i.focus?i.pushControl(n,i.focus):d.lua_pushnil(n),1),GetControllerLeftStickAxis:n=>(d.lua_pushnumber(n,i.stick.left[0]),d.lua_pushnumber(n,i.stick.left[1]),2),GetControllerRightStickAxis:n=>(d.lua_pushnumber(n,i.stick.right[0]),d.lua_pushnumber(n,i.stick.right[1]),2),Tween:n=>{let o=ke(d.lua_touserdata(n,1))||be(n,i,1),a=be(n,i,2)||{},s=d.lua_tonumber(n,3),c=new bi(i,o,a,s);return i.pushTween(n,c),1},TweenSequence:n=>(i.pushTween(n,new Ut(i)),1),ServerSignal:n=>{let o=Z(n,1);return i.pushSignal(n,i.makeServerSignal(o)),1},GetGlobalCustomVariableValue:n=>{let o=we(be(n,i,1)),a=Z(n,2);return le(n,i,i.getVar(o,a)),1},PauseLevelTime:n=>(i.clock.paused=!!d.lua_toboolean(n,1),0),IsLevelTimePaused:n=>(d.lua_pushboolean(n,i.clock.paused),1),PlayAudio2D:n=>{let o=i.playAudio(i.audioInteger(n));return d.lua_pushinteger(n,o),1},StopAudio:n=>(i.stopAudio(i.audioInteger(n)),0),IsAudioAlive:n=>{let o=i.audios.get(i.audioInteger(n));return d.lua_pushboolean(n,!!(o&&o.alive)),1},GetLanguageType:n=>(i.pushEnumItem(n,gt("LanguageType",i.language)),1),GetStageMode:n=>(i.pushEnumItem(n,gt("StageMode",i.stageMode)),1),IsTestPlay:n=>(d.lua_pushboolean(n,i.testPlay),1),GetText:n=>{let o=Z(n,1);return d.lua_pushstring(n,T(o)),1},PrintClientUITree:n=>{for(let o of i.roots)i.log("info",bn(o).join(`
108
- `));return 0}};for(let[n,o]of Object.entries(r)){let a=uu[n];if(a===void 0)throw new Error(`missing game arity for ${n}`);d.lua_pushcfunction(t,s=>{let c=d.lua_gettop(s);return c!==a?ee.luaL_error(s,T(`bad argument count to '${n}' (${a} expected, got ${c})`)):o(s)}),d.lua_setfield(t,-2,T(n))}d.lua_setglobal(t,T("game"))}makeServerSignal(t){let i=[],r=this;return{__kind:"ServerSignal",name:t,AddParam(n,o){i.push({type:we(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(t,n)}}}audioInteger(t){let i=d.lua_tonumber(t,1);return d.lua_type(t,1)!==d.LUA_TNUMBER||!Number.isSafeInteger(i)?ee.luaL_error(t,T("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,o={instanceId:i,audioId:t,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(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 o=new nt(this,{...n,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(o),o.SetAsLastSibling(),Ve(o,a=>this.controlsById.set(a.Id,a)),this.mountSpecScripts(n,o),o}destroyControl(t){if(!(!t||!t.alive)){if(t._destroying)throw new Error(`\u5BA2\u6237\u7AEF\u63A7\u4EF6\u751F\u547D\u5468\u671F\u5904\u4E8E\u521B\u5EFA\u6216\u9500\u6BC1\u65F6\uFF0C\u65E0\u6CD5\u8C03\u7528DestroyClientUIControl, ID:${t.name}`);Ve(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=[];Ve(t,n=>r.push({control:n,was:n.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let n of r){let o=n.control.activeInHierarchy;if(n.was!==o)for(let a of n.control.scripts.slice())o?this.enableScript(a):this.disableScript(a)}}bindScriptEnv(t){let i=t.env;return i?(this.pushScript(i,t),d.lua_setglobal(i,T("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,o,a){ee.luaL_newmetatable(t,T(i)),d.lua_pushcfunction(t,s=>{let c=Xe(s,1)||ke(d.lua_touserdata(s,1)),l=Z(s,2);if(o[l]&&(!a||a(c,l)))return d.lua_pushcfunction(s,o[l]),1;let u;try{u=r(c,l)}catch(f){return ee.luaL_error(s,T(String(f.message||f)))}return u===void 0?(d.lua_pushnil(s),1):(le(s,this,u),1)}),d.lua_setfield(t,-2,T("__index")),d.lua_pushcfunction(t,s=>{try{let c=Xe(s,1)||ke(d.lua_touserdata(s,1)),l=Z(s,2),u=be(s,this,3);return n(c,l,u),0}catch(c){return d.lua_pushstring(s,T(String(c.message||c))),d.lua_error(s)}}),d.lua_setfield(t,-2,T("__newindex")),d.lua_pushcfunction(t,s=>{let c=Xe(s,1)||ke(d.lua_touserdata(s,1)),l=Xe(s,2)||ke(d.lua_touserdata(s,2));return d.lua_pushboolean(s,c===l),1}),d.lua_setfield(t,-2,T("__eq")),d.lua_pop(t,1)}method(t){let i=this;return r=>{let n=Xe(r,1)||ke(d.lua_touserdata(r,1)),o=d.lua_gettop(r),a=[];for(let s=2;s<=o;s++)a.push(be(r,i,s));try{let s=t(n,...a);if(s===n)return d.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 d.lua_createtable(r,s.length,0),s.forEach((c,l)=>{i.pushControl(r,c),d.lua_rawseti(r,-2,l+1)}),1;if(s.__scripts)return d.lua_createtable(r,s.length,0),s.forEach((c,l)=>{i.pushScript(r,c),d.lua_rawseti(r,-2,l+1)}),1;if(typeof s[0]=="number"&&s.length<=4){for(let c of s)d.lua_pushnumber(r,c);return s.length}}return le(r,i,s),1}catch(s){return d.lua_pushstring(r,T(String(s.message||s))),d.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,o)=>r.SetAnchoredPosition(n,o)),GetSizeDelta:this.method(r=>r.GetSizeDelta()),SetSizeDelta:this.method((r,n,o)=>r.SetSizeDelta(n,o)),GetAnchorMin:this.method(r=>r.GetAnchorMin()),SetAnchorMin:this.method((r,n,o)=>r.SetAnchorMin(n,o)),GetAnchorMax:this.method(r=>r.GetAnchorMax()),SetAnchorMax:this.method((r,n,o)=>r.SetAnchorMax(n,o)),GetPivot:this.method(r=>r.GetPivot()),SetPivot:this.method((r,n,o)=>r.SetPivot(n,o)),GetLocalScale:this.method(r=>r.GetLocalScale()),SetLocalScale:this.method((r,n,o,a)=>r.SetLocalScale(n,o,a)),GetLocalRotation:this.method(r=>r.GetLocalRotation()),SetLocalRotation:this.method((r,n,o,a)=>r.SetLocalRotation(n,o,a)),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,o)=>r.AddCursorEventListener(we(n),o)),RemoveCursorEventListener:this.method((r,n,o)=>r.RemoveCursorEventListener(we(n),o)),RemoveCursorEventListeners:this.method((r,n)=>r.RemoveCursorEventListeners(we(n))),RemoveAllCursorEventListeners:this.method(r=>r.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(r=>r.SimulateCursorClick()),AddKeyEventListener:this.method((r,n,o)=>r.AddKeyEventListener(we(n),o)),RemoveKeyEventListener:this.method((r,n,o)=>r.RemoveKeyEventListener(we(n),o)),RemoveKeyEventListeners:this.method((r,n)=>r.RemoveKeyEventListeners(we(n))),RemoveAllKeyEventListeners:this.method(r=>r.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((r,n,o)=>r.AddNavigationEventListener(we(n),o)),RemoveNavigationEventListener:this.method((r,n,o)=>r.RemoveNavigationEventListener(we(n),o)),RemoveNavigationEventListeners:this.method((r,n)=>r.RemoveNavigationEventListeners(we(n))),RemoveAllNavigationEventListeners:this.method(r=>r.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((r,n,o,a)=>r.SetControllerNavigation(we(n),o,a)),GetControllerNavigation:this.method((r,n)=>r.GetControllerNavigation(we(n))),SetImage:this.method((r,n,o)=>r.SetImage(n,o)),SetSoftEdgeWidth:this.method((r,n,o)=>r.SetSoftEdgeWidth(n,o)),SetFillUnused:this.method(r=>r.SetFillUnused()),SetFillHorizontal:this.method((r,n,o)=>r.SetFillHorizontal(n,o)),SetFillVertical:this.method((r,n,o)=>r.SetFillVertical(n,o)),SetFillRadial90:this.method((r,n,o)=>r.SetFillRadial90(n,o)),SetFillRadial180:this.method((r,n,o)=>r.SetFillRadial180(n,o)),SetFillRadial360:this.method((r,n,o)=>r.SetFillRadial360(n,o)),PlayAnimation:this.method(r=>r.PlayAnimation()),StopAnimation:this.method(r=>r.StopAnimation()),RefreshItems:this.method((r,n,o)=>{this.retainLuaCallback(o);try{r.RefreshItems(n,o)}finally{this.unrefLuaCallback(o)}}),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,o)=>r.ScrollToItemAt(n,o)),GetContentLength:this.method(r=>r.GetContentLength())};this.mtIndexNewindex(t,"Control",(r,n)=>{if(!yn(r,n))return;if(!r.alive&&n!=="alive")throw new Error(`attempt to read '${n}' of a destroyed control`);let o=r.luaFieldValue(n),a=$a[n];return a?Sn(a,o):typeof o=="number"&&!lu.has(n)&&!cu.has(n)?new pi(o):o},(r,n,o)=>{if(yn(r,n)==="rw"){if((n==="fontSize"||n==="minimumFontSize")&&!Number.isInteger(o)){let c=o===null?"nil":typeof o;throw new Error(`bad argument #2 to '${n}' (integer expected, got ${c})`)}let s=$a[n];if(n==="imageType"&&(o?.EnumType!=="ImageType"||!["Basic","Stretch"].includes(o.Name)))throw new Error("imageType requires Enum.ImageType.Basic or Stretch");r[n]=s?Sn(s,o):o,typeof r.markPlayDirty=="function"&&r.markPlayDirty(er.has(n));return}throw new Error(`cannot set ${n}, no such field`)},i,Na)}mtScript(t){let i=this,r=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(n,o)=>r.has(o)?n[o]:void 0,(n,o,a)=>{if(o==="enabled"){n.enabled=!!a;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,a)=>{i.signalHandlers.push({script:n,name:o,fn:a})}),UnregisterServerSignalHandler:this.method((n,o)=>{i.signalHandlers=i.signalHandlers.filter(a=>!(a.script===n&&a.name===o))}),RegisterCustomVariableChangedHandler:this.method((n,o,a,s)=>{i.varHandlers.push({script:n,entityType:we(o),name:a,fn:s})}),UnregisterCustomVariableChangedHandler:this.method((n,o,a)=>{let s=we(o);i.varHandlers=i.varHandlers.filter(c=>!(c.script===n&&c.entityType===s&&c.name===a))})})}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;d.lua_rawgeti(t,yt,d.LUA_RIDX_MAINTHREAD);let o=d.lua_tothread(t,-1);d.lua_pop(t,1);let a=this.requireCache.get(o);a||(a=new Map,this.requireCache.set(o,a));let s=a.get(n);if(s?.loading)return d.lua_pushstring(t,T(`failed to load script '${r}': cyclic require`)),d.lua_error(t);if(s&&s.ref!=null)return d.lua_rawgeti(t,yt,s.ref),1;let c=this.scriptFiles.get(n);if(c==null)return d.lua_pushstring(t,T(`failed to load script '${r}'`)),d.lua_error(t);let l=d.lua_gettop(t);a.set(n,{loading:!0});try{this.loadModule(t,o,n,c),d.lua_pushvalue(t,-1);let u=ee.luaL_ref(t,yt);return a.set(n,{ref:u}),1}catch(u){return a.delete(n),d.lua_settop(t,l),d.lua_pushstring(t,T(`failed to load script '${r}': ${u.message||u}`)),d.lua_error(t)}}newLuaThread(){let t=ee.luaL_newstate();return wa.luaL_openlibs(t),Aa(t),this.installMetatables(t),this.installGlobals(t),this.luaStates.add(t),d.lua_pushglobaltable(t),this.copyLuaEnvironment(t,-1),d.lua_remove(t,-2),this.moduleBaseEnvironments.set(t,ee.luaL_ref(t,yt)),t}copyLuaEnvironment(t,i){let r=d.lua_absindex(t,i);d.lua_newtable(t);let n=d.lua_absindex(t,-1);for(d.lua_pushnil(t);d.lua_next(t,r)!==0;)d.lua_pushvalue(t,-2),d.lua_pushvalue(t,-2),d.lua_rawset(t,n),d.lua_pop(t,1);d.lua_pushvalue(t,n),d.lua_setfield(t,n,T("_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,yt,r.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&ee.luaL_unref(t,yt,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);Ea(t)}loadModule(t,i,r,n){let o={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:r,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},a=String(n).replace(/^\uFEFF/,""),s=Zi(a);if(ee.luaL_loadbuffer(t,s,s.length,T(`@${r}`))!==Oe)throw new Error(Z(t,-1));let l=d.lua_absindex(t,-1);if(d.lua_rawgeti(t,yt,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),d.lua_remove(t,-2),this.pushScript(t,o),d.lua_setfield(t,-2,T("script")),d.lua_setupvalue(t,l,1),d.lua_pcall(t,0,1,0)!==Oe)throw new Error(Z(t,-1))}mountScript({path:t,source:i,control:r,params:n={},scriptMappingId:o=void 0}){this.L||this.boot();let a=this.newLuaThread(),s={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(o),object:r,path:this.normalizeRequirePath(t),enabled:!0,updateEnabled:!1,params:n,env:a,lifecyclePhase:"idle"};s.invoke=(l,u)=>this.invokeOn(a,l,u),r&&r.scripts.push(s),this.mountedScripts.push(s),this.pushScript(a,s),d.lua_setglobal(a,T("script"));let c=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",s.lifecyclePhase="OnInit",this.runChunk(a,i,t);let l=this.callGlobal(a,"OnInit");l&&this.mountErrors.push(l),this.lifecyclePhase="OnEnable",s.lifecyclePhase="OnEnable";let u=this.callGlobal(a,"OnEnable");u&&this.mountErrors.push(u),this.lifecyclePhase="OnStart",s.lifecyclePhase="OnStart";let f=this.callGlobal(a,"OnStart");return f&&this.mountErrors.push(f),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,a&&a!==this.L&&this.closeTrackedLuaState(a),s.env=null,l}}runChunk(t,i,r){let n=String(i).replace(/^\uFEFF/,""),o=Zi(n),a=ee.luaL_loadbuffer(t,o,o.length,T(`@${r}`));if(a!==Oe){let c=Z(t,-1)||`luaL_loadbuffer status ${a}`;throw d.lua_pop(t,1),new Error(c)}let s=d.lua_pcall(t,0,0,0);if(s!==Oe){let c=Z(t,-1)||`lua_pcall status ${s}`;throw d.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(d.lua_getglobal(t,T(i)),d.lua_isfunction(t,-1)){if(d.lua_pcall(t,0,0,0)!==Oe){let n=Z(t,-1);d.lua_pop(t,1);let o=`${i}: ${n}`;return this.log("lua-error",o),o}}else d.lua_pop(t,1);return null}callGlobalDt(t,i,r){if(d.lua_getglobal(t,T(i)),d.lua_isfunction(t,-1)){if(d.lua_pushnumber(t,r),d.lua_pcall(t,1,0,0)!==Oe){let o=Z(t,-1);d.lua_pop(t,1),this.log("lua-error",`${i}: ${o}`)}}else d.lua_pop(t,1)}luaInvoke(t){let i=Xe(t,1);if(!i||i.__kind!=="Script")return ee.luaL_error(t,T("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 f=3;f<=d.lua_gettop(t);f++)c.push(be(t,this,f));let l;try{l=i.invoke(r,c)}catch(f){return ee.luaL_error(t,T(String(f.message||f)))}if(l===void 0)return 0;let u=Array.isArray(l)&&l.__multi?l:[l];for(let f of u)le(t,this,f);return u.length}let o=2;if(d.lua_getglobal(t,T(r)),!d.lua_isfunction(t,-1))return 0;d.lua_replace(t,o),d.lua_remove(t,1);let a=d.lua_gettop(t)-1;return d.lua_pcall(t,a,Ga,0)!==Oe?d.lua_error(t):d.lua_gettop(t)}invokeOn(t,i,r){let n=d.lua_gettop(t);if(d.lua_getglobal(t,T(i)),!d.lua_isfunction(t,-1)){d.lua_settop(t,n);return}for(let c of r)le(t,this,c);if(d.lua_pcall(t,r.length,Ga,0)!==Oe){let c=Z(t,-1);throw d.lua_settop(t,n),new Error(c)}let a=d.lua_gettop(t)-n;if(a<=0){d.lua_settop(t,n);return}if(a===1){let c=be(t,this,-1);return d.lua_settop(t,n),c}let s=[];for(let c=1;c<=a;c++)s.push(be(t,this,n+c));return d.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),d.lua_setglobal(n,T("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;d.lua_createtable(r,0,5);let n=(o,a)=>{d.lua_pushcfunction(r,a),d.lua_setfield(r,-2,T(o))};return n("var",o=>(le(o,this,i.var(Z(o,1),Z(o,2))),1)),n("logContains",o=>(d.lua_pushboolean(o,i.logContains(Z(o,1))),1)),n("control",o=>(le(o,this,i.control(Z(o,1))),1)),n("logs",o=>(le(o,this,i.logs()),1)),n("signals",o=>(le(o,this,i.signals(Z(o,1))),1)),n("serverLogs",o=>(le(o,this,i.serverLogs?i.serverLogs():[]),1)),n("serverLogContains",o=>{let a=i.serverLogContains;return d.lua_pushboolean(o,a?!!a(Z(o,1)):!1),1}),d.lua_setglobal(r,T("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 vi(e){let t=new nr(e);return t.boot(),t}var vt=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),Cn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),Xa=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var In=Object.freeze([...Xa,...vt,...Cn]),qa=Object.freeze(["PlayerSelf","AllPlayers",...vt]),fu=Object.freeze(["Level","PlayerSelf",...vt]),Va=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),du=-2147483648,hu=2147483647,pu=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 Si(e){return`Player${Number(e)}`}function or(e){return`Avatar${Number(e)}`}function Ya(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function bt(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 qe(e,t=8){let i=bt(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 Ha(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of vt)e[t]=Object.create(null);for(let t of Cn)e[t]=Object.create(null);return e}function Wa(e){let t=String(e||"");if(!In.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function mu(e,t){let i=Wa(e);if(!fu.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function wi(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function ar(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function xn(e){let t=String(e||"PlayerSelf");if(!qa.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function Ii(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=Ii(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 xe(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function Ba(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 Ua(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:Ii(t),value:t}):[]}function gu(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function sr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ka(e,t){if(!sr(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 ja(e,t){return Ka(e,t)||xe(e)}function yu(e,t,i){if(!sr(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 o=mu(e.entityType,n);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${n}.value is required`);return{kind:r,entityType:o,name:wi(e.name),value:ja(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:xn(e.target),signalName:ar(e.signalName),params:e.params.map((o,a)=>ja(o,`${n}.params[${a}]`))}}throw new Error(`${n}.kind must be setCustomVariable or sendClientScriptSignal`)}function xi(e){if(e==null)return{version:1,rules:[]};if(!sr(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(!sr(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:ar(i.signalName),actions:i.actions.map((n,o)=>yu(n,r,o))}})}}function La(e,t,{typed:i=!1}={}){let r=Ka(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 xe(n[r.fromSignalParam])}return xe(e)}function bu(e){return e==="Level"?"Level":vt.includes(e)?"PlayerSelf":Cn.includes(e)?"AvatarSelf":e}function Ja(e={}){let t=Ha(),i=Ha(),r=[],n=[],o=[],a=[],s=Array.from({length:9},()=>null),c=1,l=0,u=Number(e.onlineLatencyMs||0);(!Number.isFinite(u)||u<0)&&(u=0);let f=xi(e.logic),h=bt(e.playerCount),p=qe(e.viewPlayerIndex,h);function m(b,A){a.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||Ii(S)||i[b][A]?.type||""}}function k(b,A,S){return typeof S!="number"||!Number.isInteger(S)?{ok:!0,value:S}:S>=du&&S<=hu?{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 w(b,A){let S=Wa(b),C=A||p;return S==="PlayerSelf"?Si(C):S==="AvatarSelf"?or(C):S}function N(b,A){let S=bu(b);if(b==="Level"){for(let E=1;E<=h;E+=1){let _=s[E];_&&typeof _.notifyVarHandlers=="function"&&_.notifyVarHandlers("Level",A)}return}let C=Ya(b);if(!C)return;let F=s[C];F&&typeof F.notifyVarHandlers=="function"&&F.notifyVarHandlers(S,A)}function M(b,A){let S=xn(b);return S==="AllPlayers"?Array.from({length:h},(C,F)=>F+1):S==="PlayerSelf"?[A||p]:[Ya(S)]}function Y(b){for(let A of f.rules)if(A.signalName===b.name)for(let S of A.actions){if(S.kind==="setCustomVariable"){let C=La(S.value,b);$.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=>La(F,b,{typed:!0}));$.sendToClient(S.signalName,C,{target:S.target,playerIndex:b.playerIndex}),m("info",`logic ${A.id}: sent ${S.signalName} to ${S.target}`)}}}function U(b,A){b&&(b.serverBridge={getVar:(S,C)=>$.getVar(S,C,{playerIndex:A}),setVar:(S,C,F)=>$.setVar(S,C,F,{playerIndex:A}),receiveFromClient:(S,C)=>$.receiveFromClient(S,C,{playerIndex:A})})}function H(b){b&&(b.serverBridge=null)}let $={ENTITY_TYPES:Xa,ALL_ENTITY_TYPES:In,CLIENT_SIGNAL_TARGETS:qa,get clock(){return l},get playerCount(){return h},get viewPlayerIndex(){return p},setClock(b){l=Number(b)||0},setPlayerCount(b){return h=bt(b),p>h&&(p=h),h},setViewPlayerIndex(b){return p=qe(b,h),p},log(b,A){m(b,A)},defineVar(b,A,S={},{playerIndex:C}={}){let F=w(b,C),E=wi(A);if(Object.prototype.hasOwnProperty.call(t[F],E))throw new Error(`custom variable already exists: ${F}.${E}`);let _=S.type?String(S.type):Ii(S.value??S.defaultValue);if(_&&!Va.includes(_))throw new Error(`unsupported custom variable type: ${_}`);let G=S.value!==void 0?S.value:S.defaultValue!==void 0?S.defaultValue:null;return x(F,E,G,_),$.getVar(F,E)},getVar(b,A,{playerIndex:S}={}){let C=w(b,S),F=wi(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:E}={}){let _=w(b,E),G=wi(A),B=F||i[_][G]?.type||Ii(S);if(B&&!Va.includes(B)&&B!=="")throw new Error(`unsupported custom variable type: ${B}`);let ie=S;if(!((B==="Int"||B===""&&typeof S=="number"&&Number.isInteger(S))&&(ie=k(_,G,S).value,ie===void 0)))return x(_,G,ie,B),C&&N(_,G),ie},listVars(b){let A=b?[w(b)]:["Level",...Array.from({length:h},(C,F)=>Si(F+1)),...Array.from({length:h},(C,F)=>or(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:xe(t[C][F])});return S},receiveFromClient(b,A=[],{playerIndex:S}={}){let C=qe(S||p,h);y(C);let F=ar(b),E={id:c++,direction:"inbound",name:F,params:Ua(A),values:Ba(A),time:l,playerIndex:C,from:Si(C)};return r.push(E),Y(E),E},sendToClient(b,A=[],{target:S="PlayerSelf",playerIndex:C}={}){let F=ar(b),E=xn(S),G=M(E,C||p),B={id:c++,direction:"outbound",name:F,params:Ua(A),values:Ba(A),time:l,target:E,players:G,deliverAt:l+u/1e3,delivered:!1};return n.push(B),u===0?$.deliver(B):o.push(B),B},getLogic(){return xe(f)},setLogic(b){return f=xi(b),$.getLogic()},deliver(b){if(!b||b.delivered)return;b.delivered=!0;let A=Array.isArray(b.players)&&b.players.length?b.players:M(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=o.length-1;S>=0;S-=1)o[S].deliverAt<=l&&A.push(o.splice(S,1)[0]);A.sort((S,C)=>S.id-C.id);for(let S of A)$.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=gu(A);if(!pu.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&&$.setPlayerCount(b.playerCount),b.viewPlayerIndex!==void 0&&$.setViewPlayerIndex(b.viewPlayerIndex),(b.logic!==void 0||b.serverLogic!==void 0)&&$.setLogic(b.logic??b.serverLogic);for(let A of b.vars||[]){let S=w(A.entityType),C=wi(A.name);Object.prototype.hasOwnProperty.call(t[S],C)?$.setVar(S,C,A.value??A.defaultValue,{notify:!1,type:A.type}):$.defineVar(S,C,A)}}},attachRuntime(b,{playerIndex:A=1}={}){let S=qe(A,8);return s[S]&&s[S]!==b&&H(s[S]),s[S]=b||null,U(s[S],S),$},attachRuntimes(b){$.detachRuntime();let A=Array.isArray(b)?b:[];for(let S=0;S<A.length&&S<8;S+=1)s[S+1]=A[S]||null,U(s[S+1],S+1);return $},detachRuntime(){for(let b=1;b<=8;b+=1)H(s[b]),s[b]=null},snapshot(){let b=Si(p),A=or(p),S={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let C of Object.keys(t.Level))S.Level[C]={type:i.Level[C]?.type||"",value:xe(t.Level[C])};for(let C of Object.keys(t[b]))S.PlayerSelf[C]={type:i[b][C]?.type||"",value:xe(t[b][C])};for(let C of Object.keys(t[A]))S.AvatarSelf[C]={type:i[A][C]?.type||"",value:xe(t[A][C])};for(let C=1;C<=h;C+=1){let F=Si(C),E=or(C);S[F]={},S[E]={};for(let _ of Object.keys(t[F]))S[F][_]={type:i[F][_]?.type||"",value:xe(t[F][_])};for(let _ of Object.keys(t[E]))S[E][_]={type:i[E][_]?.type||"",value:xe(t[E][_])}}return{clock:l,onlineLatencyMs:u,playerCount:h,viewPlayerIndex:p,logic:$.getLogic(),vars:S,inbound:r.map(C=>({id:C.id,name:C.name,params:xe(C.params),values:xe(C.values),time:C.time,playerIndex:C.playerIndex,from:C.from})),outbound:n.map(C=>({id:C.id,name:C.name,params:xe(C.params),values:xe(C.values),time:C.time,target:C.target,players:Array.isArray(C.players)?C.players.slice():[],deliverAt:C.deliverAt,delivered:!!C.delivered})),logs:a.map(C=>({source:"server",level:C.level,text:C.text,time:C.time}))}},reset(){for(let b of In){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,o.length=0,a.length=0,c=1,l=0},destroy(){$.detachRuntime(),$.reset()}};e.config&&$.loadConfig(e.config);for(let b of e.vars||[])$.defineVar(b.entityType,b.name,b);return $}var vu={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function kn(e,t,i=null){let r=et(e.transformByPlatform,t),n={authoringId:e.id,kind:vu[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(a=>kn(a,t,i))},o=i?.get(e.id);return o?.length&&(n.scripts=o.map(a=>{let s=Number(a.guid);return{path:a.path||a.id,source:a.source||"",...Number.isSafeInteger(s)&&s>0?{scriptMappingId:s}:{}}})),e.kind==="container"&&(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 En(e,t=[],i=""){let r=i&&J[i]?i:e.canvasId,n=J[r],o=ui(e),a=new Map;for(let c of t){if(!c.controlId)continue;let l=a.get(c.controlId)||[];l.push(c),a.set(c.controlId,l)}let s=e.meta?.assetType==="client-control-template"?(e.root.children||[]).map(c=>kn(c,r,a)):[];return{canvasId:r,platform:n.platform,device:n.luaDevice,canvasWidth:n.width,canvasHeight:n.height,root:kn(o,r,a),templates:s}}var lr="qxqy-autotest";var wt=.03333333333333333,Su=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),wu=new Set(["log","control","var","signal","tree","lua"]);function St(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function An(e){return JSON.parse(JSON.stringify(e??null))}function cr(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=St(r.x,"pointer.x"),r.y=St(r.y,"pointer.y"),r.type=String(r.type||"click"),r.type==="wheel"&&(r.deltaX=St(r.deltaX??e.deltaX??0,"pointer.deltaX"),r.deltaY=St(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:St(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:r}}function _n(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(!wu.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let r={kind:i};if(e.at!==void 0&&(r.at=St(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=An(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=An(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=An(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 Za(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+=St(n.dt??wt,"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(cr({...n,kind:n.do,t},i.length));continue}if(n.assert||n.check||n.kind){r.push(_n({...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:wt}}function Ci(e){if(Array.isArray(e)){let r=Za(e);return{format:lr,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=Za(e.queue||e.steps);return{format:lr,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)=>cr(r,n)),i=(e.asserts||[]).map((r,n)=>_n(r,n));return t.sort((r,n)=>r.t-n.t||0),{format:lr,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):wt,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function Qa(e,t={}){let i=(e||[]).map((r,n)=>cr(r,n));return{format:lr,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):wt,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((r,n)=>_n(r,n))}}function es(e,t,i){if(!e)return null;let r=cr({...t,t:t.t??i??0},e.events.length);return e.events.push(r),r}import{createCanvas as Iu}from"@napi-rs/canvas";var ts=Iu(1,1).getContext("2d"),xu='"Microsoft YaHei UI","Microsoft YaHei",sans-serif',ur=(e,t)=>Math.max(0,Math.min(t,Number.isFinite(e)?e:0));function is(e,t,i){let r=Math.max(8,Number(e.fontSize)||12),n=String(e.text??"").replace(/\r\n?/g,`
109
- `),o=JSON.stringify([n,t,i,r,e.showScrollBar]),a=e._textWindowLayout;if(a?.key!==o){ts.font=`${r}px ${xu}`;let l=p=>{let m=[];for(let y of n.split(`
110
- `)){let x="";for(let k of y)x&&ts.measureText(x+k).width>p&&(m.push(x),x=""),x+=k;m.push(x)}return m},u=l(Math.max(1,t-4)),f=e.showScrollBar!==!1&&u.length*r*1.2>i,h=Math.max(1,t-4-(f?12:0));f&&(u=l(h)),a=e._textWindowLayout={key:o,lines:u,font:r,textWidth:h,lineHeight:r*1.2,length:u.length*r*1.2}}let s=Math.max(0,a.length-i),c=ur(e._scrollOffset||0,s);return e._scrollOffset=c,{...a,max:s,offset:c,viewport:i,horizontal:!1,width:t,height:i}}function jt(e,t,i){if(!e?.showBar||e.max<=0||t<=0||i<=0)return null;let r=e.horizontal===!0,n=r?t:i,o=Math.max(0,n-4),a=Math.min(o,Math.max(18,o*n/(n+e.max))),s=o-a,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:o,height:l}:{x:t/2-l-2,y:-i/2+2,width:l,height:o},f=r?{...u,x:u.x+c,width:a}:{...u,y:u.y+c,height:a};return{track:u,thumb:f,travel:s}}var rs="https://oss.070077.xyz/",Pn="mp3-v1",fr="/qxqy-audio/",Cu=[[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 dr(e){if(!Number.isSafeInteger(e))return null;for(let[t,i]of Cu)if(e>=t&&e<t+i.length)return i[e-t];return null}var hr=e=>Number.isFinite(Number(e))?Math.max(0,Number(e)):0;function pr(e,t){if(!e||e.kind!=="image"||e.enableMask!==!0||!t)return null;let i=hr(e.sourceWidth??e.width),r=hr(e.sourceHeight??e.height),n=e.enableSoftEdge===!0,o=e.softEdgeMode!=="Pixel",a=n?hr(e.softEdgeWidthX):0,s=n?hr(e.softEdgeWidthY):0;return{id:e.id,matrix:t,width:i,height:r,featherX:o?i*a/100:a,featherY:o?r*s/100:s}}function ns(e,t,i){let r=Ie(e,t,i);return{a:e.a,b:e.b,c:e.c,d:e.d,tx:r.x,ty:r.y}}function os(e,t,i){let r=(n,o)=>n<=0?0:!(o>0)||n>=o?1:n/o;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 as(e){let t={children:[]},i=[t],r=[];for(let n of e||[]){if(!n||n.id==null)continue;let o=n.masks||[],a=o.map(c=>JSON.stringify([c.id,c.matrix,c.width,c.height,c.featherX,c.featherY])),s=0;for(;s<r.length&&s<a.length&&r[s]===a[s];)s++;i.length=s+1;for(let c=s;c<o.length;c++){let l={mask:o[c],children:[]};i.at(-1).children.push(l),i.push(l)}i.at(-1).children.push({item:n}),r=a}return t.children}import{randomUUID as us}from"node:crypto";function yr(e){for(let t of e.runtime.scrollControls||[]){let[i,r]=mi(t),n=t.kind==="grid"?Yt(t):is(t,i,r),o={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},a=JSON.stringify(o);t._scrollKey!==a&&(t._scrollKey=a,t._scroll=o,t.markPlayDirty())}}function fs(e){return{...e._scroll?{scroll:e._scroll}:{},...e.parent?._gridItems?.includes(e)?{clipToParent:!0}:{}}}function Tn(e,t){let i=e._scroll?.max||0;e.kind==="grid"?e.scrollProgress=i?ur(t,i)/i:0:e._scrollOffset=ur(t,i),e.markPlayDirty()}var ku=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 br(e){yr(e);let t=Se({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function r(n,o,a){let s=Be(o,n);s.activeInHierarchy=a&&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 ds(e,t=br(e)){let i=new Map;function r(n,o){let a=t.get(n.Id);if(!a)return;let s=ci(o,a,n);i.set(n.Id,s);for(let c of n.children)r(c,s)}for(let n of e.runtime.roots)r(n,Ft());return i}function hs(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"?Ce(e.imageSource):null,imageType:e.kind==="image"?e.imageType==null?null:Fe(e.imageType):null,primitive:e.kind==="image"?Nt(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=>hs(r,t))}}function Eu(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,pointerScroll:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function Au(e,t,i,r){let n=vi({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device,audioDuration:dr,canSelectImageType:Ao,...r?{language:r}:{}});for(let o of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(o.prefabIndex)&&o.prefabIndex>0&&n.registerTemplate(o.prefabIndex,o);for(let o of i){let a=o.path||o.id,s=o.source||"";a&&s&&n.registerScriptFile(a,s)}return n}var _u=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","pointerScroll","hoveredControl","selectedControl","stateRestores","viewCache"];function Pu(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of _u)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 ps(e,{templatesProject:t=null,scripts:i=[],sceneScripts:r=null,templateScripts:n=null,serverConfig:o=null,canvasId:a="",playerCount:s=1,viewPlayerIndex:c=1,language:l=""}={}){let u=r||i,f=n||i,h=En(e,u,a),p=t?En(t,f,a):null,m=bt(s),y=qe(c,m),x=Ja({playerCount:m,viewPlayerIndex:y});o&&x.loadConfig({...o,playerCount:m,viewPlayerIndex:y});let k=[];for(let M=0;M<m;M+=1)k.push(Au(h,p,i,l));x.attachRuntimes(k);for(let M of k)M.addRoot(h.root);let w={audioSessionId:us(),runtimes:k,views:k.map(()=>Eu()),playerCount:m,viewPlayerIndex:y,server:x,compiled:h,mountError:k.find(M=>M.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};Pu(w);let N=w.viewPlayerIndex;for(let M=1;M<=m;M+=1)w.viewPlayerIndex=M,Vu(w);return w.viewPlayerIndex=N,w}function On(e,t){if(!e)throw new Error("play session has not started");let i=qe(t,e.playerCount);return i===e.viewPlayerIndex||(ot(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function ot(e,t){!e?.recording||!e.history||es(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function Tu(e){return e?.history?.events||[]}var Fn=new Set(["image","textbox","textwindow","button","grid"]);function Ru(e,t){let i=Ie(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 Fe(e){return typeof e=="string"?e:e?.Name}function ms(e){return{fillType:Fe(e.fillType),fillHorizontalType:Fe(e.fillHorizontalType),fillVerticalType:Fe(e.fillVerticalType),fillAmount:e.fillAmount}}function Mu(e,t,i){let r=Math.abs(t.width*i.scaleX),n=Math.abs(t.height*i.scaleY),o={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,...fs(e)};return e.kind==="image"&&(o.imageSource=Ce(e.imageSource),o.imageType=e.imageType==null?null:Fe(e.imageType),o.primitive=Nt(e.imageId,o.imageSource),o.imageColor=e.imageColor,o.imageId=e.imageId,Object.assign(o,ms(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(o.text=e.text??"",o.fontSize=e.fontSize,o.fontColor=e.fontColor,o.bgColor=e.bgColor,o.enableOutline=e.enableOutline===!0,o.outlineColor=e.outlineColor,o.horizontalAlignment=Fe(e.horizontalAlignment),o.verticalAlignment=Fe(e.verticalAlignment)),o}function Nu(e,t=br(e)){let i=[],r=ds(e,t);function n(o,a=[],s=[]){let c=t.get(o.Id);if(!c||o.visible===!1||!c.activeInHierarchy)return;let l=r.get(o.Id);if(!l)return;let u=Ru(c,l),f=o.kind==="image"&&o.enableMask===!0?pr({...gs(o,c),id:o.Id},ns(l,c.centerX,c.centerY)):null,h=f?[...s,f]:s,p=()=>i.push({...Mu(o,c,u),...a.length?{clipPolygons:a}:{},...h.length?{masks:h}:{}});Fn.has(o.kind)&&o.kind!=="grid"&&p();let m=o.children||[];for(let y=m.length-1;y>=0;y-=1){let x=o._gridItems?.includes(m[y])?[...a,[[c.left,c.bottom],[c.right,c.bottom],[c.right,c.top],[c.left,c.top]].map(([k,w])=>Ie(l,k,w))]:a;n(m[y],x,h)}o.kind==="grid"&&p()}for(let o of e.runtime.roots)n(o);return i}function gs(e,t){let i={kind:e.kind,name:e.name,sourceWidth:t.width,sourceHeight:t.height,pressed:e.pressed===!0,...fs(e)};return e.kind==="image"&&(i.imageSource=Ce(e.imageSource),i.imageType=e.imageType==null?null:Fe(e.imageType),i.primitive=Nt(e.imageId,i.imageSource),i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,ms(e),{enableMask:e.enableMask===!0,enableSoftEdge:e.enableSoftEdge===!0,softEdgeMode:Fe(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=Fe(e.horizontalAlignment),i.verticalAlignment=Fe(e.verticalAlignment)),i}function Ou(e,t,i){let r=Yr(e,t),n=Ie(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 ys(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 bs(e,t,i,r,n,o){return{id:e.Id,parent:t,z:n,group:o>=16,matrix:Ou(r,e,i),...gs(e,r)}}function Fu(e){let t=Se({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,r=new Map,n=new Map;function o(c,l,u){let f=Be(l,c);if(f.activeInHierarchy=u&&c.active!==!1,n.set(c.Id,f),c.visible===!1||!f.activeInHierarchy)return!1;let h=c.children||[],p=Fn.has(c.kind),m=0;for(let y=0;y<h.length;y+=1)o(h[y],f,f.activeInHierarchy)&&(p=!0,m+=1);return p?(i.add(c.Id),r.set(c.Id,m),!0):!1}function a(c,l,u,f){if(!i.has(c.Id))return;let h=n.get(c.Id);s.push(bs(c,l,u,h,f,r.get(c.Id)||0));let p=c.children||[];for(let m=0;m<p.length;m+=1)a(p[m],c.Id,h,m)}let s=[];for(let c=0;c<e.runtime.roots.length;c+=1)o(e.runtime.roots[c],t,!0),a(e.runtime.roots[c],null,null,c);return{nodes:s,childCounts:r}}function Mn(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)Mn(i[r])}function Du(e,t){let i=Se({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=[],n=[],o=t.count,a=e.runtime._playRemoved||[];for(let l=0;l<a.length;l+=1){let u=a[l];t.fingerprints.has(u)&&(n.push(u),t.fingerprints.delete(u),t.childCounts.delete(u),o-=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),o-=1);let u=l.children;for(let f=0;f<u.length;f+=1)s(u[f])}function c(l,u,f,h,p,m){let y=m||l._playDeepDirty===!0,x=y||l._playDirty===!0,k=y||l._playChildDirty===!0;if(!x&&!k)return;if(!(p&&l.active!==!1)||l.visible===!1){s(l);return}let N=Be(u,l),M=t.childCounts.get(l.Id)||0;if(k){M=0;let A=l.children;for(let S=0;S<A.length;S+=1)c(A[S],N,l.Id,S,!0,y),t.fingerprints.has(A[S].Id)&&(M+=1)}if(!(Fn.has(l.kind)||M>0)){t.fingerprints.has(l.Id)&&(n.push(l.Id),t.fingerprints.delete(l.Id),t.childCounts.delete(l.Id),o-=1);return}let U=t.childCounts.get(l.Id);t.childCounts.set(l.Id,M);let H=M>=16!=(U||0)>=16;if(!x&&!H&&t.fingerprints.has(l.Id))return;let $=bs(l,f,u===i?null:u,N,h,M),b=ys($);t.fingerprints.get($.id)!==b&&(t.fingerprints.has($.id)||(o+=1),t.fingerprints.set($.id,b),r.push($))}for(let l=0;l<e.runtime.roots.length;l+=1)c(e.runtime.roots[l],i,null,l,!0,!1);return t.count=o,{changed:r,removed:n,count:o}}function zu(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}=Fu(e);i.rev+=1,i.fingerprints=new Map(c.map(u=>[u.id,ys(u)])),i.childCounts=l,i.count=c.length;for(let u of e.runtime.roots)Mn(u);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:o,removed:a,count:s}=Du(e,i);i.rev+=1;for(let c of e.runtime.roots)Mn(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:s,changed:o,removed:a}}function Dn(e,{inspect:t=!1,view:i=!1,paint:r=!1,sceneRev:n,compact:o=!1}={}){yr(e),e.audioSessionId||=us();let a=e.runtime,s=e.compiled,[c,l]=[a.canvasWidth,a.canvasHeight];e.server&&e.server.setClock(a.clock.time);let u=o?a.logs.slice(-100):a.logs,f=Tu(e),h=e.server?e.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 p={canvasId:s.canvasId,platform:s.platform,device:a.device,canvasWidth:c,canvasHeight:l,canvasPresets:ku,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:a.clock.time,frame:a.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!a.clock.paused,audio:{sessionId:e.audioSessionId,playerIndex:e.viewPlayerIndex||1,...a.audioSnapshot()},mountError:e.mountError||a.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:(o?f.slice(-100):f).map(m=>({t:m.t,source:m.source||"user",kind:m.kind,payload:m.payload||{}}))};if(t||r){let m=br(e);t&&(p.tree=a.roots.map(y=>hs(y,m))),r&&(p.paint=Nu(e,m))}return i&&(p.scene=zu(e,n)),Ot(p),p}function vr(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 zn(e,t){ot(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function $u(e,t){let i=null;for(let r of e.runtime.roots)Ve(r,n=>{!i&&n.name===t&&(i=n)});return i}function $n(e,t){ot(e,{kind:"click",payload:{name:String(t)}});let i=$u(e,t);i&&Gn(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function Gu(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var vs={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function Ss(e,t){let i=[];for(let[r,n]of Object.entries(vs)){let o=t[n]?Gu(t,t[n]):null;o&&i.push({state:r,child:o})}return i}function Vu(e){for(let t of e.runtime.roots)Ve(t,i=>{if(i.kind==="button"){for(let{child:r}of Ss(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);ki(e,i)}})}function ki(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 Ss(e,t))r.child.active=!0,r.child.visible=r.state===i,typeof r.child.markPlayDirty=="function"&&r.child.markPlayDirty(!0)}function Rn(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(vs).map(r=>t[r]).filter(Boolean).includes(e.authoringId)?t:e}function Gn(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 ws(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function Is(e,t){let i=e.Id,r=t.get(i);if(r!==void 0)return r;let n=Gn(e);if(!n&&ws(e)){let o=e.children;for(let a=0;a<o.length;a+=1)if(Is(o[a],t)){n=!0;break}}return t.set(i,n),n}function mr(e,t,i){yr(e);let r=Se({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=new Map;function o(s,c,l,u){if(!u||s.active===!1||s.visible===!1||!Is(s,n))return null;let f=Be(c,s),h=ci(l,f,s),p=Ue(h);if(!p)return null;let m=Ie(p,t,i);if(m.x<f.left||m.x>f.right||m.y<f.bottom||m.y>f.top)return null;if(gr(s)){let y=jt(s._scroll,f.width,f.height)?.track,x=m.x-f.centerX,k=f.centerY-m.y;if(y&&x>=y.x&&x<=y.x+y.width&&k>=y.y&&k<=y.y+y.height)return s}if(ws(s))for(let y=0;y<s.children.length;y+=1){let x=o(s.children[y],f,h,!0);if(x)return x}return Gn(s)?s:null}let a=Ft();for(let s=e.runtime.roots.length-1;s>=0;s-=1){let c=o(e.runtime.roots[s],r,a,!0);if(c)return c}return null}function Lt(e,t,i,{dragging:r=!1,press:n=null,previous:o=null}={}){let a=n||{x:t,y:i},s=o||{x:t,y:i};return e.runtime.makeCursorEventData({x:t,y:i,pressX:a.x,pressY:a.y,deltaX:t-s.x,deltaY:i-s.y,dragging:r})}function Nn(e,t,i){t.kind==="grid"||t.kind==="textwindow"||(t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),ki(e,t))}function gr(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 ss(e){for(let t=e;t;t=t.parent)if(gr(t))return t;return null}function ls(e,t,i,r){let n=br(e),o=n.get(t.Id),a=ds(e,n).get(t.Id),s=a&&Ue(a);if(!o||!s)return null;let c=Ie(s,i,r);return{x:c.x-o.centerX,y:o.centerY-c.y,width:o.width,height:o.height}}function cs(e,t,i){let r=e.pointerDownControl;if(r?.alive){let n=Lt(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),Nn(e,r,!1)}e.pointerDownControl=null,e.pointerScroll=null,e.pointerDownPosition=null,e.pointerDragging=!1,e.pointerLastPosition={x:t,y:i}}function Ei(e,t,i,r,n={}){let o=Number(i),a=Number(r);if(!Number.isFinite(o)||!Number.isFinite(a))throw new Error("pointer coordinates must be finite");e.runtime.cursor.x=o,e.runtime.cursor.y=a;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||ot(e,{kind:"pointer",payload:{type:t,x:o,y:a,...t==="wheel"?{deltaX:s,deltaY:c}:{}}}),t==="wheel"){let l=mr(e,o,a),u=ss(l);if(u){let f=u._scroll.horizontal&&s||c;Tn(u,u._scroll.offset+f)}return l}if(t==="cancel")return cs(e,o,a),null;if((t==="move"||t==="up")&&e.pointerScroll&&!gr(e.pointerScroll.control)&&cs(e,o,a),t==="move"){let l=e.pointerLastPosition||{x:o,y:a},u=e.pointerHoverControl,f=Rn(mr(e,o,a)),h=Lt(e,o,a,{previous:l});u&&u!==f&&e.runtime.injectCursor(u,"CursorExit",h),f&&u!==f&&e.runtime.injectCursor(f,"CursorEnter",h),e.pointerHoverControl=f;let p=e.hoveredControl;e.hoveredControl=f?.kind==="button"?f:null,p&&p!==e.hoveredControl&&ki(e,p),e.hoveredControl&&ki(e,e.hoveredControl);let m=e.pointerDownControl,y=e.pointerScroll;if(y)if(!gr(y.control))e.pointerScroll=null;else{let x=ls(e,y.control,o,a);if(x){let k=y.control._scroll,w=k.horizontal?x.x-y.start.x:x.y-y.start.y,N=jt(k,x.width,x.height)?.travel||0,M=y.bar?N?w*k.max/N:0:-w;Tn(y.control,y.offset+M)}}if(m?.alive){let x=e.pointerDownPosition||l,k=o!==l.x||a!==l.y;!e.pointerDragging&&k&&(y||e.runtime.injectCursor(m,"CursorBeginDrag",Lt(e,o,a,{press:x,previous:l,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&!y&&e.runtime.injectCursor(m,"CursorDrag",Lt(e,o,a,{press:x,previous:l,dragging:!0}))}return e.pointerLastPosition={x:o,y:a},f}if(t==="down"){let l=Rn(mr(e,o,a));e.pointerDownControl=l,e.pointerDownPosition={x:o,y:a},e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,e.pointerScroll=null;let u=ss(l);if(u){let f=ls(e,u,o,a),h=f&&jt(u._scroll,f.width,f.height),p=y=>f.x>=y.x&&f.x<=y.x+y.width&&f.y>=y.y&&f.y<=y.y+y.height,m=h&&p(h.track);if(m&&!p(h.thumb)){let y=u._scroll.horizontal?f.x-h.track.x-h.thumb.width/2:f.y-h.track.y-h.thumb.height/2;Tn(u,h.travel?y/h.travel*u._scroll.max:0),yr(e)}f&&(e.pointerScroll={control:u,start:f,offset:u._scroll.offset,bar:!!m})}return l&&(Nn(e,l,!0),e.runtime.injectCursor(l,"CursorDown",Lt(e,o,a))),l}if(t==="up"){let l=e.pointerDownControl,u=Rn(mr(e,o,a));if(l?.alive){let f=Lt(e,o,a,{press:e.pointerDownPosition,previous:e.pointerLastPosition,dragging:e.pointerDragging});if(e.runtime.injectCursor(l,"CursorUp",f),e.pointerDragging)e.pointerScroll||e.runtime.injectCursor(l,"CursorEndDrag",f);else if(u===l&&!e.pointerScroll?.bar){e.runtime.injectCursor(l,"CursorClick",f);let h=e.selectedControl;e.selectedControl=l.kind==="button"?l:null,h&&h!==e.selectedControl&&ki(e,h)}Nn(e,l,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,e.pointerScroll=null,u}if(t==="click")return Ei(e,"down",o,a,{silent:!0}),Ei(e,"up",o,a,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function Vn(e,t,i,r){if(!e?.server)throw new Error("play session has no server");return ot(e,{kind:"serverSet",payload:{entityType:t,name:i,value:r,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,r,{playerIndex:e.viewPlayerIndex})}function xs(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 Yn(e,t,i=[],r="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return ot(e,{kind:"serverSend",payload:{name:t,params:i,target:r,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:r,playerIndex:e.viewPlayerIndex})}function Sr(e){return{snapshot:t=>Dn(e,t),step:t=>vr(e,t),pointer:(t,i,r,n)=>Ei(e,t,i,r,n),key:t=>zn(e,t),click:t=>$n(e,t),view:t=>On(e,t),pause:()=>{ot(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{ot(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,r)=>Vn(e,t,i,r),serverSend:(t,i,r)=>Yn(e,t,i,r)}}function Hn(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function Bn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Cs(e,t){for(let i of e||[])t(i),i.children?.length&&Cs(i.children,t)}function Un(e,{id:t,name:i}){let r=null;return Cs(e,n=>{r||(t&&String(n.id)===String(t)||!t&&i&&n.name===i)&&(r=n)}),r}function Yu(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 Hu(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=Un(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 Bu(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=Un(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let r=Yu(i,e.field);return Bn(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 Bn(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||Bn(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=!!Un(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 Uu(e,t){let i=vi();try{return i.evalQueryScript(e,Hu(t)),{ok:!0,actual:!0}}catch(r){return{ok:!1,message:r?.message||String(r)}}finally{i.destroy()}}function ks(e,t){return e.kind==="lua"?Uu(e.source,t):Bu(e,t)}function ju(e,t){let i=t>0?t:wt;return Math.round((e+i)*1e9)/1e9}function Lu(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 Xu(e,t){let i=ks(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 Es(e,t){let i=Ci(t),r=i.events.slice().sort((k,w)=>k.t-w.t),n=i.asserts.slice(),o=i.dt||wt,a=r.reduce((k,w)=>Math.max(k,w.t),0),s=n.reduce((k,w)=>Math.max(k,Number(w.at||0)),0),c=Math.max(a,s),l=0,u=[],f=0,h=n.some(k=>k.kind==="control"||k.kind==="tree"||k.kind==="lua"),p=e.snapshot({inspect:h}),m=()=>{for(;l<r.length&&r[l].t<=f+1e-9;)Lu(e,r[l]),l+=1,p=e.snapshot({inspect:h})},y=()=>{for(let k of n)if(!k._done&&Number(k.at||0)<=f+1e-9){let w=Xu(k,p);if(u.push(w),k._done=!0,!w.ok)return{passed:!1,failedAt:f,frame:p.frame||0,results:u,snapshot:p}}return null};m();let x=y();if(x)return jn(i,x);for(;f+1e-9<c;){e.step(o),f=ju(f,o),p=e.snapshot({inspect:h}),m();let k=y();if(k)return jn(i,k)}return jn(i,{passed:u.every(k=>k.ok),failedAt:null,frame:p.frame||0,results:u,snapshot:p})}function jn(e,t){return V({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 Ln(e){return Array.isArray(e)?e.slice():[]}import{createHash as qu}from"node:crypto";var As=e=>qu("sha256").update(JSON.stringify(e.map(({id:t,path:i,source:r})=>({id:t,path:i,source:r})))).digest("hex");function _s(e){let t=new Map;for(let r of e){let n=`${r.controlAsset}:${r.controlId}`,o=t.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");t.set(n,{oldGuid:o?.oldGuid??r.oldGuid,newGuid:r.newGuid})}let i=new Map;for(let{oldGuid:r,newGuid:n}of t.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 Ps(e,t){let i=[],r=new Map([...t].map(([c,l])=>[String(c),l])),n=1,o=0,a=0;return{source:e.replace(/\d+/g,(c,l)=>{if(!r.has(c))return c;for(;o<l;o++)e[o]===`
111
- `&&(n++,a=o+1);let u=r.get(c),f=l+c.length,h=e.indexOf(`
112
- `,f);return i.push({start:l,end:f,oldGuid:Number(c),newGuid:u,line:n,before:e.slice(a,h<0?e.length:h).trim()}),String(u)}),edits:i,issues:[]}}var Qu={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(vt.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function ef(e,t=1){let i=e?.vars||{},r=[],n=Number(t)>0?Number(t):1,o=["Level","PlayerSelf","AvatarSelf"];if(n>1)for(let s=1;s<=n;s+=1)o.push(`Player${s}`,`Avatar${s}`);let a=new Set;for(let s of o){if(a.has(s)||!i[s])continue;a.add(s);let c=i[s]||{};for(let l of Object.keys(c))r.push(V({entityType:s,entityLabel:Qu[s]||s,name:l,type:c[l]?.type||"",value:c[l]?.value??null}))}return r}var xt="qxqy-simulator-save",tf="qxqy-simulator-scripts",ae="server-control-template",j="client-control-template",Xn={[ae]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[j]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function It(e){return e===j?"client":"server"}function Wt(e){if(!(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e.trim()))||!Me(e))throw new Error("\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F 1\u20132147483647 \u8303\u56F4\u5185\u7684\u6574\u6570");return Number(e)}function qn(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)||![ae,j].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(t.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:Wt(i.oldGuid),newGuid:Wt(i.newGuid),...i.batchId?{batchId:i.batchId}:{},...i.scriptSignature?{scriptSignature:i.scriptSignature}:{}}})}function rf(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 wr(e){let t=String(e?.controlAsset||""),i=rf(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===j||t==="client"?j:t===ae||t==="server"?ae:""}}function nf(e){let t=[],i=(r,n="")=>{if(r&&(r.path||r.source)){let o=wr(r);t.push(n?{...o,controlAsset:n}:o)}};if(Array.isArray(e?.assets?.scripts)){for(let r of e.assets.scripts)r&&(r.path||r.source)&&t.push(wr(r));return t}if(i(e?.assets?.server?.script,ae),i(e?.assets?.client?.script,j),e&&e.format!==xt){i(e?.script);for(let r of e?.scripts||[])i(r)}return t}function Wn(e){return rt(e===j?zt():pt())}var of="\u672A\u7ED1\u5B9A",Xt="\u672A\u547D\u540D\u5B58\u6863",af="\u672A\u547D\u540D\u754C\u9762";function sf(e){let t=e;for(let i=0;i<8;i++){if(Ai(Rs(t,"simulator","studio"))&&Ai(Rs(t,"lua")))return t;let r=Ju(t);if(r===t)break;t=r}return e}function lf(e){return e?{name:qt(e),path:e,bound:!0}:{name:of,path:"",bound:!1}}function cf(e,t=process.cwd()){if(Zu(e)&&Ai(e))return e;let i=t||process.cwd(),r=sf(i),n=Ms(r,e);if(Ai(n))return n;let o=Ms(i,e);if(Ai(o))return o;throw new Error("script file not found: "+e)}function _i(e,t={}){e?.format===xt&&cn(e.version);let i=[],r=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",n=e?.format===xt&&e.assets,o=qn(e?.controlGuidChanges),a=oi(e?.scriptSync),s=n?null:rt(e,{warnings:i}),c={server:n&&e.assets.server?rt(e.assets.server,{warnings:i}):Wn(ae),client:n&&e.assets.client?rt(e.assets.client,{warnings:i}):Wn(j)};s&&(c[It(s.meta.assetType)]=s);let l=n&&e.activeAssetType===j?j:s?.meta.assetType||ae,u=n&&e.meta?.name?String(e.meta.name):"",f=()=>u||Xt;!e?.meta?.name&&c.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(c.server.meta.name=af);let h=[],p=new Set;function m(){p.clear(),Dt(c.server.root,p),Dt(c.client.root,p,{skipServerContainer:!0});for(let g of h)Me(g.guid)&&p.add(Number(g.guid))}function y(g=0){m();let v=Me(g)&&!p.has(Number(g))?Number(g):Ze(p);return p.add(v),v}function x(g){let v=wr(g),I=y(v.guid);return{...v,guid:I,id:String(I)}}We(nf(e));let k=xi(e?.serverLogic),w=null,N="",M=1,Y=1;function U(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 H=()=>c[It(l)];function $(g){if(!g)return null;for(let[v,I]of[["server",c.server],["client",c.client]]){let R=pe(I.root,g);if(R&&R.kind!=="server-container")return{key:v,node:R}}return null}function b(g){if(!g.controlId)return null;let v=g.controlAsset===j?"client":g.controlAsset===ae?"server":null;if(v){let I=pe(c[v].root,g.controlId);return I&&I.kind!=="server-container"?{key:v,node:I}:null}return $(g.controlId)}function A(){for(let g of h)g.controlId&&!b(g)&&(g.controlId="",g.controlAsset="")}function S(g){if(!Me(g))return null;for(let[v,I]of[[ae,c.server],[j,c.client]]){let R="";if(Q(I.root,O=>{!R&&(O.scriptMappingIds||[]).includes(Number(g))&&(R=O.id)}),R)return{controlId:R,controlAsset:v}}return null}function C(g,v,I){let R=c[It(g.controlAsset)],O=R&&pe(R.root,g.controlId);O&&(O.scriptMappingIds=(O.scriptMappingIds||[]).map(D=>Number(D)===Number(v)?Number(I):D))}A();function F(){return h.map(g=>{let v=b(g),I=v?v.key==="client"?j:ae:"";return V({id:g.id,guid:g.guid||0,path:g.path||"",source:g.source||"",controlId:g.controlId||"",controlAsset:g.controlAsset||I,controlName:v?.node.name||"",assetType:I,assetLabel:v?Xn[I]:"",mounted:!!v})})}function E(){let g=[],v=(I,R)=>{Q(I.root,O=>{O.kind!=="server-container"&&g.push(V({id:O.id,name:O.name,kind:O.kind,assetType:R,assetLabel:Xn[R]}))})};return v(c.server,ae),v(c.client,j),g}function _(g){let v=[];return Q(g.root,I=>{I.kind!=="server-container"&&v.push(JSON.stringify({kind:I.kind,guid:I.guid,name:I.name,text:I.text??null,imageId:I.imageId??null,imageSource:I.imageSource??null,imageType:I.imageType??null,fontSize:I.fontSize??null,fontColor:I.fontColor??null,bgColor:I.bgColor??null,imageColor:I.imageColor??null,fillType:I.fillType??null,fillAmount:I.fillAmount??null,syncAllDevices:I.syncAllDevices!==!1,transformByPlatform:I.transformByPlatform||null}))}),v.join("/")}let G=_(zt()),B=_(pt());function ie(g){let v=_(g);return g.meta?.assetType===j?v===G:v===B}function L(g,v){return String(g||"").replace(/[\\/:*?"<>|]/g,"-").trim()||v}function te(g){let v=L(f(),Xt),I=g.meta?.assetType===j?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${v} \xB7 ${I}`}function Te(){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 oa(c.server,c.client,{scripts:h,fileName:`${L(f(),Xt)} \xB7 \u6574\u5408\u5305.gia`})}function _t(){let g=v=>({type:v.meta.assetType,name:v.meta.name,sourceFile:v.meta.sourceFile||""});return{format:xt,name:f(),activeAssetType:l,assets:{server:g(c.server),client:g(c.client),scripts:F()}}}function Zt(){return V({format:xt,version:4,meta:{name:f()},activeAssetType:l,serverLogic:k,controlGuidChanges:o,scriptSync:a,assets:{server:c.server,client:c.client,scripts:h.map(g=>V({id:g.id,guid:g.guid||0,path:g.path||"",source:g.source||"",controlId:g.controlId||"",controlAsset:g.controlAsset||""}))}})}function re(){let g=H(),v=Sa(g);if(v.workspace=lf(r),v.save=_t(),v.scripts=F(),v.mountTargets=E(),v.serverLogic=k,v.migrationWarnings=[...i],v.controlGuidChanges=V(o),l===j){let I=$t(g,!0);v.clientGuidAutofill={count:I.length,templateCount:I.filter(({parent:R})=>R?.kind==="server-container").length,selectedOffset:I.findIndex(({node:R})=>R.id===v.selectedId)}}return v.scriptSync=V(a),To(v),v}function ze(g){let v=H();if(g.expectedRevision!==void 0&&Number(g.expectedRevision)!==v.version)throw new Error(`revision conflict: expected ${g.expectedRevision}, current ${v.version}`);return v}function lt(g,v,I=""){let R=String(v||"");if(R){let O=I===j?j:I===ae?ae:"";if(!b({controlId:R,controlAsset:O}))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=O}else g.controlAsset="";g.controlId=R}function Fi(g){let v=ze(g);if(g.op==="addScript"){let I=x({path:String(g.path||""),source:String(g.source||""),controlId:"",controlAsset:""});g.controlId!==void 0&&g.controlId!==""&&lt(I,g.controlId,g.controlAsset),h.push(I)}else if(g.op==="updateScript"){let I=h.find(R=>R.id===g.id);if(!I)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${g.id}`);g.controlId!==void 0&&lt(I,g.controlId,g.controlAsset),g.path!==void 0&&(I.path=String(g.path)),g.source!==void 0&&(I.source=String(g.source))}else if(g.op==="removeScript"){let I=h.length;if(h=h.filter(R=>R.id!==g.id),h.length===I)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${g.id}`)}return v.version+=1,re()}function Di(g){let v=ze(g),I=pe(v.root,g.id??v.selectedId);if(!I||I.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 R=Wt(g.guid);if(Wt(I.guid),g.autoFillClientGuids!==void 0&&typeof g.autoFillClientGuids!="boolean")throw new Error("autoFillClientGuids \u5FC5\u987B\u662F\u5E03\u5C14\u503C");let O=g.autoFillClientGuids===!0;if(O&&l!==j)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 D=O?$t(v,!0).map(({node:z})=>z):[I],q=R-D.indexOf(I),K=D.map((z,se)=>({node:z,oldGuid:Wt(z.guid),newGuid:Wt(q+se)})),Ee=K.filter(({oldGuid:z,newGuid:se})=>z!==se);if(!Ee.length)return re();let de=new Map(K.map(({oldGuid:z,newGuid:se})=>[z,se]));if(de.size!==K.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 ct=new Set(D),ge=[];for(let z of Object.values(c))Q(z.root,se=>{z===c.client&&se.kind==="server-container"||ge.push({node:se,project:z})});let He=new Map([...ge.filter(z=>!ct.has(z.node)).map(({node:z})=>[Number(z.guid),z.name]),...h.map(z=>[Number(z.guid),z.path||"Lua \u811A\u672C"])]);for(let{newGuid:z}of Ee)if(He.has(z))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${z} \u5DF2\u88AB\u300C${He.get(z)}\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 ne=[],ce=(z,se,Tt)=>{let Re=z?.[se];(typeof Re=="number"||typeof Re=="string"&&/^\d+$/.test(Re.trim()))&&de.has(Number(Re))&&de.get(Number(Re))!==Number(Re)&&ne.push({owner:z,key:se,project:Tt.project,oldGuid:Number(Re),newGuid:de.get(Number(Re))})};for(let z of ge)ce(z.node,"referencedPrefabId",z),ce(z.node,"itemPrefabId",z),ce(z.node.giaRaw,"templateRefSlot",z);let Pt=new Map;for(let{node:z}of ge)Pt.set(Number(z.guid),(Pt.get(Number(z.guid))||0)+1);for(let{oldGuid:z}of ne)if(Pt.get(z)!==1)throw new Error(`\u65E7\u7D22\u5F15 ${z} \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 ye=O?Ts():"",Gr=As(h);for(let{node:z,oldGuid:se,newGuid:Tt}of Ee)z.guid=Tt,o.push({id:Ts(),controlAsset:l,controlId:z.id,controlName:z.name,oldGuid:se,newGuid:Tt,scriptSignature:Gr,...ye?{batchId:ye}:{}});let ni=new Set([v]);for(let{owner:z,key:se,project:Tt,newGuid:Re}of ne)z[se]=typeof z[se]=="string"?String(Re):Re,ni.add(Tt);for(let z of ni)z.version+=1;return re()}function oe(g){let v=ze(g);if(!Array.isArray(g.changeIds)||!g.changeIds.length||g.changeIds.some(R=>typeof R!="string"||!o.some(O=>O.id===R)))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 I=new Set(g.changeIds);return o=o.filter(R=>!I.has(R.id)),v.version+=1,re()}function $e(g){if(!g||typeof g!="object")throw new Error("patch requires op");if(g.op==="setScriptSync"){let v=ze(g);return a=oi(g.config),v.version+=1,re()}if(g.op==="setControlGuid")return Di(g);if(g.op==="acknowledgeControlGuidChanges")return oe(g);if(g.op==="setServerLogic"){let v=ze(g);return k=xi(g.logic),v.version+=1,re()}if(g.op==="addScript"||g.op==="updateScript"||g.op==="removeScript")return Fi(g);if(g.op==="selectAsset")return l=g.assetType===j?j:ae,re();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,re()}if(g.op==="newAsset"){let v=ze(g);l=g.assetType===j?j:ae;let I=Wn(l);return I.version=v.version+1,c[It(l)]=I,o=o.filter(R=>R.controlAsset!==l),A(),re()}return dn(H(),g),A(),re()}function Ye(g){return h.filter(v=>{let I=b(v);return!!(I&&I.key==="client"==(g===j))})}function Qt(g="json",v=""){let I=ei(g,v);if(o.length&&!["save","archive"].includes(String(g).toLowerCase())){let R=o.map(O=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${Xn[O.controlAsset]} / ${O.controlName} (${O.controlId})\uFF1A${O.oldGuid} \u2192 ${O.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 ${O.id}\uFF1B\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\u3002`);I.warnings=[...new Set([...I.warnings||[],...R])]}return I}function ei(g="json",v=""){let I=String(g).toLowerCase();if(I==="save"||I==="archive"){let D=Buffer.from(JSON.stringify(Zt(),null,2),"utf8");return V({filename:`${f().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:D.toString("base64"),warnings:[]})}if(I==="save-gia"||I==="archive-gia"){let D=[],q=[],K=(de,ct="")=>{let ge=Qt(de,ct);D.push(V({filename:ge.filename,mimeType:ge.mimeType,encoding:ge.encoding,data:ge.data,warnings:ge.warnings||[]})),q.push(...ge.warnings||[])},Ee=(de,ct)=>{let ge=c[It(de)],He=de===l,ne=h.some(ce=>ce.controlAsset===de&&ce.controlId);if(!He&&ie(ge)&&!ne){q.push(ct);return}K("gia",de)};if(Ee(ae,"\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"),Ee(j,"\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(de=>de.path||de.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 V({format:"qxqy-gia-package",files:D,warnings:[...new Set(q)]})}if(I==="gia-combined"||I==="combined-gia"||I==="combined"){let D=Te();return V({filename:`${L(f(),Xt)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:D.buffer.toString("base64"),warnings:[...new Set(D.warnings||[])]})}if(I==="scripts"){let D=V({format:tf,version:1,scripts:h.map(K=>V({id:K.id,guid:K.guid||0,path:K.path||"",source:K.source||"",controlId:K.controlId||"",controlAsset:K.controlAsset||""}))}),q=Buffer.from(JSON.stringify(D,null,2),"utf8");return V({filename:`${L(f(),Xt)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:q.toString("base64"),warnings:[]})}if(I==="scripts-gia"||I==="scriptsgia"){let D=la(h);return V({filename:`${L(f(),Xt)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:D.buffer.toString("base64"),warnings:D.warnings})}if(I==="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 q=qt(D.path||"")||`qxqy-script-${D.id}`;return V({filename:/\.lua$/i.test(q)?q:`${q}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(D.source||"","utf8").toString("base64"),warnings:[]})}let R=v?c[It(v)]:H(),O=te(R);if(I==="json"){let D=V({...R,scripts:Ye(R.meta.assetType),controlGuidChanges:o.filter(K=>K.controlAsset===R.meta.assetType)}),q=Buffer.from(JSON.stringify(D,null,2),"utf8");return V({filename:`${O}.json`,mimeType:"application/json",encoding:"base64",data:q.toString("base64"),warnings:[]})}if(I==="gia"){let D=na(R,R.meta.assetType===j?{scripts:Ye(j)}:{}),q=R.meta.assetType===j?[]:Ye(ae);return q.length&&D.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${q.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`),V({filename:`${O}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:D.buffer.toString("base64"),warnings:D.warnings})}throw new Error(`unsupported export format: ${g}`)}function We(g){for(let v of g){let I=wr(v);if(!I.path&&!I.source)continue;let R=I.controlId?null:S(I.guid),O=x(R?{...I,...R}:I);R&&O.guid!==I.guid&&C(R,I.guid,O.guid),O.controlId&&!b(O)&&(O.controlId="",O.controlAsset=""),h.push(O)}}function ti(g,v,I=""){let R=String(g||"").toLowerCase();if(typeof v!="string"||!v)throw new Error("import data is required");let O=Buffer.from(v,"base64"),D,q=[],K={};if(R==="json"){try{D=JSON.parse(O.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(D?.project&&(D=D.project),D?.format===xt&&D?.assets){cn(D.version);let ne=_i(D);q.push(...ne.get().migrationWarnings);let ce=ne.archiveData();return c.server=ce.assets.server,c.client=ce.assets.client,i=[...q],l=D.activeAssetType===j?j:ae,u=String(D.meta?.name||qt(I).replace(/\.json$/i,"")||u),k=ce.serverLogic,h=ce.assets.scripts,o=ce.controlGuidChanges,a=ce.scriptSync,p.clear(),V({snapshot:re(),warnings:q,metadata:{format:xt}})}}else{if(R==="lua")return h.push(x({path:qt(I||"imported.lua"),source:O.toString("utf8"),controlId:""})),V({snapshot:re(),warnings:q,metadata:{assetType:"lua-script"}});if(R==="gia"){if(ca(O)){let ye=fa(O);return We(ye.scripts),V({snapshot:re(),warnings:ye.warnings,metadata:ye.metadata})}let ne=da(O);D=ne.project,q=ne.warnings,K=ne.metadata,ne.clientProject&&(c.client=rt(ne.clientProject),o=o.filter(ye=>ye.controlAsset!==j),q.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 ce=new Map,Pt=(ye,Gr)=>{ye&&Q(ye.root,ni=>{for(let z of ni.scriptMappingIds||[]){let se=ce.get(Number(z));if(se){q.push(`\u811A\u672C GUID ${z} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${se.controlAsset===ae?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}ce.set(Number(z),{controlId:ni.id,controlAsset:Gr})}})};Pt(ne.project,ae),Pt(ne.clientProject,j),We((ne.scripts||[]).map(ye=>ce.has(Number(ye.guid))?{...ye,...ce.get(Number(ye.guid))}:ye))}else throw new Error(`unsupported import format: ${g}`)}let Ee=rt(D,{warnings:q}),de=qn(D?.controlGuidChanges);if(de.some(ne=>ne.controlAsset!==Ee.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 ct=qn([...o.filter(ne=>ne.controlAsset!==Ee.meta.assetType),...de]);i=[...q];let ge=It(Ee.meta.assetType);c[ge]=Ee,o=ct,l=Ee.meta.assetType;let He=c[ge];return I&&(He.meta.name=qt(I).replace(/\.(json|gia)$/i,"")||He.meta.name,He.meta.sourceFile=qt(I),He.meta.sourceFormat=R),We(D?.scripts||[]),D?.script&&(D.script.path||D.script.source)&&We([D.script]),V({snapshot:re(),warnings:q,metadata:K})}function Tl(g,v){return dn(H(),{op:"pick",x:g,y:v}),re()}function Rl(g){let v=typeof g=="string"&&g?g:"";!v||v===r||(r=v)}function Ml(g){let v=g.source||"";if(!v.trim()&&g.path.trim())try{v=Ku(cf(g.path,r),"utf8")}catch(I){throw new Error(`\u811A\u672C ${g.path} \u8BFB\u53D6\u5931\u8D25: ${I?.message||I}`)}return v}function ii(g={}){let v=U(g.canvasId);v&&(N=v),g.playerCount!==void 0&&g.playerCount!==null&&g.playerCount!==""&&(M=bt(g.playerCount),Y>M&&(Y=1)),g.viewPlayerIndex!==void 0&&g.viewPlayerIndex!==null&&g.viewPlayerIndex!==""&&(Y=qe(g.viewPlayerIndex,M)),w&&Hn(w);let I=h.map(O=>{try{return{id:O.id,guid:O.guid||0,path:O.path||O.id,source:Ml(O),controlId:O.controlId||"",controlAsset:O.controlAsset||""}}catch(D){return{id:O.id,guid:O.guid||0,path:O.path||O.id,source:`error([==[ ${String(D.message).replace(/]=+]/g,"] =]")} ])`,controlId:O.controlId||"",controlAsset:O.controlAsset||""}}}),R=O=>I.filter(D=>{let q={controlId:D.controlId,controlAsset:D.controlAsset},K=D.controlId?b(q):null;return!!(K&&K.key===O)});return w=ps(c.server,{templatesProject:c.client,scripts:I,sceneScripts:R("server"),templateScripts:R("client"),serverConfig:{logic:k},canvasId:N,playerCount:M,viewPlayerIndex:Y,language:g.language||""}),fe(g)}function Nl(g,v={}){let I=U(g);if(!I)throw new Error("playSetCanvas requires canvasId");return ii({...v,canvasId:I})}function fe(g={}){if(!w)return V({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let v=Dn(w,g);return v.running=!0,v.logs=Ln(v.logs),v.serverLogs=Ln(v.server?.logs||[]),v.serverVars=ef(v.server,v.playerCount||1),v}function Ol(g,v={}){return w||ii(),vr(w,g),v.observe===!1?V({running:!0,time:w.runtime.clock.time,frame:w.runtime.clock.frame,paused:!!w.debugPaused,levelTimePaused:!!w.runtime.clock.paused,playerCount:w.playerCount||1,viewPlayerIndex:w.viewPlayerIndex||1}):fe(v)}function Fl(g=0){ii();let v=Math.max(0,Number(g)||0);for(let I=0;I<v;I++)vr(w,1/30);return fe()}function Dl(){return w&&Hn(w),w=null,N="",M=1,Y=1,V({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function zl(g,v={}){let I=ri();return Y=On(I,g),v.observe===!1?null:fe(v)}function $l(g,v={}){if(!w)throw new Error("play session has not started");return zn(w,g),v.observe===!1?null:fe(v)}function Gl(g,v={}){if(!w)throw new Error("play session has not started");return $n(w,g),v.observe===!1?null:fe(v)}function Vl(g,v,I,R={}){if(!w)throw new Error("play session has not started");return Ei(w,g,v,I,R),R.observe===!1?null:fe(R)}function Yl(g={}){return w&&Sr(w).pause(),g.observe===!1?null:fe(g)}function Hl(g={}){return w&&Sr(w).resume(),g.observe===!1?null:fe(g)}function ri(){if(!w)throw new Error("play session has not started");return w}function Bl(g,v){let I=ri();if(!g&&!v){let R=fe();return V({vars:R.serverVars||[]})}return V({entityType:String(g||""),name:String(v||""),value:xs(I,g,v)})}function Ul(g,v,I){let R=ri();return Vn(R,g,v,I),fe()}function jl(g,v=[],I="PlayerSelf"){let R=ri();return Yn(R,g,v,I),fe()}function Ll(){let g=fe();return V({events:g.history||[],case:Qa(g.history||[],{playerCount:g.playerCount||1})})}function Xl(g={}){let v=fe(),I=Ci({name:g.name||"",dt:g.dt,playerCount:g.playerCount||v.playerCount||1,events:g.events||v.history||[],asserts:g.asserts||[]});return V(I)}function ql(g,v={}){let I=Ci(g);ii({...v,playerCount:v.playerCount||I.playerCount||1});let R=ri();R.recording=!1;try{return Es(Sr(R),g)}finally{R.recording=!0}}function Wl(){if(!w)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let g=w.runtime.clock;return{running:!0,paused:!!w.debugPaused,levelTimePaused:!!g.paused,time:g.time,frame:g.frame,playerCount:w.playerCount||1,viewPlayerIndex:w.viewPlayerIndex||1}}let xo={get:re,patch:$e,setWorkspace:Rl,exportData:Qt,importData:ti,pick:Tl,playStart:ii,playSetCanvas:Nl,playSetView:zl,playGet:fe,playStatus:Wl,playStep:Ol,playRun:Fl,playStop:Dl,playKey:$l,playClick:Gl,playPointer:Vl,playPause:Yl,playResume:Hl,playServerGet:Bl,playServerSet:Ul,playServerSend:jl,playHistory:Ll,playSaveCase:Xl,playRunCase:ql,archiveData:Zt};return Object.defineProperty(xo,"_project",{enumerable:!1,get:H}),xo}import{createRequire as df}from"node:module";function Kn(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 a=t*n;return{x:e.fillHorizontalType==="Right"?t/2-a:-t/2,y:-i/2,width:a,height:i}}let o=i*n;return{x:-t/2,y:e.fillVerticalType==="Top"?-i/2:i/2-o,width:t,height:o}}function Ns(e,t,i){let r=t?.m_Rect,n=t?.m_RD?.textureRectOffset,o=t?.m_RD?.textureRect,a=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(o?.width)),f=Math.round(Number(o?.height)),h=t?.m_RD?.settingsRaw?.packingRotation;if(![a,s,u,f].every(y=>Number.isInteger(y)&&y>0&&y<=8192)||a*s>16777216||!Number.isFinite(c)||!Number.isFinite(l)||c<0||l<0||c+u>a||l+f>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(a,s),m=p.getContext("2d");if(e.width===a&&e.height===s)m.drawImage(e,0,0);else{if(e.width!==u||e.height!==f)throw new Error("Sprite PNG does not match its trim metadata");m.drawImage(e,c,s-l-f)}return p}function Os(e,t,i){let r=Number(t??4294967295)>>>0;if((r&16777215)===16777215)return e;let n=i(e.width,e.height),o=n.getContext("2d");o.drawImage(e,0,0);let a=o.getImageData(0,0,n.width,n.height),s=r>>>16&255,c=r>>>8&255,l=r&255;for(let u=0;u<a.data.length;u+=4)a.data[u]=Math.round(a.data[u]*s/255),a.data[u+1]=Math.round(a.data[u+1]*c/255),a.data[u+2]=Math.round(a.data[u+2]*l/255);return o.putImageData(a,0,0),n}function uf(e){return!!e?.border&&Object.values(e.border).some(t=>Number.isFinite(t)&&t>0)}function Ds(e,t){let i=typeof t=="object"?t?.Name:t;return uf(e)&&i!=="Basic"?"Stretch":"Basic"}function zs(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,o]of[["left","X"],["bottom","Y"],["right","Z"],["top","W"]]){let a=Number(e.m_Border?.[o]??0);if(!Number.isFinite(a))throw new Error("Invalid image border");r[n]=Math.max(0,a)}return{width:t,height:i,border:r}}function ff(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 o=Math.min(1,r/(t+i||1));return{source:[0,t,e-i,e],target:[0,t*o,r-i*o,r]}}var Fs=new WeakMap;function $s(e,t,i,r,n){let o=Math.max(0,i),a=Math.max(0,r),s=Math.min(1,4096/Math.max(1,o),4096/Math.max(1,a)),c=Math.max(1,Math.round(o*s)),l=Math.max(1,Math.round(a*s)),u=n(c,l),f=u.getContext("2d");if(!o||!a)return u;let h=Fs.get(e);if(!h){let w=n(e.width,e.height),N=w.getContext("2d");N.drawImage(e,0,0),h=N.getImageData(0,0,e.width,e.height),Fs.set(e,h)}let p=f.createImageData(c,l),m=h.data,y=(w,N,M,Y,U,H)=>{let{source:$,target:b}=ff(N,M,Y,U);return Array.from({length:H},(A,S)=>{let C=(S+.5)*U/H,F=C<b[1]?0:C<b[2]?1:2,E=b[F+1]>b[F]?(C-b[F])/(b[F+1]-b[F]):0,_=Math.max(0,Math.min(w-1,($[F]+E*($[F+1]-$[F]))*w/N-.5)),G=Math.floor(_);return[G,Math.min(w-1,G+1),_-G]})},x=y(e.width,t.width,t.border.left,t.border.right,o,c),k=y(e.height,t.height,t.border.top,t.border.bottom,a,l);for(let w=0;w<l;w++)for(let N=0;N<c;N++){let[M,Y,U]=x[N],[H,$,b]=k[w],A=(H*e.width+M)*4,S=(H*e.width+Y)*4,C=($*e.width+M)*4,F=($*e.width+Y)*4,E=m[A+3]*(1-U)*(1-b),_=m[S+3]*U*(1-b),G=m[C+3]*(1-U)*b,B=m[F+3]*U*b,ie=E+_+G+B,L=(w*c+N)*4;p.data[L+3]=Math.round(ie);for(let te=0;te<3;te++)p.data[L+te]=ie?Math.round((m[A+te]*E+m[S+te]*_+m[C+te]*G+m[F+te]*B)/ie):0}return f.putImageData(p,0,0),u}var hf=df(import.meta.url),pf=[0,-.5,.5,.5,-.5,.5],mf=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],gf=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],Jn=Buffer.from([137,80,78,71,13,10,26,10]),yf=new Set(["image","textbox","textwindow","button","grid"]),Ir={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"},xr=null;function Pi(){if(xr)return xr;try{xr=hf("@napi-rs/canvas")}catch(e){let t=e?.message||String(e);throw new Error(`Host screenshot renderer requires @napi-rs/canvas (${t})`)}return xr}function X(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function kr(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 Ct(e,t=1){return`rgba(${e.r},${e.g},${e.b},${Math.max(0,Math.min(1,e.a*t))})`}function Vs(e,t,i=1){let r=Math.max(1,Math.round(X(e,1))),n=Math.max(1,Math.round(X(t,1))),o=Math.max(1,Math.min(2,X(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 Ys(e){let t=Buffer.from(e.toBuffer("image/png"));if(t.length<Jn.length||!t.subarray(0,Jn.length).equals(Jn))throw new Error("Host screenshot renderer did not produce a PNG");return t}function bf(e){return e==="triangle"?pf:e==="fourstar"?mf:gf}function vf(e,t,i,r,n){let o=bf(t);e.beginPath();for(let a=0;a<o.length;a+=2){let s=o[a]*i,c=o[a+1]*r;a===0?e.moveTo(s,c):e.lineTo(s,c)}e.closePath(),e.fillStyle=Ct(n),e.fill()}function Hs(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,o=t?.pressed?.98:1;if(n&&n.every(Number.isFinite)){let[a,s,c,l,u,f]=n;e.transform(a*o,-s*o,-c*o,l*o,u,i-f);return}e.translate(X(t.left)+X(t.width)/2,i-X(t.bottom)-X(t.height)/2),e.rotate(-X(t.rotationZ)*Math.PI/180),e.scale(o,o)}function Sf(e,t,i,r,n,o){if(typeof e.roundRect=="function"){e.roundRect(t,i,r,n,o);return}let a=Math.max(0,Math.min(o,r/2,n/2));e.moveTo(t+a,i),e.arcTo(t+r,i,t+r,i+n,a),e.arcTo(t+r,i+n,t,i+n,a),e.arcTo(t,i+n,t,i,a),e.arcTo(t,i,t+r,i,a),e.closePath()}function Bs(e,t,i,r){let n=kr(t.bgColor,16777215);e.fillStyle=Ct(n),e.fillRect(-i/2,-r/2,i,r);let o=Math.max(8,X(t.fontSize,12)),a=kr(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=`${o}px "Microsoft YaHei UI","Microsoft YaHei",sans-serif`,e.fillStyle=Ct(a),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=kr(t.outlineColor,4278190080);e.strokeStyle=Ct(y),e.lineWidth=Math.max(2,o*.12),e.lineJoin="round"}let u=l?-i/2+2+s*l.textWidth:s===0?-i/2+2:s===1?i/2-2:0,f=c===0?-r/2:c===1?r/2:0,h=l?.lines||String(t.text||"").split(`
113
- `),p=l?.lineHeight||o*1.2,m=l?-r/2-l.offset+(l.max>0?0:c*(r-l.contentLength)):c===.5?f-(h.length-1)*p/2:c===1?f-(h.length-1)*p:f;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 wf(e,t,i,r){let n=jt(t.scroll,i,r);if(n)for(let[o,a]of[[n.track,"#263447"],[n.thumb,"#90aecb"]])e.fillStyle=a,e.fillRect(o.x,o.y,o.width,o.height)}function Us(e,t,i,r){e.beginPath(),Sf(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 js(e,t,i,r,n){let o=kr(t.imageColor,4294967295),a=Yi(t.imageId,t.imageSource),s=n?.images?.get(a);if(t.primitive==="sprite"&&s){let c=n.imageMetadata?.get(a),l=Ds(c,t.imageType),u=`${a}:${Number(t.imageColor??4294967295)&16777215}:${l}:${l==="Stretch"?`${i}:${r}`:""}`,f=n.tints.get(u);if(!f){let h=l==="Stretch"?$s(s,c,i,r,Pi().createCanvas):s;f=Os(h,t.imageColor,Pi().createCanvas),n.tints.set(u,f)}e.globalAlpha*=o.a,e.drawImage(f,-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=Ct(o),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=Ct(o),e.lineWidth=7,e.stroke();return}if(t.primitive==="triangle"||t.primitive==="fourstar"||t.primitive==="fivestar"){vf(e,t.primitive,i,r,o);return}e.fillStyle=Ct(o),e.fillRect(-i/2,-r/2,i,r)}function If(e,t,i,r){let n=Math.max(0,X(t.sourceWidth,X(t.width))),o=Math.max(0,X(t.sourceHeight,X(t.height)));e.save();for(let a of t.clipPolygons||[])e.beginPath(),a.forEach((s,c)=>c?e.lineTo(s.x,i-s.y):e.moveTo(s.x,i-s.y)),e.closePath(),e.clip();if(Hs(e,t,i),t.kind==="textbox"||t.kind==="textwindow")Bs(e,t,n,o);else if(t.kind==="button")Us(e,t,n,o);else if(t.kind!=="grid"){let a=Kn(t,n,o);a&&(e.beginPath(),e.rect(a.x,a.y,a.width,a.height),e.clip()),js(e,t,n,o,r)}wf(e,t,n,o),e.restore()}function Ls(e,t,i,{checker:r=!1}={}){if(r){e.fillStyle="#28313e",e.fillRect(0,0,t,i);let o=16;for(let a=0;a<i;a+=o)for(let s=0;s<t;s+=o)(s/o+a/o)%2===0&&(e.fillStyle="rgba(255,255,255,0.04)",e.fillRect(s,a,o,o));e.strokeStyle="#40b8cf",e.lineWidth=1,e.strokeRect(.5,.5,t-1,i-1);return}let 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 xf(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 Gs(e){let t=e?.matrix;return!t||typeof t!="object"?{a:1,b:0,c:0,d:1,tx:0,ty:0}:{a:X(t.a,1),b:X(t.b),c:X(t.c),d:X(t.d,1),tx:X(t.tx),ty:X(t.ty)}}function Cf(e){let t=Array.isArray(e?.nodes)?e.nodes:[],i=new Map;for(let a of t){if(!a||a.id===void 0||a.id===null)continue;let s=a.parent==null?"":String(a.parent),c=i.get(s);c?c.push(a):i.set(s,[a])}for(let a of i.values())a.sort((s,c)=>X(s.z)-X(c.z));let r=[];function n(a,s,c,l){if(!yf.has(a.kind))return;let u=Math.abs(X(a.sourceWidth)*Math.hypot(s.a,s.b)),f=Math.abs(X(a.sourceHeight)*Math.hypot(s.c,s.d));r.push({...a,left:s.tx-u/2,bottom:s.ty-f/2,width:u,height:f,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 o(a,s,c=null,l=[],u=[]){let f=i.get(a)||[];for(let h=f.length-1;h>=0;h-=1){let p=f[h],m=s?xf(s,Gs(p)):Gs(p),y=l;if(p.clipToParent&&s&&c){let w=c.sourceWidth/2,N=c.sourceHeight/2;y=[...l,[[-w,-N],[w,-N],[w,N],[-w,N]].map(([M,Y])=>({x:s.a*M+s.c*Y+s.tx,y:s.b*M+s.d*Y+s.ty}))]}let x=pr(p,m),k=x?[...u,x]:u;p.kind!=="grid"&&n(p,m,y,k),o(String(p.id),m,p,y,k),p.kind==="grid"&&n(p,m,y,k)}}return o("",null),r}function Xs(e,t,i,r={}){return Af(Cf(e),t,i,r)}function kf(e,t,i){if(!(e.width>0&&e.height>0)||!Ue(e.matrix))return null;let r=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([c,l])=>{let u=Ie(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)))),o=Math.max(t.y,Math.floor(Math.min(...r.map(c=>c.y)))),a=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 a>n&&s>o?{x:n,y:o,width:a-n,height:s-o}:null}function Ef(e,t,i,r){let n=t.canvas.width,o=t.canvas.height,a=t.ctx.getImageData(0,0,n,o).data,s=t.x-e.x,c=t.y-e.y,l=e.ctx.getImageData(s,c,n,o),u=l.data,f=Ue(i.matrix);for(let h=0;h<o;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(!a[y+3])continue;let x=(t.x+m+.5)/r.pixelRatio,k=f.a*x+f.c*p+f.tx,w=f.b*x+f.d*p+f.ty,N=os(k,w,i),M=Math.round(a[y+3]*N)/255;if(!M)continue;let Y=u[y+3]/255,U=M+Y*(1-M);for(let H=0;H<3;H++)u[y+H]=Math.round((a[y+H]*M+u[y+H]*Y*(1-M))/U);u[y+3]=Math.round(U*255)}}e.ctx.save(),e.ctx.setTransform(1,0,0,1,0,0),e.ctx.putImageData(l,s,c),e.ctx.restore()}function qs(e,t,i,r){for(let n of t){if(n.item){If(e.ctx,n.item,i.height,r);continue}let o=kf(n.mask,e,i);if(!o)continue;let a=Pi().createCanvas(o.width,o.height),s=a.getContext("2d");s.setTransform(i.pixelRatio,0,0,i.pixelRatio,-o.x,-o.y);let c={canvas:a,ctx:s,x:o.x,y:o.y};qs(c,n.children,i,r),Ef(e,c,n.mask,i)}}function Af(e,t,i,r={}){let{createCanvas:n}=Pi(),o=Vs(t,i,r.scale),a=n(o.pixelWidth,o.pixelHeight),s=a.getContext("2d");s.scale(o.pixelRatio,o.pixelRatio),r.background!=="transparent"&&Ls(s,o.width,o.height);let c=Array.isArray(e)?e:[],l={images:r.images,imageMetadata:r.imageMetadata,tints:new Map};return qs({canvas:a,ctx:s,x:0,y:0},as(c),o,l),{data:Ys(a),width:o.width,height:o.height,pixelWidth:o.pixelWidth,pixelHeight:o.pixelHeight}}function _f(e){if(e.renderMatrix){let t=Ie(e.renderMatrix,e.centerX,e.centerY);return{kind:e.kind,width:e.width,height:e.height,matrix:{...e.renderMatrix,tx:t.x,ty:t.y}}}return{kind:e.kind,left:X(e.renderLeft,e.left),bottom:X(e.renderBottom,e.bottom),width:Math.max(0,X(e.renderWidth,e.width)),height:Math.max(0,X(e.renderHeight,e.height)),rotationZ:X(e.renderRotationZ,e.rotationZ)}}function Cr(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),o=Math.min(i-4,Math.max(24,n.width+8)),a=16;e.fillStyle="rgba(17,25,37,0.66)",e.fillRect(-o/2,-a/2,o,a),e.fillStyle="#e7edf5",e.fillText(r,0,0)}function Pf(e,t,i,r,n){let o=_f(t);if(o.width<=0||o.height<=0)return;e.save(),Hs(e,o,i);let a=-o.width/2,s=-o.height/2;if(t.kind==="image"){e.save();let c=Math.max(0,X(t.width,o.width)),l=Math.max(0,X(t.height,o.height));e.scale(c?o.width/c:1,l?o.height/l:1);let u=t.enableFill?Kn(t,c,l):null;u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),js(e,t,c,l,n),e.restore()}else if(t.kind==="textbox"||t.kind==="textwindow")Bs(e,t,o.width,o.height);else if(t.kind==="button")Us(e,t,o.width,o.height),Cr(e,t.name||Ir.button,o.width);else if(t.kind==="cursor")e.setLineDash([6,4]),e.strokeStyle="rgba(74,142,181,0.7)",e.fillStyle="rgba(74,142,181,0.1)",e.fillRect(a,s,o.width,o.height),e.strokeRect(a,s,o.width,o.height),Cr(e,t.name||Ir.cursor,o.width);else if(t.kind==="grid"){e.strokeStyle="rgba(106,146,189,0.55)",e.strokeRect(a,s,o.width,o.height),e.beginPath();for(let c=20;c<o.width;c+=20)e.moveTo(a+c,s),e.lineTo(a+c,s+o.height);for(let c=20;c<o.height;c+=20)e.moveTo(a,s+c),e.lineTo(a+o.width,s+c);e.stroke(),Cr(e,t.name||Ir.grid,o.width)}else t.kind!=="container"&&t.kind!=="server-container"?(e.setLineDash(t.kind==="reference"||t.kind==="animation"||t.kind==="fullscreen"?[4,4]:[]),e.strokeStyle="rgba(203,218,237,0.55)",e.strokeRect(a,s,o.width,o.height),Cr(e,t.name||Ir[t.kind]||t.kind,o.width)):(e.strokeStyle="rgba(78,165,230,0.42)",e.strokeRect(a,s,o.width,o.height));t.id===r&&t.kind!=="container"&&t.kind!=="server-container"&&(e.setLineDash([]),e.strokeStyle="#61b9ff",e.lineWidth=2,e.strokeRect(a,s,o.width,o.height)),e.restore()}function Ws(e,t={}){let{createCanvas:i}=Pi(),r=e?.canvas||{},n=Vs(r.width||1600,r.height||900,t.scale),o=i(n.pixelWidth,n.pixelHeight),a=o.getContext("2d");a.scale(n.pixelRatio,n.pixelRatio),Ls(a,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||Pf(a,u,n.height,c,l);return{data:Ys(o),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 Tf,existsSync as Er,openSync as Rf,opendirSync as Mf,readSync as Nf,realpathSync as Kt,statSync as Js}from"node:fs";import{basename as Of,dirname as Ks,isAbsolute as to,join as Ff,relative as Zs,resolve as Mi}from"node:path";var Df="qxqy-simulator-save",Qs=new Set(["node_modules",".git","dist",".dsh","coverage"]),Ti=50,el=4096,Zn=1e4,Qn=1e3,eo=8;function io(e=""){let t=Mi(String(e||process.cwd()));if(!Er(t))throw new Error(`workspace does not exist: ${t}`);if(!Js(t).isDirectory())throw new Error(`workspace is not a directory: ${t}`);return Kt(t)}function Ri(e,t,i=!1){let r=Zs(e,t);if(!i&&!r||r.startsWith("..")||to(r))throw new Error("path must stay inside the configured workspace");return r}function at(e,t){let i=String(t||"").trim();if(!i||to(i))throw new Error("path must be a non-empty workspace-relative path");let r=Kt(Mi(e)),n=Mi(r,i);if(Ri(r,n),!Er(n))throw new Error(`file does not exist: ${i}`);let o=Kt(n);return Ri(r,o),o}function Pe(e,t){let i=String(t||"").trim();if(!i||to(i))throw new Error("path must be a non-empty workspace-relative path");let r=Kt(Mi(e)),n=Mi(r,i);Ri(r,n);let o=Ks(n);for(;!Er(o);){let a=Ks(o);if(a===o)throw new Error("unable to resolve output directory");o=a}return Ri(r,Kt(o),!0),Er(n)&&Ri(r,Kt(n)),n}function zf(e,t=el){let i=Buffer.alloc(t),r=Rf(e,"r");try{let n=Nf(r,i,0,t,0);return i.subarray(0,n).toString("utf8")}finally{Tf(r)}}function tl(e,t,i,r,n){if(r>eo){n.depthLimitedDirectories+=1;return}if(n.scannedDirectories>=Qn){n.directoryLimitReached=!0;return}let o;try{n.scannedDirectories+=1,o=Mf(e)}catch{n.unreadableEntries+=1;return}try{let a;for(;a=o.readSync();){if(n.scannedEntries>=Zn){n.entryLimitReached=!0;return}if(n.scannedEntries+=1,a.name.startsWith(".")||a.isDirectory()&&Qs.has(a.name)){n.skippedEntries+=1,a.isDirectory()&&(n.skippedDirectories+=1);continue}let s=Ff(e,a.name);if(a.isDirectory()){if(tl(s,t,i,r+1,n),n.entryLimitReached||n.directoryLimitReached)return;continue}if(!(!a.isFile()||!/\.json$/i.test(a.name))){n.scannedJsonFiles+=1;try{let c=Js(s),l=zf(s);if(!l.includes(Df))continue;let u=l.match(/"name"\s*:\s*("(?:\\.|[^"\\])*")/)?.[1],f=Of(a.name,".json");if(u)try{f=JSON.parse(u)||f}catch{}i.push({path:Zs(t,s).replaceAll("\\","/"),name:f,bytes:c.size,mtime:c.mtimeMs})}catch{n.unreadableEntries+=1}}}}catch{n.unreadableEntries+=1}finally{try{o.closeSync()}catch{n.unreadableEntries+=1}}}function Ar(e){let t=io(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:Ti,entries:Zn,directories:Qn,depth:eo,headBytes:el},policy:{excludedDirectories:[...Qs],hiddenEntries:!1,symlinks:!1,validatesJson:!1}};return tl(t,t,i,0,r),i.sort((n,o)=>o.mtime-n.mtime||n.path.localeCompare(o.path)),r.matchedArchives=i.length,i.length>Ti&&r.warnings.push(`\u53D1\u73B0 ${i.length} \u4E2A\u5B58\u6863\uFF0C\u4EC5\u663E\u793A\u4FEE\u6539\u65F6\u95F4\u6700\u65B0\u7684 ${Ti} \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${Zn} \u9879 / ${Qn} \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 ${eo} \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>Ti||r.entryLimitReached||r.directoryLimitReached||r.depthLimitedDirectories>0,{bound:!0,workspace:t,archives:i.slice(0,Ti),discovery:r}}import{readFileSync as $f}from"node:fs";import{homedir as Gf}from"node:os";import{join as Vf}from"node:path";var Yf={"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 Hf(e){let i=[...String(e||"").matchAll(/Request to set language:([A-Za-z0-9_-]+)/g)].at(-1)?.[1]?.toLowerCase();return Yf[i]||null}function Bf(){return Vf(Gf(),"AppData","LocalLow","miHoYo","\u539F\u795E","output_log.txt")}function il(e=Bf()){try{return Hf($f(e,"utf8"))}catch{return null}}import{existsSync as oo,lstatSync as Uf,mkdirSync as rl,readFileSync as _r,readdirSync as jf,realpathSync as nl,renameSync as Lf,rmSync as Xf,statSync as Rr,writeFileSync as ol}from"node:fs";import{createHash as qf,randomUUID as al}from"node:crypto";import{homedir as Wf}from"node:os";import{basename as Kf,dirname as Pr,isAbsolute as Jf,join as Tr,relative as Zf}from"node:path";var De=e=>qf("sha256").update(e).digest("hex"),ro=e=>oo(e)?De(_r(e)):null,no=(e,t)=>{let i=Zf(e,t);return!Jf(i)&&i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)};function sl(e,t){let i=Pe(e,t),r=i;for(;r!==e;){try{if(Uf(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=Pr(r)}if(oo(i)&&!Rr(i).isFile())throw new Error("\u5B9E\u673A\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6");return i}function ll(e=Tr(Wf(),"AppData","LocalLow","miHoYo","\u539F\u795E","BeyondLocal")){let t=r=>{try{return jf(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=Tr(e,r,"Beyond_Local_Save_Level");for(let o of t(n)){let a=Tr(n,o,"external_lua_file","default_import_file");oo(a)&&Rr(a).isDirectory()&&i.push({uid:r,editorId:o,path:a})}}return{candidates:i}}var Mr=class{constructor(t){this.controller=t,this.plan=null,this.lastResult=null}preview(){let t=this.controller,i=t.studio.archiveData(),r=oi(i.scriptSync);if(!r)throw new Error("\u8BF7\u5148\u914D\u7F6E\u5B9E\u673A\u811A\u672C\u76EE\u5F55");let n=nl(t.activeWorkspacePath()),o=nl(r.clientImportRoot);if(!Rr(o).isDirectory())throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u4E0D\u5B58\u5728");let a=r.workspaceDir?at(n,r.workspaceDir):n;if(!Rr(a).isDirectory())throw new Error("\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E0D\u5B58\u5728");if(no(a,o)||no(o,a))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 f={id:u.id,path:u.path,sourceKind:u.source.trim()?"\u5B58\u6863\u6E90\u7801":"\u5DE5\u4F5C\u533A\u6587\u4EF6"};try{let h=zi(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=sl(o,m),x=y.toLowerCase();s.set(x,(s.get(x)||0)+1);let k=null,w="";try{k=_r(at(n,h),"utf8")}catch(Y){w=Y.message}if(!u.source.trim()&&k===null)throw new Error(w);let N=u.source.trim()?u.source:k,M=ro(y);return{...f,target:y,targetRelative:m,source:N,diskSource:k,diskError:w,sourceMismatch:!!(u.source.trim()&&k!==null&&u.source!==k),beforeSource:M===null?"":_r(y,"utf8"),beforeHash:M,sourceHash:De(N),status:M===null?"\u65B0\u589E":M===De(N)?"\u672A\u53D8\u5316":"\u8986\u76D6"}}catch(h){return{...f,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=De(JSON.stringify({archive:i,workspace:n,root:o,rows:c}));return this.plan={id:al(),fingerprint:l,root:o,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 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 a=i.map(u=>{let f=n.rows.find(h=>h.id===u);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 s=`.qxqy-script-sync-backups/${n.id}`,c=Pe(n.workspace,s);if(no(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 a){let f="";try{let h=sl(n.root,u.targetRelative);if(ro(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=Pe(n.workspace,`${s}/${u.targetRelative}`);rl(Pr(p),{recursive:!0}),ol(p,_r(h),{flag:"wx"})}if(rl(Pr(h),{recursive:!0}),f=Tr(Pr(h),`.${Kf(h)}.${al()}.tmp`),ol(f,u.source,{flag:"wx"}),ro(h)!==u.beforeHash)throw new Error("\u76EE\u6807\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");Lf(f,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{f&&Xf(f,{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 Qf,randomUUID as ed}from"node:crypto";import{mkdir as td,open as id,readFile as rd,rename as nd,rm as ao,stat as od,writeFile as ad}from"node:fs/promises";import{homedir as so}from"node:os";import{join as Jt,resolve as sd}from"node:path";import{setTimeout as ld}from"node:timers/promises";var lo=e=>Qf("sha256").update(e).digest("hex");function Nr(e){return Jt(process.platform==="win32"?process.env.LOCALAPPDATA||Jt(so(),"AppData","Local"):process.platform==="darwin"?Jt(so(),"Library","Caches"):process.env.XDG_CACHE_HOME||Jt(so(),".cache"),"beyond-simulator",e)}var st=class{constructor({cacheDir:t,source:i,version:r,extension:n,accepts:o,fetch:a=globalThis.fetch,timeout:s=12e3}){this.directory=Jt(sd(t),r,lo(i).slice(0,12)),Object.assign(this,{source:i,extension:n,accepts:o,fetcher:a,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 o=await this.fetcher(new URL(t,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 a=[],s=0;for await(let c of o.body){if(s+=c.length,s>i)throw new Error("Asset response too large");a.push(c)}return Buffer.concat(a)}async cached(t){try{let i=await rd(t);return{data:i,...await this.decode(i),etag:`"${lo(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=Jt(this.directory,`${t}.${this.extension}`),n=!i&&await this.cached(r);if(n)return n;await td(this.directory,{recursive:!0});let o=`${r}.lock`,a=Date.now()+3e4,s;for(;!s;)try{s=await id(o,"wx")}catch(l){if(l.code!=="EEXIST")throw l;let u=!i&&await this.cached(r);if(u)return u;try{Date.now()-(await od(o)).mtimeMs>6e4&&await ao(o,{force:!0})}catch(f){if(f.code!=="ENOENT")throw f}if(Date.now()>a)throw new Error("Timed out waiting for asset cache writer");await ld(80)}let c=`${r}.${ed()}.tmp`;try{let l=!i&&await this.cached(r);if(l)return l;let u=new AbortController,f=setTimeout(()=>u.abort(),this.timeout),h;try{h=await this.produce(t,u.signal,i)}finally{clearTimeout(f),u.abort()}let p=await this.decode(h);return await ad(c,h,{flag:"wx"}),await nd(c,r),{data:h,...p,etag:`"${lo(h)}"`}}finally{try{await ao(c,{force:!0})}finally{await s.close(),await ao(o,{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(o=>(this.failures.delete(t),o),o=>{throw i||this.failures.set(t,{until:Date.now()+6e4,error:o}),o}).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 cd}from"node:crypto";import{createCanvas as ud,loadImage as cl}from"@napi-rs/canvas";var Or=class extends st{constructor({cacheDir:t,source:i=Gi,fetch:r=globalThis.fetch}){super({cacheDir:t,source:i,fetch:r,version:"border-v1",extension:"json",accepts:n=>Ke(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=zs(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 uo=20*1024*1024,fd=Buffer.from("89504e470d0a1a0a","hex");function ul(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 dd(){return process.env.QXQY_IMAGE_CACHE_DIR||Nr("images")}function co(e){if(e.length<24||e.length>uo||!e.subarray(0,8).equals(fd))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 fo=class e extends st{constructor({cacheDir:t=dd(),fetch:i=globalThis.fetch,source:r,imageSource:n="StaticReference"}={}){let o=Ce(n);if(!["StaticReference","Prefab"].includes(o))throw new Error(`Unsupported image source: ${o}`);super({cacheDir:t,fetch:i,source:r||(o==="Prefab"?Eo:Gi),version:o==="Prefab"?ai:Vr,extension:"png",accepts:a=>Ke(a,o)}),this.imageSource=o,this.cacheDir=t,this.prefabStore=null,this.metadataStore=null}forSource(t){let i=Ce(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 co(t),{image:await cl(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 Or({cacheDir:this.cacheDir,source:this.source,fetch:(...o)=>this.fetcher(...o)}),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`,uo,i,r);co(c);let l=$i(t);if(c.readUInt32BE(16)!==l||c.readUInt32BE(20)!==l)throw new Error("Prefab PNG does not match catalog dimensions");return c}let[n,o]=await Promise.all([this.download(`sprite/${t}.png`,uo,i,r),this.metadata(t,{refresh:r})]);co(n);let a=await cl(n),s=o.raw?Ns(a,o.raw,ud):a;return o.raw?Buffer.from(s.toBuffer("image/png")):n}async prepare(t,i){let r=new Map,n=new Map,o=[],a=[...new Map((t||[]).filter(u=>u.kind==="image"&&u.visible!==!1&&Ke(u.imageId,u.imageSource)).map(u=>[Yi(u.imageId,u.imageSource),{imageId:u.imageId,imageSource:Ce(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,a.length)},async()=>{for(;l<a.length&&!c.aborted;){let[u,f]=a[l++];try{let h=await ul(this.get(f.imageId,f),c);r.set(u,h.image);let p=await ul(this.metadata(f.imageId,f),c);n.set(u,p.meta)}catch(h){o.push({...f,error:h.message})}}}));for(let[,u]of a.slice(l))o.push({...u,error:"Image preparation timed out"});return i?.throwIfAborted(),{images:r,imageMetadata:n,warnings:o}}},hd;function ho(){return hd||=new fo}async function fl(e,t,i=ho()){let r=new URL(e.url,"http://localhost");if(r.pathname!==Vi.slice(0,-1)&&!r.pathname.startsWith(Vi))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(`^${Vi}(${Vr}|${ai})/([0-9]+)\\.(png|json)$`));if(!n)throw Object.assign(new Error("Unknown image resource"),{status:404});let o={imageSource:n[1]===ai?"Prefab":"StaticReference"};if(n[3]==="json"){let{meta:c}=await i.metadata(Number(n[2]),o),l=JSON.stringify(c),u=`"${cd("sha256").update(l).digest("hex")}"`,f={"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,f),t.end()):(t.writeHead(200,f),t.end(e.method==="HEAD"?void 0:l)),!0}let a=await i.get(Number(n[2]),o),s={"content-type":"image/png","cache-control":"private, max-age=43200",etag:a.etag,"x-content-type-options":"nosniff"};e.headers["if-none-match"]===a.etag?(t.writeHead(304,s),t.end()):(t.writeHead(200,{...s,"content-length":a.data.length}),t.end(e.method==="HEAD"?void 0:a.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}import{existsSync as pd,mkdirSync as dl,readFileSync as md,renameSync as gd,rmSync as yd,writeFileSync as po}from"node:fs";import{randomUUID as ml}from"node:crypto";import{dirname as hl,join as bd}from"node:path";function pl(e,t){let i=`${e}.${ml()}.tmp`;try{po(i,t,{flag:"wx"}),gd(i,e)}finally{yd(i,{force:!0})}}var Fr=class{constructor(t){this.controller=t,this.plan=null}inspect(){let t=this.controller.studio.archiveData(),i=t.controlGuidChanges||[],r=t.assets.scripts,n=[],o=new Map;i.length||n.push("\u6CA1\u6709\u5F85\u540C\u6B65\u7684\u7D22\u5F15\u53D8\u66F4");try{o=_s(i)}catch(u){n.push(u.message)}let a=this.controller.activeWorkspacePath();a||n.push("\u8BF7\u5148\u7ED1\u5B9A\u5DE5\u4F5C\u533A\uFF0C\u4EE5\u4FDD\u5B58\u540C\u6B65\u524D\u7684\u5907\u4EFD");let s=new Map,c=r.map(u=>{let f={id:u.id,path:u.path,source:u.source,file:"",fileBefore:null,edits:[],issues:[]};if(u.path)try{if(!a)throw new Error("\u5DE5\u4F5C\u533A\u5C1A\u672A\u7ED1\u5B9A\uFF0C\u65E0\u6CD5\u6838\u5BF9\u9879\u76EE\u811A\u672C\u6587\u4EF6");let p=Pe(a,u.path);if(pd(p)){f.file=at(a,u.path);let m=md(f.file);if(f.fileBefore=m.toString("utf8"),!m.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(u.source.trim()&&f.fileBefore!==u.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(u.source.trim()||(f.source=f.fileBefore),s.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");s.set(f.file,u.id)}}catch(p){f.issues.push({line:0,reason:p.message})}!f.source.trim()&&u.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=Ps(f.source,o);return f.source=h.source,f.edits=h.edits,f.issues.push(...h.issues),f}),l=De(JSON.stringify({archive:t,files:c.map(u=>[u.file,u.fileBefore])}));return{archive:t,rows:c,issues:n,fingerprint:l}}preview(){let t=this.inspect();return t.id=ml(),this.plan=t,{id:t.id,canApply:!t.issues.length&&t.rows.every(i=>!i.issues.length),issues:t.issues,changes:t.archive.controlGuidChanges.length,replacements:t.rows.reduce((i,r)=>i+r.edits.length,0),rows:t.rows.map(({id:i,path:r,file:n,edits:o,issues:a})=>({id:i,path:r,file:n,edits:o,issues:a}))}}apply({planId:t,expectedRevision:i}){let r=this.plan;if(!r||r.id!==t)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=_i(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 a=Buffer.from(JSON.stringify(o.archiveData())).toString("base64"),s=r.rows.filter(f=>f.edits.length&&f.file),c=this.controller.activeWorkspacePath(),l=s.length?Pe(c,`.qxqy-guid-sync-backups/${r.id}`):"",u=[];try{for(let h of s){let p=bd(l,`${h.id}.lua`);dl(hl(p),{recursive:!0}),po(p,h.fileBefore,{flag:"wx"})}let f=Pe(c,`.qxqy-guid-sync-backups/${r.id}/before.save.json`);dl(hl(f),{recursive:!0}),po(f,JSON.stringify(r.archive),{flag:"wx"});for(let h of s)pl(h.file,h.source),u.push(h);this.controller.studio.importData("json",a)}catch(f){let h=[];for(let p of u.reverse())try{pl(p.file,p.fileBefore)}catch{h.push(p.file)}throw this.plan=null,new Error(`${f.message}${h.length?`\uFF1B\u56DE\u6EDA\u5931\u8D25\uFF0C\u8BF7\u4ECE ${l} \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:s.length,backupRoot:`.qxqy-guid-sync-backups/${r.id}`}}}};var kd=Math.max(1e3,Number(process.env.QXQY_PLAY_TIMEOUT_MS)||8e3),Ed=8e3;function gl(){let e=new Error("operation aborted");return e.name="AbortError",e}function go(e){if(e!=="manual"&&e!=="realtime")throw new Error("clockMode must be manual or realtime");return e}var Dr=class{constructor(t="",{imageAssets:i=ho(),clockMode:r="realtime"}={}){this.workspacePath=t?io(t):"",this.studio=_i(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 Mr(this),this.controlGuidSync=new Fr(this),this.imageAssets=i,this.defaultClockMode=go(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 ll();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=at(this.activeWorkspacePath(),this.archivePath);if(De(mo(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=Pe(this.activeWorkspacePath(),t);if(Sd(r)){let n=this.archivePath?Pe(this.activeWorkspacePath(),this.archivePath):"";if(r!==n||De(mo(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 t?.op==="previewControlGuidSync"?{...this.get(),controlGuidSyncPreview:this.controlGuidSync.preview()}:t?.op==="syncControlGuidReferences"?this.controlGuidSync.apply(t):{...this.studio.patch(t),storage:{path:this.archivePath}}}listArchives(){return Ar(this.workspacePath)}loadArchive(t){let i=this.activeWorkspacePath();if(!i)throw new Error("workspace is not bound");let r=at(i,t),n=mo(r),o=this.studio.importData("json",n.toString("base64"),xd(r));return this.archivePath=String(t).trim().replaceAll("\\","/"),this.archiveStamp=De(n),this.savedArchive=JSON.stringify(this.studio.archiveData()),o}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=Pe(r,i);wd(Cd(n),{recursive:!0});let o=Buffer.from(JSON.stringify(this.studio.archiveData(),null,2)+`
114
- `,"utf8");return Id(n,o),this.archivePath=i.replaceAll("\\","/"),this.archiveStamp=De(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 t=this.studio.get().workspace;return t?.bound&&t.path?String(t.path):this.workspacePath}createWorker(){let t=new vd(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=kd){let o=this.worker||this.createWorker(),a=this.sequence++;return new Promise((s,c)=>{let l=!1,u=(p,m)=>{l||(l=!0,clearTimeout(h),r?.removeEventListener("abort",f),p(m))},f=()=>{this.pending.delete(a),u(c,gl()),this.terminateWorker(gl())},h=setTimeout(()=>{this.pending.delete(a);let p=new Error(`play worker timed out after ${n}ms`);u(c,p),this.terminateWorker(p)},n);if(this.pending.set(a,{resolve:p=>u(s,p),reject:p=>u(c,p)}),r?.aborted)return f();r?.addEventListener("abort",f,{once:!0}),o.postMessage({id:a,action:t,args:i})})}async play(t,i={},r){if((t==="start"||t==="device")&&!i.language){let n=il();n&&(i={...i,language:n})}if(t==="start"){let n=go(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 o=go(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(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,Ed),r=await this.imageAssets.prepare(i.scene?.nodes,t),n=Xs(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=Ws(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 kt}from"@deepseek-ai/dsh-tools";import{existsSync as vl,realpathSync as yl}from"node:fs";import{isAbsolute as yo,relative as bl,resolve as zr}from"node:path";function Sl(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=yl(zr(e)),n=yo(i)?zr(i):zr(r,i),o=bl(r,n);if(!o||o.startsWith("..")||yo(o))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");if(!vl(n))throw new Error(`\u5B58\u6863\u4E0D\u5B58\u5728: ${i}`);let a=yl(n),s=bl(r,a);if(!s||s.startsWith("..")||yo(s))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");return a}function wl(e){if(!e)return{bound:!1,archives:[]};let t=zr(e);return vl(t)?Ar(t):{bound:!1,archives:[]}}var Il=32*1024*1024;function Ad(e){if(e.length<8||e.length>Il)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],o=r>>3&3,a=n>>2&3,s=n>>4;if(e[t]!==255||(r&224)!==224||(r&6)!==2||o===1||a===3||s===0||s===15)throw new Error("Invalid MP3 frame");let c=(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])[s],l=[44100,48e3,32e3][a]/(o===3?1:o===2?2:4),u=Math.floor((o===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 bo=class extends st{constructor({cacheDir:t=process.env.QXQY_AUDIO_CACHE_DIR||Nr("audio"),fetch:i=globalThis.fetch,source:r=rs}={}){super({cacheDir:t,fetch:i,source:r,version:Pn,extension:"mp3",accepts:n=>dr(n)!==null,timeout:2e4})}decode(t){return Ad(t),{}}produce(t,i,r){return this.download(`audio/${t}.mp3`,Il,i,r)}},_d;function Pd(){return _d||=new bo}async function xl(e,t,i=Pd()){let r=new URL(e.url,"http://localhost");if(r.pathname!==fr.slice(0,-1)&&!r.pathname.startsWith(fr))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(`^${fr}${Pn}/([0-9]+)\\.mp3$`));if(!n)throw Object.assign(new Error("Unknown audio resource"),{status:404});let o=await i.get(Number(n[1])),a=o.data.length,s={"content-type":"audio/mpeg","cache-control":"private, max-age=43200",etag:o.etag,"accept-ranges":"bytes","x-content-type-options":"nosniff"};if(e.headers["if-none-match"]===o.etag)return t.writeHead(304,s),t.end(),!0;let c=e.headers.range,l=0,u=a-1,f=200;if(c&&(!e.headers["if-range"]||e.headers["if-range"]===o.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:a});if(h[1]?(l=Number(h[1]),u=h[2]?Math.min(a-1,Number(h[2])):u):l=Math.max(0,a-Number(h[2])),!Number.isSafeInteger(l)||!Number.isSafeInteger(u)||l>=a||u<l)throw Object.assign(new Error("Unsatisfiable byte range"),{status:416,size:a});f=206,s["content-range"]=`bytes ${l}-${u}/${a}`}t.writeHead(f,{...s,"content-length":u-l+1}),t.end(e.method==="HEAD"?void 0:o.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 Kg="qxqy-simulator",Jg=["tools","webServer"],Cl="/qxqy-simulator/api",kl="/qxqy-simulator/play",Md="/qxqy-simulator/play-renderer.js",Nd=8*1024*1024,Od=32,El=6e4,wo=class extends Dr{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(Ni(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(),wl(this.studio.get().workspace?.path||"")}loadArchive(t){this.touch();let i=this.studio.get().workspace?.path||"",r=Sl(i,t);return{...super.loadArchive(Rd(Td(i),r)),snapshot:this.get()}}async play(t,i={},r){return this.touch(),super.play(t,Ni(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 Ni(e){if(e!=null){if(typeof e!="string")return e;try{let t=JSON.parse(e);return t&&typeof t=="object"?t:void 0}catch{return}}}function Et(e){return Pl(e?.agent?.id)}function Io(e){let t=e?.cwd;return typeof t=="string"&&t?t:""}function At(e){return Io(e?.agent?.session?.header)}async function Fd(e,t={}){let i=t.sessions?.get?.(e),r=Io(i?.header);if(r)return r;let n=t.sessionPersistence?.inspect;if(typeof n!="function")return"";try{let o=await n.call(t.sessionPersistence,e);return Io(o?.meta)}catch{return""}}function Dd(){let e=new Map,t=!1;function i(){if(e.size<Od)return;let r=[...e.entries()].sort((n,o)=>n[1].touchedAt-o[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 o=Pl(r),a=e.get(o);return a?n&&a.studio.setWorkspace(n):(i(),a=new wo(n),e.set(o,a)),a.touch(),a},async dispose(){t=!0;let r=[...e.values()];e.clear(),await Promise.all(r.map(n=>n.dispose()))}}}function $r(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 zd(){if(!vo){let t=[new URL("./play.html",import.meta.url),new URL("../lib/play.html",import.meta.url)].find(i=>Al(i));if(!t)throw new Error("standalone play page is missing");vo=_l(t,"utf8")}return vo}var vo=null;function $d(){if(!So){let t=[new URL("../dist/play-renderer.js",import.meta.url),new URL("./play-renderer.js",import.meta.url)].find(i=>Al(i));if(!t)throw new Error("standalone play renderer bundle is missing; run npm run build");So=_l(t,"utf8")}return So}var So=null;function Oi(e,t){return e.effect(()=>e.webServer.register(t),`qxqy-simulator: ${t.kind} ${t.path}`)}function Gd(e){Oi(e,{kind:"prefix",path:kl,handler(t,i){let r=new URL(t.url,"http://localhost").pathname.replace(/\/$/,"");if(t.method!=="GET"||r!==kl){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(zd())}})}function Vd(e){Oi(e,{kind:"exact",path:Md,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($d())}catch(r){i.statusCode=500,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(r?.message||String(r))}}})}function Yd(e){return new Promise((t,i)=>{let r=0,n=[];e.on("data",o=>{if(r+=o.length,r>Nd){i(new Error("request body is too large")),e.destroy();return}n.push(o)}),e.on("end",()=>{try{let o=Buffer.concat(n).toString("utf8");t(o?JSON.parse(o):{})}catch{i(new Error("invalid JSON body"))}}),e.on("error",i)})}function Hd(e,t){e.tools.register(kt({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(Et(r),At(r)).scriptSyncAction(i.action,Ni(i.args)||{})}})),e.tools.register(kt({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(Et(r),At(r)).get()}})),e.tools.register(kt({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?`
115
- \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:El+1e3,isConcurrencySafe:()=>!1,async execute(i,r){let o=await t.get(Et(r),At(r)).requestScreenshot(r.signal),a=e.get?.("attachments");if(!a?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let s=await a.saveImage({data:o.data,mediaType:"image/png",name:`qxqy-play-${o.canvasId||"canvas"}-f${o.frame}.png`}),{data:c,...l}=o;return{...l,image:{attachmentId:s.attachmentId,mediaType:s.mediaType,bytes:s.bytes,width:s.width,height:s.height,...s.name===void 0?{}:{name:s.name}}}}})),e.tools.register(kt({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 a=[{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?`
116
- \u7D20\u6750\u52A0\u8F7D\u5931\u8D25\uFF08\u753B\u9762\u4E2D\u4E3A\u5360\u4F4D\u6846\uFF09\uFF1A${JSON.stringify(r.assetWarnings)}`:"")}];return r.image&&a.push({type:"image",attachment:r.image}),a}},timeoutMs:El+1e3,isConcurrencySafe:()=>!1,async execute(i,r){let o=await t.get(Et(r),At(r)).requestUiScreenshot(r.signal),a=e.get?.("attachments");if(!a?.saveImage)throw new Error("Harness attachment service is unavailable; cannot return screenshot to AI");let s=await a.saveImage({data:o.data,mediaType:"image/png",name:`qxqy-ui-${o.page||"editor"}.png`}),{data:c,...l}=o;return{...l,image:{attachmentId:s.attachmentId,mediaType:s.mediaType,bytes:s.bytes,width:s.width,height:s.height,...s.name===void 0?{}:{name:s.name}}}}})),e.tools.register(kt({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=Ni(i.op);if(!n)throw new Error("patch requires op");return t.get(Et(r),At(r)).patch(n)}})),e.tools.register(kt({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=Ni(i.args)||{};return t.get(Et(r),At(r)).play(i.action,n,r.signal)}})),e.tools.register(kt({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=t.get(Et(r),At(r));return i.path?n.loadArchive(i.path):n.listArchives()}}))}function Bd(e,t){Oi(e,{kind:"prefix",path:Cl,async handler(i,r){if(i.method!=="POST"){$r(r,405,{ok:!1,value:null,error:"POST required"});return}let o=new URL(i.url,"http://localhost").pathname.slice(Cl.length).replace(/^\/+/,"");if(o==="health"){$r(r,200,{ok:!0,value:{status:"ok"},error:null});return}let a=new AbortController;i.once("aborted",()=>a.abort());try{let s=await Yd(i),c=await Fd(s.sessionId,{sessions:e.get?.("sessions"),sessionPersistence:e.get?.("sessionPersistence")}),l=t.get(s.sessionId,c),u;if(o==="get")u=l.get();else if(o==="patch")u=l.patch(s.op);else if(o==="export")u=l.exportData(s.format,s.assetType);else if(o==="import")u=l.importData(s.format,s.data,s.filename);else if(o==="archives")u=l.listArchives();else if(o==="load-archive")u=l.loadArchive(s.path);else if(o==="save")u=l.saveForScriptSync(s.path,s.expectedRevision);else if(o==="script-sync")u=l.scriptSyncAction(s.action,s.args||{});else if(o==="script-sync-apply")u=l.scriptSync.apply(s);else if(o==="image-refresh")await l.imageAssets.refresh(s.imageId,{imageSource:s.imageSource}),u={imageId:s.imageId,imageSource:s.imageSource||"StaticReference",refreshed:!0};else if(o==="play")u=await l.play(s.action,s.args||{},a.signal);else throw new Error("unknown API action");$r(r,200,{ok:!0,value:u,error:null})}catch(s){$r(r,400,{ok:!1,value:null,error:s?.message||String(s)})}}})}function Zg(e){let t=Dd();e.effect(()=>()=>t.dispose(),"qxqy-simulator: dispose sessions"),Hd(e,t),Bd(e,t),Gd(e),Vd(e),Oi(e,{kind:"prefix",path:"/qxqy-assets",handler:(i,r)=>fl(i,r)}),Oi(e,{kind:"prefix",path:"/qxqy-audio",handler:(i,r)=>xl(i,r)})}export{wo as SimulatorController,Zg as apply,Io as headerWorkspace,Jg as inject,Ni as jsonParam,Fd as lookupSessionWorkspace,Kg as name,At as sessionWorkspace};
122
+ `)}`);return{buffer:r,warnings:[...new Set(e.warnings)]}}function Ma(t){return Ct.toObject(Ct.decode(Eo(t)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function od(t){try{let i=Ma(t).graph||[];return i.length>0&&i.every(r=>Number(r.which)===Gi)}catch{return!1}}function sd(t){let e=[...t.graph||[],...t.accessories||[]].filter(n=>Number(n.which)===Gi),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 ad(t){let e=Ma(t),i=sd(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 fy(t){let e=[],i;try{i=Ma(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)!==Gi&&e.push(`${s}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${n.which}`),Number(n.id?.class)!==id&&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}ct(n.id?.id)||e.push(`${s}: GraphUnit.id.id \u975E\u6CD5\uFF08\u5141\u8BB8 0x40000000\u20130x403FFFFF\uFF09`),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 Eo(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);if(e.length<Si+ka)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(e.readUInt32BE(4)!==1||e.readUInt32BE(8)!==Uf||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-Si-ka)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(e.readUInt32BE(Si+i)!==Hf)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return e.subarray(Si,Si+i)}function Ye(t,e){return t.ui?.content?.data?.find(i=>i.details?.[e])?.details?.[e]||null}function dy(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 hy(t){let e=Ye(t,"transform")?.multiPlatform,i={};for(let n of e?.platforms||[]){let o=ey[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 _o(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 jf(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=_o(u),f=Ye(u,"textConfig"),h=Ye(u,"imageSlot"),m=Ye(u,"image"),g=Ye(u,"buttonPreset"),v=Ye(u,"gridView"),w=Ye(u,"genericSlot"),S=Ye(u,"footerSlot"),x=Ye(u,"cursorConfig"),F=Ye(u,"keyHint"),I=Ye(u,"containerNodeSlot"),z=c==="reference"?dy(u):null,$=Ye(u,"effectSlot"),j=Ye(u,"fullscreenEffectSlot"),G=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:S?.field505===1,scriptMappingIds:(w?.field502||[]).map(_=>Number(_?.field1?.id)).filter(_=>Number.isSafeInteger(_)&&_>0),transformByPlatform:hy(u),syncAllDevices:Ye(u,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:w?.field501??0,footerField505:S?.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:x?.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:F?.field501??1,keyHintField502:F?.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:$??""}:{},...c==="fullscreen"?{fullscreenEffectSlot:j??""}:{}},...c==="container"?{isolateNavigation:I?.isolateNavigation===!0,disableKeyEventPassthrough:I?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:I?.disableCursorEventPassthrough===!0,showCursor:I?.showCursor===!0}:{},...c==="cursor"?{raycastTarget:x?.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:F?.field502??null,controllerKeyCode:F?.field501??null}:{},...c==="animation"?{animationId:$??""}:{},...c==="fullscreen"?{animationId:j??""}:{}});n.set(u.id?.id,G),(z?.raw.templateRefSlotBase64||z?.raw.templateRefOuterBase64)&&s.push(`${G.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(`${G.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(`${G.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(`${G.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${m.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),c==="button"&&o.set(G.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 ld(t){let e=Eo(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=S=>!!S.ui?.content&&[15,21,70].includes(Number(S.which)),o=(i.graph||[]).filter(n);if(!o.some(S=>S.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let s=o.find(S=>S.which===21)||null,a=o.filter(S=>Number(S.which)===70),l=(i.accessories||[]).filter(n),u=new Set((s?.relatedIds||[]).map(S=>S.id||0)),c=s?u.size?l.filter(S=>u.has(S.id?.id||0)):l:[],f=a.length?[...a,...l.filter(S=>!u.has(S.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(S=>!n(S)&&Number(S.which)!==Gi);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=sd(i);h.push(...g.warnings);let v=null,w=null;if(c.length){let S=jf(c,{reverseSiblings:!0,idOffset:0});h.push(...S.warnings);let x=S.rootCandidates.find(I=>I.kind==="container")||S.rootCandidates[0];if(!x)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let F=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(I=>I.field501===4&&I.field502===4)?.related?.value||[]});F.children=[x],S.rootCandidates.length>1&&h.push(`\u68C0\u6D4B\u5230 ${S.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${x.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:x.id,script:{controlId:x.id,path:"",source:""},root:F}}if(f.length){let S=jf(f,{reverseSiblings:!1,idOffset:1e3});if(h.push(...S.warnings),!S.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let x=we("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});x.children=S.rootCandidates,w={version:1,layoutSchemaVersion:Ze,meta:{name:S.rootCandidates.length===1?S.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:S.rootCandidates[0].id,script:{controlId:S.rootCandidates[0].id,path:"",source:""},root:x},Yt(w,{warnings:h});for(let F of S.rootCandidates)Ae(F,I=>I.children.reverse());v||(v=w)}return{project:v,clientProject:w&&v!==w?w: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 Fa(t){let e=Eo(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=_o(m),v=m.ui?.content?.info||[],w=v.find(F=>F.field501===2&&F.field502===6)?.index?.value,S=v.find(F=>F.field501===4&&F.field502===4),x=S?.related?.value||[];return ft(w)||o.push(`${m.name}: Info.index=${w??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),S||o.push(`${m.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:m.id?.id||0,name:m.name||"",kind:g,actualIndex:w,relatedPresent:!!S,relatedGuids:x}}),c=new Map;for(let m of u){if(!ft(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,w=_o(m),S=r.includes(m)&&m.which===70,x=`${m.name||"<unnamed>"}(${g||"<missing-guid>"})`;ct(g)?a.has(g)?o.push(`${x}: GUID \u4E0E ${a.get(g).name||"<unnamed>"} \u91CD\u590D`):a.set(g,m):o.push(`${x}: GraphUnit GUID \u975E\u6CD5\uFF08\u5141\u8BB8 0x40000000\u20130x403FFFFF\uFF09`),(m.id?.class!==1||m.id?.type!==8)&&o.push(`${x}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),v.guid!==g&&o.push(`${x}: content.guid=${v.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),S&&m.which!==70&&o.push(`${x}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!S&&m.which!==15&&o.push(`${x}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let F=v.info||[],I=F.find(E=>E.field501===1&&E.field502===5),z=F.find(E=>E.field501===2&&E.field502===6);I?.guid?.value!==g&&o.push(`${x}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),ft(z?.index?.value)||o.push(`${x}: Info.index=${z?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let $=F.find(E=>E.field501===4&&E.field502===4);S&&!$&&o.push(`${x}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!S&&$&&o.push(`${x}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let j=Xf[w],G=v.data||[],_=G.map(E=>`${E.field501}/${E.field502}`),T=j?.map(([E])=>E)||[];j?JSON.stringify(_)!==JSON.stringify(T)&&o.push(`${x}: Data \u69FD\u4F4D\u987A\u5E8F ${_.join(",")}\uFF0C\u5E94\u4E3A ${T.join(",")}`):o.push(`${x}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${w}`);for(let E=0;E<Math.min(G.length,j?.length||0);E+=1){let D=G[E],[V,H,Z]=j[E];if(s(D,H)||o.push(`${x}: Data ${V} \u7F3A\u5C11 ${H} \u5206\u652F`),!Z)continue;s(D.details,Z)||o.push(`${x}: Details ${V} \u7F3A\u5C11 ${Z} \u5206\u652F`);let ne=Wf[V];(D.details?.field501!==ne||D.details?.field502!==D.field502||D.details?.field503!==1)&&o.push(`${x}: Details ${V} \u6807\u8BB0\u5E94\u4E3A ${ne}/${D.field502}/1`);let ve=D.details?.nodeRef;(ve?.class!==1||ve?.type!==8||ve?.id!==g)&&o.push(`${x}: Details ${V} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let y=(m.ui.content.data||[]).find(E=>E.field501===4&&E.field502===86);y&&(s(y.field14,"field17")?f+=1:o.push(`${x}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),s(y.details?.field14,"field17")?f+=1:o.push(`${x}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let N=(m.ui.content.data||[]).find(E=>E.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];N.length!==4&&o.push(`${x}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${N.length}\uFF0C\u5E94\u4E3A 4`);let C=N.map(E=>E.platformType||0);JSON.stringify(C)!==JSON.stringify([0,1,2,3])&&o.push(`${x}: \u5E73\u53F0\u987A\u5E8F ${C.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let d=(m.ui.content.data||[]).find(E=>E.details?.transform)?.details?.transform;d?.multiPlatform?.field502!==rn[w]&&o.push(`${x}: \u53D8\u6362 preset=${d?.multiPlatform?.field502??"<missing>"}\uFF0C${w} \u5E94\u4E3A ${rn[w]}`);for(let E of N)s(E.transform,"field508")?h+=1:o.push(`${x}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);l.push({id:g,name:m.name||"",kind:w,template:S,parent:v.parent||0,children:[...v.children||[]],relatedIds:(m.relatedIds||[]).map(E=>E.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 w=a.get(v);w?(w.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 Da(t){let e=Eo(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)===Gi),s=(i.accessories||[]).filter(d=>d.ui?.content),a=[],l=(d,E)=>d!=null&&Object.prototype.hasOwnProperty.call(d,E);/^\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 E=Number(d.which);return E===Gi||E===70||E===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 E=d.id?.id||0,D=`${d.name||"<unnamed>"}(${E||"<missing-guid>"})`;ct(E)?h.has(E)?a.push(`${D}: GUID \u91CD\u590D`):h.set(E,d):a.push(`${D}: GraphUnit GUID \u975E\u6CD5\uFF08\u5141\u8BB8 0x40000000\u20130x403FFFFF\uFF09`),(d.id?.class!==1||d.id?.type!==8)&&a.push(`${D}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),d.ui?.content?.guid!==E&&a.push(`${D}: 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 w=g.info||[];w.find(d=>d.field501===1&&d.field502===5)?.guid?.value!==m&&a.push(`${v}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),w.find(d=>d.field501===2&&d.field502===6)?.index?.value!==1&&a.push(`${v}: Info.index \u5FC5\u987B\u4E3A 1`);let S=w.find(d=>d.field501===4&&d.field502===4);S||a.push(`${v}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let x=0,F=0,I=(d,E,D,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=D.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,D.length);Re+=1){let ut=ne[Re],[yt,de,R]=D[Re];if(l(ut,de)||a.push(`${Z}: Data ${yt} \u7F3A\u5C11 ${de} \u5206\u652F`),!R)continue;l(ut.details,R)||a.push(`${Z}: Details ${yt} \u7F3A\u5C11 ${R} \u5206\u652F`);let A=Wf[yt];(ut.details?.field501!==A||ut.details?.field502!==ut.field502||ut.details?.field503!==1)&&a.push(`${Z}: Details ${yt} \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 ${yt} 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||(x+=1):a.push(`${Z}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${ee} \u7A7A\u4E32`),l(ge?.details?.field14,ee)?V||(x+=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 gt=Se.map(Re=>Re.platformType||0);JSON.stringify(gt)!==JSON.stringify([0,1,2,3])&&a.push(`${Z}: \u5E73\u53F0\u987A\u5E8F ${gt.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let qt=V?rn["server-container"]:rn[E];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")?F+=1:a.push(`${Z}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return ve};I(c,"server-container",ty,!0);let z=(c.relatedIds||[]).map(d=>d.id||0),$=new Set(z),j=s.filter(d=>$.has(d.id?.id||0)),G=j.map(d=>d.id?.id||0);JSON.stringify(z)!==JSON.stringify(G)&&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,T=h.get(_);(!T||!j.includes(T))&&a.push(`${v}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),G[0]!==_&&a.push(`${v}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let y=[];for(let d of j){let E=d.id?.id||0,D=d.ui.content,V=`${d.name||"<unnamed>"}(${E})`,H=_o(d);d.which!==15&&a.push(`${V}: which \u5FC5\u987B\u4E3A UIControl(15)`);let Z=D.info||[];(Z.length!==1||Z[0]?.field501!==1||Z[0]?.field502!==5||Z[0]?.guid?.value!==E)&&a.push(`${V}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let ne=Xf[H];ne||a.push(`${V}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${H}`);let ve=ne?I(d,H,ne):[];y.push({id:E,name:d.name||"",kind:H,parent:D.parent||0,children:[...D.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 C=new Map(y.map(d=>[d.id,d]));for(let d of y){let E=`${d.name}(${d.id})`;if(JSON.stringify(d.relatedIds)!==JSON.stringify(d.children)&&a.push(`${E}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),d.id!==_){let D=C.get(d.parent);D?D.children.includes(d.id)||a.push(`${E}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):a.push(`${E}: parent=${d.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let D of d.children){let V=C.get(D);V?V.parent!==d.id&&a.push(`${E}: child=${D} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):a.push(`${E}: child=${D} \u4E0D\u5B58\u5728`)}}if(n.length){let d=Fa(Na({...i,graph:n,accessories:s.filter(E=>!$.has(E.id?.id||0))}));a.push(...d.errors.map(E=>`\u5BA2\u6237\u7AEF\u6A21\u677F: ${E}`))}return{valid:a.length===0,errors:a,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:m,name:c.name||"",relatedGuids:S?.related?.value||[],rootGuid:_},accessoryCount:s.length,controls:y,scriptCount:o.length,explicitEmpty:{field17:x,rectField508:F}}}function ud(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=er[u],f=Ee[c].platform,h=Object.keys(Ee).filter(w=>Ee[w].platform===f&&s[w]),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):bs(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 w of h)JSON.stringify(l[u])!==JSON.stringify(Nt(s[w]))&&e.push(`${a}: ${w} \u4E0E ${u} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[u]?"\u5DF2\u6709\u5E73\u53F0":m}\u53C2\u6570`)}si(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 za(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 La(t,e,i,r=t.canvasId){let n=li(t.root,e);return!n||n.kind==="server-container"?Qe(r):i[n.id]||Qe(r)}function xi(t,{warnings:e=[]}={}){if(!t)return Ni();if(t=ud(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"?sr():Ni(),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:Mn,selectedId:t.selectedId||r.selectedId,root:xs(t.root||r.root)};return pd(n),Yt(n,{warnings:e}),n}function pd(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=Ss(t.root).id)}function cd(t){return ai(or(t))}function py(t,e){let i=!1;return Ae(t,r=>{r.id===e&&(i=!0)}),i}function my(t,e,i,r){let o=ci(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=ci(t.root,t.canvasId),l=r.kind==="server-container"?Qe(t.canvasId):a.boxes[r.id]||Qe(t.canvasId),u=ui(e.transformByPlatform,t.canvasId),c=Ai(l,u,{posX:o.centerX,posY:o.centerY,width:o.width,height:o.height});Er(t,e,c)}function gy(t,e){return t.meta.assetType!=="client-control-template"?Ps(t.root,e):(t.root.children||[]).flatMap(i=>Ps(i,e))}function md(t,e){let i=zu(t.root,e);if(t.meta.assetType!=="client-control-template")return i;let r=Vr(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 gd(t){let{canvas:e,boxes:i}=ci(t.root,t.canvasId),r=on(t,new Set,{preserveLegacy:!0}),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"&&Vr(t)?.id||""},tree:gy(t,r),boxes:md(t,i),inspector:$u(n,t.canvasId,o||e,r),root:t.root})}function Er(t,e,i){let r=ci(t.root,t.canvasId),n=La(t,e.id,r.boxes),o={};if(e.syncAllDevices!==!1)for(let s of qe){if(s===Ti(t.canvasId))continue;let a=er[s],l=ci(t.root,a,s);o[s]=La(t,e.id,l.boxes,a)}e.transformByPlatform=wu({transformByPlatform:e.transformByPlatform,source:i,canvasId:t.canvasId,syncAllDevices:e.syncAllDevices!==!1,sourceParentBox:n,targetParentBoxByPlatform:o})}var yy=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"]),vy=new Set(["posX","posY","width","height"]),by=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function wy(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 ti(t,e){let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e} must be a finite number`);return i}function fd(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 Sy=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode","itemPrefabId","layoutConstraintFixedCount"]),xy=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),Iy=new Set(["name","imageSource","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),dd=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),hd={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 _y(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}=ci(t.root,t.canvasId),n=md(t,r),o=Lu(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"?sr():Ni();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:ws(t.root),guid:cd(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=yu(r,e.kind,{id:ws(t.root),guid:cd(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?li(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||py(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 my(t,r,n,o),t.selectedId=r.id,t}if(i==="moveSibling"){let r=Ve(t.root,e.id||t.selectedId),n=r?li(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=li(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 vu(t.root,r)&&(Ae(t.root,o=>{if(o.kind==="button")for(let s of dd)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=pu(r.kind,u);if(!c)throw new Error(`unknown raw GIA field for ${r.kind}: ${u}`);if(r.giaRaw||={},r.giaRaw[u]=ps(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=fd(o),r.syncAllDevices){let u=ui(r.transformByPlatform,t.canvasId);Er(t,r,u)}return t}if(yy.has(n)){if(n.endsWith("Color")&&(o=wy(o)),Sy.has(n)){if(o=ti(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(xy.has(n)&&(o=fd(o)),Iy.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(hd[n]&&!hd[n].includes(o))throw new Error(`invalid ${n}`);if(dd.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}=ci(t.root,t.canvasId),a=La(t,r.id,s),l=ui(r.transformByPlatform,t.canvasId);if(n==="anchorType"){let u=$a(s[r.id]),c=uu(l,o);return c=Ai(a,c,u),Er(t,r,c),t}if(["rotationX","rotationY","rotationZ"].includes(n)){let u={...l,rotation:{...l.rotation,[n.slice(-1).toLowerCase()]:ti(o,n)}};return Er(t,r,u),t}if(by.has(n)){let u=$a(s[r.id]),c={...l,anchorMin:{...l.anchorMin},anchorMax:{...l.anchorMax},pivot:{...l.pivot}};return n==="anchorMinX"&&(c.anchorMin.x=ti(o,n)),n==="anchorMinY"&&(c.anchorMin.y=ti(o,n)),n==="anchorMaxX"&&(c.anchorMax.x=ti(o,n)),n==="anchorMaxY"&&(c.anchorMax.y=ti(o,n)),n==="pivotX"&&(c.pivot.x=ti(o,n)),n==="pivotY"&&(c.pivot.y=ti(o,n)),Er(t,r,Ai(a,c,u)),t}if(vy.has(n)){let u=$a(s[r.id]),c=ti(o,n);if((n==="width"||n==="height")&&c<0)throw new Error(`${n} must not be negative`);return u[n]=c,Er(t,r,Ai(a,l,u)),t}throw new Error(`set: unknown key ${n}`)}if(i==="replace"){let r=xi(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 Ga(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 _y(r,e),pd(r),Yt(r),r.version=i+1,Object.keys(t).forEach(n=>{delete t[n]}),Object.assign(t,r),t}function $a(t){return t?{posX:t.centerX,posY:t.centerY,width:t.width,height:t.height}:{posX:0,posY:0,width:0,height:0}}import Ey from"fengari";var{lua:p,lauxlib:_e,lualib:yd,to_luastring:Co,to_jsstring:Cy}=Ey,ky=p.LUA_TNIL,Ay=p.LUA_TBOOLEAN,Ty=p.LUA_TNUMBER,Ry=p.LUA_TSTRING,vd=p.LUA_TTABLE,Oy=p.LUA_TFUNCTION,qa=p.LUA_TUSERDATA,kt=p.LUA_OK,bd=new WeakMap,Ba=Symbol("luaTableEntries"),ja={__scriptHostKey:!0};function q(t){return Co(String(t))}function qi(t,e){bd.set(t,e)}function lt(t){return bd.get(t)}var sn=class{constructor(e){this.value=e}};function Le(t,e,i){if(i instanceof sn){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,q(i));return}if(r==="function"){My(t,e,i);return}if(i&&i[Ba]){let n=i[Ba];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,q(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?"":Cy(i)}function ii(t,e){e=p.lua_absindex(t,e);let i=p.lua_type(t,e);if(i===qa)return lt(p.lua_touserdata(t,e));if(i===vd){p.lua_pushlightuserdata(t,ja),p.lua_rawget(t,e);let r=p.lua_type(t,-1)===qa?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===ky)return null;if(r===Ay)return!!p.lua_toboolean(t,i);if(r===Ty)return p.lua_isinteger(t,i)?p.lua_tointeger(t,i):p.lua_tonumber(t,i);if(r===Ry)return Ce(t,i);if(r===qa){let n=p.lua_touserdata(t,i);return lt(n)??n}if(r===Oy)return Ny(t,e,i);if(r===vd){let n=ii(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,Ba,{value:o}),l}return null}function Ny(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=_e.luaL_ref(t,p.LUA_REGISTRYINDEX),o=Py(t,e,n);return r!=null&&e.luaFunctions.set(r,o),o}function Py(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 wd(t){t?.__luaRef!=null&&(t.__luaHolds=(t.__luaHolds||0)+1)}function Sd(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))&&_e.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 My(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,q(String(u&&u.message?u.message:u))),p.lua_error(n)}},2)}function xd(t){!t||typeof p.lua_close!="function"||p.lua_close(t)}function Id(t){if(_e.luaL_loadstring(t,q(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
123
+ `)))===kt&&p.lua_pcall(t,0,0,0),p.lua_settop(t,0),p.lua_pushnil(t),p.lua_setglobal(t,q("_VERSION")),p.lua_getglobal(t,q("string")),!p.lua_isnil(t,-1))for(let i of["dump","pack","unpack"])p.lua_pushnil(t),p.lua_setfield(t,-2,q(i));if(p.lua_pop(t,1),p.lua_pushnil(t),p.lua_setglobal(t,q("io")),p.lua_getglobal(t,q("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,q(i));p.lua_pop(t,1),p.lua_getglobal(t,q("debug")),p.lua_isnil(t,-1)?p.lua_pop(t,1):(p.lua_getfield(t,-1,q("traceback")),p.lua_newtable(t),p.lua_pushvalue(t,-2),p.lua_setfield(t,-2,q("traceback")),p.lua_setglobal(t,q("debug")),p.lua_pop(t,2)),p.lua_getglobal(t,q("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,q("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,q("isinf"))),p.lua_pop(t,1),p.lua_pushnil(t),p.lua_setglobal(t,q("package")),p.lua_pushnil(t),p.lua_setglobal(t,q("load")),p.lua_pushnil(t),p.lua_setglobal(t,q("loadfile")),p.lua_pushnil(t),p.lua_setglobal(t,q("dofile")),p.lua_pushnil(t),p.lua_setglobal(t,q("collectgarbage")),p.lua_pushnil(t),p.lua_setglobal(t,q("coroutine")),p.lua_pushnil(t),p.lua_setglobal(t,q("fengari"))}var pt=(t,e=0)=>Number.isFinite(Number(t))?Number(t):e,_d=t=>t?.Name||t,ko=t=>Math.max(0,Math.min(1,pt(t)));function an(t){let e=t.parent?an(t.parent):[t.runtime.canvasWidth,t.runtime.canvasHeight];return[Math.max(0,(t.anchorMaxX-t.anchorMinX)*e[0]+pt(t.sizeDeltaX)),Math.max(0,(t.anchorMaxY-t.anchorMinY)*e[1]+pt(t.sizeDeltaY))]}function ln(t){let[e,i]=an(t),r=_d(t.scrollDirection)==="Horizontal",n=Math.max(1,pt(t.cellSizeX,50)),o=Math.max(1,pt(t.cellSizeY,50)),s=Math.max(0,pt(t.spacingX)),a=Math.max(0,pt(t.spacingY)),l=Math.max(0,pt(t.padding1X)),u=Math.max(0,pt(t.padding1Y)),c=Math.max(0,pt(t.padding2X)),f=Math.max(0,pt(t.padding2Y)),h=r?i-u-f:e-l-c,m=r?o:n,g=r?a:s,v=_d(t.layoutConstraint)==="Fixed"?Math.max(1,Math.floor(pt(t.layoutConstraintFixedCount,1))):Math.max(1,Math.floor((h+g)/(m+g))),w=Math.ceil(t.itemCount/v),S=w?r?l+c+w*n+(w-1)*s:u+f+w*o+(w-1)*a:0,x=r?e:i,F=Math.max(0,S-x);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:S,viewport:x,max:F,offset:ko(t.scrollProgress)*F}}function Cr(t){let e=ln(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 Ed={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},Fy=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],Ao=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),Dy=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],zy={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},$y={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"]},Ly=["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"],Cd=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Gy={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:Cd,cursor:Cd,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function Ua(t,e){return t.kind==="image"&&e==="imageType"&&t.runtime.canSelectImageType(t.imageId,t.imageSource)?"rw":Fy.includes(e)||(zy[t.kind]||[]).includes(e)?"ro":Dy.includes(e)||($y[t.kind]||[]).includes(e)?"rw":null}var qy=["localRotationX","localRotationY","localRotationZ"],kr=Math.PI/180;function kd(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 Va(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 Ad(t,e,i){let r=x=>[Math.sin(x*kr/2),Math.cos(x*kr/2)],[n,o]=r(t),[s,a]=r(e),[l,u]=r(i),[c,f,h,m]=kd(kd([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,w,S;return Math.abs(g)>.999999?(v=Math.sign(g)*90,w=2*Math.atan2(f,m)/kr,S=0):(v=Math.asin(g)/kr,w=Math.atan2(2*(m*f+c*h),1-2*(c*c+f*f))/kr,S=Math.atan2(2*(m*h+c*f),1-2*(c*c+h*h))/kr),[Va(v),Va(w),Va(S)]}function Td(t,e){return Ly.includes(e)||(Gy[t.kind]||[]).includes(e)}var By={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}},Ii=class t{constructor(e,i){this.runtime=e,this.kind=i.kind||"container",this.typeofName=Ed[this.kind]||Ed.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=By[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=ko(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 Ad(this.localRotationX,this.localRotationY,this.localRotationZ)}luaFieldValue(e){if(e==="imageType")return this.imageType??"Stretch";let i=qy.indexOf(e);return i<0?this[e]:Ad(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,Cr(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=ln(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?ko(l/r.max):0,Cr(this),this.markPlayDirty(!0)}GetContentLength(){return ln(this).length}};function Gt(t,e){e(t);for(let i of t.children)Gt(i,e)}function Ha(t,e=[],i=""){e.push(`${i}${t.name||"(unnamed)"} [${t.typeofName}] Id=${t.Id}`);for(let r of t.children)Ha(r,e,i+" ");return e}function To(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 Rd={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-To(1-t),OutBounce:To,InOutBounce:t=>t<.5?(1-To(1-2*t))/2:(1+To(2*t-1))/2};function Od(t,e){let i=Rd[t]||Rd.Linear;return e<=0?0:e>=1?1:i(e)}function Ar(t,e,i,r=255){let n=Ro(t),o=Ro(e),s=Ro(i);return((r==null?255:Ro(r))<<24|n<<16|o<<8|s)>>>0}function un(t){let e=t>>>0;return[e>>>16&255,e>>>8&255,e&255,e>>>24&255]}function Ro(t){let e=Number(t);return Number.isFinite(e)?Math.max(0,Math.min(255,Math.trunc(e))):0}function Nd(t,e,i){let r=un(t),n=un(e);return Ar(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 jy=new Set(["fontColor","bgColor","outlineColor","imageColor"]),Vy=new Set(["fontSize","minimumFontSize"]),Ya=1e-9;function Uy(t,e){return typeof t?.luaFieldValue=="function"?t.luaFieldValue(e):t[e]}var cn=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=Uy(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=Od(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(jy.has(o)&&typeof s=="number"&&typeof a=="number")this.object[o]=Nd(s,a,i);else if(typeof s=="number"&&typeof a=="number"){let l=s+(a-s)*i;this.object[o]=Vy.has(o)?Math.trunc(l):l}else this.object[o]=i>=1?a:s;r=!0,Ao.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)}},Tr=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+Ya&&n.push({at:s.at,rank:s.fn?1:2,entry:s}),s.tween&&!s.done&&s.end<=e+Ya&&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+Ya<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 Oo={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"]},Hy=[...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"],Yy=[...Array.from({length:14},(t,e)=>`CraftspersonKey${e+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function Xy(){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}Oo.KeyboardKeyCode=Hy;Oo.ControllerKeyCode=Yy;Oo.KeyEventType=Xy();var Pd=new Map;function Bi(t,e){let i=`${t}\0${e}`,r=Pd.get(i);return r||(r={__kind:"EnumItem",Name:e,FullName:`Enum.${t}.${e}`,EnumType:t},Pd.set(i,r)),r}function Xa(t,e){return e==null?e:e.__kind==="EnumItem"?Bi(e.EnumType||t,e.Name):typeof e=="string"&&e?Bi(t,e):e}function Wa(){let t={};for(let[e,i]of Object.entries(Oo)){let r={};for(let n of i)r[n]=Bi(e,n);t[e]=r}return t}var Wy=new Set(["Id","prefabIndex","imageId","fontSize","minimumFontSize","clickAudioId","itemCount","itemPrefabIndex","animationId","referencedPrefabIndex"]),Ky=new Set(["imageColor","fontColor","bgColor","outlineColor"]),Md={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"},ji=p.LUA_REGISTRYINDEX,Fd=p.LUA_MULTRET,Jy=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 No=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=Wa(),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){wd(e)}unrefLuaCallback(e){Sd(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 Ii?e:new Ii(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 Ii)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,q("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,q("printerr")),p.lua_pushcfunction(e,r=>{if(p.lua_type(r,1)===p.LUA_TTABLE&&!ii(r,1))return p.lua_pushstring(r,q("table")),1;let n=Xe(r,i,1);return p.lua_pushstring(r,q(i.typeofOf(n))),1}),p.lua_setglobal(e,q("typeof")),this.pushColorLib(e),this.pushEnumLib(e),this.pushGameLib(e),p.lua_pushcfunction(e,r=>i.luaRequire(r)),p.lua_setglobal(e,q("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 Tr?"TweenSequence":e instanceof cn?"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,Ar(p.lua_tonumber(i,1),p.lua_tonumber(i,2),p.lua_tonumber(i,3),255)),1)),p.lua_setfield(e,-2,q("FromRGB")),p.lua_pushcfunction(e,i=>{let r=p.lua_isnoneornil(i,4)?255:p.lua_tonumber(i,4);return this.pushPackedColor(i,Ar(p.lua_tonumber(i,1),p.lua_tonumber(i,2),p.lua_tonumber(i,3),r)),1}),p.lua_setfield(e,-2,q("FromRGBA")),p.lua_pushcfunction(e,i=>{let r=p.lua_tonumber(i,1)>>>0;for(let n of un(r))p.lua_pushinteger(i,n);return 4}),p.lua_setfield(e,-2,q("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,Ar(r,n,o,s)),1}),p.lua_setfield(e,-2,q("__call")),p.lua_setmetatable(e,-2),p.lua_setglobal(e,q("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,q(n));p.lua_setfield(e,-2,q(i))}p.lua_setglobal(e,q("Enum"))}pushEnumItem(e,i){let r=p.lua_newuserdata(e,0);qi(r,i),_e.luaL_setmetatable(e,q("EnumItem"))}pushControl(e,i){let r=p.lua_newuserdata(e,0);qi(r,i),_e.luaL_setmetatable(e,q("Control"))}pushScript(e,i){p.lua_newtable(e),p.lua_pushlightuserdata(e,ja);let r=p.lua_newuserdata(e,0);qi(r,i),p.lua_rawset(e,-3),_e.luaL_getmetatable(e,q("Script")),p.lua_setmetatable(e,-2)}pushTween(e,i){let r=p.lua_newuserdata(e,0);qi(r,i);let n=i instanceof Tr?"TweenSequence":"Tween";_e.luaL_setmetatable(e,q(n))}pushSignal(e,i){let r=p.lua_newuserdata(e,0);qi(r,i),_e.luaL_setmetatable(e,q("ServerSignal"))}pushCursor(e,i){let r=p.lua_newuserdata(e,0);qi(r,i),_e.luaL_setmetatable(e,q("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,Bi("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 cn(i,o,s,a);return i.pushTween(n,l),1},TweenSequence:n=>(i.pushTween(n,new Tr(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,Bi("LanguageType",i.language)),1),GetStageMode:n=>(i.pushEnumItem(n,Bi("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,q(o)),1},PrintClientUITree:n=>{for(let o of i.roots)i.log("info",Ha(o).join(`
124
+ `));return 0}};for(let[n,o]of Object.entries(r)){let s=Jy[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?_e.luaL_error(a,q(`bad argument count to '${n}' (${s} expected, got ${l})`)):o(a)}),p.lua_setfield(e,-2,q(n))}p.lua_setglobal(e,q("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)?_e.luaL_error(e,q("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 Ii(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,q("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){_e.luaL_newmetatable(e,q(i)),p.lua_pushcfunction(e,a=>{let l=ii(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 _e.luaL_error(a,q(String(f.message||f)))}return c===void 0?(p.lua_pushnil(a),1):(Le(a,this,c),1)}),p.lua_setfield(e,-2,q("__index")),p.lua_pushcfunction(e,a=>{try{let l=ii(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,q(String(l.message||l))),p.lua_error(a)}}),p.lua_setfield(e,-2,q("__newindex")),p.lua_pushcfunction(e,a=>{let l=ii(a,1)||lt(p.lua_touserdata(a,1)),u=ii(a,2)||lt(p.lua_touserdata(a,2));return p.lua_pushboolean(a,l===u),1}),p.lua_setfield(e,-2,q("__eq")),p.lua_pop(e,1)}method(e){let i=this;return r=>{let n=ii(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,q(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):_e.luaL_error(n,q("bad argument #2 to 'SetVisible' (boolean expected, got %s)"),_e.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(!Ua(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=Md[o];return a?Xa(a,s):typeof s=="number"&&!Wy.has(o)&&!Ky.has(o)?new sn(s):s},(n,o,s)=>{if(Ua(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=Md[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?Xa(l,s):s,typeof n.markPlayDirty=="function"&&n.markPlayDirty(Ao.has(o));return}throw new Error(`cannot set ${o}, no such field`)},r,Td)}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,ji,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,q(`failed to load script '${r}': cyclic require`)),p.lua_error(e);if(a&&a.ref!=null)return p.lua_rawgeti(e,ji,a.ref),1;let l=this.scriptFiles.get(n);if(l==null)return p.lua_pushstring(e,q(`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=_e.luaL_ref(e,ji);return s.set(n,{ref:c}),1}catch(c){return s.delete(n),p.lua_settop(e,u),p.lua_pushstring(e,q(`failed to load script '${r}': ${c.message||c}`)),p.lua_error(e)}}newLuaThread(){let e=_e.luaL_newstate();return yd.luaL_openlibs(e),Id(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,_e.luaL_ref(e,ji)),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,q("_G"))}closeTrackedLuaState(e){if(!e||!this.luaStates.has(e))return;for(let r of this.requireCache.get(e)?.values()||[])r.ref!=null&&_e.luaL_unref(e,ji,r.ref);this.requireCache.delete(e);let i=this.moduleBaseEnvironments.get(e);if(i!=null&&_e.luaL_unref(e,ji,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);xd(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=Co(s);if(_e.luaL_loadbuffer(e,a,a.length,q(`@${r}`))!==kt)throw new Error(Ce(e,-1));let u=p.lua_absindex(e,-1);if(p.lua_rawgeti(e,ji,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(e,-1),p.lua_remove(e,-2),this.pushScript(e,o),p.lua_setfield(e,-2,q("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,q("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=Co(n),s=_e.luaL_loadbuffer(e,o,o.length,q(`@${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,q(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,q(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=ii(e,1);if(!i||i.__kind!=="Script")return _e.luaL_error(e,q("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 _e.luaL_error(e,q(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,q(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,Fd,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,q(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,Fd,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,q("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,q(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,q("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 fn(t){let e=new No(t);return e.boot(),e}var Ui=Object.freeze(Array.from({length:8},(t,e)=>`Player${e+1}`)),Za=Object.freeze(Array.from({length:8},(t,e)=>`Avatar${e+1}`)),jd=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var Ka=Object.freeze([...jd,...Ui,...Za]),Vd=Object.freeze(["PlayerSelf","AllPlayers",...Ui]),Zy=Object.freeze(["Level","PlayerSelf",...Ui]),Dd=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),Qy=-2147483648,e0=2147483647,t0=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 dn(t){return`Player${Number(t)}`}function Po(t){return`Avatar${Number(t)}`}function zd(t){let e=String(t||"").match(/^(?:Player|Avatar)([1-8])$/);return e?Number(e[1]):0}function Vi(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 ri(t,e=8){let i=Vi(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 $d(){let t={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let e of Ui)t[e]=Object.create(null);for(let e of Za)t[e]=Object.create(null);return t}function Ud(t){let e=String(t||"");if(!Ka.includes(e))throw new Error(`unknown CustomVariableEntityType: ${t}`);return e}function i0(t,e){let i=Ud(t);if(!Zy.includes(i))throw new Error(`${e}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function hn(t){let e=String(t??"");if(!e)throw new Error("custom variable name is required");return e}function Mo(t){let e=String(t??"");if(!e)throw new Error("signal name is required");return e}function Ja(t){let e=String(t||"PlayerSelf");if(!Vd.includes(e))throw new Error(`unsupported client signal target: ${t}. use PlayerSelf, AllPlayers, or Player1-8`);return e}function pn(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=pn(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 Ld(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 Gd(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:pn(e),value:e}):[]}function r0(t){return String(t?.kind||t?.type||t?.name||t?.id||"")}function Fo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Hd(t,e){if(!Fo(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 qd(t,e){return Hd(t,e)||ot(t)}function n0(t,e,i){if(!Fo(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=i0(t.entityType,n);if(!Object.prototype.hasOwnProperty.call(t,"value"))throw new Error(`${n}.value is required`);return{kind:r,entityType:o,name:hn(t.name),value:qd(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:Ja(t.target),signalName:Mo(t.signalName),params:t.params.map((o,s)=>qd(o,`${n}.params[${s}]`))}}throw new Error(`${n}.kind must be setCustomVariable or sendClientScriptSignal`)}function mn(t){if(t==null)return{version:1,rules:[]};if(!Fo(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(!Fo(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:Mo(i.signalName),actions:i.actions.map((n,o)=>n0(n,r,o))}})}}function Bd(t,e,{typed:i=!1}={}){let r=Hd(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 o0(t){return t==="Level"?"Level":Ui.includes(t)?"PlayerSelf":Za.includes(t)?"AvatarSelf":t}function Yd(t={}){let e=$d(),i=$d(),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=mn(t.logic),h=Vi(t.playerCount),m=ri(t.viewPlayerIndex,h);function g(_,T){s.push({source:"server",level:String(_||"engine"),text:String(T),time:u})}function v(_){let T=a[_||m],y=Number(T?.clock?.time);Number.isFinite(y)&&(u=y)}function w(_,T,y,N){e[_][T]=y,i[_][T]={type:N||pn(y)||i[_][T]?.type||""}}function S(_,T,y){return typeof y!="number"||!Number.isInteger(y)?{ok:!0,value:y}:y>=Qy&&y<=e0?{ok:!0,value:y}:(g("engine",`Int custom variable ${_}.${T} out of range ${y}; keeping previous legal value`),{ok:!1,value:e[_][T]})}function x(_,T){let y=Ud(_),N=T||m;return y==="PlayerSelf"?dn(N):y==="AvatarSelf"?Po(N):y}function F(_,T){let y=o0(_);if(_==="Level"){for(let d=1;d<=h;d+=1){let E=a[d];E&&typeof E.notifyVarHandlers=="function"&&E.notifyVarHandlers("Level",T)}return}let N=zd(_);if(!N)return;let C=a[N];C&&typeof C.notifyVarHandlers=="function"&&C.notifyVarHandlers(y,T)}function I(_,T){let y=Ja(_);return y==="AllPlayers"?Array.from({length:h},(N,C)=>C+1):y==="PlayerSelf"?[T||m]:[zd(y)]}function z(_){for(let T of f.rules)if(T.signalName===_.name)for(let y of T.actions){if(y.kind==="setCustomVariable"){let N=Bd(y.value,_);G.setVar(y.entityType,y.name,N,{type:y.variableType,playerIndex:_.playerIndex}),g("info",`logic ${T.id}: set ${y.entityType}.${y.name}`);continue}if(y.kind==="sendClientScriptSignal"){let N=y.params.map(C=>Bd(C,_,{typed:!0}));G.sendToClient(y.signalName,N,{target:y.target,playerIndex:_.playerIndex}),g("info",`logic ${T.id}: sent ${y.signalName} to ${y.target}`)}}}function $(_,T){_&&(_.serverBridge={getVar:(y,N)=>G.getVar(y,N,{playerIndex:T}),setVar:(y,N,C)=>G.setVar(y,N,C,{playerIndex:T}),receiveFromClient:(y,N)=>G.receiveFromClient(y,N,{playerIndex:T})})}function j(_){_&&(_.serverBridge=null)}let G={ENTITY_TYPES:jd,ALL_ENTITY_TYPES:Ka,CLIENT_SIGNAL_TARGETS:Vd,get clock(){return u},get playerCount(){return h},get viewPlayerIndex(){return m},setClock(_){u=Number(_)||0},setPlayerCount(_){return h=Vi(_),m>h&&(m=h),h},setViewPlayerIndex(_){return m=ri(_,h),m},log(_,T){g(_,T)},defineVar(_,T,y={},{playerIndex:N}={}){let C=x(_,N),d=hn(T);if(Object.prototype.hasOwnProperty.call(e[C],d))throw new Error(`custom variable already exists: ${C}.${d}`);let E=y.type?String(y.type):pn(y.value??y.defaultValue);if(E&&!Dd.includes(E))throw new Error(`unsupported custom variable type: ${E}`);let D=y.value!==void 0?y.value:y.defaultValue!==void 0?y.defaultValue:null;return w(C,d,D,E),G.getVar(C,d)},getVar(_,T,{playerIndex:y}={}){let N=x(_,y),C=hn(T);if(!Object.prototype.hasOwnProperty.call(e[N],C)){g("engine",`GetGlobalCustomVariableValue missing ${N}.${C}; returning nil (simulator policy)`);return}return e[N][C]},setVar(_,T,y,{notify:N=!0,type:C,playerIndex:d}={}){let E=x(_,d),D=hn(T),V=C||i[E][D]?.type||pn(y);if(V&&!Dd.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=S(E,D,y).value,H===void 0)))return w(E,D,H,V),N&&F(E,D),H},listVars(_){let T=_?[x(_)]:["Level",...Array.from({length:h},(N,C)=>dn(C+1)),...Array.from({length:h},(N,C)=>Po(C+1))],y=[];for(let N of T)for(let C of Object.keys(e[N]))y.push({entityType:N,name:C,type:i[N][C]?.type||"",value:ot(e[N][C])});return y},receiveFromClient(_,T=[],{playerIndex:y}={}){let N=ri(y||m,h);v(N);let C=Mo(_),d={id:l++,direction:"inbound",name:C,params:Gd(T),values:Ld(T),time:u,playerIndex:N,from:dn(N)};return r.push(d),z(d),d},sendToClient(_,T=[],{target:y="PlayerSelf",playerIndex:N}={}){let C=Mo(_),d=Ja(y),D=I(d,N||m),V={id:l++,direction:"outbound",name:C,params:Gd(T),values:Ld(T),time:u,target:d,players:D,deliverAt:u+c/1e3,delivered:!1};return n.push(V),c===0?G.deliver(V):o.push(V),V},getLogic(){return ot(f)},setLogic(_){return f=mn(_),G.getLogic()},deliver(_){if(!_||_.delivered)return;_.delivered=!0;let T=Array.isArray(_.players)&&_.players.length?_.players:I(_.target);for(let y of T){let N=a[y];N&&typeof N.sendClientSignal=="function"&&N.sendClientSignal(_.name,_.values)}},flush(_){_!==void 0&&(u=Number(_)||0);let T=[];for(let y=o.length-1;y>=0;y-=1)o[y].deliverAt<=u&&T.push(o.splice(y,1)[0]);T.sort((y,N)=>y.id-N.id);for(let y of T)G.deliver(y);return T},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 T of _.nodes||[]){let y=r0(T);if(!t0.has(y))throw new Error(`unsupported server node: ${y||JSON.stringify(T)}. v1 only supports custom variables and signals`)}if(_.onlineLatencyMs!==void 0){let T=Number(_.onlineLatencyMs);if(!Number.isFinite(T)||T<0)throw new Error("onlineLatencyMs must be a non-negative finite number");c=T}_.playerCount!==void 0&&G.setPlayerCount(_.playerCount),_.viewPlayerIndex!==void 0&&G.setViewPlayerIndex(_.viewPlayerIndex),(_.logic!==void 0||_.serverLogic!==void 0)&&G.setLogic(_.logic??_.serverLogic);for(let T of _.vars||[]){let y=x(T.entityType),N=hn(T.name);Object.prototype.hasOwnProperty.call(e[y],N)?G.setVar(y,N,T.value??T.defaultValue,{notify:!1,type:T.type}):G.defineVar(y,N,T)}}},attachRuntime(_,{playerIndex:T=1}={}){let y=ri(T,8);return a[y]&&a[y]!==_&&j(a[y]),a[y]=_||null,$(a[y],y),G},attachRuntimes(_){G.detachRuntime();let T=Array.isArray(_)?_:[];for(let y=0;y<T.length&&y<8;y+=1)a[y+1]=T[y]||null,$(a[y+1],y+1);return G},detachRuntime(){for(let _=1;_<=8;_+=1)j(a[_]),a[_]=null},snapshot(){let _=dn(m),T=Po(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[T]))y.AvatarSelf[N]={type:i[T][N]?.type||"",value:ot(e[T][N])};for(let N=1;N<=h;N+=1){let C=dn(N),d=Po(N);y[C]={},y[d]={};for(let E of Object.keys(e[C]))y[C][E]={type:i[C][E]?.type||"",value:ot(e[C][E])};for(let E of Object.keys(e[d]))y[d][E]={type:i[d][E]?.type||"",value:ot(e[d][E])}}return{clock:u,onlineLatencyMs:c,playerCount:h,viewPlayerIndex:m,logic:G.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 Ka){for(let T of Object.keys(e[_]))delete e[_][T];for(let T of Object.keys(i[_]))delete i[_][T]}r.length=0,n.length=0,o.length=0,s.length=0,l=1,u=0},destroy(){G.detachRuntime(),G.reset()}};t.config&&G.loadConfig(t.config);for(let _ of t.vars||[])G.defineVar(_.entityType,_.name,_);return G}var s0={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function Qa(t,e,i=null){let r=ui(t.transformByPlatform,e),n={authoringId:t.id,kind:s0[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=>Qa(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 el(t,e=[],i=""){let r=i&&Ee[i]?i:t.canvasId,n=Ee[r],o=Vr(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=>Qa(l,r,s)):[];return{canvasId:r,platform:n.platform,device:n.luaDevice,canvasWidth:n.width,canvasHeight:n.height,root:Qa(o,r,s),templates:a}}var Do="qxqy-autotest";var Yi=.03333333333333333,a0=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),l0=new Set(["log","control","var","signal","tree","lua"]);function Hi(t,e){let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e} must be a finite number`);return i}function tl(t){return JSON.parse(JSON.stringify(t??null))}function zo(t,e){if(!t||typeof t!="object")throw new Error(`events[${e}] must be an object`);let i=String(t.kind||t.do||"");if(!a0.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=Hi(r.x,"pointer.x"),r.y=Hi(r.y,"pointer.y"),r.type=String(r.type||"click"),r.type==="wheel"&&(r.deltaX=Hi(r.deltaX??t.deltaX??0,"pointer.deltaX"),r.deltaY=Hi(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:Hi(t.t??0,"event.t"),source:String(t.source||"user"),kind:i,payload:r}}function il(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(!l0.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let r={kind:i};if(t.at!==void 0&&(r.at=Hi(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=tl(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=tl(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=tl(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 Xd(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+=Hi(n.dt??Yi,"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(zo({...n,kind:n.do,t:e},i.length));continue}if(n.assert||n.check||n.kind){r.push(il({...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:Yi}}function gn(t){if(Array.isArray(t)){let r=Xd(t);return{format:Do,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=Xd(t.queue||t.steps);return{format:Do,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)=>zo(r,n)),i=(t.asserts||[]).map((r,n)=>il(r,n));return e.sort((r,n)=>r.t-n.t||0),{format:Do,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):Yi,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:e,asserts:i}}function Wd(t,e={}){let i=(t||[]).map((r,n)=>zo(r,n));return{format:Do,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):Yi,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:i,asserts:(e.asserts||[]).map((r,n)=>il(r,n))}}function Kd(t,e,i){if(!t)return null;let r=zo({...e,t:e.t??i??0},t.events.length);return t.events.push(r),r}var $o=(t,e)=>Math.max(0,Math.min(e,Number.isFinite(t)?t:0));function Jd(t,e,i){let r=Wt(t,e,i),n=Math.max(0,r.contentHeight-i),o=$o(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 Rr(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 Zd="https://oss.070077.xyz/",rl="mp3-v1",Lo="/qxqy-audio/",u0=[[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 Go(t){if(!Number.isSafeInteger(t))return null;for(let[e,i]of u0)if(t>=e&&t<e+i.length)return i[t-e];return null}import{randomUUID as ih}from"node:crypto";function jo(t){for(let e of t.runtime.scrollControls||[]){let[i,r]=an(e),n=e.kind==="grid"?Cr(e):Jd(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 rh(t){return{...t._scroll?{scroll:t._scroll}:{},...t.parent?._gridItems?.includes(t)?{clipToParent:!0}:{}}}function nl(t,e){let i=t._scroll?.max||0;t.kind==="grid"?t.scrollProgress=i?$o(e,i)/i:0:t._scrollOffset=$o(e,i),t.markPlayDirty()}var c0=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 Vo(t){jo(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 nh(t,e=Vo(t)){let i=new Map;function r(n,o){let s=e.get(n.Id);if(!s)return;let a=jr(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,nr());return i}function oh(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"?ir(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=>oh(r,e))}}function f0(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,pointerScroll:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function d0(t,e,i,r){let n=fn({canvasWidth:t.canvasWidth,canvasHeight:t.canvasHeight,device:t.device,audioDuration:Go,canSelectImageType:ru,...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 h0=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","pointerScroll","hoveredControl","selectedControl","stateRestores","viewCache"];function p0(t){Object.defineProperty(t,"runtime",{configurable:!0,enumerable:!0,get(){return t.runtimes[t.viewPlayerIndex-1]}});for(let e of h0)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 sh(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=el(t,c,s),m=e?el(e,f,s):null,g=Vi(a),v=ri(l,g),w=Yd({playerCount:g,viewPlayerIndex:v});o&&w.loadConfig({...o,playerCount:g,viewPlayerIndex:v});let S=[];for(let I=0;I<g;I+=1)S.push(d0(h,m,i,u));w.attachRuntimes(S);for(let I of S)I.addRoot(h.root);let x={audioSessionId:ih(),runtimes:S,views:S.map(()=>f0()),playerCount:g,viewPlayerIndex:v,server:w,compiled:h,mountError:S.find(I=>I.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};p0(x);let F=x.viewPlayerIndex;for(let I=1;I<=g;I+=1)x.viewPlayerIndex=I,E0(x);return x.viewPlayerIndex=F,x}function ll(t,e){if(!t)throw new Error("play session has not started");let i=ri(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||Kd(t.history,{...e,source:e.source||"user"},t.runtime.clock.time)}function m0(t){return t?.history?.events||[]}var ul=new Set(["image","textbox","textwindow","button","grid"]);function g0(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 ah(t){return{fillType:At(t.fillType),fillHorizontalType:At(t.fillHorizontalType),fillVerticalType:At(t.fillVerticalType),fillAmount:t.fillAmount}}function y0(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,...rh(t)};return t.kind==="image"&&(o.imageSource=st(t.imageSource),o.imageType=t.imageType==null?null:At(t.imageType),o.primitive=ir(t.imageId,o.imageSource),o.imageColor=t.imageColor,o.imageId=t.imageId,Object.assign(o,ah(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=Wt(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 v0(t,e=Vo(t)){let i=[],r=nh(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=g0(l,u),f=o.kind==="image"&&o.enableMask===!0?cr({...lh(o,l),id:o.Id},Vn(u,l.centerX,l.centerY)):null,h=f?[...a,f]:a,m=()=>i.push({...y0(o,l,c),...s.length?{clipPolygons:s}:{},...h.length?{masks:h}:{}});ul.has(o.kind)&&o.kind!=="grid"&&m();let g=o.children||[];for(let v=g.length-1;v>=0;v-=1){let w=o._gridItems?.includes(g[v])?[...s,[[l.left,l.bottom],[l.right,l.bottom],[l.right,l.top],[l.left,l.top]].map(([S,x])=>tt(u,S,x))]:s;n(g[v],w,h)}o.kind==="grid"&&m()}for(let o of t.runtime.roots)n(o);return i}function lh(t,e){let i={kind:t.kind,name:t.name,sourceWidth:e.width,sourceHeight:e.height,pressed:t.pressed===!0,...rh(t)};return t.kind==="image"&&(i.imageSource=st(t.imageSource),i.imageType=t.imageType==null?null:At(t.imageType),i.primitive=ir(t.imageId,i.imageSource),i.imageColor=t.imageColor,i.imageId=t.imageId,Object.assign(i,ah(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=Wt(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 b0(t,e,i){let r=ds(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 uh(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 ch(t,e,i,r,n,o){return{id:t.Id,parent:e,z:n,group:o>=16,matrix:b0(r,t,i),...lh(t,r)}}function w0(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=ul.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(ch(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 sl(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)sl(i[r])}function S0(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,w=v||u._playDirty===!0,S=v||u._playChildDirty===!0;if(!w&&!S)return;if(!(m&&u.active!==!1)||u.visible===!1){a(u);return}let F=Vt(c,u),I=e.childCounts.get(u.Id)||0;if(S){I=0;let T=u.children;for(let y=0;y<T.length;y+=1)l(T[y],F,u.Id,y,!0,v),e.fingerprints.has(T[y].Id)&&(I+=1)}if(!(ul.has(u.kind)||I>0)){e.fingerprints.has(u.Id)&&(n.push(u.Id),e.fingerprints.delete(u.Id),e.childCounts.delete(u.Id),o-=1);return}let $=e.childCounts.get(u.Id);e.childCounts.set(u.Id,I);let j=I>=16!=($||0)>=16;if(!w&&!j&&e.fingerprints.has(u.Id))return;let G=ch(u,f,c===i?null:c,F,h,I),_=uh(G);e.fingerprints.get(G.id)!==_&&(e.fingerprints.has(G.id)||(o+=1),e.fingerprints.set(G.id,_),r.push(G))}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 x0(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}=w0(t);i.rev+=1,i.fingerprints=new Map(l.map(c=>[c.id,uh(c)])),i.childCounts=u,i.count=l.length;for(let c of t.runtime.roots)sl(c);return{format:"tree-v1",revision:i.rev,reset:!0,count:l.length,nodes:l}}let{changed:o,removed:s,count:a}=S0(t,i);i.rev+=1;for(let l of t.runtime.roots)sl(l);return{format:"tree-v1",revision:i.rev,reset:!1,count:a,changed:o,removed:s}}function cl(t,{inspect:e=!1,view:i=!1,paint:r=!1,sceneRev:n,compact:o=!1}={}){jo(t),t.audioSessionId||=ih();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=m0(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:c0,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=Vo(t);e&&(m.tree=s.roots.map(v=>oh(v,g))),r&&(m.paint=v0(t,g))}return i&&(m.scene=x0(t,n)),rr(m),m}function Uo(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 fl(t,e){_i(t,{kind:"key",payload:{typeName:String(e)}}),t.runtime.injectKey(e)}function I0(t,e){let i=null;for(let r of t.runtime.roots)Gt(r,n=>{!i&&n.name===e&&(i=n)});return i}function dl(t,e){_i(t,{kind:"click",payload:{name:String(e)}});let i=I0(t,e);i&&hl(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function _0(t,e){return!t||!e?null:t.children.find(i=>i.authoringId===e||i.Id===e)||null}var fh={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function dh(t,e){let i=[];for(let[r,n]of Object.entries(fh)){let o=e[n]?_0(e,e[n]):null;o&&i.push({state:r,child:o})}return i}function E0(t){for(let e of t.runtime.roots)Gt(e,i=>{if(i.kind==="button"){for(let{child:r}of dh(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);yn(t,i)}})}function yn(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 dh(t,e))r.child.active=!0,r.child.visible=r.state===i,typeof r.child.markPlayDirty=="function"&&r.child.markPlayDirty(!0)}function ol(t){if(!t)return null;let e=t.parent;return e?.kind==="button"&&Object.values(fh).map(r=>e[r]).filter(Boolean).includes(t.authoringId)?e:t}function hl(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 hh(t){return t.kind==="container"||t.kind==="grid"||t.kind==="textwindow"||t.kind==="reference"||t.kind==="button"}function ph(t,e){let i=t.Id,r=e.get(i);if(r!==void 0)return r;let n=hl(t);if(!n&&hh(t)){let o=t.children;for(let s=0;s<o.length;s+=1)if(ph(o[s],e)){n=!0;break}}return e.set(i,n),n}function qo(t,e,i){jo(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||!ph(a,n))return null;let f=Vt(l,a),h=jr(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(Bo(a)){let v=Rr(a._scroll,f.width,f.height)?.track,w=g.x-f.centerX,S=f.centerY-g.y;if(v&&w>=v.x&&w<=v.x+v.width&&S>=v.y&&S<=v.y+v.height)return a}if(hh(a))for(let v=0;v<a.children.length;v+=1){let w=o(a.children[v],f,h,!0);if(w)return w}return hl(a)?a:null}let s=nr();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 Or(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 al(t,e,i){e.kind==="grid"||e.kind==="textwindow"||(e.pressed=i,typeof e.markPlayDirty=="function"&&e.markPlayDirty(),yn(t,e))}function Bo(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 Qd(t){for(let e=t;e;e=e.parent)if(Bo(e))return e;return null}function eh(t,e,i,r){let n=Vo(t),o=n.get(e.Id),s=nh(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 th(t,e,i){let r=t.pointerDownControl;if(r?.alive){let n=Or(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),al(t,r,!1)}t.pointerDownControl=null,t.pointerScroll=null,t.pointerDownPosition=null,t.pointerDragging=!1,t.pointerLastPosition={x:e,y:i}}function vn(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=qo(t,o,s),c=Qd(u);if(c){let f=c._scroll.horizontal&&a||l;nl(c,c._scroll.offset+f)}return u}if(e==="cancel")return th(t,o,s),null;if((e==="move"||e==="up")&&t.pointerScroll&&!Bo(t.pointerScroll.control)&&th(t,o,s),e==="move"){let u=t.pointerLastPosition||{x:o,y:s},c=t.pointerHoverControl,f=ol(qo(t,o,s)),h=Or(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&&yn(t,m),t.hoveredControl&&yn(t,t.hoveredControl);let g=t.pointerDownControl,v=t.pointerScroll;if(v)if(!Bo(v.control))t.pointerScroll=null;else{let w=eh(t,v.control,o,s);if(w){let S=v.control._scroll,x=S.horizontal?w.x-v.start.x:w.y-v.start.y,F=Rr(S,w.width,w.height)?.travel||0,I=v.bar?F?x*S.max/F:0:-x;nl(v.control,v.offset+I)}}if(g?.alive){let w=t.pointerDownPosition||u,S=Math.hypot(o-w.x,s-w.y)>5;!t.pointerDragging&&S&&(v||t.runtime.injectCursor(g,"CursorBeginDrag",Or(t,o,s,{press:w,previous:u,dragging:!1})),t.pointerDragging=!0),t.pointerDragging&&!v&&t.runtime.injectCursor(g,"CursorDrag",Or(t,o,s,{press:w,previous:u,dragging:!0}))}return t.pointerLastPosition={x:o,y:s},f}if(e==="down"){let u=ol(qo(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=Qd(u);if(c){let f=eh(t,c,o,s),h=f&&Rr(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;nl(c,h.travel?v/h.travel*c._scroll.max:0),jo(t)}f&&(t.pointerScroll={control:c,start:f,offset:c._scroll.offset,bar:!!g})}return u&&(al(t,u,!0),t.runtime.injectCursor(u,"CursorDown",Or(t,o,s))),u}if(e==="up"){let u=t.pointerDownControl,c=ol(qo(t,o,s));if(u?.alive){let f=Or(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&&yn(t,h)}al(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 vn(t,"down",o,s,{silent:!0}),vn(t,"up",o,s,{silent:!0});throw new Error(`unknown pointer type ${e}`)}function pl(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 mh(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 ml(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 Ho(t){return{snapshot:e=>cl(t,e),step:e=>Uo(t,e),pointer:(e,i,r,n)=>vn(t,e,i,r,n),key:e=>fl(t,e),click:e=>dl(t,e),view:e=>ll(t,e),pause:()=>{_i(t,{kind:"pause",payload:{}}),t.debugPaused=!0},resume:()=>{_i(t,{kind:"resume",payload:{}}),t.debugPaused=!1},serverSet:(e,i,r)=>pl(t,e,i,r),serverSend:(e,i,r)=>ml(t,e,i,r)}}function gl(t){t?.server&&t.server.destroy();let e=t?.runtimes||(t?.runtime?[t.runtime]:[]);for(let i of e)i.destroy()}function yl(t,e){return JSON.stringify(t)===JSON.stringify(e)}function gh(t,e){for(let i of t||[])e(i),i.children?.length&&gh(i.children,e)}function vl(t,{id:e,name:i}){let r=null;return gh(t,n=>{r||(e&&String(n.id)===String(e)||!e&&i&&n.name===i)&&(r=n)}),r}function C0(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 k0(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=vl(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 A0(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=vl(e.tree,t);if(!i)return{ok:!1,actual:null,expected:t.equals,message:`control not found: ${t.id||t.name}`};let r=C0(i,t.field);return yl(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 yl(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||yl(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=!!vl(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 T0(t,e){let i=fn();try{return i.evalQueryScript(t,k0(e)),{ok:!0,actual:!0}}catch(r){return{ok:!1,message:r?.message||String(r)}}finally{i.destroy()}}function yh(t,e){return t.kind==="lua"?T0(t.source,e):A0(t,e)}function R0(t,e){let i=e>0?e:Yi;return Math.round((t+i)*1e9)/1e9}function O0(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 N0(t,e){let i=yh(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 vh(t,e){let i=gn(e),r=i.events.slice().sort((S,x)=>S.t-x.t),n=i.asserts.slice(),o=i.dt||Yi,s=r.reduce((S,x)=>Math.max(S,x.t),0),a=n.reduce((S,x)=>Math.max(S,Number(x.at||0)),0),l=Math.max(s,a),u=0,c=[],f=0,h=n.some(S=>S.kind==="control"||S.kind==="tree"||S.kind==="lua"),m=t.snapshot({inspect:h}),g=()=>{for(;u<r.length&&r[u].t<=f+1e-9;)O0(t,r[u]),u+=1,m=t.snapshot({inspect:h})},v=()=>{for(let S of n)if(!S._done&&Number(S.at||0)<=f+1e-9){let x=N0(S,m);if(c.push(x),S._done=!0,!x.ok)return{passed:!1,failedAt:f,frame:m.frame||0,results:c,snapshot:m}}return null};g();let w=v();if(w)return bl(i,w);for(;f+1e-9<l;){t.step(o),f=R0(f,o),m=t.snapshot({inspect:h}),g();let S=v();if(S)return bl(i,S)}return bl(i,{passed:c.every(S=>S.ok),failedAt:null,frame:m.frame||0,results:c,snapshot:m})}function bl(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 wl(t){return Array.isArray(t)?t.slice():[]}import{createHash as P0}from"node:crypto";var bh=t=>P0("sha256").update(JSON.stringify(t.map(({id:e,path:i,source:r})=>({id:e,path:i,source:r})))).digest("hex");function wh(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 Sh(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]===`
125
+ `&&(n++,s=o+1);let c=r.get(l),f=u+l.length,h=t.indexOf(`
126
+ `,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 G0={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(Ui.map((t,e)=>[t,`\u73A9\u5BB6${e+1}`])),...Object.fromEntries(Array.from({length:8},(t,e)=>[`Avatar${e+1}`,`\u89D2\u8272${e+1}`]))};function q0(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:G0[a]||a,name:u,type:l[u]?.type||"",value:l[u]?.value??null}))}return r}var Wi="qxqy-simulator-save",B0="qxqy-simulator-scripts",Ge="server-control-template",fe="client-control-template",Sl={[Ge]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[fe]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function Xi(t){return t===fe?"client":"server"}function Eh(t){if(!(typeof t=="number"||typeof t=="string"&&/^\d+$/.test(t.trim()))||!ct(t))throw new Error(`\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F ${1073741824}\u2013${1077936127}\uFF080x40000000\u20130x403FFFFF\uFF09\u8303\u56F4\u5185\u7684\u6574\u6570`);return Number(t)}function Yo(t){let e=typeof t=="number"||typeof t=="string"&&/^\d+$/.test(t.trim()),i=Number(t);if(!e||!Ht(i))throw new Error("\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F 1\u20132147483647 \u8303\u56F4\u5185\u7684\u6574\u6570");return i}function xl(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:Yo(i.oldGuid),newGuid:Yo(i.newGuid),...i.batchId?{batchId:i.batchId}:{},...i.scriptSignature?{scriptSignature:i.scriptSignature}:{}}})}function j0(t){let e=[t?.guid,t?.id];for(let i of e){let r=Number(i);if(Ht(r))return r}return 0}function Xo(t){let e=String(t?.controlAsset||""),i=j0(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 V0(t){let e=[],i=(r,n="")=>{if(r&&(r.path||r.source)){let o=Xo(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(Xo(r));return e}if(i(t?.assets?.server?.script,Ge),i(t?.assets?.client?.script,fe),t&&t.format!==Wi){i(t?.script);for(let r of t?.scripts||[])i(r)}return e}function Il(t){return xi(t===fe?sr():Ni())}var U0="\u672A\u7ED1\u5B9A",Nr="\u672A\u547D\u540D\u5B58\u6863",H0="\u672A\u547D\u540D\u754C\u9762";function Y0(t){let e=t;for(let i=0;i<8;i++){if(bn(Ih(e,"simulator","studio"))&&bn(Ih(e,"lua")))return e;let r=$0(e);if(r===e)break;e=r}return t}function X0(t){return t?{name:Pr(t),path:t,bound:!0}:{name:U0,path:"",bound:!1}}function W0(t,e=process.cwd()){if(L0(t)&&bn(t))return t;let i=e||process.cwd(),r=Y0(i),n=_h(r,t);if(bn(n))return n;let o=_h(i,t);if(bn(o))return o;throw new Error("script file not found: "+t)}function wn(t,e={}){t?.format===Wi&&za(t.version);let i=[],r=typeof e.workspacePath=="string"&&e.workspacePath?e.workspacePath:"",n=t?.format===Wi&&t.assets,o=xl(t?.controlGuidChanges),s=Lr(t?.scriptSync),a=n?null:xi(t,{warnings:i}),l={server:n&&t.assets.server?xi(t.assets.server,{warnings:i}):Il(Ge),client:n&&t.assets.client?xi(t.assets.client,{warnings:i}):Il(fe)};a&&(l[Xi(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||Nr;!t?.meta?.name&&l.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(l.server.meta.name=H0);let h=[],m=new Set;function g(){m.clear(),or(l.server.root,m),or(l.client.root,m,{skipServerContainer:!0});for(let b of h)Ht(b.guid)&&m.add(Number(b.guid))}function v(b=0){g();let k=Ht(b)&&!m.has(Number(b))?Number(b):ai(m);return m.add(k),k}function w(b){let k=Xo(b),O=v(k.guid);return{...k,guid:O,id:String(O)}}A(V0(t));let S=mn(t?.serverLogic),x=null,F="",I=1,z=1;function $(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[Xi(u)];function G(b){if(!b)return null;for(let[k,O]of[["server",l.server],["client",l.client]]){let B=Ve(O.root,b);if(B&&B.kind!=="server-container")return{key:k,node:B}}return null}function _(b){if(!b.controlId)return null;let k=b.controlAsset===fe?"client":b.controlAsset===Ge?"server":null;if(k){let O=Ve(l[k].root,b.controlId);return O&&O.kind!=="server-container"?{key:k,node:O}:null}return G(b.controlId)}function T(){for(let b of h)b.controlId&&!_(b)&&(b.controlId="",b.controlAsset="")}function y(b){if(!Ht(b))return null;for(let[k,O]of[[Ge,l.server],[fe,l.client]]){let B="";if(Ae(O.root,Y=>{!B&&(Y.scriptMappingIds||[]).includes(Number(b))&&(B=Y.id)}),B)return{controlId:B,controlAsset:k}}return null}function N(b,k,O){let B=l[Xi(b.controlAsset)],Y=B&&Ve(B.root,b.controlId);Y&&(Y.scriptMappingIds=(Y.scriptMappingIds||[]).map(X=>Number(X)===Number(k)?Number(O):X))}T();function C(){return h.map(b=>{let k=_(b),O=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||O,controlName:k?.node.name||"",assetType:O,assetLabel:k?Sl[O]:"",mounted:!!k})})}function d(){let b=[],k=(O,B)=>{Ae(O.root,Y=>{Y.kind!=="server-container"&&b.push(se({id:Y.id,name:Y.name,kind:Y.kind,assetType:B,assetLabel:Sl[B]}))})};return k(l.server,Ge),k(l.client,fe),b}function E(b){let k=[];return Ae(b.root,O=>{O.kind!=="server-container"&&k.push(JSON.stringify({kind:O.kind,guid:O.guid,name:O.name,text:O.text??null,imageId:O.imageId??null,imageSource:O.imageSource??null,imageType:O.imageType??null,fontSize:O.fontSize??null,adaptiveFontSize:O.adaptiveFontSize??null,minimumFontSize:O.minimumFontSize??null,fontColor:O.fontColor??null,bgColor:O.bgColor??null,imageColor:O.imageColor??null,fillType:O.fillType??null,fillAmount:O.fillAmount??null,syncAllDevices:O.syncAllDevices!==!1,transformByPlatform:O.transformByPlatform||null}))}),k.join("/")}let D=E(sr()),V=E(Ni());function H(b){let k=E(b);return b.meta?.assetType===fe?k===D:k===V}function Z(b,k){return String(b||"").replace(/[\\/:*?"<>|]/g,"-").trim()||k}function ne(b){let k=Z(f(),Nr),O=b.meta?.assetType===fe?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${k} \xB7 ${O}`}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 td(l.server,l.client,{scripts:h,fileName:`${Z(f(),Nr)} \xB7 \u6574\u5408\u5305.gia`})}function be(){let b=k=>({type:k.meta.assetType,name:k.meta.name,sourceFile:k.meta.sourceFile||""});return{format:Wi,name:f(),activeAssetType:u,assets:{server:b(l.server),client:b(l.client),scripts:C()}}}function ge(){return se({format:Wi,version:4,meta:{name:f()},activeAssetType:u,serverLogic:S,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=gd(b);if(k.workspace=X0(r),k.save=be(),k.scripts=C(),k.mountTargets=d(),k.serverLogic=S,k.migrationWarnings=[...i],k.controlGuidChanges=se(o),u===fe){let O=_r(b,!0);k.clientGuidAutofill={count:O.length,templateCount:O.filter(({parent:B})=>B?.kind==="server-container").length,selectedOffset:O.findIndex(({node:B})=>B.id===k.selectedId)}}return k.scriptSync=se(s),su(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,O=""){let B=String(k||"");if(B){let Y=O===fe?fe:O===Ge?Ge:"";if(!_({controlId:B,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=B}function gt(b){let k=ce(b);if(b.op==="addScript"){let O=w({path:String(b.path||""),source:String(b.source||""),controlId:"",controlAsset:""});b.controlId!==void 0&&b.controlId!==""&&Se(O,b.controlId,b.controlAsset),h.push(O)}else if(b.op==="updateScript"){let O=h.find(B=>B.id===b.id);if(!O)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${b.id}`);b.controlId!==void 0&&Se(O,b.controlId,b.controlAsset),b.path!==void 0&&(O.path=String(b.path)),b.source!==void 0&&(O.source=String(b.source))}else if(b.op==="removeScript"){let O=h.length;if(h=h.filter(B=>B.id!==b.id),h.length===O)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${b.id}`)}return k.version+=1,ee()}function qt(b){let k=ce(b),O=Ve(k.root,b.id??k.selectedId);if(!O||O.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 B=Eh(b.guid);if(Yo(O.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?_r(k,!0).map(({node:Q})=>Q):[O],he=B-X.indexOf(O),xe=X.map((Q,Pe)=>({node:Q,oldGuid:Yo(Q.guid),newGuid:Eh(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 ni=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 ki=new Map([...We.filter(Q=>!ni.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(ki.has(Q))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${Q} \u5DF2\u88AB\u300C${ki.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 vt=Q?.[Pe];(typeof vt=="number"||typeof vt=="string"&&/^\d+$/.test(vt.trim()))&&Ne.has(Number(vt))&&Ne.get(Number(vt))!==Number(vt)&&Ot.push({owner:Q,key:Pe,project:jt.project,oldGuid:Number(vt),newGuid:Ne.get(Number(vt))})};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 $r=Y?xh():"",Je=bh(h);for(let{node:Q,oldGuid:Pe,newGuid:jt}of Bt)Q.guid=jt,o.push({id:xh(),controlAsset:u,controlId:Q.id,controlName:Q.name,oldGuid:Pe,newGuid:jt,scriptSignature:Je,...$r?{batchId:$r}:{}});let kn=new Set([k]);for(let{owner:Q,key:Pe,project:jt,newGuid:vt}of Ot)Q[Pe]=typeof Q[Pe]=="string"?String(vt):vt,kn.add(jt);for(let Q of kn)Q.version+=1;return ee()}function Re(b){let k=ce(b);if(!Array.isArray(b.changeIds)||!b.changeIds.length||b.changeIds.some(B=>typeof B!="string"||!o.some(Y=>Y.id===B)))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 O=new Set(b.changeIds);return o=o.filter(B=>!O.has(B.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=Lr(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 S=mn(b.logic),k.version+=1,ee()}if(b.op==="addScript"||b.op==="updateScript"||b.op==="removeScript")return gt(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 O=Il(u);return O.version=k.version+1,l[Xi(u)]=O,o=o.filter(B=>B.controlAsset!==u),T(),ee()}return Ga(j(),b),T(),ee()}function yt(b){return h.filter(k=>{let O=_(k);return!!(O&&O.key==="client"==(b===fe))})}function de(b="json",k=""){let O=R(b,k);if(o.length&&!["save","archive"].includes(String(b).toLowerCase())){let B=o.map(Y=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${Sl[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`);O.warnings=[...new Set([...O.warnings||[],...B])]}return O}function R(b="json",k=""){let O=String(b).toLowerCase();if(O==="save"||O==="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(O==="save-gia"||O==="archive-gia"){let X=[],he=[],xe=(Ne,ni="")=>{let We=de(Ne,ni);X.push(se({filename:We.filename,mimeType:We.mimeType,encoding:We.encoding,data:We.data,warnings:We.warnings||[]})),he.push(...We.warnings||[])},Bt=(Ne,ni)=>{let We=l[Xi(Ne)],ki=Ne===u,Ot=h.some(ke=>ke.controlAsset===Ne&&ke.controlId);if(!ki&&H(We)&&!Ot){he.push(ni);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(O==="gia-combined"||O==="combined-gia"||O==="combined"){let X=ve();return se({filename:`${Z(f(),Nr)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:X.buffer.toString("base64"),warnings:[...new Set(X.warnings||[])]})}if(O==="scripts"){let X=se({format:B0,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(),Nr)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:he.toString("base64"),warnings:[]})}if(O==="scripts-gia"||O==="scriptsgia"){let X=nd(h);return se({filename:`${Z(f(),Nr)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:X.buffer.toString("base64"),warnings:X.warnings})}if(O==="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=Pr(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 B=k?l[Xi(k)]:j(),Y=ne(B);if(O==="json"){let X=se({...B,scripts:yt(B.meta.assetType),controlGuidChanges:o.filter(xe=>xe.controlAsset===B.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(O==="gia"){let X=ed(B,B.meta.assetType===fe?{scripts:yt(fe)}:{}),he=B.meta.assetType===fe?[]:yt(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 O=Xo(k);if(!O.path&&!O.source)continue;let B=O.controlId?null:y(O.guid),Y=w(B?{...O,...B}:O);B&&Y.guid!==O.guid&&N(B,O.guid,Y.guid),Y.controlId&&!_(Y)&&(Y.controlId="",Y.controlAsset=""),h.push(Y)}}function P(b,k,O=""){let B=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(B==="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===Wi&&X?.assets){za(X.version);let ke=wn(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||Pr(O).replace(/\.json$/i,"")||c),S=Ke.serverLogic,h=Ke.assets.scripts,o=Ke.controlGuidChanges,s=Ke.scriptSync,m.clear(),se({snapshot:ee(),warnings:he,metadata:{format:Wi}})}}else{if(B==="lua")return h.push(w({path:Pr(O||"imported.lua"),source:Y.toString("utf8"),controlId:""})),se({snapshot:ee(),warnings:he,metadata:{assetType:"lua-script"}});if(B==="gia"){if(od(Y)){let Je=ad(Y);return A(Je.scripts),se({snapshot:ee(),warnings:Je.warnings,metadata:Je.metadata})}let ke=ld(Y);X=ke.project,he=ke.warnings,xe=ke.metadata,ke.clientProject&&(l.client=xi(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,$r=(Je,kn)=>{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:kn})}})};$r(ke.project,ke.project.meta.assetType),$r(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=xi(X,{warnings:he}),ni=xl(X?.controlGuidChanges);if(ni.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=xl([...o.filter(ke=>ke.controlAsset!==Ne.meta.assetType),...ni]);i=[...he];let ki=Xi(Ne.meta.assetType);l[ki]=Ne,o=We,u=Ne.meta.assetType;let Ot=l[ki];return O&&(Ot.meta.name=Pr(O).replace(/\.(json|gia)$/i,"")||Ot.meta.name,Ot.meta.sourceFile=Pr(O),Ot.meta.sourceFormat=B),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 Ga(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=z0(W0(b.path,r),"utf8")}catch(O){throw new Error(`\u811A\u672C ${b.path} \u8BFB\u53D6\u5931\u8D25: ${O?.message||O}`)}return k}function re(b={}){let k=$(b.canvasId);k&&(F=k),b.playerCount!==void 0&&b.playerCount!==null&&b.playerCount!==""&&(I=Vi(b.playerCount),z>I&&(z=1)),b.viewPlayerIndex!==void 0&&b.viewPlayerIndex!==null&&b.viewPlayerIndex!==""&&(z=ri(b.viewPlayerIndex,I)),x&&gl(x);let O=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||""}}}),B=Y=>O.filter(X=>{let he={controlId:X.controlId,controlAsset:X.controlAsset},xe=X.controlId?_(he):null;return!!(xe&&xe.key===Y)});return x=sh(l.server,{templatesProject:l.client,scripts:O,sceneScripts:B("server"),templateScripts:B("client"),serverConfig:{logic:S},canvasId:F,playerCount:I,viewPlayerIndex:z,language:b.language||""}),ie(b)}function oe(b,k={}){let O=$(b);if(!O)throw new Error("playSetCanvas requires canvasId");return re({...k,canvasId:O})}function ie(b={}){if(!x)return se({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let k=cl(x,b);return k.running=!0,k.logs=wl(k.logs),k.serverLogs=wl(k.server?.logs||[]),k.serverVars=q0(k.server,k.playerCount||1),k}function Me(b,k={}){return x||re(),Uo(x,b),k.observe===!1?se({running:!0,time:x.runtime.clock.time,frame:x.runtime.clock.frame,paused:!!x.debugPaused,levelTimePaused:!!x.runtime.clock.paused,playerCount:x.playerCount||1,viewPlayerIndex:x.viewPlayerIndex||1}):ie(k)}function Oe(b=0){re();let k=Math.max(0,Number(b)||0);for(let O=0;O<k;O++)Uo(x,1/30);return ie()}function Rt(){return x&&gl(x),x=null,F="",I=1,z=1,se({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function Rp(b,k={}){let O=zr();return z=ll(O,b),k.observe===!1?null:ie(k)}function Op(b,k={}){if(!x)throw new Error("play session has not started");return fl(x,b),k.observe===!1?null:ie(k)}function Np(b,k={}){if(!x)throw new Error("play session has not started");return dl(x,b),k.observe===!1?null:ie(k)}function Pp(b,k,O,B={}){if(!x)throw new Error("play session has not started");return vn(x,b,k,O,B),B.observe===!1?null:ie(B)}function Mp(b={}){return x&&Ho(x).pause(),b.observe===!1?null:ie(b)}function Fp(b={}){return x&&Ho(x).resume(),b.observe===!1?null:ie(b)}function zr(){if(!x)throw new Error("play session has not started");return x}function Dp(b,k){let O=zr();if(!b&&!k){let B=ie();return se({vars:B.serverVars||[]})}return se({entityType:String(b||""),name:String(k||""),value:mh(O,b,k)})}function zp(b,k,O){let B=zr();return pl(B,b,k,O),ie()}function $p(b,k=[],O="PlayerSelf"){let B=zr();return ml(B,b,k,O),ie()}function Lp(){let b=ie();return se({events:b.history||[],case:Wd(b.history||[],{playerCount:b.playerCount||1})})}function Gp(b={}){let k=ie(),O=gn({name:b.name||"",dt:b.dt,playerCount:b.playerCount||k.playerCount||1,events:b.events||k.history||[],asserts:b.asserts||[]});return se(O)}function qp(b,k={}){let O=gn(b);re({...k,playerCount:k.playerCount||O.playerCount||1});let B=zr();B.recording=!1;try{return vh(Ho(B),b)}finally{B.recording=!0}}function Bp(){if(!x)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let b=x.runtime.clock;return{running:!0,paused:!!x.debugPaused,levelTimePaused:!!b.paused,time:b.time,frame:b.frame,playerCount:x.playerCount||1,viewPlayerIndex:x.viewPlayerIndex||1}}let Zl={get:ee,patch:ut,setWorkspace:U,exportData:de,importData:P,pick:M,playStart:re,playSetCanvas:oe,playSetView:Rp,playGet:ie,playStatus:Bp,playStep:Me,playRun:Oe,playStop:Rt,playKey:Op,playClick:Np,playPointer:Pp,playPause:Mp,playResume:Fp,playServerGet:Dp,playServerSet:zp,playServerSend:$p,playHistory:Lp,playSaveCase:Gp,playRunCase:qp,archiveData:ge};return Object.defineProperty(Zl,"_project",{enumerable:!1,get:j}),Zl}import{createRequire as Z0}from"node:module";function _l(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 Ch(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 kh(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 K0(t){return!!t?.border&&Object.values(t.border).some(e=>Number.isFinite(e)&&e>0)}function Th(t,e){let i=typeof e=="object"?e?.Name:e;return K0(t)&&i!=="Basic"?"Stretch":"Basic"}function Rh(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 J0(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 Ah=new WeakMap;function Oh(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=Ah.get(t);if(!h){let x=n(t.width,t.height),F=x.getContext("2d");F.drawImage(t,0,0),h=F.getImageData(0,0,t.width,t.height),Ah.set(t,h)}let m=f.createImageData(l,u),g=h.data,v=(x,F,I,z,$,j)=>{let{source:G,target:_}=J0(F,I,z,$);return Array.from({length:j},(T,y)=>{let N=(y+.5)*$/j,C=N<_[1]?0:N<_[2]?1:2,d=_[C+1]>_[C]?(N-_[C])/(_[C+1]-_[C]):0,E=Math.max(0,Math.min(x-1,(G[C]+d*(G[C+1]-G[C]))*x/F-.5)),D=Math.floor(E);return[D,Math.min(x-1,D+1),E-D]})},w=v(t.width,e.width,e.border.left,e.border.right,o,l),S=v(t.height,e.height,e.border.top,e.border.bottom,s,u);for(let x=0;x<u;x++)for(let F=0;F<l;F++){let[I,z,$]=w[F],[j,G,_]=S[x],T=(j*t.width+I)*4,y=(j*t.width+z)*4,N=(G*t.width+I)*4,C=(G*t.width+z)*4,d=g[T+3]*(1-$)*(1-_),E=g[y+3]*$*(1-_),D=g[N+3]*(1-$)*_,V=g[C+3]*$*_,H=d+E+D+V,Z=(x*l+F)*4;m.data[Z+3]=Math.round(H);for(let ne=0;ne<3;ne++)m.data[Z+ne]=H?Math.round((g[T+ne]*d+g[y+ne]*E+g[N+ne]*D+g[C+ne]*V)/H):0}return f.putImageData(m,0,0),c}function Nh(t){let e=Number(t)>>>0;return`rgba(${e>>>16&255},${e>>>8&255},${e&255},${(e>>>24)/255})`}function Ph(t,e,i,r,n=Ur){let o=e.textLayout;if(!o?.richLines||i<=0||r<=0)return;let s=e.horizontalAlignment==="Right"?1:e.horizontalAlignment==="Middle"?.5:0,a=e.verticalAlignment==="Bottom"?1:e.verticalAlignment==="Middle"?.5:0,l=e.kind==="textwindow"?e.scroll:null,u=o.visibleLineCount??o.richLines.length,c=o.visibleContentHeight??o.contentHeight,f=e.kind==="textwindow"&&o.contentHeight>r?-(l?.offset||0):a*(r-c);t.save(),t.beginPath(),t.rect(0,0,i,r),t.clip(),t.textAlign="left",t.textBaseline="alphabetic",t.lineJoin="round",t.strokeStyle=Nh(e.outlineColor??4278190080);for(let h=0;h<u;h++){let m=o.richLines[h],g=f+m.top;if(g+m.height<0||g>r)continue;let v=2+s*(o.textWidth-m.width);for(let w of m.runs)t.font=Bn(w,n||Ur),t.fillStyle=Nh(w.color??e.fontColor??4294967295),e.enableOutline&&(t.lineWidth=Math.max(2,w.fontSize*.12),t.strokeText(w.text,v+w.x,g+m.baseline)),t.fillText(w.text,v+w.x,g+m.baseline)}t.restore()}var Q0=Z0(import.meta.url),e1=[0,-.5,.5,.5,-.5,.5],t1=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],i1=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],El=Buffer.from([137,80,78,71,13,10,26,10]),r1=new Set(["image","textbox","textwindow","button","grid"]),Wo={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"},Ko=null;function Sn(){if(Ko)return Ko;try{Ko=Q0("@napi-rs/canvas")}catch(t){let e=t?.message||String(t);throw new Error(`Host screenshot renderer requires @napi-rs/canvas (${e})`)}return Ko}function me(t,e=0){let i=Number(t);return Number.isFinite(i)?i:e}function Zo(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 Ki(t,e=1){return`rgba(${t.r},${t.g},${t.b},${Math.max(0,Math.min(1,t.a*e))})`}function Fh(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 Dh(t){let e=Buffer.from(t.toBuffer("image/png"));if(e.length<El.length||!e.subarray(0,El.length).equals(El))throw new Error("Host screenshot renderer did not produce a PNG");return e}function n1(t){return t==="triangle"?e1:t==="fourstar"?t1:i1}function o1(t,e,i,r,n){let o=n1(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=Ki(n),t.fill()}function Cl(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 s1(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 zh(t,e,i,r){let n=Zo(e.bgColor,16777215);t.fillStyle=Ki(n),t.fillRect(-i/2,-r/2,i,r);let o=e.textLayout||Wt(e,i,r);if(o.richLines){t.save(),t.translate(-i/2,-r/2),Ph(t,{...e,textLayout:o},i,r,ur()),t.restore();return}let s=o.fontSize,a=Zo(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 ${ur()}`,t.fillStyle=Ki(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 w=Zo(e.outlineColor,4278190080);t.strokeStyle=Ki(w),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.slice(0,o.visibleLineCount??o.lines.length),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 w=0;w<m.length;w+=1){let S=v+w*g;c&&(S+g<-r/2||S>r/2)||(e.enableOutline&&t.strokeText(m[w],f,S),t.fillText(m[w],f,S))}t.restore()}function a1(t,e,i,r){let n=Rr(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 $h(t,e,i,r){t.beginPath(),s1(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 Lh(t,e,i,r,n){let o=Zo(e.imageColor,4294967295),s=Nn(e.imageId,e.imageSource),a=n?.images?.get(s);if(e.primitive==="sprite"&&a){let l=n.imageMetadata?.get(s),u=Th(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"?Oh(a,l,i,r,Sn().createCanvas):a;f=kh(h,e.imageColor,Sn().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=Ki(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=Ki(o),t.lineWidth=7,t.stroke();return}if(e.primitive==="triangle"||e.primitive==="fourstar"||e.primitive==="fivestar"){o1(t,e.primitive,i,r,o);return}t.fillStyle=Ki(o),t.fillRect(-i/2,-r/2,i,r)}function l1(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(Cl(t,e,i),e.kind==="textbox"||e.kind==="textwindow")zh(t,e,n,o);else if(e.kind==="button")$h(t,e,n,o);else if(e.kind!=="grid"){let s=_l(e,n,o);s&&(t.beginPath(),t.rect(s.x,s.y,s.width,s.height),t.clip()),Lh(t,e,n,o,r)}a1(t,e,n,o),t.restore()}function Gh(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 u1(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 Mh(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 c1(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(!r1.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?u1(a,Mh(m)):Mh(m),v=u;if(m.clipToParent&&a&&l){let x=l.sourceWidth/2,F=l.sourceHeight/2;v=[...u,[[-x,-F],[x,-F],[x,F],[-x,F]].map(([I,z])=>({x:a.a*I+a.c*z+a.tx,y:a.b*I+a.d*z+a.ty}))]}let w=cr(m,g),S=w?[...c,w]:c;m.kind!=="grid"&&n(m,g,v,S),o(String(m.id),g,m,v,S),m.kind==="grid"&&n(m,g,v,S)}}return o("",null),r}function qh(t,e,i,r={}){return h1(c1(t),e,i,r)}function f1(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 d1(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 w=(e.x+g+.5)/r.pixelRatio,S=f.a*w+f.c*m+f.tx,x=f.b*w+f.d*m+f.ty,F=Du(S,x,i),I=Math.round(s[v+3]*F)/255;if(!I)continue;let z=c[v+3]/255,$=I+z*(1-I);for(let j=0;j<3;j++)c[v+j]=Math.round((s[v+j]*I+c[v+j]*z*(1-I))/$);c[v+3]=Math.round($*255)}}t.ctx.save(),t.ctx.setTransform(1,0,0,1,0,0),t.ctx.putImageData(u,a,l),t.ctx.restore()}function kl(t,e,i,r,n=l1){for(let o of e){if(o.item){n(t.ctx,o.item,i.height,r);continue}let s=f1(o.mask,t,i);if(!s)continue;let a=Sn().createCanvas(s.width,s.height),l=a.getContext("2d");l.setTransform(i.pixelRatio,0,0,i.pixelRatio,-s.x,-s.y);let u={canvas:a,ctx:l,x:s.x,y:s.y};kl(u,o.children,i,r,n),d1(t,u,o.mask,i)}}function h1(t,e,i,r={}){let{createCanvas:n}=Sn(),o=Fh(e,i,r.scale),s=n(o.pixelWidth,o.pixelHeight),a=s.getContext("2d");a.scale(o.pixelRatio,o.pixelRatio),r.background!=="transparent"&&Gh(a,o.width,o.height);let l=Array.isArray(t)?t:[],u={images:r.images,imageMetadata:r.imageMetadata,tints:new Map};return kl({canvas:s,ctx:a,x:0,y:0},Ns(l),o,u),{data:Dh(s),width:o.width,height:o.height,pixelWidth:o.pixelWidth,pixelHeight:o.pixelHeight}}function Bh(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 Jo(t,e,i){let r=String(e||"");if(!r)return;t.font=`10px ${ur()}`,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 p1(t,e,i,r){let n=Bh(e);if(n.width<=0||n.height<=0)return;t.save(),Cl(t,n,i);let o=-n.width/2,s=-n.height/2;if(e.kind==="image"){t.save();let a=Math.max(0,me(e.width,n.width)),l=Math.max(0,me(e.height,n.height));t.scale(a?n.width/a:1,l?n.height/l:1);let u=e.enableFill?_l(e,a,l):null;u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),Lh(t,e,a,l,r),t.restore()}else if(e.kind==="textbox"||e.kind==="textwindow")zh(t,e,n.width,n.height);else if(e.kind==="button")$h(t,e,n.width,n.height),Jo(t,e.name||Wo.button,n.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(o,s,n.width,n.height),t.strokeRect(o,s,n.width,n.height),Jo(t,e.name||Wo.cursor,n.width);else if(e.kind==="grid"){t.strokeStyle="rgba(106,146,189,0.55)",t.strokeRect(o,s,n.width,n.height),t.beginPath();for(let a=20;a<n.width;a+=20)t.moveTo(o+a,s),t.lineTo(o+a,s+n.height);for(let a=20;a<n.height;a+=20)t.moveTo(o,s+a),t.lineTo(o+n.width,s+a);t.stroke(),Jo(t,e.name||Wo.grid,n.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(o,s,n.width,n.height),Jo(t,e.name||Wo[e.kind]||e.kind,n.width)):(t.strokeStyle="rgba(78,165,230,0.42)",t.strokeRect(o,s,n.width,n.height));t.restore()}function jh(t,e={}){let{createCanvas:i}=Sn(),r=t?.canvas||{},n=Fh(r.width||1600,r.height||900,e.scale),o=i(n.pixelWidth,n.pixelHeight),s=o.getContext("2d");s.scale(n.pixelRatio,n.pixelRatio),Gh(s,n.width,n.height,{checker:!0});let a=(Array.isArray(t?.boxes)?t.boxes:[]).filter(f=>f&&f.kind!=="server-container"&&f.visible!==!1&&f.visibleInHierarchy!==!1),l=t?.selectedId,u={images:e.images,imageMetadata:e.imageMetadata,tints:new Map};kl({canvas:o,ctx:s,x:0,y:0},Ns(a),n,u,p1);let c=a.find(f=>f.id===l);if(c&&c.kind!=="container"){let f=Bh(c);s.save(),Cl(s,f,n.height),s.strokeStyle="#61b9ff",s.lineWidth=2,s.strokeRect(-f.width/2,-f.height/2,f.width,f.height),s.restore()}return{data:Dh(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 m1,existsSync as Qo,openSync as g1,opendirSync as y1,readSync as v1,realpathSync as Mr,statSync as Uh}from"node:fs";import{basename as b1,dirname as Vh,isAbsolute as Tl,join as w1,relative as Hh,resolve as _n}from"node:path";var S1="qxqy-simulator-save",Yh=new Set(["node_modules",".git","dist",".dsh","coverage"]),xn=50,Xh=4096,Al=(t,e)=>{let i=Number(process.env[t]);return Number.isSafeInteger(i)&&i>0?i:e},x1=()=>({entries:Al("QXQY_SCAN_ENTRY_LIMIT",1e4),directories:Al("QXQY_SCAN_DIR_LIMIT",1e3),depth:Al("QXQY_SCAN_DEPTH_LIMIT",8)});function Rl(t=""){let e=_n(String(t||process.cwd()));if(!Qo(e))throw new Error(`workspace does not exist: ${e}`);if(!Uh(e).isDirectory())throw new Error(`workspace is not a directory: ${e}`);return Mr(e)}function In(t,e,i=!1){let r=Hh(t,e);if(!i&&!r||r.startsWith("..")||Tl(r))throw new Error("path must stay inside the configured workspace");return r}function Ei(t,e){let i=String(e||"").trim();if(!i||Tl(i))throw new Error("path must be a non-empty workspace-relative path");let r=Mr(_n(t)),n=_n(r,i);if(In(r,n),!Qo(n))throw new Error(`file does not exist: ${i}`);let o=Mr(n);return In(r,o),o}function mt(t,e){let i=String(e||"").trim();if(!i||Tl(i))throw new Error("path must be a non-empty workspace-relative path");let r=Mr(_n(t)),n=_n(r,i);In(r,n);let o=Vh(n);for(;!Qo(o);){let s=Vh(o);if(s===o)throw new Error("unable to resolve output directory");o=s}return In(r,Mr(o),!0),Qo(n)&&In(r,Mr(n)),n}function I1(t,e=Xh){let i=Buffer.alloc(e),r=g1(t,"r");try{let n=v1(r,i,0,e,0);return i.subarray(0,n).toString("utf8")}finally{m1(r)}}function Wh(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=y1(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()&&Yh.has(a.name)){n.skippedEntries+=1,a.isDirectory()&&(n.skippedDirectories+=1);continue}let l=w1(t,a.name);if(a.isDirectory()){if(Wh(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=Uh(l),c=I1(l);if(!c.includes(S1))continue;let f=c.match(/"name"\s*:\s*("(?:\\.|[^"\\])*")/)?.[1],h=b1(a.name,".json");if(f)try{h=JSON.parse(f)||h}catch{}i.push({path:Hh(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 es(t){let e=Rl(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:xn,headBytes:Xh,...x1()},policy:{excludedDirectories:[...Yh],hiddenEntries:!1,symlinks:!1,validatesJson:!1}};return Wh(e,e,i,0,r),i.sort((n,o)=>o.mtime-n.mtime||n.path.localeCompare(o.path)),r.matchedArchives=i.length,i.length>xn&&r.warnings.push(`\u53D1\u73B0 ${i.length} \u4E2A\u5B58\u6863\uFF0C\u4EC5\u663E\u793A\u4FEE\u6539\u65F6\u95F4\u6700\u65B0\u7684 ${xn} \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>xn||r.entryLimitReached||r.directoryLimitReached||r.depthLimitedDirectories>0,{bound:!0,workspace:e,archives:i.slice(0,xn),discovery:r}}import{readFileSync as _1}from"node:fs";import{homedir as E1}from"node:os";import{join as C1}from"node:path";var k1={"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 A1(t){let i=[...String(t||"").matchAll(/Request to set language:([A-Za-z0-9_-]+)/g)].at(-1)?.[1]?.toLowerCase();return k1[i]||null}function T1(){return C1(E1(),"AppData","LocalLow","miHoYo","\u539F\u795E","output_log.txt")}function Kh(t=T1()){try{return A1(_1(t,"utf8"))}catch{return null}}import{existsSync as Pl,lstatSync as R1,mkdirSync as Jh,readFileSync as ts,readdirSync as O1,realpathSync as Zh,renameSync as N1,rmSync as P1,statSync as ns,writeFileSync as Qh}from"node:fs";import{createHash as M1,randomUUID as ep}from"node:crypto";import{homedir as F1}from"node:os";import{basename as D1,dirname as is,isAbsolute as z1,join as rs,relative as $1}from"node:path";var Tt=t=>M1("sha256").update(t).digest("hex"),Ol=t=>Pl(t)?Tt(ts(t)):null,Nl=(t,e)=>{let i=$1(t,e);return!z1(i)&&i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)};function tp(t,e){let i=mt(t,e),r=i;for(;r!==t;){try{if(R1(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=is(r)}if(Pl(i)&&!ns(i).isFile())throw new Error("\u5B9E\u673A\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6");return i}function ip(t=rs(F1(),"AppData","LocalLow","miHoYo","\u539F\u795E","BeyondLocal")){let e=r=>{try{return O1(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=rs(t,r,"Beyond_Local_Save_Level");for(let o of e(n)){let s=rs(n,o,"external_lua_file","default_import_file");Pl(s)&&ns(s).isDirectory()&&i.push({uid:r,editorId:o,path:s})}}return{candidates:i}}var os=class{constructor(e){this.controller=e,this.plan=null,this.lastResult=null}preview(){let e=this.controller,i=e.studio.archiveData(),r=Lr(i.scriptSync);if(!r)throw new Error("\u8BF7\u5148\u914D\u7F6E\u5B9E\u673A\u811A\u672C\u76EE\u5F55");let n=Zh(e.activeWorkspacePath()),o=Zh(r.clientImportRoot);if(!ns(o).isDirectory())throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u4E0D\u5B58\u5728");let s=r.workspaceDir?Ei(n,r.workspaceDir):n;if(!ns(s).isDirectory())throw new Error("\u5DE5\u4F5C\u533A\u811A\u672C\u76EE\u5F55\u4E0D\u5B58\u5728");if(Nl(s,o)||Nl(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=An(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=tp(o,g),w=v.toLowerCase();a.set(w,(a.get(w)||0)+1);let S=null,x="";try{S=ts(Ei(n,h),"utf8")}catch(z){x=z.message}if(!c.source.trim()&&S===null)throw new Error(x);let F=c.source.trim()?c.source:S,I=Ol(v);return{...f,target:v,targetRelative:g,source:F,diskSource:S,diskError:x,sourceMismatch:!!(c.source.trim()&&S!==null&&c.source!==S),beforeSource:I===null?"":ts(v,"utf8"),beforeHash:I,sourceHash:Tt(F),status:I===null?"\u65B0\u589E":I===Tt(F)?"\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:ep(),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=mt(n.workspace,a);if(Nl(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=tp(n.root,c.targetRelative);if(Ol(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=mt(n.workspace,`${a}/${c.targetRelative}`);Jh(is(m),{recursive:!0}),Qh(m,ts(h),{flag:"wx"})}if(Jh(is(h),{recursive:!0}),f=rs(is(h),`.${D1(h)}.${ep()}.tmp`),Qh(f,c.source,{flag:"wx"}),Ol(h)!==c.beforeHash)throw new Error("\u76EE\u6807\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5");N1(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&&P1(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 L1,randomUUID as G1}from"node:crypto";import{mkdir as q1,open as B1,readFile as j1,rename as V1,rm as Ml,stat as U1,writeFile as H1}from"node:fs/promises";import{homedir as Fl}from"node:os";import{join as Fr,resolve as Y1}from"node:path";import{setTimeout as X1}from"node:timers/promises";var Dl=t=>L1("sha256").update(t).digest("hex");function ss(t){return Fr(process.platform==="win32"?process.env.LOCALAPPDATA||Fr(Fl(),"AppData","Local"):process.platform==="darwin"?Fr(Fl(),"Library","Caches"):process.env.XDG_CACHE_HOME||Fr(Fl(),".cache"),"beyond-simulator",t)}var Ci=class{constructor({cacheDir:e,source:i,version:r,extension:n,accepts:o,fetch:s=globalThis.fetch,timeout:a=12e3}){this.directory=Fr(Y1(e),r,Dl(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 j1(e);return{data:i,...await this.decode(i),etag:`"${Dl(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=Fr(this.directory,`${e}.${this.extension}`),n=!i&&await this.cached(r);if(n)return n;await q1(this.directory,{recursive:!0});let o=`${r}.lock`,s=Date.now()+3e4,a;for(;!a;)try{a=await B1(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 U1(o)).mtimeMs>6e4&&await Ml(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 X1(80)}let l=`${r}.${G1()}.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 H1(l,h,{flag:"wx"}),await V1(l,r),{data:h,...m,etag:`"${Dl(h)}"`}}finally{try{await Ml(l,{force:!0})}finally{await a.close(),await Ml(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 W1}from"node:crypto";import{createCanvas as K1,loadImage as rp}from"@napi-rs/canvas";var as=class extends Ci{constructor({cacheDir:e,source:i=Rn,fetch:r=globalThis.fetch}){super({cacheDir:e,source:i,fetch:r,version:"border-v1",extension:"json",accepts:n=>oi(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=Rh(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 $l=20*1024*1024,J1=Buffer.from("89504e470d0a1a0a","hex");function np(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 Z1(){return process.env.QXQY_IMAGE_CACHE_DIR||ss("images")}function zl(t){if(t.length<24||t.length>$l||!t.subarray(0,8).equals(J1))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 Ll=class t extends Ci{constructor({cacheDir:e=Z1(),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"?iu:Rn),version:o==="Prefab"?Gr:fs,extension:"png",accepts:s=>oi(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 zl(e),{image:await rp(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 as({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`,$l,i,r);zl(l);let u=Tn(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`,$l,i,r),this.metadata(e,{refresh:r})]);zl(n);let s=await rp(n),a=o.raw?Ch(s,o.raw,K1):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&&oi(c.imageId,c.imageSource)).map(c=>[Nn(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 np(this.get(f.imageId,f),l);r.set(c,h.image);let m=await np(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}}},Q1;function Gl(){return Q1||=new Ll}async function op(t,e,i=Gl()){let r=new URL(t.url,"http://localhost");if(r.pathname!==On.slice(0,-1)&&!r.pathname.startsWith(On))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(`^${On}(${fs}|${Gr})/([0-9]+)\\.(png|json)$`));if(!n)throw Object.assign(new Error("Unknown image resource"),{status:404});let o={imageSource:n[1]===Gr?"Prefab":"StaticReference"};if(n[3]==="json"){let{meta:l}=await i.metadata(Number(n[2]),o),u=JSON.stringify(l),c=`"${W1("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 ev,mkdirSync as sp,readFileSync as tv,renameSync as iv,rmSync as rv,writeFileSync as ql}from"node:fs";import{randomUUID as up}from"node:crypto";import{dirname as ap,join as nv}from"node:path";function lp(t,e){let i=`${t}.${up()}.tmp`;try{ql(i,e,{flag:"wx"}),iv(i,t)}finally{rv(i,{force:!0})}}var ls=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=wh(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=mt(s,c.path);if(ev(m)){f.file=Ei(s,c.path);let g=tv(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=Sh(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=up(),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=wn(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?mt(l,`.qxqy-guid-sync-backups/${r.id}`):"",c=[];try{for(let h of a){let m=nv(u,`${h.id}.lua`);sp(ap(m),{recursive:!0}),ql(m,h.fileBefore,{flag:"wx"})}let f=mt(l,`.qxqy-guid-sync-backups/${r.id}/before.save.json`);sp(ap(f),{recursive:!0}),ql(f,JSON.stringify(r.archive),{flag:"wx"});for(let h of a)lp(h.file,h.source),c.push(h);this.controller.studio.importData("json",s)}catch(f){let h=[];for(let m of c.reverse())try{lp(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 fv=Math.max(1e3,Number(process.env.QXQY_PLAY_TIMEOUT_MS)||8e3),dv=8e3;function cp(){let t=new Error("operation aborted");return t.name="AbortError",t}function jl(t){if(t!=="manual"&&t!=="realtime")throw new Error("clockMode must be manual or realtime");return t}var us=class{constructor(e="",{imageAssets:i=Gl(),clockMode:r="realtime"}={}){Xt(),this.workspacePath=e?Rl(e):"",this.studio=wn(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 os(this),this.controlGuidSync=new ls(this),this.imageAssets=i,this.defaultClockMode=jl(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 ip();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==="save"){if(!Number.isInteger(i.expectedRevision))throw new Error("expectedRevision is required");let r=i.path??this.archivePath;if(typeof r!="string"||!r.trim())throw new Error("script sync save requires a workspace-relative path for a new archive");return this.saveForScriptSync(r,i.expectedRevision)}if(e==="preview")return this.scriptSync.preview();if(e==="apply")return this.scriptSync.apply(i);throw new Error(`unknown script sync action: ${e}`)}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=Ei(this.activeWorkspacePath(),this.archivePath);if(Tt(Bl(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=mt(this.activeWorkspacePath(),e);if(sv(r)){let n=this.archivePath?mt(this.activeWorkspacePath(),this.archivePath):"";if(r!==n||Tt(Bl(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 es(this.workspacePath)}loadArchive(e){let i=this.activeWorkspacePath();if(!i)throw new Error("workspace is not bound");let r=Ei(i,e),n=Bl(r),o=this.studio.importData("json",n.toString("base64"),uv(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=mt(r,i);av(cv(n),{recursive:!0});let o=Buffer.from(JSON.stringify(this.studio.archiveData(),null,2)+`
127
+ `,"utf8");return lv(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 ov(new URL("./worker.js",import.meta.url),{type:"module",workerData:{localFont:Xt()?.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=fv){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,cp()),this.terminateWorker(cp())},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=Kh();n&&(i={...i,language:n})}if(e==="start"){let n=jl(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=jl(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,dv),r=await this.imageAssets.prepare(i.scene?.nodes,e),n=qh(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=jh(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 Ji}from"@deepseek-ai/dsh-tools";import{existsSync as hp,realpathSync as fp}from"node:fs";import{isAbsolute as Vl,relative as dp,resolve as cs}from"node:path";function pp(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=fp(cs(t)),n=Vl(i)?cs(i):cs(r,i),o=dp(r,n);if(!o||o.startsWith("..")||Vl(o))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");if(!hp(n))throw new Error(`\u5B58\u6863\u4E0D\u5B58\u5728: ${i}`);let s=fp(n),a=dp(r,s);if(!a||a.startsWith("..")||Vl(a))throw new Error("\u5B58\u6863\u8DEF\u5F84\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185");return s}function mp(t){if(!t)return{bound:!1,archives:[]};let e=cs(t);return hp(e)?es(e):{bound:!1,archives:[]}}var gp=32*1024*1024;function hv(t){if(t.length<8||t.length>gp)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 Ul=class extends Ci{constructor({cacheDir:e=process.env.QXQY_AUDIO_CACHE_DIR||ss("audio"),fetch:i=globalThis.fetch,source:r=Zd}={}){super({cacheDir:e,fetch:i,source:r,version:rl,extension:"mp3",accepts:n=>Go(n)!==null,timeout:2e4})}decode(e){return hv(e),{}}produce(e,i,r){return this.download(`audio/${e}.mp3`,gp,i,r)}},pv;function mv(){return pv||=new Ul}async function yp(t,e,i=mv()){let r=new URL(t.url,"http://localhost");if(r.pathname!==Lo.slice(0,-1)&&!r.pathname.startsWith(Lo))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(`^${Lo}${rl}/([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 gv="https://github.com/1475505/miliastra-beyond-simulator",yv="https://api.github.com/repos/1475505/miliastra-beyond-simulator/releases?per_page=100",vv=t=>/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(t),bp=(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 vp(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 bv(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=vp(r.html_url,"tag"),a=vp(n.browser_download_url,"download");!vv(o)||!s||!a||i.push({version:o,url:s,downloadUrl:a,publishedAt:r.published_at||null})}return i.sort((r,n)=>bp(n.version,r.version))[0]||null}function wp({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(yv,{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=bv(await a.json(),t),u=l?bp(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||`${gv}/releases`,downloadUrl:l?.downloadUrl||null,checkedAt:r(),publishedAt:l?.publishedAt||null},n})().finally(()=>{o=null}),o)}}import{execFile as wv}from"node:child_process";import{win32 as Sv}from"node:path";import{promisify as xv}from"node:util";var Iv=xv(wv),Sp=t=>["localhost","127.0.0.1","::1","[::1]","::ffff:127.0.0.1"].includes(t);function Hl(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 xp(t){try{return Sp(t.socket?.remoteAddress)&&Sp(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 _v({platform:t=process.platform,env:e=process.env,execFile:i=Iv}={}){let r;return()=>r||=(async()=>{try{let n="",o="browser",s={windowsHide:!0,timeout:2500,maxBuffer:4096,encoding:"utf8"};if(t==="win32"){let a=Sv.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=Hl(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(Hl).find(Boolean)||"",o="macos-ui"}else n=[e.LANGUAGE?.split(":")[0],e.LC_ALL,e.LC_MESSAGES,e.LANG].map(Hl).find(Boolean)||"",o="host-locale";return{language:n,source:n?o:"browser"}}catch{return{language:"",source:"browser"}}})()}var Ip=_v();var Yl={name:"dsh-plugin-beyond-simulator",version:"2.2.1",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 wI="qxqy-simulator",SI=["tools","webServer"],_p="/qxqy-simulator/api",Ep="/qxqy-simulator/play",Av="/qxqy-simulator/play-renderer.js",Tv=8*1024*1024,Rv=32,Cp=6e4,Kl=class extends us{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(Cn(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(),mp(this.studio.get().workspace?.path||"")}loadArchive(e){this.touch();let i=this.studio.get().workspace?.path||"",r=pp(i,e);return{...super.loadArchive(kv(Cv(i),r)),snapshot:this.get()}}async play(e,i={},r){return this.touch(),super.play(e,Cn(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 Tp(t){let e=String(t||"").trim();if(!e||e.length>256)throw new Error("sessionId is required");return e}function Cn(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 Zi(t){return Tp(t?.agent?.id)}function Jl(t){let e=t?.cwd;return typeof e=="string"&&e?e:""}function Qi(t){return Jl(t?.agent?.session?.header)}async function Ov(t,e={}){let i=e.sessions?.get?.(t),r=Jl(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 Jl(o?.meta)}catch{return""}}function Nv(){let t=new Map,e=!1;function i(){if(t.size<Rv)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=Tp(r),s=t.get(o);return s?n&&s.studio.setWorkspace(n):(i(),s=new Kl(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 En(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 Pv(){if(!Xl){let e=[new URL("./play.html",import.meta.url),new URL("../lib/play.html",import.meta.url)].find(i=>kp(i));if(!e)throw new Error("standalone play page is missing");Xl=Ap(e,"utf8")}return Xl}var Xl=null;function Mv(){if(!Wl){let e=[new URL("../dist/play-renderer.js",import.meta.url),new URL("./play-renderer.js",import.meta.url)].find(i=>kp(i));if(!e)throw new Error("standalone play renderer bundle is missing; run npm run build");Wl=Ap(e,"utf8")}return Wl}var Wl=null;function Dr(t,e){return t.effect(()=>t.webServer.register(e),`qxqy-simulator: ${e.kind} ${e.path}`)}function Fv(t){Dr(t,{kind:"prefix",path:Ep,handler(e,i){let r=new URL(e.url,"http://localhost").pathname.replace(/\/$/,"");if(e.method!=="GET"||r!==Ep){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(Pv())}})}function Dv(t){Dr(t,{kind:"exact",path:Av,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(Mv())}catch(r){i.statusCode=500,i.setHeader("content-type","text/plain; charset=utf-8"),i.end(r?.message||String(r))}}})}function zv(t){return new Promise((e,i)=>{let r=0,n=[];t.on("data",o=>{if(r+=o.length,r>Tv){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 $v(t,e){t.tools.register(Ji({name:"qxqy_script_sync",description:"\u5B9E\u673A Lua \u811A\u672C\u76EE\u5F55\u540C\u6B65\uFF1Adiscover/status/configure/save/preview/apply\u3002configure \u9700\u8981 config(version:1, workspaceDir, clientImportRoot, clientSubdir) \u4E0E expectedRevision\uFF1Bsave \u9700\u8981 expectedRevision\uFF0C\u9996\u6B21\u4FDD\u5B58\u53E6\u4F20\u5DE5\u4F5C\u533A\u76F8\u5BF9 path\u3002\u7528\u6237\u6388\u6743\u66F4\u65B0\u540E\uFF0C\u5148 save\uFF0C\u518D preview \u6838\u5BF9\u6765\u6E90\u4E0E\u76EE\u6807\uFF0C\u6700\u540E apply \u4F20 planId\u3001\u9009\u5B9A scriptIds \u548C confirmed:true\u3002\u8BA1\u5212\u4EC5\u5728\u5F53\u524D\u4F1A\u8BDD\u6709\u6548\uFF0C\u8FC7\u671F\u9700\u91CD\u65B0\u9884\u89C8\uFF1B\u8FD4\u56DE\u9010\u6587\u4EF6\u7ED3\u679C\u4E0E\u5907\u4EFD\u4F4D\u7F6E\uFF0C\u4E0D\u4EE3\u8868\u771F\u673A\u8BD5\u73A9\u901A\u8FC7\u3002",parameters:{action:{type:"string",enum:["discover","status","configure","save","preview","apply"],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(Zi(r),Qi(r)).scriptSyncAction(i.action,Cn(i.args)||{})}})),t.tools.register(Ji({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(Zi(r),Qi(r)).get()}})),t.tools.register(Ji({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?`
128
+ \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:Cp+1e3,isConcurrencySafe:()=>!1,async execute(i,r){let o=await e.get(Zi(r),Qi(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(Ji({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?`
129
+ \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:Cp+1e3,isConcurrencySafe:()=>!1,async execute(i,r){let o=await e.get(Zi(r),Qi(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(Ji({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=Cn(i.op);if(!n)throw new Error("patch requires op");return e.get(Zi(r),Qi(r)).patch(n)}})),t.tools.register(Ji({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=Cn(i.args)||{};return e.get(Zi(r),Qi(r)).play(i.action,n,r.signal)}})),t.tools.register(Ji({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(Zi(r),Qi(r));return i.path?n.loadArchive(i.path):n.listArchives()}}))}function Lv(t,e,i){Dr(t,{kind:"prefix",path:_p,async handler(r,n){if(r.method!=="POST"){En(n,405,{ok:!1,value:null,error:"POST required"});return}let s=new URL(r.url,"http://localhost").pathname.slice(_p.length).replace(/^\/+/,"");if(s==="health"){En(n,200,{ok:!0,value:{status:"ok"},error:null});return}let a=new AbortController;r.once("aborted",()=>a.abort());try{let l=await zv(r);if(s==="locale"){En(n,200,{ok:!0,value:xp(r)?await Ip():{language:"",source:"browser"},error:null});return}let u=await Ov(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");En(n,200,{ok:!0,value:f,error:null})}catch(l){En(n,400,{ok:!1,value:null,error:l?.message||String(l)})}}})}function xI(t){Xt();let e=Nv();t.effect(()=>()=>e.dispose(),"qxqy-simulator: dispose sessions"),$v(t,e),Lv(t,e,wp({packageName:Yl.name,currentVersion:Yl.version})),Fv(t),Dv(t),Dr(t,{kind:"prefix",path:"/qxqy-assets",handler:(i,r)=>op(i,r)}),Dr(t,{kind:"prefix",path:"/qxqy-audio",handler:(i,r)=>yp(i,r)}),Dr(t,{kind:"prefix",path:"/qxqy-font",handler:Nu})}export{Kl as SimulatorController,xI as apply,Jl as headerWorkspace,SI as inject,Cn as jsonParam,Ov as lookupSessionWorkspace,wI as name,Qi as sessionWorkspace};
130
+ /*! Bundled license information:
131
+
132
+ long/umd/index.js:
133
+ (**
134
+ * @license
135
+ * Copyright 2009 The Closure Library Authors
136
+ * Copyright 2020 Daniel Wirtz / The long.js Authors.
137
+ *
138
+ * Licensed under the Apache License, Version 2.0 (the "License");
139
+ * you may not use this file except in compliance with the License.
140
+ * You may obtain a copy of the License at
141
+ *
142
+ * http://www.apache.org/licenses/LICENSE-2.0
143
+ *
144
+ * Unless required by applicable law or agreed to in writing, software
145
+ * distributed under the License is distributed on an "AS IS" BASIS,
146
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
147
+ * See the License for the specific language governing permissions and
148
+ * limitations under the License.
149
+ *
150
+ * SPDX-License-Identifier: Apache-2.0
151
+ *)
152
+ */