@fps-games/editor-deployment 0.2.3-beta.10 → 0.2.3-beta.11

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,4 @@
1
- import{gp as wr,$ as qt,_ as tn,G as rn,H as nn,kv as Ct,kJ as an,kw as Yt,c3 as on,iK as sn,jR as cn,fZ as dn,j9 as ln,hn as un,jZ as mn,lq as Cr,lk as Mr,lr as fn,bM as gn,cQ as pn,bI as hn,bK as En,bN as bn,bL as Sn,bO as yn,bP as In,w as Pn,p as k,kr as An,nf as Tn,bJ as Rn,ne as vn,ng as wn,he as Cn,n as Mn,o as _n,r as Dn,m as Wt,s as On,kN as _r,g6 as W,bd as kt,ba as jn,m9 as kn,kT as Nn,gD as Ln,gr as xn,gq as Gn,hk as Fn,jm as Bn,ny as zn,gs as Un,D as $n,cS as Hn,l as Vn,E as qn,kM as Yn,jQ as Wn,lv as ut,q as Kn,t as Jn,u as Xn,lC as Kt,g0 as Zn,mC as Qn,ms as ea,jL as ta,aO as Jt,jx as Xt,n7 as Zt,mM as ra,gf as he,bn as na,bm as aa,gQ as oa,a5 as Qt,mD as ia}from"./playable-standard-project-Brbyn9c4.js";import{C as Ns,a as Ls,b as xs,c as Gs,d as Fs,e as Bs,f as zs,g as Us,h as $s,i as Hs,j as Vs,k as qs,v as Ys,x as Ws,y as Ks,z as Js,A as Xs,B as Zs,F as Qs,I as ec,J as tc,K as rc,L as nc,M as ac,N as oc,O as ic,P as sc,Q as cc,R as dc,S as lc,T as uc,U as mc,V as fc,W as gc,X as pc,Y as hc,Z as Ec,a0 as bc,a1 as Sc,a2 as yc,a3 as Ic,a4 as Pc,a6 as Ac,a7 as Tc,a8 as Rc,a9 as vc,aa as wc,ab as Cc,ac as Mc,ad as _c,ae as Dc,af as Oc,ag as jc,ah as kc,ai as Nc,aj as Lc,ak as xc,al as Gc,am as Fc,an as Bc,ao as zc,ap as Uc,aq as $c,ar as Hc,as as Vc,at as qc,au as Yc,av as Wc,aw as Kc,ax as Jc,ay as Xc,az as Zc,aA as Qc,aB as ed,aC as td,aD as rd,aE as nd,aF as ad,aG as od,aH as id,aI as sd,aJ as cd,aK as dd,aL as ld,aM as ud,aN as md,aP as fd,aQ as gd,aR as pd,aS as hd,aT as Ed,aU as bd,aV as Sd,aW as yd,aX as Id,aY as Pd,aZ as Ad,a_ as Td,a$ as Rd,b0 as vd,b1 as wd,b2 as Cd,b3 as Md,b4 as _d,b5 as Dd,b6 as Od,b7 as jd,b8 as kd,b9 as Nd,bb as Ld,bc as xd,be as Gd,bf as Fd,bg as Bd,bh as zd,bi as Ud,bj as $d,bk as Hd,bl as Vd,bo as qd,bp as Yd,bq as Wd,br as Kd,bs as Jd,bt as Xd,bu as Zd,bv as Qd,bw as el,bx as tl,by as rl,bz as nl,bA as al,bB as ol,bC as il,bD as sl,bE as cl,bF as dl,bG as ll,bH as ul,bQ as ml,bR as fl,bS as gl,bT as pl,bU as hl,bV as El,bW as bl,bX as Sl,bY as yl,bZ as Il,b_ as Pl,b$ as Al,c0 as Tl,c1 as Rl,c2 as vl,c4 as wl,c5 as Cl,c6 as Ml,c7 as _l,c8 as Dl,c9 as Ol,ca as jl,cb as kl,cc as Nl,cd as Ll,ce as xl,cf as Gl,cg as Fl,ch as Bl,ci as zl,cj as Ul,ck as $l,cl as Hl,cm as Vl,cn as ql,co as Yl,cp as Wl,cq as Kl,cr as Jl,cs as Xl,ct as Zl,cu as Ql,cv as eu,cw as tu,cx as ru,cy as nu,cz as au,cA as ou,cB as iu,cC as su,cD as cu,cE as du,cF as lu,cG as uu,cH as mu,cI as fu,cJ as gu,cK as pu,cL as hu,cM as Eu,cN as bu,cO as Su,cP as yu,cR as Iu,cT as Pu,cU as Au,cV as Tu,cW as Ru,cX as vu,cY as wu,cZ as Cu,c_ as Mu,c$ as _u,d0 as Du,d1 as Ou,d2 as ju,d3 as ku,d4 as Nu,d5 as Lu,d6 as xu,d7 as Gu,d8 as Fu,d9 as Bu,da as zu,db as Uu,dc as $u,dd as Hu,de as Vu,df as qu,dg as Yu,dh as Wu,di as Ku,dj as Ju,dk as Xu,dl as Zu,dm as Qu,dn as em,dp as tm,dq as rm,dr as nm,ds as am,dt as om,du as im,dv as sm,dw as cm,dx as dm,dy as lm,dz as um,dA as mm,dB as fm,dC as gm,dD as pm,dE as hm,dF as Em,dG as bm,dH as Sm,dI as ym,dJ as Im,dK as Pm,dL as Am,dM as Tm,dN as Rm,dO as vm,dP as wm,dQ as Cm,dR as Mm,dS as _m,dT as Dm,dU as Om,dV as jm,dW as km,dX as Nm,dY as Lm,dZ as xm,d_ as Gm,d$ as Fm,e0 as Bm,e1 as zm,e2 as Um,e3 as $m,e4 as Hm,e5 as Vm,e6 as qm,e7 as Ym,e8 as Wm,e9 as Km,ea as Jm,eb as Xm,ec as Zm,ed as Qm,ee as ef,ef as tf,eg as rf,eh as nf,ei as af,ej as of,ek as sf,el as cf,em as df,en as lf,eo as uf,ep as mf,eq as ff,er as gf,es as pf,et as hf,eu as Ef,ev as bf,ew as Sf,ex as yf,ey as If,ez as Pf,eA as Af,eB as Tf,eC as Rf,eD as vf,eE as wf,eF as Cf,eG as Mf,eH as _f,eI as Df,eJ as Of,eK as jf,eL as kf,eM as Nf,eN as Lf,eO as xf,eP as Gf,eQ as Ff,eR as Bf,eS as zf,eT as Uf,eU as $f,eV as Hf,eW as Vf,eX as qf,eY as Yf,eZ as Wf,e_ as Kf,e$ as Jf,f0 as Xf,f1 as Zf,f2 as Qf,f3 as eg,f4 as tg,f5 as rg,f6 as ng,f7 as ag,f8 as og,f9 as ig,fa as sg,fb as cg,fc as dg,fd as lg,fe as ug,ff as mg,fg,fh as gg,fi as pg,fj as hg,fk as Eg,fl as bg,fm as Sg,fn as yg,fo as Ig,fp as Pg,fq as Ag,fr as Tg,fs as Rg,ft as vg,fu as wg,fv as Cg,fw as Mg,fx as _g,fy as Dg,fz as Og,fA as jg,fB as kg,fC as Ng,fD as Lg,fE as xg,fF as Gg,fG as Fg,fH as Bg,fI as zg,fL as Ug,fM as $g,fN as Hg,fO as Vg,fP as qg,fQ as Yg,fR as Wg,fS as Kg,fT as Jg,fU as Xg,fV as Zg,fW as Qg,fX as ep,fY as tp,f_ as rp,f$ as np,g1 as ap,g2 as op,g3 as ip,g4 as sp,g5 as cp,g7 as dp,g8 as lp,g9 as up,ga as mp,gb as fp,gc as gp,gd as pp,ge as hp,gg as Ep,gh as bp,gi as Sp,gj as yp,gk as Ip,gl as Pp,gm as Ap,gn as Tp,go as Rp,gt as vp,gu as wp,gv as Cp,gw as Mp,gx as _p,gy as Dp,gz as Op,gA as jp,gB as kp,gC as Np,gE as Lp,gF as xp,gG as Gp,gH as Fp,gI as Bp,gJ as zp,gK as Up,gL as $p,gM as Hp,gN as Vp,gO as qp,gP as Yp,gR as Wp,gS as Kp,gT as Jp,gU as Xp,gV as Zp,gW as Qp,gX as eh,gY as th,gZ as rh,g_ as nh,g$ as ah,h0 as oh,h1 as ih,h2 as sh,h3 as ch,h4 as dh,h5 as lh,h6 as uh,h7 as mh,h8 as fh,h9 as gh,ha as ph,hb as hh,hc as Eh,hd as bh,hf as Sh,hg as yh,hh as Ih,hi as Ph,hj as Ah,hl as Th,hm as Rh,ho as vh,hp as wh,hq as Ch,hr as Mh,hs as _h,ht as Dh,hu as Oh,hv as jh,hw as kh,hx as Nh,hy as Lh,hz as xh,hA as Gh,hB as Fh,hC as Bh,hD as zh,hE as Uh,hF as $h,hG as Hh,hH as Vh,hI as qh,hJ as Yh,hK as Wh,hL as Kh,hM as Jh,hN as Xh,hO as Zh,hP as Qh,hQ as eE,hR as tE,hS as rE,hT as nE,hU as aE,hV as oE,hW as iE,hX as sE,hY as cE,hZ as dE,h_ as lE,h$ as uE,i1 as mE,i2 as fE,i3 as gE,i4 as pE,i5 as hE,i6 as EE,i7 as bE,i8 as SE,i9 as yE,ia as IE,ib as PE,ic as AE,id as TE,ie as RE,ig as vE,ih as wE,ii as CE,ij as ME,ik as _E,il as DE,im as OE,io as jE,ip as kE,iq as NE,ir as LE,is as xE,it as GE,iu as FE,iv as BE,iw as zE,ix as UE,iy as $E,iz as HE,iA as VE,iB as qE,iC as YE,iD as WE,iE as KE,iF as JE,iG as XE,iH as ZE,iI as QE,iJ as eb,iL as tb,iM as rb,iN as nb,iO as ab,iP as ob,iQ as ib,iR as sb,iS as cb,iT as db,iU as lb,iV as ub,iW as mb,iX as fb,iY as gb,iZ as pb,i_ as hb,i$ as Eb,j0 as bb,j1 as Sb,j2 as yb,j3 as Ib,j4 as Pb,j5 as Ab,j6 as Tb,j7 as Rb,j8 as vb,ja as wb,jb as Cb,jc as Mb,jd as _b,je as Db,jf as Ob,jg as jb,jh as kb,ji as Nb,jj as Lb,jk as xb,jl as Gb,jn as Fb,jo as Bb,jp as zb,jq as Ub,jr as $b,js as Hb,jt as Vb,ju as qb,jv as Yb,jw as Wb,jy as Kb,jz as Jb,jA as Xb,jB as Zb,jC as Qb,jD as eS,jE as tS,jF as rS,jG as nS,jH as aS,jI as oS,jJ as iS,jK as sS,jM as cS,jN as dS,jO as lS,jP as uS,jS as mS,jT as fS,jU as gS,jV as pS,jW as hS,jX as ES,jY as bS,j_ as SS,j$ as yS,k0 as IS,k1 as PS,k2 as AS,k3 as TS,k4 as RS,k5 as vS,k6 as wS,k7 as CS,k8 as MS,k9 as _S,ka as DS,kb as OS,kc as jS,kd as kS,ke as NS,kf as LS,kg as xS,kh as GS,ki as FS,kj as BS,kk as zS,kl as US,km as $S,kn as HS,ko as VS,kp as qS,kq as YS,ks as WS,kt as KS,ku as JS,kx as XS,ky as ZS,kz as QS,kA as ey,kB as ty,kC as ry,kD as ny,kE as ay,kF as oy,kG as iy,kH as sy,kI as cy,kK as dy,kL as ly,kO as uy,kP as my,kQ as fy,kR as gy,kS as py,kU as hy,kV as Ey,kW as by,kX as Sy,kY as yy,kZ as Iy,k_ as Py,k$ as Ay,l0 as Ty,l1 as Ry,l2 as vy,l3 as wy,l4 as Cy,l5 as My,l6 as _y,l7 as Dy,l8 as Oy,l9 as jy,la as ky,lb as Ny,lc as Ly,ld as xy,le as Gy,lf as Fy,lg as By,lh as zy,li as Uy,lj as $y,ll as Hy,lm as Vy,ln as qy,lo as Yy,lp as Wy,ls as Ky,lt as Jy,lu as Xy,lw as Zy,lx as Qy,ly as eI,lz as tI,lA as rI,lB as nI,lD as aI,lE as oI,lF as iI,lG as sI,lH as cI,lI as dI,lJ as lI,lK as uI,lL as mI,lM as fI,lN as gI,lO as pI,lP as hI,lQ as EI,lR as bI,lS as SI,lT as yI,lU as II,lV as PI,lW as AI,lX as TI,lY as RI,lZ as vI,l_ as wI,l$ as CI,m0 as MI,m1 as _I,m2 as DI,m3 as OI,m4 as jI,m5 as kI,m6 as NI,m7 as LI,m8 as xI,ma as GI,mb as FI,mc as BI,md as zI,me as UI,mf as $I,mg as HI,mh as VI,mi as qI,mj as YI,mk as WI,ml as KI,mm as JI,mn as XI,mo as ZI,mp as QI,mq as eP,mr as tP,mt as rP,mu as nP,mv as aP,mw as oP,mx as iP,my as sP,mz as cP,mA as dP,mB as lP,mE as uP,mF as mP,mG as fP,mH as gP,mI as pP,mJ as hP,mK as EP,mL as bP,mN as SP,mO as yP,mP as IP,mQ as PP,mR as AP,mS as TP,mT as RP,mU as vP,mV as wP,mW as CP,mX as MP,mY as _P,mZ as DP,m_ as OP,m$ as jP,n0 as kP,n1 as NP,n2 as LP,n3 as xP,n4 as GP,n5 as FP,n6 as BP,n8 as zP,n9 as UP,na as $P,nb as HP,nc as VP,nd as qP,nh as YP,ni as WP,nj as KP,nk as JP,nl as XP,nm as ZP,nn as QP,no as eA,np as tA,nq as rA,nr as nA,ns as aA,nt as oA,nu as iA,nv as sA,nw as cA,nx as dA,nz as lA,nA as uA,nB as mA,nC as fA,nD as gA,nE as pA,nF as hA,nG as EA,nH as bA,nI as SA,nJ as yA,nK as IA}from"./playable-standard-project-Brbyn9c4.js";import"./dynamicTexture-Cuby-VOT.js";import"@fps-games/editor-core/plugin-host";function Qi(e,t){const r=wr(e),a=sa(t),n=r.revision??null;if(!a)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:null,reason:"missing-generated-from"};const o=typeof a.revision=="number"?a.revision:null;return a.sourceId!==r.sourceId||a.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:o,reason:"source-mismatch"}:n!==o?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:o,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:o}}function sa(e){if(!e||typeof e!="object")return null;const t=e.meta;if(!t||typeof t!="object")return null;const r=t.generatedFrom;if(!r||typeof r!="object")return null;const a=r.sourceId,n=r.sourceType;return typeof a!="string"||typeof n!="string"?null:{sourceId:a,sourceType:n,revision:typeof r.revision=="number"?r.revision:void 0}}function ca(e){const{document:t,runtimePatch:r}=e,a=e.getSourceRef?.(t)??wr(t),n=r.sourceBinding;if(!r.applyable||!n||r.applyTarget!==qt||n.sourceId!==tn||n.sourceType!==qt||n.sourceId!==a.sourceId||n.sourceType!==a.sourceType)return null;const o=n.objectId;if(!o||!e.findGameObject(t,o)||e.isRootGameObjectId?.(o))return null;const i=r.after;return da(i)?{label:r.label??`Apply runtime transform ${o}`,patch:e.createPatch(o,i)}:null}function es(e,t){return ca({document:e,runtimePatch:t,findGameObject:(r,a)=>r.scene.gameObjects.find(n=>n.id===a)??null,isRootGameObjectId:r=>r==="root",createPatch:(r,a)=>({kind:"game-object.transform",targetId:r,transform:a})})}function da(e){if(!e||typeof e!="object")return!1;const t=e;return Et(t.position)&&Et(t.rotation)&&Et(t.scale)}function Et(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)&&typeof t.z=="number"&&Number.isFinite(t.z)}const Dr="fps-editor.lighting-debug.open",Or="fps-editor.lighting-debug.language",la=[{field:"environmentIntensity",textKey:"intensity",tooltipKey:"environmentIntensity",step:.01,min:0},{field:"iblIntensity",textKey:"iblIntensity",tooltipKey:"iblIntensity",step:.01,min:0,max:4},{field:"iblRotationY",textKey:"iblRotationY",tooltipKey:"iblRotationY",step:.01},{field:"directionalIntensity",textKey:"intensity",tooltipKey:"directionalIntensity",step:.01,min:0},{field:"directionalHorizontalAngle",textKey:"horizontalAngle",tooltipKey:"horizontalAngle",step:.01,min:-180,max:180},{field:"directionalElevationAngle",textKey:"elevationAngle",tooltipKey:"elevationAngle",step:.01,min:nn,max:rn},{field:"shadowStrength",textKey:"shadowStrength",tooltipKey:"shadowStrength",step:.01,min:0,max:1},{field:"shadowSoftness",textKey:"shadowSoftness",tooltipKey:"shadowSoftness",step:.005,min:0,max:1}];function Ee(e){const t=la.find(r=>r.field===e);if(!t)throw new Error(`Missing lighting number field config: ${e}`);return t}function bt(e){const t=e.trim();if(!t||/^[+-]$/.test(t)||t.endsWith(".")||/[eE][+-]?$/.test(t))return null;const r=Number(t);return Number.isFinite(r)?r:null}const er={zh:{title:"光照调试",runtime:"运行时",languageButton:"EN",toggleTitle:"打开光照调试面板",environmentSection:"环境光",environmentTextureSection:"环境贴图 IBL",directionalSection:"直射光",shadowSection:"阴影外观",enabled:"启用",intensity:"强度",iblIntensity:"IBL 强度",iblRotationY:"IBL 旋转",skyLightColor:"天空光颜色",groundColor:"地面颜色",horizontalAngle:"水平角",elevationAngle:"高度角",lightColor:"光照颜色",rawDirection:"原始方向",shadowReadout:"阴影",shadowStrength:"阴影强度",shadowSoftness:"轮廓柔和度",shadowMap:"Shadow Map",shadowPlanarFollow:"Planar / 跟随直射光",shadowDynamic:"动态阴影",shadowBlob:"Blob 阴影",shadowStatic:"静态烘焙阴影",shadowNone:"Off",shadowUnknown:"Unknown",reset:"重置参数",save:"保存参数",resetStatus:"已重置为初始运行时光照。",savingStatus:"正在保存光照、IBL 和阴影参数...",savedStatus:"已保存光照、IBL 和阴影参数。",saveFailed:"保存失败",missingBindingStatus:"缺少光源绑定,只能临时预览,不能保存。"},en:{title:"Lighting Debug",runtime:"Runtime",languageButton:"中文",toggleTitle:"Toggle lighting debug panel",environmentSection:"Environment Light",environmentTextureSection:"Environment Texture IBL",directionalSection:"Directional Light",shadowSection:"Shadow Appearance",enabled:"Enabled",intensity:"Intensity",iblIntensity:"IBL Intensity",iblRotationY:"IBL Rotation",skyLightColor:"Sky Light Color",groundColor:"Ground Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",lightColor:"Light Color",rawDirection:"Raw Direction",shadowReadout:"Shadow",shadowStrength:"Shadow Strength",shadowSoftness:"Edge Softness",shadowMap:"Shadow Map",shadowPlanarFollow:"Planar / Follow Directional Light",shadowDynamic:"Dynamic Shadow",shadowBlob:"Blob Shadow",shadowStatic:"Static Baked Shadow",shadowNone:"Off",shadowUnknown:"Unknown",reset:"Reset",save:"Save Parameters",resetStatus:"Reset to initial runtime lighting.",savingStatus:"Saving lighting, IBL and shadows...",savedStatus:"Saved lighting, IBL and shadows.",saveFailed:"Save failed",missingBindingStatus:"Light binding missing; preview only, saving disabled."}},tr={zh:{languageButton:"切换光照调试面板的显示语言。",toggleTitle:"打开或关闭运行时光照调试面板。",enabled:"启用或禁用对应的运行时光源,保存后写回编辑器场景。",environmentIntensity:"环境光强度,对应运行时环境光 intensity。",iblIntensity:"环境贴图对 PBR 材质的光照贡献强度;实时预览不会重新加载贴图。",iblRotationY:"环境贴图绕 Y 轴的旋转弧度,用于调整环境反射和高光方向。",directionalIntensity:"直射光强度,对应运行时直射光 intensity。",skyLightColor:"环境光来自天空方向的漫反射颜色。",groundColor:"环境光来自地面反射方向的颜色。",horizontalAngle:"直射光在 XZ 平面内的朝向角度,会转换为运行时方向向量。",elevationAngle:"直射光相对地平线的高度角;90 度表示从正上方照下。",lightColor:"直射光漫反射颜色。",rawDirection:"只读方向向量,用于排查运行时转换结果。",shadowReadout:"只读阴影状态;支持宿主提供的运行时阴影模式摘要。",shadowStrength:"控制阴影的可见深浅;1 最深,0 不显示阴影。",shadowSoftness:"控制阴影接收边缘的柔和程度;0 表示硬边。",reset:"恢复为打开运行时时读取到的初始光照、IBL 和阴影参数。",save:"通过编辑器保存链路写回环境光、直射光、IBL 和 Shadow Map 外观参数。"},en:{languageButton:"Switch the lighting debug panel language.",toggleTitle:"Open or close the runtime lighting debug panel.",enabled:"Enable or disable the runtime light and save it back to the editor scene.",environmentIntensity:"Environment intensity. Maps to the runtime environment light intensity.",iblIntensity:"Environment texture contribution to PBR lighting. Live preview does not reload the texture.",iblRotationY:"Environment texture rotation around the Y axis in radians, affecting reflections and highlights.",directionalIntensity:"Directional intensity. Maps to the runtime directional light intensity.",skyLightColor:"Diffuse sky color for the environment light.",groundColor:"Ground bounce color for the environment light.",horizontalAngle:"Directional heading in the XZ plane, converted to a runtime direction vector.",elevationAngle:"Directional elevation above the horizon; 90 degrees points straight down.",lightColor:"Directional diffuse color.",rawDirection:"Read-only direction vector for checking runtime conversion.",shadowReadout:"Read-only shadow status supplied by the host runtime.",shadowStrength:"Visible shadow strength. One is darkest; zero hides the shadow.",shadowSoftness:"Receiver-edge softness. Zero produces a hard edge.",reset:"Restore the lighting, IBL and shadows captured when runtime opened.",save:"Save lighting, IBL and Shadow Map appearance through the editor authoring pipeline."}};function ua(e){return er[e]??er.zh}function ma(e){return tr[e]??tr.zh}function fa(e,t){return e==="shadow-map"?t.shadowMap:e==="planar"?t.shadowPlanarFollow:e==="dynamic"?t.shadowDynamic:e==="blob"?t.shadowBlob:e==="static"?t.shadowStatic:e==="none"?t.shadowNone:t.shadowUnknown}function ga(e){try{return e?.localStorage?.getItem(Dr)==="true"}catch{return!1}}function pa(e,t){try{e?.localStorage?.setItem(Dr,String(t))}catch{}}function ha(e){try{return e?.localStorage?.getItem(Or)==="en"?"en":"zh"}catch{return"zh"}}function Ea(e,t){try{e?.localStorage?.setItem(Or,t)}catch{}}function ts(e,t){const r=rr(rr(e)?.__fpsEditor),a=ce(r?.sourceId),n=ce(r?.objectGuid),o=ce(r?.objectId),i=ce(r?.propertyPath),s=ce(r?.lightType);return!a||i!=="light"||!n&&!o||t&&s&&s!==t?null:{sourceId:a,propertyPath:"light",...t?{lightType:t}:s?{lightType:s}:{},...n?{objectGuid:n}:{},...o?{objectId:o}:{}}}function ba(e){const t=ce(e.sourceId),r=ce(e.propertyPath),a=ce(e.objectGuid),n=ce(e.objectId),o=ce(e.lightType);if(!t)throw new Error("Runtime light binding is missing sourceId.");if(r!=="light")throw new Error(`Runtime light binding is not for light: ${r??"missing"}`);if(!a&&!n)throw new Error("Runtime light binding is missing objectGuid/objectId.");return{sourceId:t,propertyPath:r,...a?{objectGuid:a}:{},...n?{objectId:n}:{},...o?{lightType:o}:{}}}function rr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ce(e){return typeof e=="string"&&e.trim()?e.trim():null}function Se(e){return{environment:{enabled:e.environment.enabled,binding:e.environment.binding?{...e.environment.binding}:null,light:{type:"hemispheric",intensity:e.environment.light.intensity,...e.environment.light.diffuseColor?{diffuseColor:{...e.environment.light.diffuseColor}}:{},...e.environment.light.groundColor?{groundColor:{...e.environment.light.groundColor}}:{}}},...e.environmentTexture?{environmentTexture:{...e.environmentTexture}}:{},directional:{enabled:e.directional.enabled,binding:e.directional.binding?{...e.directional.binding}:null,light:{type:"directional",intensity:e.directional.light.intensity,direction:{...e.directional.light.direction},...e.directional.light.diffuseColor?{diffuseColor:{...e.directional.light.diffuseColor}}:{}}},shadow:{...e.shadow,...e.shadow.shadowMap?{shadowMap:{...e.shadow.shadowMap,lastRefreshReasons:[...e.shadow.shadowMap.lastRefreshReasons],...e.shadow.shadowMap.appearance?{appearance:{...e.shadow.shadowMap.appearance}}:{}}}:{}}}}function it(e){return!!e.environment.binding&&!!e.directional.binding}function rs(e){return it(e)?[{binding:e.environment.binding,enabled:e.environment.enabled,light:e.environment.light},{binding:e.directional.binding,enabled:e.directional.enabled,light:e.directional.light}]:[]}function Le(e,t){switch(t){case"environmentIntensity":return e.environment.light.intensity;case"iblIntensity":return e.environmentTexture?.iblIntensity??0;case"iblRotationY":return e.environmentTexture?.iblRotationY??0;case"directionalIntensity":return e.directional.light.intensity;case"directionalHorizontalAngle":return Ct(e.directional.light.direction).horizontalAngleDeg;case"directionalElevationAngle":return Ct(e.directional.light.direction).elevationAngleDeg;case"shadowStrength":return e.shadow.shadowMap?.appearance?.strength??0;case"shadowSoftness":return e.shadow.shadowMap?.appearance?.softness??0}}function nr(e,t){switch(t){case"environmentDiffuseColor":return e.environment.light.diffuseColor??{r:1,g:1,b:1};case"environmentGroundColor":return e.environment.light.groundColor??{r:.48,g:.52,b:.62};case"directionalDiffuseColor":return e.directional.light.diffuseColor??{r:1,g:1,b:1}}}function Sa(e,t,r){if(!Number.isFinite(r))return Se(e);const a=Se(e);switch(t){case"environmentIntensity":return a.environment.light.intensity=r,a;case"iblIntensity":return a.environmentTexture&&(a.environmentTexture.iblIntensity=r),a;case"iblRotationY":return a.environmentTexture&&(a.environmentTexture.iblRotationY=r),a;case"directionalIntensity":return a.directional.light.intensity=r,a;case"directionalHorizontalAngle":{const n=Yt(e.directional.light.direction);return ar(a,r,n.elevationAngleDeg)}case"directionalElevationAngle":{const n=Yt(e.directional.light.direction);return ar(a,n.horizontalAngleDeg,r)}case"shadowStrength":{const n=a.shadow.shadowMap?.appearance;return n&&(n.strength=r,n.darkness=1-r),a}case"shadowSoftness":return a.shadow.shadowMap?.appearance&&(a.shadow.shadowMap.appearance.softness=r),a}}function ya(e,t,r){const a=Se(e);switch(t){case"environmentDiffuseColor":return a.environment.light.diffuseColor={...r},a;case"environmentGroundColor":return a.environment.light.groundColor={...r},a;case"directionalDiffuseColor":return a.directional.light.diffuseColor={...r},a}}function Ia(e,t,r){const a=Se(e);return a[t].enabled=r,a}function ar(e,t,r){const a=on(t,r);return Pa(e,a)}function Pa(e,t){const r=Se(e);return r.directional.light.direction={...t},r.shadow.projectedLengthMultiplier=an(t),r}function jr(e,t){const r=typeof t?.materialAssetId=="string"?t.materialAssetId.trim():"",a=r?e.scene.materialAssets?.find(o=>o.id===r)??null:null,n=sn(a?.properties,t?.override);return{materialAsset:a,...a?{materialAssetShaderId:a.shaderId}:{},profile:n,...r&&!a?{missingMaterialAssetId:r}:{}}}function ns(e,t){const r=jr(e,t.overrides?.materialBinding),a={},n=cn(r.materialAssetShaderId);return n&&(Object.keys(r.profile).length>0?(a.artistMaterialShaderId=n,a.artistMaterialProfile=r.profile):a.artistMaterialShaderId=n),a}function as(e,t){const r={},a=t.overrides?.materialSlotBindings??{};for(const[n,o]of Object.entries(a)){if(!n||!o)continue;const i=jr(e,o);Object.keys(i.profile).length!==0&&(r[n]=i.profile)}return r}function os(e,t){const r=Aa(t),a=[];for(const n of e.inspector.fields){if(n.control!=="color"||n.updateClass!=="uniform")continue;const o=Ta(e,n.schemaPath??n.path);if(o?.kind!=="color")continue;const i=o.channels===4?"vec4":"vec3",s=r.get(n.binding);if(!s){a.push({code:"material.shaderColorBindingMissing",path:n.path,binding:n.binding,expectedType:i,message:`GLSL uniform ${n.binding} is missing; expected ${i}.`});continue}s!==i&&a.push({code:"material.shaderColorBindingTypeMismatch",path:n.path,binding:n.binding,expectedType:i,actualType:s,message:`GLSL uniform ${n.binding} uses ${s}; Shader Definition expects ${i}.`})}return a}function Aa(e){const t=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,""),r=new Map,a=/\buniform\s+(?:(?:lowp|mediump|highp)\s+)?([A-Za-z_]\w*)\s+([A-Za-z_]\w*)\s*(?:\[[^\]]+\])?\s*;/g;for(const n of t.matchAll(a))r.set(n[2],n[1]);return r}function Ta(e,t){const r=t.replace(/^properties\./,"").split(".").filter(Boolean);let a=e.propertiesSchema;for(const n of r){if(a.kind!=="object")return null;const o=a.properties[n];if(!o)return null;a=o}return a}function is(e,t,r={}){const a=kr(e);let n=dn(e);const o=[];for(const i of t){const s=va(i),l=ba(s.binding);if(r.expectedSourceId&&l.sourceId!==r.expectedSourceId)throw new Error(`Runtime light binding source mismatch: ${l.sourceId} !== ${r.expectedSourceId}`);const d=Ra(n,l,a);if(!d)throw new Error("Runtime light binding did not match an editor light object.");Ma(d,s.light.type,l),n=xe(n,d.id,"enabled",s.enabled,r),n=xe(n,d.id,"light.intensity",s.light.intensity,r),s.light.diffuseColor&&(n=xe(n,d.id,"light.diffuseColor",s.light.diffuseColor,r)),s.light.type==="hemispheric"?s.light.groundColor&&(n=xe(n,d.id,"light.groundColor",s.light.groundColor,r)):n=xe(n,d.id,"light.direction",s.light.direction,r),o.push({id:d.id,...d.guid?{objectGuid:d.guid}:{},lightType:s.light.type})}return{document:n,targets:o}}function Ra(e,t,r=kr(e)){if(t.objectGuid){const o=e.scene.gameObjects.find(i=>i.guid===t.objectGuid)??null;if(o){if(t.objectId&&o.id!==t.objectId)throw new Error(`Runtime light binding guid/id conflict: ${t.objectGuid} belongs to ${o.id}, not ${t.objectId}.`);return o}}if(!t.objectId)return null;const a=e.scene.gameObjects.find(o=>o.id===t.objectId)??null;if(!a)return null;const n=r.get(a.id);if(t.objectGuid&&n&&n!==t.objectGuid)throw new Error(`Runtime light binding guid conflict for ${a.id}.`);return a}function va(e){const t=_a(e.enabled,"enabled");return e.light.type==="hemispheric"?{binding:e.binding,enabled:t,light:wa(e.light)}:{binding:e.binding,enabled:t,light:Ca(e.light)}}function wa(e){if(e.type!=="hemispheric")throw new Error("Runtime light patch must be hemispheric.");return{type:"hemispheric",intensity:Nr(e.intensity,"hemispheric.intensity"),...e.diffuseColor?{diffuseColor:Mt(e.diffuseColor,"hemispheric.diffuseColor")}:{},...e.groundColor?{groundColor:Mt(e.groundColor,"hemispheric.groundColor")}:{}}}function Ca(e){if(e.type!=="directional")throw new Error("Runtime light patch must be directional.");return{type:"directional",intensity:Nr(e.intensity,"directional.intensity"),direction:ln(Da(e.direction,"directional.direction")),...e.diffuseColor?{diffuseColor:Mt(e.diffuseColor,"directional.diffuseColor")}:{}}}function xe(e,t,r,a,n){return n.patchLightField?n.patchLightField(e,t,r,a):mn(e,t,r,a,n.fieldMutation)}function Ma(e,t,r){if(!un(e))throw new Error(`Runtime light binding target is not a light object: ${e.id}`);if(!e.light)throw new Error(`Runtime light binding target is missing light config: ${e.id}`);if(e.light.type!==t)throw new Error(`Runtime light binding type mismatch for ${e.id}: ${e.light.type} !== ${t}`);if(r.lightType&&r.lightType!==t)throw new Error(`Runtime light binding metadata type mismatch: ${r.lightType} !== ${t}`)}function kr(e){const t=new Map;for(const r of e.scene.gameObjects){const a=Oa(r.guid);a&&t.set(r.id,a)}return t}function _a(e,t){if(typeof e!="boolean")throw new Error(`Runtime light ${t} must be a boolean.`);return e}function Nr(e,t){if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new Error(`Runtime light ${t} must be a non-negative finite number.`);return e}function Mt(e,t){return{r:De(e.r,`${t}.r`),g:De(e.g,`${t}.g`),b:De(e.b,`${t}.b`)}}function Da(e,t){return{x:De(e.x,`${t}.x`),y:De(e.y,`${t}.y`),z:De(e.z,`${t}.z`)}}function De(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`Runtime light ${t} must be a finite number.`);return e}function Oa(e){return typeof e=="string"&&e.trim()?e.trim():null}function ss(e={}){const t=e.ttlMs??3e4,r=e.now??(()=>Date.now()),a=new Map;return{remember(n){const o=Mr(n);for(const i of fn(n)){const s=or(i);if(s.length===0)continue;const l={point:o??void 0,asset:i,timestamp:r()};for(const d of s)a.set(d,l)}St(a,t,r())},normalize(n){St(a,t,r());const o=Cr(n);if(!o)return n;const i=or(o),s=i.map(l=>a.get(l)).find(l=>!!l)??null;for(const l of i)a.delete(l);return ja(n,s)},clearExpired(){St(a,t,r())}}}function ja(e,t){const r=Cr(e);if(!r)return e;const a=t?.asset??{},n={...a,...r,...e},o=H(e.assetName)??H(r.assetName)??H(r.name)??H(a.assetName)??H(a.name),i=H(e.assetPath)??H(r.assetPath)??H(r.path)??H(a.assetPath)??H(a.path),s=H(e.assetUrl)??H(r.assetUrl)??H(r.url)??H(a.assetUrl)??H(a.url);return{...n,...o?{assetName:o}:{},...i?{assetPath:i}:{},...s?{assetUrl:s}:{},...t?.point&&!Mr(n)?{point:t.point}:{}}}function St(e,t,r){for(const[a,n]of e)r-n.timestamp>t&&e.delete(a)}function or(e){return[H(e.id),H(e.platformAssetId),H(e.assetId)].filter((t,r,a)=>!!t&&a.indexOf(t)===r)}function H(e){return typeof e=="string"&&e.trim()?e.trim():void 0}class ve extends Error{constructor(t){super(t),this.name="PlayableEditorEntryReloadRequiredError"}}function ka(e){const t=e.now??(()=>Date.now()),r=new AbortController,a=new Set;let n=ir({phase:"idle",attempt:0,phaseStartedAtMs:t(),phaseDurationsMs:{},failure:null}),o=null,i=null,s=null,l=!1;const d=m=>{try{e.reportListenerError?.(m)}catch{}},h=(m,S={})=>{const R=t(),A={...n.phaseDurationsMs,[n.phase]:Math.max(0,R-n.phaseStartedAtMs)};n=ir({phase:m,attempt:S.attempt??n.attempt,phaseStartedAtMs:R,phaseDurationsMs:A,failure:S.failure===void 0?null:S.failure});for(const j of[...a])try{j(n)}catch(M){d(M)}return n},c=(m,S,R)=>{try{e.reportFailure?.(Object.freeze({failure:m,cause:S,rollbackCause:R}))}catch(A){d(A)}},u=()=>{if(l||r.signal.aborted)throw _t()},g=m=>{if(l||n.phase==="disposed")return Promise.reject(_t());if(n.phase==="ready"||n.phase==="preparing"||n.phase==="committing"||n.phase==="editing"||n.phase==="failed"&&n.failure?.phase!=="warmup")return Promise.resolve();if(o)return o;const S=Promise.resolve().then(async()=>{try{h("warming",m===void 0?{}:{attempt:m}),u(),await e.backend.warmup?.(r.signal),u(),h("ready")}catch(R){if(l||r.signal.aborted)throw R;const A=Be("warmup-failed","warmup",R,!0);throw h("failed",{failure:A}),c(A,R),R}});return o=S,S.finally(()=>{o===S&&(o=null)}).catch(()=>{}),S},b=async()=>{if(l||n.phase==="disposed")return we(n.attempt);if(n.phase==="editing")return Object.freeze({ok:!0,attempt:n.attempt});if(n.phase==="failed"&&n.failure&&!n.failure.recoverable)return Object.freeze({ok:!1,attempt:n.attempt,failure:n.failure});const m=n.attempt+1;try{await g(m)}catch(R){if(l||r.signal.aborted)return we(m);const A=n.failure??Be("warmup-failed","warmup",R,!0);return Object.freeze({ok:!1,attempt:m,failure:A})}if(l)return we(m);h("preparing",{attempt:m});let S;try{S=await e.backend.prepare({signal:r.signal}),u()}catch(R){if(l||r.signal.aborted)return we(m);const A=Be("prepare-failed","prepare",R,!0);return h("failed",{attempt:m,failure:A}),c(A,R),Object.freeze({ok:!1,attempt:m,failure:A})}h("committing",{attempt:m});try{return await e.backend.commit(S,{signal:r.signal}),u(),h("editing",{attempt:m}),Object.freeze({ok:!0,attempt:m})}catch(R){h("rolling-back",{attempt:m});try{await e.backend.rollback(S,R)}catch(j){if(l&&sr(R)&&sr(j))return we(m);const M=st("commit-failed","commit",R),T=st("rollback-failed","rollback",j),U=ct({...T,recoverable:!1,primary:M,rollback:T});return l||h("failed",{attempt:m,failure:U}),c(U,R,j),Object.freeze({ok:!1,attempt:m,failure:U})}if(l||r.signal.aborted)return we(m);const A=Be("commit-failed","commit",R,!0);return h("failed",{attempt:m,failure:A}),c(A,R),Object.freeze({ok:!1,attempt:m,failure:A})}},p=()=>{if(i)return i;const m=b();return i=m,m.finally(()=>{i===m&&(i=null)}).catch(()=>{}),m};return Object.freeze({start:()=>g(),enter:p,retry(){const m=n.failure;return n.phase!=="failed"||!m||m.recoverable?p():Promise.resolve(Object.freeze({ok:!1,attempt:n.attempt,failure:m}))},reset(){if(l||n.phase==="disposed")throw new Error("Disposed editor entry controller cannot be reset.");if(o||i)throw new Error("Editor entry controller cannot be reset during an active operation.");if(n.phase==="failed"&&n.failure&&!n.failure.recoverable)throw new Error("Non-recoverable editor entry failure cannot be reset. Refresh the page.");(n.phase!=="idle"||n.attempt!==0||n.failure)&&h("idle",{attempt:0})},getState:()=>n,subscribe(m){if(l)return()=>{};a.add(m);try{m(n)}catch(S){d(S)}return()=>{a.delete(m)}},dispose(){if(s)return s;l=!0,r.abort();const m=(async()=>{const S=[i,o].filter((R,A,j)=>R!==null&&j.indexOf(R)===A);await Promise.allSettled(S);try{await e.backend.dispose()}finally{n.phase!=="disposed"&&h("disposed"),a.clear()}})();return s=m,m.catch(()=>{s===m&&(s=null)}),m}})}function Be(e,t,r,a){return Na(r)?ct({...st("reload-required","runtime",r),recoverable:!1}):ct({...st(e,t,r),recoverable:a})}function Na(e){return e instanceof Error&&e.name==="PlayableEditorEntryReloadRequiredError"}function st(e,t,r){return Object.freeze({code:e,phase:t,message:La(r)})}function ct(e){return Object.freeze({...e,primary:e.primary?Object.freeze({...e.primary}):void 0,rollback:e.rollback?Object.freeze({...e.rollback}):void 0})}function ir(e){return Object.freeze({...e,phaseDurationsMs:Object.freeze({...e.phaseDurationsMs}),failure:e.failure?ct(e.failure):null})}function La(e){return e instanceof Error&&e.message.trim()?e.message:typeof e=="string"&&e.trim()?e:"Unknown editor entry failure."}function sr(e){return e instanceof Error&&e.name==="AbortError"}function _t(){const e=new Error("Editor entry was disposed.");return e.name="AbortError",e}function we(e){return Object.freeze({ok:!1,attempt:e,failure:Be("disposed","dispose",_t(),!1)})}function cs(e){const t=[],r=gn(),a=pn(),n=hn(),o=En(),i=bn(),s=Sn(),l=yn(),d=In(),h=e.materialShaderDefinitions??Pn;try{t.push(e.host.registerCommand({manifest:N(k.HIERARCHY_SCOPE_GET),handler:async(c,u)=>{const g=e.sceneAssembly.getHierarchyItems(G(u)),b={scopeKey:"scene",scopeType:"scene",revision:u.session.getState({cloneDocuments:!1}).documentRevision,title:"Scene",readonly:!1,nodes:g.map(m=>({id:m.id,label:m.label,parentId:m.parentId??null,selectable:!0,canHaveChildren:!0,renamable:!0,deletable:!0,draggable:!0})),selectedIds:u.session.getSelection().selectedIds,activeId:u.session.getSelection().activeId,capabilities:{},totalCount:g.length,returnedCount:g.length},p=await r(b,c);return p.ok?{ok:!0,output:p.output}:{ok:!1,diagnostics:[{severity:"error",source:"hierarchy",code:p.code,message:p.message}]}}})),t.push(e.host.registerCommand({manifest:N(k.SCENE_OBJECTS_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=g.workingDocument,p=Nt(b),m=await a(b.scene.gameObjects.map(S=>$e(S,b,p)),c,g.documentRevision);return m.ok?{ok:!0,output:{objects:m.items,totalCount:m.totalCount,returnedCount:m.returnedCount,...m.nextCursor?{nextCursor:m.nextCursor}:{}}}:be(m)}})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_RESOLVE,{activeId:"objectId"}),handler:(c,u)=>go(G(u),c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_PROPERTIES_GET),handler:(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=An(g.workingDocument,c,g.documentRevision,e.sceneAssembly.getInspectorObject);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_REFERENCES_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await i(g.workingDocument,c,g.documentRevision);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.ASSET_LIBRARY_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=[...await e.listAssets(g.workingDocument)].map(Tn),p=await n(b,c,Rn(g.documentRevision,b));return p.ok?{ok:!0,output:{assets:p.items,totalCount:p.totalCount,returnedCount:p.returnedCount,...p.nextCursor?{nextCursor:p.nextCursor}:{}}}:be(p)}})),t.push(e.host.registerCommand({manifest:N(k.ASSET_INFO_GET),handler:async(c,u)=>{const g=c.assetId.trim(),b=[...await e.listAssets(G(u))].find(p=>p.assetId===g||p.id===g);return b?{ok:!0,output:{asset:vn(b)}}:P("asset.notFound",`Asset was not found: ${g}`)}})),t.push(e.host.registerCommand({manifest:N(k.ASSET_REFERENCES_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await o(g.workingDocument,c,g.documentRevision);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.AUTHORING_VALIDATION_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await s(g.workingDocument,c,g.documentRevision);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.PREFAB_RESOLVE),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await e.listAssets(g.workingDocument),p=g.workingDocument.assets.filter(S=>!!S.prefab).map(S=>wn(S,b)),m=await l(p,c,g.documentRevision);return m.ok?{ok:!0,output:{prefabs:m.items,resolvedPrefab:m.totalCount===1?m.items[0]??null:null,ambiguous:m.totalCount>1,currentStage:null,totalCount:m.totalCount,returnedCount:m.returnedCount,...m.nextCursor?{nextCursor:m.nextCursor}:{}}}:be(m)}})),t.push(e.host.registerCommand({manifest:N(k.PREFAB_SCENE_GET),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await d(g.workingDocument,c,g.documentRevision,{dirty:g.dirty});return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSETS_LIST),handler:(c,u)=>({ok:!0,output:Ba(G(u),c)})})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_GET),handler:(c,u)=>$a(G(u),c.materialAssetId)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_CREATE),handler:(c,u)=>Ha(u,e.sceneAssembly,c,h)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_DUPLICATE),handler:(c,u)=>Va(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_DELETE),handler:(c,u)=>qa(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_RENAME),handler:(c,u)=>Ya(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_SET_SHADER),handler:(c,u)=>Wa(u,e.sceneAssembly,c,h)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_SHADER_DEFINITIONS_LIST),handler:c=>({ok:!0,output:za(h,c)})})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_SHADER_DEFINITION_GET),handler:c=>Ua(h,c.shaderId)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_REFERENCES_LIST),handler:(c,u)=>Ja(G(u),c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_BINDINGS_LIST),handler:(c,u)=>({ok:!0,output:mt(Dt(G(u),c),c.cursor,c.limit)})})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_BINDING_SET),handler:(c,u)=>lr(u,e.sceneAssembly,c.targets,c.materialAssetId)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_BINDING_CLEAR),handler:(c,u)=>lr(u,e.sceneAssembly,c.targets,null)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_PROPERTIES_GET),handler:(c,u)=>Xa(G(u),c.materialAssetId,c.includeSchema===!0,h)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_PROPERTIES_PATCH),handler:(c,u)=>Za(u,e.sceneAssembly,c,h)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_CREATE_GROUP),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>mr(u,e.sceneAssembly,c,e.sceneAssembly.createCreateGroupPatch)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_CREATE_PRIMITIVE),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>mr(u,e.sceneAssembly,c,e.sceneAssembly.createCreatePrimitivePatch)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_RENAME),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>ao(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_MOVE),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>oo(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_SET_ENABLED),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>co(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_DELETE,{selectedIds:"objectIds"}),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>lo(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_DUPLICATE),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>io(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_GROUP),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>so(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_PROPERTIES_PATCH_MANY),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>Eo(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.TRANSFORM_MOVE,{activeId:"objectId"}),handler:(c,u)=>{const g=Ze(G(u),c.objectId);if(!g)return P("object.notFound",`Scene object was not found: ${c.objectId}`);const b=c.position??(c.offset?{x:g.position.x+c.offset.x,y:g.position.y+c.offset.y,z:g.position.z+c.offset.z}:null);if(!b)return P("transform.invalidInput","Transform move requires position or offset.");const p=e.sceneAssembly.patchGameObjectField(G(u),c.objectId,"transform.position",b),m=Ze(p,c.objectId);return!m||JSON.stringify(m)===JSON.stringify(g)?P("transform.unchanged",`Transform did not change: ${c.objectId}`):(u.dispatch({type:"document.replace",document:p,label:`Move ${c.objectId}`,projectionImpact:{type:"incremental",syncTransformIds:[c.objectId]}}),{ok:!0,output:{objectId:c.objectId,before:g,after:m,selection:u.session.getSelection()}})}})),t.push(e.host.registerCommand({manifest:N(k.TRANSFORM_SET,{activeId:"objectId"}),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>{const g=G(u),b=Ze(g,c.objectId);if(!b)return P("object.notFound",`Scene object was not found: ${c.objectId}`);const p=u.session.getState({cloneDocuments:!1}).documentRevision,m="changes"in c?c.changes:null,S="changes"in c?null:c,R=m?Fa(m):null;if(R)return P("transform.invalidInput",`Transform changes contain a duplicate path: ${R}.`,{objectId:c.objectId,path:R});if(!m&&!S?.expected&&u.expectedRevision?.document!==p)return P("command.documentRevisionMismatch",`Expected document revision ${u.expectedRevision?.document}, received ${p}.`,{expected:u.expectedRevision?.document,actual:p});const A=m?.filter(w=>!Object.is(cr(b,w.path),w.expected))??[],j=S?["position","rotation","scale"].filter(w=>S.expected?.[w]&&!ze(S.expected[w],b[w])):[];if(A.length>0||j.length>0){const w=A.length>0?A.map(_=>_.path):j.map(_=>`transform.${_}`);return P("authoring.remoteConflict",`Transform changed after the command base revision: ${c.objectId}.`,{objectId:c.objectId,paths:w,expected:A.length>0?Object.fromEntries(A.map(_=>[_.path,_.expected])):Object.fromEntries(j.map(_=>[_,{...S.expected[_]}])),actual:A.length>0?Object.fromEntries(A.map(_=>[_.path,cr(b,_.path)])):Object.fromEntries(j.map(_=>[_,{...b[_]}])),baseDocumentRevision:u.expectedRevision?.document??null,actualDocumentRevision:p})}const M=m?new Set(m.map(w=>w.path)):null,T=m?Ga(b,m):{position:S.position?{...S.position}:{...b.position},rotation:S.rotation?{...S.rotation}:{...b.rotation},scale:S.scale?{...S.scale}:{...b.scale}},U=e.sceneAssembly.patchGameObjectTransform(g,c.objectId,{position:T.position,rotation:T.rotation,scale:T.scale}),O=Ze(U,c.objectId);return!O||xa(O,b)?P("transform.unchanged",`Transform did not change: ${c.objectId}`):(u.dispatch({type:"document.replace",document:U,label:`Set transform on ${c.objectId}`,projectionImpact:{type:"incremental",syncTransformIds:[c.objectId]},presentationImpact:{inspector:["transform"]},authoringPatch:{kind:"fields",writes:["position","rotation","scale"].flatMap(w=>(M||S[w])&&!ze(b[w],O[w])?["x","y","z"].flatMap(_=>M&&!M.has(`transform.${w}.${_}`)||Object.is(b[w][_],O[w][_])?[]:[{targetId:c.objectId,path:`transform.${w}.${_}`,before:b[w][_],after:O[w][_]}]):[])}}),{ok:!0,output:{objectId:c.objectId,before:b,after:O,selection:u.session.getSelection()}})}})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_CREATE_FROM_ASSET),handler:async(c,u)=>{const g=G(u),b=[...await e.listAssets(g)].find(R=>R.assetId===c.assetId);if(!b)return P("asset.notFound",`Asset was not found: ${c.assetId}`);if(!Cn(b))return P("asset.unplaceable",`Asset is not placeable: ${c.assetId}`);const p=e.sceneAssembly.addAssetLibraryItemToDocument(g,b,ro(c)),m=e.sceneAssembly.getHierarchyItems(p.document),S=m.findIndex(R=>R.id===p.gameObject.id);return S<0?P("asset.create.invalidResult",`Created asset object is missing from the authoritative hierarchy: ${p.gameObject.id}`):(u.dispatch({type:"document.replace",document:p.document,label:`Create ${p.gameObject.name??p.gameObject.id}`,projectionImpact:{type:"incremental",createdNodeIds:[p.gameObject.id]},presentationImpact:{hierarchy:"full",inspector:"full"}}),u.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"create",node:structuredClone(p.gameObject),index:S,parentId:m[S]?.parentId??null}]}),c.select!==!1&&u.session.dispatch({type:"selection.replace",selectedIds:[p.gameObject.id],activeId:p.gameObject.id,label:"Select Created Item"}),{ok:!0,output:{assetId:c.assetId,createdId:p.gameObject.id,object:$e(p.gameObject,p.document),selection:u.session.getSelection(),focused:!1,status:`Created ${p.gameObject.name??p.gameObject.id}`}})}}))}catch(c){for(const u of t.splice(0).reverse())u();throw c}return()=>{for(const c of t.splice(0).reverse())c()}}function ze(e,t){return Object.is(e.x,t.x)&&Object.is(e.y,t.y)&&Object.is(e.z,t.z)}function xa(e,t){return ze(e.position,t.position)&&ze(e.rotation,t.rotation)&&ze(e.scale,t.scale)}function Lr(e){const[,t,r]=e.split(".");return[t,r]}function cr(e,t){const[r,a]=Lr(t);return e[r][a]}function Ga(e,t){const r={position:{...e.position},rotation:{...e.rotation},scale:{...e.scale}};for(const a of t){const[n,o]=Lr(a.path);r[n][o]=a.value}return r}function Fa(e){const t=new Set;for(const r of e){if(t.has(r.path))return r.path;t.add(r.path)}return null}function Ba(e,t){const r=t.query?.trim().toLowerCase()??"",a=t.path?.trim().toLowerCase()??"",n=t.shaderId?.trim()??"",o=(e.scene.materialAssets??[]).map(i=>({id:i.id,name:i.name?.trim()||i.id,shaderId:i.shaderId,...i.definitionVersion!=null?{definitionVersion:i.definitionVersion}:{},properties:structuredClone(i.properties),...i.origin?{origin:structuredClone(i.origin)}:{}})).filter(i=>!n||i.shaderId===n).filter(i=>!r||`${i.name}
1
+ import{gp as wr,$ as qt,_ as tn,G as rn,H as nn,kv as Ct,kJ as an,kw as Yt,c3 as on,iK as sn,jR as cn,fZ as dn,j9 as ln,hn as un,jZ as mn,lq as Cr,lk as Mr,lr as fn,bM as gn,cQ as pn,bI as hn,bK as En,bN as bn,bL as Sn,bO as yn,bP as In,w as Pn,p as k,kr as An,nf as Tn,bJ as Rn,ne as vn,ng as wn,he as Cn,n as Mn,o as _n,r as Dn,m as Wt,s as On,kN as _r,g6 as W,bd as kt,ba as jn,m9 as kn,kT as Nn,gD as Ln,gr as xn,gq as Gn,hk as Fn,jm as Bn,ny as zn,gs as Un,D as $n,cS as Hn,l as Vn,E as qn,kM as Yn,jQ as Wn,lv as ut,q as Kn,t as Jn,u as Xn,lC as Kt,g0 as Zn,mC as Qn,ms as ea,jL as ta,aO as Jt,jx as Xt,n7 as Zt,mM as ra,gf as he,bn as na,bm as aa,gQ as oa,a5 as Qt,mD as ia}from"./playable-standard-project-ZEkeio_2.js";import{C as Ns,a as Ls,b as xs,c as Gs,d as Fs,e as Bs,f as zs,g as Us,h as $s,i as Hs,j as Vs,k as qs,v as Ys,x as Ws,y as Ks,z as Js,A as Xs,B as Zs,F as Qs,I as ec,J as tc,K as rc,L as nc,M as ac,N as oc,O as ic,P as sc,Q as cc,R as dc,S as lc,T as uc,U as mc,V as fc,W as gc,X as pc,Y as hc,Z as Ec,a0 as bc,a1 as Sc,a2 as yc,a3 as Ic,a4 as Pc,a6 as Ac,a7 as Tc,a8 as Rc,a9 as vc,aa as wc,ab as Cc,ac as Mc,ad as _c,ae as Dc,af as Oc,ag as jc,ah as kc,ai as Nc,aj as Lc,ak as xc,al as Gc,am as Fc,an as Bc,ao as zc,ap as Uc,aq as $c,ar as Hc,as as Vc,at as qc,au as Yc,av as Wc,aw as Kc,ax as Jc,ay as Xc,az as Zc,aA as Qc,aB as ed,aC as td,aD as rd,aE as nd,aF as ad,aG as od,aH as id,aI as sd,aJ as cd,aK as dd,aL as ld,aM as ud,aN as md,aP as fd,aQ as gd,aR as pd,aS as hd,aT as Ed,aU as bd,aV as Sd,aW as yd,aX as Id,aY as Pd,aZ as Ad,a_ as Td,a$ as Rd,b0 as vd,b1 as wd,b2 as Cd,b3 as Md,b4 as _d,b5 as Dd,b6 as Od,b7 as jd,b8 as kd,b9 as Nd,bb as Ld,bc as xd,be as Gd,bf as Fd,bg as Bd,bh as zd,bi as Ud,bj as $d,bk as Hd,bl as Vd,bo as qd,bp as Yd,bq as Wd,br as Kd,bs as Jd,bt as Xd,bu as Zd,bv as Qd,bw as el,bx as tl,by as rl,bz as nl,bA as al,bB as ol,bC as il,bD as sl,bE as cl,bF as dl,bG as ll,bH as ul,bQ as ml,bR as fl,bS as gl,bT as pl,bU as hl,bV as El,bW as bl,bX as Sl,bY as yl,bZ as Il,b_ as Pl,b$ as Al,c0 as Tl,c1 as Rl,c2 as vl,c4 as wl,c5 as Cl,c6 as Ml,c7 as _l,c8 as Dl,c9 as Ol,ca as jl,cb as kl,cc as Nl,cd as Ll,ce as xl,cf as Gl,cg as Fl,ch as Bl,ci as zl,cj as Ul,ck as $l,cl as Hl,cm as Vl,cn as ql,co as Yl,cp as Wl,cq as Kl,cr as Jl,cs as Xl,ct as Zl,cu as Ql,cv as eu,cw as tu,cx as ru,cy as nu,cz as au,cA as ou,cB as iu,cC as su,cD as cu,cE as du,cF as lu,cG as uu,cH as mu,cI as fu,cJ as gu,cK as pu,cL as hu,cM as Eu,cN as bu,cO as Su,cP as yu,cR as Iu,cT as Pu,cU as Au,cV as Tu,cW as Ru,cX as vu,cY as wu,cZ as Cu,c_ as Mu,c$ as _u,d0 as Du,d1 as Ou,d2 as ju,d3 as ku,d4 as Nu,d5 as Lu,d6 as xu,d7 as Gu,d8 as Fu,d9 as Bu,da as zu,db as Uu,dc as $u,dd as Hu,de as Vu,df as qu,dg as Yu,dh as Wu,di as Ku,dj as Ju,dk as Xu,dl as Zu,dm as Qu,dn as em,dp as tm,dq as rm,dr as nm,ds as am,dt as om,du as im,dv as sm,dw as cm,dx as dm,dy as lm,dz as um,dA as mm,dB as fm,dC as gm,dD as pm,dE as hm,dF as Em,dG as bm,dH as Sm,dI as ym,dJ as Im,dK as Pm,dL as Am,dM as Tm,dN as Rm,dO as vm,dP as wm,dQ as Cm,dR as Mm,dS as _m,dT as Dm,dU as Om,dV as jm,dW as km,dX as Nm,dY as Lm,dZ as xm,d_ as Gm,d$ as Fm,e0 as Bm,e1 as zm,e2 as Um,e3 as $m,e4 as Hm,e5 as Vm,e6 as qm,e7 as Ym,e8 as Wm,e9 as Km,ea as Jm,eb as Xm,ec as Zm,ed as Qm,ee as ef,ef as tf,eg as rf,eh as nf,ei as af,ej as of,ek as sf,el as cf,em as df,en as lf,eo as uf,ep as mf,eq as ff,er as gf,es as pf,et as hf,eu as Ef,ev as bf,ew as Sf,ex as yf,ey as If,ez as Pf,eA as Af,eB as Tf,eC as Rf,eD as vf,eE as wf,eF as Cf,eG as Mf,eH as _f,eI as Df,eJ as Of,eK as jf,eL as kf,eM as Nf,eN as Lf,eO as xf,eP as Gf,eQ as Ff,eR as Bf,eS as zf,eT as Uf,eU as $f,eV as Hf,eW as Vf,eX as qf,eY as Yf,eZ as Wf,e_ as Kf,e$ as Jf,f0 as Xf,f1 as Zf,f2 as Qf,f3 as eg,f4 as tg,f5 as rg,f6 as ng,f7 as ag,f8 as og,f9 as ig,fa as sg,fb as cg,fc as dg,fd as lg,fe as ug,ff as mg,fg,fh as gg,fi as pg,fj as hg,fk as Eg,fl as bg,fm as Sg,fn as yg,fo as Ig,fp as Pg,fq as Ag,fr as Tg,fs as Rg,ft as vg,fu as wg,fv as Cg,fw as Mg,fx as _g,fy as Dg,fz as Og,fA as jg,fB as kg,fC as Ng,fD as Lg,fE as xg,fF as Gg,fG as Fg,fH as Bg,fI as zg,fL as Ug,fM as $g,fN as Hg,fO as Vg,fP as qg,fQ as Yg,fR as Wg,fS as Kg,fT as Jg,fU as Xg,fV as Zg,fW as Qg,fX as ep,fY as tp,f_ as rp,f$ as np,g1 as ap,g2 as op,g3 as ip,g4 as sp,g5 as cp,g7 as dp,g8 as lp,g9 as up,ga as mp,gb as fp,gc as gp,gd as pp,ge as hp,gg as Ep,gh as bp,gi as Sp,gj as yp,gk as Ip,gl as Pp,gm as Ap,gn as Tp,go as Rp,gt as vp,gu as wp,gv as Cp,gw as Mp,gx as _p,gy as Dp,gz as Op,gA as jp,gB as kp,gC as Np,gE as Lp,gF as xp,gG as Gp,gH as Fp,gI as Bp,gJ as zp,gK as Up,gL as $p,gM as Hp,gN as Vp,gO as qp,gP as Yp,gR as Wp,gS as Kp,gT as Jp,gU as Xp,gV as Zp,gW as Qp,gX as eh,gY as th,gZ as rh,g_ as nh,g$ as ah,h0 as oh,h1 as ih,h2 as sh,h3 as ch,h4 as dh,h5 as lh,h6 as uh,h7 as mh,h8 as fh,h9 as gh,ha as ph,hb as hh,hc as Eh,hd as bh,hf as Sh,hg as yh,hh as Ih,hi as Ph,hj as Ah,hl as Th,hm as Rh,ho as vh,hp as wh,hq as Ch,hr as Mh,hs as _h,ht as Dh,hu as Oh,hv as jh,hw as kh,hx as Nh,hy as Lh,hz as xh,hA as Gh,hB as Fh,hC as Bh,hD as zh,hE as Uh,hF as $h,hG as Hh,hH as Vh,hI as qh,hJ as Yh,hK as Wh,hL as Kh,hM as Jh,hN as Xh,hO as Zh,hP as Qh,hQ as eE,hR as tE,hS as rE,hT as nE,hU as aE,hV as oE,hW as iE,hX as sE,hY as cE,hZ as dE,h_ as lE,h$ as uE,i1 as mE,i2 as fE,i3 as gE,i4 as pE,i5 as hE,i6 as EE,i7 as bE,i8 as SE,i9 as yE,ia as IE,ib as PE,ic as AE,id as TE,ie as RE,ig as vE,ih as wE,ii as CE,ij as ME,ik as _E,il as DE,im as OE,io as jE,ip as kE,iq as NE,ir as LE,is as xE,it as GE,iu as FE,iv as BE,iw as zE,ix as UE,iy as $E,iz as HE,iA as VE,iB as qE,iC as YE,iD as WE,iE as KE,iF as JE,iG as XE,iH as ZE,iI as QE,iJ as eb,iL as tb,iM as rb,iN as nb,iO as ab,iP as ob,iQ as ib,iR as sb,iS as cb,iT as db,iU as lb,iV as ub,iW as mb,iX as fb,iY as gb,iZ as pb,i_ as hb,i$ as Eb,j0 as bb,j1 as Sb,j2 as yb,j3 as Ib,j4 as Pb,j5 as Ab,j6 as Tb,j7 as Rb,j8 as vb,ja as wb,jb as Cb,jc as Mb,jd as _b,je as Db,jf as Ob,jg as jb,jh as kb,ji as Nb,jj as Lb,jk as xb,jl as Gb,jn as Fb,jo as Bb,jp as zb,jq as Ub,jr as $b,js as Hb,jt as Vb,ju as qb,jv as Yb,jw as Wb,jy as Kb,jz as Jb,jA as Xb,jB as Zb,jC as Qb,jD as eS,jE as tS,jF as rS,jG as nS,jH as aS,jI as oS,jJ as iS,jK as sS,jM as cS,jN as dS,jO as lS,jP as uS,jS as mS,jT as fS,jU as gS,jV as pS,jW as hS,jX as ES,jY as bS,j_ as SS,j$ as yS,k0 as IS,k1 as PS,k2 as AS,k3 as TS,k4 as RS,k5 as vS,k6 as wS,k7 as CS,k8 as MS,k9 as _S,ka as DS,kb as OS,kc as jS,kd as kS,ke as NS,kf as LS,kg as xS,kh as GS,ki as FS,kj as BS,kk as zS,kl as US,km as $S,kn as HS,ko as VS,kp as qS,kq as YS,ks as WS,kt as KS,ku as JS,kx as XS,ky as ZS,kz as QS,kA as ey,kB as ty,kC as ry,kD as ny,kE as ay,kF as oy,kG as iy,kH as sy,kI as cy,kK as dy,kL as ly,kO as uy,kP as my,kQ as fy,kR as gy,kS as py,kU as hy,kV as Ey,kW as by,kX as Sy,kY as yy,kZ as Iy,k_ as Py,k$ as Ay,l0 as Ty,l1 as Ry,l2 as vy,l3 as wy,l4 as Cy,l5 as My,l6 as _y,l7 as Dy,l8 as Oy,l9 as jy,la as ky,lb as Ny,lc as Ly,ld as xy,le as Gy,lf as Fy,lg as By,lh as zy,li as Uy,lj as $y,ll as Hy,lm as Vy,ln as qy,lo as Yy,lp as Wy,ls as Ky,lt as Jy,lu as Xy,lw as Zy,lx as Qy,ly as eI,lz as tI,lA as rI,lB as nI,lD as aI,lE as oI,lF as iI,lG as sI,lH as cI,lI as dI,lJ as lI,lK as uI,lL as mI,lM as fI,lN as gI,lO as pI,lP as hI,lQ as EI,lR as bI,lS as SI,lT as yI,lU as II,lV as PI,lW as AI,lX as TI,lY as RI,lZ as vI,l_ as wI,l$ as CI,m0 as MI,m1 as _I,m2 as DI,m3 as OI,m4 as jI,m5 as kI,m6 as NI,m7 as LI,m8 as xI,ma as GI,mb as FI,mc as BI,md as zI,me as UI,mf as $I,mg as HI,mh as VI,mi as qI,mj as YI,mk as WI,ml as KI,mm as JI,mn as XI,mo as ZI,mp as QI,mq as eP,mr as tP,mt as rP,mu as nP,mv as aP,mw as oP,mx as iP,my as sP,mz as cP,mA as dP,mB as lP,mE as uP,mF as mP,mG as fP,mH as gP,mI as pP,mJ as hP,mK as EP,mL as bP,mN as SP,mO as yP,mP as IP,mQ as PP,mR as AP,mS as TP,mT as RP,mU as vP,mV as wP,mW as CP,mX as MP,mY as _P,mZ as DP,m_ as OP,m$ as jP,n0 as kP,n1 as NP,n2 as LP,n3 as xP,n4 as GP,n5 as FP,n6 as BP,n8 as zP,n9 as UP,na as $P,nb as HP,nc as VP,nd as qP,nh as YP,ni as WP,nj as KP,nk as JP,nl as XP,nm as ZP,nn as QP,no as eA,np as tA,nq as rA,nr as nA,ns as aA,nt as oA,nu as iA,nv as sA,nw as cA,nx as dA,nz as lA,nA as uA,nB as mA,nC as fA,nD as gA,nE as pA,nF as hA,nG as EA,nH as bA,nI as SA,nJ as yA,nK as IA}from"./playable-standard-project-ZEkeio_2.js";import"./dynamicTexture-Cuby-VOT.js";import"@fps-games/editor-core/plugin-host";function Qi(e,t){const r=wr(e),a=sa(t),n=r.revision??null;if(!a)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:null,reason:"missing-generated-from"};const o=typeof a.revision=="number"?a.revision:null;return a.sourceId!==r.sourceId||a.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:o,reason:"source-mismatch"}:n!==o?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:o,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:n,generatedRevision:o}}function sa(e){if(!e||typeof e!="object")return null;const t=e.meta;if(!t||typeof t!="object")return null;const r=t.generatedFrom;if(!r||typeof r!="object")return null;const a=r.sourceId,n=r.sourceType;return typeof a!="string"||typeof n!="string"?null:{sourceId:a,sourceType:n,revision:typeof r.revision=="number"?r.revision:void 0}}function ca(e){const{document:t,runtimePatch:r}=e,a=e.getSourceRef?.(t)??wr(t),n=r.sourceBinding;if(!r.applyable||!n||r.applyTarget!==qt||n.sourceId!==tn||n.sourceType!==qt||n.sourceId!==a.sourceId||n.sourceType!==a.sourceType)return null;const o=n.objectId;if(!o||!e.findGameObject(t,o)||e.isRootGameObjectId?.(o))return null;const i=r.after;return da(i)?{label:r.label??`Apply runtime transform ${o}`,patch:e.createPatch(o,i)}:null}function es(e,t){return ca({document:e,runtimePatch:t,findGameObject:(r,a)=>r.scene.gameObjects.find(n=>n.id===a)??null,isRootGameObjectId:r=>r==="root",createPatch:(r,a)=>({kind:"game-object.transform",targetId:r,transform:a})})}function da(e){if(!e||typeof e!="object")return!1;const t=e;return Et(t.position)&&Et(t.rotation)&&Et(t.scale)}function Et(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)&&typeof t.z=="number"&&Number.isFinite(t.z)}const Dr="fps-editor.lighting-debug.open",Or="fps-editor.lighting-debug.language",la=[{field:"environmentIntensity",textKey:"intensity",tooltipKey:"environmentIntensity",step:.01,min:0},{field:"iblIntensity",textKey:"iblIntensity",tooltipKey:"iblIntensity",step:.01,min:0,max:4},{field:"iblRotationY",textKey:"iblRotationY",tooltipKey:"iblRotationY",step:.01},{field:"directionalIntensity",textKey:"intensity",tooltipKey:"directionalIntensity",step:.01,min:0},{field:"directionalHorizontalAngle",textKey:"horizontalAngle",tooltipKey:"horizontalAngle",step:.01,min:-180,max:180},{field:"directionalElevationAngle",textKey:"elevationAngle",tooltipKey:"elevationAngle",step:.01,min:nn,max:rn},{field:"shadowStrength",textKey:"shadowStrength",tooltipKey:"shadowStrength",step:.01,min:0,max:1},{field:"shadowSoftness",textKey:"shadowSoftness",tooltipKey:"shadowSoftness",step:.005,min:0,max:1}];function Ee(e){const t=la.find(r=>r.field===e);if(!t)throw new Error(`Missing lighting number field config: ${e}`);return t}function bt(e){const t=e.trim();if(!t||/^[+-]$/.test(t)||t.endsWith(".")||/[eE][+-]?$/.test(t))return null;const r=Number(t);return Number.isFinite(r)?r:null}const er={zh:{title:"光照调试",runtime:"运行时",languageButton:"EN",toggleTitle:"打开光照调试面板",environmentSection:"环境光",environmentTextureSection:"环境贴图 IBL",directionalSection:"直射光",shadowSection:"阴影外观",enabled:"启用",intensity:"强度",iblIntensity:"IBL 强度",iblRotationY:"IBL 旋转",skyLightColor:"天空光颜色",groundColor:"地面颜色",horizontalAngle:"水平角",elevationAngle:"高度角",lightColor:"光照颜色",rawDirection:"原始方向",shadowReadout:"阴影",shadowStrength:"阴影强度",shadowSoftness:"轮廓柔和度",shadowMap:"Shadow Map",shadowPlanarFollow:"Planar / 跟随直射光",shadowDynamic:"动态阴影",shadowBlob:"Blob 阴影",shadowStatic:"静态烘焙阴影",shadowNone:"Off",shadowUnknown:"Unknown",reset:"重置参数",save:"保存参数",resetStatus:"已重置为初始运行时光照。",savingStatus:"正在保存光照、IBL 和阴影参数...",savedStatus:"已保存光照、IBL 和阴影参数。",saveFailed:"保存失败",missingBindingStatus:"缺少光源绑定,只能临时预览,不能保存。"},en:{title:"Lighting Debug",runtime:"Runtime",languageButton:"中文",toggleTitle:"Toggle lighting debug panel",environmentSection:"Environment Light",environmentTextureSection:"Environment Texture IBL",directionalSection:"Directional Light",shadowSection:"Shadow Appearance",enabled:"Enabled",intensity:"Intensity",iblIntensity:"IBL Intensity",iblRotationY:"IBL Rotation",skyLightColor:"Sky Light Color",groundColor:"Ground Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",lightColor:"Light Color",rawDirection:"Raw Direction",shadowReadout:"Shadow",shadowStrength:"Shadow Strength",shadowSoftness:"Edge Softness",shadowMap:"Shadow Map",shadowPlanarFollow:"Planar / Follow Directional Light",shadowDynamic:"Dynamic Shadow",shadowBlob:"Blob Shadow",shadowStatic:"Static Baked Shadow",shadowNone:"Off",shadowUnknown:"Unknown",reset:"Reset",save:"Save Parameters",resetStatus:"Reset to initial runtime lighting.",savingStatus:"Saving lighting, IBL and shadows...",savedStatus:"Saved lighting, IBL and shadows.",saveFailed:"Save failed",missingBindingStatus:"Light binding missing; preview only, saving disabled."}},tr={zh:{languageButton:"切换光照调试面板的显示语言。",toggleTitle:"打开或关闭运行时光照调试面板。",enabled:"启用或禁用对应的运行时光源,保存后写回编辑器场景。",environmentIntensity:"环境光强度,对应运行时环境光 intensity。",iblIntensity:"环境贴图对 PBR 材质的光照贡献强度;实时预览不会重新加载贴图。",iblRotationY:"环境贴图绕 Y 轴的旋转弧度,用于调整环境反射和高光方向。",directionalIntensity:"直射光强度,对应运行时直射光 intensity。",skyLightColor:"环境光来自天空方向的漫反射颜色。",groundColor:"环境光来自地面反射方向的颜色。",horizontalAngle:"直射光在 XZ 平面内的朝向角度,会转换为运行时方向向量。",elevationAngle:"直射光相对地平线的高度角;90 度表示从正上方照下。",lightColor:"直射光漫反射颜色。",rawDirection:"只读方向向量,用于排查运行时转换结果。",shadowReadout:"只读阴影状态;支持宿主提供的运行时阴影模式摘要。",shadowStrength:"控制阴影的可见深浅;1 最深,0 不显示阴影。",shadowSoftness:"控制阴影接收边缘的柔和程度;0 表示硬边。",reset:"恢复为打开运行时时读取到的初始光照、IBL 和阴影参数。",save:"通过编辑器保存链路写回环境光、直射光、IBL 和 Shadow Map 外观参数。"},en:{languageButton:"Switch the lighting debug panel language.",toggleTitle:"Open or close the runtime lighting debug panel.",enabled:"Enable or disable the runtime light and save it back to the editor scene.",environmentIntensity:"Environment intensity. Maps to the runtime environment light intensity.",iblIntensity:"Environment texture contribution to PBR lighting. Live preview does not reload the texture.",iblRotationY:"Environment texture rotation around the Y axis in radians, affecting reflections and highlights.",directionalIntensity:"Directional intensity. Maps to the runtime directional light intensity.",skyLightColor:"Diffuse sky color for the environment light.",groundColor:"Ground bounce color for the environment light.",horizontalAngle:"Directional heading in the XZ plane, converted to a runtime direction vector.",elevationAngle:"Directional elevation above the horizon; 90 degrees points straight down.",lightColor:"Directional diffuse color.",rawDirection:"Read-only direction vector for checking runtime conversion.",shadowReadout:"Read-only shadow status supplied by the host runtime.",shadowStrength:"Visible shadow strength. One is darkest; zero hides the shadow.",shadowSoftness:"Receiver-edge softness. Zero produces a hard edge.",reset:"Restore the lighting, IBL and shadows captured when runtime opened.",save:"Save lighting, IBL and Shadow Map appearance through the editor authoring pipeline."}};function ua(e){return er[e]??er.zh}function ma(e){return tr[e]??tr.zh}function fa(e,t){return e==="shadow-map"?t.shadowMap:e==="planar"?t.shadowPlanarFollow:e==="dynamic"?t.shadowDynamic:e==="blob"?t.shadowBlob:e==="static"?t.shadowStatic:e==="none"?t.shadowNone:t.shadowUnknown}function ga(e){try{return e?.localStorage?.getItem(Dr)==="true"}catch{return!1}}function pa(e,t){try{e?.localStorage?.setItem(Dr,String(t))}catch{}}function ha(e){try{return e?.localStorage?.getItem(Or)==="en"?"en":"zh"}catch{return"zh"}}function Ea(e,t){try{e?.localStorage?.setItem(Or,t)}catch{}}function ts(e,t){const r=rr(rr(e)?.__fpsEditor),a=ce(r?.sourceId),n=ce(r?.objectGuid),o=ce(r?.objectId),i=ce(r?.propertyPath),s=ce(r?.lightType);return!a||i!=="light"||!n&&!o||t&&s&&s!==t?null:{sourceId:a,propertyPath:"light",...t?{lightType:t}:s?{lightType:s}:{},...n?{objectGuid:n}:{},...o?{objectId:o}:{}}}function ba(e){const t=ce(e.sourceId),r=ce(e.propertyPath),a=ce(e.objectGuid),n=ce(e.objectId),o=ce(e.lightType);if(!t)throw new Error("Runtime light binding is missing sourceId.");if(r!=="light")throw new Error(`Runtime light binding is not for light: ${r??"missing"}`);if(!a&&!n)throw new Error("Runtime light binding is missing objectGuid/objectId.");return{sourceId:t,propertyPath:r,...a?{objectGuid:a}:{},...n?{objectId:n}:{},...o?{lightType:o}:{}}}function rr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ce(e){return typeof e=="string"&&e.trim()?e.trim():null}function Se(e){return{environment:{enabled:e.environment.enabled,binding:e.environment.binding?{...e.environment.binding}:null,light:{type:"hemispheric",intensity:e.environment.light.intensity,...e.environment.light.diffuseColor?{diffuseColor:{...e.environment.light.diffuseColor}}:{},...e.environment.light.groundColor?{groundColor:{...e.environment.light.groundColor}}:{}}},...e.environmentTexture?{environmentTexture:{...e.environmentTexture}}:{},directional:{enabled:e.directional.enabled,binding:e.directional.binding?{...e.directional.binding}:null,light:{type:"directional",intensity:e.directional.light.intensity,direction:{...e.directional.light.direction},...e.directional.light.diffuseColor?{diffuseColor:{...e.directional.light.diffuseColor}}:{}}},shadow:{...e.shadow,...e.shadow.shadowMap?{shadowMap:{...e.shadow.shadowMap,lastRefreshReasons:[...e.shadow.shadowMap.lastRefreshReasons],...e.shadow.shadowMap.appearance?{appearance:{...e.shadow.shadowMap.appearance}}:{}}}:{}}}}function it(e){return!!e.environment.binding&&!!e.directional.binding}function rs(e){return it(e)?[{binding:e.environment.binding,enabled:e.environment.enabled,light:e.environment.light},{binding:e.directional.binding,enabled:e.directional.enabled,light:e.directional.light}]:[]}function Le(e,t){switch(t){case"environmentIntensity":return e.environment.light.intensity;case"iblIntensity":return e.environmentTexture?.iblIntensity??0;case"iblRotationY":return e.environmentTexture?.iblRotationY??0;case"directionalIntensity":return e.directional.light.intensity;case"directionalHorizontalAngle":return Ct(e.directional.light.direction).horizontalAngleDeg;case"directionalElevationAngle":return Ct(e.directional.light.direction).elevationAngleDeg;case"shadowStrength":return e.shadow.shadowMap?.appearance?.strength??0;case"shadowSoftness":return e.shadow.shadowMap?.appearance?.softness??0}}function nr(e,t){switch(t){case"environmentDiffuseColor":return e.environment.light.diffuseColor??{r:1,g:1,b:1};case"environmentGroundColor":return e.environment.light.groundColor??{r:.48,g:.52,b:.62};case"directionalDiffuseColor":return e.directional.light.diffuseColor??{r:1,g:1,b:1}}}function Sa(e,t,r){if(!Number.isFinite(r))return Se(e);const a=Se(e);switch(t){case"environmentIntensity":return a.environment.light.intensity=r,a;case"iblIntensity":return a.environmentTexture&&(a.environmentTexture.iblIntensity=r),a;case"iblRotationY":return a.environmentTexture&&(a.environmentTexture.iblRotationY=r),a;case"directionalIntensity":return a.directional.light.intensity=r,a;case"directionalHorizontalAngle":{const n=Yt(e.directional.light.direction);return ar(a,r,n.elevationAngleDeg)}case"directionalElevationAngle":{const n=Yt(e.directional.light.direction);return ar(a,n.horizontalAngleDeg,r)}case"shadowStrength":{const n=a.shadow.shadowMap?.appearance;return n&&(n.strength=r,n.darkness=1-r),a}case"shadowSoftness":return a.shadow.shadowMap?.appearance&&(a.shadow.shadowMap.appearance.softness=r),a}}function ya(e,t,r){const a=Se(e);switch(t){case"environmentDiffuseColor":return a.environment.light.diffuseColor={...r},a;case"environmentGroundColor":return a.environment.light.groundColor={...r},a;case"directionalDiffuseColor":return a.directional.light.diffuseColor={...r},a}}function Ia(e,t,r){const a=Se(e);return a[t].enabled=r,a}function ar(e,t,r){const a=on(t,r);return Pa(e,a)}function Pa(e,t){const r=Se(e);return r.directional.light.direction={...t},r.shadow.projectedLengthMultiplier=an(t),r}function jr(e,t){const r=typeof t?.materialAssetId=="string"?t.materialAssetId.trim():"",a=r?e.scene.materialAssets?.find(o=>o.id===r)??null:null,n=sn(a?.properties,t?.override);return{materialAsset:a,...a?{materialAssetShaderId:a.shaderId}:{},profile:n,...r&&!a?{missingMaterialAssetId:r}:{}}}function ns(e,t){const r=jr(e,t.overrides?.materialBinding),a={},n=cn(r.materialAssetShaderId);return n&&(Object.keys(r.profile).length>0?(a.artistMaterialShaderId=n,a.artistMaterialProfile=r.profile):a.artistMaterialShaderId=n),a}function as(e,t){const r={},a=t.overrides?.materialSlotBindings??{};for(const[n,o]of Object.entries(a)){if(!n||!o)continue;const i=jr(e,o);Object.keys(i.profile).length!==0&&(r[n]=i.profile)}return r}function os(e,t){const r=Aa(t),a=[];for(const n of e.inspector.fields){if(n.control!=="color"||n.updateClass!=="uniform")continue;const o=Ta(e,n.schemaPath??n.path);if(o?.kind!=="color")continue;const i=o.channels===4?"vec4":"vec3",s=r.get(n.binding);if(!s){a.push({code:"material.shaderColorBindingMissing",path:n.path,binding:n.binding,expectedType:i,message:`GLSL uniform ${n.binding} is missing; expected ${i}.`});continue}s!==i&&a.push({code:"material.shaderColorBindingTypeMismatch",path:n.path,binding:n.binding,expectedType:i,actualType:s,message:`GLSL uniform ${n.binding} uses ${s}; Shader Definition expects ${i}.`})}return a}function Aa(e){const t=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,""),r=new Map,a=/\buniform\s+(?:(?:lowp|mediump|highp)\s+)?([A-Za-z_]\w*)\s+([A-Za-z_]\w*)\s*(?:\[[^\]]+\])?\s*;/g;for(const n of t.matchAll(a))r.set(n[2],n[1]);return r}function Ta(e,t){const r=t.replace(/^properties\./,"").split(".").filter(Boolean);let a=e.propertiesSchema;for(const n of r){if(a.kind!=="object")return null;const o=a.properties[n];if(!o)return null;a=o}return a}function is(e,t,r={}){const a=kr(e);let n=dn(e);const o=[];for(const i of t){const s=va(i),l=ba(s.binding);if(r.expectedSourceId&&l.sourceId!==r.expectedSourceId)throw new Error(`Runtime light binding source mismatch: ${l.sourceId} !== ${r.expectedSourceId}`);const d=Ra(n,l,a);if(!d)throw new Error("Runtime light binding did not match an editor light object.");Ma(d,s.light.type,l),n=xe(n,d.id,"enabled",s.enabled,r),n=xe(n,d.id,"light.intensity",s.light.intensity,r),s.light.diffuseColor&&(n=xe(n,d.id,"light.diffuseColor",s.light.diffuseColor,r)),s.light.type==="hemispheric"?s.light.groundColor&&(n=xe(n,d.id,"light.groundColor",s.light.groundColor,r)):n=xe(n,d.id,"light.direction",s.light.direction,r),o.push({id:d.id,...d.guid?{objectGuid:d.guid}:{},lightType:s.light.type})}return{document:n,targets:o}}function Ra(e,t,r=kr(e)){if(t.objectGuid){const o=e.scene.gameObjects.find(i=>i.guid===t.objectGuid)??null;if(o){if(t.objectId&&o.id!==t.objectId)throw new Error(`Runtime light binding guid/id conflict: ${t.objectGuid} belongs to ${o.id}, not ${t.objectId}.`);return o}}if(!t.objectId)return null;const a=e.scene.gameObjects.find(o=>o.id===t.objectId)??null;if(!a)return null;const n=r.get(a.id);if(t.objectGuid&&n&&n!==t.objectGuid)throw new Error(`Runtime light binding guid conflict for ${a.id}.`);return a}function va(e){const t=_a(e.enabled,"enabled");return e.light.type==="hemispheric"?{binding:e.binding,enabled:t,light:wa(e.light)}:{binding:e.binding,enabled:t,light:Ca(e.light)}}function wa(e){if(e.type!=="hemispheric")throw new Error("Runtime light patch must be hemispheric.");return{type:"hemispheric",intensity:Nr(e.intensity,"hemispheric.intensity"),...e.diffuseColor?{diffuseColor:Mt(e.diffuseColor,"hemispheric.diffuseColor")}:{},...e.groundColor?{groundColor:Mt(e.groundColor,"hemispheric.groundColor")}:{}}}function Ca(e){if(e.type!=="directional")throw new Error("Runtime light patch must be directional.");return{type:"directional",intensity:Nr(e.intensity,"directional.intensity"),direction:ln(Da(e.direction,"directional.direction")),...e.diffuseColor?{diffuseColor:Mt(e.diffuseColor,"directional.diffuseColor")}:{}}}function xe(e,t,r,a,n){return n.patchLightField?n.patchLightField(e,t,r,a):mn(e,t,r,a,n.fieldMutation)}function Ma(e,t,r){if(!un(e))throw new Error(`Runtime light binding target is not a light object: ${e.id}`);if(!e.light)throw new Error(`Runtime light binding target is missing light config: ${e.id}`);if(e.light.type!==t)throw new Error(`Runtime light binding type mismatch for ${e.id}: ${e.light.type} !== ${t}`);if(r.lightType&&r.lightType!==t)throw new Error(`Runtime light binding metadata type mismatch: ${r.lightType} !== ${t}`)}function kr(e){const t=new Map;for(const r of e.scene.gameObjects){const a=Oa(r.guid);a&&t.set(r.id,a)}return t}function _a(e,t){if(typeof e!="boolean")throw new Error(`Runtime light ${t} must be a boolean.`);return e}function Nr(e,t){if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new Error(`Runtime light ${t} must be a non-negative finite number.`);return e}function Mt(e,t){return{r:De(e.r,`${t}.r`),g:De(e.g,`${t}.g`),b:De(e.b,`${t}.b`)}}function Da(e,t){return{x:De(e.x,`${t}.x`),y:De(e.y,`${t}.y`),z:De(e.z,`${t}.z`)}}function De(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`Runtime light ${t} must be a finite number.`);return e}function Oa(e){return typeof e=="string"&&e.trim()?e.trim():null}function ss(e={}){const t=e.ttlMs??3e4,r=e.now??(()=>Date.now()),a=new Map;return{remember(n){const o=Mr(n);for(const i of fn(n)){const s=or(i);if(s.length===0)continue;const l={point:o??void 0,asset:i,timestamp:r()};for(const d of s)a.set(d,l)}St(a,t,r())},normalize(n){St(a,t,r());const o=Cr(n);if(!o)return n;const i=or(o),s=i.map(l=>a.get(l)).find(l=>!!l)??null;for(const l of i)a.delete(l);return ja(n,s)},clearExpired(){St(a,t,r())}}}function ja(e,t){const r=Cr(e);if(!r)return e;const a=t?.asset??{},n={...a,...r,...e},o=H(e.assetName)??H(r.assetName)??H(r.name)??H(a.assetName)??H(a.name),i=H(e.assetPath)??H(r.assetPath)??H(r.path)??H(a.assetPath)??H(a.path),s=H(e.assetUrl)??H(r.assetUrl)??H(r.url)??H(a.assetUrl)??H(a.url);return{...n,...o?{assetName:o}:{},...i?{assetPath:i}:{},...s?{assetUrl:s}:{},...t?.point&&!Mr(n)?{point:t.point}:{}}}function St(e,t,r){for(const[a,n]of e)r-n.timestamp>t&&e.delete(a)}function or(e){return[H(e.id),H(e.platformAssetId),H(e.assetId)].filter((t,r,a)=>!!t&&a.indexOf(t)===r)}function H(e){return typeof e=="string"&&e.trim()?e.trim():void 0}class ve extends Error{constructor(t){super(t),this.name="PlayableEditorEntryReloadRequiredError"}}function ka(e){const t=e.now??(()=>Date.now()),r=new AbortController,a=new Set;let n=ir({phase:"idle",attempt:0,phaseStartedAtMs:t(),phaseDurationsMs:{},failure:null}),o=null,i=null,s=null,l=!1;const d=m=>{try{e.reportListenerError?.(m)}catch{}},h=(m,S={})=>{const R=t(),A={...n.phaseDurationsMs,[n.phase]:Math.max(0,R-n.phaseStartedAtMs)};n=ir({phase:m,attempt:S.attempt??n.attempt,phaseStartedAtMs:R,phaseDurationsMs:A,failure:S.failure===void 0?null:S.failure});for(const j of[...a])try{j(n)}catch(M){d(M)}return n},c=(m,S,R)=>{try{e.reportFailure?.(Object.freeze({failure:m,cause:S,rollbackCause:R}))}catch(A){d(A)}},u=()=>{if(l||r.signal.aborted)throw _t()},g=m=>{if(l||n.phase==="disposed")return Promise.reject(_t());if(n.phase==="ready"||n.phase==="preparing"||n.phase==="committing"||n.phase==="editing"||n.phase==="failed"&&n.failure?.phase!=="warmup")return Promise.resolve();if(o)return o;const S=Promise.resolve().then(async()=>{try{h("warming",m===void 0?{}:{attempt:m}),u(),await e.backend.warmup?.(r.signal),u(),h("ready")}catch(R){if(l||r.signal.aborted)throw R;const A=Be("warmup-failed","warmup",R,!0);throw h("failed",{failure:A}),c(A,R),R}});return o=S,S.finally(()=>{o===S&&(o=null)}).catch(()=>{}),S},b=async()=>{if(l||n.phase==="disposed")return we(n.attempt);if(n.phase==="editing")return Object.freeze({ok:!0,attempt:n.attempt});if(n.phase==="failed"&&n.failure&&!n.failure.recoverable)return Object.freeze({ok:!1,attempt:n.attempt,failure:n.failure});const m=n.attempt+1;try{await g(m)}catch(R){if(l||r.signal.aborted)return we(m);const A=n.failure??Be("warmup-failed","warmup",R,!0);return Object.freeze({ok:!1,attempt:m,failure:A})}if(l)return we(m);h("preparing",{attempt:m});let S;try{S=await e.backend.prepare({signal:r.signal}),u()}catch(R){if(l||r.signal.aborted)return we(m);const A=Be("prepare-failed","prepare",R,!0);return h("failed",{attempt:m,failure:A}),c(A,R),Object.freeze({ok:!1,attempt:m,failure:A})}h("committing",{attempt:m});try{return await e.backend.commit(S,{signal:r.signal}),u(),h("editing",{attempt:m}),Object.freeze({ok:!0,attempt:m})}catch(R){h("rolling-back",{attempt:m});try{await e.backend.rollback(S,R)}catch(j){if(l&&sr(R)&&sr(j))return we(m);const M=st("commit-failed","commit",R),T=st("rollback-failed","rollback",j),U=ct({...T,recoverable:!1,primary:M,rollback:T});return l||h("failed",{attempt:m,failure:U}),c(U,R,j),Object.freeze({ok:!1,attempt:m,failure:U})}if(l||r.signal.aborted)return we(m);const A=Be("commit-failed","commit",R,!0);return h("failed",{attempt:m,failure:A}),c(A,R),Object.freeze({ok:!1,attempt:m,failure:A})}},p=()=>{if(i)return i;const m=b();return i=m,m.finally(()=>{i===m&&(i=null)}).catch(()=>{}),m};return Object.freeze({start:()=>g(),enter:p,retry(){const m=n.failure;return n.phase!=="failed"||!m||m.recoverable?p():Promise.resolve(Object.freeze({ok:!1,attempt:n.attempt,failure:m}))},reset(){if(l||n.phase==="disposed")throw new Error("Disposed editor entry controller cannot be reset.");if(o||i)throw new Error("Editor entry controller cannot be reset during an active operation.");if(n.phase==="failed"&&n.failure&&!n.failure.recoverable)throw new Error("Non-recoverable editor entry failure cannot be reset. Refresh the page.");(n.phase!=="idle"||n.attempt!==0||n.failure)&&h("idle",{attempt:0})},getState:()=>n,subscribe(m){if(l)return()=>{};a.add(m);try{m(n)}catch(S){d(S)}return()=>{a.delete(m)}},dispose(){if(s)return s;l=!0,r.abort();const m=(async()=>{const S=[i,o].filter((R,A,j)=>R!==null&&j.indexOf(R)===A);await Promise.allSettled(S);try{await e.backend.dispose()}finally{n.phase!=="disposed"&&h("disposed"),a.clear()}})();return s=m,m.catch(()=>{s===m&&(s=null)}),m}})}function Be(e,t,r,a){return Na(r)?ct({...st("reload-required","runtime",r),recoverable:!1}):ct({...st(e,t,r),recoverable:a})}function Na(e){return e instanceof Error&&e.name==="PlayableEditorEntryReloadRequiredError"}function st(e,t,r){return Object.freeze({code:e,phase:t,message:La(r)})}function ct(e){return Object.freeze({...e,primary:e.primary?Object.freeze({...e.primary}):void 0,rollback:e.rollback?Object.freeze({...e.rollback}):void 0})}function ir(e){return Object.freeze({...e,phaseDurationsMs:Object.freeze({...e.phaseDurationsMs}),failure:e.failure?ct(e.failure):null})}function La(e){return e instanceof Error&&e.message.trim()?e.message:typeof e=="string"&&e.trim()?e:"Unknown editor entry failure."}function sr(e){return e instanceof Error&&e.name==="AbortError"}function _t(){const e=new Error("Editor entry was disposed.");return e.name="AbortError",e}function we(e){return Object.freeze({ok:!1,attempt:e,failure:Be("disposed","dispose",_t(),!1)})}function cs(e){const t=[],r=gn(),a=pn(),n=hn(),o=En(),i=bn(),s=Sn(),l=yn(),d=In(),h=e.materialShaderDefinitions??Pn;try{t.push(e.host.registerCommand({manifest:N(k.HIERARCHY_SCOPE_GET),handler:async(c,u)=>{const g=e.sceneAssembly.getHierarchyItems(G(u)),b={scopeKey:"scene",scopeType:"scene",revision:u.session.getState({cloneDocuments:!1}).documentRevision,title:"Scene",readonly:!1,nodes:g.map(m=>({id:m.id,label:m.label,parentId:m.parentId??null,selectable:!0,canHaveChildren:!0,renamable:!0,deletable:!0,draggable:!0})),selectedIds:u.session.getSelection().selectedIds,activeId:u.session.getSelection().activeId,capabilities:{},totalCount:g.length,returnedCount:g.length},p=await r(b,c);return p.ok?{ok:!0,output:p.output}:{ok:!1,diagnostics:[{severity:"error",source:"hierarchy",code:p.code,message:p.message}]}}})),t.push(e.host.registerCommand({manifest:N(k.SCENE_OBJECTS_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=g.workingDocument,p=Nt(b),m=await a(b.scene.gameObjects.map(S=>$e(S,b,p)),c,g.documentRevision);return m.ok?{ok:!0,output:{objects:m.items,totalCount:m.totalCount,returnedCount:m.returnedCount,...m.nextCursor?{nextCursor:m.nextCursor}:{}}}:be(m)}})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_RESOLVE,{activeId:"objectId"}),handler:(c,u)=>go(G(u),c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_PROPERTIES_GET),handler:(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=An(g.workingDocument,c,g.documentRevision,e.sceneAssembly.getInspectorObject);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_REFERENCES_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await i(g.workingDocument,c,g.documentRevision);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.ASSET_LIBRARY_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=[...await e.listAssets(g.workingDocument)].map(Tn),p=await n(b,c,Rn(g.documentRevision,b));return p.ok?{ok:!0,output:{assets:p.items,totalCount:p.totalCount,returnedCount:p.returnedCount,...p.nextCursor?{nextCursor:p.nextCursor}:{}}}:be(p)}})),t.push(e.host.registerCommand({manifest:N(k.ASSET_INFO_GET),handler:async(c,u)=>{const g=c.assetId.trim(),b=[...await e.listAssets(G(u))].find(p=>p.assetId===g||p.id===g);return b?{ok:!0,output:{asset:vn(b)}}:P("asset.notFound",`Asset was not found: ${g}`)}})),t.push(e.host.registerCommand({manifest:N(k.ASSET_REFERENCES_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await o(g.workingDocument,c,g.documentRevision);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.AUTHORING_VALIDATION_LIST),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await s(g.workingDocument,c,g.documentRevision);return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.PREFAB_RESOLVE),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await e.listAssets(g.workingDocument),p=g.workingDocument.assets.filter(S=>!!S.prefab).map(S=>wn(S,b)),m=await l(p,c,g.documentRevision);return m.ok?{ok:!0,output:{prefabs:m.items,resolvedPrefab:m.totalCount===1?m.items[0]??null:null,ambiguous:m.totalCount>1,currentStage:null,totalCount:m.totalCount,returnedCount:m.returnedCount,...m.nextCursor?{nextCursor:m.nextCursor}:{}}}:be(m)}})),t.push(e.host.registerCommand({manifest:N(k.PREFAB_SCENE_GET),handler:async(c,u)=>{const g=u.session.getState({cloneDocuments:!1}),b=await d(g.workingDocument,c,g.documentRevision,{dirty:g.dirty});return b.ok?b:be(b)}})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSETS_LIST),handler:(c,u)=>({ok:!0,output:Ba(G(u),c)})})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_GET),handler:(c,u)=>$a(G(u),c.materialAssetId)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_CREATE),handler:(c,u)=>Ha(u,e.sceneAssembly,c,h)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_DUPLICATE),handler:(c,u)=>Va(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_DELETE),handler:(c,u)=>qa(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_RENAME),handler:(c,u)=>Ya(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_ASSET_SET_SHADER),handler:(c,u)=>Wa(u,e.sceneAssembly,c,h)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_SHADER_DEFINITIONS_LIST),handler:c=>({ok:!0,output:za(h,c)})})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_SHADER_DEFINITION_GET),handler:c=>Ua(h,c.shaderId)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_REFERENCES_LIST),handler:(c,u)=>Ja(G(u),c)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_BINDINGS_LIST),handler:(c,u)=>({ok:!0,output:mt(Dt(G(u),c),c.cursor,c.limit)})})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_BINDING_SET),handler:(c,u)=>lr(u,e.sceneAssembly,c.targets,c.materialAssetId)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_BINDING_CLEAR),handler:(c,u)=>lr(u,e.sceneAssembly,c.targets,null)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_PROPERTIES_GET),handler:(c,u)=>Xa(G(u),c.materialAssetId,c.includeSchema===!0,h)})),t.push(e.host.registerCommand({manifest:N(k.MATERIAL_PROPERTIES_PATCH),handler:(c,u)=>Za(u,e.sceneAssembly,c,h)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_CREATE_GROUP),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>mr(u,e.sceneAssembly,c,e.sceneAssembly.createCreateGroupPatch)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_CREATE_PRIMITIVE),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>mr(u,e.sceneAssembly,c,e.sceneAssembly.createCreatePrimitivePatch)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_RENAME),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>ao(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_MOVE),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>oo(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_SET_ENABLED),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>co(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_DELETE,{selectedIds:"objectIds"}),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>lo(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_DUPLICATE),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>io(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_GROUP),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>so(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_PROPERTIES_PATCH_MANY),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>Eo(u,e.sceneAssembly,c)})),t.push(e.host.registerCommand({manifest:N(k.TRANSFORM_MOVE,{activeId:"objectId"}),handler:(c,u)=>{const g=Ze(G(u),c.objectId);if(!g)return P("object.notFound",`Scene object was not found: ${c.objectId}`);const b=c.position??(c.offset?{x:g.position.x+c.offset.x,y:g.position.y+c.offset.y,z:g.position.z+c.offset.z}:null);if(!b)return P("transform.invalidInput","Transform move requires position or offset.");const p=e.sceneAssembly.patchGameObjectField(G(u),c.objectId,"transform.position",b),m=Ze(p,c.objectId);return!m||JSON.stringify(m)===JSON.stringify(g)?P("transform.unchanged",`Transform did not change: ${c.objectId}`):(u.dispatch({type:"document.replace",document:p,label:`Move ${c.objectId}`,projectionImpact:{type:"incremental",syncTransformIds:[c.objectId]}}),{ok:!0,output:{objectId:c.objectId,before:g,after:m,selection:u.session.getSelection()}})}})),t.push(e.host.registerCommand({manifest:N(k.TRANSFORM_SET,{activeId:"objectId"}),expectedRevisionPolicy:"handler-validated",handler:(c,u)=>{const g=G(u),b=Ze(g,c.objectId);if(!b)return P("object.notFound",`Scene object was not found: ${c.objectId}`);const p=u.session.getState({cloneDocuments:!1}).documentRevision,m="changes"in c?c.changes:null,S="changes"in c?null:c,R=m?Fa(m):null;if(R)return P("transform.invalidInput",`Transform changes contain a duplicate path: ${R}.`,{objectId:c.objectId,path:R});if(!m&&!S?.expected&&u.expectedRevision?.document!==p)return P("command.documentRevisionMismatch",`Expected document revision ${u.expectedRevision?.document}, received ${p}.`,{expected:u.expectedRevision?.document,actual:p});const A=m?.filter(w=>!Object.is(cr(b,w.path),w.expected))??[],j=S?["position","rotation","scale"].filter(w=>S.expected?.[w]&&!ze(S.expected[w],b[w])):[];if(A.length>0||j.length>0){const w=A.length>0?A.map(_=>_.path):j.map(_=>`transform.${_}`);return P("authoring.remoteConflict",`Transform changed after the command base revision: ${c.objectId}.`,{objectId:c.objectId,paths:w,expected:A.length>0?Object.fromEntries(A.map(_=>[_.path,_.expected])):Object.fromEntries(j.map(_=>[_,{...S.expected[_]}])),actual:A.length>0?Object.fromEntries(A.map(_=>[_.path,cr(b,_.path)])):Object.fromEntries(j.map(_=>[_,{...b[_]}])),baseDocumentRevision:u.expectedRevision?.document??null,actualDocumentRevision:p})}const M=m?new Set(m.map(w=>w.path)):null,T=m?Ga(b,m):{position:S.position?{...S.position}:{...b.position},rotation:S.rotation?{...S.rotation}:{...b.rotation},scale:S.scale?{...S.scale}:{...b.scale}},U=e.sceneAssembly.patchGameObjectTransform(g,c.objectId,{position:T.position,rotation:T.rotation,scale:T.scale}),O=Ze(U,c.objectId);return!O||xa(O,b)?P("transform.unchanged",`Transform did not change: ${c.objectId}`):(u.dispatch({type:"document.replace",document:U,label:`Set transform on ${c.objectId}`,projectionImpact:{type:"incremental",syncTransformIds:[c.objectId]},presentationImpact:{inspector:["transform"]},authoringPatch:{kind:"fields",writes:["position","rotation","scale"].flatMap(w=>(M||S[w])&&!ze(b[w],O[w])?["x","y","z"].flatMap(_=>M&&!M.has(`transform.${w}.${_}`)||Object.is(b[w][_],O[w][_])?[]:[{targetId:c.objectId,path:`transform.${w}.${_}`,before:b[w][_],after:O[w][_]}]):[])}}),{ok:!0,output:{objectId:c.objectId,before:b,after:O,selection:u.session.getSelection()}})}})),t.push(e.host.registerCommand({manifest:N(k.OBJECT_CREATE_FROM_ASSET),handler:async(c,u)=>{const g=G(u),b=[...await e.listAssets(g)].find(R=>R.assetId===c.assetId);if(!b)return P("asset.notFound",`Asset was not found: ${c.assetId}`);if(!Cn(b))return P("asset.unplaceable",`Asset is not placeable: ${c.assetId}`);const p=e.sceneAssembly.addAssetLibraryItemToDocument(g,b,ro(c)),m=e.sceneAssembly.getHierarchyItems(p.document),S=m.findIndex(R=>R.id===p.gameObject.id);return S<0?P("asset.create.invalidResult",`Created asset object is missing from the authoritative hierarchy: ${p.gameObject.id}`):(u.dispatch({type:"document.replace",document:p.document,label:`Create ${p.gameObject.name??p.gameObject.id}`,projectionImpact:{type:"incremental",createdNodeIds:[p.gameObject.id]},presentationImpact:{hierarchy:"full",inspector:"full"}}),u.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"create",node:structuredClone(p.gameObject),index:S,parentId:m[S]?.parentId??null}]}),c.select!==!1&&u.session.dispatch({type:"selection.replace",selectedIds:[p.gameObject.id],activeId:p.gameObject.id,label:"Select Created Item"}),{ok:!0,output:{assetId:c.assetId,createdId:p.gameObject.id,object:$e(p.gameObject,p.document),selection:u.session.getSelection(),focused:!1,status:`Created ${p.gameObject.name??p.gameObject.id}`}})}}))}catch(c){for(const u of t.splice(0).reverse())u();throw c}return()=>{for(const c of t.splice(0).reverse())c()}}function ze(e,t){return Object.is(e.x,t.x)&&Object.is(e.y,t.y)&&Object.is(e.z,t.z)}function xa(e,t){return ze(e.position,t.position)&&ze(e.rotation,t.rotation)&&ze(e.scale,t.scale)}function Lr(e){const[,t,r]=e.split(".");return[t,r]}function cr(e,t){const[r,a]=Lr(t);return e[r][a]}function Ga(e,t){const r={position:{...e.position},rotation:{...e.rotation},scale:{...e.scale}};for(const a of t){const[n,o]=Lr(a.path);r[n][o]=a.value}return r}function Fa(e){const t=new Set;for(const r of e){if(t.has(r.path))return r.path;t.add(r.path)}return null}function Ba(e,t){const r=t.query?.trim().toLowerCase()??"",a=t.path?.trim().toLowerCase()??"",n=t.shaderId?.trim()??"",o=(e.scene.materialAssets??[]).map(i=>({id:i.id,name:i.name?.trim()||i.id,shaderId:i.shaderId,...i.definitionVersion!=null?{definitionVersion:i.definitionVersion}:{},properties:structuredClone(i.properties),...i.origin?{origin:structuredClone(i.origin)}:{}})).filter(i=>!n||i.shaderId===n).filter(i=>!r||`${i.name}
2
2
  ${i.id}`.toLowerCase().includes(r)).filter(i=>!a||JSON.stringify(i.origin??{}).toLowerCase().includes(a)).sort((i,s)=>i.name.localeCompare(s.name)||i.id.localeCompare(s.id));return mt(o,t.cursor,t.limit)}function za(e,t){const r=t.query?.trim().toLowerCase()??"",a=e.list().map(xr).filter(n=>t.builtin===void 0||n.builtin===t.builtin).filter(n=>!r||`${n.displayName}
3
3
  ${n.shaderId}
4
4
  ${n.runtimeKind}`.toLowerCase().includes(r)).sort((n,o)=>n.displayName.localeCompare(o.displayName)||n.shaderId.localeCompare(o.shaderId));return mt(a,t.cursor,t.limit)}function Ua(e,t){const r=t?.trim(),a=e.get(r);return a?{ok:!0,output:{definition:{...xr(a),propertiesSchema:structuredClone(a.propertiesSchema),defaultProperties:structuredClone(a.defaultProperties),inspector:structuredClone(a.inspector)}}}:P("material.shaderDefinitionNotFound",`Shader Definition was not found: ${r}`)}function xr(e){return{shaderId:e.shaderId,version:e.version,runtimeKind:e.runtimeKind,displayName:e.displayName,builtin:Un(e.shaderId)!==null,...e.sourceFile?{sourceFile:e.sourceFile}:{},sectionCount:e.inspector.sections.length,fieldCount:e.inspector.fields.length}}function $a(e,t){const r=t?.trim(),a=W(e,r);return a?{ok:!0,output:{asset:{id:a.id,name:a.name?.trim()||a.id,shaderId:a.shaderId,...a.definitionVersion!=null?{definitionVersion:a.definitionVersion}:{},properties:structuredClone(a.properties),...a.origin?{origin:structuredClone(a.origin)}:{}},referenceCount:kt(e).filter(n=>n.materialAssetId===r).length}}:P("material.assetNotFound",`Material asset was not found: ${r}`)}function Ha(e,t,r,a){const n=r.shaderId?.trim(),o=a.get(n);if(!o)return P("material.shaderDefinitionNotFound",`Shader Definition was not found: ${n}`);const i=r.name?.trim();if(r.name!==void 0&&!i)return P("material.invalidName","Material name must not be empty.");const s=t.createMaterialAssetCreatePatch({document:e.session.getWorkingDocument(),definition:o,...i?{name:i}:{}});if(!s?.createdId)return P("material.assetMutationUnavailable","Material Asset creation is unavailable.");const l=e.session.getState({cloneDocuments:!1}).documentRevision;Ve(e,s);const d=W(e.session.getWorkingDocument(),s.createdId);return ke(e,null,ge(d)),{ok:!0,output:{asset:Te(d),changed:e.session.getState({cloneDocuments:!1}).documentRevision!==l,revision:e.session.getState({cloneDocuments:!1}).documentRevision}}}function Va(e,t,r){const a=e.session.getWorkingDocument(),n=r.materialAssetId?.trim();if(!W(a,n))return P("material.assetNotFound",`Material asset was not found: ${n}`);const i=t.createMaterialAssetDuplicatePatch({document:a,materialAssetId:n});if(!i?.createdId)return P("material.assetMutationUnavailable","Material Asset duplication is unavailable.");const s=e.session.getState({cloneDocuments:!1}).documentRevision;Ve(e,i);const l=W(e.session.getWorkingDocument(),i.createdId);if(!l)throw new Error(`Duplicated Material Asset is missing after the reducer: ${i.createdId}.`);return ke(e,null,ge(l)),{ok:!0,output:{sourceMaterialAssetId:n,asset:Te(l),changed:e.session.getState({cloneDocuments:!1}).documentRevision!==s,revision:e.session.getState({cloneDocuments:!1}).documentRevision}}}function qa(e,t,r){const a=e.session.getWorkingDocument(),n=r.materialAssetId?.trim(),o=W(a,n);if(!o)return P("material.assetNotFound",`Material asset was not found: ${n}`);const i=kt(a).filter(d=>d.materialAssetId===n);if(i.length>0)return P("material.assetInUse",`Material asset is still referenced: ${n}`,{materialAssetId:n,referenceCount:i.length});const s=t.createMaterialAssetDeletePatch({document:a,materialAssetId:n});if(!s)return P("material.assetReadonly",`Material asset cannot be deleted: ${n}`);const l=e.session.getState({cloneDocuments:!1}).documentRevision;if(Ve(e,s),W(e.session.getWorkingDocument(),n))throw new Error(`Deleted Material Asset is still present after the reducer: ${n}.`);return ke(e,ge(o),null),{ok:!0,output:{materialAssetId:n,changed:e.session.getState({cloneDocuments:!1}).documentRevision!==l,revision:e.session.getState({cloneDocuments:!1}).documentRevision}}}function Ya(e,t,r){const a=e.session.getWorkingDocument(),n=r.materialAssetId?.trim(),o=W(a,n);if(!o)return P("material.assetNotFound",`Material asset was not found: ${n}`);const i=r.name?.trim();if(!i)return P("material.invalidName","Material name must not be empty.");const s=(a.scene.materialAssets??[]).find(c=>c.id!==n&&c.name?.trim().toLocaleLowerCase()===i.toLocaleLowerCase());if(s)return P("material.nameConflict",`A Material Asset named "${i}" already exists.`,{materialAssetId:n,conflictingMaterialAssetId:s.id,name:i});if(o.name===i)return{ok:!0,output:{asset:Te(o),changed:!1,revision:e.session.getState({cloneDocuments:!1}).documentRevision}};const l=t.createMaterialAssetRenamePatch({document:a,materialAssetId:n,name:i});if(!l)return P("material.assetReadonly",`Material asset is read-only: ${n}`);const d=e.session.getState({cloneDocuments:!1}).documentRevision;Ve(e,l);const h=W(e.session.getWorkingDocument(),n);return ke(e,ge(o),ge(h),l.changedIds??l.reprojectIds??[]),{ok:!0,output:{asset:Te(h),changed:e.session.getState({cloneDocuments:!1}).documentRevision!==d,revision:e.session.getState({cloneDocuments:!1}).documentRevision}}}function Wa(e,t,r,a){const n=e.session.getWorkingDocument(),o=r.materialAssetId?.trim(),i=W(n,o);if(!i)return P("material.assetNotFound",`Material asset was not found: ${o}`);const s=r.shaderId?.trim(),l=a.get(s);if(!l)return P("material.shaderDefinitionNotFound",`Shader Definition was not found: ${s}`);if(i.shaderId===s)return{ok:!0,output:{asset:Te(i),previousShaderId:i.shaderId,changed:!1,revision:e.session.getState({cloneDocuments:!1}).documentRevision,preservedPaths:[],resetPaths:[]}};const d=t.createMaterialAssetSetShaderPatch({document:n,materialAssetId:o,definition:l});if(!d)return P("material.assetReadonly",`Material asset is read-only: ${o}`);if((d.resetPaths?.length??0)>0&&r.allowReset!==!0)return P("material.shaderChangeRequiresConfirmation",`Changing to ${l.displayName} resets ${d.resetPaths.length} incompatible material properties.`,{materialAssetId:o,previousShaderId:i.shaderId,shaderId:s,preservedPaths:d.preservedPaths??[],resetPaths:d.resetPaths??[]});const h=e.session.getState({cloneDocuments:!1}).documentRevision;Ve(e,d);const c=W(e.session.getWorkingDocument(),o);return ke(e,ge(i),ge(c),d.changedIds??d.reprojectIds??[]),{ok:!0,output:{asset:Te(c),previousShaderId:i.shaderId,changed:e.session.getState({cloneDocuments:!1}).documentRevision!==h,revision:e.session.getState({cloneDocuments:!1}).documentRevision,preservedPaths:d.preservedPaths??[],resetPaths:d.resetPaths??[]}}}function Ve(e,t){e.dispatch({type:"document.patch",patch:t.patch,label:t.label,...t.reprojectIds?.length?{projectionImpact:{type:"incremental",reprojectIds:t.reprojectIds}}:{},...t.presentationImpact?{presentationImpact:t.presentationImpact}:{}})}function ke(e,t,r,a=[]){const n={kind:"material",operations:[{type:"asset-update",materialAssetId:typeof r?.id=="string"?r.id:typeof t?.id=="string"?t.id:"",before:t,after:r,affectedNodeIds:[...new Set(a.filter(o=>o.trim().length>0))]}]};e.captureAuthoringPatch(n)}function ge(e){return JSON.parse(JSON.stringify(Te(e)))}function Ka(e,t){const r={kind:"material",operations:[{type:"binding-update",scope:t.scope,targetId:t.targetId,...t.containerId?{containerId:t.containerId}:{},...t.slotId?{slotId:t.slotId}:{},before:t.before,after:t.after,affectedNodeIds:[...new Set((t.affectedNodeIds??[]).filter(a=>a.trim().length>0))]}]};e.captureAuthoringPatch(r)}function Te(e){return{id:e.id,name:e.name?.trim()||e.id,shaderId:e.shaderId,...e.definitionVersion!=null?{definitionVersion:e.definitionVersion}:{},properties:structuredClone(e.properties),...e.origin?{origin:structuredClone(e.origin)}:{}}}function Ja(e,t){const r=t.materialAssetId?.trim();if(!W(e,r))return P("material.assetNotFound",`Material asset was not found: ${r}`);const a=kt(e).filter(n=>n.materialAssetId===r).filter(n=>!t.scope||n.scope===t.scope).map(n=>({scope:n.scope,kind:n.kind,materialAssetId:n.materialAssetId,...n.scope==="scene"?{objectId:n.gameObjectId}:{},...n.gameObjectName?{objectName:n.gameObjectName}:{},...n.prefabAssetId?{prefabAssetId:n.prefabAssetId}:{},...n.prefabNodeId?{nodeId:n.prefabNodeId}:{},...n.slotId?{slotId:n.slotId}:{},bindingPath:n.bindingPath,label:n.label})).sort((n,o)=>fe(n).localeCompare(fe(o)));return{ok:!0,output:{materialAssetId:r,...mt(a,t.cursor,t.limit)}}}function Dt(e,t){const r=t.scope==="prefab"?[]:e.scene.gameObjects.filter(n=>!t.objectId||n.id===t.objectId).flatMap(n=>{const o=jn(e,n),i=kn(e,n.id)??n.overrides;return o.length===0?[dt({scope:"scene",objectId:n.id},n.overrides?.materialBinding,i?.materialBinding,i!==n.overrides?"prefab-root":"default","overrides.materialBinding.materialAssetId")]:o.map(s=>dt({scope:"scene",objectId:n.id,slotId:s.slotId},n.overrides?.materialSlotBindings?.[s.slotId],i?.materialSlotBindings?.[s.slotId],i!==n.overrides?"prefab-root":"glb-source",`overrides.materialSlotBindings.${s.slotId}.materialAssetId`))}),a=t.scope==="scene"?[]:e.assets.filter(n=>n.type==="prefab"&&!!n.prefab).filter(n=>!t.prefabAssetId||n.id===t.prefabAssetId).flatMap(n=>{const o=t.nodeId?[]:dr(e,n,null,n.prefab.overrides,void 0),i=Nn(n),s=(n.prefab?.nodes??[]).filter(l=>l.id!==i).filter(l=>!t.nodeId||l.id===t.nodeId).flatMap(l=>dr(e,n,l,l.overrides,n.prefab.overrides));return[...o,...s]});return[...r,...a].sort((n,o)=>fe(n.target).localeCompare(fe(o.target)))}function dr(e,t,r,a,n){const o=eo(e,t,r),i={scope:"prefab",prefabAssetId:t.id,...r?{nodeId:r.id}:{}};return o.length===0?[dt(i,a?.materialBinding,a?.materialBinding??n?.materialBinding,n?.materialBinding?"prefab-root":"default","overrides.materialBinding.materialAssetId")]:o.map(s=>dt({...i,slotId:s},a?.materialSlotBindings?.[s],a?.materialSlotBindings?.[s]??n?.materialSlotBindings?.[s],n?.materialSlotBindings?.[s]?"prefab-root":"glb-source",`overrides.materialSlotBindings.${s}.materialAssetId`))}function dt(e,t,r,a,n){const o=ur(t?.materialAssetId),i=ur(r?.materialAssetId),s=o?"authored":i?a:e.slotId?"glb-source":"default";return{target:e,kind:e.slotId?"slot":"root",bindingPath:n,authoredMaterialAssetId:o,effectiveMaterialAssetId:i??(s==="glb-source"?null:$n),resolvedSource:s}}function lr(e,t,r,a){const n=G(e),o=a?.trim()||null;if(o&&!W(n,o))return P("material.assetNotFound",`Material asset was not found: ${o}`);const i=Qa(r);if(!i.ok)return i.failure;const s=new Map(Dt(n,{}).map(p=>[fe(p.target),p])),l=i.targets.map(p=>s.get(fe(p)));if(l.some(p=>!p))return P("material.invalidTarget","One or more material binding targets do not exist or require a logical slotId.");const d=l,c=i.targets[0].scope==="scene"?t.createSceneMaterialBindingPatch({document:n,materialAssetId:o,targets:l.map(p=>({objectId:p.target.objectId,path:p.bindingPath}))}):t.createPrefabMaterialBindingPatch({document:n,materialAssetId:o,targets:l.map(p=>({prefabAssetId:p.target.prefabAssetId,...p.target.nodeId?{nodeId:p.target.nodeId}:{},path:p.bindingPath}))});if(!c)return P("material.patchUnavailable","Material binding preflight rejected the atomic patch.");e.dispatch({type:"document.patch",patch:c.patch,label:c.label,...c.reprojectIds?.length?{projectionImpact:{type:"incremental",reprojectIds:c.reprojectIds}}:{},...c.presentationImpact?{presentationImpact:c.presentationImpact}:{}});const u=G(e),g=new Map(Dt(u,{}).map(p=>[fe(p.target),p])),b=i.targets.map(p=>g.get(fe(p)));return i.targets.forEach((p,m)=>{const S=d[m],R=b[m];Ka(e,{scope:p.scope,targetId:p.scope==="scene"?p.objectId:p.nodeId??p.prefabAssetId,...p.scope==="prefab"&&p.prefabAssetId?{containerId:p.prefabAssetId}:{},...p.slotId?{slotId:p.slotId}:{},before:S.authoredMaterialAssetId??null,after:R.authoredMaterialAssetId??null,affectedNodeIds:c.reprojectIds??[]})}),{ok:!0,output:{changed:b.some((p,m)=>JSON.stringify(p)!==JSON.stringify(d[m])),changedCount:b.filter((p,m)=>JSON.stringify(p)!==JSON.stringify(d[m])).length,revision:e.session.getState({cloneDocuments:!1}).documentRevision,bindings:b}}}function Xa(e,t,r,a){const n=t?.trim(),o=W(e,n),i=o?Ln(o.shaderId,a):null;return o?i?{ok:!0,output:{materialAssetId:n,shaderId:o.shaderId,properties:structuredClone(o.properties),defaults:structuredClone(i.defaultProperties),...r?{schema:structuredClone(i.propertiesSchema)}:{}}}:P("material.shaderUnsupported",`Unsupported material shader: ${o.shaderId}`):P("material.assetNotFound",`Material asset was not found: ${n}`)}function Za(e,t,r,a){const n=G(e),o=r.materialAssetId?.trim(),i=W(n,o);if(!i)return P("material.assetNotFound",`Material asset was not found: ${o}`);const s=new Set,l=[];for(const c of r.changes??[]){const u=to(c.path),g=xn(i.shaderId,u,a),b=Object.prototype.hasOwnProperty.call(c,"value"),p=c.reset===!0;if(!u||s.has(u)||!g||g.kind==="object"||b===p)return P("material.invalidPropertyPatch",`Invalid material property change: ${c.path}`);const m=p?Gn(i.shaderId,u,a):{found:!0,value:c.value};if(!m.found)return P("material.invalidPropertyPatch",`Material property cannot be reset: ${u}`);s.add(u),l.push({path:u,value:m.value})}const d=t.createMaterialPropertiesPatch({document:n,materialAssetId:o,changes:l});if(!d)return P("material.invalidPropertyPatch","Material property preflight rejected the atomic patch.");e.dispatch({type:"document.patch",patch:d.patch,label:d.label,...d.reprojectIds?.length?{projectionImpact:{type:"incremental",reprojectIds:d.reprojectIds}}:{}});const h=W(G(e),o);return ke(e,ge(i),ge(h),d.reprojectIds??[]),{ok:!0,output:{materialAssetId:o,shaderId:h.shaderId,changed:JSON.stringify(i.properties)!==JSON.stringify(h.properties),changedPaths:JSON.stringify(i.properties)!==JSON.stringify(h.properties)?[...s]:[],revision:e.session.getState({cloneDocuments:!1}).documentRevision,properties:structuredClone(h.properties)}}}function Qa(e){if(!Array.isArray(e)||e.length===0)return{ok:!1,failure:P("material.invalidTarget","At least one material target is required.")};const t=new Set,r=[];for(const a of e){const n=a.scope,o=a.objectId?.trim(),i=a.prefabAssetId?.trim(),s=a.nodeId?.trim(),l=a.slotId?.trim();if(n==="scene"&&(!o||i||s)||n==="prefab"&&(!i||o)||n!=="scene"&&n!=="prefab")return{ok:!1,failure:P("material.invalidTarget","Material target identity is invalid.")};const d={scope:n,...o?{objectId:o}:{},...i?{prefabAssetId:i}:{},...s?{nodeId:s}:{},...l?{slotId:l}:{}},h=fe(d);if(t.has(h))return{ok:!1,failure:P("material.invalidTarget","Duplicate material target.")};t.add(h),r.push(d)}return new Set(r.map(a=>a.scope)).size!==1?{ok:!1,failure:P("material.invalidTarget","Scene and Prefab targets cannot be mixed.")}:r[0].scope==="prefab"&&new Set(r.map(a=>a.prefabAssetId)).size!==1?{ok:!1,failure:P("material.invalidTarget","One atomic command must target one Prefab asset.")}:{ok:!0,targets:r}}function eo(e,t,r){const a=r?.sourceAssetId??t.prefab?.sourceAssetId,n=e.assets.find(i=>i.id===a);return(Array.isArray(n?.metadata?.materialSlots)?n.metadata.materialSlots:[]).map(Yn).filter(i=>!!i?.slotId).map(i=>i.slotId)}function mt(e,t,r){const a=t?/^offset:(\d+)$/.exec(t.trim()):null,n=a?Number(a[1]):0,o=Number.isSafeInteger(r)?Math.max(1,Math.min(200,Number(r))):50,i=e.slice(n,n+o),s=n+i.length;return{items:i,total:e.length,...s<e.length?{nextCursor:`offset:${s}`}:{}}}function fe(e){return[e.scope??"",e.objectId??"",e.prefabAssetId??"",e.nodeId??"",e.slotId??""].join("\0")}function to(e){const t=typeof e=="string"?e.trim():"";return t&&!t.startsWith("properties.")?`properties.${t}`:t}function ur(e){return typeof e=="string"&&e.trim()?e.trim():null}function ro(e){if(!(!e.position&&!e.rotation&&!e.scale))return{position:e.position??{x:0,y:0,z:0},rotation:e.rotation??{x:0,y:0,z:0},scale:e.scale??{x:1,y:1,z:1}}}function mr(e,t,r,a){const n=G(e),o=typeof r.parentId=="string"?r.parentId:typeof r.activeId=="string"?r.activeId:null;return o&&!t.getHierarchyItems(n).some(i=>i.id===o)?Ue(o,["exists"],{exists:!0},{exists:!1}):r.objectId&&t.getHierarchyItems(n).some(i=>i.id===r.objectId)?Ue(r.objectId,["exists"],{exists:!1},{exists:!0}):no(e,t,a(n,r))}function no(e,t,r){if(!r?.createdId)return P("command.unavailable","The requested Hierarchy create operation is unavailable.");const a=fo(r);e.dispatch({type:"document.patch",patch:r.patch,label:r.label,...a?{projectionImpact:a}:{},presentationImpact:{hierarchy:"full",inspector:"full"}});const n=G(e),o=n.scene.gameObjects.find(l=>l.id===r.createdId),i=t.getHierarchyItems(n),s=i.findIndex(l=>l.id===r.createdId);if(!o||s<0)throw new Error(`Created Hierarchy node is missing after the authoritative reducer: ${r.createdId}.`);return e.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"create",node:structuredClone(o),index:s,parentId:i[s]?.parentId??null}]}),{ok:!0,output:{createdId:r.createdId,object:$e(o,n),selection:e.session.getSelection()}}}function ao(e,t,r){const a=G(e),n=a.scene.gameObjects.find(d=>d.id===r.objectId);if(!n)return P("object.notFound",`Scene object was not found: ${r.objectId}`);const o=n.name??n.id;if(o!==r.expectedName)return Ue(r.objectId,["name"],{name:r.expectedName},{name:o});const i=t.createRenamePatch(a,{id:r.objectId,name:r.name});if(!i)return P("object.rename.unchanged",`Rename did not change: ${r.objectId}`);e.dispatch({type:"document.patch",patch:i.patch,label:i.label,projectionImpact:{type:"incremental",syncMetadataIds:[r.objectId]},presentationImpact:{hierarchy:{labelIds:[r.objectId]},inspector:["summary"]}});const s=G(e).scene.gameObjects.find(d=>d.id===r.objectId),l=s?.name??s?.id;if(!l||l===o)throw new Error(`Rename reducer did not converge: ${r.objectId}.`);return e.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"rename",targetId:r.objectId,before:o,after:l}]}),{ok:!0,output:{objectId:r.objectId,before:o,after:l}}}function oo(e,t,r){const a=G(e),n=ft(t,a,r.expectedNodes);if(n)return n;const o={ids:[...r.objectIds],targetId:r.targetId??null,placement:r.placement,...r.parentId!==void 0?{parentId:r.parentId}:{},...r.beforeId!==void 0?{beforeId:r.beforeId}:{},...r.afterId!==void 0?{afterId:r.afterId}:{},preserveWorldTransform:r.preserveWorldTransform!==!1},i=t.validateHierarchyMove(a,o);if(!i.ok)return P("object.move.rejected",i.reason??"Hierarchy move was rejected.");const s=t.createHierarchyMovePatch(a,o);if(!s)return P("object.move.unchanged","Hierarchy move did not change the document.");e.dispatch({type:"document.patch",patch:s.patch,label:s.label,projectionImpact:{type:"incremental",syncTransformIds:s.changedIds??[...r.objectIds]},presentationImpact:{hierarchy:"full",inspector:["transform"]}});const l=G(e),d=s.changedIds??[...r.objectIds],h=Gr(a,l,d,t.getHierarchyItems(a),t.getHierarchyItems(l));if(h.moves.length===0)throw new Error("Hierarchy move reducer produced no canonical changes.");return e.captureAuthoringPatch({kind:"hierarchy",operations:[h]}),{ok:!0,output:{movedIds:d}}}function io(e,t,r){const a=G(e),n=ft(t,a,r.expectedNodes);if(n)return n;const o=t.createDuplicateSelectionPatch({document:a,targetIds:[...r.objectIds],activeId:r.activeId??null});if(!o||o.createdIds.length===0)return P("object.duplicate.rejected","Hierarchy duplicate was rejected.");e.dispatch({type:"document.patch",patch:o.patch,label:o.label,projectionImpact:{type:"incremental",createdNodeIds:[...o.createdIds]},presentationImpact:{hierarchy:"full",inspector:"full"}});const i=G(e),s=t.getHierarchyItems(i),l=o.createdIds.map(c=>{const u=i.scene.gameObjects.find(b=>b.id===c),g=s.findIndex(b=>b.id===c);if(!u||g<0)throw new Error(`Duplicated Hierarchy node is missing after the reducer: ${c}.`);return{type:"create",node:structuredClone(u),index:g,parentId:s[g]?.parentId??null}}).sort((c,u)=>c.index-u.index);e.captureAuthoringPatch({kind:"hierarchy",operations:l});const d=o.selectedIds?.length?[...o.selectedIds]:[...o.createdIds],h=o.activeId&&d.includes(o.activeId)?o.activeId:d[d.length-1]??null;return d.length>0&&e.session.dispatch({type:"selection.replace",selectedIds:d,activeId:h,label:"Select Duplicated Nodes"}),{ok:!0,output:{createdIds:[...o.createdIds],selectedIds:d,activeId:h,selection:e.session.getSelection()}}}function so(e,t,r){const a=G(e),n=ft(t,a,r.expectedNodes);if(n)return n;const o={ids:[...r.objectIds],name:r.name,pivot:"selection-center",preserveWorldTransform:r.preserveWorldTransform!==!1,...r.parentId!==void 0?{parentId:r.parentId}:{},...r.insertBeforeId!==void 0?{insertBeforeId:r.insertBeforeId}:{}},i=t.validateGroupSelection(a,o);if(!i.ok)return P("object.group.rejected",i.reason??"Hierarchy group was rejected.");const s=t.createGroupSelectionPatch(a,o);if(!s?.createdId)return P("object.group.rejected","Hierarchy group was rejected.");const l=t.getHierarchyItems(a);e.dispatch({type:"document.patch",patch:s.patch,label:s.label,projectionImpact:{type:"incremental",createdNodeIds:[s.createdId],syncTransformIds:s.changedIds?.filter(m=>m!==s.createdId)??[...r.objectIds]},presentationImpact:{hierarchy:"full",inspector:"full"}});const d=G(e),h=t.getHierarchyItems(d),c=d.scene.gameObjects.find(m=>m.id===s.createdId),u=h.findIndex(m=>m.id===s.createdId);if(!c||u<0)throw new Error(`Grouped Hierarchy parent is missing after the reducer: ${s.createdId}.`);const g=[...l];g.splice(Math.min(u,g.length),0,h[u]);const b=(s.changedIds??[...r.objectIds]).filter(m=>m!==s.createdId),p=Gr(a,d,b,g,h);if(p.moves.length===0)throw new Error("Hierarchy group reducer produced no canonical moves.");return e.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"create",node:structuredClone(c),index:u,parentId:h[u]?.parentId??null},p]}),e.session.dispatch({type:"selection.replace",selectedIds:[s.createdId],activeId:s.createdId,label:"Select Created Parent"}),{ok:!0,output:{createdId:s.createdId,movedIds:b,selection:e.session.getSelection()}}}function co(e,t,r){const a=G(e),n=a.scene.gameObjects.find(d=>d.id===r.objectId);if(!n)return P("object.notFound",`Scene object was not found: ${r.objectId}`);const o=n.active!==!1;if(o!==r.expectedEnabled)return Ue(r.objectId,["enabled"],{enabled:r.expectedEnabled},{enabled:o});const i=t.patchGameObjectField(a,r.objectId,"enabled",r.enabled),l=i.scene.gameObjects.find(d=>d.id===r.objectId)?.active!==!1;return i===a||l===o?P("object.enabled.unchanged",`Enabled state did not change: ${r.objectId}`):(e.dispatch({type:"document.replace",document:i,label:`${r.enabled?"Enable":"Disable"} ${r.objectId}`,projectionImpact:{type:"incremental",syncAppearanceIds:[r.objectId]},presentationImpact:{hierarchy:"full",inspector:["summary"]}}),e.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"set-enabled",targetId:r.objectId,before:o,after:l}]}),{ok:!0,output:{objectId:r.objectId,before:o,after:l}})}function lo(e,t,r){const a=G(e);if(r.expectedNodes){const d=ft(t,a,r.expectedNodes);if(d)return d}else{const d=e.session.getState({cloneDocuments:!1}).documentRevision;if(e.expectedRevision?.document!==d)return P("command.documentRevisionMismatch",`Expected document revision ${e.expectedRevision?.document}, received ${d}.`,{expected:e.expectedRevision?.document,actual:d})}const n=r.objectIds??(r.objectId?[r.objectId]:[]),o=t.createDeleteSubtreePatch(a,{ids:n});if(!o)return P("command.unavailable","Hierarchy delete was rejected.");const i=o.deletedIds??n,s=t.getHierarchyItems(a),l=i.map(d=>{const h=a.scene.gameObjects.find(u=>u.id===d),c=s.findIndex(u=>u.id===d);if(!h||c<0)throw new Error(`Deleted Hierarchy node is missing from the command base: ${d}.`);return{node:structuredClone(h),index:c,parentId:s.find(u=>u.id===d)?.parentId??null}});return e.dispatch({type:"document.patch",patch:o.patch,label:o.label,projectionImpact:{type:"incremental",deletedNodeIds:i},presentationImpact:{hierarchy:"full",inspector:"full"}}),e.captureAuthoringPatch({kind:"hierarchy",operations:[{type:"delete",nodes:l}]}),{ok:!0,output:{deletedIds:i,fallbackSelectionId:e.session.getSelection().activeId,selection:e.session.getSelection()}}}function ft(e,t,r){const a=e.getHierarchyItems(t),n=r.map(i=>uo(a,i.objectId)),o=r.flatMap((i,s)=>mo(i,n[s])?[]:[i.objectId]);return o.length===0?null:Ue(o[0],["parentId","previousSiblingId","nextSiblingId"],{nodes:r},{nodes:n})}function uo(e,t){const r=e.find(i=>i.id===t);if(!r)return null;const a=r.parentId??null,n=e.filter(i=>(i.parentId??null)===a),o=n.findIndex(i=>i.id===t);return{objectId:t,parentId:a,previousSiblingId:o>0?n[o-1].id:null,nextSiblingId:o>=0&&o+1<n.length?n[o+1].id:null}}function mo(e,t){return!!t&&e.objectId===t.objectId&&e.parentId===t.parentId&&e.previousSiblingId===t.previousSiblingId&&e.nextSiblingId===t.nextSiblingId}function Ue(e,t,r,a){return P("authoring.remoteConflict",`Hierarchy changed after the command base revision: ${e}.`,{objectId:e,paths:t,expected:r,actual:a})}function Gr(e,t,r,a,n){return{type:"move",moves:r.flatMap(i=>{const s=a.findIndex(g=>g.id===i),l=n.findIndex(g=>g.id===i),d=e.scene.gameObjects.find(g=>g.id===i),h=t.scene.gameObjects.find(g=>g.id===i);if(!d||!h||s<0||l<0)return[];const c=d.components.find(g=>g.type==="Transform")??null,u=h.components.find(g=>g.type==="Transform")??null;return d.parentId===h.parentId&&s===l&&JSON.stringify(c)===JSON.stringify(u)?[]:[{targetId:i,beforeParentId:a.find(g=>g.id===i)?.parentId??null,afterParentId:n.find(g=>g.id===i)?.parentId??null,beforeIndex:s,afterIndex:l,beforeTransform:structuredClone(c),afterTransform:structuredClone(u)}]})}}function fo(e){const t=e.createdId?[e.createdId]:[],r=e.deletedIds??[];let a=[];if(e.reprojectIds?.length){const n=new Set([...t,...r]);a=e.reprojectIds.filter(o=>!n.has(o))}if(!(t.length===0&&r.length===0&&a.length===0))return{type:"incremental",...t.length?{createdNodeIds:t}:{},...r.length?{deletedNodeIds:r}:{},...a.length?{reprojectIds:a}:{}}}function go(e,t){const r=t.objectId??t.name??t.path??t.query??"",a=r.trim().toLocaleLowerCase(),n=e.scene.gameObjects.find(s=>s.id===r),o=n?[n]:e.scene.gameObjects.filter(s=>s.name?.trim().toLocaleLowerCase()===a||s.id.toLocaleLowerCase().includes(a)),i=Nt(e);return{ok:!0,output:{objects:o.map(s=>$e(s,e,i)),resolvedObject:o.length===1?$e(o[0],e,i):null,ambiguous:o.length>1}}}function $e(e,t,r=Nt(t)){const a=po(e);return{id:e.id,label:e.name??e.id,name:e.name??e.id,type:_r(e),...a?{sourceAssetId:a}:{},path:ho(r,e),parentId:e.parentId??null,selectable:!0,locked:!1}}function po(e){return e.components.find(r=>r.type==="ModelRenderer"||r.type==="ImageRenderer")?.assetId||e.prefab?.sourceAssetId||e.prefab?.prefabId}function Nt(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function ho(e,t){const r=[],a=new Set;let n=t;for(;n&&!a.has(n.id);)a.add(n.id),r.push(n.name??n.id),n=n.parentId?e.get(n.parentId):void 0;return r.reverse().join("/")}function Eo(e,t,r){const a=G(e),n=new Map(a.scene.gameObjects.map(m=>[m.id,m])),o=new Map,i=new Map,s=new Set,l=Hn({hasMaterialAsset:(m,S)=>!!W(m,S),isMarkerGameObject:m=>!!m.marker});let d=0;const h=e.session.getState({cloneDocuments:!1}).documentRevision;if(!r.targets.every(m=>m.changes.every(S=>Object.prototype.hasOwnProperty.call(S,"expected")))&&e.expectedRevision?.document!==h)return P("command.documentRevisionMismatch",`Expected document revision ${e.expectedRevision?.document}, received ${h}.`,{expected:e.expectedRevision?.document,actual:h});for(const m of r.targets){const S=m.objectId.trim(),R=n.get(S);if(!R)return P("object.notFound",`Scene object was not found: ${S}`);const A=new Map((t.getInspectorObject(a,S)?.sections??[]).flatMap(M=>M.properties).map(M=>[M.path,M])),j=o.get(S)??[];for(const M of m.changes){const T=M.path.trim(),U=`${S}\0${T}`;if(s.has(U))return P("object.properties.duplicateField",`Object property is duplicated: ${S}.${T}`);if(s.add(U),(T==="shadow.cast"||T==="shadow.receive")&&!Fn(R))return P("object.properties.readOnly",`Shadow participation is readonly for this target: ${S}.`);const O=A.get(T),w=Object.prototype.hasOwnProperty.call(M,"expected");if(w&&!O)return P("object.properties.unsupportedPath",`Inspector schema does not expose a field precondition path: ${S}.${T}`);const _=yt(O?.value);if(w&&!lt(M.expected,_))return P("authoring.remoteConflict",`Object properties changed after the command base revision: ${S}.`,{objectId:S,paths:[T],expected:{[T]:yt(M.expected)},actual:{[T]:_},baseDocumentRevision:e.expectedRevision.document,actualDocumentRevision:h});const K=O?.coerce?O.coerce(M.value):Bn(T,M.value),$=O?.validate?.(K)??zn({document:a,path:T,nodeKind:_r(R),value:K,extraValidators:[l]});if(!$.ok)return P("object.properties.invalid",`${$.message??`Invalid object property: ${T}.`} Target: ${S}.`);O&&i.set(U,_),j.push({path:T,value:K}),d+=1}o.set(S,j)}const u=[...o].map(([m,S])=>({objectId:m,changes:S})),g=t.patchGameObjectPropertiesMany(a,u),b=new Map(g.scene.gameObjects.map(m=>[m.id,m])),p=u.map(m=>m.objectId).filter(m=>b.get(m)!==n.get(m));if(g!==a){const m=u.flatMap(T=>{const U=new Map((t.getInspectorObject(g,T.objectId)?.sections??[]).flatMap(O=>O.properties).map(O=>[O.path,O]));return T.changes.flatMap(O=>{const w=`${T.objectId}\0${O.path}`,_=i.get(w),K=U.get(O.path);if(_===void 0||!K)return[];const $=yt(K.value);return lt(_,$)?[]:[{targetId:T.objectId,path:O.path,before:_,after:$}]})}),S=bo(m);if(m.length===0)return{ok:!0,output:{requestedObjectCount:u.length,validatedPropertyCount:d,changed:!1,changedObjectCount:0,sampleChangedObjectIds:[]}};const R=[],A=[],j=[],M=[];for(const T of p){const U=o.get(T)??[],O=new Set(U.map(w=>So(w.path)));if(O.has("reproject")){M.push(T);continue}O.has("transform")&&R.push(T),O.has("metadata")&&A.push(T),O.has("appearance")&&j.push(T)}e.dispatch({type:"document.replace",document:g,label:`Patch ${d} properties on ${u.length} objects`,...p.length>0?{projectionImpact:{type:"incremental",...R.length>0?{syncTransformIds:R}:{},...A.length>0?{syncMetadataIds:A}:{},...j.length>0?{syncAppearanceIds:j}:{},...M.length>0?{reprojectIds:M}:{}}}:{},...S?{authoringPatch:S}:{}})}return{ok:!0,output:{requestedObjectCount:u.length,validatedPropertyCount:d,changed:p.length>0,changedObjectCount:p.length,sampleChangedObjectIds:p.slice(0,20)}}}function yt(e){const t=JSON.stringify(e);return t===void 0?null:JSON.parse(t)}function lt(e,t){if(Object.is(e,t))return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>lt(i,t[s]));if(typeof e!="object"||typeof t!="object")return!1;const r=e,a=t,n=Object.keys(r).sort(),o=Object.keys(a).sort();return n.length===o.length&&n.every((i,s)=>i===o[s]&&lt(r[i],a[i]))}function bo(e){if(e.length===0||e.length>Vn)return;const t={kind:"fields",writes:e};return new TextEncoder().encode(JSON.stringify(t)).byteLength<=qn?t:void 0}function So(e){return e==="transform.position"||e.startsWith("transform.position.")||e==="transform.rotation"||e.startsWith("transform.rotation.")||e==="transform.scale"||e.startsWith("transform.scale.")?"transform":e==="name"||e.startsWith("metadata.")?"metadata":e==="active"||e==="enabled"||e.startsWith("shadow.")||e.startsWith("rendering.")||e.startsWith("overrides.material")||e.startsWith("overrides.outline")||e.startsWith("material.")?"appearance":"reproject"}function G(e){return e.session.getState({cloneDocuments:!1}).workingDocument}function N(e,t){const r=Mn[e],a=Dn[e],n=_n[e];if(!r)throw new Error(`Built-in Editor command metadata is missing: ${e}`);return{schemaVersion:On,id:e,version:1,title:r.title,...Wt[e]?{description:Wt[e]}:{},target:r.target,access:r.access,stability:r.stability,inputSchema:a.inputSchema,outputSchema:a.outputSchema,effects:{persistence:r.access==="write"?"authoring":"none",undoable:r.access==="write",idempotent:r.access==="read"},...r.target==="authoring"&&r.access==="write"?{transaction:{compatible:!0,sideEffects:"authoring",phase:"mutation"}}:{},presentation:{category:r.category,inputMode:yo(a.inputSchema)?"schema-form":"none",...n?.aliases?{aliases:n.aliases}:{},...n?.keywords?{keywords:n.keywords}:{},...n?.examples?{examples:n.examples}:{},...n?.shortcut?{shortcut:n.shortcut}:{},...n?.menu?{menu:n.menu}:{},...t?{selectionBinding:t}:{}}}}function Ze(e,t){const r=e.scene.gameObjects.find(n=>n.id===t),a=r?.components.find(n=>n.type==="Transform")??r?.transform;return!a||"mode"in a&&a.mode==="matrix"?null:{position:{...a.position},rotation:{...a.rotation},scale:{...a.scale??{x:1,y:1,z:1}}}}function yo(e){const t=e.properties;return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0}function P(e,t,r){return{ok:!1,diagnostics:[{severity:"error",source:"command",code:e,message:t,...r?{details:r}:{}}]}}function be(e){return P(e.code,e.message)}function ds(e){return{...e,paths:{...e.paths},supportedExtensions:e.supportedExtensions?[...e.supportedExtensions]:void 0,commands:e.commands?{...e.commands}:void 0}}const ls=["model","texture","image","sound"],Lt=[".glb",".gltf"],Fr=[".png",".jpg",".jpeg",".webp"],Io=[".env",".hdr",".dds",".ktx",".ktx2"],xt=[...Fr,...Io],Gt=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],Po=[...Lt,...xt,...Gt];function Ao(e){return e.randomUUID?e.randomUUID():wo(e)}function Br(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function To(e,t){const r=Br(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function us(e){const n=String(e??"").trim().split(/[^a-zA-Z0-9_$]+/).filter(Boolean).map((o,i)=>i===0?o:`${o.charAt(0).toUpperCase()}${o.slice(1)}`).join("").replace(/[^a-zA-Z0-9_$]/g,"")||"assetUrl";return/^[a-zA-Z_$]/.test(n)?n:`asset${n}`}function Ro(e,t=""){const r=String(e??"").trim().toLowerCase();if(r==="glb"||r==="gltf"||r==="model")return"model";if(r==="groundtexture"||r==="ground-texture"||r==="texture")return"texture";if(r==="ui"||r==="image"||r==="img")return"image";if(r==="audio"||r==="sound")return"sound";const a=vo(t);return Lt.includes(a)?"model":Gt.includes(a)?"sound":xt.includes(a)?"texture":null}function vo(e){const t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),a=t.slice(r+1),n=a.lastIndexOf(".");return n>=0?a.slice(n).toLowerCase():""}function wo(e){const t=new Uint8Array(16);if(!e.fillRandomBytes)throw new Error("Asset GUID random source must provide randomUUID or fillRandomBytes.");if(e.fillRandomBytes(t),t.every(a=>a===0))throw new Error("Asset GUID random source returned no entropy.");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const r=[...t].map(a=>a.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function Ft(e){let t=String(e??"").trim();const r=t.toLowerCase();for(const a of[...Po].sort((n,o)=>o.length-n.length))if(r.endsWith(a)){t=t.slice(0,-a.length);break}return t}function ms(e,t){return String(e??"").trim()||Ft(t)||"Asset"}function fs(e,t){return Ft(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function gs(e){return e==="model"?Lt:e==="sound"?Gt:e==="texture"?xt:e==="image"?Fr:[]}class Ae extends Error{constructor(t,r){super(r),this.code=t,this.name="PlayableEditorManagedAssetError"}}function Co(){const e=globalThis.crypto;return Ao({...typeof e?.randomUUID=="function"?{randomUUID:()=>e.randomUUID()}:{},fillRandomBytes(t){if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r+=1)t[r]=Math.floor(Math.random()*256)}})}function ps(e){return Br(e)}function Mo(e,t){return To(e,t)}function fr(e){return Ft(e).trim()}function zr(e,t,r){const a=jo(t.kind,t.assetPath??t.assetName),n=de(t.guid),o=de(t.assetId),i=Ur(t),s=ko(e,t);if(s&&n&&s.guid&&s.guid!==n)throw new Ae(r.errorCodes.assetIdConflict,`Requested guid "${n}" does not match existing asset guid "${s.guid}"`);const l=s?.guid??n??Co(),d=Mo(a,l);if(s?.id&&s.id!==d)throw new Ae(r.errorCodes.assetIdConflict,`Asset id "${s.id}" does not match guid "${l}" (expected "${d}")`);if(o&&o!==d)throw new Ae(r.errorCodes.assetIdConflict,`Project asset id "${o}" does not match guid "${l}" (expected "${d}")`);const h=e.assets.find(c=>c.id===d&&c.guid&&c.guid!==l);if(h)throw new Ae(r.errorCodes.assetIdConflict,`Asset id "${d}" already points to guid "${h.guid}"`);return{guid:l,assetId:d,kind:a,...i?{external:i}:s?.external?{external:s.external}:{}}}function _o(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;const t=e,r=It(t.x),a=It(t.y),n=It(t.z);if(!(r==null||a==null||n==null||r<=0||a<=0||n<=0))return{x:r,y:a,z:n}}function Ot(e,t,r){const a=zr(e,t,r),n=t.displayName?.trim()||fr(t.assetName)||fr(t.assetPath?.split("/").pop())||"Imported Asset",o=t.category?.trim(),i=No(t.materialMode),s=Lo(t.warmupCount),l=_o(t.defaultScale??t.scale),d=xo(t.metadata);return{...a,displayName:n,...o?{category:o}:{},...i?{materialMode:i}:{},...s!=null?{warmupCount:s}:{},...typeof t.singleton=="boolean"?{singleton:t.singleton}:{},...l?{scale:l}:{},...d?{metadata:d}:{}}}function jt(e,t){if(e.kind==="model")return{id:e.assetId,guid:e.guid,type:"glb",displayName:e.displayName,...e.category?{category:e.category}:{},...e.materialMode?{materialMode:e.materialMode}:{},...e.warmupCount!=null?{warmupCount:e.warmupCount}:{},...typeof e.singleton=="boolean"?{singleton:e.singleton}:{},...e.scale?{defaults:{transform:{scale:e.scale}}}:{},...e.external?{external:e.external}:{},metadata:{...e.metadata??{},[t.metadata.key]:t.metadata.value}}}function Do(e,t,r){const a=t.assetName||t.assetPath?.split("/").pop()||"imported_asset.glb",n=Ot(e,{...t,assetName:a},r),o=t.requestId,i=t.payloadPath??t.createPayloadPath?.({...o?{requestId:o}:{},guid:n.guid,assetId:n.assetId,kind:n.kind})??`/tmp/playable-editor-asset-${o??n.assetId}.json`,s=jt(n,r),l=t.registerCommand??"npm run asset:register",d={...t.assetPath?{sourcePath:t.assetPath,assetPath:t.assetPath}:{},...t.assetUrl?{assetUrl:t.assetUrl}:{},guid:n.guid,projectAssetId:n.assetId,assetType:n.kind,assetName:a,displayName:n.displayName,...n.category?{category:n.category}:{},...n.materialMode?{materialMode:n.materialMode}:{},...n.warmupCount!=null?{warmupCount:n.warmupCount}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...n.scale?{scale:n.scale}:{},...n.metadata?{metadata:n.metadata}:{},...n.external?{external:n.external}:{},...n.external?.platformAssetId?{platformAssetId:n.external.platformAssetId}:{}},h=`${l} -- --payload ${i}`;return{...o?{requestId:o}:{},guid:n.guid,assetId:n.assetId,kind:n.kind,displayName:n.displayName,...n.external?{external:n.external}:{},transportPlan:{writes:[{path:i,contentType:"application/json",content:d}],commands:[{cmd:h,cwd:".",timeoutMs:6e4}]},...s?{sceneAsset:s}:{}}}function Oo(e,t){const r=de(e.assetId),a=de(e.guid);if(!r&&!a)throw new Ae(t.errorCodes.missingAssetId??"missing_asset_id","Missing assetId or guid for asset unregistration");const n=e.requestId,o=e.payloadPath??e.createPayloadPath?.({...n?{requestId:n}:{},...r?{assetId:r}:{},...a?{guid:a}:{}})??`/tmp/playable-editor-asset-unregister-${n??r??a}.json`,i=e.deleteFile!==!1,s=e.unregisterCommand??"npm run asset:unregister",l={...r?{assetId:r}:{},...a?{guid:a}:{},deleteFile:i},d=`${s} -- --payload ${o}`;return{...n?{requestId:n}:{},...a?{guid:a}:{},assetId:r??"",transportPlan:{writes:[{path:o,contentType:"application/json",content:l}],commands:[{cmd:d,cwd:".",timeoutMs:6e4}]}}}function de(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function jo(e,t){return Ro(e,t)??"model"}function Ur(e){const t=e.external&&typeof e.external=="object"?e.external:{},r=de(t.platformAssetId)??de(e.platformAssetId);let a;if(Object.prototype.hasOwnProperty.call(t,"assetPath")){try{a=Wn(t.assetPath)}catch{throw new Ae("external_asset_path_must_be_portable","Explicit external.assetPath must be a non-empty portable relative path")}if(!a)throw new Ae("external_asset_path_must_be_portable","Explicit external.assetPath must be a non-empty portable relative path")}const n=de(t.assetUrl)??de(e.assetUrl);if(!(!r&&!a&&!n))return{...r?{platformAssetId:r}:{},...a?{assetPath:a}:{},...n?{assetUrl:n}:{}}}function ko(e,t){const r=de(t.guid),a=de(t.assetId),n=Ur(t);return e.assets.find(o=>!!(r&&o.guid===r||a&&o.id===a||n?.platformAssetId&&o.external?.platformAssetId===n.platformAssetId||n?.assetPath&&o.external?.assetPath===n.assetPath))}function It(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function No(e){return e==="shared"||e==="instance"?e:void 0}function Lo(e){return Number.isInteger(e)&&e>=0?e:void 0}function xo(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return JSON.parse(JSON.stringify(e))}function Go(e){return{resolveAssetIdentity:(t,r,a=e.rules)=>Ge(e,()=>zr(t,r,a)),buildAssetArgs:(t,r,a=e.rules)=>Ge(e,()=>Ot(t,r,a)),createSceneAsset:(t,r=e.rules)=>jt(t,r),planAssetRegistrationCore:(t,r,a=e.rules)=>Ge(e,()=>Do(t,Fo(r,e),a)),planAssetUnregistrationCore:(t,r=e.rules)=>Ge(e,()=>Oo(Bo(t,e),r)),resolveAssetReference:(t,r,a=e.rules)=>{const n=Ge(e,()=>Ot(t,r,a)),o=jt(n,a);if(!o)throw new Error(`Asset "${n.assetId}" is not a placeable model asset`);return{guid:n.guid,assetId:n.assetId,displayName:n.displayName,asset:o}}}}function Fo(e,t){return{...e,kind:e.kind??e.assetType,createPayloadPath:e.createPayloadPath??(e.payloadPath?void 0:t.createRegistrationPayloadPath)}}function Bo(e,t){return{...e,createPayloadPath:e.createPayloadPath??(e.payloadPath?void 0:t.createUnregistrationPayloadPath)}}function Ge(e,t){try{return t()}catch(r){throw e.wrapError&&e.wrapError(r),r}}function hs(e){const t=Go(e);return{facade:t,planAssetRegistration(r,a){return t.planAssetRegistrationCore(gr(a),r)},planAssetRegistrationWithAssets(r,a){return t.planAssetRegistrationCore({assets:r},a)},planAssetUnregistration(r){return t.planAssetUnregistrationCore(r)},resolveAssetReference(r,a){return t.resolveAssetReference(gr(a),r)}}}function gr(e){return{assets:e.getAssets()}}const zo="/__fps_runtime/debug-authoring";function Es(e={}){const t=e.endpoint?.trim()||zo,r=e.fetch??globalThis.fetch,a=Math.max(1,e.operationTimeoutMs??3e4);if(typeof r!="function")throw new Error("runtime_debug_authoring_fetch_unavailable");const n=async l=>{const d=await r(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l)}),h=await d.json().catch(()=>null);if(!h)throw new Error(Pt(h,`runtime_debug_authoring_http_${d.status}`));if(!h.ok)throw new Error(Pt(h,`runtime_debug_authoring_http_${d.status}`));if(!d.ok)throw new Error(`runtime_debug_authoring_http_${d.status}`);return h},o=async l=>{const d=await n({kind:"command.invoke",invocation:l,timeoutMs:Math.min(a,1e4)});if(d.kind!=="operation"||!d.operation)throw new Error("runtime_debug_authoring_operation_missing");let h=d.operation;const c=Date.now()+a;for(;h.status==="accepted"||h.status==="running";){if(Date.now()>=c)throw new Error("runtime_debug_authoring_operation_timeout");await Uo(25);const u=await n({kind:"operation.get",operationId:h.operationId});if(u.kind!=="operation"||!u.operation)throw new Error("runtime_debug_authoring_operation_missing");h=u.operation}if(h.status!=="completed")throw new Error(Pt({ok:!1,diagnostics:h.diagnostics??[]},`runtime_debug_authoring_operation_${h.status}`));return h};return Object.freeze({load:async()=>{const l=await n({kind:"authoring.snapshot"});if(l.kind!=="authoring.snapshot"||l.result.kind!=="snapshot-required")throw new Error("runtime_debug_authoring_snapshot_missing");const d=l.result.snapshot,h=hr("companion"),c=await o({commandId:"document.companionState.get",input:{},requestId:h,idempotencyKey:h,expectedRevision:{serviceInstanceId:d.serviceInstanceId,document:d.documentRevision},principal:{type:"human"},source:"runtime-debug-panel",surface:"runtime-debug-panel"});return{snapshot:d,companionState:pr(c)}},async commitAndSave(l){const d=hr("commit"),h=await o({commandId:"runtimeDebug.commitAndSave",intentCommandId:l.commandId,input:{commandId:l.commandId,inputFingerprint:l.inputFingerprint,document:l.document,...l.companionConfigs?{companionConfigs:l.companionConfigs}:{},...l.shadowMapExperimentConfig?{shadowMapExperimentConfig:l.shadowMapExperimentConfig}:{}},requestId:d,idempotencyKey:d,expectedRevision:{serviceInstanceId:l.serviceInstanceId,document:l.expectedDocumentRevision},principal:{type:"human"},source:"runtime-debug-panel",surface:"runtime-debug-panel"});return pr(h)}})}function pr(e){const t=e.output;if(!t||typeof t!="object"||Array.isArray(t))throw new Error("runtime_debug_authoring_output_invalid");return t}function Pt(e,t){return e&&!e.ok&&e.diagnostics.length>0?e.diagnostics.map(r=>`${r.code}: ${r.message}`).join("; "):t}function hr(e){const t=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`;return`runtime-debug-${e}-${t}`}function Uo(e){return new Promise(t=>setTimeout(t,e))}const $o=["/__fps_editor_authoring"],Ho=[["manifest","/manifest"],["commit","/commit"],["editor-scene","/editor-scene"],["editor-asset-library","/editor-asset-library"],["project-files","/project-files"],["project-media","/project-media"],["project-file","/project-file"],["save-editor-scene","/save-editor-scene"],["file","/file"],["exec","/exec"]];function Vo(e,t={}){const r=new URL(e??"","http://localhost").pathname,a=t.prefixes??$o,n=qo(r,a);if(!n)return null;const o=r.slice(n.length)||"/",i=Yo(o);return i?{route:o,routeName:i,prefix:n}:null}function qo(e,t){return t.find(r=>e.startsWith(r))??null}function Yo(e){return Ho.find(([,t])=>e.startsWith(t))?.[0]??null}function V(e,t){return{statusCode:e,body:t}}function $r(e){return{statusCode:e,body:null}}function Wo(e){return typeof e=="string"?e:`${JSON.stringify(e??{},null,2)}