@fps-games/editor-deployment 0.2.3-beta.17 → 0.2.3-beta.18

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,20 +1,20 @@
1
- import{EventEmitter as SP}from"node:events";var Uo="medium",cd={low:{opacity:.32,softness:.25,bias:.0015,normalBias:.02,maxDistance:24,resolution:512,cascadeCount:1,bakeSamples:8,blurKernel:2},medium:{opacity:.42,softness:.4,bias:.001,normalBias:.01,maxDistance:48,resolution:1024,cascadeCount:2,bakeSamples:24,blurKernel:4},high:{opacity:.5,softness:.58,bias:8e-4,normalBias:.006,maxDistance:80,resolution:2048,cascadeCount:4,bakeSamples:64,blurKernel:8},ultra:{opacity:.56,softness:.72,bias:6e-4,normalBias:.004,maxDistance:120,resolution:4096,cascadeCount:4,bakeSamples:128,blurKernel:12}};function Ei(e=Uo,t={}){let r=cd[e]??cd[Uo];return{opacity:Vo(t.opacity,r.opacity),softness:Vo(t.softness,r.softness),bias:Vo(t.bias,r.bias),normalBias:Vo(t.normalBias,r.normalBias),maxDistance:Vo(t.maxDistance,r.maxDistance),resolution:xP(t.resolution,r.resolution),cascadeCount:AP(t.cascadeCount,r.cascadeCount),bakeSamples:PP(t.bakeSamples,r.bakeSamples),blurKernel:TP(t.blurKernel,r.blurKernel)}}function Vo(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function PP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):t}function TP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e):t}function xP(e,t){return e===512||e===1024||e===2048||e===4096?e:t}function AP(e,t){return e===1||e===2||e===4?e:t}function Ii(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Pi(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Ti(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function xi(e){return e==="inherit"||e==="none"||e==="dynamic"||e==="static"||e==="blob"||e==="projected"||e==="auto"}function Ai(e){return e==="inherit"||e==="low"||e==="medium"||e==="high"||e==="ultra"}function Di(e){return e==="inherit"||e==="scene-main"||e==="nearest"||e==="explicit"}function hf(e){let t=Ii(e);if(!t)return;let r={};Pi(t.cast)&&(r.cast=t.cast),Ti(t.receive)&&(r.receive=t.receive),xi(t.mode)&&(r.mode=t.mode),Ai(t.quality)&&(r.quality=t.quality);let n=Ii(t.light);if(n){let a={};Di(n.mode)&&(a.mode=n.mode),typeof n.lightId=="string"&&n.lightId.trim()&&(a.lightId=n.lightId.trim()),Object.keys(a).length>0&&(r.light=a)}let o=DP(t.params);return o&&(r.params=o),Object.keys(r).length>0?r:void 0}function He(e){let t=hf(e);return t?{shadow:t,diagnostics:[]}:{diagnostics:[]}}function dd(e,t="none"){let r=e?.mode;return!r||r==="inherit"||r==="auto"?t:r}function ld(e,t=Uo){let r=e?.quality;return r&&r!=="inherit"?r:t}function DP(e){let t=Ii(e);if(!t)return;let r={};return typeof t.opacity=="number"&&Number.isFinite(t.opacity)&&(r.opacity=t.opacity),typeof t.softness=="number"&&Number.isFinite(t.softness)&&(r.softness=t.softness),typeof t.bias=="number"&&Number.isFinite(t.bias)&&(r.bias=t.bias),typeof t.normalBias=="number"&&Number.isFinite(t.normalBias)&&(r.normalBias=t.normalBias),typeof t.maxDistance=="number"&&Number.isFinite(t.maxDistance)&&(r.maxDistance=t.maxDistance),(t.resolution===512||t.resolution===1024||t.resolution===2048||t.resolution===4096)&&(r.resolution=t.resolution),(t.cascadeCount===1||t.cascadeCount===2||t.cascadeCount===4)&&(r.cascadeCount=t.cascadeCount),typeof t.bakeSamples=="number"&&Number.isFinite(t.bakeSamples)&&(r.bakeSamples=t.bakeSamples),typeof t.blurKernel=="number"&&Number.isFinite(t.blurKernel)&&(r.blurKernel=t.blurKernel),Object.keys(r).length>0?r:void 0}var MP=new Set(["cast","receive","mode","quality","light","params"]),wP=new Set(["mode","lightId"]),kP=new Set(["opacity","softness","bias","normalBias","maxDistance","resolution","cascadeCount","bakeSamples","blurKernel"]);function Ko(e,t="$.shadow"){let r=md(e);if(!r)throw ve("schema.invalidType",t);if(ud(r,MP,t),"cast"in r&&!Pi(r.cast))throw ve("schema.invalidValue",`${t}.cast`);if("receive"in r&&!Ti(r.receive))throw ve("schema.invalidValue",`${t}.receive`);if("mode"in r&&!xi(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("quality"in r&&!Ai(r.quality))throw ve("schema.invalidValue",`${t}.quality`);"light"in r&&OP(r.light,`${t}.light`),"params"in r&&RP(r.params,`${t}.params`)}function OP(e,t){let r=md(e);if(!r)throw ve("schema.invalidType",t);if(ud(r,wP,t),"mode"in r&&!Di(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("lightId"in r&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`);if(r.mode==="explicit"&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`)}function RP(e,t){let r=md(e);if(!r)throw ve("schema.invalidType",t);if(ud(r,kP,t),Jr(r,"opacity",t,n=>n>=0&&n<=1),Jr(r,"softness",t,n=>n>=0),Jr(r,"bias",t,()=>!0),Jr(r,"normalBias",t,()=>!0),Jr(r,"maxDistance",t,n=>n>0),Jr(r,"bakeSamples",t,n=>n>0),Jr(r,"blurKernel",t,n=>n>=0),"resolution"in r&&![512,1024,2048,4096].includes(r.resolution))throw ve("schema.invalidValue",`${t}.resolution`);if("cascadeCount"in r&&![1,2,4].includes(r.cascadeCount))throw ve("schema.invalidValue",`${t}.cascadeCount`)}function Jr(e,t,r,n){if(!(t in e))return;let o=e[t];if(typeof o!="number"||!Number.isFinite(o)||!n(o))throw ve("schema.invalidValue",`${r}.${t}`)}function ud(e,t,r){for(let n of Object.keys(e))if(!t.has(n))throw ve("schema.deprecatedField",`${r}.${n}`)}function ve(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function md(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var bd="fps.shadow-map-experiment";function CP(e,t="$.scene.shadowMapExperiment"){let r=ft(e,t);Gt(r,["qualityProfile","behaviorProfile"],t),r.qualityProfile!==void 0&&vt(r.qualityProfile,`${t}.qualityProfile`),r.behaviorProfile!==void 0&&vt(r.behaviorProfile,`${t}.behaviorProfile`)}function vP(e,t="$.shadowMapExperiment"){let r=ft(e,t);Gt(r,["behaviorProfile"],t),vt(r.behaviorProfile,`${t}.behaviorProfile`)}function wi(e,t="$"){let r=ft(e,t);Gt(r,["schemaVersion","enabled","lightRef","defaultQualityProfile","defaultBehaviorProfile","qualityProfiles","behaviorProfiles"],t),r.schemaVersion!==1&&H(`${t}.schemaVersion`,"expected 1"),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),vt(r.lightRef,`${t}.lightRef`);let n=vt(r.defaultQualityProfile,`${t}.defaultQualityProfile`),o=vt(r.defaultBehaviorProfile,`${t}.defaultBehaviorProfile`),a=If(r.qualityProfiles,`${t}.qualityProfiles`),i=If(r.behaviorProfiles,`${t}.behaviorProfiles`);for(let[s,c]of Object.entries(a))jP(c,`${t}.qualityProfiles.${s}`);for(let[s,c]of Object.entries(i))NP(c,`${t}.behaviorProfiles.${s}`);Object.prototype.hasOwnProperty.call(a,n)||H(`${t}.defaultQualityProfile`,`unknown quality profile: ${n}`),Object.prototype.hasOwnProperty.call(i,o)||H(`${t}.defaultBehaviorProfile`,`unknown behavior profile: ${o}`)}function Pf(e){wi(e.config),e.settings!==void 0&&CP(e.settings),(!Number.isInteger(e.revision)||e.revision<0)&&H("$.revision","expected a non-negative integer");let t=e.settings?.qualityProfile??e.config.defaultQualityProfile,r=e.settings?.behaviorProfile??e.config.defaultBehaviorProfile,n=pd(e.config.qualityProfiles,t,"$.settings.qualityProfile","quality");pd(e.config.behaviorProfiles,r,"$.settings.behaviorProfile","behavior");let o=e.objects.map((s,c)=>{let d=`$.objects[${c}]`;s.override!==void 0&&vP(s.override,`${d}.override`);let u=s.override?.behaviorProfile??r,l=pd(e.config.behaviorProfiles,u,`${d}.override.behaviorProfile`,"behavior");return Object.freeze({entityId:vt(s.entityId,`${d}.entityId`),renderableIds:Object.freeze(UP(s.renderableIds,`${d}.renderableIds`)),cast:Ef(s.cast,`${d}.cast`)??l.cast==="enabled",receive:Ef(s.receive,`${d}.receive`)??l.receive==="enabled",updateClass:l.updateClass!=="auto"?l.updateClass:s.inferredUpdateClass??"static",behaviorProfileId:u})}).sort((s,c)=>s.entityId.localeCompare(c.entityId)),a=e.config.enabled?o:[];BP(a);let i=Object.fromEntries(Object.entries(e.config.behaviorProfiles).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>[s,Object.freeze({cast:c.cast==="enabled",receive:c.receive==="enabled",updateClass:c.updateClass})]));return Tf({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:vt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:Wo(e.lightDirection,"$.lightDirection")},qualityProfileId:t,generator:{maps:{...n.maps},...n.cascadeCount===void 0?{}:{cascadeCount:n.cascadeCount},filter:n.receiverFilter,bias:n.bias,normalBias:n.normalBias,darkness:n.darkness,...n.softness===void 0?{}:{softness:n.softness},bounds:VP(n.bounds),backend:{...n.backend}},culling:{...n.culling},diagnosticThresholds:{...n.diagnostics},behaviorProfiles:i,objects:a,diagnostics:[]})}function Ef(e,t){if(e!==void 0)return typeof e!="boolean"&&H(t,"expected a boolean"),e}function GP(e,t){let r=ft(e,t);Gt(r,["mode","center","extent","near","far"],t),r.mode!=="fixed"&&H(`${t}.mode`,"expected fixed"),Wo(r.center,`${t}.center`),Wo(r.extent,`${t}.extent`).some(i=>i<=0)&&H(`${t}.extent`,"expected positive values");let o=Mi(r.near,`${t}.near`),a=Mi(r.far,`${t}.far`);(o<0||a<=o)&&H(t,"expected 0 <= near < far")}function jP(e,t){let r=ft(e,t);Gt(r,["maps","cascadeCount","receiverFilter","bias","normalBias","darkness","softness","bounds","backend","culling","diagnostics"],t),FP(r.maps,`${t}.maps`),r.cascadeCount!==void 0&&_P(r.cascadeCount,`${t}.cascadeCount`),r.receiverFilter!=="hard"&&r.receiverFilter!=="low-pcf"&&H(`${t}.receiverFilter`,"expected hard or low-pcf"),Ho(r.bias,`${t}.bias`,0,.1),Ho(r.normalBias,`${t}.normalBias`,0,1),Ho(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&Ho(r.softness,`${t}.softness`,0,1),GP(r.bounds,`${t}.bounds`),$P(r.backend,`${t}.backend`),LP(r.culling,`${t}.culling`),zP(r.diagnostics,`${t}.diagnostics`)}function NP(e,t){let r=ft(e,t);Gt(r,["cast","receive","updateClass"],t),r.cast!=="enabled"&&r.cast!=="disabled"&&H(`${t}.cast`,"expected enabled or disabled"),r.receive!=="enabled"&&r.receive!=="disabled"&&H(`${t}.receive`,"expected enabled or disabled"),["auto","static","dynamic","skinned"].includes(String(r.updateClass))||H(`${t}.updateClass`,"expected auto, static, dynamic, or skinned")}function FP(e,t){let r=ft(e,t);Gt(r,["staticResolution","dynamicResolution","compositeResolution"],t),fd(r.staticResolution,`${t}.staticResolution`),fd(r.dynamicResolution,`${t}.dynamicResolution`),fd(r.compositeResolution,`${t}.compositeResolution`)}function fd(e,t){e!==512&&e!==1024&&e!==2048&&e!==4096&&H(t,"expected 512, 1024, 2048, or 4096")}function _P(e,t){e!==1&&e!==2&&e!==4&&H(t,"expected 1, 2, or 4")}function $P(e,t){let r=ft(e,t);Gt(r,["mode","fallback"],t),["auto","split","single"].includes(String(r.mode))||H(`${t}.mode`,"expected auto, split, or single"),r.fallback!=="single-map"&&r.fallback!=="disable"&&H(`${t}.fallback`,"expected single-map or disable")}function LP(e,t){let r=ft(e,t);Gt(r,["enabled","guardBandRatio"],t),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),Ho(r.guardBandRatio,`${t}.guardBandRatio`,0,4)}function zP(e,t){let r=ft(e,t);Gt(r,["staticCasterCountWarning","dynamicCasterCountWarning","renderableCountWarning"],t),gd(r.staticCasterCountWarning,`${t}.staticCasterCountWarning`),gd(r.dynamicCasterCountWarning,`${t}.dynamicCasterCountWarning`),gd(r.renderableCountWarning,`${t}.renderableCountWarning`)}function BP(e){let t=new Set,r=new Set;for(let n of e){t.has(n.entityId)&&H("$.objects",`duplicate entity id: ${n.entityId}`),t.add(n.entityId);for(let o of n.renderableIds)r.has(o)&&H("$.objects",`duplicate renderable id: ${o}`),r.add(o)}}function If(e,t){let r=ft(e,t);Object.keys(r).length===0&&H(t,"expected at least one profile");for(let n of Object.keys(r))vt(n,`${t} key`);return r}function pd(e,t,r,n){return Object.prototype.hasOwnProperty.call(e,t)||H(r,`unknown ${n} profile: ${t}`),e[t]}function VP(e){return Object.freeze({mode:"fixed",center:Wo(e.center,"$.bounds.center"),extent:Wo(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function Wo(e,t){let r=KP(e,t);return r.length!==3&&H(t,"expected exactly three numbers"),Object.freeze(r.map((n,o)=>Mi(n,`${t}[${o}]`)))}function UP(e,t){let r=e.map((n,o)=>vt(n,`${t}[${o}]`));return new Set(r).size!==r.length&&H(t,"expected unique strings"),r}function Mi(e,t){return(typeof e!="number"||!Number.isFinite(e))&&H(t,"expected a finite number"),e}function Ho(e,t,r,n){let o=Mi(e,t);return(o<r||o>n)&&H(t,`expected ${r}..${n}`),o}function gd(e,t){return(!Number.isInteger(e)||e<0)&&H(t,"expected a non-negative integer"),e}function vt(e,t){return(typeof e!="string"||!e.trim()||e!==e.trim())&&H(t,"expected a trimmed non-empty string"),e}function ft(e,t){(!e||typeof e!="object"||Array.isArray(e))&&H(t,"expected an object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&H(t,"expected a plain object"),e}function KP(e,t){return Array.isArray(e)||H(t,"expected an array"),e}function Gt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||H(`${r}.${o}`,"unknown field")}function Tf(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))Tf(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var xf=["useBlobShadow","blobSettings"],HP=["resolution","maxSize"],WP=new Set(["none","blob","static","planar","dynamic"]);function gt(e){let t=Xr(e);if(!t)throw X("schema.invalidType","$");for(let o of xf)if(Object.prototype.hasOwnProperty.call(t,o))throw X("schema.deprecatedField",`$.${o}`);if(q(t,["globalVolume","materials","renderingGroups","shadowMeshes","shadows"],"$"),XP(t.globalVolume,"$.globalVolume"),YP(t.materials,"$.materials"),qP(t.renderingGroups,"$.renderingGroups"),JP(t.globalVolume,"$.globalVolume"),nT(t.shadowMeshes,"$.shadowMeshes"),!Object.prototype.hasOwnProperty.call(t,"shadows"))return;let r=Xr(t.shadows);if(!r)throw X("schema.invalidType","$.shadows");for(let o of xf)if(Object.prototype.hasOwnProperty.call(r,o))throw X("schema.deprecatedField",`$.shadows.${o}`);if(q(r,["defaultMode","enabled","useCsm","settings","blob","staticProjected","planar","shadowRange","shadowOrtho","csm"],"$.shadows"),"defaultMode"in r&&!WP.has(String(r.defaultMode)))throw X("schema.invalidValue","$.shadows.defaultMode");Ge(r,"enabled","$.shadows"),Ge(r,"useCsm","$.shadows");let n=Xr(r.settings);if(Object.prototype.hasOwnProperty.call(r,"settings")&&!n)throw X("schema.invalidType","$.shadows.settings");if(n){q(n,["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ","useBlurExponentialShadowMap","shadowColor"],"$.shadows.settings");for(let o of["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ"])Ae(n,o,"$.shadows.settings");Ge(n,"useBlurExponentialShadowMap","$.shadows.settings"),ki(n.shadowColor,"$.shadows.settings.shadowColor",!1)}QP(r.blob,"$.shadows.blob"),eT(r.staticProjected,"$.shadows.staticProjected"),tT(r.planar,"$.shadows.planar"),Yr(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),Yr(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),rT(r.csm,"$.shadows.csm")}function qP(e,t){if(e===void 0)return;let r=Xr(e);if(!r||!Array.isArray(r.slots))throw X("schema.invalidType",t);q(r,["slots"],t),r.slots.forEach((n,o)=>{let a=`${t}.slots[${o}]`,i=Xr(n);if(!i)throw X("schema.invalidType",a);if(q(i,["renderingGroupId","name","alphaIndexPresets"],a),![0,1,2,3].includes(i.renderingGroupId))throw X("schema.invalidValue",`${a}.renderingGroupId`);if(typeof i.name!="string"||!i.name.trim())throw X("schema.invalidValue",`${a}.name`);if(!Array.isArray(i.alphaIndexPresets))throw X("schema.invalidType",`${a}.alphaIndexPresets`);i.alphaIndexPresets.forEach((s,c)=>{let d=`${a}.alphaIndexPresets[${c}]`,u=Xr(s);if(!u)throw X("schema.invalidType",d);if(q(u,["name","alphaIndex"],d),typeof u.name!="string"||!u.name.trim())throw X("schema.invalidValue",`${d}.name`);yd(u,"alphaIndex",d)})})}function JP(e,t){if(e===void 0)return;let r=ge(e,t);for(let a of["samples","camera","lights"])if(a in r)throw X("schema.deprecatedField",`${t}.${a}`);if(q(r,["enabled","hdr","environment","imageProcessing","toneMapping","antialiasing","postProcessing","rendering","textures"],t),Ge(r,"enabled",t),Ge(r,"hdr",t),r.environment!==void 0){let a=ge(r.environment,`${t}.environment`);for(let i of["textureAssetId","textureUrl","intensity"])if(i in a)throw X("schema.deprecatedField",`${t}.environment.${i}`);if(q(a,["texture","iblIntensity","rotationY","useCocosIBL"],`${t}.environment`),a.texture!==void 0&&a.texture!==null){let i=ge(a.texture,`${t}.environment.texture`);for(let s of Object.keys(i))if(s!=="textureAssetId"&&s!=="url")throw X("schema.deprecatedField",`${t}.environment.texture.${s}`);for(let s of["textureAssetId","url"])if(s in i&&i[s]!=null&&(typeof i[s]!="string"||!i[s].trim()))throw X("schema.invalidValue",`${t}.environment.texture.${s}`)}Ae(a,"iblIntensity",`${t}.environment`),Ae(a,"rotationY",`${t}.environment`),Ge(a,"useCocosIBL",`${t}.environment`)}if(Yr(r.imageProcessing,`${t}.imageProcessing`,["exposure","contrast"]),r.toneMapping!==void 0){let a=ge(r.toneMapping,`${t}.toneMapping`);if(q(a,["enabled","type"],`${t}.toneMapping`),Ge(a,"enabled",`${t}.toneMapping`),"type"in a&&!["standard","aces","khr-pbr-neutral"].includes(String(a.type)))throw X("schema.invalidValue",`${t}.toneMapping.type`)}if(r.antialiasing!==void 0){let a=ge(r.antialiasing,`${t}.antialiasing`);if(q(a,["samples"],`${t}.antialiasing`),"samples"in a&&![1,2,4,8].includes(a.samples))throw X("schema.invalidValue",`${t}.antialiasing.samples`)}let n=pt(r.postProcessing,`${t}.postProcessing`);n&&q(n,["bloom"],`${t}.postProcessing`);let o=n?pt(n.bloom,`${t}.postProcessing.bloom`):null;if(o){q(o,["enabled","threshold","weight","kernel","scale"],`${t}.postProcessing.bloom`),Ge(o,"enabled",`${t}.postProcessing.bloom`);for(let a of["threshold","weight","kernel","scale"])Ae(o,a,`${t}.postProcessing.bloom`)}}function XP(e,t){if(e===void 0)return;let r=ge(e,t),n=pt(r.rendering,`${t}.rendering`);n&&(q(n,["maxDpr","hardwareScalingLevel"],`${t}.rendering`),Ae(n,"maxDpr",`${t}.rendering`),ZP(n,"hardwareScalingLevel",`${t}.rendering`));let o=pt(r.textures,`${t}.textures`);if(o&&(q(o,["anisotropicFilteringLevel","samplingMode"],`${t}.textures`),Ae(o,"anisotropicFilteringLevel",`${t}.textures`),"samplingMode"in o&&(typeof o.samplingMode!="string"||!o.samplingMode.trim())))throw X("schema.invalidValue",`${t}.textures.samplingMode`)}function YP(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["sceneMaterials","plantMaterials"],t);for(let n of["sceneMaterials","plantMaterials"])n in r&&ge(r[n],`${t}.${n}`)}function ZP(e,t,r){!(t in e)||e[t]==null||Ae(e,t,r)}function QP(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","size"],t),Ge(r,"enabled",t),Yr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);n&&(q(n,["color","edgeSoftness"],`${t}.appearance`),ki(n.color,`${t}.appearance.color`,!0),Ae(n,"edgeSoftness",`${t}.appearance`)),Yr(r.size,`${t}.size`,["sizeMultiplier","minSize","maxSize"])}function eT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","bake"],t),Ge(r,"enabled",t),Yr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);if(n&&(q(n,["color"],`${t}.appearance`),ki(n.color,`${t}.appearance.color`,!0)),r.bake===void 0)return;let o=ge(r.bake,`${t}.bake`);for(let a of HP)if(a in o)throw X("schema.deprecatedField",`${t}.bake.${a}`);q(o,["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"],`${t}.bake`);for(let a of["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"])Ae(o,a,`${t}.bake`)}function tT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","projection","stencil","casters","receivers"],t),Ge(r,"enabled",t);let n=pt(r.plane,`${t}.plane`);if(n){q(n,["normal","height","bias","heightMode"],`${t}.plane`),oT(n.normal,`${t}.plane.normal`);for(let c of["height","bias"])Ae(n,c,`${t}.plane`);if("heightMode"in n&&!["fixed","receiver"].includes(String(n.heightMode)))throw X("schema.invalidValue",`${t}.plane.heightMode`)}let o=pt(r.appearance,`${t}.appearance`);o&&(q(o,["color"],`${t}.appearance`),ki(o.color,`${t}.appearance.color`,!0)),Yr(r.projection,`${t}.projection`,["footprintScale"]);let a=pt(r.stencil,`${t}.stencil`);if(a){q(a,["enabled","receiverRenderingGroup","shadowRenderingGroup"],`${t}.stencil`),Ge(a,"enabled",`${t}.stencil`);for(let c of["receiverRenderingGroup","shadowRenderingGroup"])Ae(a,c,`${t}.stencil`)}let i=pt(r.casters,`${t}.casters`);if(i){q(i,["autoDetectAll","includePatterns","excludePatterns","rootBoundaryPatterns","minVolume"],`${t}.casters`),Ge(i,"autoDetectAll",`${t}.casters`);for(let c of["includePatterns","excludePatterns","rootBoundaryPatterns"])Sd(i[c],`${t}.casters.${c}`);Ae(i,"minVolume",`${t}.casters`)}let s=pt(r.receivers,`${t}.receivers`);s&&(q(s,["patterns"],`${t}.receivers`),Sd(s.patterns,`${t}.receivers.patterns`))}function rT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["numCascades","lambda","cascadeBlendPercentage","stabilizeCascades"],t);for(let n of["numCascades","lambda","cascadeBlendPercentage"])Ae(r,n,t);Ge(r,"stabilizeCascades",t)}function nT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["shadowReceivers","shadowCasters","excludeFromShadow"],t);for(let n of["shadowReceivers","shadowCasters","excludeFromShadow"])Sd(r[n],`${t}.${n}`)}function Yr(e,t,r){if(e===void 0)return;let n=ge(e,t);q(n,r,t);for(let o of r)Ae(n,o,t)}function ki(e,t,r){if(e===void 0)return;let n=ge(e,t),o=r?["r","g","b","a"]:["r","g","b"];q(n,o,t);for(let a of o)yd(n,a,t)}function oT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["x","y","z"],t);for(let n of["x","y","z"])yd(r,n,t)}function Sd(e,t){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw X("schema.invalidType",t)}function yd(e,t,r){if(!(t in e))throw X("schema.invalidValue",`${r}.${t}`);Ae(e,t,r)}function pt(e,t){return e===void 0?null:ge(e,t)}function ge(e,t){let r=Xr(e);if(!r)throw X("schema.invalidType",t);return r}function Ge(e,t,r){if(t in e&&typeof e[t]!="boolean")throw X("schema.invalidValue",`${r}.${t}`)}function Ae(e,t,r){if(!(t in e))return;let n=e[t];if(typeof n!="number"||!Number.isFinite(n))throw X("schema.invalidValue",`${r}.${t}`)}function q(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw X("schema.unknownField",`${r}.${o}`)}function X(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function Xr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Af(e,t){let r=L(e);return{x:be(r.x,t.x),y:be(r.y,t.y),z:be(r.z,t.z)}}function hd(e,t){let r=L(e);return{r:rr(r.r,t.r,0,1),g:rr(r.g,t.g,0,1),b:rr(r.b,t.b,0,1)}}function qo(e,t){let r=L(e);return{...hd(r,t),a:rr(r.a,t.a,0,1)}}function Pr(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter((t,r,n)=>t.length>0&&n.indexOf(t)===r):[]}function Ed(e){return(typeof e=="string"?e.trim():"")||null}function Id(e,t){return(typeof e=="string"?e.trim():"")||t}function je(e,t){return typeof e=="boolean"?e:t}function Df(e){return e===0||e===1||e===2||e===3?e:null}function Mf(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function wf(e,t){return e===1||e===2||e===4||e===8?e:t}function kf(e,t){return e==="fixed"||e==="receiver"?e:t}function Of(e,t){return e==="none"||e==="blob"||e==="static"||e==="planar"||e==="dynamic"?e:t}function be(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Q(e,t){let r=be(e,t);return Math.max(0,r)}function Tr(e,t){let r=be(e,t);return r>0?r:t}function rr(e,t,r,n){let o=be(e,t);return Math.min(n,Math.max(r,o))}var Rf=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Cf=[...Rf,"_blobShadow"],aT=[...Cf,"_staticProjectedShadow"];var vf=[{renderingGroupId:0,name:"\u666E\u901A\u573A\u666F",alphaIndexPresets:[{name:"\u9ED8\u8BA4\u900F\u660E\u987A\u5E8F",alphaIndex:0},{name:"\u5730\u8868\u8D34\u82B1",alphaIndex:100},{name:"\u8FD1\u666F\u8986\u76D6",alphaIndex:200}]},{renderingGroupId:1,name:"\u6C34\u9762 / \u900F\u660E\u5730\u8868",alphaIndexPresets:[{name:"\u6C34\u9762",alphaIndex:0},{name:"\u900F\u660E\u5730\u8868",alphaIndex:100},{name:"\u6C34\u9762\u9AD8\u5149",alphaIndex:200}]},{renderingGroupId:2,name:"\u7279\u6548",alphaIndexPresets:[{name:"\u666E\u901A\u7279\u6548",alphaIndex:0},{name:"\u524D\u666F\u7279\u6548",alphaIndex:100},{name:"\u6700\u524D\u7279\u6548",alphaIndex:200}]},{renderingGroupId:3,name:"\u4E16\u754C\u7A7A\u95F4 UI / \u5F15\u5BFC\u7BAD\u5934",alphaIndexPresets:[{name:"\u4E16\u754C\u7A7A\u95F4 UI",alphaIndex:0},{name:"\u5F15\u5BFC\u7BAD\u5934",alphaIndex:100},{name:"\u9876\u5C42\u63D0\u793A",alphaIndex:200}]}];function Ne(e){e!=null&&gt(e);let t=L(e),r=L(t.shadows),n=L(r.settings),o=L(r.blob),a=iT(o),i=cT(r.staticProjected),s=L(r.shadowRange),c=L(r.shadowOrtho),d=L(r.csm),u=L(t.shadowMeshes);return{renderingGroups:Gf(t.renderingGroups),environment:dT(t.globalVolume),postProcess:lT(t.globalVolume),shadows:{defaultMode:Of(r.defaultMode,"none"),enabled:je(r.enabled,!1),useCsm:je(r.useCsm,!1),settings:{mapSize:Q(n.mapSize,1024),darkness:Q(n.darkness,.3),blurKernel:Q(n.blurKernel,16),bias:Q(n.bias,5e-5),normalBias:Q(n.normalBias,.02),useBlurExponentialShadowMap:je(n.useBlurExponentialShadowMap,!0),shadowMinZ:Q(n.shadowMinZ,1),shadowMaxZ:Q(n.shadowMaxZ,60),shadowColor:hd(n.shadowColor,{r:0,g:0,b:0})},blob:a,staticProjected:i,shadowRange:{minZ:Q(s.minZ,1),maxZ:Q(s.maxZ,60)},shadowOrtho:{left:be(c.left,-20),right:be(c.right,20),top:be(c.top,20),bottom:be(c.bottom,-20)},csm:{numCascades:Q(d.numCascades,2),lambda:rr(d.lambda,.5,0,1),cascadeBlendPercentage:rr(d.cascadeBlendPercentage,.1,0,1),stabilizeCascades:je(d.stabilizeCascades,!0)},planar:sT(r.planar)},shadowMeshes:{shadowReceivers:Pr(u.shadowReceivers),shadowCasters:Pr(u.shadowCasters),excludeFromShadow:Pr(u.excludeFromShadow)}}}function Vn(e){let t=e?.environment?.texture!=null;return{environmentTextureAssetId:e?.environment?.texture?.textureAssetId??null,environmentTextureUrl:e?.environment?.texture?.url??null,environmentIblIntensity:t?e?.environment?.iblIntensity??null:null,postProcessEnabled:e?.postProcess?.enabled??null,postProcessExposure:e?.postProcess?.imageProcessing?.exposure??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??null,blobEnabled:e?.shadows?.blob?.enabled??null,blobOpacity:e?.shadows?.blob?.appearance?.color?.a??null,staticProjectedEnabled:e?.shadows?.staticProjected?.enabled??null,staticProjectedOpacity:e?.shadows?.staticProjected?.appearance?.color?.a??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}function iT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.size),a=qo(n.color,{r:0,g:0,b:0,a:.35});return{enabled:je(t.enabled,!0),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,a),edgeSoftness:rr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Tr(o.maxSize,20)}}}function Gf(e){let t=L(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:vf.map(n=>{let o=r.find(i=>Df(L(i).renderingGroupId)===n.renderingGroupId),a=L(o);return{renderingGroupId:n.renderingGroupId,name:Id(a.name,n.name),alphaIndexPresets:jf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function jf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=L(a),c=be(s.alphaIndex,Number.NaN);!Number.isFinite(c)||n.has(c)||(n.add(c),o.push({name:Id(s.name,`Order ${i+1}`),alphaIndex:c}))}),o}function sT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.projection),a=L(t.stencil),i=L(t.casters),s=L(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:Af(r.normal,{x:0,y:1,z:0}),height:be(r.height,0),heightMode:kf(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},projection:{footprintScale:rr(o.footprintScale,1,0,2)},stencil:{enabled:je(a.enabled,!0),receiverRenderingGroup:Q(a.receiverRenderingGroup,0),shadowRenderingGroup:Q(a.shadowRenderingGroup,1)},casters:{autoDetectAll:je(i.autoDetectAll,!0),includePatterns:Pr(i.includePatterns),excludePatterns:Pr(i.excludePatterns),rootBoundaryPatterns:Pr(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Pr(s.patterns)}}}function cT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.bake),a=Tr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Tr(o.texelsPerMeter,256),atlasSize:Tr(o.atlasSize,4096),maxAtlasPages:Tr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Tr(o.targetChunkCount,64)}}}function dT(e){let t=L(e),r=L(t.environment),n=L(r.texture),o=Ed(n.textureAssetId),a=Ed(n.url);return{texture:o||a?{...o?{textureAssetId:o}:{},...a?{url:a}:{}}:null,iblIntensity:Q(r.iblIntensity,1),rotationY:be(r.rotationY,0)}}function lT(e){let t=L(e),r=L(t.imageProcessing),n=L(t.toneMapping),o=L(t.antialiasing),a=L(t.postProcessing),i=L(a.bloom);return{enabled:je(t.enabled,!0),hdr:je(t.hdr,!0),imageProcessing:{exposure:be(r.exposure,1),contrast:be(r.contrast,1)},toneMapping:{enabled:je(n.enabled,!0),type:Mf(n.type,"aces")},antialiasing:{samples:wf(o.samples,4)},bloom:{enabled:je(i.enabled,!1),threshold:Q(i.threshold,.9),weight:Q(i.weight,.2),kernel:Q(i.kernel,64),scale:Tr(i.scale,.5)}}}var Oi=class extends Error{path;reason;code="runtime.lighting.invalid";constructor(t,r){super(`Invalid Runtime Lighting data at ${t}: ${r}`),this.path=t,this.reason=r,this.name="FpsRuntimeLightingDataError"}},Nf=1e-6,uT=1e-4,mT=new Set(["schemaVersion","type","intensity","direction","diffuseColor"]),fT=new Set(["schemaVersion","type","intensity","diffuseColor","groundColor"]),pT=new Set(["x","y","z"]),gT=new Set(["r","g","b"]);function Xo(e,t="$.direction"){let r=Ff(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Nf&&bt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Un(e,t="$.light"){let r=xd(e,t);r.schemaVersion!==1&&bt(`${t}.schemaVersion`,"expected 1");let n=bT(r.intensity,`${t}.intensity`);if(r.type==="directional"){Ri(r,mT,t);let o=Ff(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Nf&&bt(`${t}.direction`,"expected a non-zero direction vector"),Math.abs(a-1)>uT&&bt(`${t}.direction`,"expected a normalized direction vector"),Object.freeze({schemaVersion:1,type:"directional",intensity:n,direction:o,diffuseColor:Pd(r.diffuseColor,`${t}.diffuseColor`)})}if(r.type==="hemispheric")return Ri(r,fT,t),Object.freeze({schemaVersion:1,type:"hemispheric",intensity:n,diffuseColor:Pd(r.diffuseColor,`${t}.diffuseColor`),groundColor:Pd(r.groundColor,`${t}.groundColor`)});bt(`${t}.type`,"expected directional or hemispheric")}function Ff(e,t){let r=xd(e,t);return Ri(r,pT,t),Object.freeze({x:Jo(r.x,`${t}.x`),y:Jo(r.y,`${t}.y`),z:Jo(r.z,`${t}.z`)})}function Pd(e,t){let r=xd(e,t);return Ri(r,gT,t),Object.freeze({r:Td(r.r,`${t}.r`),g:Td(r.g,`${t}.g`),b:Td(r.b,`${t}.b`)})}function xd(e,t){(!e||typeof e!="object"||Array.isArray(e))&&bt(t,"expected a plain object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&bt(t,"expected a plain object"),e}function Ri(e,t,r){for(let n of Object.keys(e))t.has(n)||bt(`${r}.${n}`,"unknown field")}function Jo(e,t){return(typeof e!="number"||!Number.isFinite(e))&&bt(t,"expected a finite number"),e}function bT(e,t){let r=Jo(e,t);return r<0&&bt(t,"expected a non-negative number"),r}function Td(e,t){let r=Jo(e,t);return(r<0||r>1)&&bt(t,"expected a number between 0 and 1"),r}function bt(e,t){throw new Oi(e,t)}var ST=new Set([".glb",".gltf",".png",".jpg",".jpeg",".webp",".env",".hdr",".dds",".ktx",".ktx2",".mp3",".wav",".ogg",".flac",".aac",".m4a"]);function _f(e){let t=String(e??"").trim().toLowerCase();if(/^\.[a-z0-9]+$/.test(t))return t;let r=t.split(/[?#]/,1)[0]??"",n=r.slice(r.lastIndexOf("/")+1),o=n.lastIndexOf(".");return o<=0||o===n.length-1?null:n.slice(o)}function $f(e){return ST.has(e)}function Wn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function Lf(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=zf(e.baseColor?.color);n&&(r.color=n);let o=Zr(e.baseColor?.texture);o!==void 0&&(r.texture=o),nr(e.baseColor,r,"brightness"),nr(e.baseColor,r,"saturation"),nr(e.baseColor,r,"contrast"),nr(e.baseColor,r,"hue"),Object.keys(r).length>0&&(t.baseColor=r);let a={},i=Zr(e.normal?.texture);i!==void 0&&(a.texture=i),nr(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Hn(e.metallic)&&(t.metallic=e.metallic),Hn(e.roughness)&&(t.roughness=e.roughness);let s={},c=Zr(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=Zr(e.occlusion?.texture);u!==void 0&&(d.texture=u),nr(e.occlusion,d,"strength"),Object.keys(d).length>0&&(t.occlusion=d);let l={},m=zf(e.emission?.color);m&&(l.color=m),nr(e.emission,l,"intensity");let f=Zr(e.emission?.texture);f!==void 0&&(l.texture=f);let S=Zr(e.emission?.maskTexture);S!==void 0&&(l.maskTexture=S),Object.keys(l).length>0&&(t.emission=l);let g={};(e.alpha?.mode==="opaque"||e.alpha?.mode==="mask"||e.alpha?.mode==="blend")&&(g.mode=e.alpha.mode),nr(e.alpha,g,"opacity"),nr(e.alpha,g,"cutoff");let b=Zr(e.alpha?.texture);return b!==void 0&&(g.texture=b),Object.keys(g).length>0&&(t.alpha=g),Object.keys(t).length>0?t:void 0}function Ad(...e){let t={};for(let r of e){let n=Lf(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),Kn(t,n,"baseColor"),Kn(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),Kn(t,n,"metallicRoughness"),Kn(t,n,"occlusion"),Kn(t,n,"emission"),Kn(t,n,"alpha"))}return Lf(t)??{}}function Kn(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function zf(e){return e&&Hn(e.r)&&Hn(e.g)&&Hn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function Zr(e){if(e===null)return null;if(!e||typeof e!="object")return;let t=typeof e.url=="string"?e.url.trim():"",r=typeof e.textureAssetId=="string"?e.textureAssetId.trim():"";if(!(!t&&!r))return{...t?{url:t}:{},...r?{textureAssetId:r}:{}}}function nr(e,t,r){Hn(e?.[r])&&(t[r]=e[r])}function Hn(e){return typeof e=="number"&&Number.isFinite(e)}var Bf="staticShadows";function Ar(e){let t=ar(e);if(!t)return null;let r=fe(t.sourceHash),n=fe(t.lightHash),o=fe(t.profileHash);if(!r||!n||!o)return null;let a={sourceHash:r,lightHash:n,profileHash:o,...typeof t.generatedAt=="string"&&t.generatedAt.trim()?{generatedAt:t.generatedAt.trim()}:{},...(()=>{let u=AT(t.stats);return u?{stats:u}:{}})()};if(t.version!==2||t.format!=="sdf-atlas"||!Array.isArray(t.pages)||!Array.isArray(t.chunks))return null;let i=[],s=new Map;for(let u of t.pages){let l=yT(u);if(!l||s.has(l.id))return null;i.push(l),s.set(l.id,l)}let c=[],d=new Set;for(let u of t.chunks){let l=hT(u,s);if(!l||d.has(l.id))return null;c.push(l),d.add(l.id)}return{version:2,format:"sdf-atlas",pages:i,chunks:c,...a}}function qn(e,t="$.staticShadows"){let r=Ar(e);if(r)return r;let n=new Error(`schema.unsupportedVersion: ${t}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:t}),n}function yT(e){let t=ar(e);if(!t)return null;let r=fe(t.id),n=ji(t.width),o=ji(t.height),a=DT(t.sdfTextureDataUrl);return!r||n==null||o==null||!a?null:{id:r,width:n,height:o,sdfTextureDataUrl:a}}function hT(e,t){let r=ar(e);if(!r)return null;let n=fe(r.id),o=TT(r.bounds),a=xT(r.plane),i=fe(r.pageId),s=IT(r.atlasRect),c=PT(r.atlasUv),d=MT(r.sourceNodeIds),u=fe(r.sourceHash),l=fe(r.lightHash),m=fe(r.profileHash);if(!n||!o||!a||!i||!s||!c||!d||!u||!l||!m)return null;let f=t.get(i);return!f||s.x+s.width>f.width||s.y+s.height>f.height?null:{id:n,bounds:o,plane:a,pageId:i,atlasRect:s,atlasUv:c,sourceNodeIds:d,sourceHash:u,lightHash:l,profileHash:m,...(()=>{let S=ET(r.binding);return S?{binding:S}:{}})()}}function ET(e){let t=ar(e);if(!t)return null;let r=fe(t.id),n=fe(t.ownerCasterId),o=fe(t.receiverId),a=fe(t.generatedAt),i=fe(t.sourceHash);if(!r||!n||!o||!a||!i||t.visibleWhenOwnerVisible!==!0||t.staleWhenOwnerTransformChanges!==!0||t.staleWhenLightChanges!==!0)return null;let s=fe(t.lightId),c=fe(t.textureAssetId),d=fe(t.projectionNodeId);return{id:r,ownerCasterId:n,receiverId:o,...s?{lightId:s}:{},...c?{textureAssetId:c}:{},...d?{projectionNodeId:d}:{},visibleWhenOwnerVisible:!0,staleWhenOwnerTransformChanges:!0,staleWhenLightChanges:!0,generatedAt:a,sourceHash:i}}function IT(e){let t=ar(e);if(!t)return null;let r=xr(t.x),n=xr(t.y),o=ji(t.width),a=ji(t.height);return r==null||n==null||o==null||a==null?null:{x:r,y:n,width:o,height:a}}function PT(e){let t=ar(e);if(!t)return null;let r=Ci(t.u0),n=Ci(t.v0),o=Ci(t.u1),a=Ci(t.v1);return r==null||n==null||o==null||a==null||o<=r||a<=n?null:{u0:r,v0:n,u1:o,v1:a}}function TT(e){let t=ar(e);if(!t)return null;let r=jt(t.minX),n=jt(t.maxX),o=jt(t.minZ),a=jt(t.maxZ),i=jt(t.y);return r==null||n==null||o==null||a==null||i==null||n<=r||a<=o?null:{minX:r,maxX:n,minZ:o,maxZ:a,y:i}}function xT(e){let t=ar(e);if(!t)return null;let r=jt(t.height),n=jt(t.yOffset);return r==null||n==null||n<0?null:{height:r,yOffset:n}}function AT(e){let t=ar(e);if(!t)return null;let r=xr(t.sourceRootCount),n=xr(t.sourceMeshCount),o=xr(t.attemptedChunkCount),a=xr(t.chunkCount),i=xr(t.textureCount);return r==null||n==null||o==null||a==null||i==null?null:{sourceRootCount:r,sourceMeshCount:n,attemptedChunkCount:o,chunkCount:a,textureCount:i,...vi(t.skippedChunkCount,"skippedChunkCount"),...vi(t.pageCount,"pageCount"),...or(t.resolution,"resolution"),...or(t.chunkSize,"chunkSize"),...or(t.atlasSize,"atlasSize"),...Gi(t.atlasUsedPixels,"atlasUsedPixels"),...Gi(t.atlasAllocatedPixels,"atlasAllocatedPixels"),...wT(t.atlasOccupancy,"atlasOccupancy"),...or(t.texelsPerMeter,"texelsPerMeter"),...or(t.effectiveTexelsPerMeter,"effectiveTexelsPerMeter"),...or(t.maxAtlasPages,"maxAtlasPages"),...Gi(t.sdfRadiusPx,"sdfRadiusPx"),...or(t.spatialChunkSize,"spatialChunkSize"),...or(t.effectiveSpatialChunkSize,"effectiveSpatialChunkSize"),...or(t.targetChunkCount,"targetChunkCount"),...vi(t.bakedChunkCount,"bakedChunkCount"),...vi(t.reusedChunkCount,"reusedChunkCount"),...Gi(t.durationMs,"durationMs")}}function DT(e){let t=fe(e);return t&&/^data:image\/png[;,]/i.test(t)?t:null}function MT(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],r=new Set;for(let n of e){let o=fe(n);if(!o)return null;r.has(o)||t.push(o),r.add(o)}return t}function fe(e){return typeof e=="string"&&e.trim()?e.trim():null}function jt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ji(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:null}function Ci(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:null}function vi(e,t){let r=xr(e);return r==null?{}:{[t]:r}}function or(e,t){let r=jt(e);return r==null||r<=0?{}:{[t]:r}}function Gi(e,t){let r=jt(e);return r==null||r<0?{}:{[t]:r}}function wT(e,t){let r=jt(e);return r==null||r<0||r>1?{}:{[t]:r}}function ar(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var kT="@fps-games/editor.playable-sdk.scene-compiler",OT="2",RT=1e-4,et={nodeKinds:["group","instance","transform","primitive","image"],primitiveShapes:["cube","sphere","plane","capsule"],transformTypes:["plain","light","camera","groundDecal"],assetTypes:["glb","texture"],materialScopes:["sharedAsset","nodeMaterial"],materialModes:["shared","instance"],materialShaderIds:["fps.builtin.pbr","fps.builtin.standard"],materialAssetSystemPresets:["default-pbr","default-standard"],runtimeV3:{assetFields:["id","guid","type","url","external","warmupCount","singleton","materialMode","defaults","materialSlots"],materialSlotFields:["slotId","label","sourceSurfaces"],materialSlotSourceSurfaceFields:["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMeshName"]},hierarchy:{parentTargets:["root","sceneNode"]},runtimeOnlyTokens:["/@fs","assetUrl","sourceAssetUrl","sourceAssetPath"]},CT=new Set(et.nodeKinds),vT=new Set(et.primitiveShapes),GT=new Set(et.assetTypes),jT=new Set(et.materialModes),NT=new Set(et.materialScopes),FT=new Set(et.materialAssetSystemPresets),_T=new Set(et.transformTypes),Yo=new Set(et.hierarchy.parentTargets),$T=et.runtimeOnlyTokens,LT=new Set(et.runtimeV3.assetFields),zT=new Set(et.runtimeV3.materialSlotFields),BT=new Set(et.runtimeV3.materialSlotSourceSurfaceFields);function VT(e,t={}){let{allowOrphanSharedMaterials:r=!0,allowOrphanNodeMaterials:n=!0,strictAssetIds:o=[],strictNodeIds:a=[],maxErrors:i=50}=t,s=Number.isInteger(i)&&i>0?i:50,c=[],d=new Set(o),u=new Set(a),l=(p,D)=>{c.length<s&&c.push({path:p,message:D})};if(!M(e))return l("$","scene json must be an object"),c;let m=e.schemaVersion;m!==2&&m!==3&&l("$.schemaVersion","schemaVersion must be 2 or 3"),ox(e.meta?.generatedFrom,"$.meta.generatedFrom",l);let f=fx(e),S=e.scene;if(!M(S))return l("$.scene","scene must be an object"),c;if(O(S.rootId)||l("$.scene.rootId","rootId must be a non-empty string"),Array.isArray(S.assets)||l("$.scene.assets","assets must be an array"),Array.isArray(S.nodes)||l("$.scene.nodes","nodes must be an array"),Array.isArray(S.materialAssets)||l("$.scene.materialAssets","materialAssets must be an array"),Array.isArray(S.materials)||l("$.scene.materials","materials must be an array"),Array.isArray(S.textures)||l("$.scene.textures","textures must be an array"),c.length>0)return c;e.staticShadows!=null&&Vf(()=>qn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let g=new Set,b=new Map,y=new Map,I=new Set,E=new Set([S.rootId]),T=new Map,A=new Map,$=new Set;return S.assets.forEach((p,D)=>{let h=`$.scene.assets[${D}]`;if(!M(p)){l(h,"asset must be an object");return}if(O(p.id)?g.has(p.id)?l(`${h}.id`,`duplicate asset id: ${p.id}`):(g.add(p.id),b.set(p.id,p.type)):l(`${h}.id`,"asset.id must be a non-empty string"),GT.has(p.type)||l(`${h}.type`,"asset.type must be glb or texture"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"asset.guid must be a non-empty string when present"),p.url!=null&&!O(p.url)&&l(`${h}.url`,"url must be a non-empty string when present"),p.external!=null&&!M(p.external)&&l(`${h}.external`,"external must be an object when present"),p.warmupCount!=null&&(!Number.isInteger(p.warmupCount)||p.warmupCount<0)&&l(`${h}.warmupCount`,"warmupCount must be a non-negative integer when present"),p.singleton!=null&&typeof p.singleton!="boolean"&&l(`${h}.singleton`,"singleton must be a boolean when present"),p.materialMode!=null&&!jT.has(p.materialMode)&&l(`${h}.materialMode`,"materialMode must be shared or instance"),nx(p.defaults,`${h}.defaults`,l),m===3)for(let F of Object.keys(p))LT.has(F)||l(`${h}.${F}`,`runtime schema v3 asset field is not allowed: ${F}`);else p.displayName!=null&&!O(p.displayName)&&l(`${h}.displayName`,"displayName must be a non-empty string when present"),p.category!=null&&!O(p.category)&&l(`${h}.category`,"category must be a non-empty string when present"),p.metadata!=null&&!M(p.metadata)&&l(`${h}.metadata`,"metadata must be an object when present");let R=m===3?p.materialSlots:M(p.metadata)?p.metadata.materialSlots:void 0,K=m===3?`${h}.materialSlots`:`${h}.metadata.materialSlots`,ne=new Set;R!=null&&(Array.isArray(R)?R.forEach((F,Ir)=>{let er=`${K}[${Ir}]`;if(!M(F)||!O(F.slotId)){l(er,m===3?"material slot must contain a stable slotId":"material slot must contain stable slotId and ownerNodePath");return}if(m!==3&&!O(F.ownerNodePath)){l(er,"material slot must contain stable slotId and ownerNodePath");return}ne.has(F.slotId)?l(`${er}.slotId`,`duplicate material slot id: ${F.slotId}`):ne.add(F.slotId),m===3&&rx(F,er,l)}):l(K,"materialSlots must be an array when present")),O(p.id)&&y.set(p.id,ne),d.has(p.id)&&Hf(p,h,l)}),S.nodes.forEach((p,D)=>{let h=`$.scene.nodes[${D}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&T.set(p.id,p),O(p.id)?E.has(p.id)?l(`${h}.id`,`duplicate node id: ${p.id}`):(E.add(p.id),typeof p.kind=="string"&&A.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&$.add(p.id)):l(`${h}.id`,"node.id must be a non-empty string"),CT.has(p.kind)||l(`${h}.kind`,"node.kind must be group, instance, transform, primitive, or image")}),S.materialAssets.forEach((p,D)=>{let h=`$.scene.materialAssets[${D}]`;if(!M(p)){l(h,"material asset must be an object");return}O(p.id)?I.has(p.id)?l(`${h}.id`,`duplicate material asset id: ${p.id}`):I.add(p.id):l(`${h}.id`,"material asset id must be a non-empty string"),p.name!=null&&!O(p.name)&&l(`${h}.name`,"material asset name must be a non-empty string when present"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"material asset guid must be a non-empty string when present"),Object.prototype.hasOwnProperty.call(p,"materialKind")&&l(`${h}.materialKind`,"materialKind is not supported; use shaderId"),Object.prototype.hasOwnProperty.call(p,"profile")&&l(`${h}.profile`,"profile is not supported; use properties");let R=Wn(p.shaderId),K=qT(p.shaderId);!R&&!K&&l(`${h}.shaderId`,"shaderId must be a built-in id or a namespaced lowercase project id"),p.definitionVersion!=null&&!JT(p.definitionVersion)?l(`${h}.definitionVersion`,"definitionVersion must be a positive integer when present"):K&&p.definitionVersion==null&&l(`${h}.definitionVersion`,"definitionVersion is required for project shader material assets"),R?qf(p.properties,`${h}.properties`,l):XT(p.properties,`${h}.properties`,l);for(let ne of Object.keys(p))["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(ne)||l(`${h}.${ne}`,`material asset field is not allowed: ${ne}`);YT(p.system,`${h}.system`,l),ZT(p.origin,`${h}.origin`,l),QT(p,h,l)}),S.nodes.forEach((p,D)=>{if(!M(p))return;let h=`$.scene.nodes[${D}]`,R=Object.prototype.hasOwnProperty.call(p,"parentId");R&&!O(p.parentId)&&l(`${h}.parentId`,"parentId must be a non-empty string when present");let K=R?p.parentId:S.rootId;O(K)&&ex(K,S.rootId,E,`${h}.parentId`,l),O(p.id)&&tx(p.id,S.rootId,T,`${h}.parentId`,l),ax(p.source,`${h}.source`,l),Xf(p.transform,`${h}.transform`,l),xx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&Vf(()=>Ko(p.shadow,`${h}.shadow`),`${h}.shadow`,l),Object.prototype.hasOwnProperty.call(p,"shadowMode")&&l(`${h}.shadowMode`,"deprecated field; use shadow.mode");let ne=null;p.kind==="instance"&&(M(p.instance)?g.has(p.instance.assetId)?b.get(p.instance.assetId)!=="glb"?l(`${h}.instance.assetId`,"instance.assetId must reference a glb asset"):ne=O(p.instance.assetId)?p.instance.assetId:null:l(`${h}.instance.assetId`,`assetId must reference scene.assets: ${p.instance.assetId}`):l(`${h}.instance`,"instance node must contain instance object")),p.kind==="primitive"&&(M(p.primitive)?vT.has(p.primitive.shape)||l(`${h}.primitive.shape`,"primitive.shape must be cube, sphere, plane, or capsule"):l(`${h}.primitive`,"primitive node must contain primitive object")),p.kind==="image"&&(M(p.image)?(g.has(p.image.assetId)?b.get(p.image.assetId)!=="texture"&&l(`${h}.image.assetId`,"image.assetId must reference a texture asset"):l(`${h}.image.assetId`,`assetId must reference scene.assets: ${p.image.assetId}`),M(p.image.size)?(Kf(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),Kf(p.image.size.height)||l(`${h}.image.size.height`,"image.size.height must be positive")):l(`${h}.image.size`,"image.size must be an object")):l(`${h}.image`,"image node must contain image object")),p.kind==="transform"&&p.transformType!=null&&!_T.has(p.transformType)&&l(`${h}.transformType`,"transformType must be plain, light, camera, or groundDecal"),p.kind==="transform"&&p.transformType==="groundDecal"?bx(p.groundDecal,`${h}.groundDecal`,l):Object.prototype.hasOwnProperty.call(p,"groundDecal")&&l(`${h}.groundDecal`,"groundDecal is only allowed on transform nodes with transformType groundDecal"),p.kind==="transform"&&(mx(p.camera,`${h}.camera`,l),px(p.light,`${h}.light`,l,f)),Object.prototype.hasOwnProperty.call(p,"marker")&&(p.kind!=="transform"?l(`${h}.marker`,"marker is only allowed on transform nodes"):(ix(p.marker,`${h}.marker`,l),sx(p.marker,p.id,E,$,`${h}.marker`,l))),(p.kind==="instance"||p.kind==="transform"||p.kind==="primitive"||p.kind==="image")&&KT(p.overrides,`${h}.overrides`,I,ne?y.get(ne):void 0,m===3?"materialSlots":"metadata.materialSlots",l),u.has(p.id)&&Hf(p,h,l)}),S.materials.forEach((p,D)=>{let h=`$.scene.materials[${D}]`;if(!M(p)){l(h,"material must be an object");return}if(O(p.id)||l(`${h}.id`,"material.id must be a non-empty string"),p.scope!=null&&!NT.has(p.scope)&&l(`${h}.scope`,"material scope must be sharedAsset or nodeMaterial"),p.scope==="sharedAsset"&&(!O(p.assetId)||!g.has(p.assetId))&&!r&&l(`${h}.assetId`,`shared material assetId must reference scene.assets: ${p.assetId}`),p.scope==="nodeMaterial"){if((!O(p.nodeId)||!E.has(p.nodeId))&&!n)l(`${h}.nodeId`,`node material nodeId must reference scene.nodes: ${p.nodeId}`);else if(O(p.nodeId)&&E.has(p.nodeId)){let R=A.get(p.nodeId);R!=="instance"&&R!=="transform"&&R!=="primitive"&&l(`${h}.nodeId`,`node material nodeId must reference an instance, transform, or primitive node: ${p.nodeId}`)}}O(p.materialName)||l(`${h}.materialName`,"materialName must be a non-empty string"),M(p.properties)?Zf(p.properties,`${h}.properties`,l):l(`${h}.properties`,"properties must be an object")}),c}function UT(e,t={}){let r=VT(e,t);return{ok:r.length===0,errors:r}}function Vf(e,t,r){try{e()}catch(n){let o=typeof n?.path=="string"?n.path:t,a=typeof n?.code=="string"?n.code:"schema.invalidValue";r(o,a)}}function KT(e,t,r,n,o,a){if(e!=null){if(!M(e)){a(t,"overrides must be an object when present");return}Wf(e.materialBinding,`${t}.materialBinding`,r,a),HT(e.materialSlotBindings,`${t}.materialSlotBindings`,"slotId",r,n,o,a),Object.prototype.hasOwnProperty.call(e,"childMaterialBindings")&&a(`${t}.childMaterialBindings`,"deprecated field; use materialSlotBindings keyed by slotId"),Object.prototype.hasOwnProperty.call(e,"childMaterials")&&a(`${t}.childMaterials`,"deprecated field; use materialSlotBindings keyed by slotId")}}function HT(e,t,r,n,o,a,i){if(e!=null){if(!M(e)){i(t,"material binding map must be an object when present");return}for(let[s,c]of Object.entries(e)){let d=`${t}.${s}`;O(s)||i(d,`${r} must be a non-empty string`),o?o.has(s)||i(d,`${r} must reference asset ${a}`):i(d,`${r} requires an instance asset with ${a}`),c==null?i(d,"material binding must be an object"):Wf(c,d,n,i)}}}function Wf(e,t,r,n){if(e!=null){if(!M(e)){n(t,"material binding must be an object when present");return}e.materialAssetId!=null&&(O(e.materialAssetId)?r.has(e.materialAssetId)||n(`${t}.materialAssetId`,`materialAssetId must reference scene.materialAssets: ${e.materialAssetId}`):n(`${t}.materialAssetId`,"materialAssetId must be non-empty when present")),e.override!=null&&qf(e.override,`${t}.override`,n)}}function qf(e,t,r){if(!M(e)){r(t,"material asset profile must be an object");return}if(e.lightingModel!=null&&e.lightingModel!=="lit"&&e.lightingModel!=="unlit"&&r(`${t}.lightingModel`,"lightingModel must be lit or unlit"),e.baseColor!=null)if(!M(e.baseColor))r(`${t}.baseColor`,"baseColor must be an object");else{Ni(e.baseColor.color,`${t}.baseColor.color`,r),Qr(e.baseColor.texture,`${t}.baseColor.texture`,r);for(let n of["brightness","saturation","contrast","hue"])e.baseColor[n]!=null&&!We(e.baseColor[n])&&r(`${t}.baseColor.${n}`,`${n} must be a finite number`)}for(let n of["metallic","roughness"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,`${n} must be a finite number`);e.normal!=null&&(M(e.normal)?(Qr(e.normal.texture,`${t}.normal.texture`,r),e.normal.strength!=null&&!We(e.normal.strength)&&r(`${t}.normal.strength`,"normal strength must be a finite number")):r(`${t}.normal`,"normal must be an object")),e.metallicRoughness!=null&&(M(e.metallicRoughness)?Qr(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(Qr(e.occlusion.texture,`${t}.occlusion.texture`,r),e.occlusion.strength!=null&&!We(e.occlusion.strength)&&r(`${t}.occlusion.strength`,"occlusion strength must be a finite number")):r(`${t}.occlusion`,"occlusion must be an object")),e.emission!=null&&(M(e.emission)?(Ni(e.emission.color,`${t}.emission.color`,r),e.emission.intensity!=null&&!We(e.emission.intensity)&&r(`${t}.emission.intensity`,"emission intensity must be a finite number"),Qr(e.emission.texture,`${t}.emission.texture`,r),Qr(e.emission.maskTexture,`${t}.emission.maskTexture`,r)):r(`${t}.emission`,"emission must be an object")),e.alpha!=null&&(M(e.alpha)?(e.alpha.mode!=null&&e.alpha.mode!=="opaque"&&e.alpha.mode!=="mask"&&e.alpha.mode!=="blend"&&r(`${t}.alpha.mode`,"alpha mode must be opaque, mask, or blend"),e.alpha.opacity!=null&&!We(e.alpha.opacity)&&r(`${t}.alpha.opacity`,"alpha opacity must be a finite number"),e.alpha.cutoff!=null&&!We(e.alpha.cutoff)&&r(`${t}.alpha.cutoff`,"alpha cutoff must be a finite number"),Qr(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var WT=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function Qo(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&WT.test(e)}function qT(e){return Qo(e)?e:null}function JT(e){return Number.isSafeInteger(e)&&e>0}function XT(e,t,r){if(!M(e)){r(t,"project shader material properties must be an object");return}Dd(e,t,r)}function Dd(e,t,r){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||r(t,"project shader material numbers must be finite");return}if(Array.isArray(e)){e.forEach((n,o)=>Dd(n,`${t}[${o}]`,r));return}if(M(e)){for(let[n,o]of Object.entries(e))Dd(o,`${t}.${n}`,r);return}r(t,"project shader material properties must be JSON-safe")}}function Qr(e,t,r){if(e!=null){if(!M(e)){r(t,"texture ref must be an object");return}e.url!=null&&!O(e.url)&&r(`${t}.url`,"texture url must be non-empty when present"),e.textureAssetId!=null&&!O(e.textureAssetId)&&r(`${t}.textureAssetId`,"textureAssetId must be non-empty when present")}}function YT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset system must be an object");return}e.readonly!=null&&typeof e.readonly!="boolean"&&r(`${t}.readonly`,"readonly must be boolean"),e.preset!=null&&!FT.has(e.preset)&&r(`${t}.preset`,"preset must be default-pbr or default-standard")}}function ZT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset origin must be an object");return}e.type!=="imported"&&e.type!=="created"&&e.type!=="duplicated"&&e.type!=="preset"&&r(`${t}.type`,"origin type must be imported, created, duplicated, or preset"),e.sourceAssetGuid!=null&&!O(e.sourceAssetGuid)&&r(`${t}.sourceAssetGuid`,"sourceAssetGuid must be non-empty when present"),e.sourceAssetId!=null&&!O(e.sourceAssetId)&&r(`${t}.sourceAssetId`,"sourceAssetId must be non-empty when present"),e.sourceSlotId!=null&&!O(e.sourceSlotId)&&r(`${t}.sourceSlotId`,"sourceSlotId must be non-empty when present"),e.sourceMaterialIndex!=null&&!Number.isInteger(e.sourceMaterialIndex)&&r(`${t}.sourceMaterialIndex`,"sourceMaterialIndex must be an integer when present"),e.sourceMaterialName!=null&&!O(e.sourceMaterialName)&&r(`${t}.sourceMaterialName`,"sourceMaterialName must be non-empty when present"),e.sourceMaterialAssetId!=null&&!O(e.sourceMaterialAssetId)&&r(`${t}.sourceMaterialAssetId`,"sourceMaterialAssetId must be non-empty when present")}}function QT(e,t,r){let n=M(e.system)?e.system.preset:void 0;n==="default-pbr"&&e.shaderId!=="fps.builtin.pbr"&&r(`${t}.shaderId`,"default-pbr material assets must use shaderId fps.builtin.pbr"),n==="default-standard"&&e.shaderId!=="fps.builtin.standard"&&r(`${t}.shaderId`,"default-standard material assets must use shaderId fps.builtin.standard")}function ex(e,t,r,n,o){if(e===t){Yo.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(Yo.has("sceneNode")&&r.has(e))return;let a=Yo.has("root")&&Yo.has("sceneNode")?"root or scene node":Yo.has("sceneNode")?"scene node":"root";o(n,`parentId must point to ${a}: ${e}`)}function tx(e,t,r,n,o){if(!O(t))return;let a=new Set([e]),i=O(r.get(e)?.parentId)?r.get(e)?.parentId:t;for(;O(i)&&i!==t;){if(a.has(i)){o(n,`parentId creates a node cycle involving ${e}`);return}a.add(i);let s=r.get(i);if(!s)return;i=O(s.parentId)?s.parentId:t}}function rx(e,t,r){for(let n of Object.keys(e))zT.has(n)||r(`${t}.${n}`,`runtime schema v3 material slot field is not allowed: ${n}`);if(e.label!=null&&!O(e.label)&&r(`${t}.label`,"label must be a non-empty string when present"),!Array.isArray(e.sourceSurfaces)||e.sourceSurfaces.length===0){r(`${t}.sourceSurfaces`,"sourceSurfaces must be a non-empty array");return}for(let n=0;n<e.sourceSurfaces.length;n+=1){let o=`${t}.sourceSurfaces[${n}]`,a=e.sourceSurfaces[n];if(!M(a)){r(o,"source surface must be an object");continue}for(let i of Object.keys(a))BT.has(i)||r(`${o}.${i}`,`runtime schema v3 material slot source surface field is not allowed: ${i}`);O(a.ownerNodePath)||r(`${o}.ownerNodePath`,"ownerNodePath must be a non-empty string");for(let i of["meshIndex","primitiveIndex"])(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer`);for(let i of["nodeIndex","sourceMaterialIndex"])a[i]!=null&&(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer when present`);a.nodeIndexPath!=null&&(!Array.isArray(a.nodeIndexPath)||a.nodeIndexPath.some(i=>!Number.isInteger(i)||i<0))&&r(`${o}.nodeIndexPath`,"nodeIndexPath must contain non-negative integers"),O(a.sourceMeshName)||r(`${o}.sourceMeshName`,"sourceMeshName is required")}}function nx(e,t,r){if(e!=null){if(!M(e)){r(t,"defaults must be an object");return}if(Xf(e.transform,`${t}.transform`,r),Uf(e.outline,`${t}.outline`,r),e.childOutlines!=null)if(!M(e.childOutlines))r(`${t}.childOutlines`,"childOutlines must be an object");else for(let[n,o]of Object.entries(e.childOutlines))Uf(o,`${t}.childOutlines.${n}`,r)}}function ox(e,t,r){if(e!=null){if(!M(e)){r(t,"generatedFrom must be an object when present");return}Jf(e,t,r),O(e.compilerId)||r(`${t}.compilerId`,"compilerId must be a non-empty string"),O(e.compilerVersion)||r(`${t}.compilerVersion`,"compilerVersion must be a non-empty string"),O(e.compiledAt)||r(`${t}.compiledAt`,"compiledAt must be a non-empty string")}}function ax(e,t,r){if(e!=null){if(!M(e)){r(t,"source must be an object when present");return}Jf(e,t,r),e.objectGuid!=null&&!O(e.objectGuid)&&r(`${t}.objectGuid`,"objectGuid must be a non-empty string when present"),e.objectId!=null&&!O(e.objectId)&&r(`${t}.objectId`,"objectId must be a non-empty string when present"),e.component!=null&&!O(e.component)&&r(`${t}.component`,"component must be a non-empty string when present"),e.propertyPath!=null&&!O(e.propertyPath)&&r(`${t}.propertyPath`,"propertyPath must be a non-empty string when present")}}function Jf(e,t,r){O(e.sourceId)||r(`${t}.sourceId`,"sourceId must be a non-empty string"),O(e.sourceType)||r(`${t}.sourceType`,"sourceType must be a non-empty string"),e.revision!=null&&(typeof e.revision!="number"||!Number.isFinite(e.revision))&&r(`${t}.revision`,"revision must be a finite number when present")}function Fi(e,t){let r=UT(e,t);if(r.ok)return;let n=new Error(`scene_json_schema_failed:
2
- ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_schema_failed",diagnostics:r.errors}),n}function M(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function Xf(e,t,r){if(e!=null){if(!M(e)){r(t,"transform must be an object");return}Nt(e.position,`${t}.position`,r),Nt(e.rotation,`${t}.rotation`,r),Nt(e.rotationDeg,`${t}.rotationDeg`,r),typeof e.scale=="number"?Number.isFinite(e.scale)||r(`${t}.scale`,"scale number must be finite"):Nt(e.scale,`${t}.scale`,r)}}function ix(e,t,r){if(!M(e)){r(t,"marker must be an object");return}Dr(e,["schemaVersion","label","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t,r),e.schemaVersion!==1&&r(`${t}.schemaVersion`,"marker.schemaVersion must be 1"),O(e.label)||r(`${t}.label`,"marker.label must be a non-empty string"),O(e.type)||r(`${t}.type`,"marker.type must be a non-empty string"),e.kind!=null&&!O(e.kind)&&r(`${t}.kind`,"marker.kind must be a non-empty string when present"),e.tags!=null&&(Array.isArray(e.tags)?e.tags.forEach((n,o)=>{typeof n!="string"&&r(`${t}.tags[${o}]`,"marker tag must be a string")}):r(`${t}.tags`,"marker.tags must be an array when present")),e.note!=null&&typeof e.note!="string"&&r(`${t}.note`,"marker.note must be a string when present"),e.color!=null&&lx(e.color,`${t}.color`,r),e.target!=null&&Md(e.target,`${t}.target`,r),e.semanticFrame!=null&&cx(e.semanticFrame,`${t}.semanticFrame`,r),dx(e.geometry,`${t}.geometry`,r),e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker.metadata must be an object when present")}function sx(e,t,r,n,o,a){if(!M(e))return;let i=[];e.target!=null&&i.push({value:e.target,path:`${o}.target`}),M(e.geometry)&&e.geometry.target!=null&&i.push({value:e.geometry.target,path:`${o}.geometry.target`});for(let s of i)M(s.value)&&(s.value.kind!=="scene-object"&&s.value.kind!=="marker"&&a(`${s.path}.kind`,"runtime marker target kind must be scene-object or marker"),O(s.value.id)&&(s.value.id===t?a(`${s.path}.id`,"runtime marker target must not reference its marker node"):r.has(s.value.id)?s.value.kind==="marker"&&!n.has(s.value.id)?a(`${s.path}.id`,`runtime marker target must reference a marker node: ${s.value.id}`):s.value.kind==="scene-object"&&n.has(s.value.id)&&a(`${s.path}.id`,`runtime scene-object target must not reference a marker node: ${s.value.id}`):a(`${s.path}.id`,`runtime marker target must reference scene.nodes: ${s.value.id}`)))}function Md(e,t,r){if(!M(e)){r(t,"marker target must be an object");return}Dr(e,["kind","id","label","path","metadata"],t,r),O(e.kind)||r(`${t}.kind`,"marker target kind must be a non-empty string"),O(e.id)||r(`${t}.id`,"marker target id must be a non-empty string");for(let n of["label","path"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker target ${n} must be a string when present`);e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker target metadata must be an object when present")}function cx(e,t,r){if(!M(e)){r(t,"marker semanticFrame must be an object");return}Dr(e,["origin","forward","right","up","label","description"],t,r),M(e.origin)?Nt(e.origin,`${t}.origin`,r):r(`${t}.origin`,"marker semanticFrame.origin must be a vector object");for(let n of["forward","right","up"])e[n]!=null&&Nt(e[n],`${t}.${n}`,r);for(let n of["label","description"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker semanticFrame ${n} must be a string when present`)}function dx(e,t,r){if(!M(e)){r(t,"marker.geometry must be an object");return}if(e.kind==="box"){Dr(e,["kind"],t,r);return}if(e.kind==="point"){Dr(e,["kind","coordinateSpace","position","offset","target"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&e.coordinateSpace!=="local"&&r(`${t}.coordinateSpace`,"point marker coordinateSpace must be world or local"),e.position!=null&&Nt(e.position,`${t}.position`,r),e.offset!=null&&Nt(e.offset,`${t}.offset`,r),e.target!=null&&Md(e.target,`${t}.target`,r);return}if(e.kind==="object-bounds"){Dr(e,["kind","target"],t,r),Md(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){Dr(e,["kind","coordinateSpace","vertices","faces"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&r(`${t}.coordinateSpace`,"polyhedron marker coordinateSpace must be world"),Array.isArray(e.vertices)?e.vertices.forEach((n,o)=>{let a=`${t}.vertices[${o}]`;M(n)?Nt(n,a,r):r(a,"polyhedron marker vertex must be a vector object")}):r(`${t}.vertices`,"polyhedron marker vertices must be an array"),e.faces!=null&&(Array.isArray(e.faces)?e.faces.forEach((n,o)=>{Array.isArray(n)?n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&r(`${t}.faces[${o}][${i}]`,"polyhedron marker index must be a non-negative integer")}):r(`${t}.faces[${o}]`,"polyhedron marker face must be an array")}):r(`${t}.faces`,"polyhedron marker faces must be an array when present"));return}r(`${t}.kind`,"marker.geometry.kind must be box, point, object-bounds, or polyhedron")}function lx(e,t,r){if(!M(e)){r(t,"marker color must be an object");return}Dr(e,["r","g","b"],t,r);for(let n of["r","g","b"])Yf(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function Dr(e,t,r,n){let o=new Set(t);for(let a of Object.keys(e))o.has(a)||n(`${r}.${a}`,`field is not allowed: ${a}`)}function Nt(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y","z"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function ux(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function We(e){return typeof e=="number"&&Number.isFinite(e)}function en(e){return We(e)&&e>0}function Yf(e){return We(e)&&e>=0&&e<=1}function Ni(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"color component must be a finite number")}}function mx(e,t,r){if(e!=null){if(!M(e)){r(t,"camera must be an object");return}e.projection!=null&&e.projection!=="orthographic"&&e.projection!=="perspective"&&r(`${t}.projection`,"camera projection must be orthographic or perspective");for(let n of["alpha","beta"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number when present");for(let n of["radius","orthoSize"])e[n]!=null&&!en(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!en(e.fov)&&r(`${t}.fov`,"camera fov must be a positive finite number"),Nt(e.targetOffset,`${t}.targetOffset`,r),ux(e.targetScreenOffset,`${t}.targetScreenOffset`,r);for(let n of["minZ","maxZ","lowerRadiusLimit","upperRadiusLimit"])e[n]!=null&&!en(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number");for(let n of["lowerBetaLimit","upperBetaLimit"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number");e.inertia!=null&&!Yf(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),en(e.minZ)&&en(e.maxZ)&&e.maxZ<=e.minZ&&r(`${t}.maxZ`,"camera maxZ must be greater than minZ"),We(e.lowerBetaLimit)&&We(e.upperBetaLimit)&&e.upperBetaLimit<e.lowerBetaLimit&&r(`${t}.upperBetaLimit`,"camera upperBetaLimit must be greater than or equal to lowerBetaLimit"),en(e.lowerRadiusLimit)&&en(e.upperRadiusLimit)&&e.upperRadiusLimit<e.lowerRadiusLimit&&r(`${t}.upperRadiusLimit`,"camera upperRadiusLimit must be greater than or equal to lowerRadiusLimit")}}function fx(e){let t=e.meta?.generatedFrom;return M(t)&&t.compilerId===kT&&t.compilerVersion===OT}function px(e,t,r,n=!1){if(e==null)return;let o=n&&M(e)&&!Object.prototype.hasOwnProperty.call(e,"schemaVersion")?gx(e,t):e;try{Un(o,t)}catch(a){let i=a;r(typeof i.path=="string"?i.path:t,typeof i.reason=="string"?i.reason:typeof i.message=="string"?i.message:"light does not satisfy the Engine Runtime Light contract")}}function gx(e,t){let r={...e,schemaVersion:1};if(e.type!=="directional"||!M(e.direction))return r;let{x:n,y:o,z:a}=e.direction;if(![n,o,a].every(s=>typeof s=="number"&&Number.isFinite(s)))return r;let i=Math.hypot(n,o,a);return i<=0||Math.abs(i-1)>RT?r:{...r,direction:Xo(e.direction,`${t}.direction`)}}function Uf(e,t,r){if(e!=null){if(!M(e)){r(t,"outline must be an object");return}e.renderOutline!=null&&typeof e.renderOutline!="boolean"&&r(`${t}.renderOutline`,"renderOutline must be boolean"),e.outlineWidth!=null&&(typeof e.outlineWidth!="number"||!Number.isFinite(e.outlineWidth))&&r(`${t}.outlineWidth`,"outlineWidth must be a finite number"),Ni(e.outlineColor,`${t}.outlineColor`,r)}}function bx(e,t,r){if(e==null){r(t,"groundDecal is required when transformType is groundDecal");return}if(!M(e)){r(t,"groundDecal must be an object");return}Sx(e,t,r)}function Sx(e,t,r){if(O(e.uiKind)||r(`${t}.uiKind`,"groundDecal UI kind must be non-empty"),!M(e.size))r(`${t}.size`,"groundDecal.size must be an object");else for(let n of["width","depth"])(typeof e.size[n]!="number"||!Number.isFinite(e.size[n])||e.size[n]<=0)&&r(`${t}.size.${n}`,"groundDecal size must be a positive finite number");if(e.aspectSourceLayerId!=null&&!O(e.aspectSourceLayerId)&&r(`${t}.aspectSourceLayerId`,"aspectSourceLayerId must be non-empty when present"),e.lockAspectToBorder!=null&&typeof e.lockAspectToBorder!="boolean"&&r(`${t}.lockAspectToBorder`,"lockAspectToBorder must be boolean when present"),e.editorPreviewActive!=null&&r(`${t}.editorPreviewActive`,"editorPreviewActive is editor-only and must not appear in runtime scene data"),yx(e.mask,`${t}.mask`,r),hx(e.rendering,`${t}.rendering`,r),!Array.isArray(e.layers)){r(`${t}.layers`,"groundDecal UI layers must be an array");return}e.layers.forEach((n,o)=>Ex(n,`${t}.layers[${o}]`,r)),Ix(e.layers,`${t}.layers`,r)}function yx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI mask must be an object");return}e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"mask.enabled must be boolean"),e.source!=null&&e.source!=="roundedRect"&&e.source!=="borderAlpha"&&e.source!=="texture"&&r(`${t}.source`,"mask.source must be roundedRect, borderAlpha, or texture"),e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"mask.textureId must be non-empty when present");for(let n of["cornerRadius","padding"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)&&r(`${t}.${n}`,`${n} must be a non-negative finite number`)}}function hx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI rendering must be an object");return}for(let n of["textureWidth","textureHeight"])e[n]!=null&&(!Number.isInteger(e[n])||e[n]<=0)&&r(`${t}.${n}`,`${n} must be a positive integer`);for(let n of["alphaIndex","diffuseTextureLevel","emissiveTextureLevel"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`${n} must be a finite number`)}}function Ex(e,t,r){if(!M(e)){r(t,"groundDecal UI layer must be an object");return}O(e.id)||r(`${t}.id`,"layer.id must be non-empty"),O(e.role)||r(`${t}.role`,"layer.role must be non-empty"),e.editorPreviewPercent!=null&&r(`${t}.editorPreviewPercent`,"editorPreviewPercent is editor-only and must not appear in runtime scene data"),e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"layer.enabled must be boolean"),(typeof e.zOrder!="number"||!Number.isFinite(e.zOrder))&&r(`${t}.zOrder`,"layer.zOrder must be a finite number"),e.opacity!=null&&(typeof e.opacity!="number"||!Number.isFinite(e.opacity))&&r(`${t}.opacity`,"layer.opacity must be finite"),e.rotationDeg!=null&&(typeof e.rotationDeg!="number"||!Number.isFinite(e.rotationDeg)||e.rotationDeg<=-180||e.rotationDeg>180)&&r(`${t}.rotationDeg`,"layer.rotationDeg must be in the range (-180, 180]"),Px(e.rect,`${t}.rect`,r),e.kind==="texture"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture layer imageFit must be contain or stretch"),Jn(e.tint,`${t}.tint`,r)):e.kind==="textureProgress"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture progress layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture progress layer imageFit must be contain or stretch"),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"texture progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"texture progress direction is invalid"),Jn(e.tint,`${t}.tint`,r)):e.kind==="color"?Jn(e.color,`${t}.color`,r):e.kind==="progress"?((typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"progress direction is invalid"),Jn(e.color,`${t}.color`,r)):e.kind==="text"?Tx(e.text,`${t}.text`,r):r(`${t}.kind`,"layer.kind must be texture, textureProgress, color, progress, or text")}function Ix(e,t,r){let n=new Map;e.forEach((o,a)=>{if(!M(o)||!O(o.id))return;let i=n.get(o.id);if(i!=null){r(`${t}[${a}].id`,`layer.id must be unique; duplicate of layers[${i}]`);return}n.set(o.id,a)})}function Px(e,t,r){if(!M(e)){r(t,"layer.rect must be an object");return}for(let n of["x","z","width","depth"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`rect.${n} must be a finite number`);for(let n of["width","depth"])typeof e[n]=="number"&&e[n]<=0&&r(`${t}.${n}`,`rect.${n} must be positive`)}function Tx(e,t,r){if(!M(e)){r(t,"text layer text must be an object");return}typeof e.value!="string"&&r(`${t}.value`,"text.value must be a string"),e.fontFamily!=null&&typeof e.fontFamily!="string"&&r(`${t}.fontFamily`,"fontFamily must be a string"),e.fontSize!=null&&(typeof e.fontSize!="number"||!Number.isFinite(e.fontSize)||e.fontSize<=0)&&r(`${t}.fontSize`,"fontSize must be a positive finite number"),e.fontWeight!=null&&typeof e.fontWeight!="string"&&r(`${t}.fontWeight`,"fontWeight must be a string"),Jn(e.color,`${t}.color`,r),Jn(e.strokeColor,`${t}.strokeColor`,r),e.strokeWidth!=null&&(typeof e.strokeWidth!="number"||!Number.isFinite(e.strokeWidth)||e.strokeWidth<0)&&r(`${t}.strokeWidth`,"strokeWidth must be a non-negative finite number")}function Jn(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`color.${n} must be finite`);e.a!=null&&(typeof e.a!="number"||!Number.isFinite(e.a))&&r(`${t}.a`,"color.a must be finite")}}function xx(e,t,r){if(e!=null){if(!M(e)){r(t,"rendering must be an object");return}e.renderingGroupId!=null&&e.renderingGroupId!==0&&e.renderingGroupId!==1&&e.renderingGroupId!==2&&e.renderingGroupId!==3&&r(`${t}.renderingGroupId`,"renderingGroupId must be 0, 1, 2, or 3"),e.alphaIndex!=null&&(typeof e.alphaIndex!="number"||!Number.isFinite(e.alphaIndex))&&r(`${t}.alphaIndex`,"alphaIndex must be a finite number")}}function Kf(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Zf(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;["albedoColor","diffuseColor","emissiveColor","outlineColor"].includes(n)&&Ni(o,a,r),["metallic","roughness","contrast","brightness","saturation","hue","colorDensity","alpha","alphaCutOff","transparencyMode"].includes(n)&&(typeof o!="number"||!Number.isFinite(o))&&r(a,`${n} must be a finite number`),n==="backFaceCulling"&&typeof o!="boolean"&&r(a,"backFaceCulling must be boolean"),["albedoTexture","normalTexture","metallicTexture"].includes(n)&&(M(o)?o.url!=null&&!O(o.url)&&r(`${a}.url`,"texture url must be non-empty when present"):r(a,`${n} must be an object`)),["pbr","standard"].includes(n)&&(M(o)?Zf(o,a,r):r(a,`${n} must be an object`))}}function Hf(e,t,r){let n=JSON.stringify(e),o=$T.filter(a=>n.includes(a));o.length>0&&r(t,`contains runtime-only asset fields: ${o.join(", ")}`)}function Ax(e,t,r){let n=Qf(e)??512,o=Qf(t)??512;if(!Number.isFinite(r)||r<=0)return{width:n,height:o};let a=n,i=Math.max(1,Math.round(a/r));return i>o&&(i=o,a=Math.max(1,Math.round(i*r))),{width:a,height:i}}function _i(e){let t=e.rendering?.textureWidth??512,r=e.rendering?.textureHeight??512,n=e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:t/r;return Ax(t,r,n)}function Qf(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function ep(e,t){let r=kd(t.ids);if(r.length===0)return J("empty-selection");for(let s of r)if(!ir(e,s))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");for(let s of n){let c=ir(e,s);if(!c)return J("missing-node");if(!op(c))return J(c.protected?"node-protected":c.locked?"node-locked":"node-readonly")}if(t.placement==="root")return t.parentId!=null||t.beforeId!=null||t.afterId!=null?J("invalid-root-anchors"):$i();let o=ir(e,t.targetId);if(!o)return J("missing-target-node");if(n.includes(o.id))return J("cannot-parent-to-self");if(n.some(s=>rp(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!np(o))return J("target-cannot-have-children");if(t.parentId!=null&&t.parentId!==o.id)return J("invalid-parent-anchor");let s=wd(e,o.id).filter(c=>!n.includes(c));return t.beforeId&&!s.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!s.includes(t.afterId)?J("invalid-after-anchor"):$i()}if(o.locked&&!o.protected)return J("target-node-locked");if(o.protected)return J("cannot-reorder-root");let a=ir(e,o.parentId);if(a?.locked&&!a.protected)return J("target-parent-locked");if((t.parentId??null)!==(o.parentId??null))return J("invalid-parent-anchor");let i=wd(e,o.parentId??null).filter(s=>!n.includes(s));return t.beforeId&&!i.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!i.includes(t.afterId)?J("invalid-after-anchor"):t.placement==="before"&&t.beforeId!==o.id?J("invalid-before-anchor"):t.placement==="after"&&t.afterId!==o.id?J("invalid-after-anchor"):$i()}function tp(e,t){let r=kd(t.ids);if(r.length===0)return J("empty-selection");for(let i of r)if(!ir(e,i))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");if(n.length<2)return J("selection-too-small");for(let i of n){let s=ir(e,i);if(!s)return J("missing-node");if(!op(s))return J(s.protected?"node-protected":s.locked?"node-locked":"node-readonly")}let o=ir(e,t.parentId);if(t.parentId&&!o)return J("missing-parent-node");if(o&&!np(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||rp(e,o.id,i)))return J("cannot-parent-to-descendant");let a=wd(e,t.parentId??null).filter(i=>!n.includes(i));if(t.insertBeforeId){let i=ir(e,t.insertBeforeId);if(!a.includes(t.insertBeforeId)||i?.protected)return J("invalid-before-anchor")}return $i()}function ir(e,t){return t?e.find(r=>r.id===t)??null:null}function kd(e){let t=[],r=new Set;for(let n of e)!n||r.has(n)||(r.add(n),t.push(n));return t}function St(e,t){let r=kd(t).filter(o=>!!ir(e,o)),n=new Set(r);return r.filter(o=>!Dx(e,o).some(a=>n.has(a)))}function wd(e,t){return e.filter(r=>(r.parentId??null)===(t??null)).map(r=>r.id)}function rp(e,t,r){let n=new Map(e.map(i=>[i.id,i])),o=n.get(t)??null,a=new Set;for(;o?.parentId;){if(o.parentId===r)return!0;if(a.has(o.parentId))return!1;a.add(o.parentId),o=n.get(o.parentId)??null}return!1}function np(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function op(e){return!!e&&e.protected!==!0&&e.locked!==!0&&e.draggable!==!1}function Dx(e,t){let r=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,a=r.get(t)??null;for(;a?.parentId&&!o.has(a.parentId);)o.add(a.parentId),n.push(a.parentId),a=r.get(a.parentId)??null;return n}function $i(){return{ok:!0}}function J(e){return{ok:!1,reason:e}}var yt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),tn={kind:"texture"},ap={kind:"color"},Mx={kind:"enum",values:["lit","unlit"]},wx={kind:"enum",values:["opaque","mask","blend"]},cp={lightingModel:Mx,baseColor:{kind:"object",properties:{color:ap,texture:tn,brightness:yt(0),saturation:yt(0),contrast:yt(0),hue:yt(-180,180)}},normal:{kind:"object",properties:{texture:tn,strength:yt(0)}},emission:{kind:"object",properties:{color:ap,intensity:yt(0),texture:tn,maskTexture:tn}},alpha:{kind:"object",properties:{mode:wx,opacity:yt(0,1),cutoff:yt(0,1),texture:tn}}},kx={kind:"object",properties:{...cp,metallic:yt(0,1),roughness:yt(0,1),metallicRoughness:{kind:"object",properties:{texture:tn}},occlusion:{kind:"object",properties:{texture:tn,strength:yt(0)}}}},Ox={kind:"object",properties:cp},Rx={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},Cx={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},ip=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],rn={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},dp=[Yn("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Yn("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Zn("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),ht("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),Zn("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[rn]),ht("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[rn,Xn("properties.normal.texture.textureAssetId","normalTexture")]}),Yn("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),ht("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Zn("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Yn("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),ht("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),ht("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Zn("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],vx=[...dp,ht("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[rn]}),ht("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[rn]}),Zn("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[rn]),Zn("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[rn]),ht("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[rn,Xn("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],Gx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:kx,defaultProperties:Rx,inspector:{sections:ip,fields:vx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Ox,defaultProperties:Cx,inspector:{sections:ip,fields:dp}}],Mr=jx(Gx);function jx(e){let t=new Map;for(let n of e){Fx(n,t);let o=_x(n);t.set(n.shaderId,mp(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Rd(e,t=Mr){return t.get(e)}function De(e){return Rd(e)}function Nx(e,t,r=Mr){let n=vd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function Qn(e,t,r=Mr){let n=Rd(e,r);if(!n)return null;let o=Nx(e,t,r),i=(o?.schemaPath??vd(t)).replace(/^properties\./,"").split(".").filter(Boolean);if(i.length===0)return null;let s=n.propertiesSchema;for(let c=0;c<i.length;c+=1){let d=i[c];if(s.kind==="texture"&&c===i.length-1&&(d==="url"||d==="textureAssetId"))return{kind:"string",nullable:!0};if(s.kind!=="object")return null;let u=s.properties[d];if(!u)return null;s=u}return o?.control==="texture"&&s.kind==="texture"?{kind:"string",nullable:!0}:s}function Cd(e){let t=De(e);if(!t)throw new Error(`Unknown built-in material shader: ${e}`);return structuredClone(t.defaultProperties)}function eo(e,t,r="properties",n=Mr){let o=Rd(e,n);if(!o)return[{path:"shaderId",message:`Unknown material shader: ${String(e)}`}];let a=[];return Gd(o.propertiesSchema,t,r,a),a}function Yn(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function ht(e,t,r,n,o,a,i={}){return Yn(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Zn(e,t,r,n,o,a,i,s){return Yn(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Xn(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Fx(e,t){if(!Wn(e.shaderId)&&!Qo(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Lx(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);lp(e.shaderId,e.propertiesSchema,"properties");let r=[];if(Gd(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);$x(e,a),o.add(a.path)}}function _x(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=up(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function $x(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=up(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function lp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))lp(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function Lx(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function vd(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function up(e,t){let r=vd(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function Gd(e,t,r,n){if(e.kind==="object"){if(!Od(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&Gd(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];sp(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){sp(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!Od(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function sp(e,t,r,n,o){if(!Od(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function mp(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))mp(t)}return e}function Od(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function to(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,Bx(n));for(let n of ea(e)){let o=r.get(n.type)??null;r.set(n.type,Vx(o,n))}return[...r.values()]}function Nd(e){return structuredClone(e)}function Bx(e){return{...Nd(e),metadata:{...e.metadata??{},builtIn:!0}}}function Vx(e,t){let r=e??null;return{...r??{},...Nd(t),type:t.type,label:t.label||r?.label||t.type,metadata:{...r?.metadata??{},...t.metadata??{},builtIn:r?.metadata?.builtIn===!0}}}function Ux(e,t,r={}){if(!bp(t)||$d(t.type,r))return e;let n=ea(e);return n.some(o=>o.type===t.type)?e:_d(e,[...n,Fd(t,!1)])}function Kx(e,t,r,n={}){let o=t.trim();if(!o)return e;let a=$d(o,n),i=ea(e),s=i.find(u=>u.type===o)??null;if(!a&&!s)return e;let c=s??a;if(!c)return e;let d=Fd({...c,...r,type:o,label:typeof r.label=="string"&&r.label.trim()?r.label.trim():c.label||o},!!a);return _d(e,[...i.filter(u=>u.type!==o),d])}function Hx(e,t,r={}){let n=t.trim();if(!n||Sp(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=ea(e),a=o.filter(i=>i.type!==n);return a.length===o.length?e:_d(e,a)}function Fd(e,t){return{type:e.type.trim(),label:e.label.trim()||e.type.trim(),...e.kind?{kind:e.kind}:{},...e.description!==void 0?{description:e.description}:{},...e.defaultTags?{defaultTags:[...e.defaultTags]}:{},metadata:{...e.metadata??{},builtIn:!1,...t?{overridesBuiltIn:!0}:{}}}}function ea(e){let t=e?.metadata?.markerTypes;return Array.isArray(t)?t.map(Wx).filter(r=>!!r):[]}function _d(e,t){let r=e.metadata?structuredClone(e.metadata):{};return t.length===0?delete r.markerTypes:r.markerTypes=t.map(Nd),{...e,metadata:Object.keys(r).length>0?r:void 0}}function Wx(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.type!="string"||!t.type.trim()||typeof t.label!="string"||!t.label.trim()?null:Fd({type:t.type.trim(),label:t.label.trim(),...typeof t.kind=="string"&&t.kind?{kind:t.kind}:{},...typeof t.description=="string"?{description:t.description}:{},...Array.isArray(t.defaultTags)?{defaultTags:t.defaultTags.filter(r=>typeof r=="string")}:{},...t.metadata&&typeof t.metadata=="object"?{metadata:t.metadata}:{}},t.metadata?.overridesBuiltIn===!0)}function bp(e){return!!e.type.trim()&&!!e.label.trim()}function $d(e,t={}){let r=e.trim();return t.builtInMarkerTypes?.find(n=>n.type===r)??null}function Sp(e,t={}){return!!$d(e,t)}function sr(e){let{spatial:t,...r}=structuredClone(e);return r}function Li(e){return structuredClone(e)}function yp(e,t){return{...Li(e),from:fp(e.from,t),to:fp(e.to,t)}}function hp(e,t){return{...sr(e),...e.target?{target:jd(e.target,t)}:{},geometry:qx(e.geometry,t)}}function qx(e,t){switch(e.kind){case"point":return{...structuredClone(e),...e.target?{target:jd(e.target,t)}:{}};case"object-bounds":return{...structuredClone(e),target:jd(e.target,t)};case"box":case"polyhedron":return structuredClone(e)}}function jd(e,t){return e.kind!=="marker"?structuredClone(e):{...structuredClone(e),id:t.get(e.id)??e.id}}function fp(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function Ep(e,t){let r=new Set([t]),n=!0;for(;n;){n=!1;for(let o of e.scene.gameObjects)!o.parentId||!r.has(o.parentId)||r.has(o.id)||(r.add(o.id),n=!0)}return r}function Ld(e,t){return(e.kind==="marker"||e.kind==="scene-object")&&t.has(e.id)}function ta(e,t){return!e||e.kind!=="scene-object"||t.has(e.id)}function zd(e,t,r){return e.kind==="marker"?r.has(e.id):e.kind==="scene-object"?t.has(e.id):!0}function pp(e,t){return e.kind==="marker"&&e.id===t}function cr(e){if(!e)return{schemaVersion:1,markers:[],relations:[]};let t=structuredClone(e),{metadata:r,...n}=t;return{...n,schemaVersion:1,markers:e.markers.map(sr),relations:e.relations.map(Li),...r?{metadata:structuredClone(r)}:{}}}function Bd(e,t){return{...e,scene:{...e.scene,markerGraph:t}}}function Jx(e,t){let r=sr(t),n=e.markers.some(o=>o.id===r.id);return{...e,markers:n?e.markers.map(o=>o.id===r.id?r:o):[...e.markers,r]}}function Xx(e,t,r){let n=!1,o=e.markers.map(a=>a.id!==t?a:(n=!0,sr({...a,...r,id:a.id})));return n?{...e,markers:o}:e}function Yx(e,t){return{...e,markers:e.markers.filter(r=>r.id!==t),relations:e.relations.filter(r=>!pp(r.from,t)&&!pp(r.to,t))}}function gp(e,t){let r=Li(t),n=e.relations.some(o=>o.id===r.id);return{...e,relations:n?e.relations.map(o=>o.id===r.id?r:o):[...e.relations,r]}}function Zx(e,t){let r=!1,n=e.relations.map(o=>o.id!==t?o:(r=!0,{...Li(o),from:{...o.to},to:{...o.from}}));return r?{...e,relations:n}:e}function Ip(e,t,r={}){switch(t.type){case"marker.create-box":return Jx(e,t.marker);case"marker.update":return Xx(e,t.markerId,t.patch);case"marker.delete":return Yx(e,t.markerId);case"relation.create":return gp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>gp(n,o),e);case"relation.delete":return{...e,relations:e.relations.filter(n=>n.id!==t.relationId)};case"relation.delete-many":{let n=new Set(t.relationIds);return{...e,relations:e.relations.filter(o=>!n.has(o.id))}}case"relation.reverse":return Zx(e,t.relationId);case"marker.sync-from-scene":return e;case"marker-type.create":return Ux(e,t.definition,r);case"marker-type.update":return Kx(e,t.typeId,t.patch,r);case"marker-type.delete":return Hx(e,t.typeId,r)}}function Pp(e,t,r={}){if(t.type!=="marker.create-box")return t;let n=sr(t.marker),o=new Set(e.scene.gameObjects.map(i=>i.id)),a=new Set(e.scene.gameObjects.map(i=>(i.name??"").trim()).filter(Boolean));return o.has(n.id)&&(n.id=Qx(n.id,o,r.sanitizeMarkerGameObjectId)),(!n.label.trim()||a.has(n.label.trim()))&&(n.label=tA(n.label||n.id,a)),{...t,marker:n}}function Qx(e,t,r){let o=(r??eA)(e).replace(/-\d+$/,"")||"marker";if(!t.has(o))return o;let a=2;for(;t.has(`${o}-${a}`);)a+=1;return`${o}-${a}`}function eA(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function tA(e,t){let n=(e.trim()||"Marker").replace(/\s+\d+$/,"")||"Marker";if(!t.has(n))return n;let o=2;for(;t.has(`${n} ${o}`);)o+=1;return`${n} ${o}`}function Tp(e,t,r,n={}){switch(t.type){case"marker.create-box":return rA(e,t.marker.geometry)&&!!t.marker.id.trim()&&!e.scene.gameObjects.some(o=>o.id===t.marker.id)&&nA(e,t.parentId??null,n);case"relation.create-many":return t.relations.length>0;case"relation.delete-many":return t.relationIds.length>0;case"relation.reverse":return r.relations.some(o=>o.id===t.relationId);case"marker-type.create":return bp(t.definition)&&!to(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&to(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||Sp(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&ea(r).some(a=>a.type===o)}default:return!0}}function rA(e,t){switch(t.kind){case"box":case"point":return!0;case"object-bounds":return ta(t.target,new Set(e.scene.gameObjects.map(r=>r.id)));case"polyhedron":return!1}}function nA(e,t,r){if(!t)return!0;let n=e.scene.gameObjects.find(o=>o.id===t)??null;return!!n&&!(r.isMarkerGameObject?.(n)??!!n.marker)}function xp(e){switch(e.type){case"marker.create-box":return`Create marker ${e.marker.label}`;case"marker.update":return`Update marker ${e.markerId}`;case"marker.delete":return`Delete marker ${e.markerId}`;case"relation.create":return`Create relation ${e.relation.type}`;case"relation.create-many":return`Create ${e.relations.length} relations`;case"relation.delete":return`Delete relation ${e.relationId}`;case"relation.delete-many":return`Delete ${e.relationIds.length} relations`;case"relation.reverse":return`Reverse relation ${e.relationId}`;case"marker.sync-from-scene":return"Sync marker graph";case"marker-type.create":return`Create marker type ${e.definition.label}`;case"marker-type.update":return`Update marker type ${e.typeId}`;case"marker-type.delete":return`Delete marker type ${e.typeId}`}}function Ap(e){switch(e.type){case"marker.create-box":return{changedId:e.marker.id,changedIds:[e.marker.id],selectId:e.marker.id};case"marker.update":case"marker.delete":return{changedId:e.markerId,changedIds:[e.markerId]};case"relation.create":return{changedIds:[e.relation.from.id,e.relation.to.id]};case"relation.create-many":return{changedIds:[...new Set(e.relations.flatMap(t=>[t.from.id,t.to.id]))]};case"relation.delete":case"relation.delete-many":case"relation.reverse":case"marker.sync-from-scene":case"marker-type.create":case"marker-type.update":case"marker-type.delete":return{}}}function Vd(e){let t=structuredClone(e);if(t.type==="marker.create-box"&&(t.marker=sr(t.marker)),t.type==="marker.update"){let{spatial:r,...n}=t.patch;t.patch=n}return t}function ra(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Dp(e,t,r,n={}){let o=t.find(a=>a.path===r.path);if(!o)throw new Error(`Serialized property descriptor not found: ${r.path}`);if(o.readOnly===!0||typeof o.setValue!="function")throw new Error(`Serialized property is read-only: ${r.path}`);return o.setValue(e,r.value,{...n,targetId:r.targetId})}var zi="summary",Mp="body";function Et(){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function oA(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Vi(e){let t=Cp(e);return t&&aA(t)?{mode:"matrix",matrix:t}:null}function wp(e){return tt(e)?{mode:"matrix",matrix:Xd(e.matrix)}:{...e.mode==="trs"?{mode:"trs"}:{},position:Bi(e.position),rotation:Bi(e.rotation),scale:Bi(e.scale)}}function tt(e){return e.mode==="matrix"}function It(e){return e.mode!=="matrix"}function Ui(e){return tt(e)?{x:e.matrix[12],y:e.matrix[13],z:e.matrix[14]}:Bi(e.position)}function aA(e){return!!Cp(e)&&Math.abs(e[3])<=1e-6&&Math.abs(e[7])<=1e-6&&Math.abs(e[11])<=1e-6&&Math.abs(e[15]-1)<=1e-6&&!!kp(e)}function Fe(e){if(tt(e))return Xd(e.matrix);let t=iA(e.rotation),r=t.x,n=t.y,o=t.z,a=t.w,i=r+r,s=n+n,c=o+o,d=r*i,u=r*s,l=r*c,m=n*s,f=n*c,S=o*c,g=a*i,b=a*s,y=a*c,I=e.scale.x,E=e.scale.y,T=e.scale.z;return[(1-(m+S))*I,(u+y)*I,(l-b)*I,0,(u-y)*E,(1-(d+S))*E,(f+g)*E,0,(l+b)*T,(f-g)*T,(1-(d+m))*T,0,e.position.x,e.position.y,e.position.z,1]}function Wd(e,t){return[e[0]*t[0]+e[1]*t[4]+e[2]*t[8]+e[3]*t[12],e[0]*t[1]+e[1]*t[5]+e[2]*t[9]+e[3]*t[13],e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+e[3]*t[14],e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+e[3]*t[15],e[4]*t[0]+e[5]*t[4]+e[6]*t[8]+e[7]*t[12],e[4]*t[1]+e[5]*t[5]+e[6]*t[9]+e[7]*t[13],e[4]*t[2]+e[5]*t[6]+e[6]*t[10]+e[7]*t[14],e[4]*t[3]+e[5]*t[7]+e[6]*t[11]+e[7]*t[15],e[8]*t[0]+e[9]*t[4]+e[10]*t[8]+e[11]*t[12],e[8]*t[1]+e[9]*t[5]+e[10]*t[9]+e[11]*t[13],e[8]*t[2]+e[9]*t[6]+e[10]*t[10]+e[11]*t[14],e[8]*t[3]+e[9]*t[7]+e[10]*t[11]+e[11]*t[15],e[12]*t[0]+e[13]*t[4]+e[14]*t[8]+e[15]*t[12],e[12]*t[1]+e[13]*t[5]+e[14]*t[9]+e[15]*t[13],e[12]*t[2]+e[13]*t[6]+e[14]*t[10]+e[15]*t[14],e[12]*t[3]+e[13]*t[7]+e[14]*t[11]+e[15]*t[15]]}function kp(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=t*i-r*a,I=t*s-n*a,E=t*c-o*a,T=r*s-n*i,A=r*c-o*i,$=n*c-o*s,z=d*S-u*f,p=d*g-l*f,D=d*b-m*f,h=u*g-l*S,R=u*b-m*S,K=l*b-m*g,ne=y*K-I*R+E*h+T*D-A*p+$*z;if(!Number.isFinite(ne)||Math.abs(ne)<1e-6)return null;let F=1/ne;return[(i*K-s*R+c*h)*F,(n*R-r*K-o*h)*F,(S*$-g*A+b*T)*F,(l*A-u*$-m*T)*F,(s*D-a*K-c*p)*F,(t*K-n*D+o*p)*F,(g*E-f*$-b*I)*F,(d*$-l*E+m*I)*F,(a*R-i*D+c*z)*F,(r*D-t*R-o*z)*F,(f*A-S*E+b*y)*F,(u*E-d*A-m*y)*F,(i*p-a*h-s*z)*F,(t*h-r*p+n*z)*F,(S*I-f*T-g*y)*F,(d*T-u*I+l*y)*F]}function qd(e){let t={x:e[12],y:e[13],z:e[14]},r={x:Ud(e[0],e[1],e[2]),y:Ud(e[4],e[5],e[6]),z:Ud(e[8],e[9],e[10])};if(lA(e)<=0&&(r.y*=-1),!Hd(t)||!Hd(r)||Math.abs(r.x)<1e-6||Math.abs(r.y)<1e-6||Math.abs(r.z)<1e-6)return null;let n=1/r.x,o=1/r.y,a=1/r.z,i=[e[0]*n,e[1]*n,e[2]*n,0,e[4]*o,e[5]*o,e[6]*o,0,e[8]*a,e[9]*a,e[10]*a,0,0,0,0,1];if(!uA(i))return null;let s=dA(cA(i));if(!s)return null;let c=sA(s);if(!Hd(c))return null;let d={position:t,rotation:c,scale:r};return na(Fe(d),e,1e-5)?d:null}function Jd(e,t={}){let r=qd(e);return r||(t.allowMatrixFallback?Vi(e):null)}function Op(e){let t=oA();for(let r of e)t=Wd(Fe(r),t);return Jd(t,{allowMatrixFallback:!0})}function Rp(e,t){return Jd(Wd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function ro(e,t,r={}){let n=kp(Fe(e));return n?Jd(Wd(Fe(t),n),r):null}function na(e,t,r=1e-6){return e.length===t.length&&e.every((n,o)=>Math.abs(n-t[o])<=r)}function Xd(e){return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}function Cp(e){return e.length!==16||!e.every(Number.isFinite)?null:Xd(e)}function Bi(e){return{x:e.x,y:e.y,z:e.z}}function iA(e){let t=e.z*.5,r=e.x*.5,n=e.y*.5,o=Math.sin(t),a=Math.cos(t),i=Math.sin(r),s=Math.cos(r),c=Math.sin(n),d=Math.cos(n);return{x:d*i*a+c*s*o,y:c*s*a-d*i*o,z:d*s*o-c*i*a,w:d*s*a+c*i*o}}function sA(e){let t=e.z,r=e.x,n=e.y,o=e.w,a=n*t-r*o,i=.4999999;if(a<-i)return{x:Math.PI/2,y:2*Math.atan2(n,o),z:0};if(a>i)return{x:-Math.PI/2,y:2*Math.atan2(n,o),z:0};let s=o*o,c=t*t,d=r*r,u=n*n;return{z:Math.atan2(2*(r*n+t*o),-c-d+u+s),x:Math.asin(-2*a),y:Math.atan2(2*(t*r+n*o),c-d-u+s)}}function cA(e){let t=e[0],r=e[4],n=e[8],o=e[1],a=e[5],i=e[9],s=e[2],c=e[6],d=e[10],u=t+a+d;if(u>0){let m=.5/Math.sqrt(u+1);return{w:.25/m,x:(c-i)*m,y:(n-s)*m,z:(o-r)*m}}if(t>a&&t>d){let m=2*Math.sqrt(1+t-a-d);return{w:(c-i)/m,x:.25*m,y:(r+o)/m,z:(n+s)/m}}if(a>d){let m=2*Math.sqrt(1+a-t-d);return{w:(n-s)/m,x:(r+o)/m,y:.25*m,z:(i+c)/m}}let l=2*Math.sqrt(1+d-t-a);return{w:(o-r)/l,x:(n+s)/l,y:(i+c)/l,z:.25*l}}function dA(e){let t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);return!Number.isFinite(t)||t<1e-6?null:{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}function lA(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=l*b-g*m,I=u*b-S*m,E=u*g-S*l,T=d*b-f*m,A=d*g-l*f,$=d*S-f*u,z=+(i*y-s*I+c*E),p=-(a*y-s*T+c*A),D=+(a*I-i*T+c*$),h=-(a*E-i*A+s*$);return t*z+r*p+n*D+o*h}function Ud(e,t,r){return Math.sqrt(e*e+t*t+r*r)}function uA(e){let t={x:e[0],y:e[1],z:e[2]},r={x:e[4],y:e[5],z:e[6]},n={x:e[8],y:e[9],z:e[10]};return Math.abs(Kd(t,r))<1e-6&&Math.abs(Kd(t,n))<1e-6&&Math.abs(Kd(r,n))<1e-6}function Kd(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Hd(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}var mA={supportsShear:!1,supportsMatrixTransform:!1};function Ki(e={}){let t={...mA,...e.storageCapabilities};return{allowMatrixFallback:(e.allowMatrixFallback??!1)&&t.supportsMatrixTransform&&t.supportsShear,storageCapabilities:t}}function w(e){return typeof e=="number"&&Number.isFinite(e)}function nn(e){return e==null||typeof e=="string"}function on(e){return e==null||typeof e=="string"&&e.trim().length>0}function Hi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Wi(e){return e==null||typeof e=="boolean"}function qe(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)&&w(t.z)}function qi(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)}function oa(e){if(w(e))return e>=0;if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&t.x>=0&&w(t.y)&&t.y>=0&&w(t.z)&&t.z>=0}function Ft(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.r)&&w(t.g)&&w(t.b)}function _t(e){return w(e)&&e>0}function aa(e){return w(e)&&e>=0}function Ji(e){return w(e)&&e>=0&&e<=1}function Xi(e){if(!e||typeof e!="object")return!1;let t=e;return!(t.position!==void 0&&!qe(t.position)||t.rotation!==void 0&&!qe(t.rotation)||t.rotationDeg!==void 0&&!qe(t.rotationDeg)||t.scale!==void 0&&!oa(t.scale))}function Yi(e){return e==="orthographic"||e==="perspective"}function Zi(e){return e==="hemispheric"||e==="directional"}var $t=["group","instance","transform","primitive"],vp=["instance","transform","primitive"],fA=["position","rotation","scale"],pA=["x","y","z"];function gA(e){return{path:`transform.${e}`,appliesTo:$t,validate:t=>t==null||(e==="scale"?oa(t):qe(t))}}function bA(e,t){return{path:`transform.${e}.${t}`,appliesTo:$t,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?aa(r):w(r))}}function SA(e){return[gA(e),...pA.map(t=>bA(e,t))]}var Yd=[{path:"name",appliesTo:$t,validate:nn},{path:"parentId",appliesTo:$t,validate:nn},{path:"enabled",appliesTo:$t,validate:Wi},{path:"shadow.cast",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"transform",appliesTo:$t,validate:e=>e==null||Xi(e)},...fA.flatMap(SA),{path:"transform.rotationDeg",appliesTo:$t,validate:e=>e==null||qe(e)},{path:"transform.rotationDeg.x",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.y",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.z",appliesTo:$t,validate:e=>e==null||w(e)},{path:"instance.assetId",appliesTo:["instance"],validate:e=>typeof e=="string"&&e.trim().length>0,allowDelete:!1},{path:"primitive.shape",appliesTo:["primitive"],validate:e=>e==="cube"||e==="sphere"||e==="plane"||e==="capsule",allowDelete:!1},{path:"camera.projection",appliesTo:["transform"],validate:Yi,allowDelete:!1},{path:"camera.alpha",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.beta",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.radius",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.orthoSize",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.fov",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.targetOffset",appliesTo:["transform"],validate:e=>e==null||qe(e)},{path:"camera.targetOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.minZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.maxZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.lowerBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.upperBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.lowerRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.upperRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.inertia",appliesTo:["transform"],validate:Ji,allowDelete:!1},{path:"camera.targetScreenOffset",appliesTo:["transform"],validate:e=>e==null||qi(e)},{path:"camera.targetScreenOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetScreenOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.type",appliesTo:["transform"],validate:Zi,allowDelete:!1},{path:"light.intensity",appliesTo:["transform"],validate:aa,allowDelete:!1},{path:"light.direction",appliesTo:["transform"],validate:qe,allowDelete:!1},{path:"light.direction.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.diffuseColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"light.groundColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.type",appliesTo:["transform"],validate:nn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:on},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Hi(e)},{path:"marker.note",appliesTo:["transform"],validate:nn},{path:"marker.color",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.color.r",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.g",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.b",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1}];var ie=["instance","transform","primitive"];function Je(e){return{path:e,appliesTo:ie,validate:t=>t==null||Ft(t)}}function V(e){return{path:e,appliesTo:ie,validate:t=>t==null||w(t)}}function Gp(e){return{path:e,appliesTo:ie,validate:t=>t==null||typeof t=="boolean"}}function le(e){return{path:e,appliesTo:ie,validate:on}}function hA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="opaque"||t==="mask"||t==="blend"}}function EA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="lit"||t==="unlit"}}var IA=[{path:"transformType",appliesTo:["transform"],validate:e=>e==null||typeof e=="string"},{path:"rendering.renderingGroupId",appliesTo:ie,validate:e=>e==null||e===0||e===1||e===2||e===3},{path:"rendering.alphaIndex",appliesTo:ie,validate:e=>e==null||w(e)},Je("overrides.material.albedoColor"),Je("overrides.material.diffuseColor"),Je("overrides.material.emissiveColor"),V("overrides.material.metallic"),V("overrides.material.roughness"),V("overrides.material.contrast"),V("overrides.material.brightness"),V("overrides.material.saturation"),V("overrides.material.hue"),V("overrides.material.colorDensity"),V("overrides.material.alpha"),V("overrides.material.alphaCutOff"),V("overrides.material.transparencyMode"),Gp("overrides.material.backFaceCulling"),le("overrides.material.albedoTexture.url"),le("overrides.material.normalTexture.url"),V("overrides.material.normalTexture.level"),le("overrides.material.metallicTexture.url"),le("overrides.material.occlusionTexture.url"),le("overrides.material.emissiveTexture.url"),le("overrides.material.opacityTexture.url"),Je("overrides.material.pbr.albedoColor"),V("overrides.material.pbr.baseWeight"),Je("overrides.material.pbr.reflectivityColor"),V("overrides.material.pbr.microSurface"),Je("overrides.material.pbr.emissiveColor"),Je("overrides.material.pbr.ambientColor"),V("overrides.material.pbr.lightFalloff"),V("overrides.material.pbr.directIntensity"),V("overrides.material.pbr.emissiveIntensity"),V("overrides.material.pbr.environmentIntensity"),V("overrides.material.pbr.specularIntensity"),V("overrides.material.pbr.metallicF0Factor"),V("overrides.material.pbr.indexOfRefraction"),Je("overrides.material.standard.diffuseColor"),Je("overrides.material.standard.specularColor"),V("overrides.material.standard.specularPower"),Je("overrides.material.standard.emissiveColor"),Je("overrides.material.standard.ambientColor"),Gp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:ie,validate:on},EA("overrides.materialBinding.override.lightingModel"),Je("overrides.materialBinding.override.baseColor.color"),{path:"overrides.materialBinding.override.baseColor.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},le("overrides.materialBinding.override.baseColor.texture.url"),le("overrides.materialBinding.override.baseColor.texture.textureAssetId"),V("overrides.materialBinding.override.baseColor.brightness"),V("overrides.materialBinding.override.baseColor.saturation"),V("overrides.materialBinding.override.baseColor.contrast"),V("overrides.materialBinding.override.baseColor.hue"),le("overrides.materialBinding.override.normal.texture.url"),le("overrides.materialBinding.override.normal.texture.textureAssetId"),V("overrides.materialBinding.override.normal.strength"),V("overrides.materialBinding.override.metallic"),V("overrides.materialBinding.override.roughness"),le("overrides.materialBinding.override.metallicRoughness.texture.url"),le("overrides.materialBinding.override.metallicRoughness.texture.textureAssetId"),le("overrides.materialBinding.override.occlusion.texture.url"),le("overrides.materialBinding.override.occlusion.texture.textureAssetId"),V("overrides.materialBinding.override.occlusion.strength"),Je("overrides.materialBinding.override.emission.color"),{path:"overrides.materialBinding.override.emission.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},V("overrides.materialBinding.override.emission.intensity"),le("overrides.materialBinding.override.emission.texture.url"),le("overrides.materialBinding.override.emission.texture.textureAssetId"),le("overrides.materialBinding.override.emission.maskTexture.url"),le("overrides.materialBinding.override.emission.maskTexture.textureAssetId"),hA("overrides.materialBinding.override.alpha.mode"),V("overrides.materialBinding.override.alpha.opacity"),V("overrides.materialBinding.override.alpha.cutoff"),le("overrides.materialBinding.override.alpha.texture.url"),le("overrides.materialBinding.override.alpha.texture.textureAssetId"),{path:"overrides.outline",appliesTo:ie,validate:e=>e==null||PA(e)},{path:"overrides.outline.strategy",appliesTo:ie,validate:e=>e==null||e==="babylon-default"},{path:"overrides.outline.renderOutline",appliesTo:ie,validate:e=>e==null||typeof e=="boolean"},V("overrides.outline.outlineWidth"),{path:"overrides.outline.outlineColor",appliesTo:ie,validate:e=>e==null||Ft(e)},{path:"overrides.outline.outlineColor.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1}],jp=[...Yd,...IA];function PA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.strategy==null||t.strategy==="babylon-default")&&(t.renderOutline==null||typeof t.renderOutline=="boolean")&&(t.outlineWidth==null||w(t.outlineWidth))&&(t.outlineColor==null||Ft(t.outlineColor))}function Zd(e,t){let r=jp.find(n=>n.path===e)??null;return!r||!r.appliesTo.includes(t)?null:r}var dr="scene.materialAssets.",Qd="__fps_duplicate_material_asset__:",TA="mat_";function xA(e){return String(e??"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"")}function lr(e){let t=xA(e);return`${TA}${t||"material"}`}function el(){let e=globalThis.crypto?.randomUUID?.();if(e)return e;let t=Math.random().toString(36).slice(2,12);return`${Date.now().toString(36)}-${t}`}function Np(e){let t=String(e??"").trim()||"material",r=[0,1,2,3].map(n=>AA(`${t}\0${n}`)).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-4${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20,32)}`}function AA(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Fp(e,t=dr){if(!e.startsWith(t))return null;let r=e.slice(t.length);if(!r)return null;if(r.endsWith(".name")){let s=r.slice(0,-5);return s?{materialAssetId:s,fieldPath:"name"}:null}let n=".properties.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return!a||!i?null:{materialAssetId:a,fieldPath:`properties.${i}`}}function wr(e){return e==="overrides.materialBinding.materialAssetId"||Lt(e,"materialAssetId")!=null}function tl(e){if(wr(e))return!0;let t="overrides.materialBinding.override.";if(e.startsWith(t))return Qi(`properties.${e.slice(t.length)}`);let r=DA(e);return r?Qi(`properties.${r}`):!1}function es(e){return e==="overrides.materialBinding.materialAssetId"||e.startsWith("overrides.materialBinding.override.")||Lt(e,"materialAssetId")!=null||Lt(e,"override")!=null}function Lt(e,t){let r="overrides.materialSlotBindings.";if(!e.startsWith(r))return null;let n=e.slice(r.length);if(t==="materialAssetId"){let c=".materialAssetId";if(!n.endsWith(c))return null;let d=n.slice(0,-c.length);return d||null}let o=".override.",a=n.lastIndexOf(o);if(a<0)return null;let i=n.slice(0,a),s=n.slice(a+o.length);return i&&s?i:null}function DA(e){let t="overrides.materialSlotBindings.";if(!e.startsWith(t))return null;let r=e.slice(t.length),n=".override.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return a&&i?i:null}function Qi(e){return e.endsWith(".texture.url")||e.endsWith(".maskTexture.url")||e.endsWith(".texture.textureAssetId")||e.endsWith(".maskTexture.textureAssetId")}function no(e,t){if(!De(e)||!Qi(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return Qn(e,r)?.kind==="texture"}function rt(e,t){if(e==="name"&&typeof t=="string")return t.trim();if(Qi(e)&&typeof t=="string"){let r=t.trim();return r||null}return(e==="properties.alpha.mode"||e==="properties.lightingModel")&&typeof t=="string"?t.trim():t}function zt(e,t,r,n=Mr){let o=rt(e,t);if(e==="name")return typeof o=="string"&&o.length>0;let a=MA(e,r,n);return a?wA(a,o):!1}function MA(e,t,r){if(t!=null)return Qn(t,e,r);for(let n of r.list()){let o=Qn(n.shaderId,e,r);if(o)return o}return null}function wA(e,t){if(t==null)return e.kind==="texture"||e.kind==="string"&&e.nullable===!0;if(e.kind==="number")return!(!w(t)||e.min!=null&&t<e.min||e.max!=null&&t>e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"&&t.trim().length>0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return e.channels===4?OA(t):kA(t);if(e.kind==="vec2"||e.kind==="vec3"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t,n=e.kind==="vec2"?["x","y"]:["x","y","z"];return Object.keys(r).every(o=>n.includes(o))&&n.every(o=>w(r[o]))}if(e.kind==="texture"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t;return Object.keys(r).every(n=>n==="url"||n==="textureAssetId")&&["url","textureAssetId"].every(n=>r[n]===void 0||typeof r[n]=="string"&&r[n].trim().length>0)}return!1}function ts(e){return typeof e!="string"||!e.startsWith(Qd)?null:e.slice(Qd.length).trim()||null}function _p(e){return e.trim().replace(/^\/+|\/+$/g,"")}function kA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b")&&w(t.r)&&w(t.g)&&w(t.b)}function OA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b"||r==="a")&&w(t.r)&&w(t.g)&&w(t.b)&&w(t.a)}var RA={r:.78,g:.78,b:.78};function Bt(e,t={}){let r=e??{},n=GA(r.baseColor?.texture,t),o=vA(r,t),a=CA(r,t);return{kind:"material-sphere",baseColor:jA(r),metallic:ia(r.metallic??0),roughness:ia(r.roughness??1),...r.emission?.color?{emissionColor:zp(r.emission.color)}:{},emissionIntensity:NA(r.emission?.intensity,0),textureUrl:n,profile:o,properties:structuredClone(e??{}),...a.length>0?{textureResources:a}:{}}}function CA(e,t){return[["baseColor",e.baseColor?.texture],["normal",e.normal?.texture],["metallicRoughness",e.metallicRoughness?.texture],["occlusion",e.occlusion?.texture],["emission",e.emission?.texture],["emissionMask",e.emission?.maskTexture],["alpha",e.alpha?.texture]].flatMap(([n,o])=>{let a=rl(o,t);return a?[{channel:n,...a}]:[]})}function vA(e,t){let r=structuredClone(e),n=an(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=an(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=an(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=an(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=an(r.emission?.texture,t),c=an(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=an(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function an(e,t){if(!e)return;let r=rl(e,t);if(r?.state==="missing")return{...e,url:null};let n=r?.url;return{...e,...n?{url:n}:{}}}function GA(e,t){let r=rl(e,t);return r?.state==="ready"?r.url:void 0}function rl(e,t){let r=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";if(r){let o=t.resolveTextureAssetUrl?.(r)?.trim();if(o)return{reference:r,state:"ready",url:o};let a=t.textureAssets?.find(i=>i.id===r)?.url?.trim();if(a)return{reference:r,state:"ready",url:a};if(t.resolveTextureAssetUrl||Array.isArray(t.textureAssets))return{reference:r,state:"missing"}}let n=typeof e?.url=="string"?e.url.trim():"";return n?{reference:r||n,state:"ready",url:n}:null}function Lp(e,t){let r=e??{},n=$p(r.metallic??0),o=$p(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function jA(e){let r=(e.baseColor??{}).color??RA;return zp(r)}function zp(e){return{r:ia(e.r),g:ia(e.g),b:ia(e.b)}}function ia(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function $p(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,""):"0"}function NA(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ee(e,t){return t?e.scene.materialAssets?.find(r=>r.id===t)??null:null}function Vt(e,t){return!!ee(e,t)}function Jp(e,t){return t?{state:"asset",materialAssetId:t.id,materialAsset:t}:e?.materialAssetId?{state:"missing-asset",materialAssetId:e.materialAssetId}:e?.override?{state:"override"}:{state:"inherit"}}function sa(e,t){let r=new Set;for(let n of nl(e,t))r.add(n.gameObjectId);return[...r]}function nl(e,t){let r=t.trim();return r?ca(e).filter(n=>n.materialAssetId===r):[]}function ca(e){let t=[],r=new Map(e.assets.map(n=>[n.id,n]));for(let n of e.scene.gameObjects){let o=UA(n),a=rs(n.overrides?.materialBinding);a&&t.push({kind:"root",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:a,bindingPath:"overrides.materialBinding.materialAssetId",label:o});let i=kr(e,n,r),s=new Map(i.filter(d=>!!d.slotId).map(d=>[d.slotId,d])),c=n.overrides?.materialSlotBindings??{};for(let[d,u]of Object.entries(c)){let l=rs(u);if(!l)continue;let m=s.get(d),f=KA(m,d);t.push({kind:"slot",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:l,bindingPath:`overrides.materialSlotBindings.${d}.materialAssetId`,label:`${o} / ${f}`,slotId:d,ownerNodePath:Ut(m)??d})}}for(let n of e.assets)if(!(n.type!=="prefab"||!n.prefab)){Bp(t,{ownerId:n.id,ownerName:n.displayName??n.id,prefabAssetId:n.id,path:`assets.${n.id}.prefab.overrides`,overrides:n.prefab.overrides});for(let o of n.prefab.nodes??[])Bp(t,{ownerId:`${n.id}:${o.id}`,ownerName:`${n.displayName??n.id} / ${o.name??o.id}`,prefabAssetId:n.id,prefabNodeId:o.id,path:`assets.${n.id}.prefab.nodes.${o.id}.overrides`,overrides:o.overrides})}return t}function Bp(e,t){let r=rs(t.overrides?.materialBinding);r&&e.push({kind:"root",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:r,bindingPath:`${t.path}.materialBinding.materialAssetId`,label:t.ownerName,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}});for(let[n,o]of Object.entries(t.overrides?.materialSlotBindings??{})){let a=rs(o);a&&e.push({kind:"slot",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:a,bindingPath:`${t.path}.materialSlotBindings.${n}.materialAssetId`,label:`${t.ownerName} / ${n}`,slotId:n,ownerNodePath:n,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}})}}function os(e){let t=[...new Set((e.scene.materialAssets??[]).map(s=>s.id?.trim()).filter(s=>!!s))],r=new Set(t),n=ca(e),o=n.filter(s=>!r.has(s.materialAssetId)),a=new Map;for(let s of o){let c=a.get(s.materialAssetId)??[];c.push(s),a.set(s.materialAssetId,c)}let i=[...a.entries()].map(([s,c])=>({kind:"missing-material-asset",materialAssetId:s,usages:c}));return{ok:i.length===0,materialAssetIds:t,references:n,missingMaterialAssetIds:i.map(s=>s.materialAssetId),missingReferences:o,issues:i}}function kr(e,t,r){let n=new Map;for(let o of is(e,t,r))n.set(o.slotId,o);return[...n.values()].sort((o,a)=>(o.label??o.slotId).localeCompare(a.label??a.slotId)||o.slotId.localeCompare(a.slotId))}function Xp(e,t){return is(e,t).length>0}function nt(e){return[...new Set(e.sourceSurfaces.map(t=>t.sourceMaterialIndex).filter(t=>Number.isInteger(t)))].sort((t,r)=>t-r)}function Ut(e){return e?.sourceSurfaces[0]?.ownerNodePath??null}function Yp(e){return e.slotId}function as(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function ol(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function Zp(e){let t=Qp(e);if(!t)return;let r={},n=VA(t.materialAssetId);return n&&(r.materialAssetId=n),t.override&&typeof t.override=="object"&&!Array.isArray(t.override)&&(r.override=t.override),Object.keys(r).length>0?r:void 0}function is(e,t,r){let n=Se(t);if(!n)return[];let a=(r?.get(n.assetId)??e.assets.find(s=>s.id===n.assetId))?.metadata?.materialSlots;if(!Array.isArray(a))return[];let i=[];for(let s of a){let c=Or(s);c&&i.push(c)}return i}function Or(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.slotId=="string"&&t.slotId.trim()?t.slotId.trim():"",n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces:null,o=FA(n);if(!r||!n||o.length===0||o.length!==n.length)return null;let a=typeof t.label=="string"&&t.label.trim()?t.label.trim():o[0].ownerNodePath,i=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",s=Array.isArray(t.materialNames)?t.materialNames.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim()):void 0,c=$A(t.sourceMaterialProfiles);return{slotId:r,label:a,sourceSurfaces:o,...i?{materialName:i}:{},...s&&s.length>0?{materialNames:s}:{},...c&&c.length>0?{sourceMaterialProfiles:c}:{}}}function FA(e){return Array.isArray(e)?e.flatMap(t=>{let r=Qp(t);if(!r)return[];let n=_p(typeof r.ownerNodePath=="string"?r.ownerNodePath:""),o=Number.isInteger(r.meshIndex)&&r.meshIndex>=0?r.meshIndex:void 0,a=Number.isInteger(r.primitiveIndex)&&r.primitiveIndex>=0?r.primitiveIndex:void 0;if(!n||o==null||a==null)return[];let i=Number.isInteger(r.nodeIndex)&&r.nodeIndex>=0?r.nodeIndex:void 0,s=Array.isArray(r.nodeIndexPath)?r.nodeIndexPath.filter(m=>Number.isInteger(m)&&m>=0):void 0,c=Number.isInteger(r.sourceMaterialIndex)&&r.sourceMaterialIndex>=0?r.sourceMaterialIndex:void 0,d=typeof r.sourceMeshName=="string"&&r.sourceMeshName.trim()?r.sourceMeshName.trim():void 0,u=typeof r.triangleCount=="number"&&Number.isFinite(r.triangleCount)&&r.triangleCount>=0?r.triangleCount:void 0,l=_A(r.boundingBox);return[{ownerNodePath:n,...i!=null?{nodeIndex:i}:{},...s&&s.length>0?{nodeIndexPath:s}:{},meshIndex:o,primitiveIndex:a,...c!=null?{sourceMaterialIndex:c}:{},...d?{sourceMeshName:d}:{},...u!=null?{triangleCount:u}:{},...l?{boundingBox:l}:{}}]}):[]}function _A(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=Vp(t.min),n=Vp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Vp(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return typeof t=="number"&&Number.isFinite(t)&&typeof r=="number"&&Number.isFinite(r)&&typeof n=="number"&&Number.isFinite(n)?[t,r,n]:null}function $A(e){if(!Array.isArray(e))return;let t=e.map(LA).filter(r=>!!r);return t.length>0?t:void 0}function LA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!Number.isInteger(t.sourceMaterialIndex))return null;let r=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",n=t.profile&&typeof t.profile=="object"&&!Array.isArray(t.profile)?t.profile:void 0,o=zA(t.textureHints);return{sourceMaterialIndex:t.sourceMaterialIndex,...r?{materialName:r}:{},...n?{profile:n}:{},...o&&o.length>0?{textureHints:o}:{}}}function zA(e){if(!Array.isArray(e))return;let t=e.map(BA).filter(r=>!!r);return t.length>0?t:void 0}function BA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.profilePath=="string"&&t.profilePath.trim()?t.profilePath.trim():"",n=typeof t.reason=="string"&&t.reason.trim()?t.reason.trim():"";return!r||!n?null:{profilePath:r,reason:n,...Number.isInteger(t.textureIndex)?{textureIndex:t.textureIndex}:{},...Number.isInteger(t.imageIndex)?{imageIndex:t.imageIndex}:{},...Number.isInteger(t.bufferView)?{bufferView:t.bufferView}:{},...typeof t.mimeType=="string"&&t.mimeType.trim()?{mimeType:t.mimeType.trim()}:{},...typeof t.uri=="string"&&t.uri.trim()?{uri:t.uri.trim()}:{}}}function Qp(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function VA(e){return typeof e=="string"&&e.trim()?e.trim():null}function UA(e){return e.name?.trim()||e.id}function rs(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function KA(e,t){return e?.label?.trim()||Ut(e)?.trim()||e?.slotId?.trim()||t}var ns=class{constructor(t){this.byMaterialId=new Map;this.byOwnerId=new Map;for(let r of ca(t)){let n=this.byMaterialId.get(r.materialAssetId)??[];n.push(r),this.byMaterialId.set(r.materialAssetId,n);let o=this.byOwnerId.get(r.gameObjectId)??[];o.push(r),this.byOwnerId.set(r.gameObjectId,o)}}forMaterial(t){return this.byMaterialId.get(t.trim())??[]}forOwner(t){return this.byOwnerId.get(t)??[]}},Up=new WeakMap;function HA(e){let t=Up.get(e);return t||(t=new ns(e),Up.set(e,t)),t}function al(e){return e?.system?.preset}function Kp(e,t){let r=al(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Hp(e,t){let r=al(e);return r==="default-pbr"?t.defaultMaterialMeta:r==="default-standard"?t.defaultStandardMaterialMeta:t.formatMaterialMeta(e.id)}function WA(e,t){let r=e.currentAsset??null,n=!!r&&!e.currentValue,o=r&&!n?Wp(e.document,r.id,e.ownershipText,t):null,a=r?Hp(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?qp(a,o):a;return{pickerKind:"material",pickerTitle:e.pickerText.materialPickerTitle,pickerTrigger:"preview",placeholder:e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.inheritNone,...r?{currentMaterialAssetId:r.id,currentMaterialShaderId:r.shaderId,...r.definitionVersion!=null?{currentMaterialDefinitionVersion:r.definitionVersion}:{}}:{},currentLabel:r?Kp(r,e.displayText):e.currentValue?e.currentValue:e.pickerText.inheritNone,currentMeta:i,...o?.usageLabel?{currentUsageLabel:o.usageLabel}:{},...o?.editImpactLabel?{currentEditImpactLabel:o.editImpactLabel}:{},...o?{currentOwnership:o}:{},currentPreview:r?Bt(r.properties,e.previewContext):void 0,candidates:[{label:e.pickerText.inheritNone,value:"",meta:e.pickerText.summaryInherit},...e.materialAssets.map(s=>{let c=Wp(e.document,s.id,e.ownershipText,t);return{label:Kp(s,e.displayText),value:s.id,meta:qp(Hp(s,e.displayText),c),kind:"material",preview:Bt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function Wp(e,t,r,n){if(!e||!n)return null;let o=t.trim(),a=n.forMaterial(o),i=a.length;return{materialAssetId:o,usage:{count:i,items:a.map(s=>structuredClone(s))},usageCount:i,used:i>0,shared:i>1,...r?{usageLabel:r.formatUsageCount(i),editImpactLabel:r.formatEditImpact(i),duplicateImpactLabel:r.formatDuplicateImpact(i)}:{}}}function qp(e,t){return[e,t?.usageLabel].filter(Boolean).join(" \xB7 ")}function qA(e,t,r={}){return(e.scene.materialAssets??[]).map(n=>{let o=t.forMaterial(n.id);return{id:`material:${n.id}`,assetId:n.id,kind:"material",label:n.name||n.id,meta:Lp(n.properties,n.id),preview:Bt(n.properties,r),material:{id:n.id,name:n.name||n.id,shaderId:n.shaderId,...n.definitionVersion!=null?{definitionVersion:n.definitionVersion}:{},readonly:n.system?.readonly===!0||al(n)!=null,usage:{count:o.length,items:o.map(a=>structuredClone(a))},properties:structuredClone(n.properties)},placeable:!1}})}var JA={createUsageIndex(e){return new ns(e)},getCachedUsageIndex:HA,createPickerControlOptions:WA,createBrowserAssetItems:qA},_e=JA;var sn=1;var sl="prefab.";function la(e){let t=structuredClone(e),r={ordinaryObjects:0,prefabRoots:0,discardedFields:0},n=$e(t.scene);return n&&(Me(n,"shadowMapExperiment",r),Array.isArray(n.gameObjects)&&n.gameObjects.forEach(o=>XA(o,r))),Array.isArray(t.assets)&&t.assets.forEach(o=>YA(o,r)),{document:t,summary:r}}function dn(e){let t=$e(e);return!t||t.prefab!=null||t.transformType==="camera"||t.transformType==="light"||t.camera!=null||t.light!=null?!1:t.kind==="primitive"||$e(t.primitive)?!0:Array.isArray(t.components)&&t.components.some(r=>{let n=$e(r)?.type;return n==="ModelRenderer"||n==="ImageRenderer"})}function XA(e,t){let r=$e(e);if(!r)return;let n=$e(r.shadow);Me(r,"shadowMode",t),Me(r,"shadowMapExperiment",t),dn(r)?(r.shadow=tg(n),t.ordinaryObjects+=1):Me(r,"shadow",t)}function YA(e,t){let r=$e(e);if(!r)return;let n=$e(r.defaults);n&&(Me(n,"shadowMode",t),Me(n,"shadow",t),Me(n,"shadowMapExperiment",t));let o=$e(r.prefab);if(!o)return;let a=$e(o.defaults);a&&Me(a,"shadowMode",t),o.defaults={...a??{},shadow:tg(a?.shadow)},t.prefabRoots+=1;let i=$e(o.defaults);if(Me(i,"shadowMapExperiment",t),Array.isArray(o.nodes))for(let s of o.nodes){let c=$e(s);if(!c)continue;Me(c,"shadowMode",t),Me(c,"shadow",t),Me(c,"shadowMapExperiment",t);let d=$e(c.defaults);d&&(Me(d,"shadowMode",t),Me(d,"shadow",t),Me(d,"shadowMapExperiment",t))}}function tg(e){let t=$e(e);return{cast:t?.cast==="enabled"?"enabled":"none",receive:t?.receive==="enabled"?"enabled":"none"}}function Me(e,t,r){Object.prototype.hasOwnProperty.call(e,t)&&(delete e[t],r.discardedFields+=1)}function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var HF=Symbol("unsupported-editor-scene-authored-clone-value");function G(e){return e.components.find(tD)??null}function Se(e){return e.components.find(rD)??null}function Rr(e){return e.components.find(nD)??null}function Xe(e){return e?.type==="prefab"&&te(e.prefab?.sourceAssetId)!=null}function Le(e,t){let r=e.assets.find(n=>n.id===t);return r&&Xe(r)?r:null}function ss(e){return te(e?.prefab?.prefabId)!=null}function da(e){return te(e?.prefab?.sourceAssetId)}function Ye(e){if(!e?.prefab)return null;let t=dl(e.prefab),r=te(e.prefab.rootNodeId);if(r&&t.some(o=>o.id===r))return r;let n=t.find(o=>o.kind==="root"&&!o.parentId);return n?n.id:null}function Ze(e){return e?.prefab?dl(e.prefab):[]}function oo(e,t){let r=te(t);return r?Ze(e).find(n=>n.id===r)??null:null}function cl(e,t){let r=te(t);return Ze(e).filter(n=>{let o=te(n.parentId);return r?o===r:!o})}function rg(e){if(!Xe(e))return il(e,!1,null,[{code:"prefab.invalidDefinition",severity:"error",message:`Asset "${e.id}" is not a valid prefab definition.`,assetId:e.id}]);let t=dl(e.prefab),r=Ye(e);if(e.prefab.compositionVersion!==sn||t.length===0||!r)return il(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${sn} with an explicit root node.`,assetId:e.id}]);let n=ZA(e);return il(n,JSON.stringify(n.prefab)!==JSON.stringify(e.prefab))}function il(e,t,r=null,n=[],o={}){return{ok:n.every(a=>a.severity!=="error"),changed:t,prefabAsset:e,...o.selectedNodeId?{selectedNodeId:o.selectedNodeId}:{},...o.createdNodeId?{createdNodeId:o.createdNodeId}:{},...o.deletedNodeIds?{deletedNodeIds:[...o.deletedNodeIds]}:{},...r?{node:structuredClone(r)}:{},diagnostics:n.map(a=>({...a}))}}function ZA(e){let t=structuredClone(e),r=Ze(e);t.prefab=structuredClone(t.prefab),t.prefab.compositionVersion=sn,t.prefab.nodes=r;let n=Ye({...e,prefab:{...e.prefab,nodes:r}});return n?t.prefab.rootNodeId=n:delete t.prefab.rootNodeId,t}function dl(e){if(!Array.isArray(e.nodes))return[];let t=[];for(let r of e.nodes){let n=QA(r);n&&!t.some(o=>o.id===n.id)&&t.push(n)}return structuredClone(t)}function QA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=te(t.id);return!r||!eD(t.kind)?null:{id:r,...te(t.guid)?{guid:te(t.guid)}:{},...te(t.name)?{name:te(t.name)}:{},...te(t.parentId)?{parentId:te(t.parentId)}:{},kind:t.kind,...t.transform?{transform:structuredClone(t.transform)}:{},...te(t.sourceAssetId)?{sourceAssetId:te(t.sourceAssetId)}:{},...te(t.sourceNodePath)?{sourceNodePath:te(t.sourceNodePath)}:{},...te(t.childPrefabId)?{childPrefabId:te(t.childPrefabId)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.light?{light:structuredClone(t.light)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults?{defaults:structuredClone(t.defaults)}:{},...t.overrides?{overrides:structuredClone(t.overrides)}:{},...t.metadata?{metadata:structuredClone(t.metadata)}:{}}}function eD(e){return e==="root"||e==="group"||e==="model"||e==="primitive"||e==="light"||e==="prefabInstance"||e==="marker"||e==="collision"}function ng(e){let t=da(e.prefabAsset);if(!t)throw new Error(`Prefab asset "${e.prefabAsset.id}" does not define a source asset.`);let r=e.prefabAsset.prefab?.defaults;return{id:e.id,...e.guid?{guid:e.guid}:{},name:e.name??e.prefabAsset.displayName??e.prefabAsset.id,kind:"instance",...e.parentId?{parentId:e.parentId}:{},active:e.active??r?.active??!0,prefab:{prefabId:e.prefabAsset.id,...e.prefabAsset.guid?{prefabGuid:e.prefabAsset.guid}:{},sourceAssetId:t},...e.metadata?{metadata:{...e.metadata}}:{},...e.overrides!==void 0?{overrides:e.overrides}:{},components:[e.transform,{type:"ModelRenderer",assetId:t}]}}function og(e){if(!e.startsWith(sl))return null;let t=e.slice(sl.length);return es(t)?t:null}function ll(e){return og(e)?.endsWith(".materialAssetId")===!0}function ag(e){return e.startsWith(sl)&&e.endsWith(".materialAssetId")&&ll(e)}function ig(e,t){if(t.slotId)return Zp(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function ua(e,t,r){let n=og(t);if(!n||!Xe(e))return e;let o=aD(n);if(!o)return e;let a=structuredClone(e);a.prefab=structuredClone(a.prefab??e.prefab),sD(a.prefab,o,r);let i=ug(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function sg(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=Ad(e?.override,t?.override);return ml({...n??r?{materialAssetId:n??r}:{},...cn(o)?{override:o}:{}})}function cs(e,t){let r={},n=sg(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=dD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ds(e,t){let r=ln(e,t);if(!(!r.gameObject||!r.prefab))return cs(r.definition?.prefab?.overrides,lD(r.gameObject.overrides))}function ln(e,t){let r=typeof t=="string"?oD(e,t):t,n=typeof t=="string"?t:t.id,o=[],a=ss(r)?r.prefab:null;if(!r||!a)return o.push({code:"not-prefab-instance",severity:"info",message:r?`GameObject "${r.id}" is not a prefab instance.`:`GameObject "${n}" was not found.`}),{gameObject:r,prefab:null,definition:null,sourceAsset:null,diagnostics:o};let i=e.assets.find(d=>d.id===a.prefabId&&Xe(d));i||o.push({code:"missing-prefab-definition",severity:"error",message:`Prefab definition "${a.prefabId}" was not found.`,prefabId:a.prefabId});let s=da(i)??te(a.sourceAssetId);i&&a.sourceAssetId&&s&&a.sourceAssetId!==s&&o.push({code:"source-asset-mismatch",severity:"warning",message:`Prefab instance source "${a.sourceAssetId}" does not match definition source "${s}".`,prefabId:a.prefabId,expectedSourceAssetId:s,actualSourceAssetId:a.sourceAssetId});let c=s?e.assets.find(d=>d.id===s):void 0;if(s&&!c&&o.push({code:"missing-source-asset",severity:"error",message:`Prefab source asset "${s}" was not found.`,prefabId:a.prefabId,sourceAssetId:s}),s){let d=e.assets.filter(u=>Xe(u)&&da(u)===s).map(u=>u.id);d.length>1&&o.push({code:"duplicate-source-prefab",severity:"info",message:`Source asset "${s}" is referenced by ${d.length} prefab definitions.`,prefabId:a.prefabId,sourceAssetId:s})}return{gameObject:r,prefab:a,definition:i??null,sourceAsset:c??null,diagnostics:o}}function Y(e){return e.kind==="group"||e.kind==="instance"||e.kind==="transform"||e.kind==="primitive"?e.kind:ss(e)?"instance":e.primitive?"primitive":Se(e)?"instance":Rr(e)||e.transformType?"transform":"group"}function cg(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=ul(t?.renderingGroupId),n=lg(t?.alphaIndex),o={};return r!=null&&(o.renderingGroupId=r),n!=null&&(o.alphaIndex=n),Object.keys(o).length>0?o:void 0}function ul(e){return e===0||e===1||e===2||e===3?e:null}function dg(e){return lg(e)}function tD(e){return e.type==="Transform"}function rD(e){return e.type==="ModelRenderer"}function nD(e){return e.type==="ImageRenderer"}function lg(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function te(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function oD(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function aD(e){if(e==="overrides.materialBinding.materialAssetId")return["overrides","materialBinding","materialAssetId"];let t="overrides.materialBinding.override.";if(e.startsWith(t)){let o=e.slice(t.length);return eg(["overrides","materialBinding","override"],o)}let r=Lt(e,"materialAssetId");if(r)return["overrides","materialSlotBindings",r,"materialAssetId"];let n=Lt(e,"override");if(n){let o=iD(e);return o?eg(["overrides","materialSlotBindings",n,"override"],o):null}return null}function iD(e){let t=".override.",r=e.lastIndexOf(t);if(r<0)return null;let n=e.slice(r+t.length);return n||null}function eg(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(mg)?null:[...e,...r]}function sD(e,t,r){if(t.some(mg))return;let n=e;for(let a of t.slice(0,-1)){let i=n[a];(!i||typeof i!="object"||Array.isArray(i))&&(n[a]={}),n=n[a]}let o=t[t.length-1];o&&(r==null?delete n[o]:n[o]=structuredClone(r))}function ug(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r={},n=ml(t.materialBinding);n&&(r.materialBinding=n);let o=cD(t.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ml(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=te(t.materialAssetId),n=Ad(t.override),o={...r?{materialAssetId:r}:{},...cn(n)?{override:n}:{}};return cn(o)?o:void 0}function cD(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[r,n]of Object.entries(e)){let o=te(r);if(!o)continue;let a=ml(n);a&&(t[o]=a)}return cn(t)?t:void 0}function dD(e,t){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),n={};for(let o of r){let a=sg(e?.[o],t?.[o]);a&&(n[o]=a)}return cn(n)?n:void 0}function lD(e){return ug(e)}function cn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function mg(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var uD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function fg(e,t,r){if(e.kind!=="marker"){Object.prototype.hasOwnProperty.call(e,"marker")&&N("schema.invalidValue",`${r}.marker`);return}for(let s of Object.keys(e))uD.has(s)||N("schema.invalidValue",`${r}.${s}`);ma(e.parentId)||N("schema.invalidReference",`${r}.parentId`),gD(e.transform,`${r}.transform`),mD(e.marker,`${r}.marker`);let n=ma(e.id),o=e.marker,a=fD(o,`${r}.marker`),i=a[0]??null;for(let s of a){s.target.id===n&&N("schema.invalidReference",`${s.path}.id`),i&&(s.target.kind!==i.target.kind||s.target.id!==i.target.id)&&N("schema.invalidReference",s.path);let c=t.get(s.target.id);c&&(s.target.kind==="marker"&&c.kind!=="marker"&&N("schema.invalidReference",`${s.path}.kind`),s.target.kind==="scene-object"&&c.kind==="marker"&&N("schema.invalidReference",`${s.path}.kind`))}}function mD(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["schemaVersion","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t),r.schemaVersion!==1&&N("schema.unsupportedVersion",`${t}.schemaVersion`),ma(r.type)||N("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!ma(r.kind)&&N("schema.invalidValue",`${t}.kind`),r.tags!==void 0&&yD(r.tags,`${t}.tags`),r.note!==void 0&&typeof r.note!="string"&&N("schema.invalidType",`${t}.note`),r.color!==void 0&&SD(r.color,`${t}.color`),r.target!==void 0&&fl(r.target,`${t}.target`),r.semanticFrame!==void 0&&bD(r.semanticFrame,`${t}.semanticFrame`),pD(r.geometry,`${t}.geometry`),r.metadata!==void 0&&hD(r.metadata,`${t}.metadata`)}function fD(e,t){let r=[];return e.target&&r.push({target:e.target,path:`${t}.target`}),e.geometry.kind==="point"&&e.geometry.target&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),e.geometry.kind==="object-bounds"&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),r}function pD(e,t){let r=vr(e);if(r||N("schema.invalidType",t),r.kind==="box"){Pt(r,["kind"],t);return}if(r.kind==="point"){Pt(r,["kind","coordinateSpace","position","offset","target"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&r.coordinateSpace!=="local"&&N("schema.invalidValue",`${t}.coordinateSpace`),r.position!==void 0&&Cr(r.position,`${t}.position`),r.offset!==void 0&&Cr(r.offset,`${t}.offset`),r.target!==void 0&&fl(r.target,`${t}.target`);return}if(r.kind==="object-bounds"){Pt(r,["kind","target"],t),fl(r.target,`${t}.target`);return}if(r.kind==="polyhedron"){Pt(r,["kind","coordinateSpace","vertices","faces"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&N("schema.invalidValue",`${t}.coordinateSpace`),Array.isArray(r.vertices)||N("schema.invalidType",`${t}.vertices`),r.vertices.forEach((n,o)=>Cr(n,`${t}.vertices[${o}]`)),r.faces!==void 0&&(Array.isArray(r.faces)||N("schema.invalidType",`${t}.faces`),r.faces.forEach((n,o)=>{Array.isArray(n)||N("schema.invalidType",`${t}.faces[${o}]`),n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&N("schema.invalidValue",`${t}.faces[${o}][${i}]`)})}));return}N("schema.invalidValue",`${t}.kind`)}function fl(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&N("schema.invalidValue",`${t}.kind`),ma(r.id)||N("schema.invalidValue",`${t}.id`),r.label!==void 0&&typeof r.label!="string"&&N("schema.invalidType",`${t}.label`)}function gD(e,t){let r=vr(e);if(r||N("schema.invalidType",t),r.type!=="Transform"&&N("schema.invalidValue",`${t}.type`),r.mode==="matrix"){Pt(r,["type","mode","matrix"],t),(!Array.isArray(r.matrix)||r.matrix.length!==16)&&N("schema.invalidType",`${t}.matrix`),r.matrix.forEach((n,o)=>ls(n,`${t}.matrix[${o}]`));return}Pt(r,["type","mode","position","rotation","scale"],t),r.mode!==void 0&&r.mode!=="trs"&&N("schema.invalidValue",`${t}.mode`),Cr(r.position,`${t}.position`),Cr(r.rotation,`${t}.rotation`),r.scale!==void 0&&Cr(r.scale,`${t}.scale`)}function bD(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["origin","forward","right","up","label","description"],t),Cr(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Cr(r[n],`${t}.${n}`);for(let n of["label","description"])r[n]!==void 0&&typeof r[n]!="string"&&N("schema.invalidType",`${t}.${n}`)}function SD(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["r","g","b"],t);for(let n of["r","g","b"])ls(r[n],`${t}.${n}`),(r[n]<0||r[n]>1)&&N("schema.invalidValue",`${t}.${n}`)}function Cr(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["x","y","z"],t);for(let n of["x","y","z"])ls(r[n],`${t}.${n}`)}function yD(e,t){Array.isArray(e)||N("schema.invalidType",t),e.forEach((r,n)=>{typeof r!="string"&&N("schema.invalidType",`${t}[${n}]`)})}function hD(e,t){let r=vr(e);r||N("schema.invalidType",t),pl(r,t,new Set)}function pl(e,t,r){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"){ls(e,t);return}(!e||typeof e!="object")&&N("schema.invalidType",t),r.has(e)&&N("schema.invalidValue",t);let n=Object.getPrototypeOf(e);Array.isArray(e)?n!==Array.prototype&&N("schema.invalidType",t):n!==Object.prototype&&n!==null&&N("schema.invalidType",t),r.add(e);try{if(Array.isArray(e))e.forEach((o,a)=>pl(o,`${t}[${a}]`,r));else for(let[o,a]of Object.entries(e))pl(a,`${t}.${o}`,r)}finally{r.delete(e)}}function Pt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||N("schema.invalidValue",`${r}.${o}`)}function ls(e,t){(typeof e!="number"||!Number.isFinite(e))&&N("schema.invalidValue",t)}function vr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ma(e){return typeof e=="string"&&e.trim()?e.trim():null}function N(e,t){throw new Error(`${e}: ${t}`)}function ao(e,t){return t===e.rootNodeId?e.instanceId:`${e.instanceId}:${ED(t)}`}function ED(e){return encodeURIComponent(e)}function gl(e,t){return{...structuredClone(e),id:ao(t,e.id)}}function fa(e,t){let r=structuredClone(e);return r.target&&(r.target=gl(r.target,t)),r.geometry.kind==="point"&&r.geometry.target&&(r.geometry.target=gl(r.geometry.target,t)),r.geometry.kind==="object-bounds"&&(r.geometry.target=gl(r.geometry.target,t)),r}function B(e,t){if(pg(e))try{return e[t]}catch{return}}function ce(e,t){let r=B(e,t);return typeof r=="string"&&r.trim()?r:null}function re(e,t){let r=B(e,t);return typeof r=="number"&&Number.isFinite(r)?r:null}function Te(e,t){let r=B(e,t);return typeof r=="boolean"?r:null}function we(e,t,r=[]){let n=B(e,t);if(typeof n=="function")try{return n.apply(e,r)}catch{return}}function Kt(e){if(!pg(e))return null;let t=we(e,"getClassName");if(typeof t=="string"&&t.trim())return t;let r=B(e,"constructor"),n=r&&typeof r=="function"?r.name:"";return n&&n!=="Object"?n:null}function un(e){let t=Kt(e),r=ce(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function pg(e){return!!e&&(typeof e=="object"||typeof e=="function")}function us(e,t=new WeakSet,r=0){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?ID(e):"[NonFiniteNumber]";if(typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e!="object")return String(e);if(t.has(e))return"[Circular]";if(r>6)return"[MaxDepth]";if(t.add(e),Array.isArray(e))return e.map(a=>us(a,t,r+1));let n=e,o={};for(let a of Object.keys(n).sort())o[a]=us(B(n,a),t,r+1);return o}function ID(e){return Math.round(e*1e6)/1e6}function Gr(e){let t=e.properties.filter(r=>!!r).map((r,n)=>r.order==null?{...r,order:n}:r);return t.length===0&&e.omitWhenEmpty!==!1?null:{id:e.id,title:e.title,order:e.order,placement:"body",summary:e.summary,persistence:e.persistence??(e.runtimeOnly?"runtime":"readonly"),runtimeOnly:e.runtimeOnly,effect:e.effect??(e.runtimeOnly?"runtime":void 0),disabledReason:e.disabledReason,collapsedByDefault:e.collapsedByDefault,tags:e.tags,properties:t}}function j(e){if(!PD(e.value))return null;let t=us(e.value);return{path:e.path,label:e.label,valueType:e.valueType??TD(t),control:"readonly",value:t,readOnly:!0,persistence:e.persistence??"readonly",commitMode:"blur",order:e.order,tags:AD(e.source,e.tags),tooltip:e.tooltip,effect:e.effect??xD(e.source,e.persistence),disabledReason:e.disabledReason}}function bl(e,t){let r=j(t);r&&e.push(r)}function io(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.buttonLabel??e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Sl(e){let t=mn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>j({path:`${e.basePath}.${n}`,label:`${e.label}.${n}`,value:t[n],order:r+o,persistence:e.persistence,source:e.source,tags:e.tags,effect:e.effect,disabledReason:e.disabledReason,valueType:"number"})).filter(n=>!!n)}function mn(e){if(!e||typeof e!="object")return null;let t=re(e,"x"),r=re(e,"y"),n=re(e,"z");return t==null||r==null||n==null?null:{x:t,y:r,z:n}}function PD(e){return e!=null&&!(typeof e=="number"&&!Number.isFinite(e))}function TD(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function xD(e,t){if(t==="runtime"||e==="Runtime")return"runtime";if(e==="Derived")return"derived"}function AD(e,t){let r=[...e?[e]:[],...t??[]];return r.length>0?[...new Set(r)]:void 0}function pa(e){let t=e.projectedRoot??e.root??null,r=bg(t),n=r.find(o=>!!B(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:Sg(t),meshes:r,primaryMesh:n,material:DD(t)}}function ms(e){let t=we(e,"getHierarchyBoundingVectors"),r=mn(B(t,"min")),n=mn(B(t,"max"));if(r&&n)return gg(r,n);let o=we(e,"getBoundingInfo"),a=B(o,"boundingBox"),i=mn(B(a,"minimumWorld")),s=mn(B(a,"maximumWorld"));return i&&s?gg(i,s):null}function bg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return yg(e)&&r.unshift(e),[...new Set(r)]}function Sg(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function yg(e){return!!e&&(!!B(e,"material")||typeof B(e,"getTotalVertices")=="function"||typeof B(e,"getBoundingInfo")=="function")}function fs(e,t){let r=0,n=0;for(let o of e){let a=we(o,t);typeof a!="number"||!Number.isFinite(a)||(r+=a,n+=1)}return n>0?r:"not available"}function so(e,t){let r=B(e,t);return Array.isArray(r)?r.length:0}function ps(e,t){let r=we(e,t);return Array.isArray(r)?r.length:"not available"}function yl(e){let t=we(e,"isEnabled");return typeof t=="boolean"?t:null}function ga(e,t){let r=re(e,t);if(r!=null)return r;let n=we(e,"getParam",[t]);return typeof n=="number"&&Number.isFinite(n)?n:null}function gg(e,t){return{min:e,max:t,center:{x:(e.x+t.x)/2,y:(e.y+t.y)/2,z:(e.z+t.z)/2},size:{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}}function DD(e){let t=B(e,"material");if(t)return t;let r=we(e,"getChildMeshes",[!1]);if(Array.isArray(r)){let n=r.find(o=>!!B(o,"material"));if(n)return B(n,"material")}return null}var bs={x:-.3,y:-1,z:-.2},hg=-180,Eg=180,ba=-90,Sa=90;function ya(e,t=bs){let r=e&&kD(e)?e:t,n=Math.hypot(r.x,r.y,r.z);if(!Number.isFinite(n)||n<=1e-6){let o=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/o,y:t.y/o,z:t.z/o}}return{x:r.x/n,y:r.y/n,z:r.z/n}}function El(e,t){let r=jr(ys(e)),n=jr(Dg(t,ba,Sa)),o=Math.cos(n);return{x:hl(o*Math.cos(r)),y:hl(-Math.sin(n)),z:hl(o*Math.sin(r))}}function Il(e){if(!hs(e.light))return null;let t=G(e),r=t&&"rotation"in t?t.rotation:void 0,n=xg({direction:e.light.direction,rotation:r}),o=El(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:jr(n.elevationAngleDeg),y:jr(n.horizontalAngleDeg),z:co(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function Ig(e,t){if(!hs(e.light))return e;let r=Il(e);if(!r)return e;let n=co(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=co(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=El(n,o),i={...r.rotation,x:jr(o),y:jr(n)};return{...e,light:{...e.light,direction:a},components:e.components.map(s=>s===G(e)&&"rotation"in s?{...s,rotation:i}:s)}}function MD(e,t=bs){let{horizontalAngleDeg:r,elevationAngleDeg:n}=xg({direction:t,rotation:e});return El(r,n)}function wD(e,t){let r=Tg(e);return{x:jr(r.elevationAngleDeg),y:jr(r.horizontalAngleDeg),z:co(t?.z)?t.z:0}}function lo(e){if(!hs(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=MD(t.rotation,e.light.direction);return Ag(r,ya(e.light.direction))?e:{...e,light:{...e.light,direction:r}}}function Ss(e){if(!hs(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=wD(e.light.direction,t.rotation);return Ag(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function Pg(e){let t=ya(e),r=Math.abs(t.y);return r<=1e-6?999:Math.min(999,Math.hypot(t.x,t.z)/r)}function ys(e){let t=((e+180)%360+360)%360-180;return t===-180?180:t}function kD(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.z=="number"&&Number.isFinite(e.z)}function hs(e){return e?.type==="directional"}function Tg(e){let t=ya(e);return{horizontalAngleDeg:ys(gs(Math.atan2(t.z,t.x))),elevationAngleDeg:gs(Math.asin(Dg(-t.y,-1,1)))}}function xg(e){let t=Tg(e.direction);return{horizontalAngleDeg:co(e.rotation?.y)?gs(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:co(e.rotation?.x)?gs(e.rotation.x):t.elevationAngleDeg}}function co(e){return typeof e=="number"&&Number.isFinite(e)}function Ag(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function gs(e){return e*180/Math.PI}function jr(e){return e*Math.PI/180}function hl(e){return Math.round(e*1e6)/1e6}function Dg(e,t,r){return Math.min(r,Math.max(t,e))}var fn="light.directionHorizontalAngleDeg",pn="light.directionElevationAngleDeg";function uo(e){return e===fn||e===pn}function Mg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=OD(t);return r==null?t:e===fn?Math.round(ys(r)):e===pn?Math.round(RD(r,ba,Sa)):t}function OD(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function RD(e,t,r){return Math.min(r,Math.max(t,e))}function gn(e){return t=>mo({...e,value:t})}function mo(e){let t=CD(e);if(t)return t;let r=Zd(e.path,e.nodeKind);return r?e.value==null&&r.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${e.path}.`}:r.validate(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`}:{ok:!1,message:`Unsupported scene node field: ${e.path}.`}}function bn(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?wg(t):t}function Es(e,t,r={}){if((r.isDirectionalLightAnglePath??kg)(e))return Mg(e,t);if(e==="marker.type"&&typeof t=="string"||e==="marker.target.objectId"&&typeof t=="string")return t.trim();if(e==="marker.tags")return GD(t);if(e==="marker.note"&&typeof t=="string"){let n=t.trim();return n||null}return tl(e)&&typeof t=="string"?wg(t):bn(e,t)}function Pl(e){return t=>vD(t,e)}function CD(e){for(let t of e.extraValidators??[]){let r=t({path:e.path,nodeKind:e.nodeKind,value:e.value,document:e.document});if(r)return r}return null}function vD(e,t){if(e.path==="camera.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: camera.inspectorLanguage."};if(e.path==="light.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: light.inspectorLanguage."};if((t.isDirectionalLightAnglePath??kg)(e.path))return typeof e.value=="number"&&Number.isFinite(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="metadata.artistMaterialInspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="instance.assetId"&&e.document&&typeof e.value=="string"&&!(e.document.assets??[]).some(r=>r.id===e.value))return{ok:!1,message:`Asset not found: ${e.value}.`};if(wr(e.path)&&e.document&&typeof e.value=="string"&&e.value&&!t.hasMaterialAsset(e.document,e.value))return{ok:!1,message:`Material asset not found: ${e.value}.`};if(wr(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(tl(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="marker.target.objectId"){if(typeof e.value!="string")return{ok:!1,message:"Marker target must be a scene object id."};let r=e.value.trim();if(!r)return{ok:!0,value:""};let n=e.document?.scene?.gameObjects?.find(o=>o.id===r)??null;return n&&!t.isMarkerGameObject(n)?{ok:!0,value:r}:{ok:!1,message:`Marker target object not found: ${r}.`}}return null}function wg(e){let t=e.trim();return t||null}function GD(e){let r=(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>typeof n=="string"?n.trim():"").filter((n,o,a)=>n.length>0&&a.indexOf(n)===o);return r.length>0?r:null}function kg(e){return e===fn||e===pn}function ha(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:gn({path:e.property.path,nodeKind:e.nodeKind,document:e.document,extraValidators:e.extraValidators})}}function ot(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Tt(e){return e*180/Math.PI}function Ht(e){return e*Math.PI/180}function at(e){return Math.round(e*1e6)/1e6}var Og={zh:{title:"\u6444\u50CF\u673A",summaryOrthographic:"ArcRotate \u6B63\u4EA4",summaryPerspective:"ArcRotate \u900F\u89C6",language:"\u8BED\u8A00",projection:"\u6295\u5F71\u6A21\u5F0F",projectionOrthographic:"\u6B63\u4EA4",projectionPerspective:"\u900F\u89C6",alpha:"Alpha",beta:"Beta",radius:"\u534A\u5F84",orthoSize:"\u6B63\u4EA4\u5C3A\u5BF8",fov:"\u89C6\u91CE\u89D2\u5EA6",targetOffset:"\u76EE\u6807\u504F\u79FB",nearClip:"\u8FD1\u88C1\u526A",farClip:"\u8FDC\u88C1\u526A",minBeta:"\u6700\u5C0F Beta",maxBeta:"\u6700\u5927 Beta",minRadius:"\u6700\u5C0F\u534A\u5F84",maxRadius:"\u6700\u5927\u534A\u5F84",inertia:"\u60EF\u6027",screenOffset:"\u5C4F\u5E55\u504F\u79FB",rawCamera:"\u539F\u59CB\u6444\u50CF\u673A"},en:{title:"Camera",summaryOrthographic:"ArcRotate Orthographic",summaryPerspective:"ArcRotate Perspective",language:"Language",projection:"Projection",projectionOrthographic:"Orthographic",projectionPerspective:"Perspective",alpha:"Alpha",beta:"Beta",radius:"Radius",orthoSize:"Ortho Size",fov:"FOV",targetOffset:"Target Offset",nearClip:"Near Clip",farClip:"Far Clip",minBeta:"Min Beta",maxBeta:"Max Beta",minRadius:"Min Radius",maxRadius:"Max Radius",inertia:"Inertia",screenOffset:"Screen Offset",rawCamera:"Raw Camera"}},Rg=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function Tl(e){return Og[e]??Og.zh}function jD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function Cg(e){let{camera:t,createDocumentInspectorProperty:r,nodeKind:n,rig:o}=e,a=o.inspectorLanguage??"zh",i=Tl(a),s=[],c=0;s.push(r(null,n,{path:"camera.inspectorLanguage",label:i.language,valueType:"enum",control:"enum",value:a,commitMode:"immediate",order:c,options:Rg,controlOptions:{variant:"segmented"}})),c+=1,s.push(r(null,n,{path:"camera.projection",label:i.projection,valueType:"enum",control:"enum",value:o.projection??"orthographic",commitMode:"immediate",order:c,options:jD(i),controlOptions:{variant:"segmented"}})),c+=1,s.push(ze(n,r,{path:"camera.alpha",label:i.alpha,value:o.alpha,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.beta",label:i.beta,value:o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.radius",label:i.radius,value:o.radius,order:c,min:.001,step:.1})),c+=1,(o.projection??"orthographic")==="perspective"?s.push(ze(n,r,{path:"camera.fov",label:i.fov,value:at(Tt(o.fov??.85)),order:c,min:1,max:179,step:1,coerce:d=>typeof d=="number"&&Number.isFinite(d)?Ht(d):d})):s.push(ze(n,r,{path:"camera.orthoSize",label:i.orthoSize,value:o.orthoSize??6,order:c,min:.001,step:.1})),c+=1;for(let d of["x","y","z"])s.push(ze(n,r,{path:`camera.targetOffset.${d}`,label:`${i.targetOffset} ${d.toUpperCase()}`,value:o.targetOffset?.[d]??0,order:c,step:.05})),c+=1;s.push(ze(n,r,{path:"camera.minZ",label:i.nearClip,value:o.minZ??1,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.maxZ",label:i.farClip,value:o.maxZ??1e4,order:c,min:.001,step:1})),c+=1,s.push(ze(n,r,{path:"camera.lowerBetaLimit",label:i.minBeta,value:o.lowerBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.upperBetaLimit",label:i.maxBeta,value:o.upperBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.lowerRadiusLimit",label:i.minRadius,value:o.lowerRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.upperRadiusLimit",label:i.maxRadius,value:o.upperRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.inertia",label:i.inertia,value:o.inertia??.9,order:c,min:0,max:1,step:.05})),c+=1;for(let d of["x","y"])s.push(ze(n,r,{path:`camera.targetScreenOffset.${d}`,label:`${i.screenOffset} ${d.toUpperCase()}`,value:o.targetScreenOffset?.[d]??0,order:c,step:.01})),c+=1;return bl(s,{path:"camera.raw",label:i.rawCamera,value:t??"defaults",order:s.length,source:"Document",tags:["Raw"]}),s}function xl(e){let t=Tl(e.rig.inspectorLanguage??"zh");return{id:"camera",title:t.title,order:42,placement:"body",summary:e.rig.projection==="perspective"?t.summaryPerspective:t.summaryOrthographic,persistence:"document",collapsedByDefault:!1,properties:Cg(e)}}function ze(e,t,r){return t(null,e,{path:r.path,label:r.label,valueType:"number",control:"number",value:r.value,commitMode:"live",order:r.order,min:r.min,max:r.max,step:r.step??.05,coerce:r.coerce})}var Is="scene.main",Ps="scene";function Wt(e){let t=e.meta?.authoringSource;return{sourceId:t?.sourceId||Is,sourceType:t?.sourceType||Ps,revision:typeof t?.revision=="number"?t.revision:1}}function vg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Is,sourceType:Ps,revision:t.revision??1}}}}function Gg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Is,sourceType:Ps,revision:(t.revision??0)+1}}}}function jg(e,t){let r=Wt(e),n=ND(t),o=r.revision??null;if(!n)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:null,reason:"missing-generated-from"};let a=typeof n.revision=="number"?n.revision:null;return n.sourceId!==r.sourceId||n.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"source-mismatch"}:o!==a?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a}}function ND(e){if(!e||typeof e!="object")return null;let t=e.meta;if(!t||typeof t!="object")return null;let r=t.generatedFrom;if(!r||typeof r!="object")return null;let n=r.sourceId,o=r.sourceType;return typeof n!="string"||typeof o!="string"?null:{sourceId:n,sourceType:o,revision:typeof r.revision=="number"?r.revision:void 0}}var FD="sun_light";function Ts(e){let t=_D(e);return t.shadows.planar.enabled?"planar":t.shadows.blob.enabled?"blob":t.shadows.staticProjected.enabled?"static":t.shadows.enabled?"dynamic":"none"}function _D(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function $D(e,t){let r=typeof t.prefab?.prefabId=="string"?t.prefab.prefabId:null,n=r?e.assets.find(a=>a.id===r)?.prefab?.defaults?.shadow:void 0,o=He(n??t.shadow);return{settings:o.shadow,diagnostics:o.diagnostics}}function LD(e){let t=new Map,r=e.casterId;for(let n of e.explicitReceiverIds??[]){let o=As(e.document,n);!o||o.id===r||o.active===!1||t.set(o.id,{receiverId:o.id,source:"explicit",score:120,...Al(o,"explicit",120,["explicit receiver id"])})}for(let n of e.document.scene.gameObjects){if(n.id===r||n.active===!1)continue;He(n.shadow).shadow?.receive==="enabled"&&VD(t,{receiverId:n.id,source:"explicit",score:100,...Al(n,"explicit",100,["shadow.receive enabled"])})}return[...t.values()].sort((n,o)=>o.score-n.score||n.receiverId.localeCompare(o.receiverId))}function xs(e){let t=e.caster?.id===e.casterId?e.caster:As(e.document,e.casterId),r=[];if(!t)return{casterId:e.casterId,receiverIds:[],backend:"none",mode:"none",quality:e.fallbackQuality??"medium",params:Ei(e.fallbackQuality??"medium"),diagnostics:[{code:"shadow.invalidTarget",severity:"error",message:`Shadow caster "${e.casterId}" was not found.`,casterId:e.casterId}]};let n=e.resolvedSettings!==void 0?(()=>{let f=He(e.resolvedSettings);return{settings:f.shadow,diagnostics:f.diagnostics}})():$D(e.document,t);r.push(...n.diagnostics);let a=n.settings?.cast==="enabled"?dd(n.settings,e.fallbackMode??"none"):"none",i=ld(n.settings,e.fallbackQuality??"medium"),s=Ei(i,n.settings?.params),c=zD(a),d=UD(e.explicitReceiverIds),u=c==="none"?{candidates:[],diagnostics:[]}:d.length>0&&e.strictExplicitReceivers===!0?KD(e.document,t.id,d):{candidates:LD({document:e.document,casterId:t.id,explicitReceiverIds:d.length>0?d:void 0}),diagnostics:[]};r.push(...u.diagnostics);let l=u.candidates;c!=="none"&&l.length===0&&r.push({code:"shadow.receiverNotFound",severity:"warning",message:`No shadow receiver was found for caster "${t.id}".`,casterId:t.id});let m=c==="none"?null:BD(e.document,n.settings??void 0,e.defaultLightId);return m?.diagnostic&&r.push(m.diagnostic),{casterId:t.id,receiverIds:l.map(f=>f.receiverId),...m?.lightId?{lightId:m.lightId}:{},backend:c,mode:a,quality:i,params:s,diagnostics:r}}function zD(e){return e==="dynamic"?"dynamic-map":e==="static"?"static-baked":e==="blob"?"blob":e==="projected"?"projected":"none"}function BD(e,t,r){if(t?.light?.mode==="explicit"){let a=t?.light?.lightId;return a&&Ng(e,a)?{lightId:a}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:a?`Explicit shadow light "${a}" was not found.`:"Shadow light mode is explicit, but no lightId was configured.",...a?{lightId:a}:{}}}}let n=r??FD;if(Ng(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Fg(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function Ng(e,t){let r=As(e,t);return!!r&&r.active!==!1&&Fg(r)}function Fg(e){return Y(e)==="transform"&&e.light?.type==="directional"}function VD(e,t){let r=e.get(t.receiverId);(!r||t.score>r.score)&&e.set(t.receiverId,t)}function UD(e){let t=new Set,r=[];for(let n of e??[]){let o=typeof n=="string"?n.trim():"";!o||t.has(o)||(t.add(o),r.push(o))}return r}function KD(e,t,r){let n=[],o=[];for(let a of r){let i=As(e,a);if(!i){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" was not found.`,casterId:t,receiverId:a,details:{source:"explicit"}});continue}if(i.id===t){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Shadow caster "${t}" cannot be used as its own receiver.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"self"}});continue}if(i.active===!1){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" is inactive.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"inactive"}});continue}n.push({receiverId:i.id,source:"explicit",score:120,...Al(i,"explicit",120,["explicit receiver id"])})}return{candidates:n,diagnostics:o}}function Al(e,t,r,n){let o=He(e.shadow).shadow;return{active:e.active!==!1,visible:e.active!==!1,...o?.receive?{receive:o.receive}:{},suitability:{score:r,material:Y(e)==="primitive"?"primitive":t,reasons:n}}}function As(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}var HD="main_camera",WD="environment_light",qD="sun_light";function Dl(e){return Y(e)==="group"}function xt(e){return!!G(e)}function At(e){return Y(e)==="transform"&&(e.transformType==="camera"||!!e.camera)}function fo(e){return Y(e)==="transform"&&(e.transformType==="light"||!!e.light)}function Dt(e){return e.id===HD||e.id===WD||e.id===qD||At(e)||fo(e)}function Ml(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Dt(r)}var Nr="root",JD="go_",wl="GameObject";function ue(e){return e===Nr}function Z(e){return ue(e.id)}function Ol(e){let t=new Set,r=!1,n=e.scene.gameObjects.map(o=>{let a=YD(o,t);return r=r||a!==o,a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function he(){let e=globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${JD}${e}`}function it(e,t){let r=new Set(e),n=Ds(t)||"game_object";if(!r.has(n))return n;let o=2;for(;r.has(`${n}_${o}`);)o+=1;return`${n}_${o}`}function _g(e,t=wl){return kl(e)??kl(t)??wl}function st(e,t,r={}){let n=_g(t,r.fallbackName??wl),o=new Set(e.map(s=>kl(s)).filter(s=>!!s));if(!r.alwaysAppendSuffix&&!o.has(n))return n;let a=1,i=`${n}_${a}`;for(;o.has(i);)a+=1,i=`${n}_${a}`;return i}function kl(e){let t=String(e??"").trim();return t&&t.replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||null}function Ds(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"asset"}function XD(e){return typeof e.guid=="string"&&e.guid.trim()?e.guid.trim():null}function YD(e,t){let r=XD(e);if(r&&!t.has(r))return t.add(r),r===e.guid?e:{...e,guid:r};let n=he();for(;t.has(n);)n=he();return t.add(n),{...e,guid:n}}var Fr=Et();function ke(e,t){if(ue(t))return Et();let r=_(e,t);if(!r)return null;let n=[],o=Rl(e),a=new Set,i=r;for(;i&&!a.has(i.id);)a.add(i.id),n.unshift(i),i=i.parentId?o.get(i.parentId):void 0;return Op(n.map(qt))}function _(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function Rl(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function ur(e,t,r,n){let o=t?ke(e,t):Et();return o?ro(o,r,n):null}function Ea(e,t,r,n={}){let o=Ki(n);return ur(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function qt(e){return Z(e)?Et():go(e)}function Ia(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=go(r),o=!!G(r)&&!QD(n,Fr),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=$g(s,t);return a=a||l!==s,l}if(!o||s.parentId!==Nr||!G(s))return s;let d=Rp(n,go(s));if(!d)return s;let u=Cl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function $g(e,t={}){let r=!1,n=e.parentId!==void 0||t.normalizeRootActive===!0&&e.active!==!0,o=e.components.map(i=>{if(i.type!=="Transform")return i;r=!0;let s=i;return ws(s)&&po(s.position,Fr.position)&&po(s.rotation,Fr.rotation)&&po(Lg(s,"scale"),Fr.scale)?i:(n=!0,Ms())});if(r||(n=!0,o.unshift(Ms())),!n)return e;let a={...e,...t.normalizeRootActive===!0?{active:!0}:{},components:o};return delete a.parentId,a}function Ms(){return Mt(Fr)}function go(e){let t=G(e);return t?Ee(t)?Vi(t.matrix)??Et():{position:{...t.position},rotation:{...t.rotation},scale:{...Lg(t,"scale")}}:Et()}function Cl(e,t){return{...e,components:e.components.map(r=>r.type!=="Transform"?r:mr(t)??r)}}function mr(e){let t=Sn(e);return t?tt(t)?{type:"Transform",mode:"matrix",matrix:t.matrix}:{type:"Transform",...t.mode==="trs"?{mode:"trs"}:{},position:{...t.position},rotation:{...t.rotation},scale:{...t.scale}}:null}function Sn(e){return tt(e)?Vi(e.matrix):wp(e)}function Mt(e){let t=mr(e);if(!t)throw new Error("Invalid matrix Transform component.");return t}function Ee(e){return e.mode==="matrix"}function ws(e){return e.mode!=="matrix"}function Lg(e,t){return ZD(e)?t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]:t==="scale"?{x:1,y:1,z:1}:{x:0,y:0,z:0}}function ZD(e){return!!e.position&&!!e.rotation}function QD(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):po(e.position,t.position)&&po(e.rotation,t.rotation)&&po(e.scale,t.scale)}function po(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function ye(e){return e.scene.gameObjects.find(t=>t.id===Nr&&!!G(t))?.id??e.scene.gameObjects.find(t=>!t.parentId&&!!G(t))?.id}function ks(e,t){return ue(e)&&/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/.test(t)}function vl(e,t){return!t||t===Nr?!1:!!_(e,t)}function fr(e){let t=ye(e),r=new Map(e.scene.gameObjects.map(n=>[n.id,n]));return e.scene.gameObjects.filter(n=>n.id!==Nr).map(n=>{let o=Dt(n),a=xt(n),i=n.active!==!1;return{id:n.id,label:n.name??n.id,parentId:n.parentId===t?null:n.parentId??null,depth:Math.max(0,eM(r,n)-(t?1:0)),role:a&&Dl(n)?"group":"object",...ss(n)?{icon:"prefab"}:{},selectable:!0,enabled:i&&tM(r,n.parentId,t),directEnabled:i,canToggleEnabled:!o,enableToggleDisabledReason:o?"Protected system objects cannot be hidden from Hierarchy.":void 0,protected:o,canHaveChildren:!o&&a,renamable:!o,deletable:!o,draggable:!o}})}function eM(e,t){let r=new Set,n=0,o=t.parentId??null;for(;o;){if(r.has(o))return n;r.add(o);let a=e.get(o);if(!a)return n;n+=1,o=a.parentId??null}return n}function tM(e,t,r){let n=new Set,o=t??null;for(;o;){if(n.has(o))return!0;n.add(o);let a=e.get(o);if(!a)return!0;if(a.id!==r&&a.active===!1)return!1;o=a.parentId??null}return!0}function Gl(e){let t=Ia(e,{normalizeRootActive:!0}),r=ye(t);if(!r)return t;let n=t.scene.gameObjects.find(s=>s.id===r);if(!n)return t;let o=Z(n)?null:ke(t,r);if(!Z(n)&&!o)return t;let a=!1,i=t.scene.gameObjects.map(s=>{if(s.id===r||s.parentId)return s;let c=qt(s),d=o?ro(o,c,{allowMatrixFallback:!0}):c;return a=!0,{...s,parentId:r,components:d?s.components.map(u=>u.type!=="Transform"?u:Mt(d)):s.components}});return a?{...t,scene:{...t.scene,gameObjects:i}}:t}function pr(e,t){return[...wt(e,t)]}function wt(e,t){let r=new Set,n=new Map;for(let i of e.scene.gameObjects){r.add(i.id);let s=i.parentId;if(!s)continue;let c=n.get(s);c?c.push(i.id):n.set(s,[i.id])}let o=new Set,a=[];for(let i of t)!r.has(i)||o.has(i)||(o.add(i),a.push(i));for(let i=0;i<a.length;i+=1)for(let s of n.get(a[i])??[])o.has(s)||(o.add(s),a.push(s));return o}function Fl(e){let t=[zg(e)],r=Vg(e);r&&t.push(r);let n=Hg(e);n&&t.push(n);let o=Jg(e);o&&t.push(o);let a=Zg(e);a&&t.push(a);let i=oM(e);i&&t.push(i);let s=eb(e);s&&t.push(s);let c=tb(e);c&&t.push(c);let d=nb(e);return d&&t.push(d),t}function zg(e){return{id:"common",title:"Common",order:10,placement:"body",summary:Cs(e),persistence:"document",collapsedByDefault:!1,properties:Bg(e)}}function Bg(e){let{document:t,gameObject:r}=e,n=Cs(e),o=[Qe("id","ID",r.id,0),Jt(e,{document:t,path:"name",label:"Name",valueType:"string",control:"string",value:r.name??r.id,commitMode:"blur",order:1}),Jt(e,{document:t,path:"enabled",label:"Enabled",valueType:"boolean",control:"boolean",value:r.active!==!1,commitMode:"immediate",order:2}),Qe("kind.resolved","Resolved Kind",n,3),Qe("kind.explicit","Explicit Kind",r.kind??"inferred",4),Qe("common.activeField","Active Field",r.active??"default:true",5)];return n==="transform"?o.push(Jt(e,{document:t,path:"transformType",label:"Transform Type",valueType:"enum",control:"enum",value:r.transformType??"plain",commitMode:"immediate",order:6,options:e.transformTypeOptions??Ta})):o.push(Qe("common.transformType","Transform Type",r.transformType??"none",6)),o}function Vg(e){return Gr({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:Ug(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Kg(e)})}function Ug(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Kg(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?_(t,r.parentId):null,a=t.scene.gameObjects.filter(d=>d.parentId===r.id),i=Math.max(pr(t,[r.id]).length-1,0),s=Wt(t),c=t.scene.gameObjects.filter(d=>d.parentId===r.parentId).findIndex(d=>d.id===r.id);return oe(n,{path:"hierarchy.parentId",label:"Parent ID",value:r.parentId??"none",order:0,source:"Document"}),oe(n,{path:"hierarchy.parentName",label:"Parent Name",value:o?o.name??o.id:r.parentId?"missing":"none",order:1,source:"Document"}),oe(n,{path:"hierarchy.childCount",label:"Children",value:a.length,order:2,source:"Derived"}),oe(n,{path:"hierarchy.descendantCount",label:"Descendants",value:i,order:3,source:"Derived"}),oe(n,{path:"hierarchy.siblingIndex",label:"Sibling Index",value:c>=0?c:"unknown",order:4,source:"Derived"}),oe(n,{path:"document.gameObjectIndex",label:"Document Index",value:t.scene.gameObjects.findIndex(d=>d.id===r.id),order:5,source:"Derived"}),oe(n,{path:"document.schemaVersion",label:"Schema Version",value:t.schemaVersion,order:6,source:"Document"}),oe(n,{path:"source.sourceId",label:"Source ID",value:s.sourceId,order:7,source:"Document"}),oe(n,{path:"source.sourceType",label:"Source Type",value:s.sourceType,order:8,source:"Document"}),oe(n,{path:"source.revision",label:"Revision",value:s.revision??"none",order:9,source:"Document"}),n}function Hg(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:qg(e),persistence:"document",collapsedByDefault:!1,properties:Wg(e)}:null}function Wg(e){if(!G(e.gameObject))return[];let r=Cs(e),n=Z(e.gameObject),o=n?e.rootTransform??Et():go(e.gameObject);if(tt(o))return rM(o,0);let a=!!e.gameObject.parentId,i=[],s=0;for(let c of["position","rotation","scale"]){let d=mM(o,c);for(let u of["x","y","z"]){let l=`transform.${c}.${u}`,m=c==="rotation"?at(Tt(d[u])):d[u];n?i.push(Qe(l,`${Nl(c)}.${u}`,m,s)):i.push(Jt(e,{document:null,path:l,label:`${a?`Local ${Nl(c)}`:Nl(c)}.${u}`,valueType:"number",control:"number",value:m,commitMode:"live",order:s,displayPrecision:c==="rotation"?2:3,precision:4,step:c==="rotation"?1:c==="scale"?.01:.1,stepPrecision:c==="rotation"?.1:c==="scale"?.001:.01},r)),s+=1}}if(a){let c=ke(e.document,e.gameObject.id);if(c&&!tt(c))for(let d of["x","y","z"])i.push(Qe(`transform.worldPosition.${d}`,`World Position.${d}`,c.position[d],s)),s+=1}return i}function qg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;if(Z(e.gameObject))return"Identity Root";let r=G(e.gameObject);return r&&Ee(r)?"Matrix Transform":`Relative to: ${t?t.name??t.id:"Scene"}`}function rM(e,t){if(!tt(e))return[];let r=[Qe("transform.mode","Mode","Matrix Transform",t)],n=t+1;for(let a=0;a<4;a+=1)r.push(Qe(`transform.matrix.row${a}`,`Matrix Row ${a+1}`,e.matrix.slice(a*4,a*4+4).map(Os).join(", "),n)),n+=1;let o=qd(e.matrix);return r.push(Qe("transform.matrix.trsApproximation","TRS Approximation",o?[`P ${jl(o.position)}`,`R ${jl({x:Tt(o.rotation.x),y:Tt(o.rotation.y),z:Tt(o.rotation.z)})}`,`S ${jl(o.scale)}`].join(" | "):"Not representable as TRS",n)),r}function Jg(e){let t=Se(e.gameObject),r=Rr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:Yg(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?nM(e,r):Xg(e)}:null}function nM(e,t){let r=Pa(e.document,t.assetId);return[Qe("imageRenderer.assetId","Texture Asset",r?.displayName??t.assetId,0),Qe("imageRenderer.size","Image Size",`${t.size.width} \xD7 ${t.size.height}`,1),Qe("imageRenderer.assetType","Asset Type",r?.type??"texture",2)]}function Xg(e){let t=Se(e.gameObject);if(!t)return[];let{document:r}=e,n=Pa(r,t.assetId),o=[Jt(e,{document:r,path:"instance.assetId",label:"Asset",valueType:"enum",control:"enum",value:t.assetId,commitMode:"immediate",order:0,options:r.assets.map(a=>({label:a.displayName??a.id,value:a.id}))})];return oe(o,{path:"renderer.assetId",label:"Renderer Asset ID",value:t.assetId,order:1,source:"Document"}),oe(o,{path:"asset.id",label:"Asset ID",value:n?.id??"missing",order:2,source:"Asset"}),oe(o,{path:"asset.type",label:"Asset Type",value:n?.type??"missing",order:3,source:"Asset"}),oe(o,{path:"asset.guid",label:"GUID",value:n?.guid??"missing",order:4,source:"Asset"}),oe(o,{path:"asset.displayName",label:"Display Name",value:n?.displayName??"none",order:5,source:"Asset"}),oe(o,{path:"asset.category",label:"Category",value:n?.category??"none",order:6,source:"Asset"}),oe(o,{path:"asset.materialMode",label:"Material Mode",value:n?.materialMode??"none",order:7,source:"Asset"}),oe(o,{path:"asset.defaults",label:"Defaults",value:n?.defaults??"none",order:8,source:"Asset",tags:["Raw"]}),o}function Yg(e,t){let r=Pa(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function Zg(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:Qg(e)}:null}function Qg(e){let t=e.gameObject.primitive;return t?[Jt(e,{document:e.document,path:"primitive.shape",label:"Shape",valueType:"enum",control:"enum",value:t.shape,commitMode:"immediate",order:0,options:e.primitiveShapeOptions??fM})]:[]}function oM(e){if(e.gameObject.prefab)return aM(e);if(!bo(e))return null;let t=He(e.gameObject.shadow).shadow,r=Jt(e,{document:e.document,path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.cast==="enabled",commitMode:"immediate",order:0,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u8BE5\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002"}),n=Jt(e,{document:e.document,path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.receive==="enabled",commitMode:"immediate",order:1,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002"}),o=Rs(e.renderingProfile),a=e.renderingProfile!==void 0&&Ts(o)==="none";return{id:"shadow",title:"\u9634\u5F71",order:34,placement:"body",...a?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[r,n,...a?[_l()]:[]]}}function aM(e){let t=e.gameObject.prefab?.prefabId,r=t?e.document.assets.find(i=>i.id===t)?.prefab?.defaults?.shadow:void 0,n=He(r).shadow,o=!!t,a=[{path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:0,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},{path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:1,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},...t?[io({path:"prefab.edit-definition",label:"\u8FDB\u5165 Prefab",buttonLabel:"Edit Prefab",actionId:"asset.edit-prefab",order:2,icon:"box",tooltip:"\u5728 Prefab Stage \u4E2D\u7F16\u8F91 definition root \u7684\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002",params:{assetId:t,browserAssetId:`prefab:${t}`,assetKind:"prefab"},disabled:!1})]:[]];return{id:"shadow",title:"\u9634\u5F71",order:34,summary:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B":"\u7531 Prefab definition root \u7BA1\u7406",persistence:o?"document":"readonly",collapsedByDefault:!1,properties:a}}function _l(){return{path:"rendering.shadows.open",label:"\u6253\u5F00 Rendering / Shadows",valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:"\u6253\u5F00 Rendering / Shadows",icon:"world"},value:"\u6253\u5F00 Rendering / Shadows",readOnly:!0,persistence:"readonly",commitMode:"immediate",order:2,tags:["Rendering"],effect:"active"}}function Rs(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function eb(e){if(!iM(e))return null;let t=Rs(e.renderingProfile),r=sM(e.gameObject.rendering?.renderingGroupId),n=t.renderingGroups.slots.find(a=>a.renderingGroupId===r)??t.renderingGroups.slots[0],o=cM(e.gameObject)??null;return{id:"rendering",title:"Rendering",order:36,placement:"body",summary:dM(n,o),persistence:"document",collapsedByDefault:!1,properties:[Jt(e,{document:e.document,path:"rendering.renderingGroupId",label:"Rendering Group",valueType:"enum",control:"enum",value:r,commitMode:"immediate",order:0,options:t.renderingGroups.slots.map(a=>({label:`${a.renderingGroupId}: ${a.name}`,value:a.renderingGroupId}))}),Jt(e,{document:e.document,path:"rendering.alphaIndex",label:"Alpha Order",valueType:"enum",control:"enum",value:o,commitMode:"immediate",order:1,options:lM(n,o)})]}}function tb(e){return Gr({id:"components",title:"Scripts / Components",order:65,summary:$l(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:rb(e.gameObject)})}function $l(e){return e.components.map(t=>t.type).join(", ")||"none"}function rb(e){let t=[];return oe(t,{path:"components.count",label:"Count",value:e.components.length,order:0,source:"Document"}),oe(t,{path:"components.types",label:"Types",value:$l(e),order:1,source:"Document"}),e.components.forEach((r,n)=>{oe(t,{path:`components.${n}`,label:`${r.type} ${n}`,value:r,order:n+2,source:"Document",tags:["Component","Raw"]})}),t}function nb(e){let t=e.assetId??Se(e.gameObject)?.assetId??Rr(e.gameObject)?.assetId??null,r=ob({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:ab({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function ob(e){let t=[],r=e.assetId?Pa(e.document,e.assetId):null;return oe(t,{path:"metadata.document",label:"Document Meta",value:e.document.meta??"none",order:0,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.gameObject",label:"GameObject Metadata",value:e.gameObject.metadata??"none",order:1,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.asset",label:"Asset Metadata",value:r?.metadata??"none",order:2,source:"Asset",tags:["Raw"]}),t}function ab(e){let t=e.assetId?Pa(e.document,e.assetId):null,r=[e.document.meta?"Document":null,e.gameObject.metadata?"GameObject":null,t?.metadata?"Asset":null].filter(n=>!!n);return r.length>0?r.join(" + "):"none"}function Jt(e,t,r=Cs(e)){let{document:n,...o}=t;return ha({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=j(t);r&&e.push(r)}function Qe(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Cs(e){return e.nodeKind??Y(e.gameObject)}function bo(e){let t=e.gameObject;return Z(t)?!1:dn(t)}function iM(e){let t=e.gameObject;if(Z(t)||t.transformType==="camera"||t.transformType==="light"||t.camera||t.light)return!1;let r=e.nodeKind??Y(t);return r==="instance"||r==="primitive"||r==="transform"}function sM(e){return e===1||e===2||e===3?e:0}function cM(e){let t=e.rendering?.alphaIndex;if(typeof t=="number"&&Number.isFinite(t))return t}function dM(e,t){return t==null?`${e.name} \xB7 Babylon \u9ED8\u8BA4`:`${e.name} \xB7 ${uM(e,t)}`}function lM(e,t){let r=[{label:"Babylon \u9ED8\u8BA4",value:null},...e.alphaIndexPresets.map(n=>({label:`${n.name} (${n.alphaIndex})`,value:n.alphaIndex}))];return t!=null&&!e.alphaIndexPresets.some(n=>n.alphaIndex===t)&&r.push({label:`\u672A\u547D\u540D\u503C ${t}`,value:t,batchCompatibility:"ignore"}),r}function uM(e,t){let r=e.alphaIndexPresets.find(n=>n.alphaIndex===t);return r?r.name:`\u672A\u547D\u540D\u503C ${t}`}function mM(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function jl(e){return`${Os(e.x)}, ${Os(e.y)}, ${Os(e.z)}`}function Os(e){return at(e).toString()}function Nl(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function Pa(e,t){return e.assets.find(r=>r.id===t)??null}var Ta=[{label:"Plain",value:"plain"},{label:"Light",value:"light"},{label:"Camera",value:"camera"}],fM=[{label:"Cube",value:"cube"},{label:"Sphere",value:"sphere"},{label:"Plane",value:"plane"},{label:"Capsule",value:"capsule"}];function ib(e){return[db(e),lb(e.runtime),ub(e.runtime),mb(e.runtime),fb(e.runtime),pb(e.runtime),gb(e.runtime),bb(e.runtime),Sb(e.runtime),yb(e.runtime),hb(e.runtime),Eb(e.runtime),Ib(e)].filter(t=>!!t)}function Ll(e,t){if(!e.activeId)return[];let r=t.findGameObject(e.document,e.activeId);if(!r||e.targetIds&&e.targetIds.length!==1)return[];let n=pa({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return ib({runtime:n,binding:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,objectId:e.activeId,component:t.hasModelRenderer(r)?"ModelRenderer":t.hasImageRenderer(r)?"ImageRenderer":t.readNodeKind(r)==="transform"?"Transform":"GameObject",projectionNodeId:ce(e.projectionNode,"id")??null,projectionName:ce(e.projectionNode,"name")??null,projectionParentId:ce(e.projectionNode,"parentId")??null,projectionAssetId:sb(e.projectionNode)},projectionAssetMetadata:cb(e.projectionNode)})}function sb(e){let t=B(e,"asset");return ce(t,"assetId")??ce(t,"id")}function cb(e){return B(B(e,"asset"),"metadata")}function db(e){let{binding:t,runtime:r}=e,n=[];return x(n,{path:"runtime.binding.sourceId",label:"Source ID",value:t?.sourceId??"none",order:0,source:"Document"}),x(n,{path:"runtime.binding.sourceType",label:"Source Type",value:t?.sourceType??"none",order:1,source:"Document"}),x(n,{path:"runtime.binding.objectId",label:"Object ID",value:t?.objectId??"none",order:2,source:"Document"}),x(n,{path:"runtime.binding.component",label:"Component",value:t?.component??"GameObject",order:3,source:"Derived"}),x(n,{path:"runtime.projection.nodeId",label:"Projection Node ID",value:t?.projectionNodeId??"none",order:4,source:"Derived"}),x(n,{path:"runtime.projection.name",label:"Projection Name",value:t?.projectionName??"none",order:5,source:"Derived"}),x(n,{path:"runtime.projection.parentId",label:"Projection Parent",value:t?.projectionParentId??"none",order:6,source:"Derived"}),x(n,{path:"runtime.projection.assetId",label:"Projection Asset ID",value:t?.projectionAssetId??"none",order:7,source:"Asset"}),x(n,{path:"runtime.root.status",label:"Projected Root",value:r.root?"available":"not projected",order:8,source:"Runtime"}),x(n,{path:"runtime.root.className",label:"Runtime Class",value:Kt(r.root)??"none",order:9,source:"Runtime"}),x(n,{path:"runtime.root.name",label:"Runtime Name",value:ce(r.root,"name")??"none",order:10,source:"Runtime"}),x(n,{path:"runtime.binding.primaryMesh",label:"Primary Mesh",value:un(r.primaryMesh)??"none",order:11,source:"Derived"}),x(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:un(r.material)??"none",order:12,source:"Derived"}),x(n,{path:"runtime.material.kind",label:"Material Kind",value:Db(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?un(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function lb(e){let t=[],r=ms(e.root)??ms(e.primaryMesh);return r?(yn(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),yn(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),yn(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),yn(t,"runtime.bounds.size","Bounds Size",r.size,t.length,"Derived")):x(t,{path:"runtime.bounds.status",label:"Bounds",value:"not available",source:"Derived"}),x(t,{path:"runtime.geometry.meshCount",label:"Mesh Count",value:e.meshes.length,source:"Derived"}),x(t,{path:"runtime.geometry.childNodeCount",label:"Child Nodes",value:e.childNodes.length,source:"Derived"}),x(t,{path:"runtime.geometry.totalVertices",label:"Total Vertices",value:fs(e.meshes,"getTotalVertices"),source:"Derived"}),x(t,{path:"runtime.geometry.totalIndices",label:"Total Indices",value:fs(e.meshes,"getTotalIndices"),source:"Derived"}),x(t,{path:"runtime.geometry.subMeshCount",label:"SubMeshes",value:e.meshes.reduce((n,o)=>n+so(o,"subMeshes"),0),source:"Derived"}),Be({id:"geometryBox",title:"Geometry / Box",order:920,summary:r?`${e.meshes.length} mesh${e.meshes.length===1?"":"es"}`:"no bounds",collapsedByDefault:!1,properties:t})}function ub(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.rendering.nodeClass",label:"Node Class",value:Kt(t)??"none"}),x(r,{path:"runtime.rendering.nodeName",label:"Node Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.rendering.isEnabled",label:"Enabled",value:yl(t)??"not available"}),x(r,{path:"runtime.rendering.isVisible",label:"Is Visible",value:Te(t,"isVisible")??"not available"}),x(r,{path:"runtime.rendering.visibility",label:"Visibility",value:re(t,"visibility")??"not available"}),x(r,{path:"runtime.rendering.layerMask",label:"Layer Mask",value:re(t,"layerMask")??"not available"}),x(r,{path:"runtime.rendering.renderingGroupId",label:"Rendering Group",value:re(t,"renderingGroupId")??"not available"}),x(r,{path:"runtime.rendering.alphaIndex",label:"Alpha Index",value:re(t,"alphaIndex")??"not available"}),x(r,{path:"runtime.rendering.alwaysSelectAsActiveMesh",label:"Always Active Mesh",value:Te(t,"alwaysSelectAsActiveMesh")??"not available"}),x(r,{path:"runtime.rendering.billboardMode",label:"Billboard Mode",value:re(t,"billboardMode")??"not available"}),Be({id:"rendering",title:"Rendering",order:930,summary:ce(t,"name")??Kt(t)??"not available",collapsedByDefault:!0,properties:r})}function mb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.collisions.checkCollisions",label:"Check Collisions",value:Te(t,"checkCollisions")??"not configured"}),x(r,{path:"runtime.collisions.collisionMask",label:"Collision Mask",value:re(t,"collisionMask")??"not configured"}),x(r,{path:"runtime.collisions.collisionGroup",label:"Collision Group",value:re(t,"collisionGroup")??"not configured"}),x(r,{path:"runtime.collisions.collisionResponse",label:"Collision Response",value:Te(t,"collisionResponse")??"not configured"}),x(r,{path:"runtime.collisions.moveWithCollisions",label:"Move With Collisions",value:typeof B(t,"moveWithCollisions")=="function"?"available":"not available"}),yn(r,"runtime.collisions.ellipsoid","Ellipsoid",B(t,"ellipsoid"),r.length,"Runtime","not configured"),yn(r,"runtime.collisions.ellipsoidOffset","Ellipsoid Offset",B(t,"ellipsoidOffset"),r.length,"Runtime","not configured"),Be({id:"collisions",title:"Collisions",order:940,summary:Te(t,"checkCollisions")===!0?"enabled":"not configured",collapsedByDefault:!0,properties:r})}function fb(e){let t=e.primaryMesh??e.root,r=B(t,"physicsBody"),n=B(t,"physicsImpostor"),o=r??n,a=[];return x(a,{path:"runtime.physics.status",label:"Physics",value:o?"configured":"not configured"}),x(a,{path:"runtime.physics.bodyClass",label:"Body Class",value:Kt(o)??"none"}),x(a,{path:"runtime.physics.bodyName",label:"Body Name",value:ce(o,"name")??ce(o,"id")??"none"}),x(a,{path:"runtime.physics.mass",label:"Mass",value:ga(o,"mass")??"not available"}),x(a,{path:"runtime.physics.friction",label:"Friction",value:ga(o,"friction")??"not available"}),x(a,{path:"runtime.physics.restitution",label:"Restitution",value:ga(o,"restitution")??"not available"}),x(a,{path:"runtime.physics.disablePreStep",label:"Disable Pre Step",value:Te(o,"disablePreStep")??"not available"}),Be({id:"physics",title:"Physics",order:950,summary:o?un(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function pb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.shadows.receiveShadows",label:"Receive Shadows",value:Te(t,"receiveShadows")??"not configured"}),x(r,{path:"runtime.shadows.shadowEnabled",label:"Shadow Enabled",value:we(t,"isShadowEnabled")??"not available"}),x(r,{path:"runtime.shadows.shadowDepthWrapper",label:"Shadow Depth Wrapper",value:un(B(e.material,"shadowDepthWrapper"))??"none"}),x(r,{path:"runtime.shadows.receivingMeshCount",label:"Receiving Meshes",value:e.meshes.filter(n=>Te(n,"receiveShadows")===!0).length,source:"Derived"}),Be({id:"shadows",title:"Shadows",order:960,summary:Te(t,"receiveShadows")===!0?"receiving":"not configured",collapsedByDefault:!0,properties:r})}function gb(e){let t=e.material,r=[];return x(r,{path:"runtime.material.status",label:"Material",value:t?"available":"none"}),x(r,{path:"runtime.material.className",label:"Class",value:Kt(t)??"none"}),x(r,{path:"runtime.material.name",label:"Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.material.id",label:"ID",value:ce(t,"id")??"none"}),x(r,{path:"runtime.material.uniqueId",label:"Unique ID",value:re(t,"uniqueId")??"not available"}),x(r,{path:"runtime.material.alpha",label:"Alpha",value:re(t,"alpha")??"not available"}),x(r,{path:"runtime.material.backFaceCulling",label:"Back Face Culling",value:Te(t,"backFaceCulling")??"not available"}),x(r,{path:"runtime.material.twoSidedLighting",label:"Two Sided Lighting",value:Te(t,"twoSidedLighting")??"not available"}),x(r,{path:"runtime.material.disableLighting",label:"Disable Lighting",value:Te(t,"disableLighting")??"not available"}),x(r,{path:"runtime.material.wireframe",label:"Wireframe",value:Te(t,"wireframe")??"not available"}),x(r,{path:"runtime.material.pointsCloud",label:"Points Cloud",value:Te(t,"pointsCloud")??"not available"}),x(r,{path:"runtime.material.fillMode",label:"Fill Mode",value:re(t,"fillMode")??"not available"}),x(r,{path:"runtime.material.activeTextureCount",label:"Active Textures",value:ps(t,"getActiveTextures"),source:"Derived"}),Be({id:"material",title:"Material",order:970,summary:un(t)??"none",collapsedByDefault:!0,properties:r})}function bb(e){let t=e.material,r=[];x(r,{path:"runtime.material.textures.activeCount",label:"Active Texture Count",value:ps(t,"getActiveTextures"),source:"Derived"});let n=0;for(let o of Mb){let a=B(t,o);a&&(n+=1,Tb(r,`runtime.material.textures.${o}`,xa(o),a))}return n===0&&x(r,{path:"runtime.material.textures.status",label:"Textures",value:"none"}),Be({id:"materialTextures",title:"Material Textures",order:980,summary:n>0?`${n} slot${n===1?"":"s"}`:"none",collapsedByDefault:!0,properties:r})}function Sb(e){let t=[],r=0;for(let n of wb){let o=B(e.material,n);Pb(t,`runtime.material.colors.${n}`,xa(n),o,t.length)&&(r+=1)}return r===0&&x(t,{path:"runtime.material.colors.status",label:"Colors",value:"none"}),Be({id:"materialColors",title:"Material Colors",order:990,summary:r>0?`${r} color${r===1?"":"s"}`:"none",collapsedByDefault:!0,properties:t})}function yb(e){let t=[];for(let r of kb)x(t,{path:`runtime.material.metallicRoughness.${r}`,label:xa(r),value:re(e.material,r)??"not available"});return Be({id:"metallicRoughness",title:"Metallic / Roughness",order:1e3,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function hb(e){let t=[];for(let r of Ob)x(t,{path:`runtime.material.intensity.${r}`,label:xa(r),value:re(e.material,r)??"not available"});return Be({id:"intensityProperties",title:"Intensity Properties",order:1010,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function Eb(e){let t=e.primaryMesh??e.root,r=B(t,"skeleton"),n=[];return x(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:so(e.root,"animations"),source:"Derived"}),x(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:so(t,"animations"),source:"Derived"}),x(n,{path:"runtime.skeleton.status",label:"Skeleton",value:r?"available":"none"}),x(n,{path:"runtime.skeleton.className",label:"Skeleton Class",value:Kt(r)??"none"}),x(n,{path:"runtime.skeleton.name",label:"Skeleton Name",value:ce(r,"name")??"none"}),x(n,{path:"runtime.skeleton.id",label:"Skeleton ID",value:ce(r,"id")??"none"}),x(n,{path:"runtime.skeleton.boneCount",label:"Bones",value:so(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?ce(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function Ib(e){let{runtime:t}=e,r=[];return x(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:B(t.root,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:B(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:B(t.material,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.projectionAssetMetadata",label:"Projection Asset Metadata",value:e.projectionAssetMetadata??"none",source:"Asset",tags:["Raw"]}),x(r,{path:"runtime.misc.isDisposed",label:"Root Disposed",value:we(t.root,"isDisposed")??"not available"}),Be({id:"rawMisc",title:"Raw / Misc",order:1030,summary:"metadata",collapsedByDefault:!0,properties:r})}function Be(e){return Gr({id:e.id,title:e.title,order:e.order,summary:e.summary,persistence:"runtime",runtimeOnly:!0,collapsedByDefault:e.collapsedByDefault,omitWhenEmpty:!1,tags:["Runtime"],properties:e.properties})}function x(e,t){let r=j({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function yn(e,t,r,n,o,a="Runtime",i){let s=Sl({basePath:t,label:r,value:n,order:o,persistence:"runtime",source:a});s.length>0?e.push(...s):i&&x(e,{path:`${t}.status`,label:r,value:i,order:o,source:a})}function Pb(e,t,r,n,o){let a=Ab(n);return a?(x(e,{path:`${t}.r`,label:`${r}.r`,value:a.r,order:o,valueType:"number"}),x(e,{path:`${t}.g`,label:`${r}.g`,value:a.g,order:o+1,valueType:"number"}),x(e,{path:`${t}.b`,label:`${r}.b`,value:a.b,order:o+2,valueType:"number"}),a.a!=null&&x(e,{path:`${t}.a`,label:`${r}.a`,value:a.a,order:o+3,valueType:"number"}),!0):!1}function Tb(e,t,r,n){let o=e.length;x(e,{path:`${t}.className`,label:`${r} Class`,value:Kt(n)??"Texture",order:o}),x(e,{path:`${t}.name`,label:`${r} Name`,value:ce(n,"name")??"none",order:o+1}),x(e,{path:`${t}.url`,label:`${r} URL`,value:xb(n)??"none",order:o+2}),x(e,{path:`${t}.level`,label:`${r} Level`,value:re(n,"level")??"not available",order:o+3}),x(e,{path:`${t}.coordinatesIndex`,label:`${r} UV Set`,value:re(n,"coordinatesIndex")??"not available",order:o+4}),x(e,{path:`${t}.hasAlpha`,label:`${r} Has Alpha`,value:Te(n,"hasAlpha")??"not available",order:o+5})}function xb(e){return ce(e,"url")??ce(e,"name")??ce(we(e,"getInternalTexture"),"url")}function Ab(e){if(!e||typeof e!="object")return null;let t=re(e,"r"),r=re(e,"g"),n=re(e,"b");if(t==null||r==null||n==null)return null;let o=re(e,"a");return o==null?{r:t,g:r,b:n}:{r:t,g:r,b:n,a:o}}function Db(e){let t=Kt(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function xa(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var Mb=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],wb=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],kb=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],Ob=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var Cb=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],Rb={zh:{hemisphericTitle:"\u73AF\u5883\u5149",directionalTitle:"\u76F4\u5C04\u5149",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"\u8BED\u8A00",type:"\u7C7B\u578B",typeHemispheric:"\u73AF\u5883\u5149",typeDirectional:"\u76F4\u5C04\u5149",intensity:"\u5F3A\u5EA6",skyLightColor:"\u5929\u7A7A\u5149\u989C\u8272",groundColor:"\u5730\u9762\u989C\u8272",lightColor:"\u5149\u7167\u989C\u8272",horizontalAngle:"\u6C34\u5E73\u89D2",elevationAngle:"\u9AD8\u5EA6\u89D2",shadowsTitle:"\u9634\u5F71",shadowsSummary:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",shadowSystem:"\u7CFB\u7EDF",shadowEnabled:"\u542F\u7528",shadowOpacity:"\u4E0D\u900F\u660E\u5EA6",shadowLength:"\u9634\u5F71\u957F\u5EA6",shadowFollowDirectional:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",openShadows:"\u6253\u5F00\u9634\u5F71\u8BBE\u7F6E",rawLight:"\u539F\u59CB\u5149\u6E90\u6570\u636E",tooltips:{language:"\u5207\u6362\u6B64\u5149\u6E90\u68C0\u67E5\u5668\u7684\u5C5E\u6027\u663E\u793A\u8BED\u8A00\u3002\u8BE5\u5B57\u6BB5\u53EA\u7528\u4E8E\u7F16\u8F91\u5668\uFF0C\u4E0D\u4F1A\u5BFC\u51FA\u5230\u8FD0\u884C\u65F6\u3002",type:"\u7CFB\u7EDF\u5149\u6E90\u7C7B\u578B\u53EA\u8BFB\u3002\u5BF9\u5E94 BabylonJS \u7684 HemisphericLight \u6216 DirectionalLight\u3002",intensity:"\u5149\u6E90\u5F3A\u5EA6\uFF0C\u5FC5\u987B\u662F\u975E\u8D1F\u6570\u3002BabylonJS \u4E0D\u8BBE\u7F6E\u786C\u4E0A\u9650\uFF1B\u767D\u8272\u6750\u8D28\u5728\u8F83\u9AD8\u5F3A\u5EA6\u4E0B\u901A\u5E38\u5DF2\u7ECF\u63A5\u8FD1\u663E\u793A\u9971\u548C\uFF0C\u7EE7\u7EED\u589E\u5927\u89C6\u89C9\u53D8\u5316\u4F1A\u4E0D\u660E\u663E\u3002",skyLightColor:"\u73AF\u5883\u5149\u6765\u81EA\u5929\u7A7A\u65B9\u5411\u7684\u6F2B\u53CD\u5C04\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.diffuse\u3002",groundColor:"\u73AF\u5883\u5149\u6765\u81EA\u5730\u9762\u53CD\u5C04\u65B9\u5411\u7684\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.groundColor\u3002",lightColor:"\u76F4\u5C04\u5149\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS DirectionalLight.diffuse\u3002",horizontalAngle:"\u76F4\u5C04\u5149\u5728 XZ \u5E73\u9762\u5185\u7684\u671D\u5411\u89D2\u5EA6\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",elevationAngle:"\u76F4\u5C04\u5149\u76F8\u5BF9\u5730\u5E73\u7EBF\u7684\u9AD8\u5EA6\u89D2\uFF1B90 \u5EA6\u8868\u793A\u4ECE\u6B63\u4E0A\u65B9\u7167\u4E0B\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",shadowSystem:"\u9634\u5F71\u7CFB\u7EDF\u53EA\u8BFB\u6458\u8981\u3002Planar \u9634\u5F71\u65B9\u5411\u6765\u81EA\u5F53\u524D\u76F4\u5C04\u5149\uFF0C\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowEnabled:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u662F\u5426\u542F\u7528\u3002\u8FD9\u91CC\u4EC5\u663E\u793A\u6458\u8981\uFF0C\u4E0D\u5728\u5149\u6E90 Inspector \u4E2D\u7F16\u8F91\u3002",shadowOpacity:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u4E0D\u900F\u660E\u5EA6\u3002\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowLength:"\u6839\u636E\u76F4\u5C04\u5149\u65B9\u5411\u4F30\u7B97\u7684\u5E73\u9762\u9634\u5F71\u957F\u5EA6\u500D\u7387\uFF1B\u9AD8\u5EA6\u89D2\u8D8A\u4F4E\uFF0C\u9634\u5F71\u8D8A\u957F\u3002",openShadows:"\u5207\u6362\u5230\u53F3\u4FA7 Rendering \u9762\u677F\uFF0C\u7F16\u8F91\u9879\u76EE\u7EA7\u9634\u5F71\u8BBE\u7F6E\u3002",rawLight:"\u7F16\u8F91\u5668\u6587\u6863\u4E2D\u7684\u5149\u6E90\u539F\u59CB\u6570\u636E\uFF0C\u53EA\u8BFB\u663E\u793A\u3002"}},en:{hemisphericTitle:"Environment Light",directionalTitle:"Directional Light",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"Language",type:"Type",typeHemispheric:"Environment Light",typeDirectional:"Directional Light",intensity:"Intensity",skyLightColor:"Sky Light Color",groundColor:"Ground Color",lightColor:"Light Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",shadowsTitle:"Shadows",shadowsSummary:"Planar Main / Follow Directional Light",shadowSystem:"System",shadowEnabled:"Enabled",shadowOpacity:"Opacity",shadowLength:"Shadow Length",shadowFollowDirectional:"Planar Main / Follow Directional Light",openShadows:"Open Shadows",rawLight:"Raw Light Data",tooltips:{language:"Switches the display language for this light inspector. This editor-only field is not exported to runtime.",type:"Read-only system light type. Maps to BabylonJS HemisphericLight or DirectionalLight.",intensity:"Light intensity. Must be a non-negative number. BabylonJS does not impose a hard upper limit; white surfaces often saturate at high intensity, so further increases may look subtle.",skyLightColor:"Diffuse sky color for the environment light. Maps to BabylonJS HemisphericLight.diffuse.",groundColor:"Ground bounce color for the environment light. Maps to BabylonJS HemisphericLight.groundColor.",lightColor:"Directional light color. Maps to BabylonJS DirectionalLight.diffuse.",horizontalAngle:"Directional light heading in the XZ plane. The editor converts it to BabylonJS DirectionalLight.direction.",elevationAngle:"Directional light elevation above the horizon; 90 degrees points straight down. The editor converts it to BabylonJS DirectionalLight.direction.",shadowSystem:"Read-only shadow system summary. Planar shadow direction follows this Directional Light; edit full settings in Rendering.",shadowEnabled:"Whether the project-level planar shadow system is enabled. This is summary-only in the light Inspector.",shadowOpacity:"Current project-level planar shadow opacity. Edit full settings in Rendering.",shadowLength:"Estimated planar shadow length multiplier from this light direction. Lower elevation makes longer shadows.",openShadows:"Switches the right dock to the Rendering panel for project-level shadow settings.",rawLight:"Read-only raw light data from the editor document."}}};function zl(e){return Rb[e]??Rb.zh}function Bl(e){return e.inspectorLanguage==="en"?"en":"zh"}function vb(e){let{createDocumentInspectorProperty:t,gameObject:r,light:n,nodeKind:o,normalizeValue:a}=e,i=Bl(n),s=zl(i),c=[t(null,o,{path:"light.inspectorLanguage",label:s.language,valueType:"enum",control:"enum",value:i,commitMode:"immediate",order:0,options:Cb,controlOptions:{variant:"segmented"},tooltip:s.tooltips.language}),j({path:"light.type",label:s.type,value:n.type==="hemispheric"?s.typeHemispheric:s.typeDirectional,order:1,source:"Document",tooltip:s.tooltips.type}),t(null,o,{path:"light.intensity",label:s.intensity,valueType:"number",control:"number",value:n.intensity,commitMode:"live",order:2,min:0,step:.05,tooltip:s.tooltips.intensity})],d=3;if(n.type==="hemispheric")c.push(t(null,o,{path:"light.diffuseColor",label:s.skyLightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.skyLightColor})),d+=1,c.push(t(null,o,{path:"light.groundColor",label:s.groundColor,valueType:"color",control:"color",value:n.groundColor??e.defaultEnvironmentGroundColor??{r:.48,g:.52,b:.62},commitMode:"immediate",order:d,tooltip:s.tooltips.groundColor})),d+=1;else{let l=Il(r)??{horizontalAngleDeg:0,elevationAngleDeg:90};c.push(t(null,o,{path:fn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:hg,max:Eg,step:1,coerce:m=>a(fn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:pn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:ba,max:Sa,step:1,coerce:m=>a(pn,m),tooltip:s.tooltips.elevationAngle})),d+=1,c.push(t(null,o,{path:"light.diffuseColor",label:s.lightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.lightColor})),d+=1}return gM(c,{path:"light.raw",label:s.rawLight,value:n??"defaults",order:c.length,source:"Document",tags:["Raw"],tooltip:s.tooltips.rawLight}),c}function Gb(e){let t=e.renderingProfile.shadows.planar;return Gr({id:"lightShadows",title:e.text.shadowsTitle,order:46,summary:e.text.shadowsSummary,collapsedByDefault:!1,tags:["Rendering","Derived"],properties:[j({path:"rendering.shadows.summary.system",label:e.text.shadowSystem,value:e.text.shadowFollowDirectional,order:0,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowSystem,effect:"derived"}),j({path:"rendering.shadows.summary.enabled",label:e.text.shadowEnabled,value:t.enabled,order:1,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowEnabled,effect:"derived"}),j({path:"rendering.shadows.summary.opacity",label:e.text.shadowOpacity,value:at(t.appearance.color.a),order:2,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowOpacity,effect:"derived"}),j({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:SM(Pg(e.light.direction)),order:3,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowLength,effect:"derived"}),bM(e.text)]})}function Vl(e){let t=zl(Bl(e.light)),r=[{id:"light",title:e.light.type==="hemispheric"?t.hemisphericTitle:t.directionalTitle,order:44,placement:"body",summary:e.light.type==="hemispheric"?t.hemisphericSummary:t.directionalSummary,persistence:"document",collapsedByDefault:!1,properties:vb(e)}];return e.light.type==="directional"&&r.push(Gb({light:e.light,text:t,renderingProfile:pM(e.renderingProfile)})),r}function pM(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function gM(e,t){let r=j(t);r&&e.push(r)}function bM(e){return{path:"rendering.shadows.summary.open",label:e.openShadows,valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:e.openShadows,icon:"world"},value:e.openShadows,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:4,tags:["Rendering"],tooltip:e.tooltips.openShadows,effect:"active"}}function SM(e){return`x${at(e)}`}function Oe(e,t,r){let n=t.split(".").filter(Boolean);if(n.some(yM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function yM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Ul(e){let t=_r(e.overrides);if(!t)return;let r=jb(t.material);r?t.material=r:delete t.material;let n=_r(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=_r(s);if(!c){delete n[i];continue}let d=jb(c.override);d?c.override=d:delete c.override,Object.keys(c).length===0&&delete n[i]}Object.keys(n).length===0&&delete t.materialSlotBindings}let o=_r(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=_r(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function jb(e){let t=_r(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=_r(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=_r(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function _r(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Fb(n,r);return JSON.stringify(o)===JSON.stringify(n)?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>a.id===t?o:a)}}}function Kl(e,t){if(t.length===0)return e;let r=new Map;for(let a of t)r.set(a.targetId,a.patch);let n=!1,o=e.scene.gameObjects.map(a=>{let i=r.get(a.id);if(!i)return a;let s=Fb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Fb(e,t){let r=Nb(e),n=hM(e,t),o=Nb(n);return r&&o&&!EM(r,o)?lo(n):n}function hM(e,t){return G(e)?{...e,components:e.components.map(r=>{if(r.type!=="Transform")return r;let n=r;return t.transform?mr(t.transform)??n:Ee(n)?n:{...n,position:t.position??n.position,rotation:t.rotation??n.rotation,scale:t.scale??n.scale}})}:e}function Nb(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function EM(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function _b(e){let t=new Set(e.targetIds);if(t.size===0||!Number.isFinite(e.fromAlphaIndex)||!Number.isFinite(e.toAlphaIndex)||e.fromAlphaIndex===e.toAlphaIndex)return e.gameObjects;let r=!1,n=e.gameObjects.map(o=>!t.has(o.id)||!IM(o,e)?o:(r=!0,{...o,rendering:{...o.rendering??{},alphaIndex:e.toAlphaIndex}}));return r?n:e.gameObjects}function Hl(e){let t=_b({gameObjects:e.document.scene.gameObjects,targetIds:e.targetIds,renderingGroupId:e.renderingGroupId,fromAlphaIndex:e.fromAlphaIndex,toAlphaIndex:e.toAlphaIndex});return t===e.document.scene.gameObjects?e.document:{...e.document,scene:{...e.document.scene,gameObjects:t}}}function IM(e,t){return(ul(e.rendering?.renderingGroupId)??0)===t.renderingGroupId&&dg(e.rendering?.alphaIndex)===t.fromAlphaIndex}var Aa=it,vs=Ds;function Wl(e){let t=st(e.document.scene.gameObjects.map(n=>n.name??n.id),e.name??e.asset.displayName,{fallbackName:e.asset.assetId}),r=Aa(e.document.scene.gameObjects.map(n=>n.id),vs(t));return{label:`Place ${e.asset.displayName}`,patch:{kind:"game-object.create-from-asset",assetItem:e.asset,...e.name?{name:e.name}:{},placement:{position:{...e.hit.position},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},createdId:r,changedIds:[r]}}function $b(e){let t=e.scene.gameObjects.filter(r=>!!Se(r)||!!Rr(r)||!!r.primitive).length;return{x:t%5*1.8-3.6,y:0,z:Math.floor(t/5)*1.8+1.8}}function ql(e,t){let r=t&&It(t)?t:null;return{position:r?.position?{...r.position}:$b(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Ns(e){return e.filter(t=>MM(t.kind)&&Xl(t)).map(Jl).sort(Yl)}function Ma(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(Jl).sort(Yl)}function Jl(e){let t=e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"glb",r=En(e.guid),n=TM(e);return{id:e.assetId,...r?{guid:r}:{},assetId:e.assetId,type:t,kind:e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"model",displayName:e.displayName,category:e.category??PM(e),warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:js(e.defaults),prefab:js(e.prefab),external:js(e.external),metadata:n,origin:e.origin??"project",dedupeKey:e.dedupeKey??r??DM(e.external)??e.assetId,placeable:Xl(e)}}function zb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.kind==="texture"||t.type==="texture"}function Xl(e){return zb(e)?!0:!e||typeof e!="object"||Array.isArray(e)||e.placeable!==!1}function Yl(e,t){return(e.category??"").localeCompare(t.category??"")||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)||e.type.localeCompare(t.type)}function PM(e){return e.kind==="prefab"?"Prefab":e.kind==="texture"?"Texture":e.kind==="image"?"Image":e.kind==="sound"?"Sound":"Model"}function TM(e){return xM({originalFileName:e.originalFileName,relativePath:e.relativePath,codeKey:e.codeKey,contentHash:e.contentHash,byteSize:e.byteSize,...js(e.metadata)})}function xM(e){if(!Array.isArray(e.materialSlots))return e;let t=Gs(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=Gs(c),u=Da(d?.meshIndex),l=En(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=Gs(c),u=Da(d?.nodeIndex),l=En(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=Lb(t,"meshCount",r.length)||Lb(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=Gs(c);if(!d||En(d.sourceMeshName))return c;let u=Da(d.meshIndex);if(u==null)return c;let l=Da(d.nodeIndex),m=o.get(u)??(l==null?void 0:a.get(l))??(i?AM(d):void 0);return m?{...d,sourceMeshName:m}:c});return{...e,materialSlots:s}}function AM(e){let t=En(e.label);if(t){let r=t.replace(/\s+\/\s+Primitive\s+\d+$/,"").trim();if(r)return r}return En(e.ownerNodePath)?.split("/").filter(Boolean).pop()}function Lb(e,t,r){let n=Da(e?.[t]);return n!=null&&n>r}function DM(e){return!e||typeof e!="object"||Array.isArray(e)?null:En(e.platformAssetId)}function En(e){return typeof e=="string"&&e.trim()?e.trim():null}function Da(e){return Number.isInteger(e)&&e>=0?e:null}function Gs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function js(e){return e==null?void 0:structuredClone(e)}function MM(e){return e==="model"||e==="prefab"||e==="texture"}function Zl(e,t){let r=new Map(t.filter(a=>a.type==="glb").map(a=>[a.assetId,a])),n=e.assets.map(a=>{if(a.type!=="glb")return a;let i=r.get(a.id);return i?$r(a,i):a}),o=new Set(e.assets.map(a=>a.id));for(let a of wM(e)){if(o.has(a))continue;let i=r.get(a);i&&(n.push($r({id:a,type:"glb"},i)),o.add(a))}return{...e,assets:n}}function wM(e){let t=[],r=new Set,n=o=>{let a=Ve(o);!a||r.has(a)||(r.add(a),t.push(a))};for(let o of e.assets)if(o.type==="prefab"){n(o.prefab?.sourceAssetId);for(let a of o.prefab?.nodes??[])n(a.sourceAssetId)}for(let o of e.scene.gameObjects){for(let i of o.components)i.type==="ModelRenderer"&&n(i.assetId);n(o.prefab?.sourceAssetId);let a=ct(ct(o)?.instance);n(a?.assetId)}return t}function Ql(e,t){wa(e,t);let r=new Map(t.filter(n=>n.type==="glb").map(n=>[n.assetId,n]));return{...e,assets:e.assets.map(n=>{if(n.type!=="glb")return structuredClone(n);let o=r.get(n.id);if(!o)throw new Error(`asset.catalog.missing: ${n.id}`);let a=o.guid??n.guid;return{id:n.id,...a?{guid:a}:{},type:"glb"}})}}function wa(e,t){let r=new Map(t.map(o=>[o.assetId,o])),n=new Map(t.filter(o=>o.type==="glb").map(o=>[o.assetId,o]));for(let o of e.assets){if(o.type!=="glb")continue;let a=n.get(o.id);if(!a)throw new Error(`asset.catalog.missing: ${o.id}`);RM(o,a),OM(o,a),kM(a)}for(let o of Bb(e)){if(o.kind!=="material.textureAssetId")continue;let a=r.get(o.assetId);if(!a||a.kind!=="texture"&&a.type!=="texture")throw new Error(`asset.catalog.missing: ${o.assetId} at ${o.path}`)}}function Bb(e){let t=[],r=(o,a)=>{let i=Ve(a);i&&t.push({assetId:i,...o})};for(let o=0;o<e.scene.gameObjects.length;o+=1){let a=e.scene.gameObjects[o];for(let i=0;i<a.components.length;i+=1){let s=a.components[i];s.type!=="ModelRenderer"&&s.type!=="ImageRenderer"||r({scope:"scene-object",kind:`${s.type}.assetId`,path:`scene.gameObjects[${o}].components[${i}].assetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},s.assetId)}r({scope:"scene-object",kind:"prefab.prefabId",path:`scene.gameObjects[${o}].prefab.prefabId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.prefabId),r({scope:"scene-object",kind:"prefab.sourceAssetId",path:`scene.gameObjects[${o}].prefab.sourceAssetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.sourceAssetId),So(a.overrides,`scene.gameObjects[${o}].overrides`,(i,s)=>r({scope:"scene-object",kind:"material.textureAssetId",path:i,objectId:a.id,...a.name?{objectName:a.name}:{}},s))}for(let o=0;o<e.assets.length;o+=1){let a=e.assets[o];if(!a.prefab)continue;let i=`assets[${o}].prefab`;r({scope:"prefab-asset",kind:"prefab.sourceAssetId",path:`${i}.sourceAssetId`,prefabAssetId:a.id},a.prefab.sourceAssetId),So(a.prefab.overrides,`${i}.overrides`,(c,d)=>r({scope:"prefab-asset",kind:"material.textureAssetId",path:c,prefabAssetId:a.id},d));let s=Ze(a);for(let c=0;c<s.length;c+=1){let d=s[c],u=`${i}.nodes[${c}]`;r({scope:"prefab-node",kind:"node.sourceAssetId",path:`${u}.sourceAssetId`,prefabAssetId:a.id,nodeId:d.id},d.sourceAssetId),r({scope:"prefab-node",kind:"node.childPrefabId",path:`${u}.childPrefabId`,prefabAssetId:a.id,nodeId:d.id},d.childPrefabId),So(d.overrides,`${u}.overrides`,(l,m)=>r({scope:"prefab-node",kind:"material.textureAssetId",path:l,prefabAssetId:a.id,nodeId:d.id},m))}}let n=Array.isArray(e.scene.materialAssets)?e.scene.materialAssets:[];for(let o=0;o<n.length;o+=1){let a=n[o],i=Ve(a.id)??"";r({scope:"material-asset",kind:"origin.sourceAssetId",path:`scene.materialAssets[${o}].origin.sourceAssetId`,materialAssetId:i},ct(a.origin)?.sourceAssetId),So(a.properties,`scene.materialAssets[${o}].properties`,(s,c)=>r({scope:"material-asset",kind:"material.textureAssetId",path:s,materialAssetId:i},c))}return t.sort((o,a)=>o.path.localeCompare(a.path))}function kM(e){let t=ct(e.metadata),r=ct(e.external);if(!(Ve(t?.url)??Ve(t?.relativePath)??Ve(r?.assetUrl)))throw new Error(`asset.catalog.incomplete: ${e.assetId}.url`);let o=ct(t?.assetAnalysis),a=t?.assetAnalysisStatus==="unavailable";if(!o&&!a)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.assetAnalysisStatus`);let i=new Map((Array.isArray(o?.meshes)?o.meshes:[]).flatMap(c=>{let d=ct(c),u=d?.meshIndex,l=Number.isInteger(u)?u:void 0,m=Ve(d?.name);return l==null||!m?[]:[[l,m]]})),s=Array.isArray(t?.materialSlots)?t.materialSlots:[];for(let[c,d]of s.entries()){let u=ct(d);if(!u)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}]`);let l=Number.isInteger(u.meshIndex)?u.meshIndex:void 0;if(l!=null&&!Ve(u.sourceMeshName)&&!i.has(l))throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}].sourceMeshName`)}}function OM(e,t){let r=ct(e.metadata),n=ct(t.metadata),o=ct(e.external),a=ct(t.external),i=Ve(r?.url)??Ve(r?.relativePath)??Ve(o?.assetUrl),s=Ve(n?.url)??Ve(n?.relativePath)??Ve(a?.assetUrl);if(i&&!s)throw new Error(`asset.catalog.incomplete: ${e.id}.url`);for(let c of["materialSlots","assetAnalysis"])if(r?.[c]!==void 0&&n?.[c]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.metadata.${c}`)}function RM(e,t){for(let r of["materialMode","defaults","external","warmupCount","singleton"])if(e[r]!==void 0&&t[r]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.${r}`)}function $r(e,t){return{...e,guid:t.guid??e.guid,displayName:t.displayName||e.displayName,category:t.category??e.category,warmupCount:t.warmupCount??e.warmupCount,singleton:t.singleton??e.singleton,materialMode:t.materialMode??e.materialMode,defaults:Fs(t.defaults??e.defaults),prefab:Fs(t.prefab??e.prefab),external:Fs(t.external??e.external),metadata:Fs(t.metadata??e.metadata)}}function Fs(e){return e==null?void 0:structuredClone(e)}function So(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>So(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):So(o,a,r)}}}function ct(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ve(e){return(typeof e=="string"?e.trim():"")||void 0}function ka(e,t=[]){return e?.system?.readonly===!0||e?.system?.preset==="default-pbr"||e?.system?.preset==="default-standard"||!!e&&t.includes(e.id)}function CM(e){let t=structuredClone(e??{});return In(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,In(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,In(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,In(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(In(t.emission,"texture"),In(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),In(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function In(e,t){if(!e)return;let r=e,n=r[t];if(n===null||!n||typeof n!="object"||Array.isArray(n))return;let o=n,a=typeof o.url=="string"?o.url.trim():"",i=typeof o.textureAssetId=="string"?o.textureAssetId.trim():"";a?o.url=a:delete o.url,i?o.textureAssetId=i:delete o.textureAssetId,Object.keys(o).length===0&&delete r[t]}function Vb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=rt(t,r);if(a?!no(e.shaderId,t)||!zt(t,null,e.shaderId,n):!zt(t,i,e.shaderId,n))return e;let s=structuredClone(e);if(t==="name")return typeof i!="string"?e:(s.name=i.trim(),s.name===e.name?e:s);if(!t.startsWith("properties."))return e;let c=t.slice(11);return!c||(s.properties=structuredClone(s.properties),vM(s.properties,c,i,a)||Oe(s.properties,c,i),De(s.shaderId)&&(s.properties=CM(s.properties)),eo(s.shaderId,s.properties,"properties",n).length>0)||JSON.stringify(s)===JSON.stringify(e)?e:s}function vM(e,t,r,n){let o=t.endsWith(".textureAssetId")?"textureAssetId":t.endsWith(".url")?"url":null;if(!o)return!1;let a=t.slice(0,-`.${o}`.length);if(!a.endsWith(".texture")&&!a.endsWith(".maskTexture"))return!1;let i=a.split(".").filter(Boolean);if(i.length<2)return!1;let s=i[i.length-1],c=e;for(let l of i.slice(0,-1)){let m=c[l];if(!m||typeof m!="object"||Array.isArray(m)){if(n)return!0;let f={};c[l]=f,c=f;continue}c=m}if(n)return delete c[s],!0;if(r==null)return c[s]=null,!0;let d=c[s],u=d&&typeof d=="object"&&!Array.isArray(d)?{...d}:{};return u[o]=r,delete u[o==="url"?"textureAssetId":"url"],c[s]=u,!0}var Pn="mat_default_pbr",yo="mat_default_standard",GM="00000000-0000-4000-8000-000000000001",jM="00000000-0000-4000-8000-000000000002",Tn=Pn,xn={id:Pn,guid:GM,name:"Default PBR Material",shaderId:"fps.builtin.pbr",definitionVersion:1,system:{readonly:!0,preset:"default-pbr"},origin:{type:"preset"},properties:Cd("fps.builtin.pbr")},NM={id:yo,guid:jM,name:"Default Standard Material",shaderId:"fps.builtin.standard",definitionVersion:1,system:{readonly:!0,preset:"default-standard"},origin:{type:"preset"},properties:Cd("fps.builtin.standard")};function FM(){return structuredClone(xn)}function _M(){return structuredClone(NM)}function Ub(e){let t=[FM(),_M()],r=new Set(t.map(o=>o.id)),n=[...t,...e.filter(o=>!r.has(o.id))];return JSON.stringify(n)===JSON.stringify(e)?e:n}function Kb(e){return e?.system?.preset==="default-pbr"||e?.id===Pn?"default-pbr":e?.system?.preset==="default-standard"||e?.id===yo?"default-standard":null}function Oa(e){let t=structuredClone(xn.properties);if(!e||typeof e!="object")return t;let r={...t,...structuredClone(e)};return r.baseColor={...t.baseColor??{},...e.baseColor??{}},(t.normal||e.normal)&&(r.normal={...t.normal??{},...e.normal??{}}),(t.metallicRoughness||e.metallicRoughness)&&(r.metallicRoughness={...t.metallicRoughness??{},...e.metallicRoughness??{}}),(t.occlusion||e.occlusion)&&(r.occlusion={...t.occlusion??{},...e.occlusion??{}}),r.emission={...t.emission??{},...e.emission??{}},(t.alpha||e.alpha)&&(r.alpha={...t.alpha??{},...e.alpha??{}}),r}function An(e,t){let r=[...new Set(e.sourceSurfaces.map(s=>s.sourceMaterialIndex).filter(s=>Number.isInteger(s)))],n=e.materialNames??[],o=r.findIndex(s=>s===t),a=o>=0?n[o]??(r.length===1?e.materialName:null):null;if(typeof a=="string"&&a.trim())return a.trim();let i=ho(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function ho(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var eu=[Pn,yo],$M="New Material";function Hb(e,t,r=`${t.displayName} Material`){let n=Ra(e);return{id:lr(n),guid:n,name:_s(e,r),shaderId:t.shaderId,definitionVersion:t.version,origin:{type:"created"},properties:structuredClone(t.defaultProperties)}}function LM(e,t,r){let n=t.name?.trim()||t.id,o=r.name?.trim()||r.id,a=Ra(e);return{id:lr(a),guid:a,name:`${n} - ${o}`,shaderId:r.shaderId,...r.definitionVersion!=null?{definitionVersion:r.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:r.id},properties:structuredClone(r.properties)}}function Wb(e,t,r){let n=t.name?.trim()||t.id,o=Ra(e);return{id:lr(o),guid:o,name:_s(e,r??`${n} Copy`),shaderId:t.shaderId,...t.definitionVersion!=null?{definitionVersion:t.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:t.id},properties:structuredClone(t.properties)}}function zM(e,t){let r=Ra(e);return{id:lr(r),guid:r,name:_s(e,t.name),shaderId:xn.shaderId,definitionVersion:xn.definitionVersion,origin:{type:"created",...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:Oa(t.profile)}}function qb(e,t){let r=`${t.sourceAssetGuid||t.sourceAssetId}:material:${t.sourceMaterialIndex}`,n=Np(r),o=lr(n),i=(e.scene.materialAssets??[]).some(s=>s.id===o||s.guid===n)?Ra(e):n;return{id:lr(i),guid:i,name:_s(e,t.name),shaderId:xn.shaderId,definitionVersion:xn.definitionVersion,origin:{type:"imported",sourceAssetId:t.sourceAssetId,...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},...t.sourceSlotId?{sourceSlotId:t.sourceSlotId}:{},sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:Oa(t.profile)}}function Jb(e,t,r){let n=t.trim(),o=e.scene.materialAssets?.findIndex(s=>s.id===n)??-1;if(o<0||r.id!==n)return e;let a=e.scene.materialAssets[o];if(JSON.stringify(a)===JSON.stringify(r))return e;let i=[...e.scene.materialAssets];return i[o]=structuredClone(r),{...e,scene:{...e.scene,materialAssets:i}}}function Ra(e){let t=new Set((e.scene.materialAssets??[]).map(o=>o.id)),r=el(),n=lr(r);for(;t.has(n);)r=el(),n=lr(r);return r}function _s(e,t){let r=rt("name",t),n=typeof r=="string"&&zt("name",r)?r:$M,o=new Set((e.scene.materialAssets??[]).map(s=>s.name?.trim()).filter(s=>!!s).map(s=>s.toLocaleLowerCase()));if(!o.has(n.toLocaleLowerCase()))return n;let a=2,i=`${n} ${a}`;for(;o.has(i.toLocaleLowerCase());)a+=1,i=`${n} ${a}`;return i}function Xb(e){let t=ee(e.document,e.sourceMaterialAssetId);if(!t||e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let r=LM(e.document,e.gameObject,t);return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function Yb(e){if(e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let t=`${e.gameObject.name?.trim()||e.gameObject.id} - ${e.sourceSlotId}`,r=zM(e.document,{profile:e.profile,name:e.sourceMaterialName?.trim()||t,...e.sourceAsset?.id?{sourceAssetId:e.sourceAsset.id}:{},...e.sourceAsset?.guid?{sourceAssetGuid:e.sourceAsset.guid}:{},sourceSlotId:e.sourceSlotId,sourceMaterialIndex:e.sourceMaterialIndex,...e.sourceMaterialName?.trim()?{sourceMaterialName:e.sourceMaterialName.trim()}:{}});return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function $s(e,t,r,n,o,a){let i=e.scene.materialAssets??[],s=!1,c=i.map(d=>{if(d.id!==t)return d;let u=Vb(d,r,rt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function Zb(e,t,r=[]){let n=ee(e,t),o=nl(e,t);return n?ka(n,r)?{ok:!1,reason:"readonly",materialAsset:n,usages:o}:o.length>0?{ok:!1,reason:"in-use",materialAsset:n,usages:o}:{ok:!0,materialAsset:n,usages:o}:{ok:!1,reason:"missing",usages:o}}function Qb(e,t){return Zb(e,t,eu)}function BM(e,t,r=[]){return Zb(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function tu(e){return ka(e,eu)}function eS(e,t){return BM(e,t,eu)}function Ls(e,t){return Vt(e,t.id)?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(t)]}}}function tS(e,t,r,n){return Vt(e,n.id)?e:VM({...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(n)]}},t,r,n.id)}function VM(e,t,r,n){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(o=>{if(o.id!==t)return o;let a=structuredClone(o);return UM(a,r,n),a})}}}function UM(e,t,r){let n=KM(t)??t.split(".").filter(Boolean);if(n.some(HM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function KM(e){let t=Lt(e,"materialAssetId");return t?["overrides","materialSlotBindings",t,"materialAssetId"]:null}function HM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Bs(e,t){let r=Se(t),n=r?e.assets.find(g=>g.id===r.assetId):null,o=typeof n?.guid=="string"&&n.guid.trim()?n.guid.trim():n?.id,a=is(e,t),i=new Map(a.filter(g=>!!g.slotId).map(g=>[g.slotId,g])),s=t.overrides?.materialSlotBindings??{},c=WM({document:e,assetId:n?.id,assetGuid:o,currentSlots:a,materialSlotBindings:s}),d=c.remaps,u=new Map(d.map(g=>[g.toSlotId,g])),l=new Set([...d.map(g=>g.fromSlotId),...c.coalescedSourceSlotIds]),m=new Map;for(let[g,b]of Object.entries(s))!b||l.has(g)||m.set(g,b);for(let g of d){let b=s[g.fromSlotId];b&&m.set(g.toSlotId,b)}let f=[];for(let[g,b]of a.entries()){let y=b.slotId?m.get(b.slotId):void 0,I=Eo(y),E=I?ee(e,I):null,T=nS(b),A=T[0],$=b.slotId?u.get(b.slotId):void 0;if($){f.push({status:"changed",reason:"slot-remapped",...b.slotId?{slotId:b.slotId}:{},previousSlotId:$.fromSlotId,ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},materialAssetId:I,bindingPath:`overrides.materialSlotBindings.${b.slotId}.materialAssetId`,conflict:!1});continue}let z=oS(E,o,n?.id)?.sourceMaterialIndex;if(z!=null&&T.length>0&&!T.includes(z)){f.push(rS({status:"changed",reason:"source-material-changed",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},previousSourceMaterialIndex:z,...I?{materialAssetId:I}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:""}));continue}if(!I&&T.length>0){f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1});continue}f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},...I?{materialAssetId:I}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1})}for(let[g,b]of Object.entries(s))!b||i.has(g)||l.has(g)||f.push(rS({status:"removed",reason:"slot-removed",slotId:g,...Eo(b)?{materialAssetId:Eo(b)}:{},bindingPath:`overrides.materialSlotBindings.${g}.materialAssetId`}));let S=f.filter(JM);return{gameObjectId:t.id,...t.name?{gameObjectName:t.name}:{},...n?.id?{assetId:n.id}:{},...o?{assetGuid:o}:{},ok:S.length===0,items:f,issues:S,bindingRemaps:d,bindingRemapIssues:c.issues,counts:XM(f)}}function WM(e){let t=new Set(e.currentSlots.map(d=>d.slotId).filter(d=>!!d)),r=new Set(Object.keys(e.materialSlotBindings).filter(d=>t.has(d))),n=[],o=[],a=new Map;for(let[d,u]of Object.entries(e.materialSlotBindings)){if(!u||t.has(d))continue;let l=Eo(u),m=l?ee(e.document,l):null,f=oS(m,e.assetGuid,e.assetId);if(!f){o.push({fromSlotId:d,materialAssetId:l,reason:"binding-unmatched",candidateSlotIds:[]});continue}let S=e.currentSlots.filter(g=>!!g.slotId&&nS(g).includes(f.sourceMaterialIndex)).map(g=>g.slotId);a.set(d,{materialAssetId:l,candidateSlotIds:S,binding:u,anchored:f.sourceSlotId===d})}let i=new Map;for(let[d,u]of a){if(u.candidateSlotIds.length!==1)continue;let[l]=u.candidateSlotIds,m=i.get(l)??[];m.push(d),i.set(l,m)}let s=new Set,c=new Set;for(let[d,u]of i){u.forEach(g=>c.add(g));let l=u.filter(g=>a.get(g)?.anchored).sort((g,b)=>g.localeCompare(b));if(l.length===0){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-unmatched",candidateSlotIds:[]})}continue}let m=l[0],f=a.get(m);if(!u.every(g=>qM(f.binding,a.get(g).binding))||r.has(d)){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-ambiguous",candidateSlotIds:[d]})}continue}r.add(d),n.push({fromSlotId:m,toSlotId:d,materialAssetId:f.materialAssetId,reason:"source-material-index",...u.length>1?{coalescedFromSlotIds:u.filter(g=>g!==m).sort((g,b)=>g.localeCompare(b))}:{}});for(let g of u)g!==m&&s.add(g)}for(let[d,u]of a)c.has(d)||o.push({fromSlotId:d,materialAssetId:u.materialAssetId,reason:u.anchored&&u.candidateSlotIds.length>0?"binding-ambiguous":"binding-unmatched",candidateSlotIds:u.anchored?u.candidateSlotIds:[]});return{remaps:n,issues:o,coalescedSourceSlotIds:[...s].sort((d,u)=>d.localeCompare(u))}}function qM(e,t){return Eo(e)===Eo(t)&&ru(e.override,t.override)}function ru(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>ru(i,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let r=e,n=t,o=Object.keys(r).sort(),a=Object.keys(n).sort();return o.length===a.length&&o.every((i,s)=>i===a[s]&&ru(r[i],n[i]))}function nS(e){return nt(e)}function oS(e,t,r){if(e?.origin?.type!=="imported")return null;let n=e.origin.sourceMaterialIndex;if(typeof n!="number"||!Number.isInteger(n))return null;let o=e.origin.sourceAssetGuid,a=e.origin.sourceAssetId;if((o||a)&&!(!!t&&!!o&&o===t)&&!(!!r&&!!a&&a===r)||!o&&!a&&(t||r))return null;let c=typeof e.origin.sourceSlotId=="string"&&e.origin.sourceSlotId.trim()?e.origin.sourceSlotId.trim():void 0;return{sourceMaterialIndex:n,...c?{sourceSlotId:c}:{}}}function zs(e,t){return e.label?.trim()||Ut(e)?.trim()||e.slotId?.trim()||`Slot ${t+1}`}function Eo(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function rS(e){return{...e,conflict:!0}}function JM(e){return e.conflict}function XM(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{unchanged:0,added:0,removed:0,changed:0,conflict:0})}function Vs(e){let t=os(e);if(t.ok)return;let r=new Error(`editor_scene_material_assets_missing: ${t.missingMaterialAssetIds.join(", ")}`);throw r.details={missingMaterialAssetIds:t.missingMaterialAssetIds,missingReferences:t.missingReferences.map(n=>({materialAssetId:n.materialAssetId,gameObjectId:n.gameObjectId,bindingPath:n.bindingPath,label:n.label,kind:n.kind,...n.slotId?{slotId:n.slotId}:{},...n.ownerNodePath?{ownerNodePath:n.ownerNodePath}:{}}))},r}function YM(e,t){let r=!1;return{gameObjects:t.map(o=>{let a=Bs(e,o);if(a.bindingRemaps.length===0)return o;let i=o;for(let s of a.bindingRemaps){let c=i.overrides?.materialSlotBindings?.[s.fromSlotId];if(!(!c||i.overrides?.materialSlotBindings?.[s.toSlotId])){i=structuredClone(i),i.overrides=i.overrides??{},i.overrides.materialSlotBindings=i.overrides.materialSlotBindings??{},i.overrides.materialSlotBindings[s.toSlotId]=structuredClone(c),delete i.overrides.materialSlotBindings[s.fromSlotId];for(let d of s.coalescedFromSlotIds??[])delete i.overrides.materialSlotBindings[d];Object.keys(i.overrides.materialSlotBindings).length===0&&delete i.overrides.materialSlotBindings,r=!0}}return i}),changed:r}}function aS(e,t,r){let n=YM({...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},r);return{materialAssets:t,gameObjects:n.gameObjects,changed:n.changed}}function iS(e,t){let r=cS(t);if(r.length===0)return ZM(e);let n={};for(let a of e.scene.materialAssets??[]){let i=a.origin;if(!i||!Number.isInteger(i.sourceMaterialIndex))continue;(i.sourceAssetGuid&&t.guid?i.sourceAssetGuid===t.guid:i.sourceAssetId===t.assetId)&&(n[String(i.sourceMaterialIndex)]=a.id)}let o=[];for(let a of r)for(let i of a.sourceMaterialProfiles??[]){let s=String(i.sourceMaterialIndex);if(n[s]||!i.profile)continue;let c=o.length===0?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},d=qb(c,{profile:i.profile,name:i.materialName?.trim()||`${t.displayName} Material ${i.sourceMaterialIndex+1}`,sourceAssetId:t.assetId,...t.guid?{sourceAssetGuid:t.guid}:{},sourceSlotId:a.slotId,sourceMaterialIndex:i.sourceMaterialIndex,...i.materialName?.trim()?{sourceMaterialName:i.materialName.trim()}:{}});o.push(d),n[s]=d.id}return o.length===0?{document:e,createdMaterialAssetIds:[],materialAssetIdsBySourceMaterialIndex:n}:{document:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},createdMaterialAssetIds:o.map(a=>a.id),materialAssetIdsBySourceMaterialIndex:n}}function sS(e,t,r){let n={};for(let o of cS(t)){let a=nt(o);if(a.length!==1)continue;let i=r[String(a[0])];i&&(n[o.slotId]={materialAssetId:i})}return Object.keys(n).length===0?e:{...e,overrides:{...e.overrides??{},materialSlotBindings:{...e.overrides?.materialSlotBindings??{},...n}}}}function cS(e){if(e.type!=="glb"&&e.type!=="gltf")return[];let t=e.metadata?.materialSlots;return Array.isArray(t)?t.map(Or).filter(r=>!!r):[]}function ZM(e){return{document:e,createdMaterialAssetIds:[],materialAssetIdsBySourceMaterialIndex:{}}}function dS(e,t){let r=new Set,n=e.properties,o=Dn(n)?n:{},a=Dn(t.defaultProperties)?t.defaultProperties:{},i=lS(t.propertiesSchema,o,a,"properties",r),s=new Set;uS(o,"properties",s);let c=[...s].filter(d=>!r.has(d)).sort();return{materialAsset:{...structuredClone(e),shaderId:t.shaderId,definitionVersion:t.version,properties:i},preservedPaths:[...r].sort(),resetPaths:c}}function lS(e,t,r,n,o){if(e.kind!=="object")return QM(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=Dn(t)?t:{},i=Dn(r)?r:{},s={};for(let[c,d]of Object.entries(e.properties)){let u=Object.prototype.hasOwnProperty.call(a,c),l=Object.prototype.hasOwnProperty.call(i,c);if(!u&&!l)continue;let m=lS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function QM(e,t){if(e.kind==="number")return typeof t=="number"&&Number.isFinite(t)&&(e.min==null||t>=e.min)&&(e.max==null||t<=e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"||t===null&&e.nullable===!0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return nu(t,e.channels===4?["r","g","b","a"]:["r","g","b"]);if(e.kind==="vec2")return nu(t,["x","y"]);if(e.kind==="vec3")return nu(t,["x","y","z"]);if(t===null)return!0;if(!Dn(t))return!1;let r=Object.keys(t);return r.every(n=>n==="url"||n==="textureAssetId")&&r.every(n=>typeof t[n]=="string"&&!!t[n].trim())}function uS(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;Dn(o)&&!ew(o)?uS(o,a,r):r.add(a)}}function ew(e){let t=Object.keys(e);return t.length===0?!0:t.every(r=>["r","g","b","a"].includes(r))||t.every(r=>["x","y","z"].includes(r))||t.every(r=>r==="url"||r==="textureAssetId")}function nu(e,t){return Dn(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function Dn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function tw(e){return e?.system?.preset}function fS(e,t){let r=tw(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Us(e,t){let r=t.trim();return r?e?.find(n=>n.url===r||n.id===r)??null:null}function mS(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function pS(e){let t=e.currentTexture??Us(e.textureAssets,e.currentValue),r=e.currentValue.trim(),n=!!r&&!t,o=!!t&&!t.disabled&&!!t.url.trim(),a=n?"missing":t?o?"ready":"failed":void 0,i=e.candidateValue??"url",s=(e.textureAssets??[]).filter(rw);return{pickerKind:"texture",pickerTitle:e.pickerText.texturePickerTitle,pickerTrigger:"preview",placeholder:e.pickerText.emptyTexture,currentLabel:n?e.pickerText.missingTexture:t?.label??(r||e.pickerText.emptyTexture),currentMeta:n?`${e.pickerText.missingTextureMeta} \xB7 ${r}`:t?.previewUnavailableReason??t?.meta??(r||e.pickerText.emptyTextureMeta),...a?{currentResourceState:a}:{},...r?{currentResourceReference:r}:{},resourceStatusText:{missing:e.pickerText.missingTexture,loading:e.pickerText.loadingTexture,failed:e.pickerText.failedTexture},currentPreview:o?mS(t,e.pickerText):void 0,candidates:[{label:e.pickerText.clearTexture,value:"",meta:e.pickerText.clearTextureMeta},...s.map(c=>({label:c.label,value:i==="assetId"?c.id:c.url,meta:c.meta??c.id,kind:"texture",...typeof c.width=="number"?{width:c.width}:{},...typeof c.height=="number"?{height:c.height}:{},...!c.disabled&&c.url.trim()?{preview:mS(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function rw(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function gS(e){return{path:`${e.pathPrefix??dr}${e.materialAsset.id}.${e.fieldPath}`,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.commitMode,order:e.order,tooltip:e.tooltip,tags:e.tags??["ArtistMaterial","MaterialAsset"],document:e.document}}var bS={zh:{title:"\u7F8E\u672F\u6750\u8D28",slotTitle:"\u6750\u8D28\u63D2\u69FD",language:"\u8BED\u8A00",materialAsset:"\u6750\u8D28\u8D44\u4EA7",materialCard:"\u5F53\u524D\u6750\u8D28",inheritNone:"\u7EE7\u627F / \u65E0",defaultMaterial:"\u9ED8\u8BA4 PBR \u6750\u8D28",defaultMaterialMeta:"BabylonJS \u9ED8\u8BA4 PBR \u6750\u8D28",defaultStandardMaterial:"\u9ED8\u8BA4 Standard \u6750\u8D28",defaultStandardMaterialMeta:"BabylonJS \u9ED8\u8BA4 Standard \u6750\u8D28",defaultMaterialReadOnly:"\u7CFB\u7EDF\u9ED8\u8BA4\u6750\u8D28\u4E3A\u53EA\u8BFB\uFF1B\u8BF7\u9009\u62E9\u53EF\u7F16\u8F91\u6750\u8D28\u7403\u540E\u8C03\u6574\u53C2\u6570\u3002",replace:"\u66FF\u6362",batchReplaceUnsupported:"\u591A\u9009\u7EDF\u4E00\u66FF\u6362\u6750\u8D28\u6682\u672A\u63A5\u5165\uFF1B\u8BF7\u5148\u5355\u9009\u5BF9\u8C61\u66FF\u6362\u6750\u8D28\u3002",duplicateForObject:"\u590D\u5236",materialPickerTitle:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7",texturePickerTitle:"\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",emptyTexture:"\u9009\u62E9\u8D34\u56FE",emptyTextureMeta:"\u70B9\u51FB\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",inheritTexture:"\u7EE7\u627F\u6E90\u8D34\u56FE",inheritTextureMeta:"\u4F7F\u7528 GLB / source material \u8D34\u56FE\uFF08\u82E5\u5B58\u5728\uFF09",clearTexture:"\u6E05\u9664\u8D34\u56FE",clearTextureMeta:"\u4E0D\u4F7F\u7528\u8D34\u56FE",missingTexture:"\u8D34\u56FE\u8D44\u4EA7\u7F3A\u5931",missingTextureMeta:"\u5F53\u524D\u5F15\u7528\u65E0\u6CD5\u5728\u9879\u76EE\u8D44\u4EA7\u5E93\u4E2D\u89E3\u6790",loadingTexture:"\u6B63\u5728\u52A0\u8F7D\u8D34\u56FE",failedTexture:"\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25",assetProfile:"\u8D44\u4EA7\u53C2\u6570",assetProfileEmpty:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u540E\u53EF\u7F16\u8F91\u8D44\u4EA7\u53C2\u6570",assetName:"\u8D44\u4EA7\u540D\u79F0",assetKind:"Shader",assetKindPbr:"PBR \u6807\u51C6\u6750\u8D28\u7403",assetKindStandard:"Standard \u6807\u51C6\u6750\u8D28\u7403",assetLightingModel:"\u5149\u7167\u6A21\u578B",assetLightingModelLit:"\u53D7\u5149\u7167",assetLightingModelUnlit:"\u4E0D\u53D7\u5149\u7167",assetBaseColor:"\u57FA\u7840\u8272",assetBaseTexture:"\u57FA\u7840\u8D34\u56FE",assetBrightness:"\u8D34\u56FE\u4EAE\u5EA6",assetSaturation:"\u8D34\u56FE\u9971\u548C\u5EA6",assetContrast:"\u8D34\u56FE\u5BF9\u6BD4\u5EA6",assetHue:"\u8D34\u56FE\u8272\u76F8",assetNormalTexture:"\u6CD5\u7EBF\u8D34\u56FE",assetNormalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6",assetMetallic:"\u91D1\u5C5E\u5EA6",assetRoughness:"\u7C97\u7CD9\u5EA6",assetMetallicRoughnessTexture:"\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE",assetOcclusionTexture:"AO \u8D34\u56FE",assetOcclusionStrength:"AO \u5F3A\u5EA6",resetValue:"\u6062\u590D Shader \u9ED8\u8BA4\u503C",modifiedValue:"\u5DF2\u504F\u79BB Shader \u9ED8\u8BA4\u503C",inactiveReasons:{baseTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u57FA\u7840\u8D34\u56FE\u65F6\u751F\u6548\u3002",litMaterial:"\u4EC5\u5728\u201C\u53D7\u5149\u7167\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",normalTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\u65F6\u751F\u6548\u3002",occlusionTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9 AO \u8D34\u56FE\u65F6\u751F\u6548\u3002",alphaBlend:"\u4EC5\u5728\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaMask:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaTransparency:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6216\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002"},assetEmissionColor:"\u81EA\u53D1\u5149\u8272",assetEmissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6",assetEmissionTexture:"\u81EA\u53D1\u5149\u8D34\u56FE",assetEmissionMaskUrl:"\u906E\u7F69\u8D34\u56FE",assetAlphaMode:"\u900F\u660E\u6A21\u5F0F",assetAlphaModeOpaque:"\u4E0D\u900F\u660E",assetAlphaModeMask:"\u906E\u7F69",assetAlphaModeBlend:"\u534A\u900F\u660E",assetAlphaOpacity:"\u4E0D\u900F\u660E\u5EA6",assetAlphaCutoff:"Alpha \u9608\u503C",assetAlphaTexture:"Alpha \u8D34\u56FE",createSlotMaterial:"\u6DFB\u52A0\u6750\u8D28\u69FD",slotList:"\u69FD\u5217\u8868",slotId:"\u69FD ID",slotOwnerPath:"\u69FD\u8282\u70B9\u8DEF\u5F84",slotMaterialAsset:"\u69FD\u6750\u8D28\u8D44\u4EA7",slotSourceMaterial:"\u6E90\u6750\u8D28",slotBindingPath:"\u7ED1\u5B9A\u8DEF\u5F84",reimportConflicts:"\u91CD\u5BFC\u5165\u6750\u8D28\u51B2\u7A81",summaryAsset:e=>`\u8D44\u4EA7\uFF1A${e}`,summaryMissingAsset:"\u8D44\u4EA7\u7F3A\u5931",summaryCustomOverride:"\u81EA\u5B9A\u4E49\u53C2\u6570",summaryInherit:"\u7EE7\u627F",summaryAddSlot:"\u6DFB\u52A0\u69FD",summarySlotCount:e=>`${e} \u4E2A\u69FD`,formatUsageCount:e=>e>0?`\u88AB ${e} \u5904\u4F7F\u7528`:"\u672A\u88AB\u4F7F\u7528",formatMaterialEditImpact:e=>e<=0?"\u5F53\u524D\u672A\u88AB\u573A\u666F\u4F7F\u7528\uFF0C\u4FEE\u6539\u53EA\u4F1A\u6539\u53D8\u6750\u8D28\u8D44\u4EA7\u672C\u8EAB\u3002":e===1?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u5F53\u524D\u7ED1\u5B9A\u3002":`\u5171\u4EAB\u6750\u8D28\uFF0C\u4FEE\u6539\u4F1A\u5F71\u54CD ${e} \u5904\u7ED1\u5B9A\u3002`,formatDuplicateMaterialImpact:e=>e<=0?"\u590D\u5236\u540E\u521B\u5EFA\u4E00\u4E2A\u53EF\u72EC\u7ACB\u7F16\u8F91\u7684\u6750\u8D28\u8D44\u4EA7\u3002":e===1?"\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\u3002":`\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\uFF0C\u539F ${e} \u5904\u5171\u4EAB\u7ED1\u5B9A\u4E0D\u88AB\u7EE7\u7EED\u4FEE\u6539\u3002`,formatReimportConflictSummary:e=>`\u68C0\u6D4B\u5230 ${e} \u4E2A\u6750\u8D28\u69FD\u91CD\u5BFC\u5165\u5DEE\u5F02\uFF1B\u5DF2\u4FDD\u7559\u73B0\u6709\u7ED1\u5B9A\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4\u4E0D\u53EF\u5339\u914D\u9879\u3002`,tooltips:{language:"\u5207\u6362\u7F8E\u672F\u6750\u8D28 Inspector \u7684\u663E\u793A\u8BED\u8A00\u3002",materialAsset:"\u9009\u62E9\u9879\u76EE\u7EA7\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\uFF0C\u6216\u4F7F\u7528\u53EA\u8BFB\u7684\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotMaterialAsset:"\u672A\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u65F6\u4FDD\u7559 GLB \u539F\u59CB\u6750\u8D28\uFF1B\u9009\u62E9\u540E\u53EA\u8986\u76D6\u5F53\u524D\u6750\u8D28\u63D2\u69FD\u3002",baseTexture:"\u9009\u62E9\u9879\u76EE\u8D34\u56FE\u4F5C\u4E3A\u57FA\u7840\u8D34\u56FE\u3002\u8D34\u56FE\u8C03\u8272\u53C2\u6570\u4F1A\u5148\u4F5C\u7528\u4E8E\u8FD9\u5F20\u8D34\u56FE\u3002",assetProfile:"\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u7684\u53C2\u6570\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u8D44\u4EA7\u7684\u8282\u70B9\u3002",assetName:"\u6750\u8D28\u8D44\u4EA7\u540D\u79F0\u53EA\u7528\u4E8E\u5C55\u793A\uFF1B\u7ED1\u5B9A\u4F7F\u7528\u7A33\u5B9A\u6750\u8D28 ID\uFF0C\u4E0D\u53D7\u91CD\u547D\u540D\u5F71\u54CD\u3002",assetKind:"\u9009\u62E9\u8BE5\u6750\u8D28\u5F15\u7528\u7684 Shader Definition\uFF1B\u5207\u6362\u65F6\u4F1A\u4FDD\u7559\u517C\u5BB9\u53C2\u6570\u3002",lightingModel:"\u53D7\u5149\u7167\u6750\u8D28\u4F1A\u54CD\u5E94\u73AF\u5883\u5149\u548C\u76F4\u5C04\u5149\uFF1B\u4E0D\u53D7\u5149\u7167\u6750\u8D28\u9002\u5408 UI\u3001\u7279\u6548\u3001\u56FE\u6807\u548C\u5BFC\u89C6\u6807\u8BB0\u3002",baseColor:"\u57FA\u7840\u8272\u4F5C\u4E3A\u989C\u8272\u56E0\u5B50\uFF0C\u4F1A\u5728\u57FA\u7840\u8D34\u56FE\u5B8C\u6210\u8C03\u8272\u540E\u53C2\u4E0E\u76F8\u4E58\u3002\u4FEE\u6539\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u6750\u8D28\u7403\u7684\u8282\u70B9\u3002",duplicateForObject:"\u590D\u5236\u5F53\u524D\u6750\u8D28\u7403\u4E3A\u8FD9\u4E2A\u5BF9\u8C61\u6216\u69FD\u7684\u72EC\u7ACB\u6750\u8D28\uFF0C\u7136\u540E\u81EA\u52A8\u66FF\u6362\u7ED1\u5B9A\u3002",brightness:"\u57FA\u7840\u8D34\u56FE\u4EAE\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",saturation:"\u57FA\u7840\u8D34\u56FE\u9971\u548C\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",contrast:"\u57FA\u7840\u8D34\u56FE\u5BF9\u6BD4\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",hue:"\u57FA\u7840\u8D34\u56FE\u8272\u76F8\u504F\u79FB\uFF0C\u5355\u4F4D\u4E3A\u5EA6\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",normalTexture:"\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\uFF0C\u8FD0\u884C\u65F6\u5E94\u7528\u5230 PBR/Standard \u6750\u8D28\u7684 bump/normal \u901A\u9053\u3002",normalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",metallic:"\u91D1\u5C5E\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",roughness:"\u7C97\u7CD9\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",metallicRoughnessTexture:"\u9009\u62E9\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE\u3002PBR \u8FD0\u884C\u65F6\u6309 GLB \u5E38\u7528\u7EA6\u5B9A\u8BFB\u53D6\u84DD\u8272\u91D1\u5C5E\u5EA6\u3001\u7EFF\u8272\u7C97\u7CD9\u5EA6\u3002",occlusionTexture:"\u9009\u62E9\u73AF\u5883\u906E\u853D AO \u8D34\u56FE\uFF0C\u53EA\u5BF9 PBR \u6750\u8D28\u751F\u6548\u3002",occlusionStrength:"AO \u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",emissionColor:"\u81EA\u53D1\u5149\u989C\u8272\uFF0C\u4F1A\u4E0E\u5F3A\u5EA6\u76F8\u4E58\u3002",emissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6\uFF0C0 \u8868\u793A\u65E0\u81EA\u53D1\u5149\u3002",emissionTexture:"\u9009\u62E9\u81EA\u53D1\u5149\u8D34\u56FE\uFF1B\u82E5\u672A\u8BBE\u7F6E\u5219\u517C\u5BB9\u4F7F\u7528\u65E7\u906E\u7F69\u8D34\u56FE\u3002",emissionMaskUrl:"\u9009\u62E9\u7070\u5EA6\u8D34\u56FE\u4F5C\u4E3A\u81EA\u53D1\u5149\u5F3A\u5EA6\u906E\u7F69\u3002",alphaMode:"\u900F\u660E\u6A21\u5F0F\uFF1A\u4E0D\u900F\u660E\u3001Alpha Test \u906E\u7F69\u6216 Alpha Blend \u534A\u900F\u660E\u3002",alphaOpacity:"\u6750\u8D28\u6574\u4F53\u4E0D\u900F\u660E\u5EA6\uFF0C1 \u4E3A\u5B8C\u5168\u4E0D\u900F\u660E\u3002",alphaCutoff:"\u906E\u7F69\u6A21\u5F0F\u7684 Alpha \u622A\u65AD\u9608\u503C\u3002",alphaTexture:"\u9009\u62E9 Alpha/Opacity \u8D34\u56FE\u3002",createSlotMaterial:"\u8F93\u5165 GLB \u5B50\u8282\u70B9\u6216 mesh \u7684 ownerNodePath \u6765\u6DFB\u52A0\u69FD\u7ED1\u5B9A\uFF0C\u521D\u59CB\u4F7F\u7528\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotList:"\u6839\u8282\u70B9\u4E0A\u7684\u6750\u8D28\u69FD\u4E3A\u53EA\u8BFB\u603B\u89C8\u3002",slotOwnerPath:"\u6750\u8D28\u69FD\u5B9A\u4F4D\u5230\u7684\u5B50\u8282\u70B9\u6216 mesh \u8DEF\u5F84\u3002",reimportConflicts:"\u6A21\u578B\u91CD\u5BFC\u5165\u540E\u65E0\u6CD5\u81EA\u52A8\u5339\u914D\u6216\u6E90\u6750\u8D28\u53D8\u5316\u7684\u69FD\u3002\u73B0\u6709\u7ED1\u5B9A\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u9759\u9ED8\u5220\u9664\u6216\u8986\u76D6\u3002"}},en:{title:"Artist Material",slotTitle:"Material Slots",language:"Language",materialAsset:"Material Asset",materialCard:"Current Material",inheritNone:"Inherit / None",defaultMaterial:"Default PBR Material",defaultMaterialMeta:"BabylonJS-style default PBR material",defaultStandardMaterial:"Default Standard Material",defaultStandardMaterialMeta:"BabylonJS-style default Standard material",defaultMaterialReadOnly:"The system default material is read-only. Choose an editable material asset to adjust parameters.",replace:"Replace",batchReplaceUnsupported:"Batch material replacement is not wired yet. Select one object to replace its material.",duplicateForObject:"Copy",materialPickerTitle:"Select Material Asset",texturePickerTitle:"Select Texture Asset",emptyTexture:"Select Texture",emptyTextureMeta:"Choose a texture asset",inheritTexture:"Inherit Source Texture",inheritTextureMeta:"Use the GLB / source material texture when available",clearTexture:"Clear Texture",clearTextureMeta:"Do not use a texture",missingTexture:"Missing texture asset",missingTextureMeta:"The current reference cannot be resolved in the project asset library",loadingTexture:"Loading texture",failedTexture:"Texture failed to load",assetProfile:"Asset Profile",assetProfileEmpty:"Select a material asset to edit asset parameters",assetName:"Asset Name",assetKind:"Shader",assetKindPbr:"PBR standard material",assetKindStandard:"Standard material",assetLightingModel:"Lighting Model",assetLightingModelLit:"Lit",assetLightingModelUnlit:"Unlit",assetBaseColor:"Base Color",assetBaseTexture:"Base Texture",assetBrightness:"Texture Brightness",assetSaturation:"Texture Saturation",assetContrast:"Texture Contrast",assetHue:"Texture Hue",assetNormalTexture:"Normal Texture",assetNormalStrength:"Normal Strength",assetMetallic:"Metallic",assetRoughness:"Roughness",assetMetallicRoughnessTexture:"Metallic-Roughness Texture",assetOcclusionTexture:"AO Texture",assetOcclusionStrength:"AO Strength",resetValue:"Reset to shader default",modifiedValue:"Modified from shader default",inactiveReasons:{baseTexture:"Available after assigning a base texture.",litMaterial:"Available only when the lighting model is Lit.",normalTexture:"Available after assigning a normal texture.",occlusionTexture:"Available after assigning an AO texture.",alphaBlend:"Available only in Blend alpha mode.",alphaMask:"Available only in Mask alpha mode.",alphaTransparency:"Available only in Mask or Blend alpha mode."},assetEmissionColor:"Emission Color",assetEmissionIntensity:"Emission Intensity",assetEmissionTexture:"Emission Texture",assetEmissionMaskUrl:"Mask Texture",assetAlphaMode:"Alpha Mode",assetAlphaModeOpaque:"Opaque",assetAlphaModeMask:"Mask",assetAlphaModeBlend:"Blend",assetAlphaOpacity:"Opacity",assetAlphaCutoff:"Alpha Cutoff",assetAlphaTexture:"Alpha Texture",createSlotMaterial:"Add Material Slot",slotList:"Slot List",slotId:"Slot ID",slotOwnerPath:"Slot Owner Path",slotMaterialAsset:"Slot Material Asset",slotSourceMaterial:"Source Material",slotBindingPath:"Binding Path",reimportConflicts:"Reimport Material Conflicts",summaryAsset:e=>`Asset: ${e}`,summaryMissingAsset:"Missing asset",summaryCustomOverride:"Custom override",summaryInherit:"Inherit",summaryAddSlot:"Add slot",summarySlotCount:e=>`${e} slot${e===1?"":"s"}`,formatUsageCount:e=>e>0?`Used in ${e} place${e===1?"":"s"}`:"Unused",formatMaterialEditImpact:e=>e<=0?"This material is not used in the scene; edits only change the asset.":e===1?"Edits affect the current binding.":`Shared material: edits affect ${e} bindings.`,formatDuplicateMaterialImpact:e=>e<=0?"Copying creates an independently editable material asset.":e===1?"After copying, the current object or slot uses an independent material.":`After copying, the current object or slot uses an independent material; the original ${e} shared bindings are left unchanged.`,formatReimportConflictSummary:e=>`${e} material slot reimport difference${e===1?"":"s"} detected. Existing bindings are preserved until unmatched items are resolved.`,tooltips:{language:"Switch the artist material Inspector language.",materialAsset:"Choose a project-level shared material asset, or use the read-only Default PBR material.",slotMaterialAsset:"Leave this unset to preserve the original GLB material, or choose a material asset to override only this slot.",baseTexture:"Choose a project texture as the base texture. Texture adjustment parameters are applied to this texture first.",assetProfile:"Shared asset parameters affect every node bound to this material asset.",assetName:"Material asset names are display-only for bindings; stable material IDs survive renames.",assetKind:"Select the Shader Definition referenced by this material; compatible values survive a change.",lightingModel:"Lit materials respond to environment and directional lights; unlit materials are useful for UI, VFX, icons, and markers.",baseColor:"Base color is the final color factor multiplied after base texture adjustment. Editing the shared material asset affects every bound node.",duplicateForObject:"Copy the current material as an independent material for this object or slot, then bind it automatically.",brightness:"Base texture brightness multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",saturation:"Base texture saturation multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",contrast:"Base texture contrast multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",hue:"Base texture hue offset in degrees. It only affects materials with a base texture.",normalTexture:"Choose a normal map applied to the runtime bump/normal channel for PBR and Standard materials.",normalStrength:"Normal strength. 1 keeps the texture at original strength.",metallic:"Metallic value from 0 to 1.",roughness:"Roughness value from 0 to 1.",metallicRoughnessTexture:"Choose a metallic-roughness texture. PBR runtime reads blue as metallic and green as roughness by the common GLB convention.",occlusionTexture:"Choose an ambient occlusion texture. Applies to PBR materials.",occlusionStrength:"Ambient occlusion strength. 1 keeps the texture at original strength.",emissionColor:"Emission color multiplied by emission intensity.",emissionIntensity:"Emission intensity. 0 means no emission.",emissionTexture:"Choose an emissive texture. If empty, the mask texture remains the fallback.",emissionMaskUrl:"Choose a grayscale texture to modulate emission intensity.",alphaMode:"Alpha mode: opaque, alpha-test mask, or alpha-blend transparency.",alphaOpacity:"Overall material opacity. 1 is fully opaque.",alphaCutoff:"Alpha-test cutoff threshold for mask mode.",alphaTexture:"Choose an alpha/opacity texture.",createSlotMaterial:"Enter a GLB child node or mesh ownerNodePath to add a slot binding with the Default PBR material.",slotList:"Material slots on the root object are a readonly overview.",slotOwnerPath:"Child node or mesh path targeted by this material slot.",reimportConflicts:"Slots whose source material changed or could not be matched after model reimport. Existing bindings are preserved instead of being silently deleted or overwritten."}}};function gr(e){return bS[e]??bS.zh}function Ks(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var nw={},SS=new WeakMap;function yS(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function hS(e,t){return fS(e,PS(t))}function ow(e){return{materialPickerTitle:e.materialPickerTitle,replace:e.replace,duplicateForObject:e.duplicateForObject,duplicateForObjectTooltip:e.tooltips.duplicateForObject,summaryMissingAsset:e.summaryMissingAsset,summaryInherit:e.summaryInherit,inheritNone:e.inheritNone}}function aw(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function PS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function TS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=mw(e,t,r,n,o,a??void 0);if(AS(t,o))return[...i,j({path:`scene.materialAssets.${t.id}.properties`,label:r.assetProfile,value:r.defaultMaterialReadOnly,order:n+2,source:"Document",effect:"default",disabledReason:r.defaultMaterialReadOnly,tags:["ArtistMaterial","MaterialAsset"],tooltip:r.tooltips.assetProfile})];if(!a)return i;let s=[...a.inspector.fields].sort((c,d)=>c.order-d.order||c.path.localeCompare(d.path)).map(c=>iw({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function iw(e){let{fieldDefinition:t}=e,r=ES(e.text,t.labelKey,t.label??t.path),n=dw(e.text,t.tooltipKey,t.tooltip),o=xS(e.materialAsset.properties,t),a=t.control==="texture"&&no(e.materialAsset.shaderId,t.path)?sw(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=fw({path:`${dr}${e.materialAsset.id}.${t.path}`,label:r,value:typeof o=="string"?o:"",order:e.orderOffset+t.order,text:e.text,context:e.context,textureState:a??void 0,tooltip:n});else if(t.control==="number")i=gw(e.document,e.materialAsset,t.path,r,typeof o=="number"?o:Number(t.defaultValue),e.orderOffset+t.order,t,n,e.context.materialShaderDefinitions);else if(t.control==="enum")i=bw(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:ES(e.text,d.labelKey,d.label??d.value)})),n,e.context.materialShaderDefinitions);else{let d=t.control;i=Js(e.document,e.materialAsset,t.path,r,o,e.orderOffset+t.order,d,d,"immediate",n,e.context.materialShaderDefinitions)}let s=t.control==="color"?Qn(e.definition.shaderId,t.path,e.context.materialShaderDefinitions):null;i={...i,displayPrecision:t.displayPrecision,precision:t.precision,controlOptions:{...i.controlOptions,...t.control==="color"?{colorChannels:s?.kind==="color"&&s.channels===4?4:3}:{},materialShaderSectionId:t.sectionId,materialShaderUpdateClass:t.updateClass,materialShaderBinding:t.binding}};let c=t.conditions?.find(d=>!cw(e.definition,e.materialAsset.properties,d));return c&&(i=Ew(i,!1,lw(e.text,c))),a?yw(i,e.text,a):Sw(i,e.text,t.defaultValue)}function sw(e,t){let r=Hs(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function xS(e,t){if(t.control==="texture"){let n=Hs(e,t.schemaPath??t.path);return DS(n)}let r=Hs(e,t.path);return r===void 0?structuredClone(t.defaultValue):r}function Hs(e,t){let r=t.replace(/^properties\./,"").split(".").filter(Boolean),n=e;for(let o of r){if(!n||typeof n!="object"||Array.isArray(n))return;n=n[o]}return n}function cw(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?xS(t,n):Hs(t,r.path);if(r.operator==="truthy")return!!o;let a=JSON.stringify(o??null)===JSON.stringify(r.value??null);return r.operator==="equals"?a:!a}function ES(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function dw(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function lw(e,t){let r=t.inactiveReasonKey?e.inactiveReasons[t.inactiveReasonKey]:void 0;return typeof r=="string"?r:t.inactiveReason??"This field is inactive for the current material state."}function uw(e){return e.defaultMaterialAssetIds??[Pn,yo]}function AS(e,t){return ka(e,uw(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function mw(e,t,r,n,o,a){if(!AS(t,o)){let i=o.materialShaderDefinitions??Mr;return[Js(e,t,"name",r.assetName,hS(t,r),n,"string","string","change",r.tooltips.assetName,i),{path:`${dr}${t.id}.shaderId`,label:r.assetKind,valueType:"string",control:"enum",value:t.shaderId,readOnly:!1,persistence:"document",commitMode:"immediate",order:n+1,tooltip:r.tooltips.assetKind,tags:["ArtistMaterial","MaterialAsset","ShaderDefinition"],options:i.list().map(s=>({value:s.shaderId,label:s.displayName})),controlOptions:{materialShaderSelector:!0,shaderId:t.shaderId,shaderVersion:a?.version,shaderRuntimeKind:a?.runtimeKind,...a?.sourceFile?{shaderSourceFile:a.sourceFile}:{}},validate:s=>typeof s=="string"&&i.get(s)?{ok:!0,value:s}:{ok:!1,message:"Unknown Shader Definition."},coerce:s=>typeof s=="string"?s.trim():""}]}return[yS(`${dr}${t.id}.name`,r.assetName,hS(t,r),n,r.tooltips.assetName),yS(`${dr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function fw(e){let t=ou(e.context,e.value),r=qs(e.context,e.text,e.value,t);return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:e.value,readOnly:!1,persistence:"document",commitMode:"change",order:e.order,tooltip:e.tooltip,tags:["ArtistMaterial","TextureAsset"],controlOptions:{...r,...e.textureState?{materialTextureState:e.textureState}:{},...!e.value&&e.textureState==="inherited"?{currentLabel:e.text.inheritTexture,currentMeta:e.text.inheritTextureMeta}:!e.value&&e.textureState==="cleared"?{currentLabel:e.text.clearTexture,currentMeta:e.text.clearTextureMeta}:{}},validate:n=>{let o=IS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=IS(e.context,e.path,n);return o.ok?o.value:null}}}function qs(e,t,r,n){return{...pS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:pw(t),candidateValue:"assetId"})}}function ou(e,t){return Us(e.textureAssets,t)}function DS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function IS(e,t,r){if(r==null||r==="")return{ok:!0,value:null};if(typeof r!="string")return{ok:!1};let n=r.trim();if(!n)return{ok:!0,value:null};if(!t.endsWith(".textureAssetId"))return{ok:!0,value:n};let o=Us(e.textureAssets,n);return o?{ok:!0,value:o.id}:/^[A-Za-z0-9_-]+$/.test(n)?{ok:!0,value:n}:{ok:!0,value:null}}function pw(e){return{texturePickerTitle:e.texturePickerTitle,replace:e.replace,emptyTexture:e.emptyTexture,emptyTextureMeta:e.emptyTextureMeta,clearTexture:e.clearTexture,clearTextureMeta:e.clearTextureMeta,missingTexture:e.missingTexture,missingTextureMeta:e.missingTextureMeta,loadingTexture:e.loadingTexture,failedTexture:e.failedTexture}}function gw(e,t,r,n,o,a,i={},s,c){return{...Js(e,t,r,n,o,a,"number","number","live",s,c),...i.min!=null?{min:i.min}:{},...i.max!=null?{max:i.max}:{},...i.softMin!=null?{softMin:i.softMin}:{},...i.softMax!=null?{softMax:i.softMax}:{},step:i.step??.05}}function bw(e,t,r,n,o,a,i,s,c){return{...Js(e,t,r,n,o,a,"enum","enum","immediate",s,c),options:i,controlOptions:{variant:"segmented"}}}function Js(e,t,r,n,o,a,i,s,c,d,u){return{...gS({document:e,materialAsset:t,fieldPath:r,label:n,value:o,order:a,valueType:i,control:s,commitMode:c,tooltip:d,pathPrefix:dr}),validate:l=>{let m=rt(r,l);return zt(r,m,t.shaderId,u)?{ok:!0,value:m}:{ok:!1,message:`Invalid material asset field: ${r}.`}},coerce:l=>rt(r,l)}}function Sw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!hw(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function yw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:"",resetMode:"inherit",modified:r!=="inherited",resetLabel:t.inheritTexture,modifiedLabel:r==="cleared"?t.clearTexture:t.modifiedValue}}}function hw(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function Ew(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function MS(e,t,r,n){let o=r.currentAsset??ee(e,r.value);return{path:r.path,label:r.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.value,readOnly:!1,persistence:"document",commitMode:"change",order:r.order,controlOptions:Tw(Ws(e,o,r.text,r.value,n,r.previewContext),r.currentAction),tooltip:r.text.tooltips.materialAsset,tags:["ArtistMaterial","MaterialAsset"],document:e,validate:a=>{let i=ts(a);return i&&Vt(e,i)?{ok:!0,value:a}:a==null||a===""?{ok:!0,value:a}:typeof a=="string"&&Vt(e,a)?{ok:!0,value:a}:{ok:!1,message:`Material asset not found: ${String(a)}`}},coerce:a=>typeof a=="string"?a.trim():a,effect:Iw(t,r.value),validation:Pw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function Iw(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function Pw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function Tw(e,t){return t?{...e,currentActionId:t.actionId,currentActionParams:Object.fromEntries(Object.entries(t.params).filter(r=>typeof r[1]=="string"&&r[1].length>0))}:e}function xw(e,t,r){return MS(e,t,r,_e.getCachedUsageIndex(e))}function Ws(e,t,r,n,o,a={}){return{..._e.createPickerControlOptions({materialAssets:e.scene.materialAssets??[],currentAsset:t,currentValue:n,pickerText:ow(r),displayText:PS(r),document:e,ownershipText:aw(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function Aw(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Ws(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=SS.get(e);a||(a=new WeakMap,SS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??nw,c=i.get(s);c||(c=new Map,i.set(s,c));let d=c.get(n);if(d)return d;let u=Ws(e,t,r,n,_e.getCachedUsageIndex(e),o);return c.set(n,u),u}var Dw={createSelectorInspectorPropertyWithUsage:MS,createSelectorInspectorPropertyWithCachedUsage:xw,createPickerControlOptionsWithUsage:Ws,createPickerControlOptionsWithCachedUsage:Aw},Mn=Dw;function wS(e,t,r){let n=Jp(e,t);if(n.state==="asset"&&n.materialAsset){let o=Kb(n.materialAsset),a=o==="default-pbr"?r.defaultMaterial:o==="default-standard"?r.defaultStandardMaterial:n.materialAsset.name??n.materialAsset.id;return r.summaryAsset(a)}return n.state==="missing-asset"?r.summaryMissingAsset:n.state==="override"?r.summaryCustomOverride:r.summaryInherit}function kS(e,t,r){let n=kr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function Mw(e,t,r,n,o,a={}){let i=gr(Ks(t)),s=[];return kr(e,t).forEach((d,u)=>{let l=Ut(d)??d.slotId,m=ol(t,d),f=o?.materialSlotBindings?.[d.slotId]??m,S=f?.materialAssetId?ee(e,f.materialAssetId):null,g=(u+1)*100,b=as(d),y=nt(d)[0],I=y==null?null:ho(d,y)?.profile,E=Mn.createSelectorInspectorPropertyWithUsage(e,r,{path:b,label:d.label||au(l,u,i),value:m?.materialAssetId??"",order:g,text:i,currentAsset:S,currentAction:S?{actionId:"material.open-asset",params:{materialAssetId:S.id,browserAssetId:`material:${S.id}`,sourceObjectId:t.id,sourceBindingPath:b}}:I?{actionId:"material.create-from-source",params:{sourceObjectId:t.id,sourceBindingPath:b}}:void 0,previewContext:a},n);s.push(ww(E,d,f,i,a))}),s}function ww(e,t,r,n,o){let a=nt(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:An(t,a),s=a==null?null:ho(t,a)?.profile,c=s?Bt(Oa(s),o):void 0,d=i?`GLB \u6E90\u6750\u8D28\uFF1A${i}`:"GLB \u6E90\u6750\u8D28",u=e.controlOptions??{},l=Array.isArray(u.candidates)?u.candidates.map(f=>f&&typeof f=="object"&&!Array.isArray(f)&&f.value===""?{...f,label:"\u6062\u590D\u7EE7\u627F",meta:d,...c?{preview:c}:{}}:f):void 0,m=r?.materialAssetId&&typeof u.currentMeta=="string"&&u.currentMeta?`${u.currentMeta} \xB7 ${d}`:d;return{...e,tooltip:n.tooltips.slotMaterialAsset,controlOptions:{...u,...r?.materialAssetId?{}:{currentLabel:i?`\u7EE7\u627F GLB\uFF1A${i}`:"\u7EE7\u627F GLB \u539F\u6750\u8D28",...c?{currentPreview:c}:{}},currentMeta:m,...l?{candidates:l}:{},...i?{sourceMaterialName:i}:{}}}}function kw(e,t,r,n){let o=kr(e,t);if(o.length===0)return[];let a=[],i=Bs(e,t),s=ds(e,t.id)??t.overrides;i.issues.length>0&&a.push(vw("asset.materialSlots.reimportConflicts",r.reimportConflicts,Ow(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>Rw(e,t,d,u,r,n,s));return a.push({path:"asset.materialSlots",label:r.slotList,valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:o.length,slots:c},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:r.slotMaterialAsset,slotId:r.slotId,ownerNodePath:r.slotOwnerPath,sourceMaterial:r.slotSourceMaterial,primitive:"Primitive",triangles:"Triangles",bounds:"Bounds",bindingPath:r.slotBindingPath},slots:c},tags:["ArtistMaterial","MaterialSlot","Readonly"],tooltip:r.tooltips.slotList,document:e}),a}function Ow(e,t){let r=e.map(n=>{let o=n.label||n.ownerNodePath||n.slotId||n.previousSlotId||n.bindingPath||"slot";if(n.reason==="source-material-changed"){let a=n.previousSourceMaterialIndex==null?"?":`#${n.previousSourceMaterialIndex}`,i=n.sourceMaterialIndex==null?"?":`#${n.sourceMaterialIndex}`;return`${o}: source material ${a} -> ${i}; ${n.materialAssetId??t.inheritNone}`}return n.reason==="slot-removed"?`${o}: removed slot; ${n.materialAssetId??t.inheritNone}`:`${o}: ${n.status}`});return[t.formatReimportConflictSummary(e.length),...r].join(`
3
- `)}function Rw(e,t,r,n,o,a,i){let s=ol(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??Tn),u=Mn.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=nt(r),m=l[0],f=m==null?null:An(r,m),S=r.sourceSurfaces[0],g=S.ownerNodePath;return{key:Yp(r),label:r.label||au(g,n,o),slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:g,materialAssetId:s?.materialAssetId??"",materialLabel:u.currentLabel??o.inheritNone,materialMeta:u.currentMeta??o.summaryInherit,...u.currentPreview?{materialPreview:u.currentPreview}:{},...m==null?{}:{sourceMaterialIndex:m},...l.length?{sourceMaterialIndices:l}:{},...f?{sourceMaterialName:f}:{},...r.materialNames?.length?{materialNames:r.materialNames}:{},...r.sourceSurfaces.length===1&&typeof S.triangleCount=="number"?{triangleCount:S.triangleCount}:{},...r.sourceSurfaces.length===1&&S.boundingBox?{boundingBox:S.boundingBox}:{},bindingPath:as(r)}}var Cw={createChildMaterialBindingInspectorPropertiesWithUsage:Mw,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:kw},OS=Cw;function au(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function vw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var RS="materialAsset::",Gw=5;function jw(e){return e.startsWith(RS)&&e.slice(RS.length).trim()||null}function Nw(e,t,r,n,o,a){let i=[],s=Ks(t),c=gr(s),d=t.overrides?.materialBinding,u=ds(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??Tn,f=ee(e,m),S=l?.materialAssetId?l:{...l,materialAssetId:Tn};if(!Xp(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:wS(S,f,c),persistence:"document",collapsedByDefault:!1,properties:[Mn.createSelectorInspectorPropertyWithUsage(e,r,{path:y,label:c.materialCard,value:d?.materialAssetId??"",order:0,text:c,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,sourceBindingPath:y}},previewContext:n},a)]})}let b=r==="primitive"?[]:OS.createChildMaterialBindingInspectorPropertiesWithUsage(e,t,r,a,u,n);return b.length>0&&i.push({id:"artistMaterialSlots",title:c.slotTitle,order:48,placement:"body",summary:kS(e,t,c),persistence:"document",collapsedByDefault:!1,properties:b}),i}function Fw(e,t,r,n){let o=jw(t),a=o?ee(e,o):null;if(!a)return null;let i=gr("zh"),s=n.forMaterial(a.id),c=TS(e,a,i,0,r),d=`scene.materialAssets.${a.id}.properties`,u=`${d}.`,l=E=>E.path===d||E.path.startsWith(u),m=c.filter(E=>!l(E)),f=c.filter(l),S=[{path:`scene.materialAssets.${a.id}.preview`,label:a.name||a.id,valueType:"object",control:"custom",customControl:"asset-picker-card",value:a.id,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:-10,controlOptions:{currentMaterialAssetId:a.id,currentMaterialShaderId:a.shaderId,...a.definitionVersion!=null?{currentMaterialDefinitionVersion:a.definitionVersion}:{},currentLabel:a.name||a.id,currentMeta:a.shaderId,currentPreview:Bt(a.properties,r)},document:e},...m,zw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],g=[io({path:`scene.materialAssets.${a.id}.actions.locate`,label:"\u5728 Assets \u4E2D\u5B9A\u4F4D",actionId:"material.locate-asset",icon:"asset",params:{materialAssetId:a.id,browserAssetId:`material:${a.id}`},order:20,tooltip:"\u5728 Assets \u9762\u677F\u4E2D\u5B9A\u4F4D\u5F53\u524D\u6750\u8D28\u3002",disabled:!1}),io({path:`scene.materialAssets.${a.id}.actions.back`,label:"\u8FD4\u56DE\u6765\u6E90",actionId:"material.back-to-owner",icon:"chevron-left",params:{materialAssetId:a.id},order:21,tooltip:"\u8FD4\u56DE\u6253\u5F00\u5F53\u524D\u6750\u8D28\u524D\u7684\u5BF9\u8C61\u6216 Prefab Inspector\u3002",disabled:!1})],b=[{id:"materialAssetSummary",title:"Material",order:10,regionId:zi,persistence:"readonly",collapsedByDefault:!1,properties:S}];b.push({id:"materialAssetNavigation",title:"\u5BFC\u822A",order:15,placement:"body",persistence:"readonly",collapsedByDefault:!1,properties:g}),b.push({id:"materialReferences",title:`\u4F7F\u7528\u4F4D\u7F6E (${s.length})`,order:20,placement:"body",persistence:"readonly",collapsedByDefault:s.length===0,properties:[{path:`scene.materialAssets.${a.id}.references.browser`,label:"\u4F7F\u7528\u4F4D\u7F6E",valueType:"object",control:"custom",customControl:"material-reference-list",controlOptions:{previewLimit:Gw,items:s.map((E,T)=>({key:`${E.scope}:${E.gameObjectId}:${E.bindingPath}:${T}`,label:E.label,scope:E.scope,actionId:"material.open-owner",params:Object.fromEntries(Object.entries({materialAssetId:a.id,ownerScope:E.scope,sourceObjectId:E.gameObjectId,sourceBindingPath:E.bindingPath,slotId:E.slotId,ownerNodePath:E.ownerNodePath,prefabAssetId:E.prefabAssetId,prefabNodeId:E.prefabNodeId}).filter(A=>typeof A[1]=="string"&&A[1].length>0))}))},value:s.length,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:0,tooltip:s.length>0?"\u67E5\u770B\u4F7F\u7528\u5F53\u524D\u6750\u8D28\u7684 Scene \u5BF9\u8C61\u548C Prefab \u8282\u70B9\u3002":"\u5F53\u524D\u672A\u88AB\u4EFB\u4F55\u5BF9\u8C61\u6216 Prefab \u4F7F\u7528\u3002",document:e}]});let y=r.materialShaderDefinitions?.get(a.shaderId)??De(a.shaderId);for(let[E,T]of[...y?.inspector.sections??[]].sort((A,$)=>A.order-$.order||A.id.localeCompare($.id)).entries())CS(b,{id:`material${T.id.charAt(0).toUpperCase()}${T.id.slice(1)}`,title:T.title,order:T.order,properties:[...E===0?f.filter(A=>A.path===d):[],...f.filter(A=>A.controlOptions?.materialShaderSectionId===T.id)]});let I=new Set(b.flatMap(E=>E.properties.map(T=>T.path)));return CS(b,{id:"materialAdvanced",title:"Advanced",order:80,properties:f.filter(E=>!I.has(E.path))}),{targetIds:[t],activeId:t,label:a.name||a.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"materialAsset",capabilities:["material"],document:e},sections:b}}function _w(e,t,r,n={},o){return Nw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function $w(e,t,r={}){return Fw(e,t,r,_e.getCachedUsageIndex(e))}var Lw={createArtistMaterialInspectorSectionsWithCachedUsage:_w,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:$w},iu=Lw;function CS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function zw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var vS="modelAsset::";function Bw(e){return e.startsWith(vS)&&e.slice(vS.length).trim()||null}function GS(e,t,r={}){let n=Bw(t),o=n?Vw(e,n,r.modelAssets):null;if(!o)return null;let a=Ww(o),i=[Uw(o)];return i.push(Kw(e,o,a,r)),{targetIds:[t],activeId:t,label:o.displayName??o.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"modelAsset",capabilities:["asset","materialSlots"],document:e},sections:i}}function Vw(e,t,r){let n=e.assets.find(a=>a.id===t);if(n&&n.type!=="glb")return null;let o=r?.find(a=>a.assetId===t&&a.type==="glb");return o?$r(n??{id:t,type:"glb"},o):n??null}function Uw(e){let t=qw(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:zi,persistence:"readonly",collapsedByDefault:!1,properties:[Ca(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),Ca(`assets.${e.id}.id`,"Asset ID",e.id,1),Ca(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[Ca(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function Kw(e,t,r,n){let o=`\u6750\u8D28\u63D2\u69FD (${r.length})`;if(r.length===0)return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:"\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",persistence:"readonly",collapsedByDefault:!1,properties:[Ca(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>Hw(s,c,n)),i={path:`assets.${t.id}.materialSlots`,label:"GLB \u6E90\u6750\u8D28",valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:r.length,slots:a},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:"\u5F53\u524D\u6765\u6E90",slotId:"Slot ID",ownerNodePath:"\u8282\u70B9\u8DEF\u5F84",sourceMaterial:"\u6E90\u6750\u8D28",primitive:"Primitive",triangles:"\u4E09\u89D2\u9762",bounds:"Bounds",bindingPath:"\u7ED1\u5B9A\u8DEF\u5F84"},slots:a},tags:["Asset","MaterialSlot","Readonly"],tooltip:"GLB / glTF \u6587\u4EF6\u4E2D\u89E3\u6790\u51FA\u7684\u53EA\u8BFB\u6750\u8D28\u63D2\u69FD\u3002",document:e};return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:`${r.length} \u4E2A\u5DF2\u89E3\u6790\u6E90\u63D2\u69FD`,persistence:"readonly",collapsedByDefault:!1,properties:[i]}}function Hw(e,t,r){let n=e.sourceSurfaces[0],o=nt(e),a=n.sourceMaterialIndex??o[0],i=a==null?e.materialNames?.[0]??e.materialName??null:An(e,a),s=a==null?null:ho(e,a)?.profile??null,c=e.label||i||`Material Slot ${t+1}`;return{key:e.slotId,label:c,slotId:e.slotId,sourceSurfaces:structuredClone(e.sourceSurfaces),ownerNodePath:n.ownerNodePath,materialLabel:i??c,materialMeta:"\u7EE7\u627F GLB \u6E90\u6750\u8D28",...s?{materialPreview:Bt(s,r)}:{},...a==null?{}:{sourceMaterialIndex:a},...o.length>0?{sourceMaterialIndices:o}:{},...i?{sourceMaterialName:i}:{},...e.materialNames?.length?{materialNames:e.materialNames}:{},...e.sourceSurfaces.length===1&&typeof n.triangleCount=="number"?{triangleCount:n.triangleCount}:{},...e.sourceSurfaces.length===1&&n.boundingBox?{boundingBox:n.boundingBox}:{}}}function Ww(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(Or).filter(r=>!!r)}function Ca(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function qw(e){return typeof e=="string"&&e.trim()?e.trim():""}function va(e,t,r,n={}){let o=iS(e,t),a=o.document;if(t.type==="prefab"){let u=jS(a,t),l=u?$r(u,t):su(t),m=FS(a,t,l,r,n),f=Xw(u?a.assets.map(S=>S.id===l.id?l:S):[...a.assets,l],l);return{document:{...a,assets:f,scene:{...a.scene,gameObjects:[...a.scene.gameObjects,m]}},gameObject:m}}let i=jS(a,t),s=i?$r(i,t):su(t),c=t.type==="texture"?Jw(a,t,s.id,r,n):NS(a,t,s.id,r,n),d=sS(c,t,o.materialAssetIdsBySourceMaterialIndex);return{document:{...a,assets:i?a.assets.map(u=>u.id===s.id?s:u):[...a.assets,s],scene:{...a.scene,gameObjects:[...a.scene.gameObjects,d]}},gameObject:d}}function Jw(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,kind:"transform",...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},metadata:{...t.metadata??{},assetId:t.assetId,assetType:"texture"},components:[Mt(d),{type:"ImageRenderer",assetId:r,size:{width:1,height:1}}]}}function su(e){return{id:e.assetId,guid:e.guid,type:e.type,displayName:e.displayName,category:e.category,warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:Xs(e.defaults),prefab:Xs(e.prefab),external:Xs(e.external),metadata:Xs(e.metadata)}}function NS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},components:[Mt(d),{type:"ModelRenderer",assetId:r}]}}function FS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return ng({id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},prefabAsset:r,transform:Mt(d),metadata:{...t.metadata??{},assetId:t.assetId,assetType:"prefab"}})}function cu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function jS(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function Xw(e,t){let r=da(t);if(!r||e.some(a=>a.id===r))return[...e];let n=t.prefab?.sourceAssetGuid,o=!!n&&!e.some(a=>a.guid===n);return[...e,{id:r,...o?{guid:n}:{},type:"glb",displayName:r,category:"Model",metadata:{sourcePrefabId:t.id}}]}function du(e,t,r,n){if(n.localTransform)return structuredClone(n.localTransform);let o=ql(e,r);if(!t)return o;let a=n.resolveLocalTransform?.({document:e,parentId:t,worldTransform:o})??ur(e,t,o);if(!a)throw new Error(`Cannot resolve parent-local asset placement transform for ${t}.`);return a}function lu(e,t,r){if(t===void 0)return Aa(e,vs(r));if(Aa([],t)!==t||e.includes(t))throw new Error(`Requested asset instance id is invalid or already used: ${t}`);return t}function uu(e,t){let r=t??ye(e);if(r){if(!e.scene.gameObjects.some(n=>n.id===r))throw new Error(`Requested asset instance parent does not exist: ${r}`);return r}}function Xs(e){return e==null?void 0:structuredClone(e)}function Yw(e){return!!e&&tt(e)}function pu(e,t,r={}){let n=t.type==="document.replace"?t.document:$S({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function $S(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return ja({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return wn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return Ga(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return va(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return ue(r.targetId)?t:hn(t,r.targetId,{transform:r.transform});if(r.kind==="game-object.transform-batch")return r.targets.reduce((o,a)=>{if(ue(a.targetId))return o;let i=_(o,a.targetId),s=i?G(i):null;if(!s)return o;if(Yw(a.transform))return hn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return hn(o,a.targetId,{position:c.position?{...s.position,...c.position}:void 0,rotation:c.rotation?{...s.rotation,...c.rotation}:void 0,scale:c.scale?{...ot(s,"scale"),...c.scale}:void 0})},t);if(r.kind==="game-object.duplicate-selection"){let o=new Set(t.scene.gameObjects.map(l=>l.id)),a=n.isProtectedDuplicateSource??Zw,i=new Set(t.scene.gameObjects.filter(l=>a(l,t)).map(l=>l.id)),s=new Set,c=[];for(let l of r.gameObjects)o.has(l.id)||s.has(l.id)||Z(l)||a(l,t)||(s.add(l.id),c.push(l));let d=ek(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?mu(u,r.order):u}}}if(r.kind==="game-object.rename"){let o=r.name.trim();if(!o)return t;let a=t.scene.gameObjects.find(i=>i.id===r.targetId);return!a||a.name===o?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(i=>i.id===r.targetId?{...i,name:o}:i)}}}if(r.kind==="game-object.create-group"||r.kind==="game-object.create-primitive")return t.scene.gameObjects.some(o=>o.id===r.gameObject.id)?t:{...t,scene:{...t.scene,gameObjects:[...t.scene.gameObjects,r.gameObject]}};if(r.kind==="game-object.delete-subtree"){if(r.targetIds.some(ue))return t;let o=wt(t,r.targetIds);if(o.size===0)return t;let a=n.isProtectedDeleteTarget??Qw;return t.scene.gameObjects.some(i=>o.has(i.id)&&a(i,t))?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.filter(i=>!o.has(i.id))}}}if(r.kind==="game-object.reparent"){if(ue(r.targetId))return t;let o=t.scene.gameObjects.find(c=>c.id===r.targetId);if(!o)return t;let a=r.transform?mr(r.transform):null;if(r.transform&&!a)return t;let i=!!a&&!_S(G(o),a);if(o.parentId===r.parentId&&!i)return t;let s={...o,parentId:r.parentId,components:i?o.components.map(c=>c.type==="Transform"?a:c):o.components};return{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(c=>c.id===r.targetId?s:c)}}}if(r.kind==="game-object.hierarchy-move"){let o=r.moves.filter(l=>!ue(l.targetId)),a=new Map;for(let l of o){let m=mr(l.transform);if(!m)return t;a.set(l.targetId,m)}let i=new Map(o.map(l=>[l.targetId,l]));if(i.size===0)return t;let s=!1,c=t.scene.gameObjects.map(l=>{let m=i.get(l.id);if(!m)return l;let f=a.get(m.targetId),S=!_S(G(l),f);if(l.parentId===m.parentId&&!S)return l;let g={...l,parentId:m.parentId,components:S?l.components.map(b=>b.type==="Transform"?f:b):l.components};return s=!0,g}),d=mu(c,r.order),u=d.some((l,m)=>l!==t.scene.gameObjects[m]);return!s&&!u?t:{...t,scene:{...t.scene,gameObjects:d}}}if(r.kind==="game-object.group-selection"){if(Z(r.gameObject)||t.scene.gameObjects.some(s=>s.id===r.gameObject.id))return t;let o=new Set(r.childIds.filter(s=>!ue(s)));if(o.size===0)return t;let a=new Map;for(let[s,c]of Object.entries(r.childTransforms)){if(!o.has(s))continue;let d=mr(c);if(!d)return t;a.set(s,d)}let i=t.scene.gameObjects.map(s=>{if(!o.has(s.id))return s;let c=a.get(s.id);return{...s,parentId:r.gameObject.id,components:c?s.components.map(d=>d.type!=="Transform"?d:c):s.components}});return{...t,scene:{...t.scene,gameObjects:mu([...i,r.gameObject],r.order)}}}return t}function Zw(e){return Dt(e)}function Qw(e){return At(e)}function ek(e,t,r){let n=new Map(e.map(a=>[a.id,a])),o=!0;for(;o;){o=!1;for(let a of[...n.values()])!a.parentId||n.has(a.parentId)||t.has(a.parentId)&&!r.has(a.parentId)||(n.delete(a.id),o=!0)}return e.filter(a=>n.has(a.id))}function mu(e,t){let r=new Map(e.map(a=>[a.id,a])),n=[],o=new Set;for(let a of t){if(o.has(a))continue;let i=r.get(a);i&&(n.push(i),o.add(a))}return[...n,...e.filter(a=>!o.has(a.id))]}function _S(e,t){if(!e)return!1;let r=Ee(e),n=Ee(t);return r||n?r&&n&&e.matrix.every((o,a)=>o===t.matrix[a]):fu(e.position,t.position)&&fu(e.rotation,t.rotation)&&fu(ot(e,"scale"),ot(t,"scale"))}function fu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var tk="main_camera",rk="environment_light",nk="sun_light",Ys={projection:"orthographic",alpha:3.9269908169872414,beta:.8,radius:14,orthoSize:6,fov:.85,targetOffset:{x:0,y:0,z:0},minZ:1,maxZ:1e4,lowerBetaLimit:.8,upperBetaLimit:.8,lowerRadiusLimit:14,upperRadiusLimit:14,inertia:.9,targetScreenOffset:{x:0,y:0},inspectorLanguage:"zh"},_a={type:"directional",intensity:2,direction:{...bs},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},kn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function zS(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function BS(e){let t=yu({...e,kind:"transform",transformType:"camera",camera:$a(e.camera)});return delete t.light,delete t.primitive,hu(t,e)?e:t}function Su(e,t){let r=yu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:On(e.light,t)});return delete r.camera,delete r.primitive,hu(r,e)?e:r}function VS(e){let t=yu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,hu(t,e)?e:t}function yu(e){return G(e)?e:{...e,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},...e.components]}}function $a(e){let t=Ys;return{...t,...e??{},projection:ok(e?.projection),fov:Na(e?.fov,t.fov??.85),targetOffset:ck(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:Na(e?.minZ,t.minZ??1),maxZ:Na(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:Fa(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:Fa(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:Na(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:Na(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:ik(e?.inertia,t.inertia??.9),targetScreenOffset:sk(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:ak(e?.inspectorLanguage)}}function US(e,t){return LS(e,t,{valueField:"beta",lowerField:"lowerBetaLimit",upperField:"upperBetaLimit",minValue:Number.NEGATIVE_INFINITY}),LS(e,t,{valueField:"radius",lowerField:"lowerRadiusLimit",upperField:"upperRadiusLimit",minValue:.001}),e}function LS(e,t,r){let n=`camera.${r.valueField}`,o=`camera.${r.lowerField}`,a=`camera.${r.upperField}`,i=Fa(e[r.valueField],Ys[r.valueField]),s=Fa(e[r.lowerField],i),c=Fa(e[r.upperField],i);Number.isFinite(r.minValue)&&(i=Math.max(r.minValue,i),s=Math.max(r.minValue,s),c=Math.max(r.minValue,c)),c<s&&(t===a?s=c:c=s),t===o||t===a?i=Math.min(c,Math.max(s,i)):t===n&&(i<s&&(s=i),i>c&&(c=i)),e[r.valueField]=i,e[r.lowerField]=s,e[r.upperField]=c}function ok(e){return e==="perspective"?"perspective":"orthographic"}function ak(e){return e==="en"?"en":"zh"}function KS(e){return e==="en"?"en":"zh"}function Fa(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Na(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function ik(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function sk(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)}function ck(e){if(!e||typeof e!="object")return!1;let 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)}function HS(e){return e.maxZ!=null&&e.minZ!=null&&e.maxZ<=e.minZ||e.upperBetaLimit!=null&&e.lowerBetaLimit!=null&&e.upperBetaLimit<e.lowerBetaLimit||e.upperRadiusLimit!=null&&e.lowerRadiusLimit!=null&&e.upperRadiusLimit<e.lowerRadiusLimit}function dk(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function On(e,t="directional"){return dk(e,t)==="hemispheric"?uk(e):lk(e)}function lk(e){let t=_a,r=e?.type==="directional"?e:void 0;return{...t,...r??{},type:"directional",direction:{...t.direction,...r?.direction??{}},diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,inspectorLanguage:KS(WS(r))}}function uk(e){let t=kn,r=e?.type==="hemispheric"?e:void 0;return{...t,...r??{},type:"hemispheric",diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,groundColor:r?.groundColor?{...t.groundColor,...r.groundColor}:t.groundColor,inspectorLanguage:KS(WS(r))}}function WS(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function hu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qS(e,t,r){return{id:Eu(t,tk,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:$a(void 0),components:[{type:"Transform",position:{x:0,y:5,z:-8},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function JS(e,t,r){return{id:Eu(t,nk,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:On(void 0,"directional"),components:[{type:"Transform",position:{x:0,y:4,z:-3},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function XS(e,t,r){return{id:Eu(t,rk,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:On(void 0,"hemispheric"),components:[{type:"Transform",position:{x:0,y:3,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function Eu(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function ZS(e,t){let r=t.name.trim();if(!r)return null;let n=_(e,t.id);return!n||n.name===r?null:{label:`Rename ${n.name??n.id} to ${r}`,patch:{kind:"game-object.rename",targetId:t.id,name:r},changedId:t.id}}function QS(e,t){let r=sy(e,t);if(r===null)return null;let n=st(ec(e),t.name,{fallbackName:"Empty"}),o=ty(e.scene.gameObjects.map(i=>i.id),t.objectId,n);if(!o)return null;let a={id:o,guid:he(),name:n,kind:"transform",transformType:"plain",...r?{parentId:r}:{},active:!0,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Create empty ${n}`,patch:{kind:"game-object.create-group",gameObject:a},createdId:o,changedIds:[o]}}function ey(e,t){let r=Tk(t.shape);if(!r)return null;let n=Sk(e,t);if(n===null)return null;let o=st(ec(e),t.name,{fallbackName:xk(r)}),a=ty(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=Ak(r),s={id:a,guid:he(),name:o,kind:"primitive",...n?{parentId:n}:{},active:!0,primitive:{shape:r},shadow:{cast:"none",receive:"none"},components:[Mt(i)]};return{label:`Create ${o}`,patch:{kind:"game-object.create-primitive",gameObject:s},createdId:a,changedIds:[a]}}function ty(e,t,r){return t===void 0?it(e,r):it([],t)===t&&!e.includes(t)?t:null}function ry(e,t){if(t.ids.some(ue))return null;let r=wt(e,t.ids);if(r.size===0||e.scene.gameObjects.some(a=>r.has(a.id)&&At(a)))return null;let n=Ik(e,r,t.activeId??null),o=[...r];return{label:`Delete ${o.length} GameObject${o.length===1?"":"s"}`,patch:{kind:"game-object.delete-subtree",targetIds:t.ids},deletedIds:o,fallbackSelectionId:n}}function Pu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=_(e,t.draggedId),o=_(e,t.targetId);return n?Z(n)?{ok:!1,reason:"Root GameObject cannot be reparented."}:o?G(n)?xt(o)?n.id===o.id?{ok:!1,reason:"GameObject cannot be parented to itself."}:Pk(e,n.id,o.id)?{ok:!1,reason:"GameObject cannot be parented to its descendant."}:t.preserveWorldTransform!==!1&&!Qs(e,n.id,o.id,void 0,{preserveWorldPolicy:r})?{ok:!1,reason:"Cannot preserve world transform under the target parent."}:{ok:!0}:{ok:!1,reason:`${t.targetId} cannot have children.`}:{ok:!1,reason:`${t.draggedId} has no Transform to preserve.`}:{ok:!1,reason:`Parent GameObject not found: ${t.targetId}`}:{ok:!1,reason:`GameObject not found: ${t.draggedId}`}}function ny(e,t,r={}){if(!Pu(e,t,r).ok)return null;let o=_(e,t.draggedId);if(!o||!G(o))return null;let a=t.targetId,i=t.preserveWorldTransform===!1?qt(o):Qs(e,o.id,a,void 0,{preserveWorldPolicy:r});return!i||o.parentId===a&&fy(qt(o),i)?null:{label:`Reparent ${o.name??o.id}`,patch:{kind:"game-object.reparent",targetId:o.id,parentId:a,transform:i},changedIds:[o.id]}}function Tu(e,t,r={}){let n=fr(e),o=ep(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(ue))return{ok:!1,reason:"Root GameObject cannot be moved."};let i=Du(e,t);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=_(e,s);if(!c)return{ok:!1,reason:`GameObject not found: ${s}`};if(!G(c))return{ok:!1,reason:`${s} has no Transform to preserve.`};if(!Qs(e,s,i,t,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}return{ok:!0}}function oy(e,t,r={}){if(!Tu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids),i=Du(e,t),s=a.map(l=>{let m=_(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?qt(m):Qs(e,l,i,t,r),S=f?Sn(f):null;return S?i?{targetId:l,parentId:i,transform:S}:{targetId:l,transform:S}:null}).filter(l=>!!l);if(s.length!==a.length)return null;let c=yk(e,a,t),d=e.scene.gameObjects.map(l=>l.id);return!s.some(l=>{let m=_(e,l.targetId);return!m||m.parentId!==l.parentId||!fy(qt(m),l.transform)})&&Dk(d,c)?null:{label:`Move ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.hierarchy-move",moves:s,order:c},changedIds:a}}function xu(e,t,r={}){let n=fr(e),o=tp(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(ue))return{ok:!1,reason:"Root GameObject cannot be grouped."};let i=cy(e,t.parentId??null);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=my(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!Ea(e,i,c,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."};for(let d of a){let u=_(e,d);if(!u)return{ok:!1,reason:`GameObject not found: ${d}`};if(!G(u))return{ok:!1,reason:`${d} has no Transform to preserve.`};let l=ke(e,d);if(!l||!dy(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function ay(e,t,r={}){if(!xu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids);if(a.length===0)return null;let i=cy(e,t.parentId??null),s=my(e,a);if(!s)return null;let c={position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},d=Ea(e,i,c,r);if(!d)return null;let u=st(ec(e),t.name,{fallbackName:"Parent"}),l=it(e.scene.gameObjects.map(g=>g.id),u),m={id:l,guid:he(),name:u,kind:"transform",transformType:"plain",...i?{parentId:i}:{},active:!0,components:[Mt(d)]},f={};for(let g of a){let b=_(e,g);if(!b)return null;if(t.preserveWorldTransform===!1){f[g]=qt(b);continue}let y=ke(e,g);if(!y)return null;let I=dy(c,y,r);if(!I)return null;f[g]=I}let S=hk(e,l,a,t.insertBeforeId??null);return{label:`Create Parent for ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.group-selection",gameObject:m,childIds:a,childTransforms:f,order:S},createdId:l,changedIds:[l,...a]}}function iy(e){let t=e.isProtectedDuplicateSource??mk,r=fr(e.document),n=new Set(St(r,e.targetIds).filter(b=>{let y=_(e.document,b);return!!y&&!Z(y)&&!t(y,e.document)&&!pk(e.document,y.id,t)})),o=Au(e.document).filter(b=>n.has(b));if(o.length===0)return null;let a=wt(e.document,o),i=new Map,s=new Set(e.document.scene.gameObjects.map(b=>b.id)),c=new Map,d=ec(e.document),u=gk(e.document,o,a,t);for(let b of u){let y=_(e.document,b),I=st(d,y.name,{alwaysAppendSuffix:!0,fallbackName:y.id});d.push(I);let E=it([...s],I);s.add(E),i.set(y.id,E),c.set(y.id,I)}let l=u.map(b=>_(e.document,b)).filter(b=>!!b&&i.has(b.id)).map(b=>{let y=structuredClone(b);return y.id=i.get(b.id),y.guid=he(),y.name=c.get(b.id),y.parentId&&i.has(y.parentId)&&(y.parentId=i.get(y.parentId)),y});if(l.length===0)return null;let m=l.map(b=>b.id),f=o.map(b=>i.get(b)).filter(b=>!!b),S=fk(e.document,o,e.activeId),g=S&&i.has(S)?i.get(S):f[f.length-1]??m[m.length-1]??null;return{label:`Duplicate ${m.length} object${m.length===1?"":"s"}`,patch:{kind:"game-object.duplicate-selection",gameObjects:l,order:bk(e.document,o,i)},createdIds:m,selectedIds:f,activeId:g,changedIds:m}}function mk(e){return Dt(e)}function fk(e,t,r){if(r&&t.includes(r))return r;if(r){for(let n of t)if(wt(e,[n]).has(r))return n}return t[t.length-1]??null}function pk(e,t,r){let n=new Map(e.scene.gameObjects.map(i=>[i.id,i])),o=new Set,a=n.get(t);for(;a?.parentId;){if(o.has(a.parentId))return!0;o.add(a.parentId);let i=n.get(a.parentId);if(!i)return!1;if(r(i,e))return!0;a=i}return!1}function gk(e,t,r,n){let o=Au(e),a=new Map(o.map((l,m)=>[l,m])),i=new Map(e.scene.gameObjects.map(l=>[l.id,l])),s=new Map;for(let l of e.scene.gameObjects){let m=l.parentId&&i.has(l.parentId)?l.parentId:null,f=s.get(m)??[];f.push(l.id),s.set(m,f)}for(let l of s.values())l.sort((m,f)=>(a.get(m)??Number.MAX_SAFE_INTEGER)-(a.get(f)??Number.MAX_SAFE_INTEGER));let c=[],d=new Set,u=l=>{if(d.has(l)||!r.has(l))return;d.add(l);let m=_(e,l);if(!(!m||Z(m)||n(m,e))){c.push(m.id);for(let f of s.get(m.id)??[])u(f)}};for(let l of t)u(l);return c}function bk(e,t,r){let n=Au(e),o=new Map;for(let i of t){let s=wt(e,[i]),c=n.filter(l=>s.has(l)),d=c.map(l=>r.get(l)).filter(l=>!!l),u=c[c.length-1];u&&d.length>0&&o.set(u,d)}let a=[];for(let i of n){a.push(i);let s=o.get(i);s&&a.push(...s)}return a}function Au(e){let t=e.scene.gameObjects,r=new Map(t.map(c=>[c.id,c])),n=new Map;for(let c of t){let d=c.parentId&&r.has(c.parentId)?c.parentId:null,u=n.get(d)??[];u.push(c.id),n.set(d,u)}let o=[],a=new Set,i=c=>{if(!(a.has(c)||!r.has(c))){a.add(c),o.push(c);for(let d of n.get(c)??[])i(d)}},s=ye(e);s&&i(s);for(let c of n.get(null)??[])i(c);for(let c of t)i(c.id);return o}function sy(e,t){if(t.parentId){let n=_(e,t.parentId);return n&&xt(n)?n.id:null}let r=t.activeId?_(e,t.activeId):null;if(r&&xt(r))return r.id;if(r?.parentId){let n=_(e,r.parentId);if(n&&xt(n))return n.id}return ye(e)}function Sk(e,t){return t.parentId===null?ye(e):sy(e,t)}function Du(e,t){if(t.placement==="root")return ye(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?_(e,t.targetId):null;return t.parentId??r?.parentId??ye(e)}function cy(e,t){return t&&Mu(e,t)?t:ye(e)}function Mu(e,t){let r=_(e,t);return!!r&&xt(r)}function Qs(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=_(e,t);if(!i)return null;let s=n?o.resolveLocalTransform?.({document:e,intent:n,gameObject:i,parentId:r,worldTransform:a}):null;if(s)return Sn(s);let c=Ea(e,r,a,o.preserveWorldPolicy);return c?Sn(c):null}function dy(e,t,r={}){let n=Ki(r),o=ro(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?Sn(o):null}function yk(e,t,r){let n=ly(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=Ek(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:Du(e,r)});return uy(a,n,i)}function hk(e,t,r,n){let o=ly(e,r),a=new Set(o),i=e.scene.gameObjects.map(l=>l.id),s=i.filter(l=>!a.has(l)),c=Math.min(...r.map(l=>i.indexOf(l)).filter(l=>l>=0)),d=Number.isFinite(c)?s.filter(l=>i.indexOf(l)<c).length:s.length,u=n?Math.max(0,s.indexOf(n)):d;return uy(s,[t,...o],u)}function ly(e,t){let r=wt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function Ek(e,t,r){return r.beforeId?YS(t.indexOf(r.beforeId),t.length):r.afterId?Zs(e,t,r.afterId):r.placement==="before"&&r.targetId?YS(t.indexOf(r.targetId),t.length):r.placement==="after"&&r.targetId||r.placement==="inside"&&r.targetId?Zs(e,t,r.targetId):r.placement==="root"?t.length:r.parentId?Zs(e,t,r.parentId):t.length}function Zs(e,t,r){let n=wt(e,[r]),o=t.indexOf(r);if(o<0)return t.length;for(let a=o+1;a<t.length&&n.has(t[a]);a+=1)o=a;return o+1}function uy(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function YS(e,t){return e>=0?e:t}function my(e,t){let r=t.map(o=>ke(e,o)).filter(o=>!!o);if(r.length===0)return null;let n=r.map(Ui);return{x:n.reduce((o,a)=>o+a.x,0)/n.length,y:n.reduce((o,a)=>o+a.y,0)/n.length,z:n.reduce((o,a)=>o+a.z,0)/n.length}}function Ik(e,t,r){let n=r?_(e,r):null;if(n?.parentId&&!t.has(n.parentId)&&_(e,n.parentId))return n.parentId;for(let o=e.scene.gameObjects.length-1;o>=0;o-=1){let a=e.scene.gameObjects[o];if(!t.has(a.id))return a.id}return null}function Pk(e,t,r){let n=Rl(e),o=new Set,a=n.get(r);for(;a?.parentId&&!o.has(a.parentId);){if(a.parentId===t)return!0;o.add(a.parentId),a=n.get(a.parentId)}return!1}function Tk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function xk(e){return e[0].toUpperCase()+e.slice(1)}function Ak(e){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function ec(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function fy(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):Iu(e.position,t.position)&&Iu(e.rotation,t.rotation)&&Iu(e.scale,t.scale)}function Iu(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Dk(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ku(e){return{getHierarchyItems(t){return wu(t,e)},normalizeHierarchyDocument(t){return Gl(t)},createRenamePatch(t,r){return br(ZS(t,r))},createCreateGroupPatch(t,r){return br(QS(t,r))},createCreatePrimitivePatch(t,r){return br(ey(t,r))},createDeleteSubtreePatch(t,r){let n=ry(t,r);if(!n)return null;let o=new Set(n.deletedIds);return t.scene.gameObjects.some(a=>o.has(a.id)&&e.isProtectedSystemGameObject(a))?null:br(n)},collectSubtreeIdList(t,r){return pr(t,r)},validateReparent(t,r){let n=e.findGameObject(t,r.draggedId),o=e.findGameObject(t,r.targetId);return n&&e.isProtectedSystemGameObject(n)?{ok:!1,reason:"Protected system GameObject cannot be reparented."}:o&&e.isProtectedSystemGameObject(o)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Pu(t,r)},createReparentPatch(t,r){return br(ny(t,r))},validateHierarchyMove(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be moved."};let a=Mk(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Tu(t,r)},createHierarchyMovePatch(t,r){return br(oy(t,r))},validateGroupSelection(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be grouped."};let a=wk(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:xu(t,r)},createGroupSelectionPatch(t,r){return br(ay(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return br(iy({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return br(Wl(t))}}}function wu(e,t){let r=fr(e),n=new Map(e.scene.gameObjects.map(a=>[a.id,a])),o=[];for(let a of r){let i=n.get(a.id)??null;o.push(t.decorateHierarchyItem?.({item:a,gameObject:i,document:e})??a),i&&o.push(...t.collectHierarchyItemChildren?.({item:a,gameObject:i,document:e})??[])}return o}function Mk(e,t,r){if(t.placement==="root")return r.resolveRootContainerId(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let n=t.targetId?r.findGameObject(e,t.targetId):null;return t.parentId??n?.parentId??r.resolveRootContainerId(e)}function wk(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&xt(n)?n.id:r.resolveRootContainerId(e)}function br(e){return e?{...e,patch:e.patch}:null}function Ou(e,t){let r=t.ensureGameObjectGuids(e),n=t.resolveRootContainerId(r),o=!1,a=!1,i=!1,s=r!==e,c=t.ensureDefaultMaterialAssets(r.scene.materialAssets??[]);s=s||c!==r.scene.materialAssets;let d=r.scene.gameObjects.map(S=>{if(S.id===t.systemDefaults.environmentLightId){a=!0;let g=t.systemDefaults.normalizeEnvironmentLightGameObject(S);return s=s||g!==S,g}if(S.id===t.systemDefaults.sunLightId){i=!0;let g=t.systemDefaults.normalizeSunLightGameObject(S);return s=s||g!==S,g}if(t.isCameraGameObject(S)){if(!o){o=!0;let g=t.systemDefaults.normalizeCameraGameObject(S);return s=s||g!==S,g}return s=!0,t.systemDefaults.normalizePlainTransformGameObject(S)}if(t.isLightGameObject(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=!0,g}if(!t.isCustomTransformType?.(S.transformType)&&kk(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=s||g!==S,g}return S}),u={createGameObjectGuid:t.createGameObjectGuid,createUniqueId:t.createUniqueId},l=new Set(d.map(S=>S.id));o||(s=!0,d.push(t.systemDefaults.createDefaultCameraGameObject(n,l,u))),a||(s=!0,d.push(t.systemDefaults.createDefaultEnvironmentLightGameObject(n,l,u))),i||(s=!0,d.push(t.systemDefaults.createDefaultSunLightGameObject(n,l,u)));let m=t.normalizeMaterialBindings({...r,scene:{...r.scene,gameObjects:d,materialAssets:c}},c,d);c=m.materialAssets,d=m.gameObjects,s=s||m.changed;let f=s?{...r,scene:{...r.scene,gameObjects:d,materialAssets:c}}:r;return t.syncMarkerGraphDocument(f)}function kk(e){return(e.kind==="transform"||e.transformType==="plain")&&!e.camera&&!e.light&&!e.primitive&&!e.prefab&&!e.marker&&!e.components.some(t=>t.type==="ModelRenderer"||t.type==="ImageRenderer")}function Ru(e,t,r){let n=r.normalizeRootTransformDocument(Ok(e,t,r));return r.syncMarkerGraphDocument(r.ensureGameObjectGuids(r.normalizeDocumentAfterCommand(n,t)))}function tc(e){return{normalizeFieldValue:e.normalizeFieldValue,validateField:({document:t,gameObject:r,path:n,value:o})=>e.validateField(t,r,n,o),blockFieldPatch:({document:t,targetId:r,path:n,value:o})=>rc(t,r,n,o,e),normalizePrimitiveShape:e.normalizePrimitiveShape,mergeCameraDefaults:e.systemDefaults.mergeCameraDefaults,normalizeCameraAfterFieldPatch:(t,r)=>t&&e.systemDefaults.normalizeCameraAfterFieldPatch(t,r),mergeLightDefaults:e.systemDefaults.mergeLightDefaults,isCustomTransformType:e.isCustomTransformType,applyCustomTransformType:e.applyCustomTransformType,clearCustomTransformState:e.clearCustomTransformState,patchCustomTransformField:e.patchCustomTransformField}}function Cu(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=Ig(a,{...r===o.systemDefaults.horizontalLightAnglePath?{horizontalAngleDeg:n}:{},...r===o.systemDefaults.elevationLightAnglePath?{elevationAngleDeg:n}:{}});return i===a?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(s=>s.id===t?i:s)}}}function rc(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return!1;let i=o.isCameraGameObject(a),s=o.isLightGameObject(a),c=o.isProtectedSystemGameObject(a),d=a.id===o.systemDefaults.sunLightId&&a.light?.type==="directional"&&(r==="transform.rotation"||r.startsWith("transform.rotation."));if(r.startsWith("transform.")&&c&&!d||r.startsWith("camera.")&&!i)return!0;if(r.startsWith("camera.")&&i){let u={camera:o.systemDefaults.mergeCameraDefaults(a.camera)};if(Oe(u,r,n),u.camera&&(u.camera=o.systemDefaults.normalizeCameraAfterFieldPatch(u.camera,r),o.systemDefaults.hasInvalidCameraRelationships(u.camera)))return!0}return!!(r.startsWith("light.")&&!s||r==="light.type"&&(a.id===o.systemDefaults.environmentLightId&&n!=="hemispheric"||a.id===o.systemDefaults.sunLightId&&n!=="directional")||r==="transformType"&&(i&&n!=="camera"||s&&n!=="light"||!s&&n==="light"||n==="camera"&&!i&&o.hasCamera(e,t)))}function Ok(e,t,r){let n=t.type==="document.replace"?null:t.patch;if(n){if(n.kind==="scene.material-asset.field")return r.patchMaterialAssetField(e,n.materialAssetId,n.path,n.value);if(n.kind==="scene.material-asset.replace")return r.replaceMaterialAsset(e,n.materialAssetId,n.materialAsset);if(n.kind==="scene.material-asset.create")return r.addMaterialAsset(e,n.materialAsset);if(n.kind==="scene.material-asset.delete")return r.deleteMaterialAsset(e,n.materialAssetId);if(n.kind==="scene.material-asset.create-and-bind")return r.addMaterialAssetAndBind(e,n.targetId,n.bindingPath,n.materialAsset);if(n.kind==="scene.prefab-asset.create")return r.addPrefabAsset(e,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-asset.create-from-game-object"||n.kind==="scene.prefab-asset.duplicate")return r.addPrefabAsset(e,n.prefabAsset);if(n.kind==="scene.prefab-asset.field")return r.patchPrefabAssetField(e,n.assetId,n.path,n.value);if(n.kind==="scene.prefab-asset.replace")return r.replacePrefabAsset(e,n.assetId,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-material-asset.duplicate-and-bind")return r.addMaterialAssetAndBindPrefabOverride(e,n.assetId,n.bindingPath,n.materialAsset);let o=r.reduceExtensionPatch?.({document:e,patch:n,command:t});if(o)return o;if(n.kind==="game-object.field"&&r.isDirectionalLightAnglePath(n.path)||n.kind==="game-object.field"&&r.isCustomFieldPatchPath?.(n.path))return r.patchGameObjectField(e,n.targetId,n.path,n.value);if(n.kind==="game-object.rendering-alpha-index-migration")return Ck(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return pu(e,t,Rk(r))}function Rk(e){return{field:tc(e),serializedProperty:{validateField:e.validateSerializedPropertyField},assetPlacement:{createGameObjectGuid:e.createGameObjectGuid,resolveLocalTransform:({document:t,parentId:r,worldTransform:n})=>e.resolveLocalTransform({document:t,parentId:r,worldTransform:n})},isProtectedDuplicateSource:t=>e.isProtectedSystemGameObject(t),isProtectedDeleteTarget:t=>e.isProtectedSystemGameObject(t)}}function Ck(e,t){return Hl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function Io(e,t){let r=e.path,n=t.normalizeValue(r,e.value),o=t.parseMaterialAssetFieldPath(r);if(o){let l=t.normalizeMaterialAssetValue(o.fieldPath,n);if(!t.hasMaterialAsset(e.document,o.materialAssetId)||!t.validateMaterialAssetFieldValue(e.document,o.materialAssetId,o.fieldPath,l))return null;let m=t.collectMaterialAssetBindingIds(e.document,o.materialAssetId);return{label:`Patch material asset ${o.materialAssetId} ${o.fieldPath}`,patch:t.createMaterialAssetFieldPatch(o.materialAssetId,o.fieldPath,l),changedId:m[0]??e.targetId,changedIds:m,...o.fieldPath.startsWith("properties.")?{reprojectIds:m}:{}}}let a=t.findGameObject(e.document,e.targetId);if(!a)return null;let i=a.id,s=t.parseDuplicateMaterialAssetValue(n);if(s&&t.isMaterialBindingPath(r))return vk(e.document,a,r,s,t);if(t.isRootTransformPath(i,r))return null;if(r==="marker.target.objectId"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTargetUpdateCommand(e.document,i,n);return l?py(i,"marker.target",l,t):null}if(!t.validateValue(e.document,a,r,n).ok||t.blockFieldPatch(e.document,i,r,n))return null;if(r==="marker.type"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTypeUpdateCommand(e.document,i,n);return l?py(i,"marker.type",l,t):null}if(t.isDirectionalLightAnglePath(r)&&typeof n=="number"&&Number.isFinite(n))return{label:`Patch ${i} ${r}`,patch:t.createDirectionalLightPatch(i,r,n),changedId:i,changedIds:[i],reprojectIds:[i]};let c=t.createCustomInspectorPropertyPatch?.({...e,gameObject:a,path:r,value:n});if(c)return c;let d=t.collectChangedIdsForFieldPath(e.document,i,r),u=t.isProjectionShapePath(r)||t.isArtistMaterialPatchPath(r)||t.isCustomProjectionPath?.(r)?[i]:void 0;return{label:`Patch ${i} ${r}`,patch:t.createGameObjectFieldPatch(i,r,n),changedId:i,changedIds:d,...u?{reprojectIds:u}:{}}}function nc(e,t,r,n,o){let a=o.patchCustomGameObjectField?.({document:e,targetId:t,path:r,value:n});if(a)return a;if(r.startsWith("metadata.")||o.isDirectionalLightAnglePath(r)){let s=o.findGameObject(e,t);if(!s)return e;let c=o.normalizeValue(r,n);return!o.validateValue(e,s,r,c).ok||o.blockFieldPatch(e,t,r,c)?e:o.isDirectionalLightAnglePath(r)&&typeof c=="number"&&Number.isFinite(c)?o.patchDirectionalLightAngleField(e,t,r,c):Gk(e,t,r,c,o)}let i=wn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function gy(e,t,r,n,o){let a=Array.from(new Set(t.filter(Boolean)));if(a.length===0)return e;let i=o.patchCustomGameObjectsField?.({document:e,targetIds:a,path:r,value:n,patchSingle:(c,d,u,l)=>nc(c,d,u,l,o)});if(i)return i;if(r.startsWith("metadata."))return jk(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>nc(c,d,r,n,o),e);let s=Ga(e,a,r,n,o.fieldMutationOptions);return a.reduce((c,d)=>o.normalizeAfterFieldPatch(c,d,r,n),s)}function py(e,t,r,n){return{label:`Patch ${e} ${t}`,patch:n.createMarkerGraphPatch(r),changedId:e,changedIds:[e],reprojectIds:[e]}}function vk(e,t,r,n,o){let a=Xb({document:e,gameObject:t,bindingPath:r,sourceMaterialAssetId:n,isBindingPathAllowed:s=>o.isMaterialBindingPathAllowed(t,s)});return a?{label:`Duplicate material ${o.findMaterialAssetName(e,n)??n} for ${t.name??t.id}`,patch:a.patch,changedId:a.changedId,changedIds:a.changedIds,createdId:a.createdId,reprojectIds:a.reprojectIds}:null}function Gk(e,t,r,n,o){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>{if(a.id!==t)return a;let i=structuredClone(a);return Oe(i,r,n),i.metadata&&Object.keys(i.metadata).length===0&&delete i.metadata,i})}}}function jk(e,t,r,n,o){let a=new Set(t),i=o.normalizeValue(r,n),s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id))return d;let u=d;if(!o.validateValue(e,u,r,i).ok||o.blockFieldPatch(e,d.id,r,i))return d;let l=structuredClone(d);return Oe(l,r,i),l.metadata&&Object.keys(l.metadata).length===0&&delete l.metadata,s=!0,l});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function Sy(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:bn(r.path,r.value)};return ja({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return by({document:t.document,targetIds:t.targetIds,activeId:t.activeId,path:t.path,value:e.getSerializedMultiPropertyProbeValue(t.path),services:e}).length>0},createSerializedMultiPropertyPatch(t){if(!e.isSerializedMultiFieldPath(t.path))return null;let r=bn(t.path,t.value),n=by({...t,value:r,services:e});return n.length===0?null:{label:`Patch ${n.length} GameObjects ${t.path}`,patch:e.createFieldBatchPatch(n.map(o=>({targetId:o,path:t.path,value:r}))),changedIds:n,...e.isSerializedMultiProjectionPath(t.path)?{reprojectIds:n}:{}}}}}function by(e){return e.services.isSerializedMultiFieldPath(e.path)?e.targetIds.filter(t=>{let r=e.services.findGameObject(e.document,t);return e.services.canPatchCustomSerializedMultiField?.({document:e.document,targetId:t,path:e.path,value:e.value})===!1||e.services.isSerializedMultiProjectionPath(e.path)&&(!r||e.services.isCameraGameObject(r)||e.services.isLightGameObject(r))?!1:!!e.services.createInspectorPropertyPatch({document:e.document,targetId:t,path:e.path,value:e.value})}):[]}var Nk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Fk=/^transform\.(position|rotation|scale)$/,_k=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function wn(e,t,r,n,o={}){return $k({document:e,targetId:t,path:r,value:n,options:o})}function Ga(e,t,r,n,o={}){let a=new Set(t.filter(Boolean));if(a.size===0)return e;let i=o.normalizeFieldValue?.(r,n)??n,s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id)||vu(d.id,r))return d;let u=d;if(o.validateField?.({document:e,gameObject:u,path:r,value:i})?.ok===!1||o.blockFieldPatch?.({document:e,gameObject:u,targetId:d.id,path:r,value:i}))return d;let l=bu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function gu(e,t,r={}){let n=new Map;for(let i of t){if(!i.objectId||i.changes.length===0)continue;let s=n.get(i.objectId)??[];s.push(...i.changes),n.set(i.objectId,s)}if(n.size===0)return e;let o=!1,a=e.scene.gameObjects.map(i=>{let s=n.get(i.id);if(!s?.length)return i;let c;for(let d of s){if(vu(i.id,d.path))continue;let u=r.normalizeFieldValue?.(d.path,d.value)??d.value;r.validateField?.({document:e,gameObject:c??i,path:d.path,value:u})?.ok!==!1&&(r.blockFieldPatch?.({document:e,gameObject:c??i,targetId:i.id,path:d.path,value:u})||(c??=structuredClone(i),c=Iy(c,d.path,u,r,!0)))}return!c||JSON.stringify(c)===JSON.stringify(i)?i:(o=!0,c)});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function $k(e){if(vu(e.targetId,e.path))return e.document;let t=_(e.document,e.targetId);if(!t)return e.document;let r=e.options?.normalizeFieldValue?.(e.path,e.value)??e.value;if(e.options?.validateField?.({document:e.document,gameObject:t,path:e.path,value:r})?.ok===!1||e.options?.blockFieldPatch?.({document:e.document,gameObject:t,targetId:e.targetId,path:e.path,value:r}))return e.document;let n=bu(t,e.path,r,e.options);return n===t?e.document:{...e.document,scene:{...e.document.scene,gameObjects:e.document.scene.gameObjects.map(o=>o.id===e.targetId?n:o)}}}function bu(e,t,r,n={}){let o=Iy(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function Iy(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?yy(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?hy(a):null;if(t==="name")return typeof r=="string"&&r.trim()?a.name=r.trim():delete a.name,a;if(t==="enabled")return a.active=r!==!1,a;if(t.startsWith("shadow."))return dn(a)&&Lk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=Bk(t,r);return Oe(a,t,c),Vk(a),a}if(t.startsWith("metadata."))return Oe(a,t,r),a.metadata&&Object.keys(a.metadata).length===0&&delete a.metadata,a;if(t==="instance.assetId"){let c=Se(a);return c&&typeof r=="string"&&(c.assetId=r),a.kind="instance",delete a.primitive,a}if(t==="primitive.shape"){let c=(n.normalizePrimitiveShape??Wk)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return Uk(a,r,n),a;if(Kk(a,t,r)){let c=i?yy(a):null;return i&&c&&!Ey(i,c)?lo(a):a}if(n.patchCustomTransformField?.(a,t,r))return a;if(t.startsWith("marker."))return!a.marker||typeof a.marker!="object"||(a.kind="transform",delete a.primitive,Oe(a,t,r)),a;if(t.startsWith("camera."))return a.kind="transform",a.transformType="camera",a.camera=Py(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=Hk(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=Ty(a.light,n),delete a.camera,n.clearCustomTransformState?.(a,"light"),delete a.primitive,Oe(a,t,r),(t==="light.direction"||t.startsWith("light.direction."))&&a.light?.type==="directional"&&(a.light.direction=ya(a.light.direction,s??void 0));let c=s?hy(a):null;return s&&c&&!Ey(s,c)?Ss(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Ul(a)),a}function yy(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function hy(e){return e.light?.type==="directional"?{...e.light.direction}:null}function Ey(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Lk(e,t,r){if(!zk(t,r))return;let n=e.shadow;e.shadow={cast:t==="shadow.cast"?r===!0?"enabled":"none":n?.cast==="enabled"?"enabled":"none",receive:t==="shadow.receive"?r===!0?"enabled":"none":n?.receive==="enabled"?"enabled":"none"}}function zk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function Bk(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function Vk(e){let t=e.rendering;if(!t||typeof t!="object"||Array.isArray(t)){delete e.rendering;return}Object.keys(t).length===0&&delete e.rendering}function vu(e,t){return ue(e)&&Nk.test(t)}function Uk(e,t,r){let n=t==="plain"||t==="light"||t==="camera",o=!n&&r.isCustomTransformType?.(t)===!0;if(!n&&!o)return;let a=t;e.kind="transform",e.transformType=a,delete e.primitive,a==="camera"?e.camera=Py(e.camera,r):delete e.camera,a==="light"?e.light=Ty(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function Kk(e,t,r){let n=t.match(Fk);if(n){let a=G(e);if(!a||Ee(a))return!0;let i=n[1];return i==="scale"?(w(r)?a.scale={x:r,y:r,z:r}:qe(r)&&(a.scale={...r}),!0):(qe(r)&&(a[i]=i==="rotation"?{x:Ht(r.x),y:Ht(r.y),z:Ht(r.z)}:{...r}),!0)}let o=t.match(_k);if(o&&w(r)){let a=G(e);if(!a||Ee(a))return!0;let i=o[1],s=o[2],c=i==="rotation"?Ht(r):r;return i==="scale"?a.scale={...ot(a,"scale"),[s]:c}:a[i]={...a[i],[s]:c},!0}return!1}function Py(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):xy(e)}function Hk(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function Ty(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):xy(e)}function Wk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function xy(e){return qk(e)??{}}function qk(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var wy=["position","rotation","scale"],ky=["x","y","z"],Jk=1e-6;function Gu(e){let t=[{path:"gameObject.id",label:"ID",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.id},{path:"gameObject.name",label:"Name",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.name??e.gameObject.id}],r=G(e.gameObject);if(r){let o=Z(e.gameObject),a=o?Et():ws(r)?r:null;if(!a)return t;for(let i of wy)for(let s of ky)t.push(Zk({gameObject:e.gameObject,vectorName:i,axis:s,rootTransform:o,displayTransform:a,validateField:e.validateField}))}let n=Se(e.gameObject);return n&&t.push({path:"modelRenderer.assetId",label:"Asset ID",valueType:"asset",readOnly:!0,getValue:()=>n.assetId}),vy(e.gameObject)&&t.push(...Xk({gameObject:e.gameObject,validateField:e.validateField})),t}function Oy(e){let t=[];for(let r of wy)for(let n of ky){let o=e.map(d=>{let u=G(d);return u&&!Ee(u)?ot(u,r)[n]:null}).filter(d=>typeof d=="number");if(o.length!==e.length)continue;let a=r==="rotation"?o.map(Tt):o,i=a[0]??0,s=a.some(d=>Math.abs(d-i)>Jk),c=`transform.${r}.${n}`;t.push({path:c,label:`${r}.${n}`,valueType:"number",value:at(i),mixed:s,readOnly:!1,descriptor:{path:c,valueType:"number",getValue:()=>i}})}return t}function oc(e){if(e.length===0)return[];let t=e.map(n=>n.active!==!1),r=t[0]??!0;return[{path:"enabled",label:"Enabled",valueType:"boolean",value:r,mixed:t.some(n=>n!==r),readOnly:!1,descriptor:{path:"enabled",label:"Enabled",valueType:"boolean",getValue:()=>r}}]}function La(e){return e.length===0||e.some(r=>!vy(r))?[]:[Dy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Dy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Xk(e){return[Ay({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Ay({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Ay(e){return{path:e.path,label:e.label,valueType:e.valueType,...e.options?{options:e.options}:{},getValue:()=>Ry(e.gameObject,e.path,e.defaultValue),setValue:(t,r,n)=>{if(!n.targetId)return t;let o=bn(e.path,r),a=e.validateField?.({document:t,gameObject:e.gameObject,nodeKind:Y(e.gameObject),path:e.path,value:o});return a&&!a.ok?t:wn(t,n.targetId,e.path,o)}}}function Dy(e,t){let n=e.map(a=>Ry(a,t.path,t.defaultValue))[0]??t.defaultValue,o=Yk(e,t.path);return{path:t.path,label:t.label,valueType:t.valueType,value:n,mixed:o,readOnly:!1,...t.options?{options:t.options}:{},descriptor:{path:t.path,label:t.label,valueType:t.valueType,...t.options?{options:t.options}:{},getValue:()=>n}}}function Yk(e,t){let r=e.map(n=>Cy(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function Ry(e,t,r){let n=Cy(e);return t==="shadow.cast"?My(n.cast):t==="shadow.receive"?My(n.receive):r}function My(e){return e==="enabled"}function Cy(e){return He(e.shadow).shadow??{}}function vy(e){if(Z(e)||e.transformType==="camera"||e.transformType==="light"||e.camera||e.light)return!1;let t=Y(e);return t==="instance"||t==="primitive"||t==="transform"}function Zk(e){return{path:`transform.${e.vectorName}.${e.axis}`,label:`${e.vectorName}.${e.axis}`,valueType:"number",readOnly:e.rootTransform,getValue:()=>{let r=ot(e.displayTransform,e.vectorName)[e.axis];return e.vectorName==="rotation"?at(Tt(r)):r},...e.rootTransform?{}:{setValue:(r,n,o)=>Qk({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function Qk(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=_(e.document,e.targetId),n=r?G(r):null;if(!r||!n||Ee(n))return e.document;let o=`transform.${e.vectorName}.${e.axis}`,a=e.validateField?.({document:e.document,gameObject:r,nodeKind:Y(r),path:o,value:t});if(a&&!a.ok)return e.document;let i=e.vectorName==="rotation"?Ht(t):t,s=e.vectorName==="position"?{...n.position,[e.axis]:i}:n.position,c=e.vectorName==="rotation"?{...n.rotation,[e.axis]:i}:n.rotation,d=e.vectorName==="scale"?{...ot(n,"scale"),[e.axis]:i}:ot(n,"scale");return eO(e.document,e.targetId,{position:s,rotation:c,scale:d})}function eO(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Cl(n,r):n)}}}function Gy(e){let t=new Map(e.document.scene.gameObjects.map(o=>[o.id,o])),r=e.targetIds.map(o=>t.get(o)??null).filter(o=>!!o&&!Z(o));if(r.length===0)return null;let n=r.map(o=>o.id);return{targetIds:n,activeId:e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null,label:e.label??`${r.length} GameObjects`,properties:[...oc(r),...Oy(r),...La(r)]}}var Nu="enabled",jy="shadow.",Ny=200;function _u(e){let t=tO(e.document,e.selectedIds);if(t.length===0)return null;let r=t.map(l=>l.id),n=e.activeId&&r.includes(e.activeId)?e.activeId:r[0]??null,o=e.largeSelectionThreshold??Ny,a=rO(t),i=La(a),s=t.length>o,c=s?nO({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):Gy({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>_y(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Fy({document:e.document,serialized:d,shadowOnly:s,renderingProfile:e.renderingProfile});return u.length===0?null:{targetIds:d.targetIds,activeId:d.activeId,label:d.label,document:e.document,selection:{targetIds:d.targetIds,activeId:d.activeId,document:e.document},sections:u}}function Fy(e){let t=oO(e.document,e.serialized,e.serialized.properties.filter(n=>_y(n.path)),e.renderingProfile),r=ju("common","Common",10,e.serialized.properties.filter(n=>n.path===Nu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,ju("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,ju("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Nu&&!n.path.startsWith(jy)),e.document)].filter(n=>!!n)}function tO(e,t){let r=new Map(e.scene.gameObjects.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.get(a);i&&(Z(i)||o.push(i))}return o}function rO(e){return e.filter(t=>bo({gameObject:t,nodeKind:Y(t)}))}function nO(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:La(e.shadowGameObjects);return{targetIds:e.gameObjects.map(r=>r.id),activeId:e.activeId,label:e.label??`${e.gameObjects.length} GameObjects`,properties:[...oc(e.gameObjects),...t]}}function oO(e,t,r,n){if(r.length===0)return null;let o=new Map(e.scene.gameObjects.map(b=>[b.id,b])),a=t.targetIds.map(b=>o.get(b)).filter(b=>!!b).filter(b=>bo({gameObject:b,nodeKind:Y(b)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&bo({gameObject:i,nodeKind:Y(i)})?i:a[0]??null;if(!s)return null;let c=Y(s),d=r.find(b=>b.path==="shadow.cast"),u=r.find(b=>b.path==="shadow.receive");if(!d||!u)return null;let l=Fu(d,0),m=Fu(u,1),f=gn({path:d.path,nodeKind:c,document:e}),S=gn({path:u.path,nodeKind:c,document:e}),g=n!==void 0&&Ts(Rs(n))==="none";return{id:"shadow",title:"\u9634\u5F71",order:25,placement:"body",...g?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[{...l,label:"\u6295\u5C04\u9634\u5F71",control:"boolean",value:l.value===!0,mixed:l.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6240\u9009\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002",validate:f},{...m,label:"\u63A5\u6536\u9634\u5F71",control:"boolean",value:m.value===!0,mixed:m.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002",validate:S},...g?[_l()]:[]]}}function _y(e){return e.startsWith(jy)}function ju(e,t,r,n,o){return n.length===0?null:{id:e,title:t,order:r,placement:"body",persistence:"document",properties:n.map((a,i)=>{let s=Fu(a,i),c=aO(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?gn({path:a.path,nodeKind:c,document:o}):s.validate}})}}function Fu(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":iO(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:sO(e.valueType),order:t,source:e}}function aO(e,t){if(t.startsWith("transform."))return"transform";if(t===Nu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function iO(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function sO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var cO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function ja(e){if(ue(e.patch.targetId)&&cO.test(e.patch.path))return e.document;let t=_(e.document,e.patch.targetId);if(!t)return e.document;let r=e.patch.path.startsWith("transform.rotation")?$y(t):null,n=e.patch.path.startsWith("light.direction")?Ly(t):null,o=Dp(e.document,Gu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=_(o,e.patch.targetId);if(!a)return o;let i=r?$y(a):null,s=n?Ly(a):null,c=r&&i&&!zy(r,i),d=n&&s&&!zy(n,s);return!c&&!d?o:{...o,scene:{...o.scene,gameObjects:o.scene.gameObjects.map(u=>{if(u.id!==e.patch.targetId)return u;let l=c?lo(u):u;return d?Ss(l):l})}}}function $y(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function Ly(e){return e.light?.type==="directional"?e.light.direction:null}function zy(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Lu(e){let t=e.findGameObject(e.document,e.targetId);if(!t)return null;let r=e.isMarkerGameObject(t);return{targetIds:[t.id],activeId:t.id,label:t.name??t.id,document:e.document,selection:{targetIds:[t.id],activeId:t.id,scopeType:"scene",targetKind:r?"marker":e.readNodeKind(t),...r?{capabilities:["markerGraph"]}:{},document:e.document},sections:e.createInspectorSections(e.document,t,e.context)}}function zu(e){let t=_u({document:e.document,selectedIds:e.selectedIds,activeId:e.activeId,renderingProfile:e.renderingProfile}),r=t?{...t,selection:{...t.selection,scopeType:"scene"}}:null;if(!e.extraSection)return r;if(!r){let n=e.resolveFallbackTargetIds(),o=e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null;return{targetIds:n,activeId:o,label:e.formatFallbackLabel(n),document:e.document,selection:{targetIds:n,activeId:o,scopeType:"scene",targetKind:e.fallbackSelectionKind??"object",document:e.document},sections:[e.extraSection]}}return{...r,sections:[...r.sections.filter(n=>n.id!==e.extraSection.id),e.extraSection].sort((n,o)=>(n.order??0)-(o.order??0))}}function Bu(e){let t=[...e.createBaseSections()],r=e.isCameraGameObject(e.gameObject),n=e.isLightGameObject(e.gameObject),o=e.isMarkerGameObject(e.gameObject),a=e.nodeKind==="transform";return $u(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),za(t,a&&r?e.createCameraSection?.():null),$u(t,a&&n?e.createLightSections?.():null),za(t,a&&o?e.createMarkerSection?.():null),za(t,e.createPrefabInstanceSection?.()),(e.isMaterialInspectorCandidate?.({nodeKind:e.nodeKind,gameObject:e.gameObject,isCamera:r,isLight:n,isMarker:o})??(e.nodeKind==="instance"||e.nodeKind==="primitive"||a&&!r&&!n&&!o))&&($u(t,e.createMaterialSections?.()),za(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function za(e,t){t&&e.push(t)}function $u(e,t){if(t)for(let r of t)za(e,r)}function Vu(e){let t=e.outline,r=t?"active":"default",n=r==="default"?By:void 0;return{id:"outline",title:"Outline",order:60,placement:"body",summary:t?"Configured":"Defaults",persistence:r==="default"?"readonly":"document",effect:r,disabledReason:n,collapsedByDefault:!0,properties:lO(dO(e),r,n)}}var By="Outline fields are showing defaults; configure an outline override before edits affect this object.";function dO(e){let t=e.outline,r=[e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.renderOutline",label:"Render Outline",valueType:"boolean",control:"boolean",value:t?.renderOutline??!1,commitMode:"immediate",order:0}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineWidth",label:"Width",valueType:"number",control:"number",value:t?.outlineWidth??.04,commitMode:"live",order:1,min:0,step:.005,displayPrecision:3,precision:3,stepPrecision:.001}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineColor",label:"Color",valueType:"color",control:"color",value:t?.outlineColor??{r:.03,g:.03,b:.03},commitMode:"immediate",order:2})],n=j({path:"overrides.outline.raw",label:"Raw Override",value:t??"not configured",order:r.length,source:"Document",tags:["Raw"]});return n&&r.push(n),r}function lO(e,t,r){return!t||t==="active"?e:e.map(n=>({...n,readOnly:!0,persistence:n.persistence==="runtime"?"runtime":"readonly",control:n.control==="custom"?n.control:"readonly",effect:n.effect??t,disabledReason:n.disabledReason??r}))}var uO={title:"\u6807\u8BB0",typeLabel:"\u6807\u8BB0\u7C7B\u578B",kindLabel:"\u7A7A\u95F4\u7C7B\u522B",tagsLabel:"\u6807\u7B7E",colorLabel:"\u989C\u8272",noteLabel:"\u5907\u6CE8",geometryLabel:"\u51E0\u4F55",targetLabel:"\u7ED1\u5B9A\u5BF9\u8C61",targetStatusLabel:"\u7ED1\u5B9A\u72B6\u6001",emptyTypeOption:"\u672A\u9009\u62E9",emptyTargetOption:"\u672A\u7ED1\u5B9A",tagsPlaceholder:"\u6807\u7B7E, \u53E6\u4E00\u4E2A\u6807\u7B7E",notePlaceholder:"\u53EF\u9009\u6807\u8BB0\u5907\u6CE8",unselectedSummary:"\u672A\u9009\u62E9",missingTargetPrefix:"\u7F3A\u5931",missingTargetStatus:"\u76EE\u6807\u7F3A\u5931",targetStatusUnbound:"\u672A\u7ED1\u5B9A",targetStatusOk:"\u6B63\u5E38",unsupportedTargetPrefix:"\u4E0D\u652F\u6301\u76EE\u6807"},mO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},fO={box:"\u76D2\u4F53",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function Wu(e){let t={...uO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=pO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=hO(r),i=a?.kind==="scene-object"?a.id:"",s=gO(e.document,e.gameObject.id,i,e.isMarkerGameObject,t),c=[e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.type",label:t.typeLabel,valueType:"enum",control:o.length>0?"enum":"string",value:r.type,options:o.length>0?o:void 0,commitMode:"change",order:0}),Ku("marker.kind",t.kindLabel,SO(n,e.formatMarkerKindLabel),1),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.tags",label:t.tagsLabel,valueType:"string",control:"string",value:r.tags?.join(", ")??"",commitMode:"blur",placeholder:t.tagsPlaceholder,order:2}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.color",label:t.colorLabel,valueType:"color",control:"color",value:r.color??{r:.1,g:.85,b:1},commitMode:"immediate",order:3}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.note",label:t.noteLabel,valueType:"string",control:"string",value:r.note??"",commitMode:"blur",placeholder:t.notePlaceholder,order:4}),Ku("marker.geometry.kind",t.geometryLabel,yO(r.geometry.kind,e.formatMarkerGeometryKindLabel),5),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.target.objectId",label:t.targetLabel,valueType:"enum",control:"enum",value:i,options:s,commitMode:"change",order:6}),Ku("marker.target.status",t.targetStatusLabel,EO(e.document,a,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:bO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:c}}function pO(e,t,r,n){let o=[{label:r.emptyTypeOption,value:""},...e.map(a=>({label:Hu(a.type,a.label||a.type,n),value:a.type}))];return t&&!o.some(a=>a.value===t)&&o.push({label:Hu(t,t,n),value:t}),o}function gO(e,t,r,n,o){let a=[{label:o.emptyTargetOption,value:""},...e.scene.gameObjects.filter(i=>i.id!==t&&!n(i)).map(i=>({label:i.name||i.id,value:i.id}))];return r&&!a.some(i=>i.value===r)&&a.push({label:`${o.missingTargetPrefix}: ${r}`,value:r}),a}function bO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Hu(t,o?.label||t,n)}function Hu(e,t,r){return r?.(e,t)??t}function SO(e,t){return t?.(e)??mO[e]??e}function yO(e,t){return t?.(e)??fO[e]??e}function hO(e){return e.target?Uu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Uu(e.geometry.target):null}function EO(e,t,r){return t?t.kind!=="scene-object"?`${r.unsupportedTargetPrefix}: ${t.kind}`:e.scene.gameObjects.some(n=>n.id===t.id)?r.targetStatusOk:r.missingTargetStatus:r.targetStatusUnbound}function Uu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Ku(e,t,r,n){return j({path:e,label:t,value:r,order:n,source:"Document"})}var Ba={r:1,g:1,b:1,a:1};function IO(e){return{...e}}function Hy(e){let t=IO(e);return{services:t,normalizeLayoutPatchValue:r=>lc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>Zy(r,n,t),canPatchMultiField:(r,n,o,a)=>DO(r,n,o,a,t),patchLayout:(r,n,o)=>MO(r,n,o,t),patchKind:(r,n,o)=>wO(r,n,o,t),patchInspectorField:(r,n,o,a)=>kO(r,n,o,a,t),normalizeGameObject:r=>Rn(r,t),replaceUi:(r,n,o)=>RO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>ac(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>CO(r,n,t),normalizeScales:(r,n,o)=>dc(r,t,n,o),mergeDefaults:r=>dt(r,t.createDefaultGroundDecal,t)}}function Wy(e){return{...e.policy,createDocumentInspectorProperty:e.createDocumentInspectorProperty,normalizeValue:e.normalizeValue,findTarget:e.findTarget,getTargetId:e.getTargetId,getTargetNodeKind:e.getTargetNodeKind,getTargetGroundDecal:e.getTargetGroundDecal,canShowTarget:e.canShowTarget,isUiTarget:e.isUiTarget,canPatchMultiField:e.canPatchMultiField,findTextureAsset:e.findTextureAsset,resolveTextureAssetUrl:e.resolveTextureAssetUrl,getMaterialText:e.getMaterialText,createTexturePickerControlOptions:e.createTexturePickerControlOptions}}var PO=75;function qu(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:eh({x:typeof r.x=="number"?r.x:1,y:typeof r.y=="number"?r.y:1,z:typeof r.z=="number"?r.z:1})}return!/^transform\.scale\.(x|y|z)$/.test(e)||typeof t!="number"||!Number.isFinite(t)?null:Math.max(.001,Math.abs(t))}function lc(e,t={}){let r=qa(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>TO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function TO(e,t,r={}){let n=qa(e);if(!n)return null;let o=nR(n.id)??`layer_${t}`,a=To(n.rect),i=n.fontSize==null?null:ic(n.fontSize),s=n.rotationDeg==null?null:Ao(n.rotationDeg);return!a||n.fontSize!=null&&i==null||n.rotationDeg!=null&&s==null?null:{id:o,rect:a,...s==null?{}:{rotationDeg:s},...i==null?{}:{fontSize:Lr(i)}}}function To(e){let t=qa(e);if(!t)return null;let r=Xt(t.x),n=Xt(t.z),o=ic(t.width),a=ic(t.depth);return r==null||n==null||o==null||a==null?null:{x:r,z:n,width:o,depth:a}}function Xt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ic(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function qy(e,t){if(e==="groundDecal.editorPreviewActive")return typeof t=="boolean"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(uc(e))return To(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Jy(e)){let r=Ao(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(mc(e))return typeof t=="string"?{ok:!0,value:t.trim()}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(gc(e))return typeof t=="string"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Xy(e)){let r=Xu(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(fc(e)||yc(e)||bc(e)){let r=Va(t);return r?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(pc(e)||hc(e)||Sc(e)){let r=Ua(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(Ec(e)){let r=Ju(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(zr(e)){let r=Wa(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Ka(e){let t=e.match(/^groundDecal\.layers\.(\d+)\.(rect|rotationDeg|textureId|text\.value|text\.fontSize|color|color\.a|tint|tint\.a|text\.color|text\.color\.a|editorPreviewPercent)$/);if(!t)return null;let r=Number(t[1]);return!Number.isInteger(r)||r<0?null:{index:r,field:t[2]}}function uc(e){return/^groundDecal\.layers\.\d+\.rect$/.test(e)}function Jy(e){return/^groundDecal\.layers\.\d+\.rotationDeg$/.test(e)}function mc(e){return/^groundDecal\.layers\.\d+\.textureId$/.test(e)}function fc(e){return/^groundDecal\.layers\.\d+\.color$/.test(e)}function pc(e){return/^groundDecal\.layers\.\d+\.color\.a$/.test(e)}function gc(e){return/^groundDecal\.layers\.\d+\.text\.value$/.test(e)}function Xy(e){return/^groundDecal\.layers\.\d+\.text\.fontSize$/.test(e)}function bc(e){return/^groundDecal\.layers\.\d+\.text\.color$/.test(e)}function Sc(e){return/^groundDecal\.layers\.\d+\.text\.color\.a$/.test(e)}function yc(e){return/^groundDecal\.layers\.\d+\.tint$/.test(e)}function hc(e){return/^groundDecal\.layers\.\d+\.tint\.a$/.test(e)}function Ec(e){return/^groundDecal\.layers\.\d+\.editorPreviewPercent$/.test(e)}function zr(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ic(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Ka(e)||zr(e)}function Ha(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ic(e)}function xO(e,t,r={}){return t==="rect"?xo(e,r):t==="rotationDeg"?Tc(e,r):t==="textureId"||t==="tint"||t==="tint.a"?sc(e,r):t==="text.value"||t==="text.fontSize"||t==="text.color"||t==="text.color.a"?Yy(e,r):t==="color"||t==="color.a"?cc(e,r):t==="editorPreviewPercent"?e.kind==="textureProgress"?sc(e,r):e.kind==="progress"&&cc(e,r):!1}function Pc(e,t={}){return t.isProjectEditableLayer?.(e)??e.enabled!==!1}function xo(e,t={}){return t.isLayoutEditableLayer?.(e)??e.enabled!==!1}function Tc(e,t={}){return t.isRotationEditableLayer?.(e)??!1}function sc(e,t={}){return t.isEditableTextureLayer?.(e)??(e.kind==="texture"||e.kind==="textureProgress")}function cc(e,t={}){return t.isEditableColorLayer?.(e)??(e.kind==="color"||e.kind==="progress")}function Yy(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function Zy(e,t,r={}){let n=e.layers.filter(o=>xo(o,r));return t.length!==n.length?!1:n.every((o,a)=>{let i=t[a];return i?.id===o.id&&(i.fontSize==null||o.kind==="text")&&(i.rotationDeg==null||Tc(o,r))})}function Va(e){let t=qa(e);if(!t)return null;let r=Xt(t.r),n=Xt(t.g),o=Xt(t.b);if(r==null||n==null||o==null)return null;let a=Xt(t.a);return{r:Lr(Math.max(0,Math.min(1,r))),g:Lr(Math.max(0,Math.min(1,n))),b:Lr(Math.max(0,Math.min(1,o))),...a==null?{}:{a:Lr(Math.max(0,Math.min(1,a)))}}}function Ua(e){let t=Xt(e);return t==null?null:Lr(Math.max(0,Math.min(1,t)))}function Ju(e){let t=Xt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function Ao(e){let t=Xt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=Lr(r);return Object.is(n,-0)?0:n}function Xu(e){let t=ic(e);return t==null?null:Lr(t)}function Wa(e){let t=Xt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function Lr(e){return Math.round(e*1e3)/1e3}function xc(e,t){return e==="groundDecal.editorPreviewActive"?t===!0:e==="groundDecal.layers"?lc(t)??t:uc(e)?To(t)??t:Jy(e)?Ao(t)??t:mc(e)&&typeof t=="string"?t.trim():gc(e)&&typeof t=="string"?t:Xy(e)?Xu(t)??t:fc(e)||yc(e)||bc(e)?Va(t)??t:pc(e)||hc(e)||Sc(e)?Ua(t)??t:Ec(e)?Ju(t)??t:zr(e)?Wa(t)??t:t}function Qy(e,t,r){if(t==="rect"){let n=To(r);return n?AO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=Ao(r);if(n==null)return null;if(n===0){if(e.rotationDeg==null)return e;let{rotationDeg:o,...a}=e;return a}return e.rotationDeg===n?e:{...e,rotationDeg:n}}if(t==="textureId"){if(e.kind!=="texture"&&e.kind!=="textureProgress"||typeof r!="string")return null;let n=r.trim();if(!n){if(!e.textureId)return e;let{textureId:o,...a}=e;return a}return e.textureId===n?e:{...e,textureId:n}}if(t==="text.value")return e.kind!=="text"||typeof r!="string"?null:e.text.value===r?e:{...e,text:{...e.text,value:r}};if(t==="text.fontSize"){if(e.kind!=="text")return null;let n=Xu(r);return n==null?null:e.text.fontSize===n?e:{...e,text:{...e.text,fontSize:n}}}if(t==="color"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Va(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return Po(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ua(r);if(n===null)return null;let o={...e.color,a:n};return Po(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=Ju(r);return n===null?null:e.editorPreviewPercent===n?e:{...e,editorPreviewPercent:n}}if(t==="tint"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Va(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return Po(e.tint??Ba,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ua(r);if(n===null)return null;let o={...Ba,...e.tint??{},a:n};return Po(e.tint??Ba,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=Va(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Ua(r);if(n===null)return null;let o={...e.text.color,a:n};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}return null}function dt(e,t,r={}){let n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=typeof n?.uiKind=="string"?n.uiKind.trim():"",a=o&&(r.isKnownUiKind?.(o)??!0)?o:r.defaultUiKind??"default",i=t(a);return n?{...i,...structuredClone(n),uiKind:a,size:{...i.size,...n.size&&typeof n.size=="object"?n.size:{}},layers:Array.isArray(n.layers)&&n.layers.length>0?structuredClone(n.layers):i.layers,mask:n.mask&&typeof n.mask=="object"?{...i.mask??{},...n.mask}:i.mask,rendering:n.rendering&&typeof n.rendering=="object"?{...i.rendering??{},...n.rendering}:i.rendering}:i}function Po(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function AO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function eh(e){let t=[e.x,e.y,e.z].filter(n=>Number.isFinite(n));if(t.length===0)return 1;let r=t.reduce((n,o)=>Math.abs(o-1)>Math.abs(n-1)?o:n,t[0]);return Math.max(.001,Math.abs(r))}function DO(e,t,r,n,o){if(!Ha(r))return!1;let a=_O(e,t);if(!a||!o.canShowGroundDecalInspector(a))return!1;let i=dt(a.groundDecal,o.createDefaultGroundDecal,o);if(r==="groundDecal.size.width"||r==="groundDecal.size.depth"||zr(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=lc(n,o);return d?Zy(i,d,o):!1}let s=Ka(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Pc(c,o)&&xO(c,s.field,o)}function MO(e,t,r,n){let o=lc(r,n);return o?rh(e,a=>a.id===t?vO(a,o,n):a):e}function wO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:rh(e,a=>a.id===t?GO(a,o,n):a)}function kO(e,t,r,n,o){if(r==="groundDecal.editorPreviewActive"){if(typeof n!="boolean")return e;let d=!1,u=e.scene.gameObjects.map(l=>{if(l.id!==t||!o.canShowGroundDecalInspector(l))return l;let m=dt(l.groundDecal,o.createDefaultGroundDecal,o);return m.editorPreviewActive===n?l:(d=!0,Rn({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if(zr(r))return OO(e,t,r,n,o);let a=Ka(r);if(!a)return null;let i=!1,s=xc(r,n),c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o),l=u.layers[a.index];if(!l||!Pc(l,o)||a.field==="rect"&&!xo(l,o))return d;let m=Qy(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,Rn({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function OO(e,t,r,n,o){let a=Wa(n);if(a===null)return e;let i=r==="groundDecal.rendering.textureWidth"?"textureWidth":"textureHeight",s=!1,c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o);return u.rendering?.[i]===a?d:(s=!0,Rn({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function RO(e,t,r,n){if(!n.isGroundDecalConfig(r))return e;let o=!1,a=e.scene.gameObjects.map(i=>i.id!==t||!n.isGroundDecalUiGameObject(i)||i.groundDecal.uiKind!==r.uiKind?i:(o=!0,Rn({...i,kind:"transform",transformType:"groundDecal",groundDecal:dt(r,n.createDefaultGroundDecal,n)},n)));return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function ac(e,t,r,n,o){return r.startsWith("transform.scale")?dc(e,o,t,qu(r,n)):e}function CO(e,t,r){if(t.type==="document.replace")return dc(e,r);let n=t.patch;return n.kind==="game-object.field"?ac(e,String(n.targetId??""),String(n.path??""),n.value,r):n.kind==="game-object.property-field-batch"&&Array.isArray(n.fields)?n.fields.reduce((o,a)=>{let i=qa(a);return ac(o,String(i?.targetId??""),String(i?.path??""),i?.value,r)},e):n.kind==="game-object.field-batch"?Array.isArray(n.targetIds)?n.targetIds.reduce((o,a)=>ac(o,String(a),String(n.path??""),n.value,r),e):e:dc(e,r)}function dc(e,t,r,n){let o=!1,a=e.scene.gameObjects.map(i=>{if(r&&i.id!==r||!t.isGroundDecalUiGameObject(i))return i;let s=G(i);if(!s||!FO(s)||!s.scale)return i;let c=n??eh(s.scale);return Math.abs(s.scale.x-c)<1e-6&&Math.abs(s.scale.y-c)<1e-6&&Math.abs(s.scale.z-c)<1e-6?i:(o=!0,{...i,components:i.components.map(d=>d===s?{...d,scale:{x:c,y:c,z:c}}:d)})});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function Rn(e,t){let r=jO({...e,kind:"transform",transformType:"groundDecal",groundDecal:dt(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function th(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function vO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=dt(e.groundDecal,r.createDefaultGroundDecal,r);return Rn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!xo(a,r))return a;let s=n.get(a.id)??t[i];if(!s)return a;let c=a.kind==="text"?{...a.rect,x:s.rect.x,z:s.rect.z}:s.rect,d=a.kind==="text"&&s.fontSize!=null?{...a,rect:c,text:{...a.text,fontSize:s.fontSize}}:{...a,rect:c};return s.rotationDeg!=null&&Tc(a,r)&&(d=Qy(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function GO(e,t,r){let n=dt(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return Rn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function jO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[NO(),...e.components]}}function NO(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function FO(e){return e.type==="Transform"&&e.mode!=="matrix"}function _O(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function rh(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function nh(e,t,r={},n){let o=dt(t,n.createDefaultGroundDecal,n),a=[rR("groundDecal.uiKind","Type",n.createUiKindLabel?.(o.uiKind)??o.uiKind,0),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.width",label:"Width",valueType:"number",control:"number",value:o.size.width,commitMode:"live",order:1,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.depth",label:"Depth",valueType:"number",control:"number",value:o.size.depth,commitMode:"live",order:2,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureWidth",label:"Texture Width",valueType:"number",control:"number",value:o.rendering?.textureWidth??512,commitMode:"change",order:3,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureHeight",label:"Texture Height",valueType:"number",control:"number",value:o.rendering?.textureHeight??512,commitMode:"change",order:4,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.layers",label:"Layout",valueType:"object",control:"custom",customControl:"ground-decal-layout",value:ch(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:eR(o),aspectRatioUsesDecalSize:QO(o),sizeWidth:o.size.width,sizeDepth:o.size.depth}})],i=10;if((n.canShowActivePreview?.(o)??!1)&&a.push(n.createDocumentInspectorProperty(null,e,{path:"groundDecal.editorPreviewActive",label:"Preview Active Background",valueType:"boolean",control:"boolean",value:o.editorPreviewActive===!0,commitMode:"immediate",order:6,tags:["GroundDecalUI","Preview"],controlOptions:{refreshInspector:!1}})),r.enableGroundDecalUiActions&&(n.canShowLayerPairActions?.(o)??!1)&&n.layerPairActions){let s=n.getLayerPairs?.(o).length??0,c=n.canAddLayerPair?.(o)??!1,d=n.canRemoveLayerPair?.(o)??!1;a.push(Ky({path:n.layerPairActions.addPath??"groundDecal.layerPairs.add",label:n.layerPairActions.addLabel??"Add item",actionId:n.layerPairActions.addActionId,order:i,icon:"asset",tooltip:n.layerPairActions.addTooltip??"Add an item.",params:{},disabled:!c,disabledReason:c?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"add",pairCount:s}),effect:c?"active":"unsupported"})),i+=1,a.push(Ky({path:n.layerPairActions.removePath??"groundDecal.layerPairs.remove",label:n.layerPairActions.removeLabel??"Remove item",actionId:n.layerPairActions.removeActionId,order:i,icon:"asset",tooltip:n.layerPairActions.removeTooltip??"Remove an item.",params:{},disabled:!d,disabledReason:d?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"remove",pairCount:s}),effect:d?"active":"unsupported"})),i+=1}for(let s=0;s<o.layers.length;s+=1){let c=o.layers[s];if(!c||!Pc(c,n))continue;let d=dh(c,n);if(sc(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=qO(e,r,c,s,d,i,n);u!=="stretch"&&o.lockAspectToBorder===!0&&o.aspectSourceLayerId===c.id&&(l.controlOptions={...l.controlOptions,groundDecalAspectSizeWidth:o.size.width,groundDecalAspectSizeDepthPath:"groundDecal.size.depth",groundDecalAspectTextureWidth:o.rendering?.textureWidth??512,groundDecalAspectTextureHeight:o.rendering?.textureHeight??512,groundDecalAspectTextureWidthPath:"groundDecal.rendering.textureWidth",groundDecalAspectTextureHeightPath:"groundDecal.rendering.textureHeight"}),a.push(l),i+=1,a.push(YO(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&cc(c,n)||c.kind==="textureProgress"&&sc(c,n))&&(a.push(XO(e,c,s,d,i,n)),i+=1),cc(c,n)&&(a.push(JO(e,c,s,d,i,n)),i+=1),Yy(c,n)&&(a.push(n.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${s}.text.value`,label:`${d} Text`,valueType:"string",control:"string",value:c.text.value,commitMode:"blur",order:i,tags:["GroundDecalUI","Text"]})),i+=1,a.push(ZO(e,c,s,d,i,n)),i+=1)}return tR(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function oh(e,t,r,n){let o=n.getTargetGroundDecal(e),a=dt(o,n.createDefaultGroundDecal,n),i=nh(t,a,{...r,enableGroundDecalUiActions:n.isUiTarget?.(e)??!1},n),s=i.find(d=>d.path==="groundDecal.layers");if(!s)throw new Error("Ground Decal Inspector requires the canonical layout property.");let c=i.filter(d=>d!==s).map(d=>({...d,controlOptions:{...d.controlOptions,groundDecalWorkbenchChild:!0}}));return{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:LO(a,n),persistence:"document",collapsedByDefault:!1,properties:[$O(a,[s,...c],n),...c]}}function $O(e,t,r){let n=t.find(a=>a.path==="groundDecal.layers");if(!n||!n.value||typeof n.value!="object"||Array.isArray(n.value))throw new Error("Ground Decal Inspector requires the canonical layout property.");let o={uiKind:e.uiKind,uiKindLabel:r.createUiKindLabel?.(e.uiKind)??e.uiKind,layout:n.value,properties:t.filter(a=>a!==n)};return{...n,label:"Ground Decal Editor",customControl:"ground-decal-workbench",value:o,controlOptions:{...n.controlOptions,refreshInspector:!1}}}function LO(e,t){let r=t.createUiKindLabel?.(e.uiKind)??e.uiKind,n=Math.max(1,Math.round(e.rendering?.textureWidth??512)),o=Math.max(1,Math.round(e.rendering?.textureHeight??512)),a=n===o?`${n}\xB2`:`${n}\xD7${o}`,i=t.canShowLayerPairActions?.(e)??!1?t.getLayerPairs?.(e).length??0:0;return i>0?`${r} \xB7 ${i} item${i===1?"":"s"} \xB7 ${a}`:`${r} \xB7 ${a}`}function ah(e,t,r,n,o){let a=sh(e,t,o);if(a.length<=1)return null;let i=a.find(l=>o.getTargetId(l.target)===r)??a[0];if(!i)return null;let s=zO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=nh(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>VO(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:UO(a,l.path,n,o)}));return d.length===0?null:{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:a.some(l=>l.decal.uiKind!==i.decal.uiKind)?"Mixed":`${a.length} ${o.createUiKindLabel?.(i.decal.uiKind)??i.decal.uiKind} UIs`,persistence:"document",collapsedByDefault:!1,properties:d}}function ih(e,t,r){return sh(e,t,r).map(n=>r.getTargetId(n.target))}function sh(e,t,r){let n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.findTarget(e,a);!i||!r.canShowTarget(i)||o.push({target:i,decal:dt(r.getTargetGroundDecal(i),r.createDefaultGroundDecal,r)})}return o}function zO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>BO(o,t));return n.every(o=>o===r)}function BO(e,t={}){return e.layers.map((r,n)=>({layer:r,index:n})).filter(r=>Pc(r.layer,t)).map(({layer:r,index:n})=>`${n}:${r.id}:${r.role}:${r.kind}`).join("|")}function VO(e,t){return e.path==="groundDecal.raw"?!1:e.path==="groundDecal.uiKind"||e.path==="groundDecal.size.width"||e.path==="groundDecal.size.depth"||e.path==="groundDecal.editorPreviewActive"||zr(e.path)?!0:e.path==="groundDecal.layers"||Ka(e.path)?t:!1}function UO(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(KO(i.decal,t,r,n)));return a.some(i=>i!==o)}function KO(e,t,r,n){if(t==="groundDecal.uiKind")return e.uiKind;if(t==="groundDecal.size.width")return e.size.width;if(t==="groundDecal.size.depth")return e.size.depth;if(t==="groundDecal.editorPreviewActive")return e.editorPreviewActive===!0;if(t==="groundDecal.rendering.textureWidth")return e.rendering?.textureWidth??512;if(t==="groundDecal.rendering.textureHeight")return e.rendering?.textureHeight??512;if(t==="groundDecal.layers")return ch(e,r,n).layers;let o=Ka(t);if(!o)return;let a=e.layers[o.index];if(a)return HO(a,o.field)}function HO(e,t){if(t==="rect")return e.rect;if(t==="rotationDeg")return e.rotationDeg??0;if(t==="textureId")return e.kind==="texture"||e.kind==="textureProgress"?e.textureId:void 0;if(t==="text.value")return e.kind==="text"?e.text.value:void 0;if(t==="text.fontSize")return e.kind==="text"?e.text.fontSize:void 0;if(t==="color")return e.kind==="color"||e.kind==="progress"?e.color:void 0;if(t==="color.a")return e.kind==="color"||e.kind==="progress"?e.color.a??1:void 0;if(t==="tint")return e.kind==="texture"||e.kind==="textureProgress"?e.tint??Ba:void 0;if(t==="tint.a")return e.kind==="texture"||e.kind==="textureProgress"?e.tint?.a??1:void 0;if(t==="text.color")return e.kind==="text"?e.text.color:void 0;if(t==="text.color.a")return e.kind==="text"?e.text.color.a??1:void 0;if(t==="editorPreviewPercent")return e.kind==="progress"||e.kind==="textureProgress"?Yu(e):void 0}function ch(e,t,r){let n=_i(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>xo(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>Vy(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=Vy(t,a,i,r),c=r.getLayerPreviewVisibility?.(a,e);return c?{...s,enabled:s.enabled!==!1&&c.value,previewVisibilityPath:c.path,previewVisibilityBaseEnabled:s.enabled!==!1}:s})}}function Vy(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:dh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Tc(t,n),enabled:t.enabled!==!1,editable:xo(t,n),zOrder:t.zOrder,...typeof t.opacity=="number"?{opacity:t.opacity}:{},...n.useUniformLayoutScaleMode?.(t)?{scaleMode:"uniform"}:{},...t.kind==="progress"||t.kind==="textureProgress"?{previewValuePath:`groundDecal.layers.${r}.editorPreviewPercent`}:{},...t.kind==="text"&&typeof t.text.fontSize=="number"?{fontSize:t.text.fontSize}:{},preview:WO(e,t,n)}}function dh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function WO(e,t,r){if(t.kind==="texture"||t.kind==="textureProgress"){if(!t.textureId)return;let n=r.findTextureAsset?.(e,t.textureId)??null,o=n?.url??e.resolveTextureAssetUrl?.(t.textureId)??r.resolveTextureAssetUrl?.(t.textureId);return o?{kind:t.kind==="textureProgress"?"imageProgress":"image",url:o,alt:n?.label??t.textureId,imageFit:r.resolveImageFit?.(t)??t.imageFit??"contain",...t.tint?{tint:t.tint}:{},...t.kind==="textureProgress"?{value:Uy(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:Uy(t),direction:t.direction,color:t.color};if(t.kind==="text")return{kind:"text",text:t.text.value,fontFamily:t.text.fontFamily,fontSize:t.text.fontSize,fontWeight:t.text.fontWeight,color:t.text.color,strokeColor:t.text.strokeColor,strokeWidth:t.text.strokeWidth,align:t.text.align,baseline:t.text.baseline}}function Yu(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:PO;return Math.round(Math.max(0,Math.min(100,t)))}function Uy(e){return Yu(e)/100}function qO(e,t,r,n,o,a,i){let s=i.getMaterialText?.("zh"),c=i.findTextureAsset?.(t,r.textureId)??null,d=`groundDecal.layers.${n}.textureId`;return i.createDocumentInspectorProperty(null,e,{path:d,label:`${o} PNG`,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.textureId??"",commitMode:"change",order:a,tags:["GroundDecalUI","TextureAsset"],controlOptions:i.createTexturePickerControlOptions?.(t,s,r.textureId,c)??{currentTextureId:r.textureId,currentTexture:c},coerce:u=>i.normalizeValue(d,u)})}function JO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function XO(e,t,r,n,o,a){let i=`groundDecal.layers.${r}.editorPreviewPercent`;return a.createDocumentInspectorProperty(null,e,{path:i,label:`${n} Preview %`,valueType:"number",control:"number",value:Yu(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function YO(e,t,r,n,o,a){let i=t.tint??Ba;return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.tint`,label:`${n} Color`,valueType:"color",control:"color",value:i,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function ZO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.text.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.text.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function QO(e){return e.size.width>0&&e.size.depth>0}function eR(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function tR(e,t){let r=j(t);r&&e.push(r)}function rR(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Ky(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function qa(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function nR(e){return typeof e=="string"&&e.trim()?e.trim():null}var Cn="groundDecal";function oR(e){if(e.id!==Cn||e.scene?.kind!==Cn||!e.config||typeof e.config!="object"||Array.isArray(e.config))return null;let t=e.config;return!Array.isArray(t.uiKinds)||t.uiKinds.length===0||t.uiKinds.some(r=>typeof r!="string"||r.trim().length===0)||!t.documentPolicy||typeof t.documentPolicy!="object"||Array.isArray(t.documentPolicy)||typeof t.documentPolicy.createDefaultGroundDecal!="function"||typeof t.documentPolicy.isGroundDecalConfig!="function"?null:t}function lh(e,t){let r=oR(e);if(!r)return null;let n=r.documentPolicy,o=aR(n),a=s=>s?.transformType===Cn&&o.isGroundDecalConfig(s.groundDecal);return iR({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>Wy({policy:{...o,...r.inspectorPolicy??{}},createDocumentInspectorProperty:s,normalizeValue:xc,findTarget:(d,u)=>d.scene.gameObjects.find(l=>l.id===u)??null,getTargetId:d=>d.id,getTargetNodeKind:d=>d.kind??"transform",getTargetGroundDecal:d=>d.groundDecal??null,canShowTarget:a,isUiTarget:a,canPatchMultiField:c.canPatchMultiField,findTextureAsset:(d,u)=>ou(d,u??""),getMaterialText:gr,createTexturePickerControlOptions:(d,u,l,m)=>qs(d,u,l??"",m)}),getDocumentInspectorPropertyFactory:t,createDefaultGroundDecal:o.createDefaultGroundDecal,createObjectPatch:s=>({kind:"game-object.create-primitive",gameObject:s}),isGroundDecalObject:a,createHierarchyLabel:r.createHierarchyLabel}).contribution}function aR(e){let t=e;return{...e,createDefaultGroundDecal:r=>structuredClone(e.createDefaultGroundDecal(r)),isGroundDecalConfig(r){return e.isGroundDecalConfig(structuredClone(r))},...typeof t.isProjectEditableLayer=="function"?{isProjectEditableLayer:r=>t.isProjectEditableLayer(structuredClone(r))}:{},...typeof t.isLayoutEditableLayer=="function"?{isLayoutEditableLayer:r=>t.isLayoutEditableLayer(structuredClone(r))}:{},...typeof t.isRotationEditableLayer=="function"?{isRotationEditableLayer:r=>t.isRotationEditableLayer(structuredClone(r))}:{}}}function iR(e){let r=(e.features.find(i=>i.id===Cn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=Hy({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=sR({uiKinds:n,documentBridge:o,createInspectorServices:i=>e.createInspectorServices(i,o),getDocumentInspectorPropertyFactory:e.getDocumentInspectorPropertyFactory,createDefaultGroundDecal:e.createDefaultGroundDecal,createObjectPatch:e.createObjectPatch,canShowInspector:e.isGroundDecalObject,isGroundDecalObject:e.isGroundDecalObject,createHierarchyLabel:e.createHierarchyLabel});return{bridge:o,contribution:a,uiKinds:n,resolve(i){return i.id===Cn&&i.scene?.kind===Cn?a:null}}}function sR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:Cn}],normalizeInspectorValue:(n,o)=>n.startsWith("groundDecal.")?xc(n,o):void 0,validateInspectorField({path:n,value:o}){if(n==="groundDecal.uiKind")return e.uiKinds.includes(String(o))?{ok:!0,value:o}:{ok:!1,message:"Invalid value for scene node field: groundDecal.uiKind."};if(n==="groundDecal.size.width"||n==="groundDecal.size.depth")return typeof o=="number"&&Number.isFinite(o)&&o>0?{ok:!0,value:o}:{ok:!1,message:`Invalid value for scene node field: ${n}.`};if(n==="groundDecal.layers"){let a=t.normalizeLayoutPatchValue(o);return a?{ok:!0,value:a}:{ok:!1,message:"Invalid value for scene node field: groundDecal.layers."}}return qy(n,o)},isInspectorPatchPath:Ic,isProjectionPath:th,normalizeDocumentAfterCommand:t.normalizeScalesForCommand,normalizeAfterFieldPatch:t.normalizeScaleAfterFieldPatch,fieldMutation:{isCustomTransformType:n=>n==="groundDecal",applyCustomTransformType(n,o){o==="groundDecal"&&(n.groundDecal=t.mergeDefaults(n.groundDecal))},clearCustomTransformState(n,o){o!=="groundDecal"&&delete n.groundDecal},patchCustomTransformField(n,o,a){return o.startsWith("groundDecal.")?(n.kind="transform",n.transformType=n.transformType??"groundDecal",delete n.primitive,n.groundDecal=t.mergeDefaults(n.groundDecal),dR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=qu(o,a);return s===null?null:{label:`Patch ${n.id} transform.scale`,patch:{kind:"game-object.field",targetId:n.id,path:"transform.scale",value:{x:s,y:s,z:s}},changedId:n.id,changedIds:i()}},patchGameObjectField:({document:n,targetId:o,path:a,value:i})=>a==="groundDecal.uiKind"?t.patchKind(n,o,i):a==="groundDecal.layers"?t.patchLayout(n,o,i):t.patchInspectorField(n,o,a,i),patchGameObjectsField:({document:n,targetIds:o,path:a,value:i,patchSingle:s})=>a==="groundDecal.uiKind"||a==="groundDecal.layers"||Ic(a)?o.reduce((c,d)=>s(c,d,a,i),n):null,reducePatch:({document:n,patch:o})=>o.kind==="game-object.ground-decal-ui.replace"?t.replaceUi(n,String(o.targetId),o.groundDecal):null,createHierarchyPatch:(n,o)=>cR(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[oh(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>ah(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>ih(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Ha,isSerializedMultiProjectionPath:Ha,getSerializedMultiProbeValue:lR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Ha(a)||t.canPatchMultiField(n,o,a,i)}}function cR(e,t,r){let n=t.startsWith("ground-decal:")?t.slice(13):"";if(!r.uiKinds.includes(n))return null;let o=it(e.scene.gameObjects.map(d=>d.id),`${n}_ground_decal_ui`),a=r.createHierarchyLabel?.(n)??`${n} Ground Decal UI`,i=new Set(e.scene.gameObjects.map(d=>d.name).filter(Boolean)),s=a;for(let d=2;i.has(s);d+=1)s=`${a} ${d}`;let c={id:o,guid:he(),name:s,kind:"transform",parentId:ye(e)??void 0,active:!0,transformType:"groundDecal",groundDecal:r.createDefaultGroundDecal(n),components:[{type:"Transform",position:{x:0,y:.02,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Add ${a}`,patch:r.createObjectPatch(c),createdId:o,changedIds:[o],reprojectIds:[o]}}function dR(e,t,r){let n=t.split("."),o=e;for(let a of n.slice(0,-1))o=o[a]??={};o[n[n.length-1]]=r}function lR(e){if(e.endsWith(".width")||e.endsWith(".depth"))return 1;if(e.endsWith(".rotationDeg"))return 45;if(e.endsWith("textureWidth")||e.endsWith("textureHeight"))return 512;if(e==="groundDecal.layers")return{layers:[{id:"mainLogo",rect:{x:0,z:0,width:1,depth:1}}]};if(mc(e))return"texture_probe";if(gc(e))return"30";if(fc(e)||yc(e)||bc(e))return{r:1,g:1,b:1,a:1};if(pc(e)||hc(e)||Sc(e))return 1;if(Ec(e))return 75;if(uc(e))return To({x:0,z:0,width:1,depth:1});if(zr(e))return Wa(512)}function Ja(e){let t=typeof e=="string"&&e.trim()?e.trim():void 0;if(!t)return;if(t.includes("\0"))throw new Error("external_asset_path_must_be_portable");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))throw new Error("external_asset_path_must_be_portable");let n=[];for(let o of r.split("/"))if(!(!o||o===".")){if(o==="..")throw new Error("external_asset_path_must_be_portable");n.push(o)}if(n.length===0)throw new Error("external_asset_path_must_be_portable");return n.join("/")}function se(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ac(e,t=4,r="$"){if(!Number.isInteger(t)||t<0||t>100)throw new Error(`json.number.invalidDecimalPlaces: ${t}`);let n=[],o=a=>{if(typeof a=="number"){if(!Number.isFinite(a))throw new Error(`json.number.nonFinite: ${uR(r,n)}`);if(Object.is(a,-0))return 0;if(Number.isInteger(a))return a;let i=Number(a.toFixed(t));return Object.is(i,-0)?0:i}if(Array.isArray(a)){let i;for(let s=0;s<a.length;s+=1){let c=a[s];n.push(s);let d=o(c);n.pop(),!Object.is(d,c)&&(i??=a.slice(),i[s]=d)}return i??a}if(a&&typeof a=="object"){let i=a,s;for(let[c,d]of Object.entries(i)){n.push(c);let u=o(d);n.pop(),!Object.is(u,d)&&(s??={...i},s[c]=u)}return s??a}return a};return o(e)}function uR(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var Zu=64*1024,mR=8,uh=256,fR=8*1024,pR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function mh(e){if(!Xa(e))throw new Error("asset_import_payload_must_be_object");for(let a of Object.keys(e))if(!pR.has(a))throw new Error(`asset_import_field_not_allowed:${a}`);yR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:bR(t.assetPath),n=Do(t.projectAssetId,"projectAssetId");if(!r&&!n)throw new Error("asset_import_asset_path_or_project_asset_id_required");if(t.assetType!==void 0&&t.assetType!=="model"&&t.assetType!=="texture")throw new Error("asset_import_asset_type_invalid");let o=["platformAssetId","guid","assetName","displayName","mimeType","assetUrl","category","materialMode"];for(let a of o){let i=Do(t[a],a);i&&(t[a]=i)}for(let a of["placeable","singleton"])if(t[a]!==void 0&&typeof t[a]!="boolean")throw new Error(`asset_import_${a}_must_be_boolean`);if(t.warmupCount!==void 0&&(!Number.isInteger(t.warmupCount)||t.warmupCount<0))throw new Error("asset_import_warmupCount_must_be_non_negative_integer");for(let a of["defaultScale","scale"])t[a]!==void 0&&(t[a]=SR(t[a],a));if(t.metadata!==void 0&&!Xa(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!Xa(t.external))throw new Error("asset_import_external_must_be_object");let a=new Set(["platformAssetId","assetPath","assetUrl"]);for(let s of Object.keys(t.external))if(!a.has(s))throw new Error(`asset_import_external_field_not_allowed:${s}`);let i=t.external.assetPath===void 0?void 0:gR(t.external.assetPath,"external.assetPath");t.external={...Do(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:Do(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...Do(t.external.assetUrl,"external.assetUrl")?{assetUrl:Do(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function gR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=Ja(e);if(!r)throw new Error("empty");if(r.length>1024)throw new Error("too_long");return r}catch{throw new Error(`asset_import_${t}_must_be_project_relative`)}}function bR(e){if(typeof e!="string")throw new Error("asset_import_assetPath_must_be_string");let t=e.trim();if(!t||t.includes("\0")||t.length>4096)throw new Error("asset_import_assetPath_invalid");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||r.startsWith("//"))return r;try{return Ja(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function Do(e,t){if(e===void 0)return;if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);let r=e.trim();if(!r)throw new Error(`asset_import_${t}_must_not_be_empty`);if(r.length>1024)throw new Error(`asset_import_${t}_too_long`);return r}function SR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(Xa(e)&&Object.keys(e).every(r=>r==="x"||r==="y"||r==="z")&&typeof e.x=="number"&&Number.isFinite(e.x)&&e.x>0&&typeof e.y=="number"&&Number.isFinite(e.y)&&e.y>0&&typeof e.z=="number"&&Number.isFinite(e.z)&&e.z>0)return{x:e.x,y:e.y,z:e.z};throw new Error(`asset_import_${t}_invalid`)}function yR(e){let t=0,r=(n,o)=>{if(o>mR)throw new Error("asset_import_payload_too_deep");if(n===null||typeof n=="boolean")return;if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("asset_import_payload_number_invalid");return}if(typeof n=="string"){if(n.length>fR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>uh)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!Xa(n)||Object.getPrototypeOf(n)!==Object.prototype)throw new Error("asset_import_payload_not_json_safe");let a=Object.entries(n);if(t+=a.length,t>uh)throw new Error("asset_import_payload_too_many_values");for(let[,i]of a){if(i===void 0||typeof i=="function"||typeof i=="symbol"||typeof i=="bigint")throw new Error("asset_import_payload_not_json_safe");r(i,o+1)}};if(r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>Zu)throw new Error("asset_import_payload_too_large")}function Xa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ya(){return{isCoreMaterialOverridePath:ll,isMaterialAssetIdOverridePath:ag,addMaterialAsset:Ls}}function fh(e,t=[]){return e.assets.filter(Xe).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=hR(r,t);return[{id:`prefab:${r.id}`,assetId:r.id,guid:r.guid,type:"prefab",kind:"prefab",label:r.displayName??r.id,displayName:r.displayName??r.id,category:r.category??"Prefab",origin:"project",placeable:o.placeable,...o.availability?{availability:structuredClone(o.availability)}:{},dedupeKey:`prefab:${r.guid??r.id}`,prefab:{id:r.id,guid:r.guid,displayName:r.displayName??r.id,category:r.category??"Prefab",...structuredClone(r.prefab),sourceAssetId:n},metadata:structuredClone(r.metadata??{})}]})}function hR(e,t){let r=e.prefab?.sourceAssetId,n=typeof r=="string"?t.find(a=>a.assetId===r||a.id===r):void 0,o=n?.availability;return{placeable:n?.placeable!==!1&&o?.status!=="unavailable",...o?{availability:o}:{}}}function Qu(e,t,r=Ya()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(tm(e))return t==null?null:e==="prefab.defaults.shadow"?t:e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"?t===!0?"enabled":t===!1?"none":t:t;if(r.isMaterialAssetIdOverridePath(e)&&typeof t=="string"){let n=t.trim();return n||null}return t}function em(e,t,r=Ya()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(tm(e)){if(e==="prefab.defaults.shadow")return!!t&&typeof t=="object"&&typeof t.cast=="boolean"&&typeof t.receive=="boolean";let n=e.slice(16);return mo({path:n,nodeKind:"instance",value:t}).ok}return r.isCoreMaterialOverridePath(e)?r.isMaterialAssetIdOverridePath(e)&&(t==null||typeof t=="string"&&t.trim().length>0):!1}function tm(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function ph(e,t,r){let n=[...e.assets];r&&!n.some(a=>a.id===r.id)&&n.push(structuredClone(r));let o=Dc(t);return n.some(a=>a.id===t.id)||n.push(structuredClone(o)),n.length===e.assets.length?e:{...e,assets:n}}function rm(e,t,r,n,o=Ya()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Xe(s));if(!a)return e;let i=ER(bh(a),r,n,o);return JSON.stringify(i)===JSON.stringify(a)?e:{...e,assets:e.assets.map(s=>s.id===t?i:s)}}function gh(e,t,r,n){let o=e.assets.find(s=>s.id===t&&Xe(s));if(!o)return e;let a=n&&!e.assets.some(s=>s.id===n.id)?[...e.assets,structuredClone(n)]:e.assets,i=Dc({...structuredClone(r),id:t});return JSON.stringify(i)===JSON.stringify(o)&&a===e.assets?e:{...e,assets:a.map(s=>s.id===t?i:s)}}function ER(e,t,r,n=Ya()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||tm(t)){let o=structuredClone(e),a=structuredClone(o.prefab??e.prefab);if(a.defaults={...a.defaults??{}},t==="prefab.defaults.active")r==null?delete a.defaults.active:a.defaults.active=r;else{if(t==="prefab.defaults.shadow"){if(!r||typeof r!="object")return e;let s=r.cast,c=r.receive;return typeof s!="boolean"||typeof c!="boolean"?e:(a.defaults.shadow={cast:s?"enabled":"none",receive:c?"enabled":"none"},o.prefab=a,Dc(o))}if(r!=="enabled"&&r!=="none")return e;let i=a.defaults.shadow;a.defaults.shadow={cast:t==="prefab.defaults.shadow.cast"?r:i?.cast==="enabled"?"enabled":"none",receive:t==="prefab.defaults.shadow.receive"?r:i?.receive==="enabled"?"enabled":"none"}}return Object.keys(a.defaults).length===0&&delete a.defaults,o.prefab=a,Dc(o)}return ua(e,t,r)}function bh(e){if(!Xe(e))return e;let t=rg(e);return t.ok?t.prefabAsset:e}function Dc(e){if(!Xe(e))return e;let t=bh(e),r=Ye(t);if(!r||!Array.isArray(t.prefab?.nodes))return t;let n=t.prefab.nodes.findIndex(a=>a.id===r);if(n<0)return t;let o=structuredClone(t.prefab.nodes[n]);if(o.name=t.displayName??o.name,t.prefab.defaults){let{shadow:a,...i}=t.prefab.defaults;Object.keys(i).length>0?o.defaults=structuredClone(i):delete o.defaults}else delete o.defaults;return t.prefab.nodes=[...t.prefab.nodes],t.prefab.nodes[n]=o,t}function Sh(e,t,r,n,o=Ya()){let a=o.addMaterialAsset(e,n);return rm(a,t,r,n.id,o)}function hh(e,t,r,n){let o=Le(e,t.assetId),a=t.sourceAssetId??o?.prefab?.sourceAssetId,i=a?e.assets.find(l=>l.id===a):null,s=IR(i,a),c=Mc(i),d=PR(c,!!n.importStructureReady),u=Ih(n.importStructure)?Ph(n.importStructure):[];return wc([s,...d?[d]:[],...u],r)}function IR(e,t){return{id:"prefab-source",label:e?.displayName??t??"Missing source asset",kind:"source",sourceAssetId:t,...e?.metadata?.relativePath?{meta:e.metadata.relativePath}:{}}}function PR(e,t){return e.length===0?null:{id:"prefab-material-slots",label:`${t?"Editable Material Slots":"Meshes / Materials"} (${e.length})`,kind:"group",children:[...e]}}function Mc(e){return(Array.isArray(e?.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(xR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=xh(o.ownerNodePath),i=nt(r),s=i.map(m=>An(r,m)).filter(m=>!!m);if(s.length===0&&r.materialNames?.length&&s.push(...r.materialNames.filter(m=>typeof m=="string"&&!!m.trim())),s.length===0&&r.materialName&&s.push(r.materialName),!r.slotId)return null;let c=`prefab.overrides.materialSlotBindings.${r.slotId}`,d=o.sourceMaterialIndex,u=r.label??s[0]??a.split("/").filter(Boolean).pop()??`Material Slot ${n+1}`;return{id:`prefab-material-slot:${om(r.slotId??a,`material_slot_${n+1}`)}:${n+1}`,itemType:"prefab-material-slot",label:u,kind:"material",bindingKind:"slot",bindingPath:c,materialAssetIdPath:`${c}.materialAssetId`,profilePathPrefix:`${c}.override`,slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:a,...typeof o.nodeIndex=="number"?{nodeIndex:o.nodeIndex}:{},...o.nodeIndexPath?.length?{nodeIndexPath:o.nodeIndexPath}:{},...typeof o.meshIndex=="number"?{meshIndex:o.meshIndex}:{},...typeof o.primitiveIndex=="number"?{primitiveIndex:o.primitiveIndex}:{},...d==null?{}:{sourceMaterialIndex:d},...i.length>0?{sourceMaterialIndices:i}:{},...s[0]?{sourceMaterialName:s[0]}:{},...s.length>0?{sourceMaterialNames:s}:{},...r.sourceSurfaces.length===1&&typeof o.triangleCount=="number"?{triangleCount:o.triangleCount}:{},...r.sourceSurfaces.length===1&&o.boundingBox?{boundingBox:o.boundingBox}:{},meta:[a,r.sourceSurfaces.length===1?`primitive #${o.primitiveIndex}`:`${r.sourceSurfaces.length} source surfaces`,s.length>0?s.join(", "):null].filter(Boolean).join(" - ")}}).filter(r=>r!=null)}function Eh(e){return e.map(t=>[t.label,typeof t.primitiveIndex=="number"?`primitive #${t.primitiveIndex}`:null,typeof t.sourceMaterialIndex=="number"?`material #${t.sourceMaterialIndex}`:null,typeof t.triangleCount=="number"?`${t.triangleCount} triangles`:null,TR(t.boundingBox)].filter(Boolean).join(" \xB7 ")).join(`
4
- `)}function TR(e){if(!e)return null;let t=e.min?e.min.join(", "):"",r=e.max?e.max.join(", "):"";return t&&r?`bounds min ${t}; max ${r}`:t?`bounds min ${t}`:r?`bounds max ${r}`:null}function xR(e){return Or(e)}function Ih(e){return["nodes","materials","textures","animations"].some(t=>Za(e,t).length>0)}function Ph(e){let t=[],r=Za(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:AR(r)});let n=Za(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>nm(i,s,"material"))});let o=Za(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>nm(i,s,"texture"))});let a=Za(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>nm(i,s,"animation"))}),t}function AR(e){let t=e.map((o,a)=>{let i=Re(o.id)??`runtime-node-${a+1}`,s=Re(o.kind),c={id:`prefab-import-node:${om(i,`node_${a+1}`)}`,runtimeId:i,label:Re(o.name)??Re(o.sourceName)??i,kind:s==="mesh"?"mesh":s==="root"?"root":"group",...Re(o.ownerNodePath)?{ownerNodePath:Re(o.ownerNodePath)}:{},...Re(o.sourceName)?{sourceName:Re(o.sourceName)}:{},...Array.isArray(o.materialIds)?{materialIds:o.materialIds.filter(d=>typeof d=="string")}:{},children:[]};return{runtimeId:i,parentId:Re(o.parentId),item:c}}),r=new Map(t.map(o=>[o.runtimeId,o.item])),n=[];for(let o of t)o.parentId&&r.has(o.parentId)?r.get(o.parentId).children.push(o.item):n.push(o.item);return n}function nm(e,t,r){let n=Re(e.id)??`${r}-${t+1}`,o=Re(e.url),a=Array.isArray(e.nodeIds)?e.nodeIds.filter(s=>typeof s=="string"):[],i=Array.isArray(e.textureIds)?e.textureIds.filter(s=>typeof s=="string"):[];return{id:`prefab-import-${r}:${om(n,`${r}_${t+1}`)}`,itemType:r==="material"?"runtime-material":r==="texture"?"runtime-texture":"runtime-animation",runtimeId:n,label:Re(e.name)??n,kind:r,...Re(e.kind)?{runtimeKind:Re(e.kind)}:{},...o?{url:o}:{},...a.length>0?{nodeIds:a}:{},...i.length>0?{textureIds:i}:{},meta:[Re(e.kind),o,a.length>0?`${a.length} node${a.length===1?"":"s"}`:null,i.length>0?`${i.length} texture${i.length===1?"":"s"}`:null].filter(Boolean).join(" - ")}}function Th(e,t,r,n){if(r.itemType==="prefab-material-slot"||r.itemType==="runtime-material"||r.itemType==="runtime-texture")return r;if(r.itemType!=="prefab-node"||r.kind!=="model")return null;let o=typeof r.sourceAssetId=="string"?r.sourceAssetId:t.sourceAssetId;if(!o)return null;let a=e.assets.find(c=>c.id===o),i=Mc(a);if(i.length>0){let c=i[0]??null;return c?{...c,...typeof r.nodeId=="string"?{prefabNodeId:r.nodeId}:{}}:null}return(Ih(n.importStructure)?Ph(n.importStructure).find(c=>c.id==="prefab-import-materials"):null)?.children?.[0]??null}function wc(e,t){for(let r of e){if(r.id===t)return r;let n=r.children?wc(r.children,t):null;if(n)return n}return null}function xh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function om(e,t){return xh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Za(e,t){let n=yh(e)?.[t];return Array.isArray(n)?n.map(yh).filter(o=>!!o):[]}function yh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ah(e,t,r={}){let n=Le(e,t.assetId);if(!n?.prefab)return[{id:"prefab-scene",label:"Prefab Scene Tree",kind:"root",children:[]}];let o=Ye(n),a=cl(n,null);return[{id:"prefab-root",label:"Prefab Scene Tree",kind:"root",children:(o?a.filter(s=>s.id===o):a).map(s=>Dh(n,s))}]}function Dh(e,t){let r=cl(e,t.id).map(n=>Dh(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??DR(t),kind:t.kind,itemType:"prefab-node",...t.guid?{guid:t.guid}:{},...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.childPrefabId?{childPrefabId:t.childPrefabId}:{},...t.sourceNodePath?{sourceNodePath:t.sourceNodePath}:{},...t.transform?{transform:structuredClone(t.transform)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults&&Object.keys(t.defaults).length>0?{defaults:structuredClone(t.defaults)}:{},...t.overrides&&Object.keys(t.overrides).length>0?{overrides:structuredClone(t.overrides)}:{},...r.length>0?{children:r}:{}}}function DR(e){return e.kind==="model"?e.sourceAssetId??e.id:e.kind==="prefabInstance"?e.childPrefabId??e.id:e.kind==="primitive"?e.primitive?.shape??e.id:e.id}function Mh(e,t,r){if(t.itemType!=="prefab-node"||t.kind!=="model")return null;let n=typeof t.sourceAssetId=="string"?t.sourceAssetId:null;if(!n)return null;let o=e.assets.find(S=>S.id===n),a=Mc(o),i=Oc(o?.metadata?.assetAnalysis),s=am(i?.nodes),c=am(i?.meshes),d=kc(r.importStructure,"nodes").length,u=kc(r.importStructure,"materials").length,l=kc(r.importStructure,"textures").length,m=kc(r.importStructure,"animations").length,f=[kt("prefab.sourceStructure.sourceAsset","Source Asset",o?.displayName??n,0),kt("prefab.sourceStructure.assetId","Asset ID",n,1)];return o?.metadata?.relativePath&&f.push(kt("prefab.sourceStructure.relativePath","Relative Path",String(o.metadata.relativePath),2)),f.push(kt("prefab.sourceStructure.materialSlots","Material Slots",String(a.length),10),kt("prefab.sourceStructure.modelNodes","Model Nodes",s.length>0?MR(s):"No SDK node analysis",11),kt("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?wR(c):"No SDK mesh primitive analysis",12),kt("prefab.sourceStructure.runtimeNodes","Runtime Nodes",String(d),20),kt("prefab.sourceStructure.runtimeMaterials","Runtime Materials",String(u),21),kt("prefab.sourceStructure.runtimeTextures","Runtime Textures",String(l),22),kt("prefab.sourceStructure.runtimeAnimations","Runtime Animations",String(m),23)),a.length>0&&f.push(kt("prefab.sourceStructure.materialSlotSummary","Material Slot Summary",Eh(a),30)),{id:"prefab-source-structure",title:"Source Structure",summary:o?"Readonly GLB / glTF anatomy":"Missing source asset",persistence:"readonly",effect:o?"active":"unsupported",properties:f}}function MR(e){return e.slice(0,8).map((t,r)=>{let n=Rc(t.ownerNodePath)??Rc(t.name)??`node #${typeof t.nodeIndex=="number"?t.nodeIndex:r}`,o=typeof t.meshIndex=="number"?`mesh #${t.meshIndex}`:null,a=typeof t.primitiveCount=="number"?`${t.primitiveCount} primitives`:null;return[n,o,a].filter(Boolean).join(" \xB7 ")}).join(`
5
- `)}function wR(e){return e.slice(0,8).map((t,r)=>{let n=Rc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=am(t.primitives);if(o.length===0)return n;let a=o.slice(0,6).map((i,s)=>[`p${typeof i.primitiveIndex=="number"?i.primitiveIndex:s}`,typeof i.sourceMaterialIndex=="number"?`mat #${i.sourceMaterialIndex}`:null,Rc(i.materialName),typeof i.triangleCount=="number"?`${i.triangleCount} tri`:null].filter(Boolean).join(" ")).join(", ");return`${n}: ${a}`}).join(`
6
- `)}function kc(e,t){let n=Oc(e)?.[t];return Array.isArray(n)?n.map(Oc).filter(o=>!!o):[]}function Oc(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function am(e){return Array.isArray(e)?e.map(Oc).filter(t=>!!t):[]}function Rc(e){return typeof e=="string"&&e.trim()?e.trim():null}function kt(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function wh(e,t,r){let n=e.prefab?.defaults?.shadow;return[Qa({path:"prefab.defaults.shadow.cast",label:"Cast Shadow",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",order:t+0,tooltip:"Controls shadow casting for the entire Prefab definition."},r),Qa({path:"prefab.defaults.shadow.receive",label:"Receive Shadow",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",order:t+1,tooltip:"Controls shadow receiving for the entire Prefab definition."},r)]}function Qa(e,t){let r=n=>t.normalizePrefabAssetFieldValue(e.path,e.coerce?e.coerce(n):n);return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,...e.mixed===!0?{mixed:!0}:{},readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},...e.tooltip?{tooltip:e.tooltip}:{},validate:n=>t.validatePrefabAssetFieldValue(e.path,r(n))?{ok:!0,value:r(n)}:{ok:!1,message:`Invalid prefab field: ${e.path}.`},coerce:r}}function kR(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?OR(e,t,r,n,o,a()):r.itemType==="runtime-material"?kh("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?kh("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function OR(e,t,r,n,o,a){let i=gr("en"),s=ig(t,r),c=r.prefabNodeId?oo(t,r.prefabNodeId):null,d=r.prefabNodeId&&r.slotId?c?.overrides?.materialSlotBindings?.[r.slotId]:s,u=typeof d?.materialAssetId=="string"?d.materialAssetId:"",l=u||(typeof s?.materialAssetId=="string"?s.materialAssetId:""),m=e,f=ee(m,l||Tn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Editable",0),Mo("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),Mo("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),Mn.createSelectorInspectorPropertyWithUsage(m,"instance",{path:r.materialAssetIdPath,label:"Material",value:u,order:10,text:i,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,ownerScope:"prefab",prefabAssetId:t.id,prefabNodeId:r.prefabNodeId,sourceBindingPath:r.materialAssetIdPath}},previewContext:n},a)]}}function RR(e,t,r,n,o){return kR(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var CR={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:RR},Oh=CR;function kh(e,t){return{id:"prefab-material-override-target",title:"Prefab Material Override",order:20,placement:"body",summary:e,persistence:"readonly",effect:"unsupported",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Read Only",0),Mo("prefab.materialOverride.reason","Reason",e,1),Mo("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function Mo(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function vR(e,t,r,n,o,a){let i=Le(e,t.assetId);if(!i)return null;let s=t.sourceAssetId?e.assets.find(b=>b.id===t.sourceAssetId)??null:null,c=r?wc(Ah(e,t,n),r)??hh(e,t,r,n):null,d=c?Th(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Mh(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?oo(i,m):null,S=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?NR(i,f):null,g=f?.kind==="marker"&&f.marker?LR(i,f,o):null;return{targetIds:[i.id],activeId:i.id,label:n.importStructureReady?"Prefab Runtime Ready":t.label,document:e,selection:{targetIds:[i.id],activeId:i.id,scopeType:"prefab-stage",targetKind:"prefab",document:e},sections:[{id:"prefab-stage",title:"Prefab Stage",summary:n.importStructureReady?"Runtime Ready":"Preview",persistence:"document",properties:[Qa({path:"displayName",label:"Display Name",valueType:"string",control:"string",value:i.displayName??i.id,order:0},o),j({path:"prefab.sourceAssetId",label:"Source Asset",value:s?.displayName??t.sourceAssetId??"Missing",order:1}),Qa({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...wh(i,3,o),j({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(b=>!!b)},...S?[S]:[],...g?[g]:[],...l?[l]:[],...u?[u]:[]]}}function GR(e,t,r,n={},o){return vR(e,t,r,n,o,Oh.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var jR={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:GR},Ch=jR;function NR(e,t){let r=FR(t),n=t.parentId?oo(e,t.parentId):null,o=[],a=0;for(let i of["position","rotation","scale"])for(let s of["x","y","z"]){let c=r[i][s];o.push({path:`transform.${i}.${s}`,label:`${_R(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?$R(c):c,readOnly:!1,persistence:"document",commitMode:"live",order:a,step:i==="rotation"?1:.1,validate:d=>typeof d=="number"&&Number.isFinite(d)?{ok:!0,value:d}:{ok:!1,message:"Transform value must be a finite number."},coerce:d=>typeof d=="number"?d:Number(d)}),a+=1}return{id:"transform",title:"Transform",summary:`Relative to: ${n?.name??n?.id??"Prefab"}`,order:20,placement:"body",persistence:"document",collapsedByDefault:!1,properties:o}}function FR(e){return e.transform?.type==="Transform"&&e.transform.mode!=="matrix"?{...e.transform,mode:e.transform.mode??"trs",scale:e.transform.scale??{x:1,y:1,z:1}}:{type:"Transform",mode:"trs",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function _R(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function $R(e){return Math.round(e*180/Math.PI*1e6)/1e6}function LR(e,t,r){let n=t.marker,o=n.target??null,a=o?Rh(o):"",i=[{label:"Unbound",value:""},...Ze(e).filter(c=>c.id!==t.id).map(c=>{let d=c.kind==="marker"?"marker":"scene-object";return{label:c.name??c.id,value:Rh({kind:d,id:c.id})}})];o&&a&&!i.some(c=>c.value===a)&&i.push({label:`Missing: ${o.id}`,value:a});let s=r.markerTypeCatalog.map(c=>({label:c.label||c.type,value:c.type}));return s.some(c=>c.value===n.type)||s.push({label:`Missing: ${n.type}`,value:n.type}),{id:"prefab-marker",title:"Marker",summary:r.markerTypeCatalog.find(c=>c.type===n.type)?.label??n.type,order:35,placement:"body",persistence:"document",collapsedByDefault:!1,properties:[ei({path:"prefab.marker.type",label:"Marker Type",valueType:"enum",control:"enum",value:n.type,options:s,order:0,validate:c=>typeof c=="string"&&r.markerTypeCatalog.some(d=>d.type===c)}),j({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),j({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),ei({path:"prefab.marker.target",label:"Target",valueType:"enum",control:"enum",value:a,options:i,order:3,validate:c=>typeof c=="string"&&i.some(d=>d.value===c)}),j({path:"prefab.marker.targetStatus",label:"Target Status",value:o?i.some(c=>c.value===a&&!c.label.startsWith("Missing:"))?"Resolved":"Unresolved local reference":"Unbound",order:4,source:"Derived"}),ei({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:c=>typeof c=="string"}),ei({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:c=>typeof c=="string"}),ei({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:zR})].filter(c=>!!c)}}function ei(e){return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},validate:t=>e.validate(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid Prefab Marker field: ${e.path}.`}}}function Rh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function zR(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return["r","g","b"].every(r=>typeof t[r]=="number"&&Number.isFinite(t[r])&&t[r]>=0&&t[r]<=1)}function vh(e,t){let r=ln(e,t.id);if(!r.prefab)return null;let n=r.diagnostics.filter(m=>m.severity==="error").length,o=r.diagnostics.filter(m=>m.severity==="warning").length,a=r.diagnostics.filter(m=>m.severity==="info").length,i=r.diagnostics.length>0,s=n>0?"unsupported":i?"derived":"active",c=n>0?"Prefab relation is incomplete; fix the missing definition or source asset before using prefab actions.":void 0,d=r.definition?.displayName??r.definition?.id??r.prefab.prefabId,u=r.sourceAsset?.displayName??r.sourceAsset?.id??r.prefab.sourceAssetId??"Missing",l=[j({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),j({path:"prefab.relation.source",label:"Source Model",value:u,order:1,source:r.sourceAsset?"Asset":"Document",effect:s,disabledReason:c})].filter(m=>!!m);return i&&l.push(j({path:"prefab.relation.diagnostics",label:"Diagnostics",value:r.diagnostics.map(m=>`${m.severity}:${m.code} - ${m.message}`).join(`
7
- `),order:2,source:"Derived",effect:s,disabledReason:c})),l.push(im({path:"prefab.actions.editDefinition",label:"Edit Prefab",actionId:"prefab.edit-definition",order:10,icon:"prefab",tooltip:"Open the prefab definition stage.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.selectDefinition",label:"Select Prefab",actionId:"prefab.select-definition",order:11,icon:"prefab",tooltip:"Select the prefab asset in the asset browser.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.pingSource",label:"Ping Source",actionId:"prefab.ping-source",order:12,icon:"asset",tooltip:"Select the prefab source asset in the asset browser.",params:{assetId:r.sourceAsset?.id??r.prefab.sourceAssetId},disabled:!r.sourceAsset,disabledReason:c,effect:s})),{id:"prefab-instance",title:"Prefab",order:48,placement:"body",summary:n>0?`${n} ${n===1?"error":"errors"}`:o>0?"Warning":a>0?"Info":"Ready",persistence:"readonly",effect:s,disabledReason:c,collapsedByDefault:!1,properties:l}}function im(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Gh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function cm(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function vn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return UR(r)?me(r):Ie(1,1,1)}return Ie(1,1,1)}function Br(e,t){let r=ke(e,t);return r&&It(r)?r:null}function dm(e,t,r){let n=ur(e,t??void 0,r);return n&&It(n)?n:null}function Fh(e,t){let r=ke(e,t.id);return r?$h(r,t.name??t.id):null}function _h(e,t){let r=mm(t);if(r?.kind!=="scene-object")return null;let n=e.scene.gameObjects.find(a=>a.id===r.id)??null,o=ke(e,r.id);return!n||!o?null:$h(o,r.label||n.name||r.id)}function $h(e,t){let r=Fe(e),n=Cc(Ie(r[0],r[1],r[2]));if(!n)return null;let o=Ie(r[4],r[5],r[6]),a=Cc(BR(o,sm(n,jh(o,n))));if(!a)return null;let i=Cc(Nh(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);jh(i,s)<0&&(i=sm(i,-1));let c=Cc(Nh(i,n));return c?{origin:Ui(e),right:n,up:c,forward:i,label:t}:null}function jh(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Nh(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function BR(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function sm(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Cc(e){let t=Math.hypot(e.x,e.y,e.z);return Number.isFinite(t)&&t>1e-6?sm(e,1/t):null}function Sr(e,t,r,n={}){let o=t.trim(),a=o?to(HR(e),n).find(i=>i.type===o)?.kind:void 0;return vc(a??r??(o?void 0:"point"))}function vc(e){let t=e?.trim();return t?t==="object-bound"||t==="object-bounds"?"object":t:"point"}function Lh(e,t){return lm(t)?"box":um(t)&&mm(e)?"object-bounds":"point"}function Gc(e,t,r,n,o={}){let a=Br(e,t.id),i=me(a?.position??Ie(0,0,0)),s=me(a?.rotation??Ie(0,0,0)),c=VR(e,t,r,o)?wo(r):me(a?.scale??vn(t));if(lm(r))return{kind:"box",coordinateSpace:"world",center:i,size:Fc(c),rotation:s};let d=mm(t.marker);return um(r)&&d?{kind:"object-bounds",target:d}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:i,...d?{target:d}:{}}}function zh(e,t,r,n,o){if(o)return um(n)||r.kind==="object-bounds"?{kind:"object-bounds",target:structuredClone(o)}:r.kind==="point"?{...structuredClone(r),target:structuredClone(o)}:structuredClone(r);if(r.kind==="object-bounds"){let a=Br(e,t.id);return{kind:"point",coordinateSpace:"world",position:me(a?.position??Ie(0,0,0))}}if(r.kind==="point"){let a=structuredClone(r);return delete a.target,a}return structuredClone(r)}function Bh(e,t){let r=e.scene.gameObjects.find(n=>n.id===t)??null;return!r||de(r)?null:{kind:"scene-object",id:r.id,label:r.name||r.id}}function VR(e,t,r,n={}){let o=Sr(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=Br(e,t.id)?.scale??vn(t);return Uh(a,wo(o))}function Vh(e,t,r,n={}){if(!de(t))return!1;let o=Sr(e,t.marker.type,t.marker.kind,n),a=vc(r.kind);if(o===a&&t.marker.geometry.kind===r.geometry.kind)return!1;let i=Br(e,t.id)?.scale??vn(t);return Uh(i,wo(o))}function wo(e){return lm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function lm(e){return vc(e)==="region"}function um(e){return vc(e)==="object"}function mm(e){return e.target?structuredClone(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?structuredClone(e.geometry.target):null}function Uh(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Kh(e){switch(e.kind){case"box":return{kind:"box"};case"point":return{kind:"point",coordinateSpace:e.coordinateSpace,...e.coordinateSpace==="local"?{position:me(e.position)}:{},...e.target?{target:structuredClone(e.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(e.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:e.coordinateSpace,vertices:e.vertices.map(me),...e.faces?{faces:e.faces.map(t=>[...t])}:{}}}}function jc(e){switch(e.kind){case"box":return me(e.center);case"point":return e.coordinateSpace==="world"?me(e.position):Ie(0,0,0);case"polyhedron":return KR(e.vertices);case"object-bounds":return Ie(0,0,0)}}function Nc(e){return e.kind==="box"&&e.rotation?me(e.rotation):Ie(0,0,0)}function fm(e,t){return e.kind==="box"?Fc(e.size):me(t)}function Fc(e){return{x:Math.max(1e-6,Math.abs(e.x)),y:Math.max(1e-6,Math.abs(e.y)),z:Math.max(1e-6,Math.abs(e.z))}}function _c(e){return e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function me(e){return{x:e.x,y:e.y,z:e.z}}function UR(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Ie(e,t,r){return{x:e,y:t,z:r}}function Hh(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function KR(e){if(e.length===0)return Ie(0,0,0);let t={x:Math.min(...e.map(n=>n.x)),y:Math.min(...e.map(n=>n.y)),z:Math.min(...e.map(n=>n.z))},r={x:Math.max(...e.map(n=>n.x)),y:Math.max(...e.map(n=>n.y)),z:Math.max(...e.map(n=>n.z))};return{x:(t.x+r.x)/2,y:(t.y+r.y)/2,z:(t.z+r.z)/2}}function HR(e){return e.scene.markerGraph??null}function $c(e,t={}){let r=QR(e,t);if(r!==e)return $c(r,t);let n=WR(e);if(n!==e)return $c(n,t);let o=Lc(e);if(!o)return e;let a=cr(o),i=qR(e,a);return ra(o,i)?e:Bd(e,i)}function WR(e){let t=Lc(e),r=t?cr(t):null;if(!r||r.markers.length===0)return e;let n=new Set(e.scene.gameObjects.map(c=>c.id)),o=new Map,a=[];for(let c of r.markers){if(e.scene.gameObjects.some(u=>u.id===c.id&&de(u))){o.set(c.id,c.id);continue}let d=n.has(c.id)?oC(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>qh(e,hp(c.marker,o),c.gameObjectId,null)),s=cr({...r,markers:[],relations:r.relations.map(c=>yp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function qR(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>JR(i,r)),o=new Set([...n.map(i=>i.id),...e.scene.gameObjects.filter(de).map(i=>i.id)]),a=t.relations.filter(i=>zd(i.from,r,o)&&zd(i.to,r,o));return{...t,markers:n,relations:a}}function JR(e,t){if(!ta(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return ta(e.geometry.target,t);case"point":return ta(e.geometry.target,t);case"box":case"polyhedron":return!0}}function Wh(e,t,r={}){switch(t.type){case"marker.create-box":return XR(e,t.marker,t.parentId??null);case"marker.update":return YR(e,t.markerId,t.patch,r);case"marker.delete":return ZR(e,t.markerId);default:return null}}function XR(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=cr(Lc(e)),o=qh(e,t,t.id,r),a={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,o]}};return Bd(a,{...n,markers:n.markers.filter(i=>i.id!==t.id)})}function YR(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=Vr(e,o,n),i=sr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=cr(void 0);if(ra({...s,markers:[a]},{...s,markers:[i]}))return e;let c=Jh(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function ZR(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=Ep(e,t),o=cr(Lc(e));return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.filter(a=>!n.has(a.id)),markerGraph:{...o,markers:[],relations:o.relations.filter(a=>!Ld(a.from,n)&&!Ld(a.to,n))}}}}function QR(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=eC(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function eC(e,t,r={}){return rC(e,t,r)}function qh(e,t,r,n){let o=wo(t.kind),a={position:jc(t.geometry),rotation:Nc(t.geometry),scale:fm(t.geometry,o)},i=n?dm(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:Yh(t),components:[{type:"Transform",...i}]}}function Jh(e,t,r,n={}){let o=Br(e,t.id)?.scale??vn(t),a=Vh(e,t,r,n)?wo(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:Yh(r),components:tC(e,t,t.components,r.geometry,a)}}function tC(e,t,r,n,o){let a=o??vn(t),i=Br(e,t.id),s={position:cm(n)?me(i?.position??jc(n)):jc(n),rotation:cm(n)?me(i?.rotation??Nc(n)):Nc(n),scale:fm(n,a)},c=dm(e,t.parentId,s)??s,d=!1,u=r.map(l=>l.type!=="Transform"?l:(d=!0,{...l,position:c.position,rotation:c.rotation,scale:c.scale}));return d?u:[...u,{type:"Transform",position:c.position,rotation:c.rotation,scale:c.scale}]}function rC(e,t,r={}){if(t.marker.geometry.kind==="polyhedron")return t;let n=Sr(e,t.marker.type,t.marker.kind,r),o=Lh(t.marker,n);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===o)return t;let a=Vr(e,t,r),i=sr({...a,kind:n,markerType:t.marker.type.trim(),geometry:Gc(e,t,n,a.geometry,r)});return Jh(e,t,i,r)}function Xh(e,t={}){return e.scene.gameObjects.filter(de).map(r=>Vr(e,r,t))}function Vr(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?_h(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):Fh(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:Sr(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:nC(e,t),...n.target?{target:structuredClone(n.target)}:{},...i?{semanticFrame:i}:{},...n.tags?.length?{tags:[...n.tags]}:{},...Object.keys(o).length>0?{metadata:o}:{}}}function nC(e,t){let r=t.marker,n=Br(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??vn(t);switch(r.geometry.kind){case"box":return{kind:"box",coordinateSpace:"world",center:me(o),size:Fc(i),rotation:me(a)};case"point":return(r.geometry.coordinateSpace??"world")==="world"?{kind:"point",coordinateSpace:"world",position:r.geometry.offset?Hh(o,r.geometry.offset):me(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}}:{kind:"point",coordinateSpace:"local",position:r.geometry.position?me(r.geometry.position):me(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(r.geometry.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:r.geometry.coordinateSpace??"world",vertices:r.geometry.vertices.map(me),...r.geometry.faces?{faces:r.geometry.faces.map(s=>[...s])}:{}}}}function Yh(e){let t=e.metadata?structuredClone(e.metadata):{},r=aC(t.color),n=typeof t.note=="string",o=n?t.note:void 0;return r&&delete t.color,n&&delete t.note,{schemaVersion:1,type:e.markerType,...e.kind?{kind:e.kind}:{},...e.tags?.length?{tags:[...e.tags]}:{},...o!==void 0?{note:o}:{},...r?{color:r}:{},...e.target?{target:structuredClone(e.target)}:{},...e.semanticFrame?{semanticFrame:structuredClone(e.semanticFrame)}:{},geometry:Kh(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function oC(e,t){let r=_c(e)||"marker",n=1,o=`${r}-marker`;for(;t.has(o);)n+=1,o=`${r}-marker-${n}`;return o}function aC(e){if(!e||typeof e!="object")return null;let t=e,r=pm(t.r),n=pm(t.g),o=pm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function pm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function Lc(e){return e.scene.markerGraph??null}function Qh(e){let t=n=>e.getMarkerTypeCatalogFromGraph(Zh(n)),r=n=>{let o=cr(Zh(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of Xh(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=Pp(n,o,{sanitizeMarkerGameObjectId:_c});return Tp(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(Vd(a)),label:xp(a),...Ap(a),...a.type==="marker.create-box"?{createdId:a.marker.id}:{},normalizedCommand:Vd(a)}:null},createMarkerTypeUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?t(n).find(m=>m.type===s)??null:null;if(s&&!c)return null;let d=Sr(n,s,i.marker.kind,e.options),u=Vr(n,i,e.options),l=Gc(n,i,d,u.geometry,e.options);return{type:"marker.update",markerId:o,patch:{markerType:s,kind:d,geometry:l}}},createMarkerTargetUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?Bh(n,s):null;if(s&&!c)return null;let d=Vr(n,i,e.options),u=Sr(n,i.marker.type,i.marker.kind,e.options),l=zh(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return Sr(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=Wh(n,o,e.options);if(a)return a;let i=r(n),s=Ip(i,o,e.options);return ra(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return $c(n,e.options)}}}function Zh(e){return e?.scene.markerGraph}function eE(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?rE(e,n,r,r.id,t):[]})}function tE(e,t,r,n=[]){let o=Le(e,t);if(!o)return[];let a={id:r,name:o.displayName??o.id,kind:"group",components:[zc()]};return rE(e,o,a,r,n)}function rE(e,t,r,n,o){let a=[],i=[];nE(e,t,{instanceId:r.id,parentId:r.parentId,rootTransform:G(r)??zc(),isHostRoot:!0,visitedPrefabIds:new Set,derivedObjects:a,markerDescriptors:i});let s=new Set([r.id,...a.map(d=>d.id)]);for(let d of a)d.marker&&(d.marker.target&&s.add(d.marker.target.id),d.marker.geometry.kind==="point"&&d.marker.geometry.target&&s.add(d.marker.geometry.target.id),d.marker.geometry.kind==="object-bounds"&&s.add(d.marker.geometry.target.id));let c={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects.filter(d=>!s.has(d.id)),r,...a]}};return i.flatMap(d=>{let u=c.scene.gameObjects.find(l=>l.id===d.runtimeId);return u?.marker?[{ownerInstanceId:n,prefabAssetId:d.prefabAssetId,localNodeId:d.localNodeId,marker:Vr(c,u,{builtInMarkerTypes:o})}]:[]})}function nE(e,t,r){if(r.visitedPrefabIds.has(t.id))return;let n=Ze(t),o=Ye(t),a=o?n.find(d=>d.id===o):null;if(!a)return;let i=new Set(r.visitedPrefabIds).add(t.id),s={instanceId:r.instanceId,rootNodeId:a.id},c=d=>ao(s,d.id);for(let d of n){let u=c(d),l=d.id===a.id,m=d.parentId?n.find(g=>g.id===d.parentId):null,f=l?r.parentId:c(m??a);if(d.kind==="prefabInstance"&&d.childPrefabId){let g=Le(e,d.childPrefabId);g&&nE(e,g,{instanceId:u,...f?{parentId:f}:{},rootTransform:l?r.rootTransform:d.transform??zc(),isHostRoot:r.isHostRoot&&l,visitedPrefabIds:i,derivedObjects:r.derivedObjects,markerDescriptors:r.markerDescriptors});continue}if(r.isHostRoot&&l)continue;let S=d.kind==="marker"&&d.marker?fa({...structuredClone(d.marker),semanticFrame:void 0},s):void 0;r.derivedObjects.push({id:u,name:d.name??d.id,kind:d.kind==="marker"?"transform":"group",...f?{parentId:f}:{},...S?{marker:S}:{},components:[l?r.rootTransform:d.transform??zc()]}),S&&r.markerDescriptors.push({prefabAssetId:t.id,localNodeId:d.id,runtimeId:u})}}function zc(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function iC(e){return e?e.list().filter(t=>De(t.shaderId)==null).map(t=>{let r=t.inspector.sections.length,n=t.inspector.fields.length;return{id:`shader:${t.shaderId}`,assetId:t.shaderId,label:t.displayName,kind:"shader",placeable:!1,meta:`${t.shaderId} \xB7 v${t.version} \xB7 ${n} fields`,shader:{shaderId:t.shaderId,displayName:t.displayName,version:t.version,runtimeKind:t.runtimeKind,sectionCount:r,fieldCount:n,...t.sourceFile?{sourceFile:t.sourceFile}:{}}}}):[]}function oE(e){let t=Sy(e.objectCommandServices);return{getHierarchyItems:e.hierarchyFacade.getHierarchyItems,normalizeHierarchyDocument:e.hierarchyFacade.normalizeHierarchyDocument,createRenamePatch:e.hierarchyFacade.createRenamePatch,createCreateGroupPatch:e.hierarchyFacade.createCreateGroupPatch,createCreatePrimitivePatch:e.hierarchyFacade.createCreatePrimitivePatch,createDeleteSubtreePatch:e.hierarchyFacade.createDeleteSubtreePatch,collectSubtreeIdList:e.hierarchyFacade.collectSubtreeIdList,validateReparent:e.hierarchyFacade.validateReparent,createReparentPatch:e.hierarchyFacade.createReparentPatch,validateHierarchyMove:e.hierarchyFacade.validateHierarchyMove,createHierarchyMovePatch:e.hierarchyFacade.createHierarchyMovePatch,validateGroupSelection:e.hierarchyFacade.validateGroupSelection,createGroupSelectionPatch:e.hierarchyFacade.createGroupSelectionPatch,createDuplicateSelectionPatch:e.hierarchyFacade.createDuplicateSelectionPatch,createPlacedAssetPatch:e.hierarchyFacade.createPlacedAssetPatch,applySerializedPropertyPatch:t.applySerializedPropertyPatch,canCreateSerializedMultiPropertyPatch:t.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:t.createSerializedMultiPropertyPatch,createBrowserAssetItems(r,n={}){let o=_e.getCachedUsageIndex(r);return[..._e.createBrowserAssetItems(r,o,n),...iC(n.materialShaderDefinitions),...fh(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o,a){let i=va(r,n,o,{...e.assetPlacementServices,...a});return{document:i.document,gameObject:i.gameObject}}}}function sC(e,t){if(!e.scene||typeof e.scene!="object"||Array.isArray(e.scene))return null;let r=e.scene;if(r.kind!==e.id)return null;let n=cE(r.contribution);return n?gm(n):t?lh(e,t):null}function iE(e){let t=(e.features??[]).flatMap(p=>{let D=e.resolveFeatureSceneContribution?.(p);if(D)return[gm(D)];let h=sC(p,()=>d);if(h)return[h];let R=cE(p.scene);return R?[gm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=GC(t),o=Qh({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>kC(e.markerTypes,p)}),a=(p,D)=>D?_(p,D):null,i=()=>[p=>n?.validateInspectorField?.({document:p.document??null,gameObject:p.document?a(p.document,p.targetId):null,path:p.path,value:p.value})??null,p=>wC(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Pl({hasMaterialAsset:Vt,isMarkerGameObject:de,isDirectionalLightAnglePath:uo})],s=(p,D)=>n?.normalizeInspectorValue?.(p,D)??Es(p,D,{isDirectionalLightAnglePath:uo}),c=(p,D,h,R)=>{if(uo(h)&&D.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:D,path:h,value:R});return K||mo({document:p,path:h,nodeKind:ti(D),value:R,extraValidators:i()})},d=(p,D,h)=>ha({document:p,nodeKind:D,property:h,extraValidators:i()}),l={systemDefaults:PC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:Gh,findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isProtectedSystemGameObject:Dt,hasCamera:(p,D)=>p.scene.gameObjects.some(h=>h.id!==D&&At(h)),...n?.fieldMutation},m=xC(e,o,l,a,s,c,n),f=(p,D,h,R)=>nc(p,D,h,R,m),S=(p,D,h,R)=>gy(p,D,h,R,m),g=(p,D)=>gu(p,D,m.fieldMutationOptions),b=(p,D,h)=>hn(p,D,{transform:h}),y=(p,D)=>Kl(p,D),I=TC(e,o,l,f,S,n),E=AC(o),T={isRootTransformPath:ks,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isSerializedMultiFieldPath:p=>RC(p,n),isSerializedMultiProjectionPath:p=>CC(p,n),getSerializedMultiPropertyProbeValue:p=>vC(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>Io(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},A=oE({hierarchyFacade:E,objectCommandServices:T,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:D,worldTransform:h})=>ur(p,D??void 0,h)}}),$={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(D=>D.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(D=>D.type==="ImageRenderer"),readNodeKind:ti},z={};return Object.assign(z,{historyDocumentStorage:r,defaults:{camera:Ys,sunLight:_a,environmentLight:kn},reduceDocument:(p,D)=>Ru(p,D,I),ensureEnvironmentDefaults:p=>Ou(p,I),isSelectableHierarchyId:(p,D)=>vl(p,D),resolveDiagnosticLocator:(p,D)=>{let h=D.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=kr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:Mp,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:A.getHierarchyItems,normalizeHierarchyDocument:A.normalizeHierarchyDocument,createRenamePatch:A.createRenamePatch,createCreateGroupPatch:A.createCreateGroupPatch,createCreatePrimitivePatch:A.createCreatePrimitivePatch,createDeleteSubtreePatch:A.createDeleteSubtreePatch,createReparentPatch:A.createReparentPatch,createHierarchyMovePatch:A.createHierarchyMovePatch,createGroupSelectionPatch:A.createGroupSelectionPatch,createDuplicateSelectionPatch:A.createDuplicateSelectionPatch,createPlacedAssetPatch:A.createPlacedAssetPatch,validateReparent:A.validateReparent,validateHierarchyMove:A.validateHierarchyMove,validateGroupSelection:A.validateGroupSelection,collectSubtreeIds:pr,createFeatureHierarchyPatch:(p,D)=>n?.createHierarchyPatch?.(p,D)??null,createInspectorPropertyPatch:p=>lC(m,p),createSceneMaterialBindingPatch:p=>dC(e,m,p),createPrefabMaterialBindingPatch:p=>uC(e,p),createMaterialPropertiesPatch:p=>IC(e,m,p),createMaterialAssetCreatePatch:p=>pC(e,p),createMaterialAssetRestorePatch:p=>gC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>bC(e,p),createMaterialAssetDuplicatePatch:p=>SC(e,p),createMaterialAssetDeletePatch:p=>yC(e,p),createMaterialAssetRenamePatch:p=>hC(e,p),createMaterialAssetSetShaderPatch:p=>EC(e,p),patchGameObjectField:f,patchGameObjectsField:S,patchGameObjectPropertiesMany:g,patchGameObjectTransform:b,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>cC(e,m,p),canCreateSerializedMultiPropertyPatch:A.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:A.createSerializedMultiPropertyPatch,createBrowserAssetItems:A.createBrowserAssetItems,addAssetLibraryItemToDocument:A.addAssetLibraryItemToDocument,getInspectorObject:(p,D,h={})=>DC(z,e,o,p,D,aE(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,D,h,R={})=>MC(p,D,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,D,h,R={})=>Ch.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,D,h,aE(e.materialShaderDefinitions,R),{createIdentityTransformComponent:zS,mergeLightDefaults:On,sunLightId:"sun_light",normalizePrefabAssetFieldValue:Qu,validatePrefabAssetFieldValue:em,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>Ll({...p,sourceRef:Wt(p.document)},$),createRuntimeInspectorSnapshot:p=>pa({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>eE(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,D,h)=>tE(p,D,h,o.getMarkerTypeCatalog(p)),getRelationTypeCatalog:()=>e.relationTypes.map(p=>structuredClone(p)),createMarkerGraphPatch:o.createMarkerGraphPatch,reduceMarkerGraphPatch:o.reduceMarkerGraphPatch,syncMarkerGraphDocument:o.syncMarkerGraphDocument,resolveMarkerKind:o.resolveMarkerKind,assertMaterialAssetIntegrity:Vs}),z}function cC(e,t,r){if(r.changes.length<2)return null;let n=new Set,o=[],a=new Set;for(let s of r.changes){let c=`${s.targetId}\0${s.path}`;if(!s.targetId||!s.path||n.has(c))return null;n.add(c);let d=Io({document:r.document,targetId:s.targetId,path:s.path,value:s.value},t),u=d?.patch;if(!d||!u||u.kind!=="game-object.field"||u.targetId!==s.targetId||u.path!==s.path)return null;o.push({targetId:s.targetId,path:s.path,value:u.value});for(let l of d.reprojectIds??[])a.add(l)}let i=[...new Set(o.map(s=>s.targetId))];return{patch:e.createPatch.gameObjectFieldBatch(o),label:`Patch ${o.length} Inspector properties`,changedIds:i,...a.size>0?{reprojectIds:[...a]}:{}}}function dC(e,t,r){if(r.targets.length===0)return null;let n=new Set,o=[];for(let s of r.targets){let c=`${s.objectId}\0${s.path}`;if(n.has(c))return null;n.add(c);let u=Io({document:r.document,targetId:s.objectId,path:s.path,value:r.materialAssetId},t)?.patch;if(!u||u.kind!=="game-object.field"||u.targetId!==s.objectId||u.path!==s.path)return null;o.push({targetId:s.objectId,path:s.path,value:u.value})}let a=[...new Set(o.map(s=>s.targetId))],i=sE(r.document,r.targets,r.materialAssetId);return{patch:e.createPatch.gameObjectFieldBatch(o),label:`${r.materialAssetId?"Set":"Clear"} ${o.length} scene material binding${o.length===1?"":"s"}`,changedIds:a,reprojectIds:a,presentationImpact:i}}function lC(e,t){let r=Io(t,e);if(!r||!wr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:sE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function uC(e,t){if(t.targets.length===0||t.materialAssetId&&!Vt(t.document,t.materialAssetId)||new Set(t.targets.map(s=>s.prefabAssetId)).size!==1)return null;let n=t.targets[0].prefabAssetId,o=Le(t.document,n);if(!o?.prefab)return null;let a=structuredClone(o),i=new Set;for(let s of t.targets){let c=`${s.nodeId??""}\0${s.path}`;if(i.has(c))return null;i.add(c);let d=`prefab.${s.path}`,u=Qu(d,t.materialAssetId);if(!em(d,u))return null;if(!s.nodeId){a=ua(a,d,u);continue}let l=a.prefab?.nodes?.findIndex(b=>b.id===s.nodeId)??-1;if(l<0||!a.prefab?.nodes)return null;let m=a.prefab.nodes[l],f={...a,prefab:{...a.prefab,overrides:structuredClone(m.overrides)}},S=ua(f,d,u),g={...m,...S.prefab?.overrides?{overrides:structuredClone(S.prefab.overrides)}:{}};S.prefab?.overrides||delete g.overrides,a.prefab.nodes=[...a.prefab.nodes],a.prefab.nodes[l]=g}return{patch:e.createPatch.prefabAssetReplace?.(n,a)??{kind:"scene.prefab-asset.replace",assetId:n,prefabAsset:a},label:`${t.materialAssetId?"Set":"Clear"} ${t.targets.length} prefab material binding${t.targets.length===1?"":"s"}`,changedId:n,changedIds:[n],reprojectIds:[n],presentationImpact:mC(t.document,t.targets,t.materialAssetId)}}function sE(e,t,r){let n=new Set(t.map(a=>`${a.objectId}\0${a.path}`)),o=new Set;r&&o.add(r);for(let a of ca(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function mC(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=fC(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function fC(e,t){let r=Le(e,t.prefabAssetId)?.prefab,n=t.nodeId?r?.nodes?.find(a=>a.id===t.nodeId)?.overrides:r?.overrides;if(!n)return null;let o=t.path==="overrides.materialBinding.materialAssetId"?n.materialBinding?.materialAssetId:n.materialSlotBindings?.[Lt(t.path,"materialAssetId")??""]?.materialAssetId;return typeof o=="string"&&o.trim()?o.trim():null}function pC(e,t){let r=Hb(t.document,t.definition,t.name);return{patch:e.createPatch.materialAssetCreate?.(r)??{kind:"scene.material-asset.create",materialAsset:r},label:`Create material ${r.name}`,changedIds:[],createdId:r.id}}function gC(e,t){return ee(t.document,t.materialAsset.id)?null:{patch:e.createPatch.materialAssetCreate?.(t.materialAsset)??{kind:"scene.material-asset.create",materialAsset:t.materialAsset},label:`Restore material ${t.materialAsset.name}`,changedIds:[],createdId:t.materialAsset.id}}function bC(e,t){let r=Yb({document:t.document,gameObject:t.gameObject,bindingPath:t.bindingPath,profile:t.profile,sourceAsset:t.sourceAsset,sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,sourceMaterialName:t.sourceMaterialName});return r?{...r,patch:e.createPatch.materialAssetCreateAndBind?.({targetId:r.patch.targetId,bindingPath:r.patch.bindingPath,materialAsset:r.patch.materialAsset})??r.patch,label:`Create material ${r.patch.materialAsset.name} from GLB source`,presentationImpact:{inspector:["material"],materials:{assetIds:[r.createdId]}}}:null}function SC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=Wb(t.document,r);return{patch:e.createPatch.materialAssetCreate?.(n)??{kind:"scene.material-asset.create",materialAsset:n},label:`Duplicate material ${r.name??r.id}`,changedIds:[],createdId:n.id,presentationImpact:{inspector:["material"],materials:{assetIds:[n.id]}}}}function yC(e,t){let r=Qb(t.document,t.materialAssetId);return r.ok?{patch:e.createPatch.materialAssetDelete?.(t.materialAssetId)??{kind:"scene.material-asset.delete",materialAssetId:t.materialAssetId},label:`Delete material ${r.materialAsset.name??r.materialAsset.id}`,changedIds:[],presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}:null}function hC(e,t){let r=ee(t.document,t.materialAssetId),n=rt("name",t.name);return!r||tu(r)||typeof n!="string"||!zt("name",n)?null:{patch:e.createPatch.materialAssetField(t.materialAssetId,"name",n),label:`Rename material ${r.name} to ${n}`,changedIds:sa(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function EC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||tu(r))return null;let n=dS(r,t.definition),o=sa(t.document,t.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(t.materialAssetId,n.materialAsset)??{kind:"scene.material-asset.replace",materialAssetId:t.materialAssetId,materialAsset:n.materialAsset},label:`Set material ${r.name} shader to ${t.definition.displayName}`,changedIds:o,reprojectIds:o,presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}},preservedPaths:n.preservedPaths,resetPaths:n.resetPaths}}function IC(e,t,r){if(r.changes.length===0)return null;let n=ee(r.document,r.materialAssetId);if(!n)return null;let o=new Set,a=r.document;for(let c of r.changes){if(!c.path.startsWith("properties.")||o.has(c.path))return null;if(o.add(c.path),c.inheritTexture){if(!no(n.shaderId,c.path))return null;a=$s(a,r.materialAssetId,c.path,null,e.materialShaderDefinitions,{textureMode:"inherit"});continue}let d=`scene.materialAssets.${r.materialAssetId}.${c.path}`,l=Io({document:a,targetId:r.materialAssetId,path:d,value:c.value},t)?.patch;if(!l||l.kind!=="scene.material-asset.field"||l.materialAssetId!==r.materialAssetId||l.path!==c.path)return null;a=$s(a,r.materialAssetId,c.path,l.value,e.materialShaderDefinitions)}let i=ee(a,r.materialAssetId);if(!i)return null;let s=sa(r.document,r.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(r.materialAssetId,i)??{kind:"scene.material-asset.replace",materialAssetId:r.materialAssetId,materialAsset:i},label:`Patch material ${r.materialAssetId} properties`,changedIds:s,reprojectIds:s}}function PC(e){let t=r=>n=>{let o=r(n);if(!e)return o;let a=structuredClone(o),i=structuredClone(n),s=e(a,i)??a;return JSON.stringify(s)===JSON.stringify(n)?n:s};return{environmentLightId:"environment_light",sunLightId:"sun_light",horizontalLightAnglePath:"light.directionHorizontalAngleDeg",elevationLightAnglePath:"light.directionElevationAngleDeg",normalizeEnvironmentLightGameObject:r=>t(n=>Su(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>Su(n,"directional"))(r),normalizeCameraGameObject:t(BS),normalizePlainTransformGameObject:t(VS),createDefaultCameraGameObject:qS,createDefaultEnvironmentLightGameObject:XS,createDefaultSunLightGameObject:JS,mergeCameraDefaults:$a,normalizeCameraAfterFieldPatch:US,hasInvalidCameraRelationships:HS,mergeLightDefaults:On}}function TC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:Ia,syncMarkerGraphDocument:t.syncMarkerGraphDocument,ensureGameObjectGuids:Ol,normalizeDocumentAfterCommand:(i,s)=>a?.normalizeDocumentAfterCommand?.(i,s)??i,patchMaterialAssetField:(i,s,c,d)=>$s(i,s,c,d,e.materialShaderDefinitions),replaceMaterialAsset:(i,s,c)=>Jb(i,s,c),addMaterialAsset:(i,s)=>Ls(i,s),deleteMaterialAsset:(i,s)=>eS(i,s),addMaterialAssetAndBind:(i,s,c,d)=>tS(i,s,c,d),addPrefabAsset:(i,s,c)=>ph(i,s,c),patchPrefabAssetField:(i,s,c,d)=>rm(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>gh(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>Sh(i,s,c,d),patchGameObjectField:n,patchGameObjectsField:o,reduceExtensionPatch:({document:i,patch:s,command:c})=>s.kind==="game-object.property-field-batch"&&Array.isArray(s.fields)?s.fields.reduce((d,u)=>o(d,[u.targetId],u.path,u.value),i):a?.reducePatch?.({document:i,patch:s,command:c})??null,isCustomFieldPatchPath:a?.isInspectorPatchPath,reduceMarkerGraphPatch:(i,s)=>t.reduceMarkerGraphPatch(i,s),isDirectionalLightAnglePath:uo,validateSerializedPropertyField:i=>r.validateField(i.document,i.gameObject,i.path,i.value),createGameObjectGuid:he,createUniqueId:it,resolveLocalTransform:({document:i,parentId:s,worldTransform:c})=>ur(i,s??void 0,c),resolveRootContainerId:ye,ensureDefaultMaterialAssets:Ub,normalizeMaterialBindings:aS}}function xC(e,t,r,n,o,a,i){return{fieldMutationOptions:tc(r),findGameObject:n,normalizeValue:o,validateValue:a,blockFieldPatch:(s,c,d,u)=>rc(s,c,d,u,r),isRootTransformPath:ks,parseDuplicateMaterialAssetValue:ts,isMaterialBindingPath:wr,isMaterialBindingPathAllowed:(s,c)=>wr(c)&&(!!e.resolveFieldSchema?.(c,ti(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Fp,normalizeMaterialAssetValue:rt,hasMaterialAsset:Vt,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return zt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:sa,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:uo,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>Cu(s,c,d,u,r),createCustomInspectorPropertyPatch:({document:s,gameObject:c,path:d,value:u})=>i?.createInspectorPropertyPatch?.({document:s,gameObject:c,path:d,value:u,collectChangedIds:()=>pr(s,[c.id])})??null,patchCustomGameObjectField:i?.patchGameObjectField,patchCustomGameObjectsField:i?.patchGameObjectsField,normalizeAfterFieldPatch:(s,c,d,u)=>i?.normalizeAfterFieldPatch?.(s,c,d,u)??s,isProjectionShapePath:OC,isArtistMaterialPatchPath:es,isCustomProjectionPath:i?.isProjectionPath,collectChangedIdsForFieldPath:(s,c,d)=>d.startsWith("transform.")?pr(s,[c]):[c],createGameObjectFieldPatch:e.createPatch.gameObjectField,createMaterialAssetFieldPatch:e.createPatch.materialAssetField}}function AC(e){return ku({findGameObject:(t,r)=>r?_(t,r):null,resolveRootContainerId:ye,isProtectedSystemGameObject:Dt,isProtectedSystemGameObjectId:Ml,decorateHierarchyItem:({item:t,gameObject:r})=>r&&de(r)?{...t,role:"marker",icon:"view-overlay",canHaveChildren:!1}:t})}function aE(e,t){return{materialShaderDefinitions:e,...t}}function DC(e,t,r,n,o,a,i,s,c,d){let u=GS(n,o,a);if(u)return u;let l=iu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||Lu({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:ti,isMarkerGameObject:de,createInspectorSections:(m,f,S)=>{let g=ti(f);return Bu({document:m,gameObject:f,context:S,nodeKind:g,isCameraGameObject:At,isLightGameObject:fo,isMarkerGameObject:de,createBaseSections:()=>Fl({document:m,gameObject:f,nodeKind:g,extraValidators:c(),rootTransform:Fr,renderingProfile:t.getRenderingProfile(),transformTypeOptions:dE(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:g,context:S,createDocumentInspectorProperty:i})??[],createCameraSection:()=>xl({nodeKind:g,camera:f.camera,rig:$a(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>Vl({nodeKind:g,gameObject:f,light:On(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(b,y)=>d?.normalizeInspectorValue?.(b,y)??Es(b,y),defaultEnvironmentGroundColor:kn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?Wu({document:m,gameObject:f,nodeKind:g,markerTypeCatalog:r.getMarkerTypeCatalog(m),resolveMarkerKind:(b,y)=>r.resolveMarkerKind(m,y.type,y.kind),isMarkerGameObject:de,formatMarkerTypeLabel:t.formatMarkerTypeLabel??((b,y)=>y),createDocumentInspectorProperty:i}):null,createPrefabInstanceSection:()=>vh(m,f),createMaterialSections:()=>iu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,g,S,{createDocumentInspectorProperty:i}),createOutlineSection:()=>Vu({nodeKind:g,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function MC(e,t,r,n,o,a){let i=null,s=[];for(let c of o){let d=c.createMultiInspectorSection?.({document:e,targetIds:t,activeId:r,context:n})??null;if(d){i=d,s=c.resolveMultiInspectorTargetIds?.(e,t)??[];break}}return zu({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function wC(e,t,r){return e?r==null&&e.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${t}.`}:e.validate(r)?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${t}.`}:null}function kC(e,t){return to(t,{builtInMarkerTypes:e})}var ti=Y;function OC(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function RC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function CC(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function vC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function cE(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return["documentReducerImmutability","transformTypeOptions","normalizeInspectorValue","validateInspectorField","isInspectorPatchPath","isProjectionPath","normalizeDocumentAfterCommand","normalizeAfterFieldPatch","fieldMutation","createInspectorPropertyPatch","patchGameObjectField","patchGameObjectsField","reducePatch","createHierarchyPatch","createInspectorSections","createMultiInspectorSection","resolveMultiInspectorTargetIds","isSerializedMultiFieldPath","isSerializedMultiProjectionPath","getSerializedMultiProbeValue","canPatchSerializedMultiField"].some(n=>t[n]!=null)?t:null}function gm(e){let{documentReducerImmutability:t,...r}=e;return r}function GC(e){if(e.length===0)return;let t=r=>{for(let n of e){let o=r(n);if(o!=null)return o}return null};return{documentReducerImmutability:e.every(r=>r.documentReducerImmutability==="preserves-input")?"preserves-input":void 0,transformTypeOptions:dE(e.flatMap(r=>r.transformTypeOptions??[])).slice(Ta.length),normalizeInspectorValue(r,n){for(let o of e){let a=o.normalizeInspectorValue?.(r,n);if(a!==void 0)return a}},validateInspectorField:r=>t(n=>n.validateInspectorField?.(r)),isInspectorPatchPath:r=>e.some(n=>n.isInspectorPatchPath?.(r)),isProjectionPath:r=>e.some(n=>n.isProjectionPath?.(r)),normalizeDocumentAfterCommand:(r,n)=>e.reduce((o,a)=>a.normalizeDocumentAfterCommand?.(o,n)??o,r),normalizeAfterFieldPatch:(r,n,o,a)=>e.reduce((i,s)=>s.normalizeAfterFieldPatch?.(i,n,o,a)??i,r),fieldMutation:jC(e),createInspectorPropertyPatch:r=>t(n=>n.createInspectorPropertyPatch?.(r)),patchGameObjectField:r=>t(n=>n.patchGameObjectField?.(r)),patchGameObjectsField:r=>t(n=>n.patchGameObjectsField?.(r)),reducePatch:r=>t(n=>n.reducePatch?.(r)),createHierarchyPatch:(r,n)=>t(o=>o.createHierarchyPatch?.(r,n)),createInspectorSections:r=>e.flatMap(n=>n.createInspectorSections?.(r)??[]),isSerializedMultiFieldPath:r=>e.some(n=>n.isSerializedMultiFieldPath?.(r)),isSerializedMultiProjectionPath:r=>e.some(n=>n.isSerializedMultiProjectionPath?.(r)),getSerializedMultiProbeValue(r){for(let n of e){let o=n.getSerializedMultiProbeValue?.(r);if(o!==void 0)return o}},canPatchSerializedMultiField:r=>e.every(n=>n.canPatchSerializedMultiField?.(r)!==!1)}}function dE(e=[]){let t=[],r=new Set;for(let n of[...Ta,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function jC(e){let t=e.flatMap(r=>r.fieldMutation?[r.fieldMutation]:[]);if(t.length!==0)return{isCustomTransformType:r=>t.some(n=>n.isCustomTransformType?.(r)),applyCustomTransformType(r,n){for(let o of t)o.clearCustomTransformState?.(r,n);for(let o of t)o.applyCustomTransformType?.(r,n)},clearCustomTransformState(r,n){for(let o of t)o.clearCustomTransformState?.(r,n)},patchCustomTransformField(r,n,o){for(let a of t)if(a.patchCustomTransformField?.(r,n,o))return!0;return!1}}}var bm=["model","texture","image","sound"],Bc=[".glb",".gltf"],Sm=[".png",".jpg",".jpeg",".webp"],lE=[".env",".hdr",".dds",".ktx",".ktx2"],Vc=[...Sm,...lE],Uc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],ko=[...Bc,...Vc,...Uc];function uE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Kc(e,t){let r=uE(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function Hc(e){let o=String(e??"").trim().split(/[^a-zA-Z0-9_$]+/).filter(Boolean).map((a,i)=>i===0?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join("").replace(/[^a-zA-Z0-9_$]/g,"")||"assetUrl";return/^[a-zA-Z_$]/.test(o)?o:`asset${o}`}function Wc(e,t=""){let 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";let n=mE(t);return Bc.includes(n)?"model":Uc.includes(n)?"sound":Vc.includes(n)?"texture":null}function mE(e){let t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.slice(r+1),o=n.lastIndexOf(".");return o>=0?n.slice(o).toLowerCase():""}function ym(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...ko].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function hm(e,t){return String(e??"").trim()||ym(t)||"Asset"}function Em(e,t){return ym(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function Im(e){return e==="model"?Bc:e==="sound"?Uc:e==="texture"?Vc:e==="image"?Sm:[]}function Tm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=Pm(t.x),n=Pm(t.y),o=Pm(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function Pm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xm(e){return e==="shared"||e==="instance"?e:void 0}function Am(e){return Number.isInteger(e)&&e>=0?e:void 0}var fE="rendering",Gn=Bf;function Ur(e){let t=se(e);return NC(t?.companionConfigs)}function Mm(e){return Ur(e)[fE]??null}function pE(e){return Ar(Ur(e)[Gn])}function NC(e){if(e==null)return{};let t=FC(e,"$.companionConfigs"),r={};for(let[n,o]of Object.entries(t)){if(!n||n!==n.trim())throw Dm("schema.invalidValue","$.companionConfigs");let a=n;if(o===null){r[a]=null;continue}let i=se(o);if(!i)throw Dm("schema.invalidType",`$.companionConfigs.${a}`);a===fE&&gt(i),a===Gn&&qn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function FC(e,t){let r=se(e);if(!r)throw Dm("schema.invalidType",t);return r}function Dm(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}var EE="@fps-games/editor.playable-sdk.scene-compiler",IE="3",_C=new Set(["shadowMode","childMaterialBindings","childMaterials"]),$C=new Set(["coordinateSpace","center","size","rotation"]),gE=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function qc(e){TE(e,!0)}function PE(e){let t=la(e);return qc(t.document),t}function Rm(e){TE(e,!1)}function TE(e,t){let r=k(e);if(!r)throw new Error("editor_scene_must_be_object");if(r.schemaVersion!==1)throw P("schema.unsupportedVersion","$.schemaVersion");if(!Array.isArray(r.assets))throw new Error("editor_scene_assets_must_be_array");let n=k(r.scene);if(!Array.isArray(n?.gameObjects))throw new Error("editor_scene_game_objects_must_be_array");if(n.materialAssets!=null&&!Array.isArray(n.materialAssets))throw new Error("editor_scene_material_assets_must_be_array");if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw P("schema.forbiddenField","$.scene.shadowMapExperiment");VC(r.assets,n.gameObjects),Om(r,"$"),UC(r.assets),BC(r.assets,n.gameObjects),KC(n.gameObjects,r.assets),HC(n.gameObjects),zC(n.materialAssets??[]),t&&WC(r.assets,n.gameObjects),Vs(r),LC(r.assets,n.gameObjects)}function LC(e,t){for(let r=0;r<t.length;r+=1){let n=k(t[r]),o=`$.scene.gameObjects[${r}]`,a=Object.prototype.hasOwnProperty.call(n,"shadow");if(k(n.prefab)){if(a)throw P("schema.forbiddenField",`${o}.shadow`)}else if(dn(n))bE(n.shadow,`${o}.shadow`);else if(a)throw P("schema.forbiddenField",`${o}.shadow`);if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw P("schema.forbiddenField",`${o}.shadowMapExperiment`)}for(let r=0;r<e.length;r+=1){let n=k(e[r]),o=`$.assets[${r}]`,a=k(n.defaults);if(a?.shadow!==void 0)throw P("schema.forbiddenField",`${o}.defaults.shadow`);if(a?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${o}.defaults.shadowMapExperiment`);let i=k(n.prefab);if(!i)continue;let s=k(i.defaults);if(bE(s?.shadow,`${o}.prefab.defaults.shadow`),s?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${o}.prefab.defaults.shadowMapExperiment`);Array.isArray(i.nodes)&&i.nodes.forEach((c,d)=>{let u=k(c),l=`${o}.prefab.nodes[${d}]`,m=k(u?.defaults);if(u?.shadow!==void 0)throw P("schema.forbiddenField",`${l}.shadow`);if(m?.shadow!==void 0)throw P("schema.forbiddenField",`${l}.defaults.shadow`);if(u?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${l}.shadowMapExperiment`);if(m?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${l}.defaults.shadowMapExperiment`)})}}function bE(e,t){let r=k(e);if(!r||r.cast===void 0||r.receive===void 0)throw P("schema.invalidType",t);if(r.cast!=="enabled"&&r.cast!=="none"||r.receive!=="enabled"&&r.receive!=="none")throw P("schema.invalidValue",t);for(let n of Object.keys(r))if(n!=="cast"&&n!=="receive")throw P("schema.forbiddenField",`${t}.${n}`)}function zC(e){let t=new Set,r=new Set;for(let n=0;n<e.length;n+=1){let o=k(e[n]),a=`$.scene.materialAssets[${n}]`;if(!o)throw P("schema.invalidType",a);if(Object.prototype.hasOwnProperty.call(o,"materialKind"))throw P("schema.deprecatedField",`${a}.materialKind`);if(Object.prototype.hasOwnProperty.call(o,"profile"))throw P("schema.deprecatedField",`${a}.profile`);let i=C(o.id);if(!i)throw P("schema.invalidType",`${a}.id`);if(t.has(i))throw P("schema.invalidValue",`${a}.id`);t.add(i);let s=C(o.guid);if(s){if(r.has(s))throw P("schema.invalidValue",`${a}.guid`);r.add(s)}if(!C(o.name))throw P("schema.invalidType",`${a}.name`);let c=C(o.shaderId);if(!c)throw P("schema.invalidValue",`${a}.shaderId`);let d=De(c),u=o.definitionVersion;if(u!=null&&(typeof u!="number"||!Number.isSafeInteger(u)||u<1))throw P("schema.invalidValue",`${a}.definitionVersion`);if(!d&&u==null)throw P("schema.invalidValue",`${a}.definitionVersion`);if(d){let l=eo(c,o.properties,`${a}.properties`);if(l[0])throw P("schema.invalidValue",l[0].path)}else if(!k(o.properties))throw P("schema.invalidType",`${a}.properties`);for(let l of Object.keys(o))if(!["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(l))throw P("schema.unknownField",`${a}.${l}`)}}function BC(e,t){let r=new Set(e.map(k).filter(a=>a?.type==="glb").map(a=>C(a?.id)).filter(a=>!!a)),n=new Set(e.map(k).filter(a=>a?.type==="texture").map(a=>C(a?.id)).filter(a=>!!a)),o=new Map;for(let a of e.map(k)){if(a?.type!=="prefab")continue;let i=C(a.id),s=C(k(a.prefab)?.sourceAssetId);i&&s&&o.set(i,s)}for(let a=0;a<e.length;a+=1){let i=k(e[a]);if(i?.type!=="prefab")continue;let s=k(i.prefab),c=C(s?.sourceAssetId),d=C(s?.rootNodeId);if(!c||!r.has(c))throw P("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);let u=Array.isArray(s?.nodes)?s.nodes:[];for(let l=0;l<u.length;l+=1){let m=k(u[l]),f=C(m?.sourceAssetId);if(m?.kind==="model"&&(!f||!r.has(f)))throw P("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`);if(m?.kind==="prefabInstance"){let S=C(m.childPrefabId),g=S?o.get(S):null;if(C(m.id)===d&&c!==g)throw P("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);if(f&&f!==g)throw P("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`)}}}for(let a=0;a<t.length;a+=1){let i=k(t[a]),s=C(k(i?.instance)?.assetId);if(s&&!r.has(s))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].instance.assetId`);let c=Array.isArray(i?.components)?i.components:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ModelRenderer")continue;let l=C(u.assetId);if(!l||!r.has(l))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`)}for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ImageRenderer")continue;let l=C(u.assetId);if(!l||!n.has(l))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`);let m=k(u.size);if(!m||!hE(m.width)||!hE(m.height))throw P("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function VC(e,t){let r=new Set;e.forEach((a,i)=>{let s=k(a);if(!s)throw P("schema.invalidType",`$.assets[${i}]`);let c=C(s.id);if(!c||!C(s.type))throw P("schema.invalidValue",`$.assets[${i}]`);if(r.has(c))throw P("schema.invalidValue",`$.assets[${i}].id`);r.add(c)});let n=new Set,o=new Map;t.forEach((a,i)=>{let s=k(a);if(!s)throw P("schema.invalidType",`$.scene.gameObjects[${i}]`);let c=C(s.id);if(!c)throw P("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.has(c))throw P("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.add(c),o.set(c,{value:s,index:i}),!Array.isArray(s.components))throw P("schema.invalidType",`$.scene.gameObjects[${i}].components`);s.components.forEach((d,u)=>{let l=k(d);if(!l)throw P("schema.invalidType",`$.scene.gameObjects[${i}].components[${u}]`);if(!C(l.type))throw P("schema.invalidValue",`$.scene.gameObjects[${i}].components[${u}].type`)})});for(let[a,i]of o){if(!("parentId"in i.value))continue;let s=C(i.value.parentId);if(!s||!o.has(s))throw P("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);let c=new Set([a]),d=s;for(;d;){if(c.has(d))throw P("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);c.add(d);let u=o.get(d)?.value;d=u&&u.parentId!=null?C(u.parentId):null}}}function Om(e,t){if(Array.isArray(e)){e.forEach((n,o)=>Om(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(_C.has(n))throw P("schema.deprecatedField",a);n==="shadow"&&Ko(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&Om(o,a)}}function UC(e){let t=new Set(e.map(k).filter(i=>i?.type==="prefab").map(i=>C(i?.id)).filter(i=>!!i)),r=new Map;for(let i=0;i<e.length;i+=1){let s=k(e[i]);if(s?.type!=="prefab")continue;let c=k(s.prefab);if(!Array.isArray(c?.nodes))throw P("schema.unsupportedVersion",`$.assets[${i}].prefab.nodes`);SE(c.defaults,`$.assets[${i}].prefab.defaults`);let d=[],u=new Set;for(let S=0;S<c.nodes.length;S+=1){let g=`$.assets[${i}].prefab.nodes[${S}]`,b=k(c.nodes[S]);if(!b)throw P("schema.invalidType",g);SE(b.defaults,`${g}.defaults`);let y=C(b.id);if(!y||!gE.has(String(b.kind)))throw P("schema.invalidValue",g);if(u.has(y))throw P("schema.invalidValue",`${g}.id`);u.add(y),d.push(b)}let l=C(c?.rootNodeId),m=l?d.find(S=>C(S?.id)===l):null,f=!!m&&gE.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==sn||d.length===0||!f)throw P("schema.unsupportedVersion",`$.assets[${i}].prefab`);r.set(C(s.id),d.flatMap((S,g)=>{let b=C(S.childPrefabId);return b?[{prefabId:b,path:`$.assets[${i}].prefab.nodes[${g}].childPrefabId`}]:[]}));for(let S=0;S<d.length;S+=1){let g=d[S];fg(g,new Map(d.map(T=>[C(T.id),T])),`$.assets[${i}].prefab.nodes[${S}]`);let b=C(g.id),y=C(g.parentId);if(b!==l&&(!y||!u.has(y)))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);if(g.kind==="prefabInstance"){let T=C(g.childPrefabId);if(!T||!t.has(T))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].childPrefabId`)}let I=new Set([b]),E=y;for(;E;){if(I.has(E))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);I.add(E);let T=d.find(A=>C(A.id)===E);E=T?C(T.parentId):null}}}let n=new Set,o=new Set,a=i=>{if(!o.has(i)){n.add(i);for(let s of r.get(i)??[]){if(n.has(s.prefabId))throw P("schema.invalidReference",s.path);a(s.prefabId)}n.delete(i),o.add(i)}};for(let i of r.keys())a(i)}function SE(e,t){if(e==null)return;let r=k(e);if(!r)throw P("schema.invalidType",t);if(Object.prototype.hasOwnProperty.call(r,"active")&&typeof r.active!="boolean")throw P("schema.invalidType",`${t}.active`)}function KC(e,t){let r=new Map;for(let n of t.map(k)){if(n?.type!=="prefab")continue;let o=C(n.id),a=C(k(n.prefab)?.sourceAssetId);o&&a&&r.set(o,a)}for(let n=0;n<e.length;n+=1){let o=k(e[n]);if(!o||o.prefab==null)continue;let a=k(o.prefab),i=C(a?.prefabId),s=i?r.get(i):null;if(!i||!s)throw P("schema.unsupportedVersion",`$.scene.gameObjects[${n}].prefab`);if(C(a?.sourceAssetId)!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].prefab.sourceAssetId`);let c=C(k(o.instance)?.assetId);if(c&&c!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].instance.assetId`);let d=Array.isArray(o.components)?o.components:[];for(let u=0;u<d.length;u+=1){let l=k(d[u]);if(l?.type==="ModelRenderer"&&C(l.assetId)!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].components[${u}].assetId`)}}}function HC(e){for(let t=0;t<e.length;t+=1){let r=k(k(k(e[t])?.marker)?.geometry);if(r?.kind!=="box")continue;for(let o of $C)if(Object.prototype.hasOwnProperty.call(r,o))throw P("schema.deprecatedField",`$.scene.gameObjects[${t}].marker.geometry.${o}`);if(!(Array.isArray(k(e[t])?.components)?k(e[t]).components:[]).some(o=>k(o)?.type==="Transform"))throw P("schema.invalidValue",`$.scene.gameObjects[${t}].components`)}}function WC(e,t){let r=new Map,n=new Map;for(let o=0;o<e.length;o+=1){let a=k(e[o]),i=C(a?.id);if(!a||!i)continue;if(a.type==="prefab"){let l=C(k(a.prefab)?.sourceAssetId);l&&n.set(i,l)}let s=k(a.metadata),c=s?.materialSlots;if(c==null){r.set(i,new Set);continue}if(!Array.isArray(c))throw P("schema.invalidType",`$.assets[${o}].metadata.materialSlots`);let d=qC(s?.assetAnalysis),u=new Set;for(let l=0;l<c.length;l+=1){let m=k(c[l]),f=C(m?.slotId);if(!m||!f)throw P("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}]`);let S=`$.assets[${o}].metadata.materialSlots[${l}]`;for(let g of["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMaterialIndices","sourceMeshName","triangleCount","boundingBox"])if(Object.prototype.hasOwnProperty.call(m,g))throw P("schema.deprecatedField",`${S}.${g}`);if(!Array.isArray(m.sourceSurfaces))throw P("schema.invalidType",`${S}.sourceSurfaces`);if(m.sourceSurfaces.length===0)throw P("schema.invalidValue",`${S}.sourceSurfaces`);for(let g=0;g<m.sourceSurfaces.length;g+=1){let b=`${S}.sourceSurfaces[${g}]`,y=k(m.sourceSurfaces[g]);if(!y||!C(y.ownerNodePath))throw P("schema.invalidValue",b);yE(y,"nodeIndex",b),yE(y,"sourceMaterialIndex",b);for(let E of["meshIndex","primitiveIndex"])if(!Number.isInteger(y[E])||y[E]<0)throw P("schema.invalidValue",`${b}.${E}`);if(y.nodeIndexPath!=null&&(!Array.isArray(y.nodeIndexPath)||y.nodeIndexPath.some(E=>!Number.isInteger(E)||E<0)))throw P("schema.invalidValue",`${b}.nodeIndexPath`);let I=y.meshIndex;if(!C(y.sourceMeshName)&&!d.has(I))throw P("schema.invalidValue",`${b}.sourceMeshName`)}if(u.has(f))throw P("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}].slotId`);u.add(f)}r.set(i,u)}for(let o=0;o<e.length;o+=1){let a=k(e[o]);if(a?.type!=="prefab")continue;let i=k(a.prefab),s=C(i?.sourceAssetId);wm(i?.overrides,s?r.get(s):void 0,`$.assets[${o}].prefab.overrides`);let c=Array.isArray(i?.nodes)?i.nodes:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]),l=C(u?.childPrefabId),m=C(u?.sourceAssetId)??(l?n.get(l)??null:null);wm(u?.overrides,m?r.get(m):void 0,`$.assets[${o}].prefab.nodes[${d}].overrides`)}}for(let o=0;o<t.length;o+=1){let a=k(t[o]),s=(Array.isArray(a?.components)?a.components:[]).map(k).find(d=>d?.type==="ModelRenderer"),c=C(s?.assetId);wm(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function wm(e,t,r){let n=k(e);if(!n||n.materialSlotBindings==null)return;let o=k(n.materialSlotBindings);if(!o)throw P("schema.invalidType",`${r}.materialSlotBindings`);for(let[a,i]of Object.entries(o)){if(!t?.has(a))throw P("schema.invalidReference",`${r}.materialSlotBindings.${a}`);let s=`${r}.materialSlotBindings.${a}`,c=k(i);if(!c)throw P("schema.invalidType",s);for(let d of Object.keys(c))if(d!=="materialAssetId"&&d!=="override")throw P("schema.deprecatedField",`${s}.${d}`);if("materialAssetId"in c&&c.materialAssetId!=null&&!C(c.materialAssetId))throw P("schema.invalidValue",`${s}.materialAssetId`);if("override"in c&&!k(c.override))throw P("schema.invalidType",`${s}.override`);"override"in c&&JC(c.override,`${s}.override`)}}function yE(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw P("schema.invalidValue",`${r}.${t}`)}function qC(e){let t=k(e),r=Array.isArray(t?.meshes)?t.meshes:[];return new Set(r.flatMap(n=>{let o=k(n),a=o?.meshIndex,i=Number.isInteger(a)?a:null;return i!=null&&C(o?.name)?[i]:[]}))}function JC(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);if(Oo(r,["lightingModel","baseColor","normal","metallic","roughness","metallicRoughness","occlusion","emission","alpha"],t),"lightingModel"in r&&!["lit","unlit"].includes(String(r.lightingModel)))throw P("schema.invalidValue",`${t}.lightingModel`);for(let n of["metallic","roughness"])ni(r,n,t);XC(r.baseColor,`${t}.baseColor`),km(r.normal,`${t}.normal`,["texture","strength"]),km(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),km(r.occlusion,`${t}.occlusion`,["texture","strength"]),YC(r.emission,`${t}.emission`),ZC(r.alpha,`${t}.alpha`)}function XC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","texture","brightness","saturation","contrast","hue"],t),xE(r.color,`${t}.color`),ri(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ni(r,n,t)}function km(e,t,r){if(e==null)return;let n=Ro(e,t);Oo(n,r,t),ri(n.texture,`${t}.texture`),r.includes("strength")&&ni(n,"strength",t)}function YC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","intensity","texture","maskTexture"],t),xE(r.color,`${t}.color`),ni(r,"intensity",t),ri(r.texture,`${t}.texture`),ri(r.maskTexture,`${t}.maskTexture`)}function ZC(e,t){if(e==null)return;let r=Ro(e,t);if(Oo(r,["mode","opacity","cutoff","texture"],t),"mode"in r&&!["opaque","mask","blend"].includes(String(r.mode)))throw P("schema.invalidValue",`${t}.mode`);for(let n of["opacity","cutoff"])ni(r,n,t);ri(r.texture,`${t}.texture`)}function ri(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["url","textureAssetId"],t);for(let n of["url","textureAssetId"])if(n in r&&r[n]!=null&&!C(r[n]))throw P("schema.invalidValue",`${t}.${n}`)}function xE(e,t){if(e==null)return;let r=Ro(e,t);for(let n of["r","g","b"])QC(r,n,t)}function Oo(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw P("schema.deprecatedField",`${r}.${o}`)}function ni(e,t,r){if(t in e&&e[t]!=null&&(typeof e[t]!="number"||!Number.isFinite(e[t])))throw P("schema.invalidType",`${r}.${t}`)}function QC(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw P("schema.invalidValue",`${r}.${t}`)}function Ro(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);return r}function P(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function C(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function hE(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}var ev=Object.freeze({bash:"shell",cjs:"javascript",conf:"config",config:"config",css:"css",env:"dotenv",frag:"glsl",fs:"glsl",glsl:"glsl",htm:"html",html:"html",ini:"config",js:"javascript",json:"json",jsonc:"jsonc",jsx:"javascript",less:"less",md:"markdown",mjs:"javascript",scss:"scss",shader:"glsl",sh:"shell",toml:"toml",ts:"typescript",tsx:"typescript",txt:"text",vert:"glsl",vs:"glsl",wgsl:"wgsl",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"shell"}),tv=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),rv=Object.freeze({png:{kind:"image",mimeType:"image/png"},jpg:{kind:"image",mimeType:"image/jpeg"},jpeg:{kind:"image",mimeType:"image/jpeg"},webp:{kind:"image",mimeType:"image/webp"},gif:{kind:"image",mimeType:"image/gif"},bmp:{kind:"image",mimeType:"image/bmp"},glb:{kind:"model",mimeType:"model/gltf-binary"},mp3:{kind:"audio",mimeType:"audio/mpeg"},wav:{kind:"audio",mimeType:"audio/wav"},ogg:{kind:"audio",mimeType:"audio/ogg"},m4a:{kind:"audio",mimeType:"audio/mp4"},aac:{kind:"audio",mimeType:"audio/aac"},flac:{kind:"audio",mimeType:"audio/flac"}});function Jc(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"",n=r.lastIndexOf(".");return n>0?r.slice(n+1):""}function Cm(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return tv[r]??ev[Jc(r)]??null}function AE(e){return Cm(e)!==null}function vm(e){return rv[Jc(e)]??null}var nv="fps.plugin.ground-decal",DE="@fps-games/plugin-ground-decal";function ME(e){iv(e);let t=e.plugins.find(i=>i.pluginId===nv),r=t?av(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:ov(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:sv(e.metadata),project:Object.freeze({projectId:e.projectId,projectName:e.projectName,source:Object.freeze({editorScene:o.document,runtimeScene:o.runtimeArtifact,...o.rendering?{rendering:o.rendering}:{},...o.shadows?{shadows:o.shadows}:{}}),assets:Object.freeze({...a}),features:Object.freeze(n),...e.metadata&&Ce(e.metadata)?{metadata:Object.freeze({...e.metadata})}:{}})})}function ov(e){let t=new Map(e.kinds.map(l=>[l.id,l])),r=new Set(e.editableLayerRoles??[]),n=new Set(e.layoutEditableLayerRoles??[]),o=new Set(e.rotationEditableLayerRoles??[]),a=new Set(e.stretchedImageRoles??[]),i=new Set(e.activePreviewKinds??[]),s=l=>t.has(l),c=l=>{let m=t.get(l)??t.get(e.defaultUiKind);if(!m)throw new Error(`Ground Decal kind is not configured: ${l}`);return structuredClone(m.defaultConfig)},d=l=>cv(l,t),u={defaultUiKind:e.defaultUiKind,isKnownUiKind:s,isProjectEditableLayer:l=>r.size===0||r.has(l.role),isLayoutEditableLayer:l=>n.has(l.role),isRotationEditableLayer:l=>o.has(l.role),createDefaultGroundDecal:c,isGroundDecalConfig:d};return{uiKinds:Object.freeze([...t.keys()]),documentPolicy:u,inspectorPolicy:{...u,isEditableTextureLayer:l=>(l.kind==="texture"||l.kind==="textureProgress")&&(r.size===0||r.has(l.role)),isEditableColorLayer:l=>(l.kind==="color"||l.kind==="progress")&&(r.size===0||r.has(l.role)),isEditableTextLayer:l=>l.kind==="text"&&(r.size===0||r.has(l.role)),useUniformLayoutScaleMode:l=>n.has(l.role),resolveImageFit:l=>"imageFit"in l&&(l.imageFit==="stretch"||l.imageFit==="contain")?l.imageFit:a.has(l.role)?"stretch":"contain",createLayerLabel:l=>dv(l.role),createUiKindLabel:l=>t.get(l)?.label??l,canShowActivePreview:l=>i.has(l.uiKind),getLayerPreviewVisibility:(l,m)=>i.has(m.uiKind)&&l.role==="activeBackground"?{path:"groundDecal.editorPreviewActive",value:m.editorPreviewActive===!0}:null},createHierarchyLabel:l=>t.get(l)?.hierarchyLabel??`${t.get(l)?.label??l} Ground Decal UI`}}function av(e){if(e.packageName!==DE)throw new Error(`Ground Decal Plugin package must be ${DE}.`);if(!e.targets.includes("editor"))throw new Error("Ground Decal Plugin must target editor.");let t=e.config;if(!Ce(t)||t.schemaVersion!==1)throw new Error("Ground Decal Plugin config schemaVersion must be 1.");if(typeof t.defaultUiKind!="string"||!Array.isArray(t.kinds)||t.kinds.length===0)throw new Error("Ground Decal Plugin config must define defaultUiKind and kinds.");let r=new Set;for(let n of t.kinds){if(!Ce(n)||typeof n.id!="string"||typeof n.label!="string"||!Ce(n.defaultConfig))throw new Error("Ground Decal Plugin kinds must contain id, label, and defaultConfig.");if(r.has(n.id))throw new Error(`Duplicate Ground Decal kind: ${n.id}`);if(r.add(n.id),n.defaultConfig.uiKind!==n.id)throw new Error(`Ground Decal defaultConfig.uiKind must match kind id: ${n.id}`)}if(!r.has(t.defaultUiKind))throw new Error(`Ground Decal defaultUiKind is not declared: ${t.defaultUiKind}`);for(let n of["editableLayerRoles","layoutEditableLayerRoles","rotationEditableLayerRoles","stretchedImageRoles","activePreviewKinds"]){let o=t[n];if(o!==void 0&&(!Array.isArray(o)||o.some(a=>typeof a!="string")))throw new Error(`Ground Decal Plugin config.${n} must be an array of strings.`)}return t}function iv(e){if(!Ce(e)||e.schemaVersion!==1)throw new Error("Editor Project definition schemaVersion must be 1.");if(typeof e.projectId!="string"||typeof e.projectName!="string")throw new Error("Editor Project identity is invalid.");if(!Ce(e.authoring)||!Ce(e.authoring.source)||!Ce(e.authoring.assets)||!Array.isArray(e.plugins))throw new Error("Editor Project authoring or Plugin configuration is invalid.")}function sv(e){return Ce(e)?Object.freeze({...Array.isArray(e.markerTypes)?{markerTypes:Object.freeze(e.markerTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{},...Array.isArray(e.relationTypes)?{relationTypes:Object.freeze(e.relationTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{}}):Object.freeze({})}function cv(e,t){if(!Ce(e)||typeof e.uiKind!="string"||!t.has(e.uiKind)||!Ce(e.size)||!Xc(e.size.width)||!Xc(e.size.depth)||!Array.isArray(e.layers))return!1;let r=new Set;for(let n of e.layers){if(!Ce(n)||typeof n.id!="string"||!n.id||typeof n.role!="string"||!n.role||typeof n.kind!="string"||!Ce(n.rect)||!Number.isFinite(n.rect.x)||!Number.isFinite(n.rect.z)||!Xc(n.rect.width)||!Xc(n.rect.depth)||r.has(n.id))return!1;r.add(n.id)}return!0}function Xc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function dv(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var lv=["/__fps_editor_authoring"],uv=[["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"],["asset-import","/asset-import"],["save-editor-scene","/save-editor-scene"]];function wE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??lv,o=mv(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=fv(a);return i?{route:a,routeName:i,prefix:o}:null}function mv(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function fv(e){return uv.find(([,t])=>e===t)?.[0]??null}function Pe(e,t){return{statusCode:e,body:t}}function Yc(e){return{statusCode:e,body:null}}async function kE(e,t){let r=wE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return Yc(204);try{if(pv(r.routeName)){if(n!=="GET")return Pe(405,{ok:!1,error:"method_not_allowed"});if(r.routeName==="project-file"){let a=new URL(e.url??"","http://localhost").searchParams.get("path")?.trim()??"";if(!a)return Pe(400,{ok:!1,error:"missing_file_path"});let i=await t.loadProjectFile?.({path:a,route:r});return Pe(200,i??{ok:!1,error:"not_found"})}return Pe(200,await gv(r,t))}if(n!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let o=e.body??await t.readBody?.(e,r)??{};return await bv(r,o,t)}catch(o){let a=typeof o?.code=="string"?o.code:"authoring_request_failed",i=a==="asset_import_payload_too_large"?413:r.routeName==="save-editor-scene"&&a==="authoring_source_revision_mismatch"?200:r.routeName==="asset-import"?400:500;return Pe(i,{ok:!1,error:o instanceof Error?o.message:String(o),code:a,details:se(o?.details)})}}function pv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function gv(e,t){return e.routeName==="manifest"&&t.loadManifest?t.loadManifest(e):e.routeName==="editor-scene"&&t.loadEditorScene?t.loadEditorScene(e):e.routeName==="editor-asset-library"&&t.loadEditorAssetLibrary?t.loadEditorAssetLibrary(e):e.routeName==="project-files"&&t.loadProjectFiles?t.loadProjectFiles(e):{ok:!1,error:"not_found"}}async function bv(e,t,r){if(e.routeName==="asset-import"){let n=mh(t),o=await r.importAsset?.({payload:n,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}return e.routeName==="save-editor-scene"?Sv(e,t,r):e.routeName==="commit"?Pe(410,await yv(e,t,r)):Pe(404,{ok:!1,error:"not_found"})}async function Sv(e,t,r){let n=t.mode==="prepare-platform-save"?"prepare-platform-save":"local-commit-save",o=await r.saveEditorScene?.({body:t,mode:n,rawEditorScene:t.editorScene,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}async function yv(e,t,r){return r.commit?.({body:t,route:e})??{ok:!1,error:"platform_commit_route_disabled",message:"Save through /__fps_editor_authoring/save-editor-scene so scene.main remains the authoring source of truth."}}function RE(e,t,r={}){let n=PE(e).document,o=t;Object.prototype.hasOwnProperty.call(o,"staticShadows")&&o.staticShadows!=null&&qn(o.staticShadows,"$.staticShadows");let{scene:a,...i}=t,s=structuredClone(i),c=Ue(a)?a:void 0,d=Wt(n),u={...d,compilerId:EE,compilerVersion:IE,compiledAt:new Date().toISOString()};s.schemaVersion=3,s.meta={...s.meta??{},generatedFrom:u};let l=c?.rootId||"root",m=n.scene.gameObjects.filter(I=>I.id!==l),f=Tv(n,r.materialShaderDefinitions,!0),S={...n,scene:{...n.scene,materialAssets:f}},g=m.flatMap(I=>Gv(I,d,S,r)),b=g.map(CE);Ev(l,b),Iv(l,b);let y={rootId:l,assets:S.assets.filter(Dv).map(Mv),nodes:b,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=Nv(s.plugins,r.shadowMapExperimentConfig,g,l,d.revision),Fi(s),{sceneConfig:s,summary:{assetCount:y.assets.length,gameObjectCount:n.scene.gameObjects.length,nodeCount:y.nodes.length}}}function CE(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function Ev(e,t){let r=new Set([e]);for(let n=0;n<t.length;n+=1){let o=t[n].id;if(r.has(o)){let a=new Error(`schema.invalidReference: $.scene.nodes[${n}].id`);throw Object.assign(a,{code:"schema.invalidReference",path:`$.scene.nodes[${n}].id`,nodeId:o}),a}r.add(o)}}function Iv(e,t){let r=new Map(t.map(n=>[n.id,n]));for(let n=0;n<t.length;n+=1){let o=t[n];if(!(o.source?.component!=="PrefabMarker"||!("marker"in o)||!o.marker))for(let a of Pv(o.marker)){let i=r.get(a.target.id);if(a.target.id!==e&&(!i||i.source?.objectId===o.source.objectId))continue;let s=`$.scene.nodes[${n}].marker.${a.path}.id`,c=new Error(`schema.invalidReference: ${s}`);throw Object.assign(c,{code:"schema.invalidReference",path:s,nodeId:o.id,targetId:a.target.id}),c}}}function Pv(e){let t=[];return e.target&&t.push({path:"target",target:e.target}),e.geometry.kind==="point"&&e.geometry.target&&t.push({path:"geometry.target",target:e.geometry.target}),e.geometry.kind==="object-bounds"&&t.push({path:"geometry.target",target:e.geometry.target}),t}function Tv(e,t,r=!1){let n=structuredClone(e.scene.materialAssets??[]);for(let a=0;a<n.length;a+=1){let i=n[a];if(De(i.shaderId))continue;let s=t?.get(i.shaderId);if(!s){if(!r)continue;throw Gm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Gm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=eo(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Gm("material.propertiesInvalid",c[0].path,c[0].message)}let o=os(xv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Gm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function xv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=LE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),...Av(r)]}}}function Av(e){let t=[];for(let r of e.scene.gameObjects){let n=ln(e,r);!n.definition||!Zc(n.definition)||t.push(...vE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function vE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=_E(Ze(e.prefabAsset),Ye(e.prefabAsset)??""),r=t.find(a=>a.id===Ye(e.prefabAsset));if(!r)return e.visitedPrefabIds.delete(e.prefabAsset.id),[];let n=$E(t,e.prefabAsset),o=[];for(let a of t){if(a.kind==="prefabInstance"&&a.childPrefabId){let d=e.editorDocument.assets.find(u=>u.id===a.childPrefabId);if(d&&Zc(d)){o.push(...vE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=Hv(e.hostGameObject,a);if(!i)continue;let s=a.kind==="model"&&a.sourceAssetId?e.editorDocument.assets.find(d=>d.id===a.sourceAssetId):void 0,c=$m({hostGameObject:i,prefabAsset:e.prefabAsset,rootNode:r,node:a,asset:s,editorDocument:e.editorDocument,instanceOverrides:a.id===n?e.instanceOverrides:void 0});c&&o.push({...i,overrides:c})}return e.visitedPrefabIds.delete(e.prefabAsset.id),o}function Dv(e){return e.type==="glb"||e.type==="texture"}function Mv(e){let t=Ov(e),r=e.type==="glb"?Rv(e):[],n=kv(e.external),o=wv(e.defaults);return{id:e.id,type:e.type,...e.guid?{guid:e.guid}:{},...t?{url:t}:{},...typeof e.warmupCount=="number"&&Number.isInteger(e.warmupCount)&&e.warmupCount>=0?{warmupCount:e.warmupCount}:{},...typeof e.singleton=="boolean"?{singleton:e.singleton}:{},...typeof e.materialMode=="string"?{materialMode:e.materialMode}:{},...o!==void 0?{defaults:o}:{},...n?{external:n}:{},...r.length>0?{materialSlots:r}:{}}}function wv(e){if(!e)return;let t=structuredClone(e);return Ue(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function kv(e){let t=Ue(e)?e:void 0,r=yr(t?.platformAssetId),n=yr(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Ov(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Ue(e.external)?e.external:void 0;return yr(t?.url)??yr(r?.assetUrl)??void 0}function Rv(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Cv(t?.assetAnalysis);return r.flatMap(o=>{if(!Ue(o))return[];let a=yr(o.slotId);if(!a)return[];let i=yr(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ue(c))return[];let d=yr(c.ownerNodePath),u=oi(c.meshIndex),l=oi(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=oi(c.nodeIndex),f=vv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),S=oi(c.sourceMaterialIndex),g=yr(c.sourceMeshName)??n.get(u);return[{ownerNodePath:d,...m==null?{}:{nodeIndex:m},...f.length>0?{nodeIndexPath:f}:{},meshIndex:u,primitiveIndex:l,...S==null?{}:{sourceMaterialIndex:S},...g?{sourceMeshName:g}:{}}]});return s.length===0?[]:[{slotId:a,...i?{label:i}:{},sourceSurfaces:s}]})}function Cv(e){let t=Ue(e)?e:void 0,r=Array.isArray(t?.meshes)?t.meshes:[];return new Map(r.flatMap(n=>{if(!Ue(n))return[];let o=oi(n.meshIndex),a=yr(n.name);return o==null||!a?[]:[[o,a]]}))}function vv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function oi(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function Gv(e,t,r,n){let o=ln(r,e);return(o.definition&&Zc(o.definition)?_v(e,o.definition,t,r,new Set,n):[jv(e,t,r,n)]).map(i=>{let s=i.kind==="instance"?r.assets.find(d=>d.id===i.instance.assetId):void 0,c=n.inferShadowMapExperimentUpdateClass?.({gameObject:e,runtimeNode:CE(i),...s?{asset:s}:{}})??Fv(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function jv(e,t,r,n={}){let o=G(e),a=Se(e),i=Rr(e),s=qv(e),c=Y(e),d=LE(e,r),u=cg(e),l={sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision,...e.guid?{objectGuid:e.guid}:{},objectId:e.id,component:a?"ModelRenderer":i?"ImageRenderer":s||c==="primitive"?"PrimitiveRenderer":c==="transform"?"Transform":"GameObject"},m={id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...zv(r,e,n),...u?{rendering:u}:{},source:l,...o&&"position"in o?{transform:{position:o.position,rotation:o.rotation,...o.scale?{scale:o.scale}:{}}}:{}};if(c==="primitive")return{...m,kind:"primitive",primitive:{shape:s?.shape??"cube"},...d?{overrides:d}:{}};if(i)return{...m,kind:"image",image:{assetId:i.assetId,size:{width:i.size.width,height:i.size.height}},...d?{overrides:d}:{}};if(!a){if(c==="transform"){let f=Lv(e,n),S=f.transformType;delete f.transformType;let g=OE(S)??OE(e.transformType);return{...m,kind:"transform",...g?{transformType:g}:{},...e.camera?{camera:Yv(e.camera)}:{},...e.light?{light:zE(e.light)}:{},...e.marker?{marker:{label:e.name||e.id,...structuredClone(e.marker)}}:{},...f,...d?{overrides:d}:{}}}return{...m,kind:"group"}}return{...m,kind:"instance",instance:{assetId:a.assetId},...d?{overrides:d}:{}}}function Nv(e,t,r,n,o){let a=(e??[]).filter(u=>u.pluginId!==bd);if(!t)return a;let i=r.find(u=>u.id===t.lightRef),s=i?.kind==="transform"&&i.light?.type==="directional"?i:void 0;if(!i&&t.enabled)throw new Error(`shadowMapExperiment.lightMissing:${t.lightRef}`);if(i&&!s&&t.enabled)throw new Error(`shadowMapExperiment.lightUnsupported:${t.lightRef}`);let c=s?.kind==="transform"&&s.light?.type==="directional"?[s.light.direction.x,s.light.direction.y,s.light.direction.z]:[0,-1,0],d=Pf({revision:typeof o=="number"&&Number.isInteger(o)&&o>=0?o:0,scopeId:n,config:t,lightDirection:c,objects:r.filter(u=>u.kind==="instance"||u.kind==="primitive").map(u=>({entityId:u.id,renderableIds:[u.id],cast:u.shadow?.cast==="enabled",receive:u.shadow?.receive==="enabled",inferredUpdateClass:u.shadowMapExperimentInferredUpdateClass??"static"}))});return[...a,{pluginId:bd,schemaVersion:3,data:d}]}function Fv(e){let t=Ue(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=jm(t.skinCount),n=jm(t.morphTargetCount);return r>0||n>0?"skinned":jm(t.animationCount)>0?"dynamic":"static"}function jm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function _v(e,t,r,n,o,a){return GE({prefabAsset:t,sourceRef:r,editorDocument:n,hostGameObject:e,rootRuntimeId:e.id,rootParentId:e.parentId,rootName:e.name??t.displayName??t.id,rootTransform:G(e)??void 0,rootActive:e.active,instanceOverrides:e.overrides,propertyPathPrefix:`assets.${t.id}.prefab.nodes`,visitedPrefabIds:o,compilerOptions:a})}function GE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"PrefabCycle",propertyPath:e.propertyPathPrefix})];e.visitedPrefabIds.add(e.prefabAsset.id);let t=Ze(e.prefabAsset),r=Ye(e.prefabAsset),n=r?t.find(d=>d.id===r):null;if(!n||t.length===0)return e.visitedPrefabIds.delete(e.prefabAsset.id),[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"Prefab",propertyPath:e.propertyPathPrefix})];let o={instanceId:e.rootRuntimeId,rootNodeId:n.id},a=d=>ao(o,d.id),i=_E(t,n.id),s=$E(i,e.prefabAsset),c=[];for(let d of i){let u=a(d),l=d.id===n.id?e.rootParentId:a(t.find(m=>m.id===d.parentId)??n);if(d.kind==="prefabInstance"&&d.childPrefabId){let m=e.editorDocument.assets.find(f=>f.id===d.childPrefabId);if(m&&Zc(m)){let f=d.id===n.id;c.push(...GE({prefabAsset:m,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeId:u,rootParentId:l,rootName:f?e.rootName??d.name??m.displayName??m.id:d.name??m.displayName??m.id,rootTransform:f?e.rootTransform??d.transform:d.transform,rootActive:f?e.rootActive??d.defaults?.active??e.prefabAsset.prefab?.defaults?.active:d.defaults?.active,instanceOverrides:f?ai(ai(Yt(e.prefabAsset.prefab?.overrides),Yt(d.overrides)),Yt(e.instanceOverrides)):d.overrides,propertyPathPrefix:`${e.propertyPathPrefix}.${d.id}.childPrefab.nodes`,visitedPrefabIds:new Set(e.visitedPrefabIds),compilerOptions:e.compilerOptions}));continue}c.push(Nm({id:u,name:d.name??d.childPrefabId??"Prefab Instance",parentId:l,transform:d.transform,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,component:"UnsupportedPrefabInstance",propertyPath:`${e.propertyPathPrefix}.${d.id}`}));continue}c.push($v({node:d,rootNode:n,identityScope:o,prefabAsset:e.prefabAsset,runtimeId:u,parentId:l,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeName:e.rootName,rootRuntimeTransform:e.rootTransform,rootRuntimeActive:e.rootActive,instanceOverrides:d.id===s?e.instanceOverrides:void 0,propertyPath:`${e.propertyPathPrefix}.${d.id}`,shadowFallbackMode:_m(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),Vv({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:_m(e.compilerOptions)})}function $v(e){let t=e.node.id===e.rootNode.id,r=t?e.rootRuntimeTransform??e.node.transform:e.node.transform,n=e.node.kind==="model"&&e.node.sourceAssetId?e.editorDocument.assets.find(i=>i.id===e.node.sourceAssetId):void 0,o=e.node.kind==="model"||e.node.kind==="primitive",a=jE({id:e.runtimeId,name:t?e.rootRuntimeName??e.node.name??e.prefabAsset.displayName??e.prefabAsset.id:e.node.name,parentId:e.parentId,transform:r,active:t?e.rootRuntimeActive??e.node.defaults?.active??e.prefabAsset.prefab?.defaults?.active:e.node.defaults?.active,...o?{shadow:e.prefabAsset.prefab?.defaults?.shadow}:{},editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.node.kind==="model"?"PrefabModel":e.node.kind==="primitive"?"PrefabPrimitive":e.node.kind==="light"?"PrefabLight":e.node.kind==="marker"?"PrefabMarker":"PrefabNode",propertyPath:e.propertyPath});if(e.node.kind==="model"&&e.node.sourceAssetId){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:n,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"instance",instance:{assetId:e.node.sourceAssetId},...i?{overrides:i}:{}}}if(e.node.kind==="primitive"){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:void 0,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"primitive",primitive:{shape:e.node.primitive?.shape??"cube"},...i?{overrides:i}:{}}}return e.node.kind==="light"?{...a,kind:"transform",transformType:"light",...e.node.light?{light:zE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...fa(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Nm(e){return{...jE({id:e.id,name:e.name,parentId:e.parentId,transform:e.transform,editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.component,propertyPath:e.propertyPath}),kind:"group"}}function Lv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function jE(e){return{id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Bv(e),source:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,revision:e.sourceRef.revision,...e.hostGameObject.guid?{objectGuid:e.hostGameObject.guid}:{},objectId:e.hostGameObject.id,component:e.component,propertyPath:e.propertyPath},...e.transform&&"position"in e.transform?{transform:{position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}}:{}}}function zv(e,t,r){let n=xs({document:e,casterId:t.id,caster:t,fallbackMode:_m(r)});return Lm(n,!!t.shadow)?{shadowPlan:n}:{}}function Bv(e){if(!e.editorDocument)return{};let t=He(e.shadow),r=!!e.shadow||!!t.shadow;if(!r&&t.diagnostics.length===0)return{};let n=xs({document:e.editorDocument,casterId:e.hostGameObject.id,caster:e.hostGameObject,resolvedSettings:t.shadow,fallbackMode:e.shadowFallbackMode}),o={...n,casterId:e.id,diagnostics:[...t.diagnostics,...n.diagnostics].map(a=>({...a,casterId:a.casterId===e.hostGameObject.id||!a.casterId?e.id:a.casterId}))};return Lm(o,r)?{shadowPlan:o}:{}}function Lm(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function Vv(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>Uv(i)),n={...e.editorDocument,scene:{...e.editorDocument.scene,gameObjects:[...e.editorDocument.scene.gameObjects.filter(i=>!t.has(i.id)),...r]}},o=e.compiledNodes.filter(i=>i.shadow?.receive==="enabled").map(i=>i.id),a=r.find(i=>i.light?.type==="directional"&&i.active!==!1)?.id;return e.compiledNodes.map((i,s)=>{let c=r[s],d=xs({document:n,casterId:i.id,caster:c,explicitReceiverIds:o,...a?{defaultLightId:a}:{},fallbackMode:e.shadowFallbackMode}),u=!!i.shadow;if(!Lm(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function _m(e){let t=Ne(e.renderingProfile).shadows,r=t.planar.enabled?"planar":t.blob.enabled?"blob":t.staticProjected.enabled?"static":t.enabled?"dynamic":"none";return r==="planar"?"projected":r}function Uv(e){let t=[];return e.transform&&t.push({type:"Transform",position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}),e.kind==="instance"&&t.push({type:"ModelRenderer",assetId:e.instance.assetId}),e.kind==="image"&&t.push({type:"ImageRenderer",assetId:e.image.assetId,size:structuredClone(e.image.size)}),{id:e.id,...e.name?{name:e.name}:{},kind:e.kind==="image"?"transform":e.kind,...e.parentId?{parentId:e.parentId}:{},...e.enabled===!1?{active:!1}:{},...e.shadow?{shadow:{cast:e.shadow.cast==="enabled"?"enabled":"none",receive:e.shadow.receive==="enabled"?"enabled":"none"}}:{},...e.kind==="primitive"?{primitive:{shape:e.primitive.shape}}:{},...e.kind==="transform"&&e.transformType?{transformType:e.transformType}:{},...e.kind==="transform"&&e.light?{light:e.light}:{},...e.kind==="transform"&&e.camera?{camera:e.camera}:{},...e.kind==="transform"&&e.marker?{marker:structuredClone(e.marker)}:{},components:t}}function $m(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?FE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=Wv([Fm(Yt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),Fm(Yt(e.rootNode.overrides),e.rootNode.kind==="model"?e.rootNode.sourceAssetId:e.prefabAsset.prefab?.sourceAssetId,e.asset),e.node.id===e.rootNode.id?void 0:Fm(Yt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Yt(e.instanceOverrides);return NE(ai(n,o),e.asset)}function Fm(e,t,r){return NE(e,t&&t===r?.id?r:void 0)}function NE(e,t){if(!e?.materialSlotBindings)return e;let r=Ue(t?.metadata)&&Array.isArray(t.metadata.materialSlots)?t.metadata.materialSlots:[],n=new Set(r.flatMap(i=>{let s=Ue(i)&&typeof i.slotId=="string"?i.slotId.trim():"";return s?[s]:[]})),o=Object.fromEntries(Object.entries(e.materialSlotBindings).filter(([i])=>n.has(i))),a=structuredClone(e);return Object.keys(o).length>0?a.materialSlotBindings=o:delete a.materialSlotBindings,Object.keys(a).length>0?a:void 0}function FE(e,t,r){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"instance",components:[...t.transform?[t.transform]:[],{type:"ModelRenderer",assetId:r}]}}function Kv(e,t){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"primitive",primitive:{shape:t.primitive?.shape??"cube"},components:[...t.transform?[t.transform]:[]]}}function Hv(e,t){return t.kind==="model"&&t.sourceAssetId?FE(e,t,t.sourceAssetId):t.kind==="primitive"?Kv(e,t):null}function Wv(e){let t;for(let r of e){let n=Yt(r);n&&(t=ai(t,n))}return t}function _E(e,t){let r=new Map;for(let s of e){if(!s.parentId)continue;let c=r.get(s.parentId)??[];c.push(s),r.set(s.parentId,c)}let n=[],o=new Set,a=s=>{if(!o.has(s.id)){o.add(s.id),n.push(s);for(let c of r.get(s.id)??[])a(c)}},i=e.find(s=>s.id===t);i&&a(i);for(let s of e)a(s);return n}function $E(e,t){let r=t.prefab?.sourceAssetId;return e.find(n=>n.kind==="model"&&n.sourceAssetId===r)?.id??e.find(n=>n.kind==="model")?.id}function Zc(e){return Xe(e)&&e.prefab.compositionVersion===sn&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ye(e)}function qv(e){return e.primitive??null}function LE(e,t){let r=Y(e);if(r!=="instance"&&r!=="transform"&&r!=="primitive")return;let n=Se(e),o=n?t.assets.find(a=>a.id===n.assetId):void 0;return Jv(e,t,o)}function Jv(e,t,r){let n=Yt(e.overrides),o=ln(t,e),a=Yt(o.definition?.prefab?.overrides);return ai(a,n)}function ai(e,t){let r=cs(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))Xv(o)||a===void 0||(r??={},r[o]=structuredClone(a));return r&&Object.keys(r).length>0?r:void 0}function Yt(e){if(!Ue(e))return;let t=structuredClone(e);return Object.keys(t).length>0?t:void 0}function Xv(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ue(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function yr(e){return(typeof e=="string"?e.trim():"")||void 0}function OE(e){return typeof e=="string"?e:void 0}function Yv(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function zE(e){return e.type==="directional"?Un({schemaVersion:1,type:"directional",intensity:e.intensity,direction:Xo(e.direction),diffuseColor:e.diffuseColor??_a.diffuseColor}):Un({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??kn.diffuseColor,groundColor:e.groundColor??kn.groundColor})}var Zv=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function UE(e){let t=_i(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>Qv(n,o)),rendering:{textureWidth:t.width,textureHeight:t.height}};return e.aspectSourceLayerId&&(r.aspectSourceLayerId=e.aspectSourceLayerId),typeof e.lockAspectToBorder=="boolean"&&(r.lockAspectToBorder=e.lockAspectToBorder),e.mask&&(r.mask={...typeof e.mask.enabled=="boolean"?{enabled:e.mask.enabled}:{},...e.mask.source==="roundedRect"||e.mask.source==="borderAlpha"||e.mask.source==="texture"?{source:e.mask.source}:{},...e.mask.textureId?{textureId:e.mask.textureId}:{},...typeof e.mask.cornerRadius=="number"&&Number.isFinite(e.mask.cornerRadius)?{cornerRadius:e.mask.cornerRadius}:{},...typeof e.mask.padding=="number"&&Number.isFinite(e.mask.padding)?{padding:e.mask.padding}:{}}),e.rendering&&(r.rendering={...r.rendering,...typeof e.rendering.alphaIndex=="number"&&Number.isFinite(e.rendering.alphaIndex)?{alphaIndex:e.rendering.alphaIndex}:{},...typeof e.rendering.diffuseTextureLevel=="number"&&Number.isFinite(e.rendering.diffuseTextureLevel)?{diffuseTextureLevel:e.rendering.diffuseTextureLevel}:{},...typeof e.rendering.emissiveTextureLevel=="number"&&Number.isFinite(e.rendering.emissiveTextureLevel)?{emissiveTextureLevel:e.rendering.emissiveTextureLevel}:{}}),r}function Qv(e,t){let r=Ao(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:eG(e.rect),...r!==0?{rotationDeg:r}:{},...typeof e.enabled=="boolean"?{enabled:e.enabled}:{},...typeof e.opacity=="number"&&Number.isFinite(e.opacity)?{opacity:e.opacity}:{}};return e.kind==="texture"?{...n,kind:"texture",...e.textureId?{textureId:e.textureId}:{},...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:VE(e.value),...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...BE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:Co(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:VE(e.value??0),color:Co(e.color),...BE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:Co(e.text.color),...e.text.fontFamily?{fontFamily:e.text.fontFamily}:{},...typeof e.text.fontSize=="number"&&Number.isFinite(e.text.fontSize)?{fontSize:e.text.fontSize}:{},...e.text.fontWeight!=null?{fontWeight:String(e.text.fontWeight)}:{},...e.text.strokeColor?{strokeColor:Co(e.text.strokeColor)}:{},...typeof e.text.strokeWidth=="number"&&Number.isFinite(e.text.strokeWidth)?{strokeWidth:e.text.strokeWidth}:{},...e.text.align==="left"||e.text.align==="center"||e.text.align==="right"?{align:e.text.align}:{},...e.text.baseline==="top"||e.text.baseline==="middle"||e.text.baseline==="bottom"?{baseline:e.text.baseline}:{}}}}function eG(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function Co(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function BE(e){return typeof e=="string"&&Zv.has(e)}function VE(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function KE(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return Yc(204);try{if(r==="GET"){let c=oG(await t.loadConfig?.()),d=c.renderingConfig;gt(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:nG(d),normalized:u,summary:Vn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=ii(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});gt(o);let a=Ne(o),i=Vn(a),s=await t.saveConfig?.({body:n,renderingConfig:o,normalized:a,summary:i});return Pe(200,{ok:!0,...s??{},renderingConfig:o,normalized:a,summary:i})}catch(n){let o=tG(n),a=rG(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:ii(n?.details)})}}function tG(e){let t=e?.code;return typeof t=="string"&&t?t:null}function rG(e){let t=e?.path;return typeof t=="string"&&t?t:null}function ii(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function nG(e){return ii(e)??{}}function oG(e){let t=ii(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:ii(t.response)??{}}:{renderingConfig:e??{},response:{}}}function HE(e,t={}){let r=t.generatedBy??"scripts/register-asset.mjs",n=t.codeKeyPolicy??"legacy",o=e.filter(d=>d.codeKey);if(n==="disabled"&&o.length>0){let d=o[0];throw Object.assign(new Error("manifest_code_key_disabled"),{name:"PlayableEditorAssetCatalogGenerationError",details:{codeKeyPolicy:n,assetId:d.assetId,codeKey:d.codeKey}})}let a=e.map(d=>`import ${Hc(d.assetId)} from ${JSON.stringify(`${d.relativePath}?url`)};`).join(`
8
- `),i=e.map(d=>{let u=_f(d.relativePath);if(!u)throw new Error(`Generated asset catalog entry has no file extension: ${d.assetId}`);if(!$f(u))throw new Error(`Generated asset catalog entry has unsupported format: ${d.assetId} (${u})`);let l=[`guid: ${JSON.stringify(d.guid)}`,`assetId: ${JSON.stringify(d.assetId)}`,`kind: ${JSON.stringify(d.kind)}`,`displayName: ${JSON.stringify(d.displayName)}`,`url: ${Hc(d.assetId)}`,`format: ${JSON.stringify(u)}`,`relativePath: ${JSON.stringify(d.relativePath)}`,d.originalFileName?`originalFileName: ${JSON.stringify(d.originalFileName)}`:"",d.codeKey?`codeKey: ${JSON.stringify(d.codeKey)}`:"",d.category?`category: ${JSON.stringify(d.category)}`:"",typeof d.placeable=="boolean"?`placeable: ${JSON.stringify(d.placeable)}`:"",typeof d.warmupCount=="number"?`warmupCount: ${JSON.stringify(d.warmupCount)}`:"",typeof d.singleton=="boolean"?`singleton: ${JSON.stringify(d.singleton)}`:"",d.materialMode?`materialMode: ${JSON.stringify(d.materialMode)}`:"",d.defaults?`defaults: ${JSON.stringify(d.defaults)}`:"",d.contentHash?`contentHash: ${JSON.stringify(d.contentHash)}`:"",typeof d.byteSize=="number"?`byteSize: ${JSON.stringify(d.byteSize)}`:"",d.external?`external: ${JSON.stringify(d.external)}`:"",d.metadata?`metadata: ${JSON.stringify(d.metadata)}`:"",d.createdAt?`createdAt: ${JSON.stringify(d.createdAt)}`:"",d.updatedAt?`updatedAt: ${JSON.stringify(d.updatedAt)}`:""].filter(Boolean).join(", ");return` ${JSON.stringify(d.assetId)}: { ${l} },`}).join(`
1
+ import{EventEmitter as xP}from"node:events";var Jo="medium",md={low:{opacity:.32,softness:.25,bias:.0015,normalBias:.02,maxDistance:24,resolution:512,cascadeCount:1,bakeSamples:8,blurKernel:2},medium:{opacity:.42,softness:.4,bias:.001,normalBias:.01,maxDistance:48,resolution:1024,cascadeCount:2,bakeSamples:24,blurKernel:4},high:{opacity:.5,softness:.58,bias:8e-4,normalBias:.006,maxDistance:80,resolution:2048,cascadeCount:4,bakeSamples:64,blurKernel:8},ultra:{opacity:.56,softness:.72,bias:6e-4,normalBias:.004,maxDistance:120,resolution:4096,cascadeCount:4,bakeSamples:128,blurKernel:12}};function Di(e=Jo,t={}){let r=md[e]??md[Jo];return{opacity:qo(t.opacity,r.opacity),softness:qo(t.softness,r.softness),bias:qo(t.bias,r.bias),normalBias:qo(t.normalBias,r.normalBias),maxDistance:qo(t.maxDistance,r.maxDistance),resolution:RP(t.resolution,r.resolution),cascadeCount:CP(t.cascadeCount,r.cascadeCount),bakeSamples:kP(t.bakeSamples,r.bakeSamples),blurKernel:OP(t.blurKernel,r.blurKernel)}}function qo(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function kP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):t}function OP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e):t}function RP(e,t){return e===512||e===1024||e===2048||e===4096?e:t}function CP(e,t){return e===1||e===2||e===4?e:t}function Mi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function wi(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function ki(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Oi(e){return e==="inherit"||e==="none"||e==="dynamic"||e==="static"||e==="blob"||e==="projected"||e==="auto"}function Ri(e){return e==="inherit"||e==="low"||e==="medium"||e==="high"||e==="ultra"}function Ci(e){return e==="inherit"||e==="scene-main"||e==="nearest"||e==="explicit"}function Mf(e){let t=Mi(e);if(!t)return;let r={};wi(t.cast)&&(r.cast=t.cast),ki(t.receive)&&(r.receive=t.receive),Oi(t.mode)&&(r.mode=t.mode),Ri(t.quality)&&(r.quality=t.quality);let n=Mi(t.light);if(n){let a={};Ci(n.mode)&&(a.mode=n.mode),typeof n.lightId=="string"&&n.lightId.trim()&&(a.lightId=n.lightId.trim()),Object.keys(a).length>0&&(r.light=a)}let o=vP(t.params);return o&&(r.params=o),Object.keys(r).length>0?r:void 0}function We(e){let t=Mf(e);return t?{shadow:t,diagnostics:[]}:{diagnostics:[]}}function fd(e,t="none"){let r=e?.mode;return!r||r==="inherit"||r==="auto"?t:r}function pd(e,t=Jo){let r=e?.quality;return r&&r!=="inherit"?r:t}function vP(e){let t=Mi(e);if(!t)return;let r={};return typeof t.opacity=="number"&&Number.isFinite(t.opacity)&&(r.opacity=t.opacity),typeof t.softness=="number"&&Number.isFinite(t.softness)&&(r.softness=t.softness),typeof t.bias=="number"&&Number.isFinite(t.bias)&&(r.bias=t.bias),typeof t.normalBias=="number"&&Number.isFinite(t.normalBias)&&(r.normalBias=t.normalBias),typeof t.maxDistance=="number"&&Number.isFinite(t.maxDistance)&&(r.maxDistance=t.maxDistance),(t.resolution===512||t.resolution===1024||t.resolution===2048||t.resolution===4096)&&(r.resolution=t.resolution),(t.cascadeCount===1||t.cascadeCount===2||t.cascadeCount===4)&&(r.cascadeCount=t.cascadeCount),typeof t.bakeSamples=="number"&&Number.isFinite(t.bakeSamples)&&(r.bakeSamples=t.bakeSamples),typeof t.blurKernel=="number"&&Number.isFinite(t.blurKernel)&&(r.blurKernel=t.blurKernel),Object.keys(r).length>0?r:void 0}var GP=new Set(["cast","receive","mode","quality","light","params"]),jP=new Set(["mode","lightId"]),NP=new Set(["opacity","softness","bias","normalBias","maxDistance","resolution","cascadeCount","bakeSamples","blurKernel"]);function Xo(e,t="$.shadow"){let r=bd(e);if(!r)throw ve("schema.invalidType",t);if(gd(r,GP,t),"cast"in r&&!wi(r.cast))throw ve("schema.invalidValue",`${t}.cast`);if("receive"in r&&!ki(r.receive))throw ve("schema.invalidValue",`${t}.receive`);if("mode"in r&&!Oi(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("quality"in r&&!Ri(r.quality))throw ve("schema.invalidValue",`${t}.quality`);"light"in r&&FP(r.light,`${t}.light`),"params"in r&&_P(r.params,`${t}.params`)}function FP(e,t){let r=bd(e);if(!r)throw ve("schema.invalidType",t);if(gd(r,jP,t),"mode"in r&&!Ci(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("lightId"in r&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`);if(r.mode==="explicit"&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`)}function _P(e,t){let r=bd(e);if(!r)throw ve("schema.invalidType",t);if(gd(r,NP,t),Zr(r,"opacity",t,n=>n>=0&&n<=1),Zr(r,"softness",t,n=>n>=0),Zr(r,"bias",t,()=>!0),Zr(r,"normalBias",t,()=>!0),Zr(r,"maxDistance",t,n=>n>0),Zr(r,"bakeSamples",t,n=>n>0),Zr(r,"blurKernel",t,n=>n>=0),"resolution"in r&&![512,1024,2048,4096].includes(r.resolution))throw ve("schema.invalidValue",`${t}.resolution`);if("cascadeCount"in r&&![1,2,4].includes(r.cascadeCount))throw ve("schema.invalidValue",`${t}.cascadeCount`)}function Zr(e,t,r,n){if(!(t in e))return;let o=e[t];if(typeof o!="number"||!Number.isFinite(o)||!n(o))throw ve("schema.invalidValue",`${r}.${t}`)}function gd(e,t,r){for(let n of Object.keys(e))if(!t.has(n))throw ve("schema.deprecatedField",`${r}.${n}`)}function ve(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function bd(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var Ed="fps.shadow-map-experiment";function $P(e,t="$.scene.shadowMapExperiment"){let r=gt(e,t);jt(r,["qualityProfile","behaviorProfile"],t),r.qualityProfile!==void 0&&Gt(r.qualityProfile,`${t}.qualityProfile`),r.behaviorProfile!==void 0&&Gt(r.behaviorProfile,`${t}.behaviorProfile`)}function LP(e,t="$.shadowMapExperiment"){let r=gt(e,t);jt(r,["behaviorProfile"],t),Gt(r.behaviorProfile,`${t}.behaviorProfile`)}function Gi(e,t="$"){let r=gt(e,t);jt(r,["schemaVersion","enabled","lightRef","defaultQualityProfile","defaultBehaviorProfile","qualityProfiles","behaviorProfiles"],t),r.schemaVersion!==1&&H(`${t}.schemaVersion`,"expected 1"),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),Gt(r.lightRef,`${t}.lightRef`);let n=Gt(r.defaultQualityProfile,`${t}.defaultQualityProfile`),o=Gt(r.defaultBehaviorProfile,`${t}.defaultBehaviorProfile`),a=kf(r.qualityProfiles,`${t}.qualityProfiles`),i=kf(r.behaviorProfiles,`${t}.behaviorProfiles`);for(let[s,c]of Object.entries(a))BP(c,`${t}.qualityProfiles.${s}`);for(let[s,c]of Object.entries(i))VP(c,`${t}.behaviorProfiles.${s}`);Object.prototype.hasOwnProperty.call(a,n)||H(`${t}.defaultQualityProfile`,`unknown quality profile: ${n}`),Object.prototype.hasOwnProperty.call(i,o)||H(`${t}.defaultBehaviorProfile`,`unknown behavior profile: ${o}`)}function Of(e){Gi(e.config),e.settings!==void 0&&$P(e.settings),(!Number.isInteger(e.revision)||e.revision<0)&&H("$.revision","expected a non-negative integer");let t=e.settings?.qualityProfile??e.config.defaultQualityProfile,r=e.settings?.behaviorProfile??e.config.defaultBehaviorProfile,n=yd(e.config.qualityProfiles,t,"$.settings.qualityProfile","quality");yd(e.config.behaviorProfiles,r,"$.settings.behaviorProfile","behavior");let o=e.objects.map((s,c)=>{let d=`$.objects[${c}]`;s.override!==void 0&&LP(s.override,`${d}.override`);let u=s.override?.behaviorProfile??r,l=yd(e.config.behaviorProfiles,u,`${d}.override.behaviorProfile`,"behavior");return Object.freeze({entityId:Gt(s.entityId,`${d}.entityId`),renderableIds:Object.freeze(YP(s.renderableIds,`${d}.renderableIds`)),cast:wf(s.cast,`${d}.cast`)??l.cast==="enabled",receive:wf(s.receive,`${d}.receive`)??l.receive==="enabled",updateClass:l.updateClass!=="auto"?l.updateClass:s.inferredUpdateClass??"static",behaviorProfileId:u})}).sort((s,c)=>s.entityId.localeCompare(c.entityId)),a=e.config.enabled?o:[];JP(a);let i=Object.fromEntries(Object.entries(e.config.behaviorProfiles).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>[s,Object.freeze({cast:c.cast==="enabled",receive:c.receive==="enabled",updateClass:c.updateClass})]));return Rf({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:Gt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:Zo(e.lightDirection,"$.lightDirection")},qualityProfileId:t,generator:{maps:{...n.maps},...n.cascadeCount===void 0?{}:{cascadeCount:n.cascadeCount},filter:n.receiverFilter,bias:n.bias,normalBias:n.normalBias,darkness:n.darkness,...n.softness===void 0?{}:{softness:n.softness},bounds:XP(n.bounds),backend:{...n.backend}},culling:{...n.culling},diagnosticThresholds:{...n.diagnostics},behaviorProfiles:i,objects:a,diagnostics:[]})}function wf(e,t){if(e!==void 0)return typeof e!="boolean"&&H(t,"expected a boolean"),e}function zP(e,t){let r=gt(e,t);jt(r,["mode","center","extent","near","far"],t),r.mode!=="fixed"&&H(`${t}.mode`,"expected fixed"),Zo(r.center,`${t}.center`),Zo(r.extent,`${t}.extent`).some(i=>i<=0)&&H(`${t}.extent`,"expected positive values");let o=vi(r.near,`${t}.near`),a=vi(r.far,`${t}.far`);(o<0||a<=o)&&H(t,"expected 0 <= near < far")}function BP(e,t){let r=gt(e,t);jt(r,["maps","cascadeCount","receiverFilter","bias","normalBias","darkness","softness","bounds","backend","culling","diagnostics"],t),UP(r.maps,`${t}.maps`),r.cascadeCount!==void 0&&KP(r.cascadeCount,`${t}.cascadeCount`),r.receiverFilter!=="hard"&&r.receiverFilter!=="low-pcf"&&H(`${t}.receiverFilter`,"expected hard or low-pcf"),Yo(r.bias,`${t}.bias`,0,.1),Yo(r.normalBias,`${t}.normalBias`,0,1),Yo(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&Yo(r.softness,`${t}.softness`,0,1),zP(r.bounds,`${t}.bounds`),HP(r.backend,`${t}.backend`),WP(r.culling,`${t}.culling`),qP(r.diagnostics,`${t}.diagnostics`)}function VP(e,t){let r=gt(e,t);jt(r,["cast","receive","updateClass"],t),r.cast!=="enabled"&&r.cast!=="disabled"&&H(`${t}.cast`,"expected enabled or disabled"),r.receive!=="enabled"&&r.receive!=="disabled"&&H(`${t}.receive`,"expected enabled or disabled"),["auto","static","dynamic","skinned"].includes(String(r.updateClass))||H(`${t}.updateClass`,"expected auto, static, dynamic, or skinned")}function UP(e,t){let r=gt(e,t);jt(r,["staticResolution","dynamicResolution","compositeResolution"],t),Sd(r.staticResolution,`${t}.staticResolution`),Sd(r.dynamicResolution,`${t}.dynamicResolution`),Sd(r.compositeResolution,`${t}.compositeResolution`)}function Sd(e,t){e!==512&&e!==1024&&e!==2048&&e!==4096&&H(t,"expected 512, 1024, 2048, or 4096")}function KP(e,t){e!==1&&e!==2&&e!==4&&H(t,"expected 1, 2, or 4")}function HP(e,t){let r=gt(e,t);jt(r,["mode","fallback"],t),["auto","split","single"].includes(String(r.mode))||H(`${t}.mode`,"expected auto, split, or single"),r.fallback!=="single-map"&&r.fallback!=="disable"&&H(`${t}.fallback`,"expected single-map or disable")}function WP(e,t){let r=gt(e,t);jt(r,["enabled","guardBandRatio"],t),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),Yo(r.guardBandRatio,`${t}.guardBandRatio`,0,4)}function qP(e,t){let r=gt(e,t);jt(r,["staticCasterCountWarning","dynamicCasterCountWarning","renderableCountWarning"],t),hd(r.staticCasterCountWarning,`${t}.staticCasterCountWarning`),hd(r.dynamicCasterCountWarning,`${t}.dynamicCasterCountWarning`),hd(r.renderableCountWarning,`${t}.renderableCountWarning`)}function JP(e){let t=new Set,r=new Set;for(let n of e){t.has(n.entityId)&&H("$.objects",`duplicate entity id: ${n.entityId}`),t.add(n.entityId);for(let o of n.renderableIds)r.has(o)&&H("$.objects",`duplicate renderable id: ${o}`),r.add(o)}}function kf(e,t){let r=gt(e,t);Object.keys(r).length===0&&H(t,"expected at least one profile");for(let n of Object.keys(r))Gt(n,`${t} key`);return r}function yd(e,t,r,n){return Object.prototype.hasOwnProperty.call(e,t)||H(r,`unknown ${n} profile: ${t}`),e[t]}function XP(e){return Object.freeze({mode:"fixed",center:Zo(e.center,"$.bounds.center"),extent:Zo(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function Zo(e,t){let r=ZP(e,t);return r.length!==3&&H(t,"expected exactly three numbers"),Object.freeze(r.map((n,o)=>vi(n,`${t}[${o}]`)))}function YP(e,t){let r=e.map((n,o)=>Gt(n,`${t}[${o}]`));return new Set(r).size!==r.length&&H(t,"expected unique strings"),r}function vi(e,t){return(typeof e!="number"||!Number.isFinite(e))&&H(t,"expected a finite number"),e}function Yo(e,t,r,n){let o=vi(e,t);return(o<r||o>n)&&H(t,`expected ${r}..${n}`),o}function hd(e,t){return(!Number.isInteger(e)||e<0)&&H(t,"expected a non-negative integer"),e}function Gt(e,t){return(typeof e!="string"||!e.trim()||e!==e.trim())&&H(t,"expected a trimmed non-empty string"),e}function gt(e,t){(!e||typeof e!="object"||Array.isArray(e))&&H(t,"expected an object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&H(t,"expected a plain object"),e}function ZP(e,t){return Array.isArray(e)||H(t,"expected an array"),e}function jt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||H(`${r}.${o}`,"unknown field")}function Rf(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))Rf(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var Cf=["useBlobShadow","blobSettings"],QP=["resolution","maxSize"],eT=new Set(["none","blob","static","planar","dynamic"]);function St(e){let t=Qr(e);if(!t)throw X("schema.invalidType","$");for(let o of Cf)if(Object.prototype.hasOwnProperty.call(t,o))throw X("schema.deprecatedField",`$.${o}`);if(q(t,["globalVolume","materials","renderingGroups","shadowMeshes","shadows"],"$"),nT(t.globalVolume,"$.globalVolume"),oT(t.materials,"$.materials"),tT(t.renderingGroups,"$.renderingGroups"),rT(t.globalVolume,"$.globalVolume"),lT(t.shadowMeshes,"$.shadowMeshes"),!Object.prototype.hasOwnProperty.call(t,"shadows"))return;let r=Qr(t.shadows);if(!r)throw X("schema.invalidType","$.shadows");for(let o of Cf)if(Object.prototype.hasOwnProperty.call(r,o))throw X("schema.deprecatedField",`$.shadows.${o}`);if(q(r,["defaultMode","enabled","useCsm","settings","blob","staticProjected","planar","shadowRange","shadowOrtho","csm"],"$.shadows"),"defaultMode"in r&&!eT.has(String(r.defaultMode)))throw X("schema.invalidValue","$.shadows.defaultMode");Ge(r,"enabled","$.shadows"),Ge(r,"useCsm","$.shadows");let n=Qr(r.settings);if(Object.prototype.hasOwnProperty.call(r,"settings")&&!n)throw X("schema.invalidType","$.shadows.settings");if(n){q(n,["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ","useBlurExponentialShadowMap","shadowColor"],"$.shadows.settings");for(let o of["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ"])Ae(n,o,"$.shadows.settings");Ge(n,"useBlurExponentialShadowMap","$.shadows.settings"),ji(n.shadowColor,"$.shadows.settings.shadowColor",!1)}iT(r.blob,"$.shadows.blob"),sT(r.staticProjected,"$.shadows.staticProjected"),cT(r.planar,"$.shadows.planar"),en(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),en(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),dT(r.csm,"$.shadows.csm")}function tT(e,t){if(e===void 0)return;let r=Qr(e);if(!r||!Array.isArray(r.slots))throw X("schema.invalidType",t);q(r,["slots"],t),r.slots.forEach((n,o)=>{let a=`${t}.slots[${o}]`,i=Qr(n);if(!i)throw X("schema.invalidType",a);if(q(i,["renderingGroupId","name","alphaIndexPresets"],a),![0,1,2,3].includes(i.renderingGroupId))throw X("schema.invalidValue",`${a}.renderingGroupId`);if(typeof i.name!="string"||!i.name.trim())throw X("schema.invalidValue",`${a}.name`);if(!Array.isArray(i.alphaIndexPresets))throw X("schema.invalidType",`${a}.alphaIndexPresets`);i.alphaIndexPresets.forEach((s,c)=>{let d=`${a}.alphaIndexPresets[${c}]`,u=Qr(s);if(!u)throw X("schema.invalidType",d);if(q(u,["name","alphaIndex"],d),typeof u.name!="string"||!u.name.trim())throw X("schema.invalidValue",`${d}.name`);Pd(u,"alphaIndex",d)})})}function rT(e,t){if(e===void 0)return;let r=ge(e,t);for(let a of["samples","camera","lights"])if(a in r)throw X("schema.deprecatedField",`${t}.${a}`);if(q(r,["enabled","hdr","environment","imageProcessing","toneMapping","antialiasing","postProcessing","rendering","textures"],t),Ge(r,"enabled",t),Ge(r,"hdr",t),r.environment!==void 0){let a=ge(r.environment,`${t}.environment`);for(let i of["textureAssetId","textureUrl","intensity"])if(i in a)throw X("schema.deprecatedField",`${t}.environment.${i}`);if(q(a,["texture","iblIntensity","rotationY","useCocosIBL"],`${t}.environment`),a.texture!==void 0&&a.texture!==null){let i=ge(a.texture,`${t}.environment.texture`);for(let s of Object.keys(i))if(s!=="textureAssetId"&&s!=="url")throw X("schema.deprecatedField",`${t}.environment.texture.${s}`);for(let s of["textureAssetId","url"])if(s in i&&i[s]!=null&&(typeof i[s]!="string"||!i[s].trim()))throw X("schema.invalidValue",`${t}.environment.texture.${s}`)}Ae(a,"iblIntensity",`${t}.environment`),Ae(a,"rotationY",`${t}.environment`),Ge(a,"useCocosIBL",`${t}.environment`)}if(en(r.imageProcessing,`${t}.imageProcessing`,["exposure","contrast"]),r.toneMapping!==void 0){let a=ge(r.toneMapping,`${t}.toneMapping`);if(q(a,["enabled","type"],`${t}.toneMapping`),Ge(a,"enabled",`${t}.toneMapping`),"type"in a&&!["standard","aces","khr-pbr-neutral"].includes(String(a.type)))throw X("schema.invalidValue",`${t}.toneMapping.type`)}if(r.antialiasing!==void 0){let a=ge(r.antialiasing,`${t}.antialiasing`);if(q(a,["samples"],`${t}.antialiasing`),"samples"in a&&![1,2,4,8].includes(a.samples))throw X("schema.invalidValue",`${t}.antialiasing.samples`)}let n=bt(r.postProcessing,`${t}.postProcessing`);n&&q(n,["bloom"],`${t}.postProcessing`);let o=n?bt(n.bloom,`${t}.postProcessing.bloom`):null;if(o){q(o,["enabled","threshold","weight","kernel","scale"],`${t}.postProcessing.bloom`),Ge(o,"enabled",`${t}.postProcessing.bloom`);for(let a of["threshold","weight","kernel","scale"])Ae(o,a,`${t}.postProcessing.bloom`)}}function nT(e,t){if(e===void 0)return;let r=ge(e,t),n=bt(r.rendering,`${t}.rendering`);n&&(q(n,["maxDpr","hardwareScalingLevel"],`${t}.rendering`),Ae(n,"maxDpr",`${t}.rendering`),aT(n,"hardwareScalingLevel",`${t}.rendering`));let o=bt(r.textures,`${t}.textures`);if(o&&(q(o,["anisotropicFilteringLevel","samplingMode"],`${t}.textures`),Ae(o,"anisotropicFilteringLevel",`${t}.textures`),"samplingMode"in o&&(typeof o.samplingMode!="string"||!o.samplingMode.trim())))throw X("schema.invalidValue",`${t}.textures.samplingMode`)}function oT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["sceneMaterials","plantMaterials"],t);for(let n of["sceneMaterials","plantMaterials"])n in r&&ge(r[n],`${t}.${n}`)}function aT(e,t,r){!(t in e)||e[t]==null||Ae(e,t,r)}function iT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","size"],t),Ge(r,"enabled",t),en(r.plane,`${t}.plane`,["height","yOffset"]);let n=bt(r.appearance,`${t}.appearance`);n&&(q(n,["color","edgeSoftness"],`${t}.appearance`),ji(n.color,`${t}.appearance.color`,!0),Ae(n,"edgeSoftness",`${t}.appearance`)),en(r.size,`${t}.size`,["sizeMultiplier","minSize","maxSize"])}function sT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","bake"],t),Ge(r,"enabled",t),en(r.plane,`${t}.plane`,["height","yOffset"]);let n=bt(r.appearance,`${t}.appearance`);if(n&&(q(n,["color"],`${t}.appearance`),ji(n.color,`${t}.appearance.color`,!0)),r.bake===void 0)return;let o=ge(r.bake,`${t}.bake`);for(let a of QP)if(a in o)throw X("schema.deprecatedField",`${t}.bake.${a}`);q(o,["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"],`${t}.bake`);for(let a of["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"])Ae(o,a,`${t}.bake`)}function cT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","projection","stencil","casters","receivers"],t),Ge(r,"enabled",t);let n=bt(r.plane,`${t}.plane`);if(n){q(n,["normal","height","bias","heightMode"],`${t}.plane`),uT(n.normal,`${t}.plane.normal`);for(let c of["height","bias"])Ae(n,c,`${t}.plane`);if("heightMode"in n&&!["fixed","receiver"].includes(String(n.heightMode)))throw X("schema.invalidValue",`${t}.plane.heightMode`)}let o=bt(r.appearance,`${t}.appearance`);o&&(q(o,["color"],`${t}.appearance`),ji(o.color,`${t}.appearance.color`,!0)),en(r.projection,`${t}.projection`,["footprintScale"]);let a=bt(r.stencil,`${t}.stencil`);if(a){q(a,["enabled","receiverRenderingGroup","shadowRenderingGroup"],`${t}.stencil`),Ge(a,"enabled",`${t}.stencil`);for(let c of["receiverRenderingGroup","shadowRenderingGroup"])Ae(a,c,`${t}.stencil`)}let i=bt(r.casters,`${t}.casters`);if(i){q(i,["autoDetectAll","includePatterns","excludePatterns","rootBoundaryPatterns","minVolume"],`${t}.casters`),Ge(i,"autoDetectAll",`${t}.casters`);for(let c of["includePatterns","excludePatterns","rootBoundaryPatterns"])Id(i[c],`${t}.casters.${c}`);Ae(i,"minVolume",`${t}.casters`)}let s=bt(r.receivers,`${t}.receivers`);s&&(q(s,["patterns"],`${t}.receivers`),Id(s.patterns,`${t}.receivers.patterns`))}function dT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["numCascades","lambda","cascadeBlendPercentage","stabilizeCascades"],t);for(let n of["numCascades","lambda","cascadeBlendPercentage"])Ae(r,n,t);Ge(r,"stabilizeCascades",t)}function lT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["shadowReceivers","shadowCasters","excludeFromShadow"],t);for(let n of["shadowReceivers","shadowCasters","excludeFromShadow"])Id(r[n],`${t}.${n}`)}function en(e,t,r){if(e===void 0)return;let n=ge(e,t);q(n,r,t);for(let o of r)Ae(n,o,t)}function ji(e,t,r){if(e===void 0)return;let n=ge(e,t),o=r?["r","g","b","a"]:["r","g","b"];q(n,o,t);for(let a of o)Pd(n,a,t)}function uT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["x","y","z"],t);for(let n of["x","y","z"])Pd(r,n,t)}function Id(e,t){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw X("schema.invalidType",t)}function Pd(e,t,r){if(!(t in e))throw X("schema.invalidValue",`${r}.${t}`);Ae(e,t,r)}function bt(e,t){return e===void 0?null:ge(e,t)}function ge(e,t){let r=Qr(e);if(!r)throw X("schema.invalidType",t);return r}function Ge(e,t,r){if(t in e&&typeof e[t]!="boolean")throw X("schema.invalidValue",`${r}.${t}`)}function Ae(e,t,r){if(!(t in e))return;let n=e[t];if(typeof n!="number"||!Number.isFinite(n))throw X("schema.invalidValue",`${r}.${t}`)}function q(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw X("schema.unknownField",`${r}.${o}`)}function X(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function Qr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function vf(e,t){let r=L(e);return{x:be(r.x,t.x),y:be(r.y,t.y),z:be(r.z,t.z)}}function Td(e,t){let r=L(e);return{r:nr(r.r,t.r,0,1),g:nr(r.g,t.g,0,1),b:nr(r.b,t.b,0,1)}}function Qo(e,t){let r=L(e);return{...Td(r,t),a:nr(r.a,t.a,0,1)}}function Ar(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter((t,r,n)=>t.length>0&&n.indexOf(t)===r):[]}function xd(e){return(typeof e=="string"?e.trim():"")||null}function Ad(e,t){return(typeof e=="string"?e.trim():"")||t}function je(e,t){return typeof e=="boolean"?e:t}function Gf(e){return e===0||e===1||e===2||e===3?e:null}function jf(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function Nf(e,t){return e===1||e===2||e===4||e===8?e:t}function Ff(e,t){return e==="fixed"||e==="receiver"?e:t}function _f(e,t){return e==="none"||e==="blob"||e==="static"||e==="planar"||e==="dynamic"?e:t}function be(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Q(e,t){let r=be(e,t);return Math.max(0,r)}function Dr(e,t){let r=be(e,t);return r>0?r:t}function nr(e,t,r,n){let o=be(e,t);return Math.min(n,Math.max(r,o))}var $f=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Lf=[...$f,"_blobShadow"],mT=[...Lf,"_staticProjectedShadow"];var zf=[{renderingGroupId:0,name:"\u666E\u901A\u573A\u666F",alphaIndexPresets:[{name:"\u9ED8\u8BA4\u900F\u660E\u987A\u5E8F",alphaIndex:0},{name:"\u5730\u8868\u8D34\u82B1",alphaIndex:100},{name:"\u8FD1\u666F\u8986\u76D6",alphaIndex:200}]},{renderingGroupId:1,name:"\u6C34\u9762 / \u900F\u660E\u5730\u8868",alphaIndexPresets:[{name:"\u6C34\u9762",alphaIndex:0},{name:"\u900F\u660E\u5730\u8868",alphaIndex:100},{name:"\u6C34\u9762\u9AD8\u5149",alphaIndex:200}]},{renderingGroupId:2,name:"\u7279\u6548",alphaIndexPresets:[{name:"\u666E\u901A\u7279\u6548",alphaIndex:0},{name:"\u524D\u666F\u7279\u6548",alphaIndex:100},{name:"\u6700\u524D\u7279\u6548",alphaIndex:200}]},{renderingGroupId:3,name:"\u4E16\u754C\u7A7A\u95F4 UI / \u5F15\u5BFC\u7BAD\u5934",alphaIndexPresets:[{name:"\u4E16\u754C\u7A7A\u95F4 UI",alphaIndex:0},{name:"\u5F15\u5BFC\u7BAD\u5934",alphaIndex:100},{name:"\u9876\u5C42\u63D0\u793A",alphaIndex:200}]}];function Ne(e){e!=null&&St(e);let t=L(e),r=L(t.shadows),n=L(r.settings),o=L(r.blob),a=fT(o),i=gT(r.staticProjected),s=L(r.shadowRange),c=L(r.shadowOrtho),d=L(r.csm),u=L(t.shadowMeshes);return{renderingGroups:Bf(t.renderingGroups),environment:bT(t.globalVolume),postProcess:ST(t.globalVolume),shadows:{defaultMode:_f(r.defaultMode,"none"),enabled:je(r.enabled,!1),useCsm:je(r.useCsm,!1),settings:{mapSize:Q(n.mapSize,1024),darkness:Q(n.darkness,.3),blurKernel:Q(n.blurKernel,16),bias:Q(n.bias,5e-5),normalBias:Q(n.normalBias,.02),useBlurExponentialShadowMap:je(n.useBlurExponentialShadowMap,!0),shadowMinZ:Q(n.shadowMinZ,1),shadowMaxZ:Q(n.shadowMaxZ,60),shadowColor:Td(n.shadowColor,{r:0,g:0,b:0})},blob:a,staticProjected:i,shadowRange:{minZ:Q(s.minZ,1),maxZ:Q(s.maxZ,60)},shadowOrtho:{left:be(c.left,-20),right:be(c.right,20),top:be(c.top,20),bottom:be(c.bottom,-20)},csm:{numCascades:Q(d.numCascades,2),lambda:nr(d.lambda,.5,0,1),cascadeBlendPercentage:nr(d.cascadeBlendPercentage,.1,0,1),stabilizeCascades:je(d.stabilizeCascades,!0)},planar:pT(r.planar)},shadowMeshes:{shadowReceivers:Ar(u.shadowReceivers),shadowCasters:Ar(u.shadowCasters),excludeFromShadow:Ar(u.excludeFromShadow)}}}function Hn(e){let t=e?.environment?.texture!=null;return{environmentTextureAssetId:e?.environment?.texture?.textureAssetId??null,environmentTextureUrl:e?.environment?.texture?.url??null,environmentIblIntensity:t?e?.environment?.iblIntensity??null:null,postProcessEnabled:e?.postProcess?.enabled??null,postProcessExposure:e?.postProcess?.imageProcessing?.exposure??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??null,blobEnabled:e?.shadows?.blob?.enabled??null,blobOpacity:e?.shadows?.blob?.appearance?.color?.a??null,staticProjectedEnabled:e?.shadows?.staticProjected?.enabled??null,staticProjectedOpacity:e?.shadows?.staticProjected?.appearance?.color?.a??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}function fT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.size),a=Qo(n.color,{r:0,g:0,b:0,a:.35});return{enabled:je(t.enabled,!0),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:Qo(n.color,a),edgeSoftness:nr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Dr(o.maxSize,20)}}}function Bf(e){let t=L(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:zf.map(n=>{let o=r.find(i=>Gf(L(i).renderingGroupId)===n.renderingGroupId),a=L(o);return{renderingGroupId:n.renderingGroupId,name:Ad(a.name,n.name),alphaIndexPresets:Vf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function Vf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=L(a),c=be(s.alphaIndex,Number.NaN);!Number.isFinite(c)||n.has(c)||(n.add(c),o.push({name:Ad(s.name,`Order ${i+1}`),alphaIndex:c}))}),o}function pT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.projection),a=L(t.stencil),i=L(t.casters),s=L(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:vf(r.normal,{x:0,y:1,z:0}),height:be(r.height,0),heightMode:Ff(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:Qo(n.color,{r:0,g:0,b:0,a:.35})},projection:{footprintScale:nr(o.footprintScale,1,0,2)},stencil:{enabled:je(a.enabled,!0),receiverRenderingGroup:Q(a.receiverRenderingGroup,0),shadowRenderingGroup:Q(a.shadowRenderingGroup,1)},casters:{autoDetectAll:je(i.autoDetectAll,!0),includePatterns:Ar(i.includePatterns),excludePatterns:Ar(i.excludePatterns),rootBoundaryPatterns:Ar(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Ar(s.patterns)}}}function gT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.bake),a=Dr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:Qo(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Dr(o.texelsPerMeter,256),atlasSize:Dr(o.atlasSize,4096),maxAtlasPages:Dr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Dr(o.targetChunkCount,64)}}}function bT(e){let t=L(e),r=L(t.environment),n=L(r.texture),o=xd(n.textureAssetId),a=xd(n.url);return{texture:o||a?{...o?{textureAssetId:o}:{},...a?{url:a}:{}}:null,iblIntensity:Q(r.iblIntensity,1),rotationY:be(r.rotationY,0)}}function ST(e){let t=L(e),r=L(t.imageProcessing),n=L(t.toneMapping),o=L(t.antialiasing),a=L(t.postProcessing),i=L(a.bloom);return{enabled:je(t.enabled,!0),hdr:je(t.hdr,!0),imageProcessing:{exposure:be(r.exposure,1),contrast:be(r.contrast,1)},toneMapping:{enabled:je(n.enabled,!0),type:jf(n.type,"aces")},antialiasing:{samples:Nf(o.samples,4)},bloom:{enabled:je(i.enabled,!1),threshold:Q(i.threshold,.9),weight:Q(i.weight,.2),kernel:Q(i.kernel,64),scale:Dr(i.scale,.5)}}}var Ni=class extends Error{path;reason;code="runtime.lighting.invalid";constructor(t,r){super(`Invalid Runtime Lighting data at ${t}: ${r}`),this.path=t,this.reason=r,this.name="FpsRuntimeLightingDataError"}},Uf=1e-6,yT=1e-4,hT=new Set(["schemaVersion","type","intensity","direction","diffuseColor"]),ET=new Set(["schemaVersion","type","intensity","diffuseColor","groundColor"]),IT=new Set(["x","y","z"]),PT=new Set(["r","g","b"]);function ta(e,t="$.direction"){let r=Kf(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Uf&&yt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Wn(e,t="$.light"){let r=wd(e,t);r.schemaVersion!==1&&yt(`${t}.schemaVersion`,"expected 1");let n=TT(r.intensity,`${t}.intensity`);if(r.type==="directional"){Fi(r,hT,t);let o=Kf(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Uf&&yt(`${t}.direction`,"expected a non-zero direction vector"),Math.abs(a-1)>yT&&yt(`${t}.direction`,"expected a normalized direction vector"),Object.freeze({schemaVersion:1,type:"directional",intensity:n,direction:o,diffuseColor:Dd(r.diffuseColor,`${t}.diffuseColor`)})}if(r.type==="hemispheric")return Fi(r,ET,t),Object.freeze({schemaVersion:1,type:"hemispheric",intensity:n,diffuseColor:Dd(r.diffuseColor,`${t}.diffuseColor`),groundColor:Dd(r.groundColor,`${t}.groundColor`)});yt(`${t}.type`,"expected directional or hemispheric")}function Kf(e,t){let r=wd(e,t);return Fi(r,IT,t),Object.freeze({x:ea(r.x,`${t}.x`),y:ea(r.y,`${t}.y`),z:ea(r.z,`${t}.z`)})}function Dd(e,t){let r=wd(e,t);return Fi(r,PT,t),Object.freeze({r:Md(r.r,`${t}.r`),g:Md(r.g,`${t}.g`),b:Md(r.b,`${t}.b`)})}function wd(e,t){(!e||typeof e!="object"||Array.isArray(e))&&yt(t,"expected a plain object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&yt(t,"expected a plain object"),e}function Fi(e,t,r){for(let n of Object.keys(e))t.has(n)||yt(`${r}.${n}`,"unknown field")}function ea(e,t){return(typeof e!="number"||!Number.isFinite(e))&&yt(t,"expected a finite number"),e}function TT(e,t){let r=ea(e,t);return r<0&&yt(t,"expected a non-negative number"),r}function Md(e,t){let r=ea(e,t);return(r<0||r>1)&&yt(t,"expected a number between 0 and 1"),r}function yt(e,t){throw new Ni(e,t)}var xT=new Set([".glb",".gltf",".png",".jpg",".jpeg",".webp",".env",".hdr",".dds",".ktx",".ktx2",".mp3",".wav",".ogg",".flac",".aac",".m4a"]);function _i(e){let t=String(e??"").trim().toLowerCase();if(/^\.[a-z0-9]+$/.test(t))return t;let r=t.split(/[?#]/,1)[0]??"",n=r.slice(r.lastIndexOf("/")+1),o=n.lastIndexOf(".");return o<=0||o===n.length-1?null:n.slice(o)}function Hf(e){return xT.has(e)}function Xn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function Wf(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=qf(e.baseColor?.color);n&&(r.color=n);let o=tn(e.baseColor?.texture);o!==void 0&&(r.texture=o),or(e.baseColor,r,"brightness"),or(e.baseColor,r,"saturation"),or(e.baseColor,r,"contrast"),or(e.baseColor,r,"hue"),Object.keys(r).length>0&&(t.baseColor=r);let a={},i=tn(e.normal?.texture);i!==void 0&&(a.texture=i),or(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Jn(e.metallic)&&(t.metallic=e.metallic),Jn(e.roughness)&&(t.roughness=e.roughness);let s={},c=tn(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=tn(e.occlusion?.texture);u!==void 0&&(d.texture=u),or(e.occlusion,d,"strength"),Object.keys(d).length>0&&(t.occlusion=d);let l={},m=qf(e.emission?.color);m&&(l.color=m),or(e.emission,l,"intensity");let f=tn(e.emission?.texture);f!==void 0&&(l.texture=f);let g=tn(e.emission?.maskTexture);g!==void 0&&(l.maskTexture=g),Object.keys(l).length>0&&(t.emission=l);let b={};(e.alpha?.mode==="opaque"||e.alpha?.mode==="mask"||e.alpha?.mode==="blend")&&(b.mode=e.alpha.mode),or(e.alpha,b,"opacity"),or(e.alpha,b,"cutoff");let S=tn(e.alpha?.texture);return S!==void 0&&(b.texture=S),Object.keys(b).length>0&&(t.alpha=b),Object.keys(t).length>0?t:void 0}function kd(...e){let t={};for(let r of e){let n=Wf(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),qn(t,n,"baseColor"),qn(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),qn(t,n,"metallicRoughness"),qn(t,n,"occlusion"),qn(t,n,"emission"),qn(t,n,"alpha"))}return Wf(t)??{}}function qn(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function qf(e){return e&&Jn(e.r)&&Jn(e.g)&&Jn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function tn(e){if(e===null)return null;if(!e||typeof e!="object")return;let t=typeof e.url=="string"?e.url.trim():"",r=typeof e.textureAssetId=="string"?e.textureAssetId.trim():"";if(!(!t&&!r))return{...t?{url:t}:{},...r?{textureAssetId:r}:{}}}function or(e,t,r){Jn(e?.[r])&&(t[r]=e[r])}function Jn(e){return typeof e=="number"&&Number.isFinite(e)}var Jf="staticShadows";function wr(e){let t=ir(e);if(!t)return null;let r=fe(t.sourceHash),n=fe(t.lightHash),o=fe(t.profileHash);if(!r||!n||!o)return null;let a={sourceHash:r,lightHash:n,profileHash:o,...typeof t.generatedAt=="string"&&t.generatedAt.trim()?{generatedAt:t.generatedAt.trim()}:{},...(()=>{let u=CT(t.stats);return u?{stats:u}:{}})()};if(t.version!==2||t.format!=="sdf-atlas"||!Array.isArray(t.pages)||!Array.isArray(t.chunks))return null;let i=[],s=new Map;for(let u of t.pages){let l=AT(u);if(!l||s.has(l.id))return null;i.push(l),s.set(l.id,l)}let c=[],d=new Set;for(let u of t.chunks){let l=DT(u,s);if(!l||d.has(l.id))return null;c.push(l),d.add(l.id)}return{version:2,format:"sdf-atlas",pages:i,chunks:c,...a}}function Yn(e,t="$.staticShadows"){let r=wr(e);if(r)return r;let n=new Error(`schema.unsupportedVersion: ${t}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:t}),n}function AT(e){let t=ir(e);if(!t)return null;let r=fe(t.id),n=Bi(t.width),o=Bi(t.height),a=vT(t.sdfTextureDataUrl);return!r||n==null||o==null||!a?null:{id:r,width:n,height:o,sdfTextureDataUrl:a}}function DT(e,t){let r=ir(e);if(!r)return null;let n=fe(r.id),o=OT(r.bounds),a=RT(r.plane),i=fe(r.pageId),s=wT(r.atlasRect),c=kT(r.atlasUv),d=GT(r.sourceNodeIds),u=fe(r.sourceHash),l=fe(r.lightHash),m=fe(r.profileHash);if(!n||!o||!a||!i||!s||!c||!d||!u||!l||!m)return null;let f=t.get(i);return!f||s.x+s.width>f.width||s.y+s.height>f.height?null:{id:n,bounds:o,plane:a,pageId:i,atlasRect:s,atlasUv:c,sourceNodeIds:d,sourceHash:u,lightHash:l,profileHash:m,...(()=>{let g=MT(r.binding);return g?{binding:g}:{}})()}}function MT(e){let t=ir(e);if(!t)return null;let r=fe(t.id),n=fe(t.ownerCasterId),o=fe(t.receiverId),a=fe(t.generatedAt),i=fe(t.sourceHash);if(!r||!n||!o||!a||!i||t.visibleWhenOwnerVisible!==!0||t.staleWhenOwnerTransformChanges!==!0||t.staleWhenLightChanges!==!0)return null;let s=fe(t.lightId),c=fe(t.textureAssetId),d=fe(t.projectionNodeId);return{id:r,ownerCasterId:n,receiverId:o,...s?{lightId:s}:{},...c?{textureAssetId:c}:{},...d?{projectionNodeId:d}:{},visibleWhenOwnerVisible:!0,staleWhenOwnerTransformChanges:!0,staleWhenLightChanges:!0,generatedAt:a,sourceHash:i}}function wT(e){let t=ir(e);if(!t)return null;let r=Mr(t.x),n=Mr(t.y),o=Bi(t.width),a=Bi(t.height);return r==null||n==null||o==null||a==null?null:{x:r,y:n,width:o,height:a}}function kT(e){let t=ir(e);if(!t)return null;let r=$i(t.u0),n=$i(t.v0),o=$i(t.u1),a=$i(t.v1);return r==null||n==null||o==null||a==null||o<=r||a<=n?null:{u0:r,v0:n,u1:o,v1:a}}function OT(e){let t=ir(e);if(!t)return null;let r=Nt(t.minX),n=Nt(t.maxX),o=Nt(t.minZ),a=Nt(t.maxZ),i=Nt(t.y);return r==null||n==null||o==null||a==null||i==null||n<=r||a<=o?null:{minX:r,maxX:n,minZ:o,maxZ:a,y:i}}function RT(e){let t=ir(e);if(!t)return null;let r=Nt(t.height),n=Nt(t.yOffset);return r==null||n==null||n<0?null:{height:r,yOffset:n}}function CT(e){let t=ir(e);if(!t)return null;let r=Mr(t.sourceRootCount),n=Mr(t.sourceMeshCount),o=Mr(t.attemptedChunkCount),a=Mr(t.chunkCount),i=Mr(t.textureCount);return r==null||n==null||o==null||a==null||i==null?null:{sourceRootCount:r,sourceMeshCount:n,attemptedChunkCount:o,chunkCount:a,textureCount:i,...Li(t.skippedChunkCount,"skippedChunkCount"),...Li(t.pageCount,"pageCount"),...ar(t.resolution,"resolution"),...ar(t.chunkSize,"chunkSize"),...ar(t.atlasSize,"atlasSize"),...zi(t.atlasUsedPixels,"atlasUsedPixels"),...zi(t.atlasAllocatedPixels,"atlasAllocatedPixels"),...jT(t.atlasOccupancy,"atlasOccupancy"),...ar(t.texelsPerMeter,"texelsPerMeter"),...ar(t.effectiveTexelsPerMeter,"effectiveTexelsPerMeter"),...ar(t.maxAtlasPages,"maxAtlasPages"),...zi(t.sdfRadiusPx,"sdfRadiusPx"),...ar(t.spatialChunkSize,"spatialChunkSize"),...ar(t.effectiveSpatialChunkSize,"effectiveSpatialChunkSize"),...ar(t.targetChunkCount,"targetChunkCount"),...Li(t.bakedChunkCount,"bakedChunkCount"),...Li(t.reusedChunkCount,"reusedChunkCount"),...zi(t.durationMs,"durationMs")}}function vT(e){let t=fe(e);return t&&/^data:image\/png[;,]/i.test(t)?t:null}function GT(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],r=new Set;for(let n of e){let o=fe(n);if(!o)return null;r.has(o)||t.push(o),r.add(o)}return t}function fe(e){return typeof e=="string"&&e.trim()?e.trim():null}function Nt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Mr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Bi(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:null}function $i(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:null}function Li(e,t){let r=Mr(e);return r==null?{}:{[t]:r}}function ar(e,t){let r=Nt(e);return r==null||r<=0?{}:{[t]:r}}function zi(e,t){let r=Nt(e);return r==null||r<0?{}:{[t]:r}}function jT(e,t){let r=Nt(e);return r==null||r<0||r>1?{}:{[t]:r}}function ir(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var NT="@fps-games/editor.playable-sdk.scene-compiler",FT="2",_T=1e-4,tt={nodeKinds:["group","instance","transform","primitive","image"],primitiveShapes:["cube","sphere","plane","capsule"],transformTypes:["plain","light","camera","groundDecal"],assetTypes:["glb","texture"],materialScopes:["sharedAsset","nodeMaterial"],materialModes:["shared","instance"],materialShaderIds:["fps.builtin.pbr","fps.builtin.standard"],materialAssetSystemPresets:["default-pbr","default-standard"],runtimeV3:{assetFields:["id","guid","type","url","external","warmupCount","singleton","materialMode","defaults","materialSlots"],materialSlotFields:["slotId","label","sourceSurfaces"],materialSlotSourceSurfaceFields:["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMeshName"]},hierarchy:{parentTargets:["root","sceneNode"]},runtimeOnlyTokens:["/@fs","assetUrl","sourceAssetUrl","sourceAssetPath"]},$T=new Set(tt.nodeKinds),LT=new Set(tt.primitiveShapes),zT=new Set(tt.assetTypes),BT=new Set(tt.materialModes),VT=new Set(tt.materialScopes),UT=new Set(tt.materialAssetSystemPresets),KT=new Set(tt.transformTypes),ra=new Set(tt.hierarchy.parentTargets),HT=tt.runtimeOnlyTokens,WT=new Set(tt.runtimeV3.assetFields),qT=new Set(tt.runtimeV3.materialSlotFields),JT=new Set(tt.runtimeV3.materialSlotSourceSurfaceFields);function XT(e,t={}){let{allowOrphanSharedMaterials:r=!0,allowOrphanNodeMaterials:n=!0,strictAssetIds:o=[],strictNodeIds:a=[],maxErrors:i=50}=t,s=Number.isInteger(i)&&i>0?i:50,c=[],d=new Set(o),u=new Set(a),l=(p,A)=>{c.length<s&&c.push({path:p,message:A})};if(!M(e))return l("$","scene json must be an object"),c;let m=e.schemaVersion;m!==2&&m!==3&&l("$.schemaVersion","schemaVersion must be 2 or 3"),ux(e.meta?.generatedFrom,"$.meta.generatedFrom",l);let f=Ex(e),g=e.scene;if(!M(g))return l("$.scene","scene must be an object"),c;if(O(g.rootId)||l("$.scene.rootId","rootId must be a non-empty string"),Array.isArray(g.assets)||l("$.scene.assets","assets must be an array"),Array.isArray(g.nodes)||l("$.scene.nodes","nodes must be an array"),Array.isArray(g.materialAssets)||l("$.scene.materialAssets","materialAssets must be an array"),Array.isArray(g.materials)||l("$.scene.materials","materials must be an array"),Array.isArray(g.textures)||l("$.scene.textures","textures must be an array"),c.length>0)return c;e.staticShadows!=null&&Xf(()=>Yn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let b=new Set,S=new Map,y=new Map,I=new Set,E=new Set([g.rootId]),D=new Map,x=new Map,N=new Set;return g.assets.forEach((p,A)=>{let h=`$.scene.assets[${A}]`;if(!M(p)){l(h,"asset must be an object");return}if(O(p.id)?b.has(p.id)?l(`${h}.id`,`duplicate asset id: ${p.id}`):(b.add(p.id),S.set(p.id,p.type)):l(`${h}.id`,"asset.id must be a non-empty string"),zT.has(p.type)||l(`${h}.type`,"asset.type must be glb or texture"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"asset.guid must be a non-empty string when present"),p.url!=null&&!O(p.url)&&l(`${h}.url`,"url must be a non-empty string when present"),p.external!=null&&!M(p.external)&&l(`${h}.external`,"external must be an object when present"),p.warmupCount!=null&&(!Number.isInteger(p.warmupCount)||p.warmupCount<0)&&l(`${h}.warmupCount`,"warmupCount must be a non-negative integer when present"),p.singleton!=null&&typeof p.singleton!="boolean"&&l(`${h}.singleton`,"singleton must be a boolean when present"),p.materialMode!=null&&!BT.has(p.materialMode)&&l(`${h}.materialMode`,"materialMode must be shared or instance"),lx(p.defaults,`${h}.defaults`,l),m===3)for(let _ of Object.keys(p))WT.has(_)||l(`${h}.${_}`,`runtime schema v3 asset field is not allowed: ${_}`);else p.displayName!=null&&!O(p.displayName)&&l(`${h}.displayName`,"displayName must be a non-empty string when present"),p.category!=null&&!O(p.category)&&l(`${h}.category`,"category must be a non-empty string when present"),p.metadata!=null&&!M(p.metadata)&&l(`${h}.metadata`,"metadata must be an object when present");let R=m===3?p.materialSlots:M(p.metadata)?p.metadata.materialSlots:void 0,K=m===3?`${h}.materialSlots`:`${h}.metadata.materialSlots`,ne=new Set;R!=null&&(Array.isArray(R)?R.forEach((_,xr)=>{let tr=`${K}[${xr}]`;if(!M(_)||!O(_.slotId)){l(tr,m===3?"material slot must contain a stable slotId":"material slot must contain stable slotId and ownerNodePath");return}if(m!==3&&!O(_.ownerNodePath)){l(tr,"material slot must contain stable slotId and ownerNodePath");return}ne.has(_.slotId)?l(`${tr}.slotId`,`duplicate material slot id: ${_.slotId}`):ne.add(_.slotId),m===3&&dx(_,tr,l)}):l(K,"materialSlots must be an array when present")),O(p.id)&&y.set(p.id,ne),d.has(p.id)&&Qf(p,h,l)}),g.nodes.forEach((p,A)=>{let h=`$.scene.nodes[${A}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&D.set(p.id,p),O(p.id)?E.has(p.id)?l(`${h}.id`,`duplicate node id: ${p.id}`):(E.add(p.id),typeof p.kind=="string"&&x.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&N.add(p.id)):l(`${h}.id`,"node.id must be a non-empty string"),$T.has(p.kind)||l(`${h}.kind`,"node.kind must be group, instance, transform, primitive, or image")}),g.materialAssets.forEach((p,A)=>{let h=`$.scene.materialAssets[${A}]`;if(!M(p)){l(h,"material asset must be an object");return}O(p.id)?I.has(p.id)?l(`${h}.id`,`duplicate material asset id: ${p.id}`):I.add(p.id):l(`${h}.id`,"material asset id must be a non-empty string"),p.name!=null&&!O(p.name)&&l(`${h}.name`,"material asset name must be a non-empty string when present"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"material asset guid must be a non-empty string when present"),Object.prototype.hasOwnProperty.call(p,"materialKind")&&l(`${h}.materialKind`,"materialKind is not supported; use shaderId"),Object.prototype.hasOwnProperty.call(p,"profile")&&l(`${h}.profile`,"profile is not supported; use properties");let R=Xn(p.shaderId),K=tx(p.shaderId);!R&&!K&&l(`${h}.shaderId`,"shaderId must be a built-in id or a namespaced lowercase project id"),p.definitionVersion!=null&&!rx(p.definitionVersion)?l(`${h}.definitionVersion`,"definitionVersion must be a positive integer when present"):K&&p.definitionVersion==null&&l(`${h}.definitionVersion`,"definitionVersion is required for project shader material assets"),R?tp(p.properties,`${h}.properties`,l):nx(p.properties,`${h}.properties`,l);for(let ne of Object.keys(p))["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(ne)||l(`${h}.${ne}`,`material asset field is not allowed: ${ne}`);ox(p.system,`${h}.system`,l),ax(p.origin,`${h}.origin`,l),ix(p,h,l)}),g.nodes.forEach((p,A)=>{if(!M(p))return;let h=`$.scene.nodes[${A}]`,R=Object.prototype.hasOwnProperty.call(p,"parentId");R&&!O(p.parentId)&&l(`${h}.parentId`,"parentId must be a non-empty string when present");let K=R?p.parentId:g.rootId;O(K)&&sx(K,g.rootId,E,`${h}.parentId`,l),O(p.id)&&cx(p.id,g.rootId,D,`${h}.parentId`,l),mx(p.source,`${h}.source`,l),np(p.transform,`${h}.transform`,l),Rx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&Xf(()=>Xo(p.shadow,`${h}.shadow`),`${h}.shadow`,l),Object.prototype.hasOwnProperty.call(p,"shadowMode")&&l(`${h}.shadowMode`,"deprecated field; use shadow.mode");let ne=null;p.kind==="instance"&&(M(p.instance)?b.has(p.instance.assetId)?S.get(p.instance.assetId)!=="glb"?l(`${h}.instance.assetId`,"instance.assetId must reference a glb asset"):ne=O(p.instance.assetId)?p.instance.assetId:null:l(`${h}.instance.assetId`,`assetId must reference scene.assets: ${p.instance.assetId}`):l(`${h}.instance`,"instance node must contain instance object")),p.kind==="primitive"&&(M(p.primitive)?LT.has(p.primitive.shape)||l(`${h}.primitive.shape`,"primitive.shape must be cube, sphere, plane, or capsule"):l(`${h}.primitive`,"primitive node must contain primitive object")),p.kind==="image"&&(M(p.image)?(b.has(p.image.assetId)?S.get(p.image.assetId)!=="texture"&&l(`${h}.image.assetId`,"image.assetId must reference a texture asset"):l(`${h}.image.assetId`,`assetId must reference scene.assets: ${p.image.assetId}`),M(p.image.size)?(Zf(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),Zf(p.image.size.height)||l(`${h}.image.size.height`,"image.size.height must be positive")):l(`${h}.image.size`,"image.size must be an object")):l(`${h}.image`,"image node must contain image object")),p.kind==="transform"&&p.transformType!=null&&!KT.has(p.transformType)&&l(`${h}.transformType`,"transformType must be plain, light, camera, or groundDecal"),p.kind==="transform"&&p.transformType==="groundDecal"?Tx(p.groundDecal,`${h}.groundDecal`,l):Object.prototype.hasOwnProperty.call(p,"groundDecal")&&l(`${h}.groundDecal`,"groundDecal is only allowed on transform nodes with transformType groundDecal"),p.kind==="transform"&&(hx(p.camera,`${h}.camera`,l),Ix(p.light,`${h}.light`,l,f)),Object.prototype.hasOwnProperty.call(p,"marker")&&(p.kind!=="transform"?l(`${h}.marker`,"marker is only allowed on transform nodes"):(fx(p.marker,`${h}.marker`,l),px(p.marker,p.id,E,N,`${h}.marker`,l))),(p.kind==="instance"||p.kind==="transform"||p.kind==="primitive"||p.kind==="image")&&ZT(p.overrides,`${h}.overrides`,I,ne?y.get(ne):void 0,m===3?"materialSlots":"metadata.materialSlots",l),u.has(p.id)&&Qf(p,h,l)}),g.materials.forEach((p,A)=>{let h=`$.scene.materials[${A}]`;if(!M(p)){l(h,"material must be an object");return}if(O(p.id)||l(`${h}.id`,"material.id must be a non-empty string"),p.scope!=null&&!VT.has(p.scope)&&l(`${h}.scope`,"material scope must be sharedAsset or nodeMaterial"),p.scope==="sharedAsset"&&(!O(p.assetId)||!b.has(p.assetId))&&!r&&l(`${h}.assetId`,`shared material assetId must reference scene.assets: ${p.assetId}`),p.scope==="nodeMaterial"){if((!O(p.nodeId)||!E.has(p.nodeId))&&!n)l(`${h}.nodeId`,`node material nodeId must reference scene.nodes: ${p.nodeId}`);else if(O(p.nodeId)&&E.has(p.nodeId)){let R=x.get(p.nodeId);R!=="instance"&&R!=="transform"&&R!=="primitive"&&l(`${h}.nodeId`,`node material nodeId must reference an instance, transform, or primitive node: ${p.nodeId}`)}}O(p.materialName)||l(`${h}.materialName`,"materialName must be a non-empty string"),M(p.properties)?ap(p.properties,`${h}.properties`,l):l(`${h}.properties`,"properties must be an object")}),c}function YT(e,t={}){let r=XT(e,t);return{ok:r.length===0,errors:r}}function Xf(e,t,r){try{e()}catch(n){let o=typeof n?.path=="string"?n.path:t,a=typeof n?.code=="string"?n.code:"schema.invalidValue";r(o,a)}}function ZT(e,t,r,n,o,a){if(e!=null){if(!M(e)){a(t,"overrides must be an object when present");return}ep(e.materialBinding,`${t}.materialBinding`,r,a),QT(e.materialSlotBindings,`${t}.materialSlotBindings`,"slotId",r,n,o,a),Object.prototype.hasOwnProperty.call(e,"childMaterialBindings")&&a(`${t}.childMaterialBindings`,"deprecated field; use materialSlotBindings keyed by slotId"),Object.prototype.hasOwnProperty.call(e,"childMaterials")&&a(`${t}.childMaterials`,"deprecated field; use materialSlotBindings keyed by slotId")}}function QT(e,t,r,n,o,a,i){if(e!=null){if(!M(e)){i(t,"material binding map must be an object when present");return}for(let[s,c]of Object.entries(e)){let d=`${t}.${s}`;O(s)||i(d,`${r} must be a non-empty string`),o?o.has(s)||i(d,`${r} must reference asset ${a}`):i(d,`${r} requires an instance asset with ${a}`),c==null?i(d,"material binding must be an object"):ep(c,d,n,i)}}}function ep(e,t,r,n){if(e!=null){if(!M(e)){n(t,"material binding must be an object when present");return}e.materialAssetId!=null&&(O(e.materialAssetId)?r.has(e.materialAssetId)||n(`${t}.materialAssetId`,`materialAssetId must reference scene.materialAssets: ${e.materialAssetId}`):n(`${t}.materialAssetId`,"materialAssetId must be non-empty when present")),e.override!=null&&tp(e.override,`${t}.override`,n)}}function tp(e,t,r){if(!M(e)){r(t,"material asset profile must be an object");return}if(e.lightingModel!=null&&e.lightingModel!=="lit"&&e.lightingModel!=="unlit"&&r(`${t}.lightingModel`,"lightingModel must be lit or unlit"),e.baseColor!=null)if(!M(e.baseColor))r(`${t}.baseColor`,"baseColor must be an object");else{Vi(e.baseColor.color,`${t}.baseColor.color`,r),rn(e.baseColor.texture,`${t}.baseColor.texture`,r);for(let n of["brightness","saturation","contrast","hue"])e.baseColor[n]!=null&&!qe(e.baseColor[n])&&r(`${t}.baseColor.${n}`,`${n} must be a finite number`)}for(let n of["metallic","roughness"])e[n]!=null&&!qe(e[n])&&r(`${t}.${n}`,`${n} must be a finite number`);e.normal!=null&&(M(e.normal)?(rn(e.normal.texture,`${t}.normal.texture`,r),e.normal.strength!=null&&!qe(e.normal.strength)&&r(`${t}.normal.strength`,"normal strength must be a finite number")):r(`${t}.normal`,"normal must be an object")),e.metallicRoughness!=null&&(M(e.metallicRoughness)?rn(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(rn(e.occlusion.texture,`${t}.occlusion.texture`,r),e.occlusion.strength!=null&&!qe(e.occlusion.strength)&&r(`${t}.occlusion.strength`,"occlusion strength must be a finite number")):r(`${t}.occlusion`,"occlusion must be an object")),e.emission!=null&&(M(e.emission)?(Vi(e.emission.color,`${t}.emission.color`,r),e.emission.intensity!=null&&!qe(e.emission.intensity)&&r(`${t}.emission.intensity`,"emission intensity must be a finite number"),rn(e.emission.texture,`${t}.emission.texture`,r),rn(e.emission.maskTexture,`${t}.emission.maskTexture`,r)):r(`${t}.emission`,"emission must be an object")),e.alpha!=null&&(M(e.alpha)?(e.alpha.mode!=null&&e.alpha.mode!=="opaque"&&e.alpha.mode!=="mask"&&e.alpha.mode!=="blend"&&r(`${t}.alpha.mode`,"alpha mode must be opaque, mask, or blend"),e.alpha.opacity!=null&&!qe(e.alpha.opacity)&&r(`${t}.alpha.opacity`,"alpha opacity must be a finite number"),e.alpha.cutoff!=null&&!qe(e.alpha.cutoff)&&r(`${t}.alpha.cutoff`,"alpha cutoff must be a finite number"),rn(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var ex=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function oa(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&ex.test(e)}function tx(e){return oa(e)?e:null}function rx(e){return Number.isSafeInteger(e)&&e>0}function nx(e,t,r){if(!M(e)){r(t,"project shader material properties must be an object");return}Od(e,t,r)}function Od(e,t,r){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||r(t,"project shader material numbers must be finite");return}if(Array.isArray(e)){e.forEach((n,o)=>Od(n,`${t}[${o}]`,r));return}if(M(e)){for(let[n,o]of Object.entries(e))Od(o,`${t}.${n}`,r);return}r(t,"project shader material properties must be JSON-safe")}}function rn(e,t,r){if(e!=null){if(!M(e)){r(t,"texture ref must be an object");return}e.url!=null&&!O(e.url)&&r(`${t}.url`,"texture url must be non-empty when present"),e.textureAssetId!=null&&!O(e.textureAssetId)&&r(`${t}.textureAssetId`,"textureAssetId must be non-empty when present")}}function ox(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset system must be an object");return}e.readonly!=null&&typeof e.readonly!="boolean"&&r(`${t}.readonly`,"readonly must be boolean"),e.preset!=null&&!UT.has(e.preset)&&r(`${t}.preset`,"preset must be default-pbr or default-standard")}}function ax(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset origin must be an object");return}e.type!=="imported"&&e.type!=="created"&&e.type!=="duplicated"&&e.type!=="preset"&&r(`${t}.type`,"origin type must be imported, created, duplicated, or preset"),e.sourceAssetGuid!=null&&!O(e.sourceAssetGuid)&&r(`${t}.sourceAssetGuid`,"sourceAssetGuid must be non-empty when present"),e.sourceAssetId!=null&&!O(e.sourceAssetId)&&r(`${t}.sourceAssetId`,"sourceAssetId must be non-empty when present"),e.sourceSlotId!=null&&!O(e.sourceSlotId)&&r(`${t}.sourceSlotId`,"sourceSlotId must be non-empty when present"),e.sourceMaterialIndex!=null&&!Number.isInteger(e.sourceMaterialIndex)&&r(`${t}.sourceMaterialIndex`,"sourceMaterialIndex must be an integer when present"),e.sourceMaterialName!=null&&!O(e.sourceMaterialName)&&r(`${t}.sourceMaterialName`,"sourceMaterialName must be non-empty when present"),e.sourceMaterialAssetId!=null&&!O(e.sourceMaterialAssetId)&&r(`${t}.sourceMaterialAssetId`,"sourceMaterialAssetId must be non-empty when present")}}function ix(e,t,r){let n=M(e.system)?e.system.preset:void 0;n==="default-pbr"&&e.shaderId!=="fps.builtin.pbr"&&r(`${t}.shaderId`,"default-pbr material assets must use shaderId fps.builtin.pbr"),n==="default-standard"&&e.shaderId!=="fps.builtin.standard"&&r(`${t}.shaderId`,"default-standard material assets must use shaderId fps.builtin.standard")}function sx(e,t,r,n,o){if(e===t){ra.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(ra.has("sceneNode")&&r.has(e))return;let a=ra.has("root")&&ra.has("sceneNode")?"root or scene node":ra.has("sceneNode")?"scene node":"root";o(n,`parentId must point to ${a}: ${e}`)}function cx(e,t,r,n,o){if(!O(t))return;let a=new Set([e]),i=O(r.get(e)?.parentId)?r.get(e)?.parentId:t;for(;O(i)&&i!==t;){if(a.has(i)){o(n,`parentId creates a node cycle involving ${e}`);return}a.add(i);let s=r.get(i);if(!s)return;i=O(s.parentId)?s.parentId:t}}function dx(e,t,r){for(let n of Object.keys(e))qT.has(n)||r(`${t}.${n}`,`runtime schema v3 material slot field is not allowed: ${n}`);if(e.label!=null&&!O(e.label)&&r(`${t}.label`,"label must be a non-empty string when present"),!Array.isArray(e.sourceSurfaces)||e.sourceSurfaces.length===0){r(`${t}.sourceSurfaces`,"sourceSurfaces must be a non-empty array");return}for(let n=0;n<e.sourceSurfaces.length;n+=1){let o=`${t}.sourceSurfaces[${n}]`,a=e.sourceSurfaces[n];if(!M(a)){r(o,"source surface must be an object");continue}for(let i of Object.keys(a))JT.has(i)||r(`${o}.${i}`,`runtime schema v3 material slot source surface field is not allowed: ${i}`);O(a.ownerNodePath)||r(`${o}.ownerNodePath`,"ownerNodePath must be a non-empty string");for(let i of["meshIndex","primitiveIndex"])(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer`);for(let i of["nodeIndex","sourceMaterialIndex"])a[i]!=null&&(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer when present`);a.nodeIndexPath!=null&&(!Array.isArray(a.nodeIndexPath)||a.nodeIndexPath.some(i=>!Number.isInteger(i)||i<0))&&r(`${o}.nodeIndexPath`,"nodeIndexPath must contain non-negative integers"),O(a.sourceMeshName)||r(`${o}.sourceMeshName`,"sourceMeshName is required")}}function lx(e,t,r){if(e!=null){if(!M(e)){r(t,"defaults must be an object");return}if(np(e.transform,`${t}.transform`,r),Yf(e.outline,`${t}.outline`,r),e.childOutlines!=null)if(!M(e.childOutlines))r(`${t}.childOutlines`,"childOutlines must be an object");else for(let[n,o]of Object.entries(e.childOutlines))Yf(o,`${t}.childOutlines.${n}`,r)}}function ux(e,t,r){if(e!=null){if(!M(e)){r(t,"generatedFrom must be an object when present");return}rp(e,t,r),O(e.compilerId)||r(`${t}.compilerId`,"compilerId must be a non-empty string"),O(e.compilerVersion)||r(`${t}.compilerVersion`,"compilerVersion must be a non-empty string"),O(e.compiledAt)||r(`${t}.compiledAt`,"compiledAt must be a non-empty string")}}function mx(e,t,r){if(e!=null){if(!M(e)){r(t,"source must be an object when present");return}rp(e,t,r),e.objectGuid!=null&&!O(e.objectGuid)&&r(`${t}.objectGuid`,"objectGuid must be a non-empty string when present"),e.objectId!=null&&!O(e.objectId)&&r(`${t}.objectId`,"objectId must be a non-empty string when present"),e.component!=null&&!O(e.component)&&r(`${t}.component`,"component must be a non-empty string when present"),e.propertyPath!=null&&!O(e.propertyPath)&&r(`${t}.propertyPath`,"propertyPath must be a non-empty string when present")}}function rp(e,t,r){O(e.sourceId)||r(`${t}.sourceId`,"sourceId must be a non-empty string"),O(e.sourceType)||r(`${t}.sourceType`,"sourceType must be a non-empty string"),e.revision!=null&&(typeof e.revision!="number"||!Number.isFinite(e.revision))&&r(`${t}.revision`,"revision must be a finite number when present")}function Ui(e,t){let r=YT(e,t);if(r.ok)return;let n=new Error(`scene_json_schema_failed:
2
+ ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_schema_failed",diagnostics:r.errors}),n}function M(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function np(e,t,r){if(e!=null){if(!M(e)){r(t,"transform must be an object");return}Ft(e.position,`${t}.position`,r),Ft(e.rotation,`${t}.rotation`,r),Ft(e.rotationDeg,`${t}.rotationDeg`,r),typeof e.scale=="number"?Number.isFinite(e.scale)||r(`${t}.scale`,"scale number must be finite"):Ft(e.scale,`${t}.scale`,r)}}function fx(e,t,r){if(!M(e)){r(t,"marker must be an object");return}kr(e,["schemaVersion","label","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t,r),e.schemaVersion!==1&&r(`${t}.schemaVersion`,"marker.schemaVersion must be 1"),O(e.label)||r(`${t}.label`,"marker.label must be a non-empty string"),O(e.type)||r(`${t}.type`,"marker.type must be a non-empty string"),e.kind!=null&&!O(e.kind)&&r(`${t}.kind`,"marker.kind must be a non-empty string when present"),e.tags!=null&&(Array.isArray(e.tags)?e.tags.forEach((n,o)=>{typeof n!="string"&&r(`${t}.tags[${o}]`,"marker tag must be a string")}):r(`${t}.tags`,"marker.tags must be an array when present")),e.note!=null&&typeof e.note!="string"&&r(`${t}.note`,"marker.note must be a string when present"),e.color!=null&&Sx(e.color,`${t}.color`,r),e.target!=null&&Rd(e.target,`${t}.target`,r),e.semanticFrame!=null&&gx(e.semanticFrame,`${t}.semanticFrame`,r),bx(e.geometry,`${t}.geometry`,r),e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker.metadata must be an object when present")}function px(e,t,r,n,o,a){if(!M(e))return;let i=[];e.target!=null&&i.push({value:e.target,path:`${o}.target`}),M(e.geometry)&&e.geometry.target!=null&&i.push({value:e.geometry.target,path:`${o}.geometry.target`});for(let s of i)M(s.value)&&(s.value.kind!=="scene-object"&&s.value.kind!=="marker"&&a(`${s.path}.kind`,"runtime marker target kind must be scene-object or marker"),O(s.value.id)&&(s.value.id===t?a(`${s.path}.id`,"runtime marker target must not reference its marker node"):r.has(s.value.id)?s.value.kind==="marker"&&!n.has(s.value.id)?a(`${s.path}.id`,`runtime marker target must reference a marker node: ${s.value.id}`):s.value.kind==="scene-object"&&n.has(s.value.id)&&a(`${s.path}.id`,`runtime scene-object target must not reference a marker node: ${s.value.id}`):a(`${s.path}.id`,`runtime marker target must reference scene.nodes: ${s.value.id}`)))}function Rd(e,t,r){if(!M(e)){r(t,"marker target must be an object");return}kr(e,["kind","id","label","path","metadata"],t,r),O(e.kind)||r(`${t}.kind`,"marker target kind must be a non-empty string"),O(e.id)||r(`${t}.id`,"marker target id must be a non-empty string");for(let n of["label","path"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker target ${n} must be a string when present`);e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker target metadata must be an object when present")}function gx(e,t,r){if(!M(e)){r(t,"marker semanticFrame must be an object");return}kr(e,["origin","forward","right","up","label","description"],t,r),M(e.origin)?Ft(e.origin,`${t}.origin`,r):r(`${t}.origin`,"marker semanticFrame.origin must be a vector object");for(let n of["forward","right","up"])e[n]!=null&&Ft(e[n],`${t}.${n}`,r);for(let n of["label","description"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker semanticFrame ${n} must be a string when present`)}function bx(e,t,r){if(!M(e)){r(t,"marker.geometry must be an object");return}if(e.kind==="box"){kr(e,["kind"],t,r);return}if(e.kind==="point"){kr(e,["kind","coordinateSpace","position","offset","target"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&e.coordinateSpace!=="local"&&r(`${t}.coordinateSpace`,"point marker coordinateSpace must be world or local"),e.position!=null&&Ft(e.position,`${t}.position`,r),e.offset!=null&&Ft(e.offset,`${t}.offset`,r),e.target!=null&&Rd(e.target,`${t}.target`,r);return}if(e.kind==="object-bounds"){kr(e,["kind","target"],t,r),Rd(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){kr(e,["kind","coordinateSpace","vertices","faces"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&r(`${t}.coordinateSpace`,"polyhedron marker coordinateSpace must be world"),Array.isArray(e.vertices)?e.vertices.forEach((n,o)=>{let a=`${t}.vertices[${o}]`;M(n)?Ft(n,a,r):r(a,"polyhedron marker vertex must be a vector object")}):r(`${t}.vertices`,"polyhedron marker vertices must be an array"),e.faces!=null&&(Array.isArray(e.faces)?e.faces.forEach((n,o)=>{Array.isArray(n)?n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&r(`${t}.faces[${o}][${i}]`,"polyhedron marker index must be a non-negative integer")}):r(`${t}.faces[${o}]`,"polyhedron marker face must be an array")}):r(`${t}.faces`,"polyhedron marker faces must be an array when present"));return}r(`${t}.kind`,"marker.geometry.kind must be box, point, object-bounds, or polyhedron")}function Sx(e,t,r){if(!M(e)){r(t,"marker color must be an object");return}kr(e,["r","g","b"],t,r);for(let n of["r","g","b"])op(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function kr(e,t,r,n){let o=new Set(t);for(let a of Object.keys(e))o.has(a)||n(`${r}.${a}`,`field is not allowed: ${a}`)}function Ft(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y","z"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function yx(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function qe(e){return typeof e=="number"&&Number.isFinite(e)}function nn(e){return qe(e)&&e>0}function op(e){return qe(e)&&e>=0&&e<=1}function Vi(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"color component must be a finite number")}}function hx(e,t,r){if(e!=null){if(!M(e)){r(t,"camera must be an object");return}e.projection!=null&&e.projection!=="orthographic"&&e.projection!=="perspective"&&r(`${t}.projection`,"camera projection must be orthographic or perspective");for(let n of["alpha","beta"])e[n]!=null&&!qe(e[n])&&r(`${t}.${n}`,"camera property must be a finite number when present");for(let n of["radius","orthoSize"])e[n]!=null&&!nn(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!nn(e.fov)&&r(`${t}.fov`,"camera fov must be a positive finite number"),Ft(e.targetOffset,`${t}.targetOffset`,r),yx(e.targetScreenOffset,`${t}.targetScreenOffset`,r);for(let n of["minZ","maxZ","lowerRadiusLimit","upperRadiusLimit"])e[n]!=null&&!nn(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number");for(let n of["lowerBetaLimit","upperBetaLimit"])e[n]!=null&&!qe(e[n])&&r(`${t}.${n}`,"camera property must be a finite number");e.inertia!=null&&!op(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),nn(e.minZ)&&nn(e.maxZ)&&e.maxZ<=e.minZ&&r(`${t}.maxZ`,"camera maxZ must be greater than minZ"),qe(e.lowerBetaLimit)&&qe(e.upperBetaLimit)&&e.upperBetaLimit<e.lowerBetaLimit&&r(`${t}.upperBetaLimit`,"camera upperBetaLimit must be greater than or equal to lowerBetaLimit"),nn(e.lowerRadiusLimit)&&nn(e.upperRadiusLimit)&&e.upperRadiusLimit<e.lowerRadiusLimit&&r(`${t}.upperRadiusLimit`,"camera upperRadiusLimit must be greater than or equal to lowerRadiusLimit")}}function Ex(e){let t=e.meta?.generatedFrom;return M(t)&&t.compilerId===NT&&t.compilerVersion===FT}function Ix(e,t,r,n=!1){if(e==null)return;let o=n&&M(e)&&!Object.prototype.hasOwnProperty.call(e,"schemaVersion")?Px(e,t):e;try{Wn(o,t)}catch(a){let i=a;r(typeof i.path=="string"?i.path:t,typeof i.reason=="string"?i.reason:typeof i.message=="string"?i.message:"light does not satisfy the Engine Runtime Light contract")}}function Px(e,t){let r={...e,schemaVersion:1};if(e.type!=="directional"||!M(e.direction))return r;let{x:n,y:o,z:a}=e.direction;if(![n,o,a].every(s=>typeof s=="number"&&Number.isFinite(s)))return r;let i=Math.hypot(n,o,a);return i<=0||Math.abs(i-1)>_T?r:{...r,direction:ta(e.direction,`${t}.direction`)}}function Yf(e,t,r){if(e!=null){if(!M(e)){r(t,"outline must be an object");return}e.renderOutline!=null&&typeof e.renderOutline!="boolean"&&r(`${t}.renderOutline`,"renderOutline must be boolean"),e.outlineWidth!=null&&(typeof e.outlineWidth!="number"||!Number.isFinite(e.outlineWidth))&&r(`${t}.outlineWidth`,"outlineWidth must be a finite number"),Vi(e.outlineColor,`${t}.outlineColor`,r)}}function Tx(e,t,r){if(e==null){r(t,"groundDecal is required when transformType is groundDecal");return}if(!M(e)){r(t,"groundDecal must be an object");return}xx(e,t,r)}function xx(e,t,r){if(O(e.uiKind)||r(`${t}.uiKind`,"groundDecal UI kind must be non-empty"),!M(e.size))r(`${t}.size`,"groundDecal.size must be an object");else for(let n of["width","depth"])(typeof e.size[n]!="number"||!Number.isFinite(e.size[n])||e.size[n]<=0)&&r(`${t}.size.${n}`,"groundDecal size must be a positive finite number");if(e.aspectSourceLayerId!=null&&!O(e.aspectSourceLayerId)&&r(`${t}.aspectSourceLayerId`,"aspectSourceLayerId must be non-empty when present"),e.lockAspectToBorder!=null&&typeof e.lockAspectToBorder!="boolean"&&r(`${t}.lockAspectToBorder`,"lockAspectToBorder must be boolean when present"),e.editorPreviewActive!=null&&r(`${t}.editorPreviewActive`,"editorPreviewActive is editor-only and must not appear in runtime scene data"),Ax(e.mask,`${t}.mask`,r),Dx(e.rendering,`${t}.rendering`,r),!Array.isArray(e.layers)){r(`${t}.layers`,"groundDecal UI layers must be an array");return}e.layers.forEach((n,o)=>Mx(n,`${t}.layers[${o}]`,r)),wx(e.layers,`${t}.layers`,r)}function Ax(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI mask must be an object");return}e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"mask.enabled must be boolean"),e.source!=null&&e.source!=="roundedRect"&&e.source!=="borderAlpha"&&e.source!=="texture"&&r(`${t}.source`,"mask.source must be roundedRect, borderAlpha, or texture"),e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"mask.textureId must be non-empty when present");for(let n of["cornerRadius","padding"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)&&r(`${t}.${n}`,`${n} must be a non-negative finite number`)}}function Dx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI rendering must be an object");return}for(let n of["textureWidth","textureHeight"])e[n]!=null&&(!Number.isInteger(e[n])||e[n]<=0)&&r(`${t}.${n}`,`${n} must be a positive integer`);for(let n of["alphaIndex","diffuseTextureLevel","emissiveTextureLevel"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`${n} must be a finite number`)}}function Mx(e,t,r){if(!M(e)){r(t,"groundDecal UI layer must be an object");return}O(e.id)||r(`${t}.id`,"layer.id must be non-empty"),O(e.role)||r(`${t}.role`,"layer.role must be non-empty"),e.editorPreviewPercent!=null&&r(`${t}.editorPreviewPercent`,"editorPreviewPercent is editor-only and must not appear in runtime scene data"),e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"layer.enabled must be boolean"),(typeof e.zOrder!="number"||!Number.isFinite(e.zOrder))&&r(`${t}.zOrder`,"layer.zOrder must be a finite number"),e.opacity!=null&&(typeof e.opacity!="number"||!Number.isFinite(e.opacity))&&r(`${t}.opacity`,"layer.opacity must be finite"),e.rotationDeg!=null&&(typeof e.rotationDeg!="number"||!Number.isFinite(e.rotationDeg)||e.rotationDeg<=-180||e.rotationDeg>180)&&r(`${t}.rotationDeg`,"layer.rotationDeg must be in the range (-180, 180]"),kx(e.rect,`${t}.rect`,r),e.kind==="texture"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture layer imageFit must be contain or stretch"),Zn(e.tint,`${t}.tint`,r)):e.kind==="textureProgress"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture progress layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture progress layer imageFit must be contain or stretch"),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"texture progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"texture progress direction is invalid"),Zn(e.tint,`${t}.tint`,r)):e.kind==="color"?Zn(e.color,`${t}.color`,r):e.kind==="progress"?((typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"progress direction is invalid"),Zn(e.color,`${t}.color`,r)):e.kind==="text"?Ox(e.text,`${t}.text`,r):r(`${t}.kind`,"layer.kind must be texture, textureProgress, color, progress, or text")}function wx(e,t,r){let n=new Map;e.forEach((o,a)=>{if(!M(o)||!O(o.id))return;let i=n.get(o.id);if(i!=null){r(`${t}[${a}].id`,`layer.id must be unique; duplicate of layers[${i}]`);return}n.set(o.id,a)})}function kx(e,t,r){if(!M(e)){r(t,"layer.rect must be an object");return}for(let n of["x","z","width","depth"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`rect.${n} must be a finite number`);for(let n of["width","depth"])typeof e[n]=="number"&&e[n]<=0&&r(`${t}.${n}`,`rect.${n} must be positive`)}function Ox(e,t,r){if(!M(e)){r(t,"text layer text must be an object");return}typeof e.value!="string"&&r(`${t}.value`,"text.value must be a string"),e.fontFamily!=null&&typeof e.fontFamily!="string"&&r(`${t}.fontFamily`,"fontFamily must be a string"),e.fontSize!=null&&(typeof e.fontSize!="number"||!Number.isFinite(e.fontSize)||e.fontSize<=0)&&r(`${t}.fontSize`,"fontSize must be a positive finite number"),e.fontWeight!=null&&typeof e.fontWeight!="string"&&r(`${t}.fontWeight`,"fontWeight must be a string"),Zn(e.color,`${t}.color`,r),Zn(e.strokeColor,`${t}.strokeColor`,r),e.strokeWidth!=null&&(typeof e.strokeWidth!="number"||!Number.isFinite(e.strokeWidth)||e.strokeWidth<0)&&r(`${t}.strokeWidth`,"strokeWidth must be a non-negative finite number")}function Zn(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`color.${n} must be finite`);e.a!=null&&(typeof e.a!="number"||!Number.isFinite(e.a))&&r(`${t}.a`,"color.a must be finite")}}function Rx(e,t,r){if(e!=null){if(!M(e)){r(t,"rendering must be an object");return}e.renderingGroupId!=null&&e.renderingGroupId!==0&&e.renderingGroupId!==1&&e.renderingGroupId!==2&&e.renderingGroupId!==3&&r(`${t}.renderingGroupId`,"renderingGroupId must be 0, 1, 2, or 3"),e.alphaIndex!=null&&(typeof e.alphaIndex!="number"||!Number.isFinite(e.alphaIndex))&&r(`${t}.alphaIndex`,"alphaIndex must be a finite number")}}function Zf(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ap(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;["albedoColor","diffuseColor","emissiveColor","outlineColor"].includes(n)&&Vi(o,a,r),["metallic","roughness","contrast","brightness","saturation","hue","colorDensity","alpha","alphaCutOff","transparencyMode"].includes(n)&&(typeof o!="number"||!Number.isFinite(o))&&r(a,`${n} must be a finite number`),n==="backFaceCulling"&&typeof o!="boolean"&&r(a,"backFaceCulling must be boolean"),["albedoTexture","normalTexture","metallicTexture"].includes(n)&&(M(o)?o.url!=null&&!O(o.url)&&r(`${a}.url`,"texture url must be non-empty when present"):r(a,`${n} must be an object`)),["pbr","standard"].includes(n)&&(M(o)?ap(o,a,r):r(a,`${n} must be an object`))}}function Qf(e,t,r){let n=JSON.stringify(e),o=HT.filter(a=>n.includes(a));o.length>0&&r(t,`contains runtime-only asset fields: ${o.join(", ")}`)}function Cx(e,t,r){let n=ip(e)??512,o=ip(t)??512;if(!Number.isFinite(r)||r<=0)return{width:n,height:o};let a=n,i=Math.max(1,Math.round(a/r));return i>o&&(i=o,a=Math.max(1,Math.round(i*r))),{width:a,height:i}}function Ki(e){let t=e.rendering?.textureWidth??512,r=e.rendering?.textureHeight??512,n=e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:t/r;return Cx(t,r,n)}function ip(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function sp(e,t){let r=vd(t.ids);if(r.length===0)return J("empty-selection");for(let s of r)if(!sr(e,s))return J("missing-node");let n=ht(e,t.ids);if(n.length===0)return J("empty-selection");for(let s of n){let c=sr(e,s);if(!c)return J("missing-node");if(!up(c))return J(c.protected?"node-protected":c.locked?"node-locked":"node-readonly")}if(t.placement==="root")return t.parentId!=null||t.beforeId!=null||t.afterId!=null?J("invalid-root-anchors"):Hi();let o=sr(e,t.targetId);if(!o)return J("missing-target-node");if(n.includes(o.id))return J("cannot-parent-to-self");if(n.some(s=>dp(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!lp(o))return J("target-cannot-have-children");if(t.parentId!=null&&t.parentId!==o.id)return J("invalid-parent-anchor");let s=Cd(e,o.id).filter(c=>!n.includes(c));return t.beforeId&&!s.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!s.includes(t.afterId)?J("invalid-after-anchor"):Hi()}if(o.locked&&!o.protected)return J("target-node-locked");if(o.protected)return J("cannot-reorder-root");let a=sr(e,o.parentId);if(a?.locked&&!a.protected)return J("target-parent-locked");if((t.parentId??null)!==(o.parentId??null))return J("invalid-parent-anchor");let i=Cd(e,o.parentId??null).filter(s=>!n.includes(s));return t.beforeId&&!i.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!i.includes(t.afterId)?J("invalid-after-anchor"):t.placement==="before"&&t.beforeId!==o.id?J("invalid-before-anchor"):t.placement==="after"&&t.afterId!==o.id?J("invalid-after-anchor"):Hi()}function cp(e,t){let r=vd(t.ids);if(r.length===0)return J("empty-selection");for(let i of r)if(!sr(e,i))return J("missing-node");let n=ht(e,t.ids);if(n.length===0)return J("empty-selection");if(n.length<2)return J("selection-too-small");for(let i of n){let s=sr(e,i);if(!s)return J("missing-node");if(!up(s))return J(s.protected?"node-protected":s.locked?"node-locked":"node-readonly")}let o=sr(e,t.parentId);if(t.parentId&&!o)return J("missing-parent-node");if(o&&!lp(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||dp(e,o.id,i)))return J("cannot-parent-to-descendant");let a=Cd(e,t.parentId??null).filter(i=>!n.includes(i));if(t.insertBeforeId){let i=sr(e,t.insertBeforeId);if(!a.includes(t.insertBeforeId)||i?.protected)return J("invalid-before-anchor")}return Hi()}function sr(e,t){return t?e.find(r=>r.id===t)??null:null}function vd(e){let t=[],r=new Set;for(let n of e)!n||r.has(n)||(r.add(n),t.push(n));return t}function ht(e,t){let r=vd(t).filter(o=>!!sr(e,o)),n=new Set(r);return r.filter(o=>!vx(e,o).some(a=>n.has(a)))}function Cd(e,t){return e.filter(r=>(r.parentId??null)===(t??null)).map(r=>r.id)}function dp(e,t,r){let n=new Map(e.map(i=>[i.id,i])),o=n.get(t)??null,a=new Set;for(;o?.parentId;){if(o.parentId===r)return!0;if(a.has(o.parentId))return!1;a.add(o.parentId),o=n.get(o.parentId)??null}return!1}function lp(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function up(e){return!!e&&e.protected!==!0&&e.locked!==!0&&e.draggable!==!1}function vx(e,t){let r=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,a=r.get(t)??null;for(;a?.parentId&&!o.has(a.parentId);)o.add(a.parentId),n.push(a.parentId),a=r.get(a.parentId)??null;return n}function Hi(){return{ok:!0}}function J(e){return{ok:!1,reason:e}}var Et=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),on={kind:"texture"},mp={kind:"color"},Gx={kind:"enum",values:["lit","unlit"]},jx={kind:"enum",values:["opaque","mask","blend"]},gp={lightingModel:Gx,baseColor:{kind:"object",properties:{color:mp,texture:on,brightness:Et(0),saturation:Et(0),contrast:Et(0),hue:Et(-180,180)}},normal:{kind:"object",properties:{texture:on,strength:Et(0)}},emission:{kind:"object",properties:{color:mp,intensity:Et(0),texture:on,maskTexture:on}},alpha:{kind:"object",properties:{mode:jx,opacity:Et(0,1),cutoff:Et(0,1),texture:on}}},Nx={kind:"object",properties:{...gp,metallic:Et(0,1),roughness:Et(0,1),metallicRoughness:{kind:"object",properties:{texture:on}},occlusion:{kind:"object",properties:{texture:on,strength:Et(0)}}}},Fx={kind:"object",properties:gp},_x={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},$x={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},fp=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],an={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},bp=[eo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),eo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),to("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),It("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Qn("properties.baseColor.texture.textureAssetId","baseTexture")]}),It("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Qn("properties.baseColor.texture.textureAssetId","baseTexture")]}),It("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Qn("properties.baseColor.texture.textureAssetId","baseTexture")]}),It("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Qn("properties.baseColor.texture.textureAssetId","baseTexture")]}),to("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[an]),It("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[an,Qn("properties.normal.texture.textureAssetId","normalTexture")]}),eo("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),It("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),to("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),eo("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),It("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),It("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),to("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Lx=[...bp,It("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[an]}),It("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[an]}),to("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[an]),to("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[an]),It("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[an,Qn("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],zx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:Nx,defaultProperties:_x,inspector:{sections:fp,fields:Lx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Fx,defaultProperties:$x,inspector:{sections:fp,fields:bp}}],Or=Bx(zx);function Bx(e){let t=new Map;for(let n of e){Ux(n,t);let o=Kx(n);t.set(n.shaderId,hp(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function jd(e,t=Or){return t.get(e)}function De(e){return jd(e)}function Vx(e,t,r=Or){let n=Fd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function ro(e,t,r=Or){let n=jd(e,r);if(!n)return null;let o=Vx(e,t,r),i=(o?.schemaPath??Fd(t)).replace(/^properties\./,"").split(".").filter(Boolean);if(i.length===0)return null;let s=n.propertiesSchema;for(let c=0;c<i.length;c+=1){let d=i[c];if(s.kind==="texture"&&c===i.length-1&&(d==="url"||d==="textureAssetId"))return{kind:"string",nullable:!0};if(s.kind!=="object")return null;let u=s.properties[d];if(!u)return null;s=u}return o?.control==="texture"&&s.kind==="texture"?{kind:"string",nullable:!0}:s}function Nd(e){let t=De(e);if(!t)throw new Error(`Unknown built-in material shader: ${e}`);return structuredClone(t.defaultProperties)}function no(e,t,r="properties",n=Or){let o=jd(e,n);if(!o)return[{path:"shaderId",message:`Unknown material shader: ${String(e)}`}];let a=[];return _d(o.propertiesSchema,t,r,a),a}function eo(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function It(e,t,r,n,o,a,i={}){return eo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function to(e,t,r,n,o,a,i,s){return eo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Qn(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Ux(e,t){if(!Xn(e.shaderId)&&!oa(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Wx(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);Sp(e.shaderId,e.propertiesSchema,"properties");let r=[];if(_d(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);Hx(e,a),o.add(a.path)}}function Kx(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=yp(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Hx(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=yp(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function Sp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))Sp(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function Wx(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function Fd(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function yp(e,t){let r=Fd(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function _d(e,t,r,n){if(e.kind==="object"){if(!Gd(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&_d(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];pp(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){pp(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!Gd(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function pp(e,t,r,n,o){if(!Gd(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function hp(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))hp(t)}return e}function Gd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Rr(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,Jx(n));for(let n of aa(e)){let o=r.get(n.type)??null;r.set(n.type,Xx(o,n))}return[...r.values()]}function Ld(e){return structuredClone(e)}function Jx(e){return{...Ld(e),metadata:{...e.metadata??{},builtIn:!0}}}function Xx(e,t){let r=e??null;return{...r??{},...Ld(t),type:t.type,label:t.label||r?.label||t.type,metadata:{...r?.metadata??{},...t.metadata??{},builtIn:r?.metadata?.builtIn===!0}}}function Yx(e,t,r={}){if(!Vd(t)||Ud(t.type,r))return e;let n=aa(e);return n.some(o=>o.type===t.type)?e:Bd(e,[...n,zd(t,!1)])}function Zx(e,t,r,n={}){let o=t.trim();if(!o)return e;let a=Ud(o,n),i=aa(e),s=i.find(u=>u.type===o)??null;if(!a&&!s)return e;let c=s??a;if(!c)return e;let d=zd({...c,...r,type:o,label:typeof r.label=="string"&&r.label.trim()?r.label.trim():c.label||o},!!a);return Bd(e,[...i.filter(u=>u.type!==o),d])}function Qx(e,t,r={}){let n=t.trim();if(!n||Tp(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=aa(e),a=o.filter(i=>i.type!==n);return a.length===o.length?e:Bd(e,a)}function zd(e,t){return{type:e.type.trim(),label:e.label.trim()||e.type.trim(),...e.kind?{kind:e.kind}:{},...e.description!==void 0?{description:e.description}:{},...e.defaultForCreation!==void 0?{defaultForCreation:e.defaultForCreation}:{},...e.defaultGeometryKind!==void 0?{defaultGeometryKind:e.defaultGeometryKind}:{},...e.allowedGeometryKinds?{allowedGeometryKinds:[...e.allowedGeometryKinds]}:{},...e.defaultTags?{defaultTags:[...e.defaultTags]}:{},metadata:{...e.metadata??{},builtIn:!1,...t?{overridesBuiltIn:!0}:{}}}}function aa(e){let t=e?.metadata?.markerTypes;return Array.isArray(t)?t.map(eA).filter(r=>!!r):[]}function Bd(e,t){let r=e.metadata?structuredClone(e.metadata):{};return t.length===0?delete r.markerTypes:r.markerTypes=t.map(Ld),{...e,metadata:Object.keys(r).length>0?r:void 0}}function eA(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.type!="string"||!t.type.trim()||typeof t.label!="string"||!t.label.trim())return null;let r=zd({type:t.type.trim(),label:t.label.trim(),...typeof t.kind=="string"&&t.kind?{kind:t.kind}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.defaultForCreation=="boolean"?{defaultForCreation:t.defaultForCreation}:{},...t.defaultGeometryKind==="box"||t.defaultGeometryKind==="cylinder"?{defaultGeometryKind:t.defaultGeometryKind}:{},...Array.isArray(t.allowedGeometryKinds)?{allowedGeometryKinds:t.allowedGeometryKinds.filter(n=>n==="box"||n==="cylinder")}:{},...Array.isArray(t.defaultTags)?{defaultTags:t.defaultTags.filter(n=>typeof n=="string")}:{},...t.metadata&&typeof t.metadata=="object"?{metadata:t.metadata}:{}},t.metadata?.overridesBuiltIn===!0);return Vd(r)?r:null}function Vd(e){return!(!e.type.trim()||!e.label.trim()||(e.defaultGeometryKind!==void 0||e.allowedGeometryKinds!==void 0)&&e.kind!=="region"||e.allowedGeometryKinds&&e.allowedGeometryKinds.length===0||e.defaultGeometryKind&&e.allowedGeometryKinds&&!e.allowedGeometryKinds.includes(e.defaultGeometryKind))}function Ud(e,t={}){let r=e.trim();return t.builtInMarkerTypes?.find(n=>n.type===r)??null}function Tp(e,t={}){return!!Ud(e,t)}function cr(e){let{spatial:t,...r}=structuredClone(e);return r}function Wi(e){return structuredClone(e)}function xp(e,t){return{...Wi(e),from:Ep(e.from,t),to:Ep(e.to,t)}}function Ap(e,t){return{...cr(e),...e.target?{target:$d(e.target,t)}:{},geometry:tA(e.geometry,t)}}function tA(e,t){switch(e.kind){case"point":return{...structuredClone(e),...e.target?{target:$d(e.target,t)}:{}};case"object-bounds":return{...structuredClone(e),target:$d(e.target,t)};case"box":case"cylinder":case"polyhedron":return structuredClone(e)}}function $d(e,t){return e.kind!=="marker"?structuredClone(e):{...structuredClone(e),id:t.get(e.id)??e.id}}function Ep(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function Dp(e,t){let r=new Set([t]),n=!0;for(;n;){n=!1;for(let o of e.scene.gameObjects)!o.parentId||!r.has(o.parentId)||r.has(o.id)||(r.add(o.id),n=!0)}return r}function Kd(e,t){return(e.kind==="marker"||e.kind==="scene-object")&&t.has(e.id)}function ia(e,t){return!e||e.kind!=="scene-object"||t.has(e.id)}function Hd(e,t,r){return e.kind==="marker"?r.has(e.id):e.kind==="scene-object"?t.has(e.id):!0}function Ip(e,t){return e.kind==="marker"&&e.id===t}function dr(e){if(!e)return{schemaVersion:1,markers:[],relations:[]};let t=structuredClone(e),{metadata:r,...n}=t;return{...n,schemaVersion:1,markers:e.markers.map(cr),relations:e.relations.map(Wi),...r?{metadata:structuredClone(r)}:{}}}function Wd(e,t){return{...e,scene:{...e.scene,markerGraph:t}}}function rA(e,t){let r=cr(t),n=e.markers.some(o=>o.id===r.id);return{...e,markers:n?e.markers.map(o=>o.id===r.id?r:o):[...e.markers,r]}}function nA(e,t,r){let n=!1,o=e.markers.map(a=>a.id!==t?a:(n=!0,cr({...a,...r,id:a.id})));return n?{...e,markers:o}:e}function oA(e,t){return{...e,markers:e.markers.filter(r=>r.id!==t),relations:e.relations.filter(r=>!Ip(r.from,t)&&!Ip(r.to,t))}}function Pp(e,t){let r=Wi(t),n=e.relations.some(o=>o.id===r.id);return{...e,relations:n?e.relations.map(o=>o.id===r.id?r:o):[...e.relations,r]}}function aA(e,t){let r=!1,n=e.relations.map(o=>o.id!==t?o:(r=!0,{...Wi(o),from:{...o.to},to:{...o.from}}));return r?{...e,relations:n}:e}function Mp(e,t,r={}){switch(t.type){case"marker.create-box":return rA(e,t.marker);case"marker.update":return nA(e,t.markerId,t.patch);case"marker.delete":return oA(e,t.markerId);case"relation.create":return Pp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>Pp(n,o),e);case"relation.delete":return{...e,relations:e.relations.filter(n=>n.id!==t.relationId)};case"relation.delete-many":{let n=new Set(t.relationIds);return{...e,relations:e.relations.filter(o=>!n.has(o.id))}}case"relation.reverse":return aA(e,t.relationId);case"marker.sync-from-scene":return e;case"marker-type.create":return Yx(e,t.definition,r);case"marker-type.update":return Zx(e,t.typeId,t.patch,r);case"marker-type.delete":return Qx(e,t.typeId,r)}}function wp(e,t,r={}){if(t.type!=="marker.create-box")return t;let n=cr(t.marker),o=new Set(e.scene.gameObjects.map(i=>i.id)),a=new Set(e.scene.gameObjects.map(i=>(i.name??"").trim()).filter(Boolean));return o.has(n.id)&&(n.id=iA(n.id,o,r.sanitizeMarkerGameObjectId)),(!n.label.trim()||a.has(n.label.trim()))&&(n.label=cA(n.label||n.id,a)),{...t,marker:n}}function iA(e,t,r){let o=(r??sA)(e).replace(/-\d+$/,"")||"marker";if(!t.has(o))return o;let a=2;for(;t.has(`${o}-${a}`);)a+=1;return`${o}-${a}`}function sA(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function cA(e,t){let n=(e.trim()||"Marker").replace(/\s+\d+$/,"")||"Marker";if(!t.has(n))return n;let o=2;for(;t.has(`${n} ${o}`);)o+=1;return`${n} ${o}`}function kp(e,t,r,n={}){switch(t.type){case"marker.create-box":return dA(e,t.marker.geometry)&&!!t.marker.id.trim()&&!e.scene.gameObjects.some(o=>o.id===t.marker.id)&&lA(e,t.parentId??null,n);case"relation.create-many":return t.relations.length>0;case"relation.delete-many":return t.relationIds.length>0;case"relation.reverse":return r.relations.some(o=>o.id===t.relationId);case"marker-type.create":return Vd(t.definition)&&!Rr(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&Rr(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||Tp(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&aa(r).some(a=>a.type===o)}default:return!0}}function dA(e,t){switch(t.kind){case"box":case"cylinder":case"point":return!0;case"object-bounds":return ia(t.target,new Set(e.scene.gameObjects.map(r=>r.id)));case"polyhedron":return!1}}function lA(e,t,r){if(!t)return!0;let n=e.scene.gameObjects.find(o=>o.id===t)??null;return!!n&&!(r.isMarkerGameObject?.(n)??!!n.marker)}function Op(e){switch(e.type){case"marker.create-box":return`Create marker ${e.marker.label}`;case"marker.update":return`Update marker ${e.markerId}`;case"marker.delete":return`Delete marker ${e.markerId}`;case"relation.create":return`Create relation ${e.relation.type}`;case"relation.create-many":return`Create ${e.relations.length} relations`;case"relation.delete":return`Delete relation ${e.relationId}`;case"relation.delete-many":return`Delete ${e.relationIds.length} relations`;case"relation.reverse":return`Reverse relation ${e.relationId}`;case"marker.sync-from-scene":return"Sync marker graph";case"marker-type.create":return`Create marker type ${e.definition.label}`;case"marker-type.update":return`Update marker type ${e.typeId}`;case"marker-type.delete":return`Delete marker type ${e.typeId}`}}function Rp(e){switch(e.type){case"marker.create-box":return{changedId:e.marker.id,changedIds:[e.marker.id],selectId:e.marker.id};case"marker.update":case"marker.delete":return{changedId:e.markerId,changedIds:[e.markerId]};case"relation.create":return{changedIds:[e.relation.from.id,e.relation.to.id]};case"relation.create-many":return{changedIds:[...new Set(e.relations.flatMap(t=>[t.from.id,t.to.id]))]};case"relation.delete":case"relation.delete-many":case"relation.reverse":case"marker.sync-from-scene":case"marker-type.create":case"marker-type.update":case"marker-type.delete":return{}}}function qd(e){let t=structuredClone(e);if(t.type==="marker.create-box"&&(t.marker=cr(t.marker)),t.type==="marker.update"){let{spatial:r,...n}=t.patch;t.patch=n}return t}function sa(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Cp(e,t,r,n={}){let o=t.find(a=>a.path===r.path);if(!o)throw new Error(`Serialized property descriptor not found: ${r.path}`);if(o.readOnly===!0||typeof o.setValue!="function")throw new Error(`Serialized property is read-only: ${r.path}`);return o.setValue(e,r.value,{...n,targetId:r.targetId})}var qi="summary",vp="body";function Pt(){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function uA(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Xi(e){let t=_p(e);return t&&mA(t)?{mode:"matrix",matrix:t}:null}function Gp(e){return rt(e)?{mode:"matrix",matrix:tl(e.matrix)}:{...e.mode==="trs"?{mode:"trs"}:{},position:Ji(e.position),rotation:Ji(e.rotation),scale:Ji(e.scale)}}function rt(e){return e.mode==="matrix"}function Tt(e){return e.mode!=="matrix"}function Yi(e){return rt(e)?{x:e.matrix[12],y:e.matrix[13],z:e.matrix[14]}:Ji(e.position)}function mA(e){return!!_p(e)&&Math.abs(e[3])<=1e-6&&Math.abs(e[7])<=1e-6&&Math.abs(e[11])<=1e-6&&Math.abs(e[15]-1)<=1e-6&&!!jp(e)}function Fe(e){if(rt(e))return tl(e.matrix);let t=fA(e.rotation),r=t.x,n=t.y,o=t.z,a=t.w,i=r+r,s=n+n,c=o+o,d=r*i,u=r*s,l=r*c,m=n*s,f=n*c,g=o*c,b=a*i,S=a*s,y=a*c,I=e.scale.x,E=e.scale.y,D=e.scale.z;return[(1-(m+g))*I,(u+y)*I,(l-S)*I,0,(u-y)*E,(1-(d+g))*E,(f+b)*E,0,(l+S)*D,(f-b)*D,(1-(d+m))*D,0,e.position.x,e.position.y,e.position.z,1]}function Zd(e,t){return[e[0]*t[0]+e[1]*t[4]+e[2]*t[8]+e[3]*t[12],e[0]*t[1]+e[1]*t[5]+e[2]*t[9]+e[3]*t[13],e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+e[3]*t[14],e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+e[3]*t[15],e[4]*t[0]+e[5]*t[4]+e[6]*t[8]+e[7]*t[12],e[4]*t[1]+e[5]*t[5]+e[6]*t[9]+e[7]*t[13],e[4]*t[2]+e[5]*t[6]+e[6]*t[10]+e[7]*t[14],e[4]*t[3]+e[5]*t[7]+e[6]*t[11]+e[7]*t[15],e[8]*t[0]+e[9]*t[4]+e[10]*t[8]+e[11]*t[12],e[8]*t[1]+e[9]*t[5]+e[10]*t[9]+e[11]*t[13],e[8]*t[2]+e[9]*t[6]+e[10]*t[10]+e[11]*t[14],e[8]*t[3]+e[9]*t[7]+e[10]*t[11]+e[11]*t[15],e[12]*t[0]+e[13]*t[4]+e[14]*t[8]+e[15]*t[12],e[12]*t[1]+e[13]*t[5]+e[14]*t[9]+e[15]*t[13],e[12]*t[2]+e[13]*t[6]+e[14]*t[10]+e[15]*t[14],e[12]*t[3]+e[13]*t[7]+e[14]*t[11]+e[15]*t[15]]}function jp(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],g=e[13],b=e[14],S=e[15],y=t*i-r*a,I=t*s-n*a,E=t*c-o*a,D=r*s-n*i,x=r*c-o*i,N=n*c-o*s,B=d*g-u*f,p=d*b-l*f,A=d*S-m*f,h=u*b-l*g,R=u*S-m*g,K=l*S-m*b,ne=y*K-I*R+E*h+D*A-x*p+N*B;if(!Number.isFinite(ne)||Math.abs(ne)<1e-6)return null;let _=1/ne;return[(i*K-s*R+c*h)*_,(n*R-r*K-o*h)*_,(g*N-b*x+S*D)*_,(l*x-u*N-m*D)*_,(s*A-a*K-c*p)*_,(t*K-n*A+o*p)*_,(b*E-f*N-S*I)*_,(d*N-l*E+m*I)*_,(a*R-i*A+c*B)*_,(r*A-t*R-o*B)*_,(f*x-g*E+S*y)*_,(u*E-d*x-m*y)*_,(i*p-a*h-s*B)*_,(t*h-r*p+n*B)*_,(g*I-f*D-b*y)*_,(d*D-u*I+l*y)*_]}function Qd(e){let t={x:e[12],y:e[13],z:e[14]},r={x:Jd(e[0],e[1],e[2]),y:Jd(e[4],e[5],e[6]),z:Jd(e[8],e[9],e[10])};if(SA(e)<=0&&(r.y*=-1),!Yd(t)||!Yd(r)||Math.abs(r.x)<1e-6||Math.abs(r.y)<1e-6||Math.abs(r.z)<1e-6)return null;let n=1/r.x,o=1/r.y,a=1/r.z,i=[e[0]*n,e[1]*n,e[2]*n,0,e[4]*o,e[5]*o,e[6]*o,0,e[8]*a,e[9]*a,e[10]*a,0,0,0,0,1];if(!yA(i))return null;let s=bA(gA(i));if(!s)return null;let c=pA(s);if(!Yd(c))return null;let d={position:t,rotation:c,scale:r};return ca(Fe(d),e,1e-5)?d:null}function el(e,t={}){let r=Qd(e);return r||(t.allowMatrixFallback?Xi(e):null)}function Np(e){let t=uA();for(let r of e)t=Zd(Fe(r),t);return el(t,{allowMatrixFallback:!0})}function Fp(e,t){return el(Zd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function oo(e,t,r={}){let n=jp(Fe(e));return n?el(Zd(Fe(t),n),r):null}function ca(e,t,r=1e-6){return e.length===t.length&&e.every((n,o)=>Math.abs(n-t[o])<=r)}function tl(e){return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}function _p(e){return e.length!==16||!e.every(Number.isFinite)?null:tl(e)}function Ji(e){return{x:e.x,y:e.y,z:e.z}}function fA(e){let t=e.z*.5,r=e.x*.5,n=e.y*.5,o=Math.sin(t),a=Math.cos(t),i=Math.sin(r),s=Math.cos(r),c=Math.sin(n),d=Math.cos(n);return{x:d*i*a+c*s*o,y:c*s*a-d*i*o,z:d*s*o-c*i*a,w:d*s*a+c*i*o}}function pA(e){let t=e.z,r=e.x,n=e.y,o=e.w,a=n*t-r*o,i=.4999999;if(a<-i)return{x:Math.PI/2,y:2*Math.atan2(n,o),z:0};if(a>i)return{x:-Math.PI/2,y:2*Math.atan2(n,o),z:0};let s=o*o,c=t*t,d=r*r,u=n*n;return{z:Math.atan2(2*(r*n+t*o),-c-d+u+s),x:Math.asin(-2*a),y:Math.atan2(2*(t*r+n*o),c-d-u+s)}}function gA(e){let t=e[0],r=e[4],n=e[8],o=e[1],a=e[5],i=e[9],s=e[2],c=e[6],d=e[10],u=t+a+d;if(u>0){let m=.5/Math.sqrt(u+1);return{w:.25/m,x:(c-i)*m,y:(n-s)*m,z:(o-r)*m}}if(t>a&&t>d){let m=2*Math.sqrt(1+t-a-d);return{w:(c-i)/m,x:.25*m,y:(r+o)/m,z:(n+s)/m}}if(a>d){let m=2*Math.sqrt(1+a-t-d);return{w:(n-s)/m,x:(r+o)/m,y:.25*m,z:(i+c)/m}}let l=2*Math.sqrt(1+d-t-a);return{w:(o-r)/l,x:(n+s)/l,y:(i+c)/l,z:.25*l}}function bA(e){let t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);return!Number.isFinite(t)||t<1e-6?null:{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}function SA(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],g=e[13],b=e[14],S=e[15],y=l*S-b*m,I=u*S-g*m,E=u*b-g*l,D=d*S-f*m,x=d*b-l*f,N=d*g-f*u,B=+(i*y-s*I+c*E),p=-(a*y-s*D+c*x),A=+(a*I-i*D+c*N),h=-(a*E-i*x+s*N);return t*B+r*p+n*A+o*h}function Jd(e,t,r){return Math.sqrt(e*e+t*t+r*r)}function yA(e){let t={x:e[0],y:e[1],z:e[2]},r={x:e[4],y:e[5],z:e[6]},n={x:e[8],y:e[9],z:e[10]};return Math.abs(Xd(t,r))<1e-6&&Math.abs(Xd(t,n))<1e-6&&Math.abs(Xd(r,n))<1e-6}function Xd(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Yd(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}var hA={supportsShear:!1,supportsMatrixTransform:!1};function Zi(e={}){let t={...hA,...e.storageCapabilities};return{allowMatrixFallback:(e.allowMatrixFallback??!1)&&t.supportsMatrixTransform&&t.supportsShear,storageCapabilities:t}}function w(e){return typeof e=="number"&&Number.isFinite(e)}function sn(e){return e==null||typeof e=="string"}function cn(e){return e==null||typeof e=="string"&&e.trim().length>0}function Qi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function es(e){return e==null||typeof e=="boolean"}function Je(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)&&w(t.z)}function ts(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)}function da(e){if(w(e))return e>=0;if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&t.x>=0&&w(t.y)&&t.y>=0&&w(t.z)&&t.z>=0}function _t(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.r)&&w(t.g)&&w(t.b)}function $t(e){return w(e)&&e>0}function la(e){return w(e)&&e>=0}function rs(e){return w(e)&&e>=0&&e<=1}function ns(e){if(!e||typeof e!="object")return!1;let t=e;return!(t.position!==void 0&&!Je(t.position)||t.rotation!==void 0&&!Je(t.rotation)||t.rotationDeg!==void 0&&!Je(t.rotationDeg)||t.scale!==void 0&&!da(t.scale))}function os(e){return e==="orthographic"||e==="perspective"}function as(e){return e==="hemispheric"||e==="directional"}var Lt=["group","instance","transform","primitive"],$p=["instance","transform","primitive"],EA=["position","rotation","scale"],IA=["x","y","z"];function PA(e){return{path:`transform.${e}`,appliesTo:Lt,validate:t=>t==null||(e==="scale"?da(t):Je(t))}}function TA(e,t){return{path:`transform.${e}.${t}`,appliesTo:Lt,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?la(r):w(r))}}function xA(e){return[PA(e),...IA.map(t=>TA(e,t))]}var rl=[{path:"name",appliesTo:Lt,validate:sn},{path:"parentId",appliesTo:Lt,validate:sn},{path:"enabled",appliesTo:Lt,validate:es},{path:"shadow.cast",appliesTo:$p,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:$p,validate:e=>typeof e=="boolean"},{path:"transform",appliesTo:Lt,validate:e=>e==null||ns(e)},...EA.flatMap(xA),{path:"transform.rotationDeg",appliesTo:Lt,validate:e=>e==null||Je(e)},{path:"transform.rotationDeg.x",appliesTo:Lt,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.y",appliesTo:Lt,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.z",appliesTo:Lt,validate:e=>e==null||w(e)},{path:"instance.assetId",appliesTo:["instance"],validate:e=>typeof e=="string"&&e.trim().length>0,allowDelete:!1},{path:"primitive.shape",appliesTo:["primitive"],validate:e=>e==="cube"||e==="sphere"||e==="plane"||e==="capsule",allowDelete:!1},{path:"camera.projection",appliesTo:["transform"],validate:os,allowDelete:!1},{path:"camera.alpha",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.beta",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.radius",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.orthoSize",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.fov",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.targetOffset",appliesTo:["transform"],validate:e=>e==null||Je(e)},{path:"camera.targetOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.minZ",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.maxZ",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.lowerBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.upperBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.lowerRadiusLimit",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.upperRadiusLimit",appliesTo:["transform"],validate:$t,allowDelete:!1},{path:"camera.inertia",appliesTo:["transform"],validate:rs,allowDelete:!1},{path:"camera.targetScreenOffset",appliesTo:["transform"],validate:e=>e==null||ts(e)},{path:"camera.targetScreenOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetScreenOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.type",appliesTo:["transform"],validate:as,allowDelete:!1},{path:"light.intensity",appliesTo:["transform"],validate:la,allowDelete:!1},{path:"light.direction",appliesTo:["transform"],validate:Je,allowDelete:!1},{path:"light.direction.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.diffuseColor",appliesTo:["transform"],validate:e=>e==null||_t(e)},{path:"light.groundColor",appliesTo:["transform"],validate:e=>e==null||_t(e)},{path:"marker.type",appliesTo:["transform"],validate:sn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:cn},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Qi(e)},{path:"marker.note",appliesTo:["transform"],validate:sn},{path:"marker.color",appliesTo:["transform"],validate:e=>e==null||_t(e)},{path:"marker.color.r",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.g",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.b",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1}];var se=["instance","transform","primitive"];function Xe(e){return{path:e,appliesTo:se,validate:t=>t==null||_t(t)}}function V(e){return{path:e,appliesTo:se,validate:t=>t==null||w(t)}}function Lp(e){return{path:e,appliesTo:se,validate:t=>t==null||typeof t=="boolean"}}function ue(e){return{path:e,appliesTo:se,validate:cn}}function DA(e){return{path:e,appliesTo:se,validate:t=>t==null||t==="opaque"||t==="mask"||t==="blend"}}function MA(e){return{path:e,appliesTo:se,validate:t=>t==null||t==="lit"||t==="unlit"}}var wA=[{path:"transformType",appliesTo:["transform"],validate:e=>e==null||typeof e=="string"},{path:"rendering.renderingGroupId",appliesTo:se,validate:e=>e==null||e===0||e===1||e===2||e===3},{path:"rendering.alphaIndex",appliesTo:se,validate:e=>e==null||w(e)},Xe("overrides.material.albedoColor"),Xe("overrides.material.diffuseColor"),Xe("overrides.material.emissiveColor"),V("overrides.material.metallic"),V("overrides.material.roughness"),V("overrides.material.contrast"),V("overrides.material.brightness"),V("overrides.material.saturation"),V("overrides.material.hue"),V("overrides.material.colorDensity"),V("overrides.material.alpha"),V("overrides.material.alphaCutOff"),V("overrides.material.transparencyMode"),Lp("overrides.material.backFaceCulling"),ue("overrides.material.albedoTexture.url"),ue("overrides.material.normalTexture.url"),V("overrides.material.normalTexture.level"),ue("overrides.material.metallicTexture.url"),ue("overrides.material.occlusionTexture.url"),ue("overrides.material.emissiveTexture.url"),ue("overrides.material.opacityTexture.url"),Xe("overrides.material.pbr.albedoColor"),V("overrides.material.pbr.baseWeight"),Xe("overrides.material.pbr.reflectivityColor"),V("overrides.material.pbr.microSurface"),Xe("overrides.material.pbr.emissiveColor"),Xe("overrides.material.pbr.ambientColor"),V("overrides.material.pbr.lightFalloff"),V("overrides.material.pbr.directIntensity"),V("overrides.material.pbr.emissiveIntensity"),V("overrides.material.pbr.environmentIntensity"),V("overrides.material.pbr.specularIntensity"),V("overrides.material.pbr.metallicF0Factor"),V("overrides.material.pbr.indexOfRefraction"),Xe("overrides.material.standard.diffuseColor"),Xe("overrides.material.standard.specularColor"),V("overrides.material.standard.specularPower"),Xe("overrides.material.standard.emissiveColor"),Xe("overrides.material.standard.ambientColor"),Lp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:se,validate:cn},MA("overrides.materialBinding.override.lightingModel"),Xe("overrides.materialBinding.override.baseColor.color"),{path:"overrides.materialBinding.override.baseColor.color.r",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.g",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.b",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},ue("overrides.materialBinding.override.baseColor.texture.url"),ue("overrides.materialBinding.override.baseColor.texture.textureAssetId"),V("overrides.materialBinding.override.baseColor.brightness"),V("overrides.materialBinding.override.baseColor.saturation"),V("overrides.materialBinding.override.baseColor.contrast"),V("overrides.materialBinding.override.baseColor.hue"),ue("overrides.materialBinding.override.normal.texture.url"),ue("overrides.materialBinding.override.normal.texture.textureAssetId"),V("overrides.materialBinding.override.normal.strength"),V("overrides.materialBinding.override.metallic"),V("overrides.materialBinding.override.roughness"),ue("overrides.materialBinding.override.metallicRoughness.texture.url"),ue("overrides.materialBinding.override.metallicRoughness.texture.textureAssetId"),ue("overrides.materialBinding.override.occlusion.texture.url"),ue("overrides.materialBinding.override.occlusion.texture.textureAssetId"),V("overrides.materialBinding.override.occlusion.strength"),Xe("overrides.materialBinding.override.emission.color"),{path:"overrides.materialBinding.override.emission.color.r",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.g",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.b",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},V("overrides.materialBinding.override.emission.intensity"),ue("overrides.materialBinding.override.emission.texture.url"),ue("overrides.materialBinding.override.emission.texture.textureAssetId"),ue("overrides.materialBinding.override.emission.maskTexture.url"),ue("overrides.materialBinding.override.emission.maskTexture.textureAssetId"),DA("overrides.materialBinding.override.alpha.mode"),V("overrides.materialBinding.override.alpha.opacity"),V("overrides.materialBinding.override.alpha.cutoff"),ue("overrides.materialBinding.override.alpha.texture.url"),ue("overrides.materialBinding.override.alpha.texture.textureAssetId"),{path:"overrides.outline",appliesTo:se,validate:e=>e==null||kA(e)},{path:"overrides.outline.strategy",appliesTo:se,validate:e=>e==null||e==="babylon-default"},{path:"overrides.outline.renderOutline",appliesTo:se,validate:e=>e==null||typeof e=="boolean"},V("overrides.outline.outlineWidth"),{path:"overrides.outline.outlineColor",appliesTo:se,validate:e=>e==null||_t(e)},{path:"overrides.outline.outlineColor.r",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.g",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.b",appliesTo:se,validate:e=>e==null||w(e),allowDelete:!1}],zp=[...rl,...wA];function kA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.strategy==null||t.strategy==="babylon-default")&&(t.renderOutline==null||typeof t.renderOutline=="boolean")&&(t.outlineWidth==null||w(t.outlineWidth))&&(t.outlineColor==null||_t(t.outlineColor))}function nl(e,t){let r=zp.find(n=>n.path===e)??null;return!r||!r.appliesTo.includes(t)?null:r}var lr="scene.materialAssets.",ol="__fps_duplicate_material_asset__:",OA="mat_";function RA(e){return String(e??"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"")}function ur(e){let t=RA(e);return`${OA}${t||"material"}`}function al(){let e=globalThis.crypto?.randomUUID?.();if(e)return e;let t=Math.random().toString(36).slice(2,12);return`${Date.now().toString(36)}-${t}`}function Bp(e){let t=String(e??"").trim()||"material",r=[0,1,2,3].map(n=>CA(`${t}\0${n}`)).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-4${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20,32)}`}function CA(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Vp(e,t=lr){if(!e.startsWith(t))return null;let r=e.slice(t.length);if(!r)return null;if(r.endsWith(".name")){let s=r.slice(0,-5);return s?{materialAssetId:s,fieldPath:"name"}:null}let n=".properties.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return!a||!i?null:{materialAssetId:a,fieldPath:`properties.${i}`}}function Cr(e){return e==="overrides.materialBinding.materialAssetId"||zt(e,"materialAssetId")!=null}function il(e){if(Cr(e))return!0;let t="overrides.materialBinding.override.";if(e.startsWith(t))return is(`properties.${e.slice(t.length)}`);let r=vA(e);return r?is(`properties.${r}`):!1}function ss(e){return e==="overrides.materialBinding.materialAssetId"||e.startsWith("overrides.materialBinding.override.")||zt(e,"materialAssetId")!=null||zt(e,"override")!=null}function zt(e,t){let r="overrides.materialSlotBindings.";if(!e.startsWith(r))return null;let n=e.slice(r.length);if(t==="materialAssetId"){let c=".materialAssetId";if(!n.endsWith(c))return null;let d=n.slice(0,-c.length);return d||null}let o=".override.",a=n.lastIndexOf(o);if(a<0)return null;let i=n.slice(0,a),s=n.slice(a+o.length);return i&&s?i:null}function vA(e){let t="overrides.materialSlotBindings.";if(!e.startsWith(t))return null;let r=e.slice(t.length),n=".override.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return a&&i?i:null}function is(e){return e.endsWith(".texture.url")||e.endsWith(".maskTexture.url")||e.endsWith(".texture.textureAssetId")||e.endsWith(".maskTexture.textureAssetId")}function ao(e,t){if(!De(e)||!is(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return ro(e,r)?.kind==="texture"}function nt(e,t){if(e==="name"&&typeof t=="string")return t.trim();if(is(e)&&typeof t=="string"){let r=t.trim();return r||null}return(e==="properties.alpha.mode"||e==="properties.lightingModel")&&typeof t=="string"?t.trim():t}function Bt(e,t,r,n=Or){let o=nt(e,t);if(e==="name")return typeof o=="string"&&o.length>0;let a=GA(e,r,n);return a?jA(a,o):!1}function GA(e,t,r){if(t!=null)return ro(t,e,r);for(let n of r.list()){let o=ro(n.shaderId,e,r);if(o)return o}return null}function jA(e,t){if(t==null)return e.kind==="texture"||e.kind==="string"&&e.nullable===!0;if(e.kind==="number")return!(!w(t)||e.min!=null&&t<e.min||e.max!=null&&t>e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"&&t.trim().length>0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return e.channels===4?FA(t):NA(t);if(e.kind==="vec2"||e.kind==="vec3"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t,n=e.kind==="vec2"?["x","y"]:["x","y","z"];return Object.keys(r).every(o=>n.includes(o))&&n.every(o=>w(r[o]))}if(e.kind==="texture"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t;return Object.keys(r).every(n=>n==="url"||n==="textureAssetId")&&["url","textureAssetId"].every(n=>r[n]===void 0||typeof r[n]=="string"&&r[n].trim().length>0)}return!1}function cs(e){return typeof e!="string"||!e.startsWith(ol)?null:e.slice(ol.length).trim()||null}function Up(e){return e.trim().replace(/^\/+|\/+$/g,"")}function NA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b")&&w(t.r)&&w(t.g)&&w(t.b)}function FA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b"||r==="a")&&w(t.r)&&w(t.g)&&w(t.b)&&w(t.a)}var _A={r:.78,g:.78,b:.78};function Vt(e,t={}){let r=e??{},n=zA(r.baseColor?.texture,t),o=LA(r,t),a=$A(r,t);return{kind:"material-sphere",baseColor:BA(r),metallic:ua(r.metallic??0),roughness:ua(r.roughness??1),...r.emission?.color?{emissionColor:Wp(r.emission.color)}:{},emissionIntensity:VA(r.emission?.intensity,0),textureUrl:n,profile:o,properties:structuredClone(e??{}),...a.length>0?{textureResources:a}:{}}}function $A(e,t){return[["baseColor",e.baseColor?.texture],["normal",e.normal?.texture],["metallicRoughness",e.metallicRoughness?.texture],["occlusion",e.occlusion?.texture],["emission",e.emission?.texture],["emissionMask",e.emission?.maskTexture],["alpha",e.alpha?.texture]].flatMap(([n,o])=>{let a=sl(o,t);return a?[{channel:n,...a}]:[]})}function LA(e,t){let r=structuredClone(e),n=dn(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=dn(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=dn(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=dn(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=dn(r.emission?.texture,t),c=dn(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=dn(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function dn(e,t){if(!e)return;let r=sl(e,t);if(r?.state==="missing")return{...e,url:null};let n=r?.url;return{...e,...n?{url:n}:{}}}function zA(e,t){let r=sl(e,t);return r?.state==="ready"?r.url:void 0}function sl(e,t){let r=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";if(r){let o=t.resolveTextureAssetUrl?.(r)?.trim();if(o)return{reference:r,state:"ready",url:o};let a=t.textureAssets?.find(i=>i.id===r)?.url?.trim();if(a)return{reference:r,state:"ready",url:a};if(t.resolveTextureAssetUrl||Array.isArray(t.textureAssets))return{reference:r,state:"missing"}}let n=typeof e?.url=="string"?e.url.trim():"";return n?{reference:r||n,state:"ready",url:n}:null}function Hp(e,t){let r=e??{},n=Kp(r.metallic??0),o=Kp(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function BA(e){let r=(e.baseColor??{}).color??_A;return Wp(r)}function Wp(e){return{r:ua(e.r),g:ua(e.g),b:ua(e.b)}}function ua(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Kp(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,""):"0"}function VA(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ee(e,t){return t?e.scene.materialAssets?.find(r=>r.id===t)??null:null}function Ut(e,t){return!!ee(e,t)}function tg(e,t){return t?{state:"asset",materialAssetId:t.id,materialAsset:t}:e?.materialAssetId?{state:"missing-asset",materialAssetId:e.materialAssetId}:e?.override?{state:"override"}:{state:"inherit"}}function ma(e,t){let r=new Set;for(let n of cl(e,t))r.add(n.gameObjectId);return[...r]}function cl(e,t){let r=t.trim();return r?fa(e).filter(n=>n.materialAssetId===r):[]}function fa(e){let t=[],r=new Map(e.assets.map(n=>[n.id,n]));for(let n of e.scene.gameObjects){let o=YA(n),a=ds(n.overrides?.materialBinding);a&&t.push({kind:"root",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:a,bindingPath:"overrides.materialBinding.materialAssetId",label:o});let i=vr(e,n,r),s=new Map(i.filter(d=>!!d.slotId).map(d=>[d.slotId,d])),c=n.overrides?.materialSlotBindings??{};for(let[d,u]of Object.entries(c)){let l=ds(u);if(!l)continue;let m=s.get(d),f=ZA(m,d);t.push({kind:"slot",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:l,bindingPath:`overrides.materialSlotBindings.${d}.materialAssetId`,label:`${o} / ${f}`,slotId:d,ownerNodePath:Kt(m)??d})}}for(let n of e.assets)if(!(n.type!=="prefab"||!n.prefab)){qp(t,{ownerId:n.id,ownerName:n.displayName??n.id,prefabAssetId:n.id,path:`assets.${n.id}.prefab.overrides`,overrides:n.prefab.overrides});for(let o of n.prefab.nodes??[])qp(t,{ownerId:`${n.id}:${o.id}`,ownerName:`${n.displayName??n.id} / ${o.name??o.id}`,prefabAssetId:n.id,prefabNodeId:o.id,path:`assets.${n.id}.prefab.nodes.${o.id}.overrides`,overrides:o.overrides})}return t}function qp(e,t){let r=ds(t.overrides?.materialBinding);r&&e.push({kind:"root",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:r,bindingPath:`${t.path}.materialBinding.materialAssetId`,label:t.ownerName,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}});for(let[n,o]of Object.entries(t.overrides?.materialSlotBindings??{})){let a=ds(o);a&&e.push({kind:"slot",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:a,bindingPath:`${t.path}.materialSlotBindings.${n}.materialAssetId`,label:`${t.ownerName} / ${n}`,slotId:n,ownerNodePath:n,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}})}}function us(e){let t=[...new Set((e.scene.materialAssets??[]).map(s=>s.id?.trim()).filter(s=>!!s))],r=new Set(t),n=fa(e),o=n.filter(s=>!r.has(s.materialAssetId)),a=new Map;for(let s of o){let c=a.get(s.materialAssetId)??[];c.push(s),a.set(s.materialAssetId,c)}let i=[...a.entries()].map(([s,c])=>({kind:"missing-material-asset",materialAssetId:s,usages:c}));return{ok:i.length===0,materialAssetIds:t,references:n,missingMaterialAssetIds:i.map(s=>s.materialAssetId),missingReferences:o,issues:i}}function vr(e,t,r){let n=new Map;for(let o of fs(e,t,r))n.set(o.slotId,o);return[...n.values()].sort((o,a)=>(o.label??o.slotId).localeCompare(a.label??a.slotId)||o.slotId.localeCompare(a.slotId))}function rg(e,t){return fs(e,t).length>0}function ot(e){return[...new Set(e.sourceSurfaces.map(t=>t.sourceMaterialIndex).filter(t=>Number.isInteger(t)))].sort((t,r)=>t-r)}function Kt(e){return e?.sourceSurfaces[0]?.ownerNodePath??null}function ng(e){return e.slotId}function ms(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function dl(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function og(e){let t=ag(e);if(!t)return;let r={},n=XA(t.materialAssetId);return n&&(r.materialAssetId=n),t.override&&typeof t.override=="object"&&!Array.isArray(t.override)&&(r.override=t.override),Object.keys(r).length>0?r:void 0}function fs(e,t,r){let n=Se(t);if(!n)return[];let a=(r?.get(n.assetId)??e.assets.find(s=>s.id===n.assetId))?.metadata?.materialSlots;if(!Array.isArray(a))return[];let i=[];for(let s of a){let c=Gr(s);c&&i.push(c)}return i}function Gr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.slotId=="string"&&t.slotId.trim()?t.slotId.trim():"",n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces:null,o=UA(n);if(!r||!n||o.length===0||o.length!==n.length)return null;let a=typeof t.label=="string"&&t.label.trim()?t.label.trim():o[0].ownerNodePath,i=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",s=Array.isArray(t.materialNames)?t.materialNames.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim()):void 0,c=HA(t.sourceMaterialProfiles);return{slotId:r,label:a,sourceSurfaces:o,...i?{materialName:i}:{},...s&&s.length>0?{materialNames:s}:{},...c&&c.length>0?{sourceMaterialProfiles:c}:{}}}function UA(e){return Array.isArray(e)?e.flatMap(t=>{let r=ag(t);if(!r)return[];let n=Up(typeof r.ownerNodePath=="string"?r.ownerNodePath:""),o=Number.isInteger(r.meshIndex)&&r.meshIndex>=0?r.meshIndex:void 0,a=Number.isInteger(r.primitiveIndex)&&r.primitiveIndex>=0?r.primitiveIndex:void 0;if(!n||o==null||a==null)return[];let i=Number.isInteger(r.nodeIndex)&&r.nodeIndex>=0?r.nodeIndex:void 0,s=Array.isArray(r.nodeIndexPath)?r.nodeIndexPath.filter(m=>Number.isInteger(m)&&m>=0):void 0,c=Number.isInteger(r.sourceMaterialIndex)&&r.sourceMaterialIndex>=0?r.sourceMaterialIndex:void 0,d=typeof r.sourceMeshName=="string"&&r.sourceMeshName.trim()?r.sourceMeshName.trim():void 0,u=typeof r.triangleCount=="number"&&Number.isFinite(r.triangleCount)&&r.triangleCount>=0?r.triangleCount:void 0,l=KA(r.boundingBox);return[{ownerNodePath:n,...i!=null?{nodeIndex:i}:{},...s&&s.length>0?{nodeIndexPath:s}:{},meshIndex:o,primitiveIndex:a,...c!=null?{sourceMaterialIndex:c}:{},...d?{sourceMeshName:d}:{},...u!=null?{triangleCount:u}:{},...l?{boundingBox:l}:{}}]}):[]}function KA(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=Jp(t.min),n=Jp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Jp(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return typeof t=="number"&&Number.isFinite(t)&&typeof r=="number"&&Number.isFinite(r)&&typeof n=="number"&&Number.isFinite(n)?[t,r,n]:null}function HA(e){if(!Array.isArray(e))return;let t=e.map(WA).filter(r=>!!r);return t.length>0?t:void 0}function WA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!Number.isInteger(t.sourceMaterialIndex))return null;let r=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",n=t.profile&&typeof t.profile=="object"&&!Array.isArray(t.profile)?t.profile:void 0,o=qA(t.textureHints);return{sourceMaterialIndex:t.sourceMaterialIndex,...r?{materialName:r}:{},...n?{profile:n}:{},...o&&o.length>0?{textureHints:o}:{}}}function qA(e){if(!Array.isArray(e))return;let t=e.map(JA).filter(r=>!!r);return t.length>0?t:void 0}function JA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.profilePath=="string"&&t.profilePath.trim()?t.profilePath.trim():"",n=typeof t.reason=="string"&&t.reason.trim()?t.reason.trim():"";return!r||!n?null:{profilePath:r,reason:n,...Number.isInteger(t.textureIndex)?{textureIndex:t.textureIndex}:{},...Number.isInteger(t.imageIndex)?{imageIndex:t.imageIndex}:{},...Number.isInteger(t.bufferView)?{bufferView:t.bufferView}:{},...typeof t.mimeType=="string"&&t.mimeType.trim()?{mimeType:t.mimeType.trim()}:{},...typeof t.uri=="string"&&t.uri.trim()?{uri:t.uri.trim()}:{}}}function ag(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function XA(e){return typeof e=="string"&&e.trim()?e.trim():null}function YA(e){return e.name?.trim()||e.id}function ds(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function ZA(e,t){return e?.label?.trim()||Kt(e)?.trim()||e?.slotId?.trim()||t}var ls=class{constructor(t){this.byMaterialId=new Map;this.byOwnerId=new Map;for(let r of fa(t)){let n=this.byMaterialId.get(r.materialAssetId)??[];n.push(r),this.byMaterialId.set(r.materialAssetId,n);let o=this.byOwnerId.get(r.gameObjectId)??[];o.push(r),this.byOwnerId.set(r.gameObjectId,o)}}forMaterial(t){return this.byMaterialId.get(t.trim())??[]}forOwner(t){return this.byOwnerId.get(t)??[]}},Xp=new WeakMap;function QA(e){let t=Xp.get(e);return t||(t=new ls(e),Xp.set(e,t)),t}function ll(e){return e?.system?.preset}function Yp(e,t){let r=ll(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Zp(e,t){let r=ll(e);return r==="default-pbr"?t.defaultMaterialMeta:r==="default-standard"?t.defaultStandardMaterialMeta:t.formatMaterialMeta(e.id)}function eD(e,t){let r=e.currentAsset??null,n=!!r&&!e.currentValue,o=r&&!n?Qp(e.document,r.id,e.ownershipText,t):null,a=r?Zp(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?eg(a,o):a;return{pickerKind:"material",pickerTitle:e.pickerText.materialPickerTitle,pickerTrigger:"preview",placeholder:e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.inheritNone,...r?{currentMaterialAssetId:r.id,currentMaterialShaderId:r.shaderId,...r.definitionVersion!=null?{currentMaterialDefinitionVersion:r.definitionVersion}:{}}:{},currentLabel:r?Yp(r,e.displayText):e.currentValue?e.currentValue:e.pickerText.inheritNone,currentMeta:i,...o?.usageLabel?{currentUsageLabel:o.usageLabel}:{},...o?.editImpactLabel?{currentEditImpactLabel:o.editImpactLabel}:{},...o?{currentOwnership:o}:{},currentPreview:r?Vt(r.properties,e.previewContext):void 0,candidates:[{label:e.pickerText.inheritNone,value:"",meta:e.pickerText.summaryInherit},...e.materialAssets.map(s=>{let c=Qp(e.document,s.id,e.ownershipText,t);return{label:Yp(s,e.displayText),value:s.id,meta:eg(Zp(s,e.displayText),c),kind:"material",preview:Vt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function Qp(e,t,r,n){if(!e||!n)return null;let o=t.trim(),a=n.forMaterial(o),i=a.length;return{materialAssetId:o,usage:{count:i,items:a.map(s=>structuredClone(s))},usageCount:i,used:i>0,shared:i>1,...r?{usageLabel:r.formatUsageCount(i),editImpactLabel:r.formatEditImpact(i),duplicateImpactLabel:r.formatDuplicateImpact(i)}:{}}}function eg(e,t){return[e,t?.usageLabel].filter(Boolean).join(" \xB7 ")}function tD(e,t,r={}){return(e.scene.materialAssets??[]).map(n=>{let o=t.forMaterial(n.id);return{id:`material:${n.id}`,assetId:n.id,kind:"material",label:n.name||n.id,meta:Hp(n.properties,n.id),preview:Vt(n.properties,r),material:{id:n.id,name:n.name||n.id,shaderId:n.shaderId,...n.definitionVersion!=null?{definitionVersion:n.definitionVersion}:{},readonly:n.system?.readonly===!0||ll(n)!=null,usage:{count:o.length,items:o.map(a=>structuredClone(a))},properties:structuredClone(n.properties)},placeable:!1}})}var rD={createUsageIndex(e){return new ls(e)},getCachedUsageIndex:QA,createPickerControlOptions:eD,createBrowserAssetItems:tD},_e=rD;var ln=1;var ml="prefab.";function ga(e){let t=structuredClone(e),r={ordinaryObjects:0,prefabRoots:0,discardedFields:0},n=$e(t.scene);return n&&(Me(n,"shadowMapExperiment",r),Array.isArray(n.gameObjects)&&n.gameObjects.forEach(o=>nD(o,r))),Array.isArray(t.assets)&&t.assets.forEach(o=>oD(o,r)),{document:t,summary:r}}function mn(e){let t=$e(e);return!t||t.prefab!=null||t.transformType==="camera"||t.transformType==="light"||t.camera!=null||t.light!=null?!1:t.kind==="primitive"||$e(t.primitive)?!0:Array.isArray(t.components)&&t.components.some(r=>{let n=$e(r)?.type;return n==="ModelRenderer"||n==="ImageRenderer"})}function nD(e,t){let r=$e(e);if(!r)return;let n=$e(r.shadow);Me(r,"shadowMode",t),Me(r,"shadowMapExperiment",t),mn(r)?(r.shadow=sg(n),t.ordinaryObjects+=1):Me(r,"shadow",t)}function oD(e,t){let r=$e(e);if(!r)return;let n=$e(r.defaults);n&&(Me(n,"shadowMode",t),Me(n,"shadow",t),Me(n,"shadowMapExperiment",t));let o=$e(r.prefab);if(!o)return;let a=$e(o.defaults);a&&Me(a,"shadowMode",t),o.defaults={...a??{},shadow:sg(a?.shadow)},t.prefabRoots+=1;let i=$e(o.defaults);if(Me(i,"shadowMapExperiment",t),Array.isArray(o.nodes))for(let s of o.nodes){let c=$e(s);if(!c)continue;Me(c,"shadowMode",t),Me(c,"shadow",t),Me(c,"shadowMapExperiment",t);let d=$e(c.defaults);d&&(Me(d,"shadowMode",t),Me(d,"shadow",t),Me(d,"shadowMapExperiment",t))}}function sg(e){let t=$e(e);return{cast:t?.cast==="enabled"?"enabled":"none",receive:t?.receive==="enabled"?"enabled":"none"}}function Me(e,t,r){Object.prototype.hasOwnProperty.call(e,t)&&(delete e[t],r.discardedFields+=1)}function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var r0=Symbol("unsupported-editor-scene-authored-clone-value");function G(e){return e.components.find(cD)??null}function Se(e){return e.components.find(dD)??null}function jr(e){return e.components.find(lD)??null}function Ye(e){return e?.type==="prefab"&&te(e.prefab?.sourceAssetId)!=null}function Le(e,t){let r=e.assets.find(n=>n.id===t);return r&&Ye(r)?r:null}function ps(e){return te(e?.prefab?.prefabId)!=null}function pa(e){return te(e?.prefab?.sourceAssetId)}function Ze(e){if(!e?.prefab)return null;let t=pl(e.prefab),r=te(e.prefab.rootNodeId);if(r&&t.some(o=>o.id===r))return r;let n=t.find(o=>o.kind==="root"&&!o.parentId);return n?n.id:null}function Qe(e){return e?.prefab?pl(e.prefab):[]}function io(e,t){let r=te(t);return r?Qe(e).find(n=>n.id===r)??null:null}function fl(e,t){let r=te(t);return Qe(e).filter(n=>{let o=te(n.parentId);return r?o===r:!o})}function cg(e){if(!Ye(e))return ul(e,!1,null,[{code:"prefab.invalidDefinition",severity:"error",message:`Asset "${e.id}" is not a valid prefab definition.`,assetId:e.id}]);let t=pl(e.prefab),r=Ze(e);if(e.prefab.compositionVersion!==ln||t.length===0||!r)return ul(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${ln} with an explicit root node.`,assetId:e.id}]);let n=aD(e);return ul(n,JSON.stringify(n.prefab)!==JSON.stringify(e.prefab))}function ul(e,t,r=null,n=[],o={}){return{ok:n.every(a=>a.severity!=="error"),changed:t,prefabAsset:e,...o.selectedNodeId?{selectedNodeId:o.selectedNodeId}:{},...o.createdNodeId?{createdNodeId:o.createdNodeId}:{},...o.deletedNodeIds?{deletedNodeIds:[...o.deletedNodeIds]}:{},...r?{node:structuredClone(r)}:{},diagnostics:n.map(a=>({...a}))}}function aD(e){let t=structuredClone(e),r=Qe(e);t.prefab=structuredClone(t.prefab),t.prefab.compositionVersion=ln,t.prefab.nodes=r;let n=Ze({...e,prefab:{...e.prefab,nodes:r}});return n?t.prefab.rootNodeId=n:delete t.prefab.rootNodeId,t}function pl(e){if(!Array.isArray(e.nodes))return[];let t=[];for(let r of e.nodes){let n=iD(r);n&&!t.some(o=>o.id===n.id)&&t.push(n)}return structuredClone(t)}function iD(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=te(t.id);return!r||!sD(t.kind)?null:{id:r,...te(t.guid)?{guid:te(t.guid)}:{},...te(t.name)?{name:te(t.name)}:{},...te(t.parentId)?{parentId:te(t.parentId)}:{},kind:t.kind,...t.transform?{transform:structuredClone(t.transform)}:{},...te(t.sourceAssetId)?{sourceAssetId:te(t.sourceAssetId)}:{},...te(t.sourceNodePath)?{sourceNodePath:te(t.sourceNodePath)}:{},...te(t.childPrefabId)?{childPrefabId:te(t.childPrefabId)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.light?{light:structuredClone(t.light)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults?{defaults:structuredClone(t.defaults)}:{},...t.overrides?{overrides:structuredClone(t.overrides)}:{},...t.metadata?{metadata:structuredClone(t.metadata)}:{}}}function sD(e){return e==="root"||e==="group"||e==="model"||e==="primitive"||e==="light"||e==="prefabInstance"||e==="marker"||e==="collision"}function dg(e){let t=pa(e.prefabAsset);if(!t)throw new Error(`Prefab asset "${e.prefabAsset.id}" does not define a source asset.`);let r=e.prefabAsset.prefab?.defaults;return{id:e.id,...e.guid?{guid:e.guid}:{},name:e.name??e.prefabAsset.displayName??e.prefabAsset.id,kind:"instance",...e.parentId?{parentId:e.parentId}:{},active:e.active??r?.active??!0,prefab:{prefabId:e.prefabAsset.id,...e.prefabAsset.guid?{prefabGuid:e.prefabAsset.guid}:{},sourceAssetId:t},...e.metadata?{metadata:{...e.metadata}}:{},...e.overrides!==void 0?{overrides:e.overrides}:{},components:[e.transform,{type:"ModelRenderer",assetId:t}]}}function lg(e){if(!e.startsWith(ml))return null;let t=e.slice(ml.length);return ss(t)?t:null}function gl(e){return lg(e)?.endsWith(".materialAssetId")===!0}function ug(e){return e.startsWith(ml)&&e.endsWith(".materialAssetId")&&gl(e)}function mg(e,t){if(t.slotId)return og(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function ba(e,t,r){let n=lg(t);if(!n||!Ye(e))return e;let o=mD(n);if(!o)return e;let a=structuredClone(e);a.prefab=structuredClone(a.prefab??e.prefab),pD(a.prefab,o,r);let i=Sg(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function fg(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=kd(e?.override,t?.override);return Sl({...n??r?{materialAssetId:n??r}:{},...un(o)?{override:o}:{}})}function gs(e,t){let r={},n=fg(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=bD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),un(r)?r:void 0}function bs(e,t){let r=fn(e,t);if(!(!r.gameObject||!r.prefab))return gs(r.definition?.prefab?.overrides,SD(r.gameObject.overrides))}function fn(e,t){let r=typeof t=="string"?uD(e,t):t,n=typeof t=="string"?t:t.id,o=[],a=ps(r)?r.prefab:null;if(!r||!a)return o.push({code:"not-prefab-instance",severity:"info",message:r?`GameObject "${r.id}" is not a prefab instance.`:`GameObject "${n}" was not found.`}),{gameObject:r,prefab:null,definition:null,sourceAsset:null,diagnostics:o};let i=e.assets.find(d=>d.id===a.prefabId&&Ye(d));i||o.push({code:"missing-prefab-definition",severity:"error",message:`Prefab definition "${a.prefabId}" was not found.`,prefabId:a.prefabId});let s=pa(i)??te(a.sourceAssetId);i&&a.sourceAssetId&&s&&a.sourceAssetId!==s&&o.push({code:"source-asset-mismatch",severity:"warning",message:`Prefab instance source "${a.sourceAssetId}" does not match definition source "${s}".`,prefabId:a.prefabId,expectedSourceAssetId:s,actualSourceAssetId:a.sourceAssetId});let c=s?e.assets.find(d=>d.id===s):void 0;if(s&&!c&&o.push({code:"missing-source-asset",severity:"error",message:`Prefab source asset "${s}" was not found.`,prefabId:a.prefabId,sourceAssetId:s}),s){let d=e.assets.filter(u=>Ye(u)&&pa(u)===s).map(u=>u.id);d.length>1&&o.push({code:"duplicate-source-prefab",severity:"info",message:`Source asset "${s}" is referenced by ${d.length} prefab definitions.`,prefabId:a.prefabId,sourceAssetId:s})}return{gameObject:r,prefab:a,definition:i??null,sourceAsset:c??null,diagnostics:o}}function Y(e){return e.kind==="group"||e.kind==="instance"||e.kind==="transform"||e.kind==="primitive"?e.kind:ps(e)?"instance":e.primitive?"primitive":Se(e)?"instance":jr(e)||e.transformType?"transform":"group"}function pg(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=bl(t?.renderingGroupId),n=bg(t?.alphaIndex),o={};return r!=null&&(o.renderingGroupId=r),n!=null&&(o.alphaIndex=n),Object.keys(o).length>0?o:void 0}function bl(e){return e===0||e===1||e===2||e===3?e:null}function gg(e){return bg(e)}function cD(e){return e.type==="Transform"}function dD(e){return e.type==="ModelRenderer"}function lD(e){return e.type==="ImageRenderer"}function bg(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function te(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function uD(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function mD(e){if(e==="overrides.materialBinding.materialAssetId")return["overrides","materialBinding","materialAssetId"];let t="overrides.materialBinding.override.";if(e.startsWith(t)){let o=e.slice(t.length);return ig(["overrides","materialBinding","override"],o)}let r=zt(e,"materialAssetId");if(r)return["overrides","materialSlotBindings",r,"materialAssetId"];let n=zt(e,"override");if(n){let o=fD(e);return o?ig(["overrides","materialSlotBindings",n,"override"],o):null}return null}function fD(e){let t=".override.",r=e.lastIndexOf(t);if(r<0)return null;let n=e.slice(r+t.length);return n||null}function ig(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(yg)?null:[...e,...r]}function pD(e,t,r){if(t.some(yg))return;let n=e;for(let a of t.slice(0,-1)){let i=n[a];(!i||typeof i!="object"||Array.isArray(i))&&(n[a]={}),n=n[a]}let o=t[t.length-1];o&&(r==null?delete n[o]:n[o]=structuredClone(r))}function Sg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r={},n=Sl(t.materialBinding);n&&(r.materialBinding=n);let o=gD(t.materialSlotBindings);return o&&(r.materialSlotBindings=o),un(r)?r:void 0}function Sl(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=te(t.materialAssetId),n=kd(t.override),o={...r?{materialAssetId:r}:{},...un(n)?{override:n}:{}};return un(o)?o:void 0}function gD(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[r,n]of Object.entries(e)){let o=te(r);if(!o)continue;let a=Sl(n);a&&(t[o]=a)}return un(t)?t:void 0}function bD(e,t){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),n={};for(let o of r){let a=fg(e?.[o],t?.[o]);a&&(n[o]=a)}return un(n)?n:void 0}function SD(e){return Sg(e)}function un(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function yg(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var yD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function hg(e,t,r){if(e.kind!=="marker"){Object.prototype.hasOwnProperty.call(e,"marker")&&F("schema.invalidValue",`${r}.marker`);return}for(let s of Object.keys(e))yD.has(s)||F("schema.invalidValue",`${r}.${s}`);Sa(e.parentId)||F("schema.invalidReference",`${r}.parentId`),PD(e.transform,`${r}.transform`),hD(e.marker,`${r}.marker`);let n=Sa(e.id),o=e.marker,a=ED(o,`${r}.marker`),i=a[0]??null;for(let s of a){s.target.id===n&&F("schema.invalidReference",`${s.path}.id`),i&&(s.target.kind!==i.target.kind||s.target.id!==i.target.id)&&F("schema.invalidReference",s.path);let c=t.get(s.target.id);c&&(s.target.kind==="marker"&&c.kind!=="marker"&&F("schema.invalidReference",`${s.path}.kind`),s.target.kind==="scene-object"&&c.kind==="marker"&&F("schema.invalidReference",`${s.path}.kind`))}}function hD(e,t){let r=Fr(e);r||F("schema.invalidType",t),at(r,["schemaVersion","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t),r.schemaVersion!==1&&F("schema.unsupportedVersion",`${t}.schemaVersion`),Sa(r.type)||F("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!Sa(r.kind)&&F("schema.invalidValue",`${t}.kind`),r.tags!==void 0&&AD(r.tags,`${t}.tags`),r.note!==void 0&&typeof r.note!="string"&&F("schema.invalidType",`${t}.note`),r.color!==void 0&&xD(r.color,`${t}.color`),r.target!==void 0&&yl(r.target,`${t}.target`),r.semanticFrame!==void 0&&TD(r.semanticFrame,`${t}.semanticFrame`),ID(r.geometry,`${t}.geometry`),r.metadata!==void 0&&DD(r.metadata,`${t}.metadata`)}function ED(e,t){let r=[];return e.target&&r.push({target:e.target,path:`${t}.target`}),e.geometry.kind==="point"&&e.geometry.target&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),e.geometry.kind==="object-bounds"&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),r}function ID(e,t){let r=Fr(e);if(r||F("schema.invalidType",t),r.kind==="box"){at(r,["kind"],t);return}if(r.kind==="cylinder"){at(r,["kind"],t);return}if(r.kind==="point"){at(r,["kind","coordinateSpace","position","offset","target"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&r.coordinateSpace!=="local"&&F("schema.invalidValue",`${t}.coordinateSpace`),r.position!==void 0&&Nr(r.position,`${t}.position`),r.offset!==void 0&&Nr(r.offset,`${t}.offset`),r.target!==void 0&&yl(r.target,`${t}.target`);return}if(r.kind==="object-bounds"){at(r,["kind","target"],t),yl(r.target,`${t}.target`);return}if(r.kind==="polyhedron"){at(r,["kind","coordinateSpace","vertices","faces"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&F("schema.invalidValue",`${t}.coordinateSpace`),Array.isArray(r.vertices)||F("schema.invalidType",`${t}.vertices`),r.vertices.forEach((n,o)=>Nr(n,`${t}.vertices[${o}]`)),r.faces!==void 0&&(Array.isArray(r.faces)||F("schema.invalidType",`${t}.faces`),r.faces.forEach((n,o)=>{Array.isArray(n)||F("schema.invalidType",`${t}.faces[${o}]`),n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&F("schema.invalidValue",`${t}.faces[${o}][${i}]`)})}));return}F("schema.invalidValue",`${t}.kind`)}function yl(e,t){let r=Fr(e);r||F("schema.invalidType",t),at(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&F("schema.invalidValue",`${t}.kind`),Sa(r.id)||F("schema.invalidValue",`${t}.id`),r.label!==void 0&&typeof r.label!="string"&&F("schema.invalidType",`${t}.label`)}function PD(e,t){let r=Fr(e);if(r||F("schema.invalidType",t),r.type!=="Transform"&&F("schema.invalidValue",`${t}.type`),r.mode==="matrix"){at(r,["type","mode","matrix"],t),(!Array.isArray(r.matrix)||r.matrix.length!==16)&&F("schema.invalidType",`${t}.matrix`),r.matrix.forEach((n,o)=>Ss(n,`${t}.matrix[${o}]`));return}at(r,["type","mode","position","rotation","scale"],t),r.mode!==void 0&&r.mode!=="trs"&&F("schema.invalidValue",`${t}.mode`),Nr(r.position,`${t}.position`),Nr(r.rotation,`${t}.rotation`),r.scale!==void 0&&Nr(r.scale,`${t}.scale`)}function TD(e,t){let r=Fr(e);r||F("schema.invalidType",t),at(r,["origin","forward","right","up","label","description"],t),Nr(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Nr(r[n],`${t}.${n}`);for(let n of["label","description"])r[n]!==void 0&&typeof r[n]!="string"&&F("schema.invalidType",`${t}.${n}`)}function xD(e,t){let r=Fr(e);r||F("schema.invalidType",t),at(r,["r","g","b"],t);for(let n of["r","g","b"])Ss(r[n],`${t}.${n}`),(r[n]<0||r[n]>1)&&F("schema.invalidValue",`${t}.${n}`)}function Nr(e,t){let r=Fr(e);r||F("schema.invalidType",t),at(r,["x","y","z"],t);for(let n of["x","y","z"])Ss(r[n],`${t}.${n}`)}function AD(e,t){Array.isArray(e)||F("schema.invalidType",t),e.forEach((r,n)=>{typeof r!="string"&&F("schema.invalidType",`${t}[${n}]`)})}function DD(e,t){let r=Fr(e);r||F("schema.invalidType",t),hl(r,t,new Set)}function hl(e,t,r){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"){Ss(e,t);return}(!e||typeof e!="object")&&F("schema.invalidType",t),r.has(e)&&F("schema.invalidValue",t);let n=Object.getPrototypeOf(e);Array.isArray(e)?n!==Array.prototype&&F("schema.invalidType",t):n!==Object.prototype&&n!==null&&F("schema.invalidType",t),r.add(e);try{if(Array.isArray(e))e.forEach((o,a)=>hl(o,`${t}[${a}]`,r));else for(let[o,a]of Object.entries(e))hl(a,`${t}.${o}`,r)}finally{r.delete(e)}}function at(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||F("schema.invalidValue",`${r}.${o}`)}function Ss(e,t){(typeof e!="number"||!Number.isFinite(e))&&F("schema.invalidValue",t)}function Fr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Sa(e){return typeof e=="string"&&e.trim()?e.trim():null}function F(e,t){throw new Error(`${e}: ${t}`)}function so(e,t){return t===e.rootNodeId?e.instanceId:`${e.instanceId}:${MD(t)}`}function MD(e){return encodeURIComponent(e)}function El(e,t){return{...structuredClone(e),id:so(t,e.id)}}function ya(e,t){let r=structuredClone(e);return r.target&&(r.target=El(r.target,t)),r.geometry.kind==="point"&&r.geometry.target&&(r.geometry.target=El(r.geometry.target,t)),r.geometry.kind==="object-bounds"&&(r.geometry.target=El(r.geometry.target,t)),r}function z(e,t){if(Eg(e))try{return e[t]}catch{return}}function le(e,t){let r=z(e,t);return typeof r=="string"&&r.trim()?r:null}function re(e,t){let r=z(e,t);return typeof r=="number"&&Number.isFinite(r)?r:null}function Te(e,t){let r=z(e,t);return typeof r=="boolean"?r:null}function we(e,t,r=[]){let n=z(e,t);if(typeof n=="function")try{return n.apply(e,r)}catch{return}}function Ht(e){if(!Eg(e))return null;let t=we(e,"getClassName");if(typeof t=="string"&&t.trim())return t;let r=z(e,"constructor"),n=r&&typeof r=="function"?r.name:"";return n&&n!=="Object"?n:null}function pn(e){let t=Ht(e),r=le(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function Eg(e){return!!e&&(typeof e=="object"||typeof e=="function")}function ys(e,t=new WeakSet,r=0){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?wD(e):"[NonFiniteNumber]";if(typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e!="object")return String(e);if(t.has(e))return"[Circular]";if(r>6)return"[MaxDepth]";if(t.add(e),Array.isArray(e))return e.map(a=>ys(a,t,r+1));let n=e,o={};for(let a of Object.keys(n).sort())o[a]=ys(z(n,a),t,r+1);return o}function wD(e){return Math.round(e*1e6)/1e6}function _r(e){let t=e.properties.filter(r=>!!r).map((r,n)=>r.order==null?{...r,order:n}:r);return t.length===0&&e.omitWhenEmpty!==!1?null:{id:e.id,title:e.title,order:e.order,placement:"body",summary:e.summary,persistence:e.persistence??(e.runtimeOnly?"runtime":"readonly"),runtimeOnly:e.runtimeOnly,effect:e.effect??(e.runtimeOnly?"runtime":void 0),disabledReason:e.disabledReason,collapsedByDefault:e.collapsedByDefault,tags:e.tags,properties:t}}function j(e){if(!kD(e.value))return null;let t=ys(e.value);return{path:e.path,label:e.label,valueType:e.valueType??OD(t),control:"readonly",value:t,readOnly:!0,persistence:e.persistence??"readonly",commitMode:"blur",order:e.order,tags:CD(e.source,e.tags),tooltip:e.tooltip,effect:e.effect??RD(e.source,e.persistence),disabledReason:e.disabledReason}}function Il(e,t){let r=j(t);r&&e.push(r)}function co(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.buttonLabel??e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Pl(e){let t=gn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>j({path:`${e.basePath}.${n}`,label:`${e.label}.${n}`,value:t[n],order:r+o,persistence:e.persistence,source:e.source,tags:e.tags,effect:e.effect,disabledReason:e.disabledReason,valueType:"number"})).filter(n=>!!n)}function gn(e){if(!e||typeof e!="object")return null;let t=re(e,"x"),r=re(e,"y"),n=re(e,"z");return t==null||r==null||n==null?null:{x:t,y:r,z:n}}function kD(e){return e!=null&&!(typeof e=="number"&&!Number.isFinite(e))}function OD(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function RD(e,t){if(t==="runtime"||e==="Runtime")return"runtime";if(e==="Derived")return"derived"}function CD(e,t){let r=[...e?[e]:[],...t??[]];return r.length>0?[...new Set(r)]:void 0}function ha(e){let t=e.projectedRoot??e.root??null,r=Pg(t),n=r.find(o=>!!z(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:Tg(t),meshes:r,primaryMesh:n,material:vD(t)}}function hs(e){let t=we(e,"getHierarchyBoundingVectors"),r=gn(z(t,"min")),n=gn(z(t,"max"));if(r&&n)return Ig(r,n);let o=we(e,"getBoundingInfo"),a=z(o,"boundingBox"),i=gn(z(a,"minimumWorld")),s=gn(z(a,"maximumWorld"));return i&&s?Ig(i,s):null}function Pg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return xg(e)&&r.unshift(e),[...new Set(r)]}function Tg(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function xg(e){return!!e&&(!!z(e,"material")||typeof z(e,"getTotalVertices")=="function"||typeof z(e,"getBoundingInfo")=="function")}function Es(e,t){let r=0,n=0;for(let o of e){let a=we(o,t);typeof a!="number"||!Number.isFinite(a)||(r+=a,n+=1)}return n>0?r:"not available"}function lo(e,t){let r=z(e,t);return Array.isArray(r)?r.length:0}function Is(e,t){let r=we(e,t);return Array.isArray(r)?r.length:"not available"}function Tl(e){let t=we(e,"isEnabled");return typeof t=="boolean"?t:null}function Ea(e,t){let r=re(e,t);if(r!=null)return r;let n=we(e,"getParam",[t]);return typeof n=="number"&&Number.isFinite(n)?n:null}function Ig(e,t){return{min:e,max:t,center:{x:(e.x+t.x)/2,y:(e.y+t.y)/2,z:(e.z+t.z)/2},size:{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}}function vD(e){let t=z(e,"material");if(t)return t;let r=we(e,"getChildMeshes",[!1]);if(Array.isArray(r)){let n=r.find(o=>!!z(o,"material"));if(n)return z(n,"material")}return null}var Ts={x:-.3,y:-1,z:-.2},Ag=-180,Dg=180,Ia=-90,Pa=90;function Ta(e,t=Ts){let r=e&&ND(e)?e:t,n=Math.hypot(r.x,r.y,r.z);if(!Number.isFinite(n)||n<=1e-6){let o=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/o,y:t.y/o,z:t.z/o}}return{x:r.x/n,y:r.y/n,z:r.z/n}}function Al(e,t){let r=$r(As(e)),n=$r(Cg(t,Ia,Pa)),o=Math.cos(n);return{x:xl(o*Math.cos(r)),y:xl(-Math.sin(n)),z:xl(o*Math.sin(r))}}function Dl(e){if(!Ds(e.light))return null;let t=G(e),r=t&&"rotation"in t?t.rotation:void 0,n=Og({direction:e.light.direction,rotation:r}),o=Al(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:$r(n.elevationAngleDeg),y:$r(n.horizontalAngleDeg),z:uo(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function Mg(e,t){if(!Ds(e.light))return e;let r=Dl(e);if(!r)return e;let n=uo(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=uo(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=Al(n,o),i={...r.rotation,x:$r(o),y:$r(n)};return{...e,light:{...e.light,direction:a},components:e.components.map(s=>s===G(e)&&"rotation"in s?{...s,rotation:i}:s)}}function GD(e,t=Ts){let{horizontalAngleDeg:r,elevationAngleDeg:n}=Og({direction:t,rotation:e});return Al(r,n)}function jD(e,t){let r=kg(e);return{x:$r(r.elevationAngleDeg),y:$r(r.horizontalAngleDeg),z:uo(t?.z)?t.z:0}}function mo(e){if(!Ds(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=GD(t.rotation,e.light.direction);return Rg(r,Ta(e.light.direction))?e:{...e,light:{...e.light,direction:r}}}function xs(e){if(!Ds(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=jD(e.light.direction,t.rotation);return Rg(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function wg(e){let t=Ta(e),r=Math.abs(t.y);return r<=1e-6?999:Math.min(999,Math.hypot(t.x,t.z)/r)}function As(e){let t=((e+180)%360+360)%360-180;return t===-180?180:t}function ND(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.z=="number"&&Number.isFinite(e.z)}function Ds(e){return e?.type==="directional"}function kg(e){let t=Ta(e);return{horizontalAngleDeg:As(Ps(Math.atan2(t.z,t.x))),elevationAngleDeg:Ps(Math.asin(Cg(-t.y,-1,1)))}}function Og(e){let t=kg(e.direction);return{horizontalAngleDeg:uo(e.rotation?.y)?Ps(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:uo(e.rotation?.x)?Ps(e.rotation.x):t.elevationAngleDeg}}function uo(e){return typeof e=="number"&&Number.isFinite(e)}function Rg(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Ps(e){return e*180/Math.PI}function $r(e){return e*Math.PI/180}function xl(e){return Math.round(e*1e6)/1e6}function Cg(e,t,r){return Math.min(r,Math.max(t,e))}var bn="light.directionHorizontalAngleDeg",Sn="light.directionElevationAngleDeg";function fo(e){return e===bn||e===Sn}function vg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=FD(t);return r==null?t:e===bn?Math.round(As(r)):e===Sn?Math.round(_D(r,Ia,Pa)):t}function FD(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function _D(e,t,r){return Math.min(r,Math.max(t,e))}function yn(e){return t=>po({...e,value:t})}function po(e){let t=$D(e);if(t)return t;let r=nl(e.path,e.nodeKind);return r?e.value==null&&r.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${e.path}.`}:r.validate(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`}:{ok:!1,message:`Unsupported scene node field: ${e.path}.`}}function hn(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?Gg(t):t}function mr(e,t,r={}){if((r.isDirectionalLightAnglePath??jg)(e))return vg(e,t);if((e==="marker.type"||e==="marker.geometry.kind")&&typeof t=="string"||e==="marker.target.objectId"&&typeof t=="string")return t.trim();if(e==="marker.tags")return BD(t);if(e==="marker.note"&&typeof t=="string"){let n=t.trim();return n||null}return il(e)&&typeof t=="string"?Gg(t):hn(e,t)}function Ml(e){return t=>LD(t,e)}function $D(e){for(let t of e.extraValidators??[]){let r=t({path:e.path,nodeKind:e.nodeKind,value:e.value,document:e.document});if(r)return r}return null}function LD(e,t){if(e.path==="camera.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: camera.inspectorLanguage."};if(e.path==="light.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: light.inspectorLanguage."};if((t.isDirectionalLightAnglePath??jg)(e.path))return typeof e.value=="number"&&Number.isFinite(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="metadata.artistMaterialInspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="instance.assetId"&&e.document&&typeof e.value=="string"&&!(e.document.assets??[]).some(r=>r.id===e.value))return{ok:!1,message:`Asset not found: ${e.value}.`};if(Cr(e.path)&&e.document&&typeof e.value=="string"&&e.value&&!t.hasMaterialAsset(e.document,e.value))return{ok:!1,message:`Material asset not found: ${e.value}.`};if(Cr(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(il(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="marker.type")return typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value.trim()}:{ok:!1,message:"Marker type must be a non-empty string."};if(e.path==="marker.tags")return e.value==null||Array.isArray(e.value)&&e.value.every(r=>typeof r=="string"&&r.trim().length>0)?{ok:!0,value:e.value}:{ok:!1,message:"Marker tags must be non-empty strings."};if(e.path==="marker.color")return zD(e.value)?{ok:!0,value:e.value}:{ok:!1,message:"Marker color must contain RGB values between 0 and 1."};if(e.path==="marker.note")return e.value==null||typeof e.value=="string"?{ok:!0,value:e.value}:{ok:!1,message:"Marker note must be a string or null."};if(e.path==="marker.geometry.kind")return e.value==="box"||e.value==="cylinder"?{ok:!0,value:e.value}:{ok:!1,message:"Marker geometry must be box or cylinder."};if(e.path==="marker.target.objectId"){if(typeof e.value!="string")return{ok:!1,message:"Marker target must be a scene object id."};let r=e.value.trim();if(!r)return{ok:!0,value:""};let n=e.document?.scene?.gameObjects?.find(o=>o.id===r)??null;return n&&!t.isMarkerGameObject(n)?{ok:!0,value:r}:{ok:!1,message:`Marker target object not found: ${r}.`}}return null}function zD(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return[t.r,t.g,t.b].every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0&&r<=1)}function Gg(e){let t=e.trim();return t||null}function BD(e){let r=(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>typeof n=="string"?n.trim():"").filter((n,o,a)=>n.length>0&&a.indexOf(n)===o);return r.length>0?r:null}function jg(e){return e===bn||e===Sn}function xa(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:yn({path:e.property.path,nodeKind:e.nodeKind,document:e.document,extraValidators:e.extraValidators})}}function it(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function xt(e){return e*180/Math.PI}function Wt(e){return e*Math.PI/180}function st(e){return Math.round(e*1e6)/1e6}var Ng={zh:{title:"\u6444\u50CF\u673A",summaryOrthographic:"ArcRotate \u6B63\u4EA4",summaryPerspective:"ArcRotate \u900F\u89C6",language:"\u8BED\u8A00",projection:"\u6295\u5F71\u6A21\u5F0F",projectionOrthographic:"\u6B63\u4EA4",projectionPerspective:"\u900F\u89C6",alpha:"Alpha",beta:"Beta",radius:"\u534A\u5F84",orthoSize:"\u6B63\u4EA4\u5C3A\u5BF8",fov:"\u89C6\u91CE\u89D2\u5EA6",targetOffset:"\u76EE\u6807\u504F\u79FB",nearClip:"\u8FD1\u88C1\u526A",farClip:"\u8FDC\u88C1\u526A",minBeta:"\u6700\u5C0F Beta",maxBeta:"\u6700\u5927 Beta",minRadius:"\u6700\u5C0F\u534A\u5F84",maxRadius:"\u6700\u5927\u534A\u5F84",inertia:"\u60EF\u6027",screenOffset:"\u5C4F\u5E55\u504F\u79FB",rawCamera:"\u539F\u59CB\u6444\u50CF\u673A"},en:{title:"Camera",summaryOrthographic:"ArcRotate Orthographic",summaryPerspective:"ArcRotate Perspective",language:"Language",projection:"Projection",projectionOrthographic:"Orthographic",projectionPerspective:"Perspective",alpha:"Alpha",beta:"Beta",radius:"Radius",orthoSize:"Ortho Size",fov:"FOV",targetOffset:"Target Offset",nearClip:"Near Clip",farClip:"Far Clip",minBeta:"Min Beta",maxBeta:"Max Beta",minRadius:"Min Radius",maxRadius:"Max Radius",inertia:"Inertia",screenOffset:"Screen Offset",rawCamera:"Raw Camera"}},Fg=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function wl(e){return Ng[e]??Ng.zh}function VD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function _g(e){let{camera:t,createDocumentInspectorProperty:r,nodeKind:n,rig:o}=e,a=o.inspectorLanguage??"zh",i=wl(a),s=[],c=0;s.push(r(null,n,{path:"camera.inspectorLanguage",label:i.language,valueType:"enum",control:"enum",value:a,commitMode:"immediate",order:c,options:Fg,controlOptions:{variant:"segmented"}})),c+=1,s.push(r(null,n,{path:"camera.projection",label:i.projection,valueType:"enum",control:"enum",value:o.projection??"orthographic",commitMode:"immediate",order:c,options:VD(i),controlOptions:{variant:"segmented"}})),c+=1,s.push(ze(n,r,{path:"camera.alpha",label:i.alpha,value:o.alpha,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.beta",label:i.beta,value:o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.radius",label:i.radius,value:o.radius,order:c,min:.001,step:.1})),c+=1,(o.projection??"orthographic")==="perspective"?s.push(ze(n,r,{path:"camera.fov",label:i.fov,value:st(xt(o.fov??.85)),order:c,min:1,max:179,step:1,coerce:d=>typeof d=="number"&&Number.isFinite(d)?Wt(d):d})):s.push(ze(n,r,{path:"camera.orthoSize",label:i.orthoSize,value:o.orthoSize??6,order:c,min:.001,step:.1})),c+=1;for(let d of["x","y","z"])s.push(ze(n,r,{path:`camera.targetOffset.${d}`,label:`${i.targetOffset} ${d.toUpperCase()}`,value:o.targetOffset?.[d]??0,order:c,step:.05})),c+=1;s.push(ze(n,r,{path:"camera.minZ",label:i.nearClip,value:o.minZ??1,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.maxZ",label:i.farClip,value:o.maxZ??1e4,order:c,min:.001,step:1})),c+=1,s.push(ze(n,r,{path:"camera.lowerBetaLimit",label:i.minBeta,value:o.lowerBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.upperBetaLimit",label:i.maxBeta,value:o.upperBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.lowerRadiusLimit",label:i.minRadius,value:o.lowerRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.upperRadiusLimit",label:i.maxRadius,value:o.upperRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.inertia",label:i.inertia,value:o.inertia??.9,order:c,min:0,max:1,step:.05})),c+=1;for(let d of["x","y"])s.push(ze(n,r,{path:`camera.targetScreenOffset.${d}`,label:`${i.screenOffset} ${d.toUpperCase()}`,value:o.targetScreenOffset?.[d]??0,order:c,step:.01})),c+=1;return Il(s,{path:"camera.raw",label:i.rawCamera,value:t??"defaults",order:s.length,source:"Document",tags:["Raw"]}),s}function kl(e){let t=wl(e.rig.inspectorLanguage??"zh");return{id:"camera",title:t.title,order:42,placement:"body",summary:e.rig.projection==="perspective"?t.summaryPerspective:t.summaryOrthographic,persistence:"document",collapsedByDefault:!1,properties:_g(e)}}function ze(e,t,r){return t(null,e,{path:r.path,label:r.label,valueType:"number",control:"number",value:r.value,commitMode:"live",order:r.order,min:r.min,max:r.max,step:r.step??.05,coerce:r.coerce})}var Ms="scene.main",ws="scene";function qt(e){let t=e.meta?.authoringSource;return{sourceId:t?.sourceId||Ms,sourceType:t?.sourceType||ws,revision:typeof t?.revision=="number"?t.revision:1}}function $g(e){let t=qt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Ms,sourceType:ws,revision:t.revision??1}}}}function Lg(e){let t=qt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Ms,sourceType:ws,revision:(t.revision??0)+1}}}}function zg(e,t){let r=qt(e),n=UD(t),o=r.revision??null;if(!n)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:null,reason:"missing-generated-from"};let a=typeof n.revision=="number"?n.revision:null;return n.sourceId!==r.sourceId||n.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"source-mismatch"}:o!==a?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a}}function UD(e){if(!e||typeof e!="object")return null;let t=e.meta;if(!t||typeof t!="object")return null;let r=t.generatedFrom;if(!r||typeof r!="object")return null;let n=r.sourceId,o=r.sourceType;return typeof n!="string"||typeof o!="string"?null:{sourceId:n,sourceType:o,revision:typeof r.revision=="number"?r.revision:void 0}}var KD="sun_light";function ks(e){let t=HD(e);return t.shadows.planar.enabled?"planar":t.shadows.blob.enabled?"blob":t.shadows.staticProjected.enabled?"static":t.shadows.enabled?"dynamic":"none"}function HD(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function WD(e,t){let r=typeof t.prefab?.prefabId=="string"?t.prefab.prefabId:null,n=r?e.assets.find(a=>a.id===r)?.prefab?.defaults?.shadow:void 0,o=We(n??t.shadow);return{settings:o.shadow,diagnostics:o.diagnostics}}function qD(e){let t=new Map,r=e.casterId;for(let n of e.explicitReceiverIds??[]){let o=Rs(e.document,n);!o||o.id===r||o.active===!1||t.set(o.id,{receiverId:o.id,source:"explicit",score:120,...Ol(o,"explicit",120,["explicit receiver id"])})}for(let n of e.document.scene.gameObjects){if(n.id===r||n.active===!1)continue;We(n.shadow).shadow?.receive==="enabled"&&YD(t,{receiverId:n.id,source:"explicit",score:100,...Ol(n,"explicit",100,["shadow.receive enabled"])})}return[...t.values()].sort((n,o)=>o.score-n.score||n.receiverId.localeCompare(o.receiverId))}function Os(e){let t=e.caster?.id===e.casterId?e.caster:Rs(e.document,e.casterId),r=[];if(!t)return{casterId:e.casterId,receiverIds:[],backend:"none",mode:"none",quality:e.fallbackQuality??"medium",params:Di(e.fallbackQuality??"medium"),diagnostics:[{code:"shadow.invalidTarget",severity:"error",message:`Shadow caster "${e.casterId}" was not found.`,casterId:e.casterId}]};let n=e.resolvedSettings!==void 0?(()=>{let f=We(e.resolvedSettings);return{settings:f.shadow,diagnostics:f.diagnostics}})():WD(e.document,t);r.push(...n.diagnostics);let a=n.settings?.cast==="enabled"?fd(n.settings,e.fallbackMode??"none"):"none",i=pd(n.settings,e.fallbackQuality??"medium"),s=Di(i,n.settings?.params),c=JD(a),d=ZD(e.explicitReceiverIds),u=c==="none"?{candidates:[],diagnostics:[]}:d.length>0&&e.strictExplicitReceivers===!0?QD(e.document,t.id,d):{candidates:qD({document:e.document,casterId:t.id,explicitReceiverIds:d.length>0?d:void 0}),diagnostics:[]};r.push(...u.diagnostics);let l=u.candidates;c!=="none"&&l.length===0&&r.push({code:"shadow.receiverNotFound",severity:"warning",message:`No shadow receiver was found for caster "${t.id}".`,casterId:t.id});let m=c==="none"?null:XD(e.document,n.settings??void 0,e.defaultLightId);return m?.diagnostic&&r.push(m.diagnostic),{casterId:t.id,receiverIds:l.map(f=>f.receiverId),...m?.lightId?{lightId:m.lightId}:{},backend:c,mode:a,quality:i,params:s,diagnostics:r}}function JD(e){return e==="dynamic"?"dynamic-map":e==="static"?"static-baked":e==="blob"?"blob":e==="projected"?"projected":"none"}function XD(e,t,r){if(t?.light?.mode==="explicit"){let a=t?.light?.lightId;return a&&Bg(e,a)?{lightId:a}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:a?`Explicit shadow light "${a}" was not found.`:"Shadow light mode is explicit, but no lightId was configured.",...a?{lightId:a}:{}}}}let n=r??KD;if(Bg(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Vg(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function Bg(e,t){let r=Rs(e,t);return!!r&&r.active!==!1&&Vg(r)}function Vg(e){return Y(e)==="transform"&&e.light?.type==="directional"}function YD(e,t){let r=e.get(t.receiverId);(!r||t.score>r.score)&&e.set(t.receiverId,t)}function ZD(e){let t=new Set,r=[];for(let n of e??[]){let o=typeof n=="string"?n.trim():"";!o||t.has(o)||(t.add(o),r.push(o))}return r}function QD(e,t,r){let n=[],o=[];for(let a of r){let i=Rs(e,a);if(!i){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" was not found.`,casterId:t,receiverId:a,details:{source:"explicit"}});continue}if(i.id===t){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Shadow caster "${t}" cannot be used as its own receiver.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"self"}});continue}if(i.active===!1){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" is inactive.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"inactive"}});continue}n.push({receiverId:i.id,source:"explicit",score:120,...Ol(i,"explicit",120,["explicit receiver id"])})}return{candidates:n,diagnostics:o}}function Ol(e,t,r,n){let o=We(e.shadow).shadow;return{active:e.active!==!1,visible:e.active!==!1,...o?.receive?{receive:o.receive}:{},suitability:{score:r,material:Y(e)==="primitive"?"primitive":t,reasons:n}}}function Rs(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}var eM="main_camera",tM="environment_light",rM="sun_light";function Rl(e){return Y(e)==="group"}function At(e){return!!G(e)}function Dt(e){return Y(e)==="transform"&&(e.transformType==="camera"||!!e.camera)}function go(e){return Y(e)==="transform"&&(e.transformType==="light"||!!e.light)}function Mt(e){return e.id===eM||e.id===tM||e.id===rM||Dt(e)||go(e)}function Cl(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Mt(r)}var Lr="root",nM="go_",vl="GameObject";function me(e){return e===Lr}function Z(e){return me(e.id)}function jl(e){let t=new Set,r=!1,n=e.scene.gameObjects.map(o=>{let a=aM(o,t);return r=r||a!==o,a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function he(){let e=globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${nM}${e}`}function ct(e,t){let r=new Set(e),n=Cs(t)||"game_object";if(!r.has(n))return n;let o=2;for(;r.has(`${n}_${o}`);)o+=1;return`${n}_${o}`}function Ug(e,t=vl){return Gl(e)??Gl(t)??vl}function dt(e,t,r={}){let n=Ug(t,r.fallbackName??vl),o=new Set(e.map(s=>Gl(s)).filter(s=>!!s));if(!r.alwaysAppendSuffix&&!o.has(n))return n;let a=1,i=`${n}_${a}`;for(;o.has(i);)a+=1,i=`${n}_${a}`;return i}function Gl(e){let t=String(e??"").trim();return t&&t.replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||null}function Cs(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"asset"}function oM(e){return typeof e.guid=="string"&&e.guid.trim()?e.guid.trim():null}function aM(e,t){let r=oM(e);if(r&&!t.has(r))return t.add(r),r===e.guid?e:{...e,guid:r};let n=he();for(;t.has(n);)n=he();return t.add(n),{...e,guid:n}}var zr=Pt();function ke(e,t){if(me(t))return Pt();let r=$(e,t);if(!r)return null;let n=[],o=Nl(e),a=new Set,i=r;for(;i&&!a.has(i.id);)a.add(i.id),n.unshift(i),i=i.parentId?o.get(i.parentId):void 0;return Np(n.map(Jt))}function $(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function Nl(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function fr(e,t,r,n){let o=t?ke(e,t):Pt();return o?oo(o,r,n):null}function Aa(e,t,r,n={}){let o=Zi(n);return fr(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function Jt(e){return Z(e)?Pt():So(e)}function Da(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=So(r),o=!!G(r)&&!sM(n,zr),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=Kg(s,t);return a=a||l!==s,l}if(!o||s.parentId!==Lr||!G(s))return s;let d=Fp(n,So(s));if(!d)return s;let u=Fl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function Kg(e,t={}){let r=!1,n=e.parentId!==void 0||t.normalizeRootActive===!0&&e.active!==!0,o=e.components.map(i=>{if(i.type!=="Transform")return i;r=!0;let s=i;return Gs(s)&&bo(s.position,zr.position)&&bo(s.rotation,zr.rotation)&&bo(Hg(s,"scale"),zr.scale)?i:(n=!0,vs())});if(r||(n=!0,o.unshift(vs())),!n)return e;let a={...e,...t.normalizeRootActive===!0?{active:!0}:{},components:o};return delete a.parentId,a}function vs(){return wt(zr)}function So(e){let t=G(e);return t?Ee(t)?Xi(t.matrix)??Pt():{position:{...t.position},rotation:{...t.rotation},scale:{...Hg(t,"scale")}}:Pt()}function Fl(e,t){return{...e,components:e.components.map(r=>r.type!=="Transform"?r:pr(t)??r)}}function pr(e){let t=En(e);return t?rt(t)?{type:"Transform",mode:"matrix",matrix:t.matrix}:{type:"Transform",...t.mode==="trs"?{mode:"trs"}:{},position:{...t.position},rotation:{...t.rotation},scale:{...t.scale}}:null}function En(e){return rt(e)?Xi(e.matrix):Gp(e)}function wt(e){let t=pr(e);if(!t)throw new Error("Invalid matrix Transform component.");return t}function Ee(e){return e.mode==="matrix"}function Gs(e){return e.mode!=="matrix"}function Hg(e,t){return iM(e)?t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]:t==="scale"?{x:1,y:1,z:1}:{x:0,y:0,z:0}}function iM(e){return!!e.position&&!!e.rotation}function sM(e,t){return!Tt(e)||!Tt(t)?ca(Fe(e),Fe(t)):bo(e.position,t.position)&&bo(e.rotation,t.rotation)&&bo(e.scale,t.scale)}function bo(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function ye(e){return e.scene.gameObjects.find(t=>t.id===Lr&&!!G(t))?.id??e.scene.gameObjects.find(t=>!t.parentId&&!!G(t))?.id}function js(e,t){return me(e)&&/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/.test(t)}function _l(e,t){return!t||t===Lr?!1:!!$(e,t)}function gr(e){let t=ye(e),r=new Map(e.scene.gameObjects.map(n=>[n.id,n]));return e.scene.gameObjects.filter(n=>n.id!==Lr).map(n=>{let o=Mt(n),a=At(n),i=n.active!==!1;return{id:n.id,label:n.name??n.id,parentId:n.parentId===t?null:n.parentId??null,depth:Math.max(0,cM(r,n)-(t?1:0)),role:a&&Rl(n)?"group":"object",...ps(n)?{icon:"prefab"}:{},selectable:!0,enabled:i&&dM(r,n.parentId,t),directEnabled:i,canToggleEnabled:!o,enableToggleDisabledReason:o?"Protected system objects cannot be hidden from Hierarchy.":void 0,protected:o,canHaveChildren:!o&&a,renamable:!o,deletable:!o,draggable:!o}})}function cM(e,t){let r=new Set,n=0,o=t.parentId??null;for(;o;){if(r.has(o))return n;r.add(o);let a=e.get(o);if(!a)return n;n+=1,o=a.parentId??null}return n}function dM(e,t,r){let n=new Set,o=t??null;for(;o;){if(n.has(o))return!0;n.add(o);let a=e.get(o);if(!a)return!0;if(a.id!==r&&a.active===!1)return!1;o=a.parentId??null}return!0}function $l(e){let t=Da(e,{normalizeRootActive:!0}),r=ye(t);if(!r)return t;let n=t.scene.gameObjects.find(s=>s.id===r);if(!n)return t;let o=Z(n)?null:ke(t,r);if(!Z(n)&&!o)return t;let a=!1,i=t.scene.gameObjects.map(s=>{if(s.id===r||s.parentId)return s;let c=Jt(s),d=o?oo(o,c,{allowMatrixFallback:!0}):c;return a=!0,{...s,parentId:r,components:d?s.components.map(u=>u.type!=="Transform"?u:wt(d)):s.components}});return a?{...t,scene:{...t.scene,gameObjects:i}}:t}function br(e,t){return[...kt(e,t)]}function kt(e,t){let r=new Set,n=new Map;for(let i of e.scene.gameObjects){r.add(i.id);let s=i.parentId;if(!s)continue;let c=n.get(s);c?c.push(i.id):n.set(s,[i.id])}let o=new Set,a=[];for(let i of t)!r.has(i)||o.has(i)||(o.add(i),a.push(i));for(let i=0;i<a.length;i+=1)for(let s of n.get(a[i])??[])o.has(s)||(o.add(s),a.push(s));return o}function Bl(e){let t=[Wg(e)],r=Jg(e);r&&t.push(r);let n=Zg(e);n&&t.push(n);let o=tb(e);o&&t.push(o);let a=ob(e);a&&t.push(a);let i=mM(e);i&&t.push(i);let s=ib(e);s&&t.push(s);let c=sb(e);c&&t.push(c);let d=db(e);return d&&t.push(d),t}function Wg(e){return{id:"common",title:"Common",order:10,placement:"body",summary:_s(e),persistence:"document",collapsedByDefault:!1,properties:qg(e)}}function qg(e){let{document:t,gameObject:r}=e,n=_s(e),o=[et("id","ID",r.id,0),Xt(e,{document:t,path:"name",label:"Name",valueType:"string",control:"string",value:r.name??r.id,commitMode:"blur",order:1}),Xt(e,{document:t,path:"enabled",label:"Enabled",valueType:"boolean",control:"boolean",value:r.active!==!1,commitMode:"immediate",order:2}),et("kind.resolved","Resolved Kind",n,3),et("kind.explicit","Explicit Kind",r.kind??"inferred",4),et("common.activeField","Active Field",r.active??"default:true",5)];return n==="transform"?o.push(Xt(e,{document:t,path:"transformType",label:"Transform Type",valueType:"enum",control:"enum",value:r.transformType??"plain",commitMode:"immediate",order:6,options:e.transformTypeOptions??wa})):o.push(et("common.transformType","Transform Type",r.transformType??"none",6)),o}function Jg(e){return _r({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:Xg(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Yg(e)})}function Xg(e){let t=e.gameObject.parentId?$(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Yg(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?$(t,r.parentId):null,a=t.scene.gameObjects.filter(d=>d.parentId===r.id),i=Math.max(br(t,[r.id]).length-1,0),s=qt(t),c=t.scene.gameObjects.filter(d=>d.parentId===r.parentId).findIndex(d=>d.id===r.id);return oe(n,{path:"hierarchy.parentId",label:"Parent ID",value:r.parentId??"none",order:0,source:"Document"}),oe(n,{path:"hierarchy.parentName",label:"Parent Name",value:o?o.name??o.id:r.parentId?"missing":"none",order:1,source:"Document"}),oe(n,{path:"hierarchy.childCount",label:"Children",value:a.length,order:2,source:"Derived"}),oe(n,{path:"hierarchy.descendantCount",label:"Descendants",value:i,order:3,source:"Derived"}),oe(n,{path:"hierarchy.siblingIndex",label:"Sibling Index",value:c>=0?c:"unknown",order:4,source:"Derived"}),oe(n,{path:"document.gameObjectIndex",label:"Document Index",value:t.scene.gameObjects.findIndex(d=>d.id===r.id),order:5,source:"Derived"}),oe(n,{path:"document.schemaVersion",label:"Schema Version",value:t.schemaVersion,order:6,source:"Document"}),oe(n,{path:"source.sourceId",label:"Source ID",value:s.sourceId,order:7,source:"Document"}),oe(n,{path:"source.sourceType",label:"Source Type",value:s.sourceType,order:8,source:"Document"}),oe(n,{path:"source.revision",label:"Revision",value:s.revision??"none",order:9,source:"Document"}),n}function Zg(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:eb(e),persistence:"document",collapsedByDefault:!1,properties:Qg(e)}:null}function Qg(e){if(!G(e.gameObject))return[];let r=_s(e),n=Z(e.gameObject),o=n?e.rootTransform??Pt():So(e.gameObject);if(rt(o))return lM(o,0);let a=!!e.gameObject.parentId,i=[],s=0;for(let c of["position","rotation","scale"]){let d=EM(o,c);for(let u of["x","y","z"]){let l=`transform.${c}.${u}`,m=c==="rotation"?st(xt(d[u])):d[u];n?i.push(et(l,`${zl(c)}.${u}`,m,s)):i.push(Xt(e,{document:null,path:l,label:`${a?`Local ${zl(c)}`:zl(c)}.${u}`,valueType:"number",control:"number",value:m,commitMode:"live",order:s,displayPrecision:c==="rotation"?2:3,precision:4,step:c==="rotation"?1:c==="scale"?.01:.1,stepPrecision:c==="rotation"?.1:c==="scale"?.001:.01},r)),s+=1}}if(a){let c=ke(e.document,e.gameObject.id);if(c&&!rt(c))for(let d of["x","y","z"])i.push(et(`transform.worldPosition.${d}`,`World Position.${d}`,c.position[d],s)),s+=1}return i}function eb(e){let t=e.gameObject.parentId?$(e.document,e.gameObject.parentId):null;if(Z(e.gameObject))return"Identity Root";let r=G(e.gameObject);return r&&Ee(r)?"Matrix Transform":`Relative to: ${t?t.name??t.id:"Scene"}`}function lM(e,t){if(!rt(e))return[];let r=[et("transform.mode","Mode","Matrix Transform",t)],n=t+1;for(let a=0;a<4;a+=1)r.push(et(`transform.matrix.row${a}`,`Matrix Row ${a+1}`,e.matrix.slice(a*4,a*4+4).map(Ns).join(", "),n)),n+=1;let o=Qd(e.matrix);return r.push(et("transform.matrix.trsApproximation","TRS Approximation",o?[`P ${Ll(o.position)}`,`R ${Ll({x:xt(o.rotation.x),y:xt(o.rotation.y),z:xt(o.rotation.z)})}`,`S ${Ll(o.scale)}`].join(" | "):"Not representable as TRS",n)),r}function tb(e){let t=Se(e.gameObject),r=jr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:nb(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?uM(e,r):rb(e)}:null}function uM(e,t){let r=Ma(e.document,t.assetId);return[et("imageRenderer.assetId","Texture Asset",r?.displayName??t.assetId,0),et("imageRenderer.size","Image Size",`${t.size.width} \xD7 ${t.size.height}`,1),et("imageRenderer.assetType","Asset Type",r?.type??"texture",2)]}function rb(e){let t=Se(e.gameObject);if(!t)return[];let{document:r}=e,n=Ma(r,t.assetId),o=[Xt(e,{document:r,path:"instance.assetId",label:"Asset",valueType:"enum",control:"enum",value:t.assetId,commitMode:"immediate",order:0,options:r.assets.map(a=>({label:a.displayName??a.id,value:a.id}))})];return oe(o,{path:"renderer.assetId",label:"Renderer Asset ID",value:t.assetId,order:1,source:"Document"}),oe(o,{path:"asset.id",label:"Asset ID",value:n?.id??"missing",order:2,source:"Asset"}),oe(o,{path:"asset.type",label:"Asset Type",value:n?.type??"missing",order:3,source:"Asset"}),oe(o,{path:"asset.guid",label:"GUID",value:n?.guid??"missing",order:4,source:"Asset"}),oe(o,{path:"asset.displayName",label:"Display Name",value:n?.displayName??"none",order:5,source:"Asset"}),oe(o,{path:"asset.category",label:"Category",value:n?.category??"none",order:6,source:"Asset"}),oe(o,{path:"asset.materialMode",label:"Material Mode",value:n?.materialMode??"none",order:7,source:"Asset"}),oe(o,{path:"asset.defaults",label:"Defaults",value:n?.defaults??"none",order:8,source:"Asset",tags:["Raw"]}),o}function nb(e,t){let r=Ma(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function ob(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:ab(e)}:null}function ab(e){let t=e.gameObject.primitive;return t?[Xt(e,{document:e.document,path:"primitive.shape",label:"Shape",valueType:"enum",control:"enum",value:t.shape,commitMode:"immediate",order:0,options:e.primitiveShapeOptions??IM})]:[]}function mM(e){if(e.gameObject.prefab)return fM(e);if(!yo(e))return null;let t=We(e.gameObject.shadow).shadow,r=Xt(e,{document:e.document,path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.cast==="enabled",commitMode:"immediate",order:0,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u8BE5\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002"}),n=Xt(e,{document:e.document,path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.receive==="enabled",commitMode:"immediate",order:1,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002"}),o=Fs(e.renderingProfile),a=e.renderingProfile!==void 0&&ks(o)==="none";return{id:"shadow",title:"\u9634\u5F71",order:34,placement:"body",...a?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[r,n,...a?[Vl()]:[]]}}function fM(e){let t=e.gameObject.prefab?.prefabId,r=t?e.document.assets.find(i=>i.id===t)?.prefab?.defaults?.shadow:void 0,n=We(r).shadow,o=!!t,a=[{path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:0,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},{path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:1,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},...t?[co({path:"prefab.edit-definition",label:"\u8FDB\u5165 Prefab",buttonLabel:"Edit Prefab",actionId:"asset.edit-prefab",order:2,icon:"box",tooltip:"\u5728 Prefab Stage \u4E2D\u7F16\u8F91 definition root \u7684\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002",params:{assetId:t,browserAssetId:`prefab:${t}`,assetKind:"prefab"},disabled:!1})]:[]];return{id:"shadow",title:"\u9634\u5F71",order:34,summary:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B":"\u7531 Prefab definition root \u7BA1\u7406",persistence:o?"document":"readonly",collapsedByDefault:!1,properties:a}}function Vl(){return{path:"rendering.shadows.open",label:"\u6253\u5F00 Rendering / Shadows",valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:"\u6253\u5F00 Rendering / Shadows",icon:"world"},value:"\u6253\u5F00 Rendering / Shadows",readOnly:!0,persistence:"readonly",commitMode:"immediate",order:2,tags:["Rendering"],effect:"active"}}function Fs(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function ib(e){if(!pM(e))return null;let t=Fs(e.renderingProfile),r=gM(e.gameObject.rendering?.renderingGroupId),n=t.renderingGroups.slots.find(a=>a.renderingGroupId===r)??t.renderingGroups.slots[0],o=bM(e.gameObject)??null;return{id:"rendering",title:"Rendering",order:36,placement:"body",summary:SM(n,o),persistence:"document",collapsedByDefault:!1,properties:[Xt(e,{document:e.document,path:"rendering.renderingGroupId",label:"Rendering Group",valueType:"enum",control:"enum",value:r,commitMode:"immediate",order:0,options:t.renderingGroups.slots.map(a=>({label:`${a.renderingGroupId}: ${a.name}`,value:a.renderingGroupId}))}),Xt(e,{document:e.document,path:"rendering.alphaIndex",label:"Alpha Order",valueType:"enum",control:"enum",value:o,commitMode:"immediate",order:1,options:yM(n,o)})]}}function sb(e){return _r({id:"components",title:"Scripts / Components",order:65,summary:Ul(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:cb(e.gameObject)})}function Ul(e){return e.components.map(t=>t.type).join(", ")||"none"}function cb(e){let t=[];return oe(t,{path:"components.count",label:"Count",value:e.components.length,order:0,source:"Document"}),oe(t,{path:"components.types",label:"Types",value:Ul(e),order:1,source:"Document"}),e.components.forEach((r,n)=>{oe(t,{path:`components.${n}`,label:`${r.type} ${n}`,value:r,order:n+2,source:"Document",tags:["Component","Raw"]})}),t}function db(e){let t=e.assetId??Se(e.gameObject)?.assetId??jr(e.gameObject)?.assetId??null,r=lb({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:ub({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function lb(e){let t=[],r=e.assetId?Ma(e.document,e.assetId):null;return oe(t,{path:"metadata.document",label:"Document Meta",value:e.document.meta??"none",order:0,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.gameObject",label:"GameObject Metadata",value:e.gameObject.metadata??"none",order:1,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.asset",label:"Asset Metadata",value:r?.metadata??"none",order:2,source:"Asset",tags:["Raw"]}),t}function ub(e){let t=e.assetId?Ma(e.document,e.assetId):null,r=[e.document.meta?"Document":null,e.gameObject.metadata?"GameObject":null,t?.metadata?"Asset":null].filter(n=>!!n);return r.length>0?r.join(" + "):"none"}function Xt(e,t,r=_s(e)){let{document:n,...o}=t;return xa({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=j(t);r&&e.push(r)}function et(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function _s(e){return e.nodeKind??Y(e.gameObject)}function yo(e){let t=e.gameObject;return Z(t)?!1:mn(t)}function pM(e){let t=e.gameObject;if(Z(t)||t.transformType==="camera"||t.transformType==="light"||t.camera||t.light)return!1;let r=e.nodeKind??Y(t);return r==="instance"||r==="primitive"||r==="transform"}function gM(e){return e===1||e===2||e===3?e:0}function bM(e){let t=e.rendering?.alphaIndex;if(typeof t=="number"&&Number.isFinite(t))return t}function SM(e,t){return t==null?`${e.name} \xB7 Babylon \u9ED8\u8BA4`:`${e.name} \xB7 ${hM(e,t)}`}function yM(e,t){let r=[{label:"Babylon \u9ED8\u8BA4",value:null},...e.alphaIndexPresets.map(n=>({label:`${n.name} (${n.alphaIndex})`,value:n.alphaIndex}))];return t!=null&&!e.alphaIndexPresets.some(n=>n.alphaIndex===t)&&r.push({label:`\u672A\u547D\u540D\u503C ${t}`,value:t,batchCompatibility:"ignore"}),r}function hM(e,t){let r=e.alphaIndexPresets.find(n=>n.alphaIndex===t);return r?r.name:`\u672A\u547D\u540D\u503C ${t}`}function EM(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Ll(e){return`${Ns(e.x)}, ${Ns(e.y)}, ${Ns(e.z)}`}function Ns(e){return st(e).toString()}function zl(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function Ma(e,t){return e.assets.find(r=>r.id===t)??null}var wa=[{label:"Plain",value:"plain"},{label:"Light",value:"light"},{label:"Camera",value:"camera"}],IM=[{label:"Cube",value:"cube"},{label:"Sphere",value:"sphere"},{label:"Plane",value:"plane"},{label:"Capsule",value:"capsule"}];function mb(e){return[gb(e),bb(e.runtime),Sb(e.runtime),yb(e.runtime),hb(e.runtime),Eb(e.runtime),Ib(e.runtime),Pb(e.runtime),Tb(e.runtime),xb(e.runtime),Ab(e.runtime),Db(e.runtime),Mb(e)].filter(t=>!!t)}function Kl(e,t){if(!e.activeId)return[];let r=t.findGameObject(e.document,e.activeId);if(!r||e.targetIds&&e.targetIds.length!==1)return[];let n=ha({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return mb({runtime:n,binding:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,objectId:e.activeId,component:t.hasModelRenderer(r)?"ModelRenderer":t.hasImageRenderer(r)?"ImageRenderer":t.readNodeKind(r)==="transform"?"Transform":"GameObject",projectionNodeId:le(e.projectionNode,"id")??null,projectionName:le(e.projectionNode,"name")??null,projectionParentId:le(e.projectionNode,"parentId")??null,projectionAssetId:fb(e.projectionNode)},projectionAssetMetadata:pb(e.projectionNode)})}function fb(e){let t=z(e,"asset");return le(t,"assetId")??le(t,"id")}function pb(e){return z(z(e,"asset"),"metadata")}function gb(e){let{binding:t,runtime:r}=e,n=[];return T(n,{path:"runtime.binding.sourceId",label:"Source ID",value:t?.sourceId??"none",order:0,source:"Document"}),T(n,{path:"runtime.binding.sourceType",label:"Source Type",value:t?.sourceType??"none",order:1,source:"Document"}),T(n,{path:"runtime.binding.objectId",label:"Object ID",value:t?.objectId??"none",order:2,source:"Document"}),T(n,{path:"runtime.binding.component",label:"Component",value:t?.component??"GameObject",order:3,source:"Derived"}),T(n,{path:"runtime.projection.nodeId",label:"Projection Node ID",value:t?.projectionNodeId??"none",order:4,source:"Derived"}),T(n,{path:"runtime.projection.name",label:"Projection Name",value:t?.projectionName??"none",order:5,source:"Derived"}),T(n,{path:"runtime.projection.parentId",label:"Projection Parent",value:t?.projectionParentId??"none",order:6,source:"Derived"}),T(n,{path:"runtime.projection.assetId",label:"Projection Asset ID",value:t?.projectionAssetId??"none",order:7,source:"Asset"}),T(n,{path:"runtime.root.status",label:"Projected Root",value:r.root?"available":"not projected",order:8,source:"Runtime"}),T(n,{path:"runtime.root.className",label:"Runtime Class",value:Ht(r.root)??"none",order:9,source:"Runtime"}),T(n,{path:"runtime.root.name",label:"Runtime Name",value:le(r.root,"name")??"none",order:10,source:"Runtime"}),T(n,{path:"runtime.binding.primaryMesh",label:"Primary Mesh",value:pn(r.primaryMesh)??"none",order:11,source:"Derived"}),T(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:pn(r.material)??"none",order:12,source:"Derived"}),T(n,{path:"runtime.material.kind",label:"Material Kind",value:Cb(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?pn(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function bb(e){let t=[],r=hs(e.root)??hs(e.primaryMesh);return r?(In(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),In(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),In(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),In(t,"runtime.bounds.size","Bounds Size",r.size,t.length,"Derived")):T(t,{path:"runtime.bounds.status",label:"Bounds",value:"not available",source:"Derived"}),T(t,{path:"runtime.geometry.meshCount",label:"Mesh Count",value:e.meshes.length,source:"Derived"}),T(t,{path:"runtime.geometry.childNodeCount",label:"Child Nodes",value:e.childNodes.length,source:"Derived"}),T(t,{path:"runtime.geometry.totalVertices",label:"Total Vertices",value:Es(e.meshes,"getTotalVertices"),source:"Derived"}),T(t,{path:"runtime.geometry.totalIndices",label:"Total Indices",value:Es(e.meshes,"getTotalIndices"),source:"Derived"}),T(t,{path:"runtime.geometry.subMeshCount",label:"SubMeshes",value:e.meshes.reduce((n,o)=>n+lo(o,"subMeshes"),0),source:"Derived"}),Be({id:"geometryBox",title:"Geometry / Box",order:920,summary:r?`${e.meshes.length} mesh${e.meshes.length===1?"":"es"}`:"no bounds",collapsedByDefault:!1,properties:t})}function Sb(e){let t=e.primaryMesh??e.root,r=[];return T(r,{path:"runtime.rendering.nodeClass",label:"Node Class",value:Ht(t)??"none"}),T(r,{path:"runtime.rendering.nodeName",label:"Node Name",value:le(t,"name")??"none"}),T(r,{path:"runtime.rendering.isEnabled",label:"Enabled",value:Tl(t)??"not available"}),T(r,{path:"runtime.rendering.isVisible",label:"Is Visible",value:Te(t,"isVisible")??"not available"}),T(r,{path:"runtime.rendering.visibility",label:"Visibility",value:re(t,"visibility")??"not available"}),T(r,{path:"runtime.rendering.layerMask",label:"Layer Mask",value:re(t,"layerMask")??"not available"}),T(r,{path:"runtime.rendering.renderingGroupId",label:"Rendering Group",value:re(t,"renderingGroupId")??"not available"}),T(r,{path:"runtime.rendering.alphaIndex",label:"Alpha Index",value:re(t,"alphaIndex")??"not available"}),T(r,{path:"runtime.rendering.alwaysSelectAsActiveMesh",label:"Always Active Mesh",value:Te(t,"alwaysSelectAsActiveMesh")??"not available"}),T(r,{path:"runtime.rendering.billboardMode",label:"Billboard Mode",value:re(t,"billboardMode")??"not available"}),Be({id:"rendering",title:"Rendering",order:930,summary:le(t,"name")??Ht(t)??"not available",collapsedByDefault:!0,properties:r})}function yb(e){let t=e.primaryMesh??e.root,r=[];return T(r,{path:"runtime.collisions.checkCollisions",label:"Check Collisions",value:Te(t,"checkCollisions")??"not configured"}),T(r,{path:"runtime.collisions.collisionMask",label:"Collision Mask",value:re(t,"collisionMask")??"not configured"}),T(r,{path:"runtime.collisions.collisionGroup",label:"Collision Group",value:re(t,"collisionGroup")??"not configured"}),T(r,{path:"runtime.collisions.collisionResponse",label:"Collision Response",value:Te(t,"collisionResponse")??"not configured"}),T(r,{path:"runtime.collisions.moveWithCollisions",label:"Move With Collisions",value:typeof z(t,"moveWithCollisions")=="function"?"available":"not available"}),In(r,"runtime.collisions.ellipsoid","Ellipsoid",z(t,"ellipsoid"),r.length,"Runtime","not configured"),In(r,"runtime.collisions.ellipsoidOffset","Ellipsoid Offset",z(t,"ellipsoidOffset"),r.length,"Runtime","not configured"),Be({id:"collisions",title:"Collisions",order:940,summary:Te(t,"checkCollisions")===!0?"enabled":"not configured",collapsedByDefault:!0,properties:r})}function hb(e){let t=e.primaryMesh??e.root,r=z(t,"physicsBody"),n=z(t,"physicsImpostor"),o=r??n,a=[];return T(a,{path:"runtime.physics.status",label:"Physics",value:o?"configured":"not configured"}),T(a,{path:"runtime.physics.bodyClass",label:"Body Class",value:Ht(o)??"none"}),T(a,{path:"runtime.physics.bodyName",label:"Body Name",value:le(o,"name")??le(o,"id")??"none"}),T(a,{path:"runtime.physics.mass",label:"Mass",value:Ea(o,"mass")??"not available"}),T(a,{path:"runtime.physics.friction",label:"Friction",value:Ea(o,"friction")??"not available"}),T(a,{path:"runtime.physics.restitution",label:"Restitution",value:Ea(o,"restitution")??"not available"}),T(a,{path:"runtime.physics.disablePreStep",label:"Disable Pre Step",value:Te(o,"disablePreStep")??"not available"}),Be({id:"physics",title:"Physics",order:950,summary:o?pn(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function Eb(e){let t=e.primaryMesh??e.root,r=[];return T(r,{path:"runtime.shadows.receiveShadows",label:"Receive Shadows",value:Te(t,"receiveShadows")??"not configured"}),T(r,{path:"runtime.shadows.shadowEnabled",label:"Shadow Enabled",value:we(t,"isShadowEnabled")??"not available"}),T(r,{path:"runtime.shadows.shadowDepthWrapper",label:"Shadow Depth Wrapper",value:pn(z(e.material,"shadowDepthWrapper"))??"none"}),T(r,{path:"runtime.shadows.receivingMeshCount",label:"Receiving Meshes",value:e.meshes.filter(n=>Te(n,"receiveShadows")===!0).length,source:"Derived"}),Be({id:"shadows",title:"Shadows",order:960,summary:Te(t,"receiveShadows")===!0?"receiving":"not configured",collapsedByDefault:!0,properties:r})}function Ib(e){let t=e.material,r=[];return T(r,{path:"runtime.material.status",label:"Material",value:t?"available":"none"}),T(r,{path:"runtime.material.className",label:"Class",value:Ht(t)??"none"}),T(r,{path:"runtime.material.name",label:"Name",value:le(t,"name")??"none"}),T(r,{path:"runtime.material.id",label:"ID",value:le(t,"id")??"none"}),T(r,{path:"runtime.material.uniqueId",label:"Unique ID",value:re(t,"uniqueId")??"not available"}),T(r,{path:"runtime.material.alpha",label:"Alpha",value:re(t,"alpha")??"not available"}),T(r,{path:"runtime.material.backFaceCulling",label:"Back Face Culling",value:Te(t,"backFaceCulling")??"not available"}),T(r,{path:"runtime.material.twoSidedLighting",label:"Two Sided Lighting",value:Te(t,"twoSidedLighting")??"not available"}),T(r,{path:"runtime.material.disableLighting",label:"Disable Lighting",value:Te(t,"disableLighting")??"not available"}),T(r,{path:"runtime.material.wireframe",label:"Wireframe",value:Te(t,"wireframe")??"not available"}),T(r,{path:"runtime.material.pointsCloud",label:"Points Cloud",value:Te(t,"pointsCloud")??"not available"}),T(r,{path:"runtime.material.fillMode",label:"Fill Mode",value:re(t,"fillMode")??"not available"}),T(r,{path:"runtime.material.activeTextureCount",label:"Active Textures",value:Is(t,"getActiveTextures"),source:"Derived"}),Be({id:"material",title:"Material",order:970,summary:pn(t)??"none",collapsedByDefault:!0,properties:r})}function Pb(e){let t=e.material,r=[];T(r,{path:"runtime.material.textures.activeCount",label:"Active Texture Count",value:Is(t,"getActiveTextures"),source:"Derived"});let n=0;for(let o of vb){let a=z(t,o);a&&(n+=1,kb(r,`runtime.material.textures.${o}`,ka(o),a))}return n===0&&T(r,{path:"runtime.material.textures.status",label:"Textures",value:"none"}),Be({id:"materialTextures",title:"Material Textures",order:980,summary:n>0?`${n} slot${n===1?"":"s"}`:"none",collapsedByDefault:!0,properties:r})}function Tb(e){let t=[],r=0;for(let n of Gb){let o=z(e.material,n);wb(t,`runtime.material.colors.${n}`,ka(n),o,t.length)&&(r+=1)}return r===0&&T(t,{path:"runtime.material.colors.status",label:"Colors",value:"none"}),Be({id:"materialColors",title:"Material Colors",order:990,summary:r>0?`${r} color${r===1?"":"s"}`:"none",collapsedByDefault:!0,properties:t})}function xb(e){let t=[];for(let r of jb)T(t,{path:`runtime.material.metallicRoughness.${r}`,label:ka(r),value:re(e.material,r)??"not available"});return Be({id:"metallicRoughness",title:"Metallic / Roughness",order:1e3,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function Ab(e){let t=[];for(let r of Nb)T(t,{path:`runtime.material.intensity.${r}`,label:ka(r),value:re(e.material,r)??"not available"});return Be({id:"intensityProperties",title:"Intensity Properties",order:1010,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function Db(e){let t=e.primaryMesh??e.root,r=z(t,"skeleton"),n=[];return T(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:lo(e.root,"animations"),source:"Derived"}),T(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:lo(t,"animations"),source:"Derived"}),T(n,{path:"runtime.skeleton.status",label:"Skeleton",value:r?"available":"none"}),T(n,{path:"runtime.skeleton.className",label:"Skeleton Class",value:Ht(r)??"none"}),T(n,{path:"runtime.skeleton.name",label:"Skeleton Name",value:le(r,"name")??"none"}),T(n,{path:"runtime.skeleton.id",label:"Skeleton ID",value:le(r,"id")??"none"}),T(n,{path:"runtime.skeleton.boneCount",label:"Bones",value:lo(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?le(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function Mb(e){let{runtime:t}=e,r=[];return T(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:z(t.root,"metadata")??"none",tags:["Raw"]}),T(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:z(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),T(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:z(t.material,"metadata")??"none",tags:["Raw"]}),T(r,{path:"runtime.raw.projectionAssetMetadata",label:"Projection Asset Metadata",value:e.projectionAssetMetadata??"none",source:"Asset",tags:["Raw"]}),T(r,{path:"runtime.misc.isDisposed",label:"Root Disposed",value:we(t.root,"isDisposed")??"not available"}),Be({id:"rawMisc",title:"Raw / Misc",order:1030,summary:"metadata",collapsedByDefault:!0,properties:r})}function Be(e){return _r({id:e.id,title:e.title,order:e.order,summary:e.summary,persistence:"runtime",runtimeOnly:!0,collapsedByDefault:e.collapsedByDefault,omitWhenEmpty:!1,tags:["Runtime"],properties:e.properties})}function T(e,t){let r=j({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function In(e,t,r,n,o,a="Runtime",i){let s=Pl({basePath:t,label:r,value:n,order:o,persistence:"runtime",source:a});s.length>0?e.push(...s):i&&T(e,{path:`${t}.status`,label:r,value:i,order:o,source:a})}function wb(e,t,r,n,o){let a=Rb(n);return a?(T(e,{path:`${t}.r`,label:`${r}.r`,value:a.r,order:o,valueType:"number"}),T(e,{path:`${t}.g`,label:`${r}.g`,value:a.g,order:o+1,valueType:"number"}),T(e,{path:`${t}.b`,label:`${r}.b`,value:a.b,order:o+2,valueType:"number"}),a.a!=null&&T(e,{path:`${t}.a`,label:`${r}.a`,value:a.a,order:o+3,valueType:"number"}),!0):!1}function kb(e,t,r,n){let o=e.length;T(e,{path:`${t}.className`,label:`${r} Class`,value:Ht(n)??"Texture",order:o}),T(e,{path:`${t}.name`,label:`${r} Name`,value:le(n,"name")??"none",order:o+1}),T(e,{path:`${t}.url`,label:`${r} URL`,value:Ob(n)??"none",order:o+2}),T(e,{path:`${t}.level`,label:`${r} Level`,value:re(n,"level")??"not available",order:o+3}),T(e,{path:`${t}.coordinatesIndex`,label:`${r} UV Set`,value:re(n,"coordinatesIndex")??"not available",order:o+4}),T(e,{path:`${t}.hasAlpha`,label:`${r} Has Alpha`,value:Te(n,"hasAlpha")??"not available",order:o+5})}function Ob(e){return le(e,"url")??le(e,"name")??le(we(e,"getInternalTexture"),"url")}function Rb(e){if(!e||typeof e!="object")return null;let t=re(e,"r"),r=re(e,"g"),n=re(e,"b");if(t==null||r==null||n==null)return null;let o=re(e,"a");return o==null?{r:t,g:r,b:n}:{r:t,g:r,b:n,a:o}}function Cb(e){let t=Ht(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function ka(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var vb=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],Gb=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],jb=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],Nb=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var _b=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],Fb={zh:{hemisphericTitle:"\u73AF\u5883\u5149",directionalTitle:"\u76F4\u5C04\u5149",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"\u8BED\u8A00",type:"\u7C7B\u578B",typeHemispheric:"\u73AF\u5883\u5149",typeDirectional:"\u76F4\u5C04\u5149",intensity:"\u5F3A\u5EA6",skyLightColor:"\u5929\u7A7A\u5149\u989C\u8272",groundColor:"\u5730\u9762\u989C\u8272",lightColor:"\u5149\u7167\u989C\u8272",horizontalAngle:"\u6C34\u5E73\u89D2",elevationAngle:"\u9AD8\u5EA6\u89D2",shadowsTitle:"\u9634\u5F71",shadowsSummary:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",shadowSystem:"\u7CFB\u7EDF",shadowEnabled:"\u542F\u7528",shadowOpacity:"\u4E0D\u900F\u660E\u5EA6",shadowLength:"\u9634\u5F71\u957F\u5EA6",shadowFollowDirectional:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",openShadows:"\u6253\u5F00\u9634\u5F71\u8BBE\u7F6E",rawLight:"\u539F\u59CB\u5149\u6E90\u6570\u636E",tooltips:{language:"\u5207\u6362\u6B64\u5149\u6E90\u68C0\u67E5\u5668\u7684\u5C5E\u6027\u663E\u793A\u8BED\u8A00\u3002\u8BE5\u5B57\u6BB5\u53EA\u7528\u4E8E\u7F16\u8F91\u5668\uFF0C\u4E0D\u4F1A\u5BFC\u51FA\u5230\u8FD0\u884C\u65F6\u3002",type:"\u7CFB\u7EDF\u5149\u6E90\u7C7B\u578B\u53EA\u8BFB\u3002\u5BF9\u5E94 BabylonJS \u7684 HemisphericLight \u6216 DirectionalLight\u3002",intensity:"\u5149\u6E90\u5F3A\u5EA6\uFF0C\u5FC5\u987B\u662F\u975E\u8D1F\u6570\u3002BabylonJS \u4E0D\u8BBE\u7F6E\u786C\u4E0A\u9650\uFF1B\u767D\u8272\u6750\u8D28\u5728\u8F83\u9AD8\u5F3A\u5EA6\u4E0B\u901A\u5E38\u5DF2\u7ECF\u63A5\u8FD1\u663E\u793A\u9971\u548C\uFF0C\u7EE7\u7EED\u589E\u5927\u89C6\u89C9\u53D8\u5316\u4F1A\u4E0D\u660E\u663E\u3002",skyLightColor:"\u73AF\u5883\u5149\u6765\u81EA\u5929\u7A7A\u65B9\u5411\u7684\u6F2B\u53CD\u5C04\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.diffuse\u3002",groundColor:"\u73AF\u5883\u5149\u6765\u81EA\u5730\u9762\u53CD\u5C04\u65B9\u5411\u7684\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.groundColor\u3002",lightColor:"\u76F4\u5C04\u5149\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS DirectionalLight.diffuse\u3002",horizontalAngle:"\u76F4\u5C04\u5149\u5728 XZ \u5E73\u9762\u5185\u7684\u671D\u5411\u89D2\u5EA6\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",elevationAngle:"\u76F4\u5C04\u5149\u76F8\u5BF9\u5730\u5E73\u7EBF\u7684\u9AD8\u5EA6\u89D2\uFF1B90 \u5EA6\u8868\u793A\u4ECE\u6B63\u4E0A\u65B9\u7167\u4E0B\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",shadowSystem:"\u9634\u5F71\u7CFB\u7EDF\u53EA\u8BFB\u6458\u8981\u3002Planar \u9634\u5F71\u65B9\u5411\u6765\u81EA\u5F53\u524D\u76F4\u5C04\u5149\uFF0C\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowEnabled:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u662F\u5426\u542F\u7528\u3002\u8FD9\u91CC\u4EC5\u663E\u793A\u6458\u8981\uFF0C\u4E0D\u5728\u5149\u6E90 Inspector \u4E2D\u7F16\u8F91\u3002",shadowOpacity:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u4E0D\u900F\u660E\u5EA6\u3002\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowLength:"\u6839\u636E\u76F4\u5C04\u5149\u65B9\u5411\u4F30\u7B97\u7684\u5E73\u9762\u9634\u5F71\u957F\u5EA6\u500D\u7387\uFF1B\u9AD8\u5EA6\u89D2\u8D8A\u4F4E\uFF0C\u9634\u5F71\u8D8A\u957F\u3002",openShadows:"\u5207\u6362\u5230\u53F3\u4FA7 Rendering \u9762\u677F\uFF0C\u7F16\u8F91\u9879\u76EE\u7EA7\u9634\u5F71\u8BBE\u7F6E\u3002",rawLight:"\u7F16\u8F91\u5668\u6587\u6863\u4E2D\u7684\u5149\u6E90\u539F\u59CB\u6570\u636E\uFF0C\u53EA\u8BFB\u663E\u793A\u3002"}},en:{hemisphericTitle:"Environment Light",directionalTitle:"Directional Light",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"Language",type:"Type",typeHemispheric:"Environment Light",typeDirectional:"Directional Light",intensity:"Intensity",skyLightColor:"Sky Light Color",groundColor:"Ground Color",lightColor:"Light Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",shadowsTitle:"Shadows",shadowsSummary:"Planar Main / Follow Directional Light",shadowSystem:"System",shadowEnabled:"Enabled",shadowOpacity:"Opacity",shadowLength:"Shadow Length",shadowFollowDirectional:"Planar Main / Follow Directional Light",openShadows:"Open Shadows",rawLight:"Raw Light Data",tooltips:{language:"Switches the display language for this light inspector. This editor-only field is not exported to runtime.",type:"Read-only system light type. Maps to BabylonJS HemisphericLight or DirectionalLight.",intensity:"Light intensity. Must be a non-negative number. BabylonJS does not impose a hard upper limit; white surfaces often saturate at high intensity, so further increases may look subtle.",skyLightColor:"Diffuse sky color for the environment light. Maps to BabylonJS HemisphericLight.diffuse.",groundColor:"Ground bounce color for the environment light. Maps to BabylonJS HemisphericLight.groundColor.",lightColor:"Directional light color. Maps to BabylonJS DirectionalLight.diffuse.",horizontalAngle:"Directional light heading in the XZ plane. The editor converts it to BabylonJS DirectionalLight.direction.",elevationAngle:"Directional light elevation above the horizon; 90 degrees points straight down. The editor converts it to BabylonJS DirectionalLight.direction.",shadowSystem:"Read-only shadow system summary. Planar shadow direction follows this Directional Light; edit full settings in Rendering.",shadowEnabled:"Whether the project-level planar shadow system is enabled. This is summary-only in the light Inspector.",shadowOpacity:"Current project-level planar shadow opacity. Edit full settings in Rendering.",shadowLength:"Estimated planar shadow length multiplier from this light direction. Lower elevation makes longer shadows.",openShadows:"Switches the right dock to the Rendering panel for project-level shadow settings.",rawLight:"Read-only raw light data from the editor document."}}};function Hl(e){return Fb[e]??Fb.zh}function Wl(e){return e.inspectorLanguage==="en"?"en":"zh"}function $b(e){let{createDocumentInspectorProperty:t,gameObject:r,light:n,nodeKind:o,normalizeValue:a}=e,i=Wl(n),s=Hl(i),c=[t(null,o,{path:"light.inspectorLanguage",label:s.language,valueType:"enum",control:"enum",value:i,commitMode:"immediate",order:0,options:_b,controlOptions:{variant:"segmented"},tooltip:s.tooltips.language}),j({path:"light.type",label:s.type,value:n.type==="hemispheric"?s.typeHemispheric:s.typeDirectional,order:1,source:"Document",tooltip:s.tooltips.type}),t(null,o,{path:"light.intensity",label:s.intensity,valueType:"number",control:"number",value:n.intensity,commitMode:"live",order:2,min:0,step:.05,tooltip:s.tooltips.intensity})],d=3;if(n.type==="hemispheric")c.push(t(null,o,{path:"light.diffuseColor",label:s.skyLightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.skyLightColor})),d+=1,c.push(t(null,o,{path:"light.groundColor",label:s.groundColor,valueType:"color",control:"color",value:n.groundColor??e.defaultEnvironmentGroundColor??{r:.48,g:.52,b:.62},commitMode:"immediate",order:d,tooltip:s.tooltips.groundColor})),d+=1;else{let l=Dl(r)??{horizontalAngleDeg:0,elevationAngleDeg:90};c.push(t(null,o,{path:bn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:Ag,max:Dg,step:1,coerce:m=>a(bn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:Sn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:Ia,max:Pa,step:1,coerce:m=>a(Sn,m),tooltip:s.tooltips.elevationAngle})),d+=1,c.push(t(null,o,{path:"light.diffuseColor",label:s.lightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.lightColor})),d+=1}return TM(c,{path:"light.raw",label:s.rawLight,value:n??"defaults",order:c.length,source:"Document",tags:["Raw"],tooltip:s.tooltips.rawLight}),c}function Lb(e){let t=e.renderingProfile.shadows.planar;return _r({id:"lightShadows",title:e.text.shadowsTitle,order:46,summary:e.text.shadowsSummary,collapsedByDefault:!1,tags:["Rendering","Derived"],properties:[j({path:"rendering.shadows.summary.system",label:e.text.shadowSystem,value:e.text.shadowFollowDirectional,order:0,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowSystem,effect:"derived"}),j({path:"rendering.shadows.summary.enabled",label:e.text.shadowEnabled,value:t.enabled,order:1,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowEnabled,effect:"derived"}),j({path:"rendering.shadows.summary.opacity",label:e.text.shadowOpacity,value:st(t.appearance.color.a),order:2,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowOpacity,effect:"derived"}),j({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:AM(wg(e.light.direction)),order:3,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowLength,effect:"derived"}),xM(e.text)]})}function ql(e){let t=Hl(Wl(e.light)),r=[{id:"light",title:e.light.type==="hemispheric"?t.hemisphericTitle:t.directionalTitle,order:44,placement:"body",summary:e.light.type==="hemispheric"?t.hemisphericSummary:t.directionalSummary,persistence:"document",collapsedByDefault:!1,properties:$b(e)}];return e.light.type==="directional"&&r.push(Lb({light:e.light,text:t,renderingProfile:PM(e.renderingProfile)})),r}function PM(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function TM(e,t){let r=j(t);r&&e.push(r)}function xM(e){return{path:"rendering.shadows.summary.open",label:e.openShadows,valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:e.openShadows,icon:"world"},value:e.openShadows,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:4,tags:["Rendering"],tooltip:e.tooltips.openShadows,effect:"active"}}function AM(e){return`x${st(e)}`}function Oe(e,t,r){let n=t.split(".").filter(Boolean);if(n.some(DM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function DM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Jl(e){let t=Br(e.overrides);if(!t)return;let r=zb(t.material);r?t.material=r:delete t.material;let n=Br(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=Br(s);if(!c){delete n[i];continue}let d=zb(c.override);d?c.override=d:delete c.override,Object.keys(c).length===0&&delete n[i]}Object.keys(n).length===0&&delete t.materialSlotBindings}let o=Br(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=Br(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function zb(e){let t=Br(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=Br(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=Br(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function Br(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Pn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Vb(n,r);return JSON.stringify(o)===JSON.stringify(n)?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>a.id===t?o:a)}}}function Xl(e,t){if(t.length===0)return e;let r=new Map;for(let a of t)r.set(a.targetId,a.patch);let n=!1,o=e.scene.gameObjects.map(a=>{let i=r.get(a.id);if(!i)return a;let s=Vb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Vb(e,t){let r=Bb(e),n=MM(e,t),o=Bb(n);return r&&o&&!wM(r,o)?mo(n):n}function MM(e,t){return G(e)?{...e,components:e.components.map(r=>{if(r.type!=="Transform")return r;let n=r;return t.transform?pr(t.transform)??n:Ee(n)?n:{...n,position:t.position??n.position,rotation:t.rotation??n.rotation,scale:t.scale??n.scale}})}:e}function Bb(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function wM(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Ub(e){let t=new Set(e.targetIds);if(t.size===0||!Number.isFinite(e.fromAlphaIndex)||!Number.isFinite(e.toAlphaIndex)||e.fromAlphaIndex===e.toAlphaIndex)return e.gameObjects;let r=!1,n=e.gameObjects.map(o=>!t.has(o.id)||!kM(o,e)?o:(r=!0,{...o,rendering:{...o.rendering??{},alphaIndex:e.toAlphaIndex}}));return r?n:e.gameObjects}function Yl(e){let t=Ub({gameObjects:e.document.scene.gameObjects,targetIds:e.targetIds,renderingGroupId:e.renderingGroupId,fromAlphaIndex:e.fromAlphaIndex,toAlphaIndex:e.toAlphaIndex});return t===e.document.scene.gameObjects?e.document:{...e.document,scene:{...e.document.scene,gameObjects:t}}}function kM(e,t){return(bl(e.rendering?.renderingGroupId)??0)===t.renderingGroupId&&gg(e.rendering?.alphaIndex)===t.fromAlphaIndex}var Oa=ct,$s=Cs;function Zl(e){let t=dt(e.document.scene.gameObjects.map(n=>n.name??n.id),e.name??e.asset.displayName,{fallbackName:e.asset.assetId}),r=Oa(e.document.scene.gameObjects.map(n=>n.id),$s(t));return{label:`Place ${e.asset.displayName}`,patch:{kind:"game-object.create-from-asset",assetItem:e.asset,...e.name?{name:e.name}:{},placement:{position:{...e.hit.position},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},createdId:r,changedIds:[r]}}function Kb(e){let t=e.scene.gameObjects.filter(r=>!!Se(r)||!!jr(r)||!!r.primitive).length;return{x:t%5*1.8-3.6,y:0,z:Math.floor(t/5)*1.8+1.8}}function Ql(e,t){let r=t&&Tt(t)?t:null;return{position:r?.position?{...r.position}:Kb(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Eo(e){return e.filter(t=>NM(t.kind)&&tu(t)).map(eu).sort(ru)}function Ca(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(eu).sort(ru)}function Tn(e,t){return{assets:[...t],resourceProjection:qb(e,t)}}function qb(e,t){let r=jM(t),n=new Map(e.map(a=>[a.assetId,a])),o=[...r].sort((a,i)=>a.localeCompare(i)).flatMap(a=>{let i=n.get(a);if(!i||i.kind!=="texture"&&i.kind!=="image")return[];let s=Ve(i.relativePath),c=_i(s);if(!s||!c)return[];let d=i.kind==="texture"?"texture":"image";return[{assetId:a,kind:d,format:c,relativePath:s,...Ve(i.originalFileName)?{originalFileName:Ve(i.originalFileName)}:{},...Ve(i.contentHash)?{contentHash:Ve(i.contentHash)}:{}}]});return{schemaVersion:1,entries:o}}function eu(e){let t=e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"glb",r=Ve(e.guid),n=RM(e);return{id:e.assetId,...r?{guid:r}:{},assetId:e.assetId,type:t,kind:e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"model",displayName:e.displayName,category:e.category??OM(e),warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:Ls(e.defaults),prefab:Ls(e.prefab),external:Ls(e.external),metadata:n,origin:e.origin??"project",dedupeKey:e.dedupeKey??r??GM(e.external)??e.assetId,placeable:tu(e)}}function Jb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.kind==="texture"||t.type==="texture"}function tu(e){return Jb(e)?!0:!e||typeof e!="object"||Array.isArray(e)||e.placeable!==!1}function ru(e,t){return(e.category??"").localeCompare(t.category??"")||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)||e.type.localeCompare(t.type)}function OM(e){return e.kind==="prefab"?"Prefab":e.kind==="texture"?"Texture":e.kind==="image"?"Image":e.kind==="sound"?"Sound":"Model"}function RM(e){return CM({originalFileName:e.originalFileName,relativePath:e.relativePath,codeKey:e.codeKey,contentHash:e.contentHash,byteSize:e.byteSize,...Ls(e.metadata)})}function CM(e){if(!Array.isArray(e.materialSlots))return e;let t=ho(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=ho(c),u=Ra(d?.meshIndex),l=Ve(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=ho(c),u=Ra(d?.nodeIndex),l=Ve(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=Hb(t,"meshCount",r.length)||Hb(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=ho(c);if(!d||Ve(d.sourceMeshName))return c;let u=Ra(d.meshIndex);if(u==null)return c;let l=Ra(d.nodeIndex),m=o.get(u)??(l==null?void 0:a.get(l))??(i?vM(d):void 0);return m?{...d,sourceMeshName:m}:c});return{...e,materialSlots:s}}function vM(e){let t=Ve(e.label);if(t){let r=t.replace(/\s+\/\s+Primitive\s+\d+$/,"").trim();if(r)return r}return Ve(e.ownerNodePath)?.split("/").filter(Boolean).pop()}function Hb(e,t,r){let n=Ra(e?.[t]);return n!=null&&n>r}function GM(e){return!e||typeof e!="object"||Array.isArray(e)?null:Ve(e.platformAssetId)}function jM(e){let t=new Set;for(let r of e){let n=ho(r.metadata),o=Ve(n?.previewTextureAssetId);o&&t.add(o);let a=ho(n?.previewTextureAssetIdsBySourceAssetId);for(let i of Object.values(a??{})){let s=Ve(i);s&&t.add(s)}}return t}function Ve(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ra(e){return Number.isInteger(e)&&e>=0?e:null}function ho(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ls(e){return e==null?void 0:structuredClone(e)}function NM(e){return e==="model"||e==="prefab"||e==="texture"}function nu(e,t){let r=new Map(t.filter(a=>a.type==="glb").map(a=>[a.assetId,a])),n=e.assets.map(a=>{if(a.type!=="glb")return a;let i=r.get(a.id);return i?Vr(a,i):a}),o=new Set(e.assets.map(a=>a.id));for(let a of FM(e)){if(o.has(a))continue;let i=r.get(a);i&&(n.push(Vr({id:a,type:"glb"},i)),o.add(a))}return{...e,assets:n}}function FM(e){let t=[],r=new Set,n=o=>{let a=Ue(o);!a||r.has(a)||(r.add(a),t.push(a))};for(let o of e.assets)if(o.type==="prefab"){n(o.prefab?.sourceAssetId);for(let a of o.prefab?.nodes??[])n(a.sourceAssetId)}for(let o of e.scene.gameObjects){for(let i of o.components)i.type==="ModelRenderer"&&n(i.assetId);n(o.prefab?.sourceAssetId);let a=lt(lt(o)?.instance);n(a?.assetId)}return t}function ou(e,t){va(e,t);let r=new Map(t.filter(n=>n.type==="glb").map(n=>[n.assetId,n]));return{...e,assets:e.assets.map(n=>{if(n.type!=="glb")return structuredClone(n);let o=r.get(n.id);if(!o)throw new Error(`asset.catalog.missing: ${n.id}`);let a=o.guid??n.guid;return{id:n.id,...a?{guid:a}:{},type:"glb"}})}}function va(e,t){let r=new Map(t.map(o=>[o.assetId,o])),n=new Map(t.filter(o=>o.type==="glb").map(o=>[o.assetId,o]));for(let o of e.assets){if(o.type!=="glb")continue;let a=n.get(o.id);if(!a)throw new Error(`asset.catalog.missing: ${o.id}`);LM(o,a),$M(o,a),_M(a)}for(let o of Xb(e)){if(o.kind!=="material.textureAssetId")continue;let a=r.get(o.assetId);if(!a||a.kind!=="texture"&&a.type!=="texture")throw new Error(`asset.catalog.missing: ${o.assetId} at ${o.path}`)}}function Xb(e){let t=[],r=(o,a)=>{let i=Ue(a);i&&t.push({assetId:i,...o})};for(let o=0;o<e.scene.gameObjects.length;o+=1){let a=e.scene.gameObjects[o];for(let i=0;i<a.components.length;i+=1){let s=a.components[i];s.type!=="ModelRenderer"&&s.type!=="ImageRenderer"||r({scope:"scene-object",kind:`${s.type}.assetId`,path:`scene.gameObjects[${o}].components[${i}].assetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},s.assetId)}r({scope:"scene-object",kind:"prefab.prefabId",path:`scene.gameObjects[${o}].prefab.prefabId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.prefabId),r({scope:"scene-object",kind:"prefab.sourceAssetId",path:`scene.gameObjects[${o}].prefab.sourceAssetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.sourceAssetId),Io(a.overrides,`scene.gameObjects[${o}].overrides`,(i,s)=>r({scope:"scene-object",kind:"material.textureAssetId",path:i,objectId:a.id,...a.name?{objectName:a.name}:{}},s))}for(let o=0;o<e.assets.length;o+=1){let a=e.assets[o];if(!a.prefab)continue;let i=`assets[${o}].prefab`;r({scope:"prefab-asset",kind:"prefab.sourceAssetId",path:`${i}.sourceAssetId`,prefabAssetId:a.id},a.prefab.sourceAssetId),Io(a.prefab.overrides,`${i}.overrides`,(c,d)=>r({scope:"prefab-asset",kind:"material.textureAssetId",path:c,prefabAssetId:a.id},d));let s=Qe(a);for(let c=0;c<s.length;c+=1){let d=s[c],u=`${i}.nodes[${c}]`;r({scope:"prefab-node",kind:"node.sourceAssetId",path:`${u}.sourceAssetId`,prefabAssetId:a.id,nodeId:d.id},d.sourceAssetId),r({scope:"prefab-node",kind:"node.childPrefabId",path:`${u}.childPrefabId`,prefabAssetId:a.id,nodeId:d.id},d.childPrefabId),Io(d.overrides,`${u}.overrides`,(l,m)=>r({scope:"prefab-node",kind:"material.textureAssetId",path:l,prefabAssetId:a.id,nodeId:d.id},m))}}let n=Array.isArray(e.scene.materialAssets)?e.scene.materialAssets:[];for(let o=0;o<n.length;o+=1){let a=n[o],i=Ue(a.id)??"";r({scope:"material-asset",kind:"origin.sourceAssetId",path:`scene.materialAssets[${o}].origin.sourceAssetId`,materialAssetId:i},lt(a.origin)?.sourceAssetId),Io(a.properties,`scene.materialAssets[${o}].properties`,(s,c)=>r({scope:"material-asset",kind:"material.textureAssetId",path:s,materialAssetId:i},c))}return t.sort((o,a)=>o.path.localeCompare(a.path))}function _M(e){let t=lt(e.metadata),r=lt(e.external);if(!(Ue(t?.url)??Ue(t?.relativePath)??Ue(r?.assetUrl)))throw new Error(`asset.catalog.incomplete: ${e.assetId}.url`);let o=lt(t?.assetAnalysis),a=t?.assetAnalysisStatus==="unavailable";if(!o&&!a)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.assetAnalysisStatus`);let i=new Map((Array.isArray(o?.meshes)?o.meshes:[]).flatMap(c=>{let d=lt(c),u=d?.meshIndex,l=Number.isInteger(u)?u:void 0,m=Ue(d?.name);return l==null||!m?[]:[[l,m]]})),s=Array.isArray(t?.materialSlots)?t.materialSlots:[];for(let[c,d]of s.entries()){let u=lt(d);if(!u)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}]`);let l=Number.isInteger(u.meshIndex)?u.meshIndex:void 0;if(l!=null&&!Ue(u.sourceMeshName)&&!i.has(l))throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}].sourceMeshName`)}}function $M(e,t){let r=lt(e.metadata),n=lt(t.metadata),o=lt(e.external),a=lt(t.external),i=Ue(r?.url)??Ue(r?.relativePath)??Ue(o?.assetUrl),s=Ue(n?.url)??Ue(n?.relativePath)??Ue(a?.assetUrl);if(i&&!s)throw new Error(`asset.catalog.incomplete: ${e.id}.url`);for(let c of["materialSlots","assetAnalysis"])if(r?.[c]!==void 0&&n?.[c]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.metadata.${c}`)}function LM(e,t){for(let r of["materialMode","defaults","external","warmupCount","singleton"])if(e[r]!==void 0&&t[r]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.${r}`)}function Vr(e,t){return{...e,guid:t.guid??e.guid,displayName:t.displayName||e.displayName,category:t.category??e.category,warmupCount:t.warmupCount??e.warmupCount,singleton:t.singleton??e.singleton,materialMode:t.materialMode??e.materialMode,defaults:zs(t.defaults??e.defaults),prefab:zs(t.prefab??e.prefab),external:zs(t.external??e.external),metadata:zs(t.metadata??e.metadata)}}function zs(e){return e==null?void 0:structuredClone(e)}function Io(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>Io(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):Io(o,a,r)}}}function lt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ue(e){return(typeof e=="string"?e.trim():"")||void 0}function Ga(e,t=[]){return e?.system?.readonly===!0||e?.system?.preset==="default-pbr"||e?.system?.preset==="default-standard"||!!e&&t.includes(e.id)}function zM(e){let t=structuredClone(e??{});return xn(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,xn(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,xn(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,xn(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(xn(t.emission,"texture"),xn(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),xn(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function xn(e,t){if(!e)return;let r=e,n=r[t];if(n===null||!n||typeof n!="object"||Array.isArray(n))return;let o=n,a=typeof o.url=="string"?o.url.trim():"",i=typeof o.textureAssetId=="string"?o.textureAssetId.trim():"";a?o.url=a:delete o.url,i?o.textureAssetId=i:delete o.textureAssetId,Object.keys(o).length===0&&delete r[t]}function Yb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=nt(t,r);if(a?!ao(e.shaderId,t)||!Bt(t,null,e.shaderId,n):!Bt(t,i,e.shaderId,n))return e;let s=structuredClone(e);if(t==="name")return typeof i!="string"?e:(s.name=i.trim(),s.name===e.name?e:s);if(!t.startsWith("properties."))return e;let c=t.slice(11);return!c||(s.properties=structuredClone(s.properties),BM(s.properties,c,i,a)||Oe(s.properties,c,i),De(s.shaderId)&&(s.properties=zM(s.properties)),no(s.shaderId,s.properties,"properties",n).length>0)||JSON.stringify(s)===JSON.stringify(e)?e:s}function BM(e,t,r,n){let o=t.endsWith(".textureAssetId")?"textureAssetId":t.endsWith(".url")?"url":null;if(!o)return!1;let a=t.slice(0,-`.${o}`.length);if(!a.endsWith(".texture")&&!a.endsWith(".maskTexture"))return!1;let i=a.split(".").filter(Boolean);if(i.length<2)return!1;let s=i[i.length-1],c=e;for(let l of i.slice(0,-1)){let m=c[l];if(!m||typeof m!="object"||Array.isArray(m)){if(n)return!0;let f={};c[l]=f,c=f;continue}c=m}if(n)return delete c[s],!0;if(r==null)return c[s]=null,!0;let d=c[s],u=d&&typeof d=="object"&&!Array.isArray(d)?{...d}:{};return u[o]=r,delete u[o==="url"?"textureAssetId":"url"],c[s]=u,!0}var An="mat_default_pbr",Po="mat_default_standard",VM="00000000-0000-4000-8000-000000000001",UM="00000000-0000-4000-8000-000000000002",Dn=An,Mn={id:An,guid:VM,name:"Default PBR Material",shaderId:"fps.builtin.pbr",definitionVersion:1,system:{readonly:!0,preset:"default-pbr"},origin:{type:"preset"},properties:Nd("fps.builtin.pbr")},KM={id:Po,guid:UM,name:"Default Standard Material",shaderId:"fps.builtin.standard",definitionVersion:1,system:{readonly:!0,preset:"default-standard"},origin:{type:"preset"},properties:Nd("fps.builtin.standard")};function HM(){return structuredClone(Mn)}function WM(){return structuredClone(KM)}function Zb(e){let t=[HM(),WM()],r=new Set(t.map(o=>o.id)),n=[...t,...e.filter(o=>!r.has(o.id))];return JSON.stringify(n)===JSON.stringify(e)?e:n}function Qb(e){return e?.system?.preset==="default-pbr"||e?.id===An?"default-pbr":e?.system?.preset==="default-standard"||e?.id===Po?"default-standard":null}function ja(e){let t=structuredClone(Mn.properties);if(!e||typeof e!="object")return t;let r={...t,...structuredClone(e)};return r.baseColor={...t.baseColor??{},...e.baseColor??{}},(t.normal||e.normal)&&(r.normal={...t.normal??{},...e.normal??{}}),(t.metallicRoughness||e.metallicRoughness)&&(r.metallicRoughness={...t.metallicRoughness??{},...e.metallicRoughness??{}}),(t.occlusion||e.occlusion)&&(r.occlusion={...t.occlusion??{},...e.occlusion??{}}),r.emission={...t.emission??{},...e.emission??{}},(t.alpha||e.alpha)&&(r.alpha={...t.alpha??{},...e.alpha??{}}),r}function wn(e,t){let r=[...new Set(e.sourceSurfaces.map(s=>s.sourceMaterialIndex).filter(s=>Number.isInteger(s)))],n=e.materialNames??[],o=r.findIndex(s=>s===t),a=o>=0?n[o]??(r.length===1?e.materialName:null):null;if(typeof a=="string"&&a.trim())return a.trim();let i=To(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function To(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var au=[An,Po],qM="New Material";function eS(e,t,r=`${t.displayName} Material`){let n=Na(e);return{id:ur(n),guid:n,name:Bs(e,r),shaderId:t.shaderId,definitionVersion:t.version,origin:{type:"created"},properties:structuredClone(t.defaultProperties)}}function JM(e,t,r){let n=t.name?.trim()||t.id,o=r.name?.trim()||r.id,a=Na(e);return{id:ur(a),guid:a,name:`${n} - ${o}`,shaderId:r.shaderId,...r.definitionVersion!=null?{definitionVersion:r.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:r.id},properties:structuredClone(r.properties)}}function tS(e,t,r){let n=t.name?.trim()||t.id,o=Na(e);return{id:ur(o),guid:o,name:Bs(e,r??`${n} Copy`),shaderId:t.shaderId,...t.definitionVersion!=null?{definitionVersion:t.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:t.id},properties:structuredClone(t.properties)}}function XM(e,t){let r=Na(e);return{id:ur(r),guid:r,name:Bs(e,t.name),shaderId:Mn.shaderId,definitionVersion:Mn.definitionVersion,origin:{type:"created",...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:ja(t.profile)}}function rS(e,t){let r=`${t.sourceAssetGuid||t.sourceAssetId}:material:${t.sourceMaterialIndex}`,n=Bp(r),o=ur(n),i=(e.scene.materialAssets??[]).some(s=>s.id===o||s.guid===n)?Na(e):n;return{id:ur(i),guid:i,name:Bs(e,t.name),shaderId:Mn.shaderId,definitionVersion:Mn.definitionVersion,origin:{type:"imported",sourceAssetId:t.sourceAssetId,...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},...t.sourceSlotId?{sourceSlotId:t.sourceSlotId}:{},sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:ja(t.profile)}}function nS(e,t,r){let n=t.trim(),o=e.scene.materialAssets?.findIndex(s=>s.id===n)??-1;if(o<0||r.id!==n)return e;let a=e.scene.materialAssets[o];if(JSON.stringify(a)===JSON.stringify(r))return e;let i=[...e.scene.materialAssets];return i[o]=structuredClone(r),{...e,scene:{...e.scene,materialAssets:i}}}function Na(e){let t=new Set((e.scene.materialAssets??[]).map(o=>o.id)),r=al(),n=ur(r);for(;t.has(n);)r=al(),n=ur(r);return r}function Bs(e,t){let r=nt("name",t),n=typeof r=="string"&&Bt("name",r)?r:qM,o=new Set((e.scene.materialAssets??[]).map(s=>s.name?.trim()).filter(s=>!!s).map(s=>s.toLocaleLowerCase()));if(!o.has(n.toLocaleLowerCase()))return n;let a=2,i=`${n} ${a}`;for(;o.has(i.toLocaleLowerCase());)a+=1,i=`${n} ${a}`;return i}function oS(e){let t=ee(e.document,e.sourceMaterialAssetId);if(!t||e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let r=JM(e.document,e.gameObject,t);return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function aS(e){if(e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let t=`${e.gameObject.name?.trim()||e.gameObject.id} - ${e.sourceSlotId}`,r=XM(e.document,{profile:e.profile,name:e.sourceMaterialName?.trim()||t,...e.sourceAsset?.id?{sourceAssetId:e.sourceAsset.id}:{},...e.sourceAsset?.guid?{sourceAssetGuid:e.sourceAsset.guid}:{},sourceSlotId:e.sourceSlotId,sourceMaterialIndex:e.sourceMaterialIndex,...e.sourceMaterialName?.trim()?{sourceMaterialName:e.sourceMaterialName.trim()}:{}});return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function Vs(e,t,r,n,o,a){let i=e.scene.materialAssets??[],s=!1,c=i.map(d=>{if(d.id!==t)return d;let u=Yb(d,r,nt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function iS(e,t,r=[]){let n=ee(e,t),o=cl(e,t);return n?Ga(n,r)?{ok:!1,reason:"readonly",materialAsset:n,usages:o}:o.length>0?{ok:!1,reason:"in-use",materialAsset:n,usages:o}:{ok:!0,materialAsset:n,usages:o}:{ok:!1,reason:"missing",usages:o}}function sS(e,t){return iS(e,t,au)}function YM(e,t,r=[]){return iS(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function iu(e){return Ga(e,au)}function cS(e,t){return YM(e,t,au)}function Us(e,t){return Ut(e,t.id)?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(t)]}}}function dS(e,t,r,n){return Ut(e,n.id)?e:ZM({...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(n)]}},t,r,n.id)}function ZM(e,t,r,n){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(o=>{if(o.id!==t)return o;let a=structuredClone(o);return QM(a,r,n),a})}}}function QM(e,t,r){let n=ew(t)??t.split(".").filter(Boolean);if(n.some(tw))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function ew(e){let t=zt(e,"materialAssetId");return t?["overrides","materialSlotBindings",t,"materialAssetId"]:null}function tw(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Hs(e,t){let r=Se(t),n=r?e.assets.find(b=>b.id===r.assetId):null,o=typeof n?.guid=="string"&&n.guid.trim()?n.guid.trim():n?.id,a=fs(e,t),i=new Map(a.filter(b=>!!b.slotId).map(b=>[b.slotId,b])),s=t.overrides?.materialSlotBindings??{},c=rw({document:e,assetId:n?.id,assetGuid:o,currentSlots:a,materialSlotBindings:s}),d=c.remaps,u=new Map(d.map(b=>[b.toSlotId,b])),l=new Set([...d.map(b=>b.fromSlotId),...c.coalescedSourceSlotIds]),m=new Map;for(let[b,S]of Object.entries(s))!S||l.has(b)||m.set(b,S);for(let b of d){let S=s[b.fromSlotId];S&&m.set(b.toSlotId,S)}let f=[];for(let[b,S]of a.entries()){let y=S.slotId?m.get(S.slotId):void 0,I=xo(y),E=I?ee(e,I):null,D=uS(S),x=D[0],N=S.slotId?u.get(S.slotId):void 0;if(N){f.push({status:"changed",reason:"slot-remapped",...S.slotId?{slotId:S.slotId}:{},previousSlotId:N.fromSlotId,ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...x==null?{}:{sourceMaterialIndex:x},...D.length>0?{sourceMaterialIndices:D}:{},materialAssetId:I,bindingPath:`overrides.materialSlotBindings.${S.slotId}.materialAssetId`,conflict:!1});continue}let B=mS(E,o,n?.id)?.sourceMaterialIndex;if(B!=null&&D.length>0&&!D.includes(B)){f.push(lS({status:"changed",reason:"source-material-changed",...S.slotId?{slotId:S.slotId}:{},ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...x==null?{}:{sourceMaterialIndex:x},...D.length>0?{sourceMaterialIndices:D}:{},previousSourceMaterialIndex:B,...I?{materialAssetId:I}:{},bindingPath:S.slotId?`overrides.materialSlotBindings.${S.slotId}.materialAssetId`:""}));continue}if(!I&&D.length>0){f.push({status:"unchanged",reason:"slot-current",...S.slotId?{slotId:S.slotId}:{},ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...x==null?{}:{sourceMaterialIndex:x},...D.length>0?{sourceMaterialIndices:D}:{},bindingPath:S.slotId?`overrides.materialSlotBindings.${S.slotId}.materialAssetId`:"",conflict:!1});continue}f.push({status:"unchanged",reason:"slot-current",...S.slotId?{slotId:S.slotId}:{},ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...x==null?{}:{sourceMaterialIndex:x},...D.length>0?{sourceMaterialIndices:D}:{},...I?{materialAssetId:I}:{},bindingPath:S.slotId?`overrides.materialSlotBindings.${S.slotId}.materialAssetId`:"",conflict:!1})}for(let[b,S]of Object.entries(s))!S||i.has(b)||l.has(b)||f.push(lS({status:"removed",reason:"slot-removed",slotId:b,...xo(S)?{materialAssetId:xo(S)}:{},bindingPath:`overrides.materialSlotBindings.${b}.materialAssetId`}));let g=f.filter(ow);return{gameObjectId:t.id,...t.name?{gameObjectName:t.name}:{},...n?.id?{assetId:n.id}:{},...o?{assetGuid:o}:{},ok:g.length===0,items:f,issues:g,bindingRemaps:d,bindingRemapIssues:c.issues,counts:aw(f)}}function rw(e){let t=new Set(e.currentSlots.map(d=>d.slotId).filter(d=>!!d)),r=new Set(Object.keys(e.materialSlotBindings).filter(d=>t.has(d))),n=[],o=[],a=new Map;for(let[d,u]of Object.entries(e.materialSlotBindings)){if(!u||t.has(d))continue;let l=xo(u),m=l?ee(e.document,l):null,f=mS(m,e.assetGuid,e.assetId);if(!f){o.push({fromSlotId:d,materialAssetId:l,reason:"binding-unmatched",candidateSlotIds:[]});continue}let g=e.currentSlots.filter(b=>!!b.slotId&&uS(b).includes(f.sourceMaterialIndex)).map(b=>b.slotId);a.set(d,{materialAssetId:l,candidateSlotIds:g,binding:u,anchored:f.sourceSlotId===d})}let i=new Map;for(let[d,u]of a){if(u.candidateSlotIds.length!==1)continue;let[l]=u.candidateSlotIds,m=i.get(l)??[];m.push(d),i.set(l,m)}let s=new Set,c=new Set;for(let[d,u]of i){u.forEach(b=>c.add(b));let l=u.filter(b=>a.get(b)?.anchored).sort((b,S)=>b.localeCompare(S));if(l.length===0){for(let b of u){let S=a.get(b);o.push({fromSlotId:b,materialAssetId:S.materialAssetId,reason:"binding-unmatched",candidateSlotIds:[]})}continue}let m=l[0],f=a.get(m);if(!u.every(b=>nw(f.binding,a.get(b).binding))||r.has(d)){for(let b of u){let S=a.get(b);o.push({fromSlotId:b,materialAssetId:S.materialAssetId,reason:"binding-ambiguous",candidateSlotIds:[d]})}continue}r.add(d),n.push({fromSlotId:m,toSlotId:d,materialAssetId:f.materialAssetId,reason:"source-material-index",...u.length>1?{coalescedFromSlotIds:u.filter(b=>b!==m).sort((b,S)=>b.localeCompare(S))}:{}});for(let b of u)b!==m&&s.add(b)}for(let[d,u]of a)c.has(d)||o.push({fromSlotId:d,materialAssetId:u.materialAssetId,reason:u.anchored&&u.candidateSlotIds.length>0?"binding-ambiguous":"binding-unmatched",candidateSlotIds:u.anchored?u.candidateSlotIds:[]});return{remaps:n,issues:o,coalescedSourceSlotIds:[...s].sort((d,u)=>d.localeCompare(u))}}function nw(e,t){return xo(e)===xo(t)&&su(e.override,t.override)}function su(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>su(i,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let r=e,n=t,o=Object.keys(r).sort(),a=Object.keys(n).sort();return o.length===a.length&&o.every((i,s)=>i===a[s]&&su(r[i],n[i]))}function uS(e){return ot(e)}function mS(e,t,r){if(e?.origin?.type!=="imported")return null;let n=e.origin.sourceMaterialIndex;if(typeof n!="number"||!Number.isInteger(n))return null;let o=e.origin.sourceAssetGuid,a=e.origin.sourceAssetId;if((o||a)&&!(!!t&&!!o&&o===t)&&!(!!r&&!!a&&a===r)||!o&&!a&&(t||r))return null;let c=typeof e.origin.sourceSlotId=="string"&&e.origin.sourceSlotId.trim()?e.origin.sourceSlotId.trim():void 0;return{sourceMaterialIndex:n,...c?{sourceSlotId:c}:{}}}function Ks(e,t){return e.label?.trim()||Kt(e)?.trim()||e.slotId?.trim()||`Slot ${t+1}`}function xo(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function lS(e){return{...e,conflict:!0}}function ow(e){return e.conflict}function aw(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{unchanged:0,added:0,removed:0,changed:0,conflict:0})}function Ws(e){let t=us(e);if(t.ok)return;let r=new Error(`editor_scene_material_assets_missing: ${t.missingMaterialAssetIds.join(", ")}`);throw r.details={missingMaterialAssetIds:t.missingMaterialAssetIds,missingReferences:t.missingReferences.map(n=>({materialAssetId:n.materialAssetId,gameObjectId:n.gameObjectId,bindingPath:n.bindingPath,label:n.label,kind:n.kind,...n.slotId?{slotId:n.slotId}:{},...n.ownerNodePath?{ownerNodePath:n.ownerNodePath}:{}}))},r}function iw(e,t){let r=!1;return{gameObjects:t.map(o=>{let a=Hs(e,o);if(a.bindingRemaps.length===0)return o;let i=o;for(let s of a.bindingRemaps){let c=i.overrides?.materialSlotBindings?.[s.fromSlotId];if(!(!c||i.overrides?.materialSlotBindings?.[s.toSlotId])){i=structuredClone(i),i.overrides=i.overrides??{},i.overrides.materialSlotBindings=i.overrides.materialSlotBindings??{},i.overrides.materialSlotBindings[s.toSlotId]=structuredClone(c),delete i.overrides.materialSlotBindings[s.fromSlotId];for(let d of s.coalescedFromSlotIds??[])delete i.overrides.materialSlotBindings[d];Object.keys(i.overrides.materialSlotBindings).length===0&&delete i.overrides.materialSlotBindings,r=!0}}return i}),changed:r}}function fS(e,t,r){let n=iw({...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},r);return{materialAssets:t,gameObjects:n.gameObjects,changed:n.changed}}function pS(e,t){let r=bS(t);if(r.length===0)return sw(e);let n={};for(let a of e.scene.materialAssets??[]){let i=a.origin;if(!i||!Number.isInteger(i.sourceMaterialIndex))continue;(i.sourceAssetGuid&&t.guid?i.sourceAssetGuid===t.guid:i.sourceAssetId===t.assetId)&&(n[String(i.sourceMaterialIndex)]=a.id)}let o=[];for(let a of r)for(let i of a.sourceMaterialProfiles??[]){let s=String(i.sourceMaterialIndex);if(n[s]||!i.profile)continue;let c=o.length===0?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},d=rS(c,{profile:i.profile,name:i.materialName?.trim()||`${t.displayName} Material ${i.sourceMaterialIndex+1}`,sourceAssetId:t.assetId,...t.guid?{sourceAssetGuid:t.guid}:{},sourceSlotId:a.slotId,sourceMaterialIndex:i.sourceMaterialIndex,...i.materialName?.trim()?{sourceMaterialName:i.materialName.trim()}:{}});o.push(d),n[s]=d.id}return o.length===0?{document:e,createdMaterialAssetIds:[],materialAssetIdsBySourceMaterialIndex:n}:{document:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},createdMaterialAssetIds:o.map(a=>a.id),materialAssetIdsBySourceMaterialIndex:n}}function gS(e,t,r){let n={};for(let o of bS(t)){let a=ot(o);if(a.length!==1)continue;let i=r[String(a[0])];i&&(n[o.slotId]={materialAssetId:i})}return Object.keys(n).length===0?e:{...e,overrides:{...e.overrides??{},materialSlotBindings:{...e.overrides?.materialSlotBindings??{},...n}}}}function bS(e){if(e.type!=="glb"&&e.type!=="gltf")return[];let t=e.metadata?.materialSlots;return Array.isArray(t)?t.map(Gr).filter(r=>!!r):[]}function sw(e){return{document:e,createdMaterialAssetIds:[],materialAssetIdsBySourceMaterialIndex:{}}}function SS(e,t){let r=new Set,n=e.properties,o=kn(n)?n:{},a=kn(t.defaultProperties)?t.defaultProperties:{},i=yS(t.propertiesSchema,o,a,"properties",r),s=new Set;hS(o,"properties",s);let c=[...s].filter(d=>!r.has(d)).sort();return{materialAsset:{...structuredClone(e),shaderId:t.shaderId,definitionVersion:t.version,properties:i},preservedPaths:[...r].sort(),resetPaths:c}}function yS(e,t,r,n,o){if(e.kind!=="object")return cw(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=kn(t)?t:{},i=kn(r)?r:{},s={};for(let[c,d]of Object.entries(e.properties)){let u=Object.prototype.hasOwnProperty.call(a,c),l=Object.prototype.hasOwnProperty.call(i,c);if(!u&&!l)continue;let m=yS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function cw(e,t){if(e.kind==="number")return typeof t=="number"&&Number.isFinite(t)&&(e.min==null||t>=e.min)&&(e.max==null||t<=e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"||t===null&&e.nullable===!0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return cu(t,e.channels===4?["r","g","b","a"]:["r","g","b"]);if(e.kind==="vec2")return cu(t,["x","y"]);if(e.kind==="vec3")return cu(t,["x","y","z"]);if(t===null)return!0;if(!kn(t))return!1;let r=Object.keys(t);return r.every(n=>n==="url"||n==="textureAssetId")&&r.every(n=>typeof t[n]=="string"&&!!t[n].trim())}function hS(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;kn(o)&&!dw(o)?hS(o,a,r):r.add(a)}}function dw(e){let t=Object.keys(e);return t.length===0?!0:t.every(r=>["r","g","b","a"].includes(r))||t.every(r=>["x","y","z"].includes(r))||t.every(r=>r==="url"||r==="textureAssetId")}function cu(e,t){return kn(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function kn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function lw(e){return e?.system?.preset}function IS(e,t){let r=lw(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function qs(e,t){let r=t.trim();return r?e?.find(n=>n.url===r||n.id===r)??null:null}function ES(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function PS(e){let t=e.currentTexture??qs(e.textureAssets,e.currentValue),r=e.currentValue.trim(),n=!!r&&!t,o=!!t&&!t.disabled&&!!t.url.trim(),a=n?"missing":t?o?"ready":"failed":void 0,i=e.candidateValue??"url",s=(e.textureAssets??[]).filter(uw);return{pickerKind:"texture",pickerTitle:e.pickerText.texturePickerTitle,pickerTrigger:"preview",placeholder:e.pickerText.emptyTexture,currentLabel:n?e.pickerText.missingTexture:t?.label??(r||e.pickerText.emptyTexture),currentMeta:n?`${e.pickerText.missingTextureMeta} \xB7 ${r}`:t?.previewUnavailableReason??t?.meta??(r||e.pickerText.emptyTextureMeta),...a?{currentResourceState:a}:{},...r?{currentResourceReference:r}:{},resourceStatusText:{missing:e.pickerText.missingTexture,loading:e.pickerText.loadingTexture,failed:e.pickerText.failedTexture},currentPreview:o?ES(t,e.pickerText):void 0,candidates:[{label:e.pickerText.clearTexture,value:"",meta:e.pickerText.clearTextureMeta},...s.map(c=>({label:c.label,value:i==="assetId"?c.id:c.url,meta:c.meta??c.id,kind:"texture",...typeof c.width=="number"?{width:c.width}:{},...typeof c.height=="number"?{height:c.height}:{},...!c.disabled&&c.url.trim()?{preview:ES(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function uw(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function TS(e){return{path:`${e.pathPrefix??lr}${e.materialAsset.id}.${e.fieldPath}`,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.commitMode,order:e.order,tooltip:e.tooltip,tags:e.tags??["ArtistMaterial","MaterialAsset"],document:e.document}}var xS={zh:{title:"\u7F8E\u672F\u6750\u8D28",slotTitle:"\u6750\u8D28\u63D2\u69FD",language:"\u8BED\u8A00",materialAsset:"\u6750\u8D28\u8D44\u4EA7",materialCard:"\u5F53\u524D\u6750\u8D28",inheritNone:"\u7EE7\u627F / \u65E0",defaultMaterial:"\u9ED8\u8BA4 PBR \u6750\u8D28",defaultMaterialMeta:"BabylonJS \u9ED8\u8BA4 PBR \u6750\u8D28",defaultStandardMaterial:"\u9ED8\u8BA4 Standard \u6750\u8D28",defaultStandardMaterialMeta:"BabylonJS \u9ED8\u8BA4 Standard \u6750\u8D28",defaultMaterialReadOnly:"\u7CFB\u7EDF\u9ED8\u8BA4\u6750\u8D28\u4E3A\u53EA\u8BFB\uFF1B\u8BF7\u9009\u62E9\u53EF\u7F16\u8F91\u6750\u8D28\u7403\u540E\u8C03\u6574\u53C2\u6570\u3002",replace:"\u66FF\u6362",batchReplaceUnsupported:"\u591A\u9009\u7EDF\u4E00\u66FF\u6362\u6750\u8D28\u6682\u672A\u63A5\u5165\uFF1B\u8BF7\u5148\u5355\u9009\u5BF9\u8C61\u66FF\u6362\u6750\u8D28\u3002",duplicateForObject:"\u590D\u5236",materialPickerTitle:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7",texturePickerTitle:"\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",emptyTexture:"\u9009\u62E9\u8D34\u56FE",emptyTextureMeta:"\u70B9\u51FB\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",inheritTexture:"\u7EE7\u627F\u6E90\u8D34\u56FE",inheritTextureMeta:"\u4F7F\u7528 GLB / source material \u8D34\u56FE\uFF08\u82E5\u5B58\u5728\uFF09",clearTexture:"\u6E05\u9664\u8D34\u56FE",clearTextureMeta:"\u4E0D\u4F7F\u7528\u8D34\u56FE",missingTexture:"\u8D34\u56FE\u8D44\u4EA7\u7F3A\u5931",missingTextureMeta:"\u5F53\u524D\u5F15\u7528\u65E0\u6CD5\u5728\u9879\u76EE\u8D44\u4EA7\u5E93\u4E2D\u89E3\u6790",loadingTexture:"\u6B63\u5728\u52A0\u8F7D\u8D34\u56FE",failedTexture:"\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25",assetProfile:"\u8D44\u4EA7\u53C2\u6570",assetProfileEmpty:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u540E\u53EF\u7F16\u8F91\u8D44\u4EA7\u53C2\u6570",assetName:"\u8D44\u4EA7\u540D\u79F0",assetKind:"Shader",assetKindPbr:"PBR \u6807\u51C6\u6750\u8D28\u7403",assetKindStandard:"Standard \u6807\u51C6\u6750\u8D28\u7403",assetLightingModel:"\u5149\u7167\u6A21\u578B",assetLightingModelLit:"\u53D7\u5149\u7167",assetLightingModelUnlit:"\u4E0D\u53D7\u5149\u7167",assetBaseColor:"\u57FA\u7840\u8272",assetBaseTexture:"\u57FA\u7840\u8D34\u56FE",assetBrightness:"\u8D34\u56FE\u4EAE\u5EA6",assetSaturation:"\u8D34\u56FE\u9971\u548C\u5EA6",assetContrast:"\u8D34\u56FE\u5BF9\u6BD4\u5EA6",assetHue:"\u8D34\u56FE\u8272\u76F8",assetNormalTexture:"\u6CD5\u7EBF\u8D34\u56FE",assetNormalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6",assetMetallic:"\u91D1\u5C5E\u5EA6",assetRoughness:"\u7C97\u7CD9\u5EA6",assetMetallicRoughnessTexture:"\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE",assetOcclusionTexture:"AO \u8D34\u56FE",assetOcclusionStrength:"AO \u5F3A\u5EA6",resetValue:"\u6062\u590D Shader \u9ED8\u8BA4\u503C",modifiedValue:"\u5DF2\u504F\u79BB Shader \u9ED8\u8BA4\u503C",inactiveReasons:{baseTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u57FA\u7840\u8D34\u56FE\u65F6\u751F\u6548\u3002",litMaterial:"\u4EC5\u5728\u201C\u53D7\u5149\u7167\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",normalTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\u65F6\u751F\u6548\u3002",occlusionTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9 AO \u8D34\u56FE\u65F6\u751F\u6548\u3002",alphaBlend:"\u4EC5\u5728\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaMask:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaTransparency:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6216\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002"},assetEmissionColor:"\u81EA\u53D1\u5149\u8272",assetEmissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6",assetEmissionTexture:"\u81EA\u53D1\u5149\u8D34\u56FE",assetEmissionMaskUrl:"\u906E\u7F69\u8D34\u56FE",assetAlphaMode:"\u900F\u660E\u6A21\u5F0F",assetAlphaModeOpaque:"\u4E0D\u900F\u660E",assetAlphaModeMask:"\u906E\u7F69",assetAlphaModeBlend:"\u534A\u900F\u660E",assetAlphaOpacity:"\u4E0D\u900F\u660E\u5EA6",assetAlphaCutoff:"Alpha \u9608\u503C",assetAlphaTexture:"Alpha \u8D34\u56FE",createSlotMaterial:"\u6DFB\u52A0\u6750\u8D28\u69FD",slotList:"\u69FD\u5217\u8868",slotId:"\u69FD ID",slotOwnerPath:"\u69FD\u8282\u70B9\u8DEF\u5F84",slotMaterialAsset:"\u69FD\u6750\u8D28\u8D44\u4EA7",slotSourceMaterial:"\u6E90\u6750\u8D28",slotBindingPath:"\u7ED1\u5B9A\u8DEF\u5F84",reimportConflicts:"\u91CD\u5BFC\u5165\u6750\u8D28\u51B2\u7A81",summaryAsset:e=>`\u8D44\u4EA7\uFF1A${e}`,summaryMissingAsset:"\u8D44\u4EA7\u7F3A\u5931",summaryCustomOverride:"\u81EA\u5B9A\u4E49\u53C2\u6570",summaryInherit:"\u7EE7\u627F",summaryAddSlot:"\u6DFB\u52A0\u69FD",summarySlotCount:e=>`${e} \u4E2A\u69FD`,formatUsageCount:e=>e>0?`\u88AB ${e} \u5904\u4F7F\u7528`:"\u672A\u88AB\u4F7F\u7528",formatMaterialEditImpact:e=>e<=0?"\u5F53\u524D\u672A\u88AB\u573A\u666F\u4F7F\u7528\uFF0C\u4FEE\u6539\u53EA\u4F1A\u6539\u53D8\u6750\u8D28\u8D44\u4EA7\u672C\u8EAB\u3002":e===1?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u5F53\u524D\u7ED1\u5B9A\u3002":`\u5171\u4EAB\u6750\u8D28\uFF0C\u4FEE\u6539\u4F1A\u5F71\u54CD ${e} \u5904\u7ED1\u5B9A\u3002`,formatDuplicateMaterialImpact:e=>e<=0?"\u590D\u5236\u540E\u521B\u5EFA\u4E00\u4E2A\u53EF\u72EC\u7ACB\u7F16\u8F91\u7684\u6750\u8D28\u8D44\u4EA7\u3002":e===1?"\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\u3002":`\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\uFF0C\u539F ${e} \u5904\u5171\u4EAB\u7ED1\u5B9A\u4E0D\u88AB\u7EE7\u7EED\u4FEE\u6539\u3002`,formatReimportConflictSummary:e=>`\u68C0\u6D4B\u5230 ${e} \u4E2A\u6750\u8D28\u69FD\u91CD\u5BFC\u5165\u5DEE\u5F02\uFF1B\u5DF2\u4FDD\u7559\u73B0\u6709\u7ED1\u5B9A\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4\u4E0D\u53EF\u5339\u914D\u9879\u3002`,tooltips:{language:"\u5207\u6362\u7F8E\u672F\u6750\u8D28 Inspector \u7684\u663E\u793A\u8BED\u8A00\u3002",materialAsset:"\u9009\u62E9\u9879\u76EE\u7EA7\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\uFF0C\u6216\u4F7F\u7528\u53EA\u8BFB\u7684\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotMaterialAsset:"\u672A\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u65F6\u4FDD\u7559 GLB \u539F\u59CB\u6750\u8D28\uFF1B\u9009\u62E9\u540E\u53EA\u8986\u76D6\u5F53\u524D\u6750\u8D28\u63D2\u69FD\u3002",baseTexture:"\u9009\u62E9\u9879\u76EE\u8D34\u56FE\u4F5C\u4E3A\u57FA\u7840\u8D34\u56FE\u3002\u8D34\u56FE\u8C03\u8272\u53C2\u6570\u4F1A\u5148\u4F5C\u7528\u4E8E\u8FD9\u5F20\u8D34\u56FE\u3002",assetProfile:"\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u7684\u53C2\u6570\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u8D44\u4EA7\u7684\u8282\u70B9\u3002",assetName:"\u6750\u8D28\u8D44\u4EA7\u540D\u79F0\u53EA\u7528\u4E8E\u5C55\u793A\uFF1B\u7ED1\u5B9A\u4F7F\u7528\u7A33\u5B9A\u6750\u8D28 ID\uFF0C\u4E0D\u53D7\u91CD\u547D\u540D\u5F71\u54CD\u3002",assetKind:"\u9009\u62E9\u8BE5\u6750\u8D28\u5F15\u7528\u7684 Shader Definition\uFF1B\u5207\u6362\u65F6\u4F1A\u4FDD\u7559\u517C\u5BB9\u53C2\u6570\u3002",lightingModel:"\u53D7\u5149\u7167\u6750\u8D28\u4F1A\u54CD\u5E94\u73AF\u5883\u5149\u548C\u76F4\u5C04\u5149\uFF1B\u4E0D\u53D7\u5149\u7167\u6750\u8D28\u9002\u5408 UI\u3001\u7279\u6548\u3001\u56FE\u6807\u548C\u5BFC\u89C6\u6807\u8BB0\u3002",baseColor:"\u57FA\u7840\u8272\u4F5C\u4E3A\u989C\u8272\u56E0\u5B50\uFF0C\u4F1A\u5728\u57FA\u7840\u8D34\u56FE\u5B8C\u6210\u8C03\u8272\u540E\u53C2\u4E0E\u76F8\u4E58\u3002\u4FEE\u6539\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u6750\u8D28\u7403\u7684\u8282\u70B9\u3002",duplicateForObject:"\u590D\u5236\u5F53\u524D\u6750\u8D28\u7403\u4E3A\u8FD9\u4E2A\u5BF9\u8C61\u6216\u69FD\u7684\u72EC\u7ACB\u6750\u8D28\uFF0C\u7136\u540E\u81EA\u52A8\u66FF\u6362\u7ED1\u5B9A\u3002",brightness:"\u57FA\u7840\u8D34\u56FE\u4EAE\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",saturation:"\u57FA\u7840\u8D34\u56FE\u9971\u548C\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",contrast:"\u57FA\u7840\u8D34\u56FE\u5BF9\u6BD4\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",hue:"\u57FA\u7840\u8D34\u56FE\u8272\u76F8\u504F\u79FB\uFF0C\u5355\u4F4D\u4E3A\u5EA6\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",normalTexture:"\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\uFF0C\u8FD0\u884C\u65F6\u5E94\u7528\u5230 PBR/Standard \u6750\u8D28\u7684 bump/normal \u901A\u9053\u3002",normalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",metallic:"\u91D1\u5C5E\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",roughness:"\u7C97\u7CD9\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",metallicRoughnessTexture:"\u9009\u62E9\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE\u3002PBR \u8FD0\u884C\u65F6\u6309 GLB \u5E38\u7528\u7EA6\u5B9A\u8BFB\u53D6\u84DD\u8272\u91D1\u5C5E\u5EA6\u3001\u7EFF\u8272\u7C97\u7CD9\u5EA6\u3002",occlusionTexture:"\u9009\u62E9\u73AF\u5883\u906E\u853D AO \u8D34\u56FE\uFF0C\u53EA\u5BF9 PBR \u6750\u8D28\u751F\u6548\u3002",occlusionStrength:"AO \u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",emissionColor:"\u81EA\u53D1\u5149\u989C\u8272\uFF0C\u4F1A\u4E0E\u5F3A\u5EA6\u76F8\u4E58\u3002",emissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6\uFF0C0 \u8868\u793A\u65E0\u81EA\u53D1\u5149\u3002",emissionTexture:"\u9009\u62E9\u81EA\u53D1\u5149\u8D34\u56FE\uFF1B\u82E5\u672A\u8BBE\u7F6E\u5219\u517C\u5BB9\u4F7F\u7528\u65E7\u906E\u7F69\u8D34\u56FE\u3002",emissionMaskUrl:"\u9009\u62E9\u7070\u5EA6\u8D34\u56FE\u4F5C\u4E3A\u81EA\u53D1\u5149\u5F3A\u5EA6\u906E\u7F69\u3002",alphaMode:"\u900F\u660E\u6A21\u5F0F\uFF1A\u4E0D\u900F\u660E\u3001Alpha Test \u906E\u7F69\u6216 Alpha Blend \u534A\u900F\u660E\u3002",alphaOpacity:"\u6750\u8D28\u6574\u4F53\u4E0D\u900F\u660E\u5EA6\uFF0C1 \u4E3A\u5B8C\u5168\u4E0D\u900F\u660E\u3002",alphaCutoff:"\u906E\u7F69\u6A21\u5F0F\u7684 Alpha \u622A\u65AD\u9608\u503C\u3002",alphaTexture:"\u9009\u62E9 Alpha/Opacity \u8D34\u56FE\u3002",createSlotMaterial:"\u8F93\u5165 GLB \u5B50\u8282\u70B9\u6216 mesh \u7684 ownerNodePath \u6765\u6DFB\u52A0\u69FD\u7ED1\u5B9A\uFF0C\u521D\u59CB\u4F7F\u7528\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotList:"\u6839\u8282\u70B9\u4E0A\u7684\u6750\u8D28\u69FD\u4E3A\u53EA\u8BFB\u603B\u89C8\u3002",slotOwnerPath:"\u6750\u8D28\u69FD\u5B9A\u4F4D\u5230\u7684\u5B50\u8282\u70B9\u6216 mesh \u8DEF\u5F84\u3002",reimportConflicts:"\u6A21\u578B\u91CD\u5BFC\u5165\u540E\u65E0\u6CD5\u81EA\u52A8\u5339\u914D\u6216\u6E90\u6750\u8D28\u53D8\u5316\u7684\u69FD\u3002\u73B0\u6709\u7ED1\u5B9A\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u9759\u9ED8\u5220\u9664\u6216\u8986\u76D6\u3002"}},en:{title:"Artist Material",slotTitle:"Material Slots",language:"Language",materialAsset:"Material Asset",materialCard:"Current Material",inheritNone:"Inherit / None",defaultMaterial:"Default PBR Material",defaultMaterialMeta:"BabylonJS-style default PBR material",defaultStandardMaterial:"Default Standard Material",defaultStandardMaterialMeta:"BabylonJS-style default Standard material",defaultMaterialReadOnly:"The system default material is read-only. Choose an editable material asset to adjust parameters.",replace:"Replace",batchReplaceUnsupported:"Batch material replacement is not wired yet. Select one object to replace its material.",duplicateForObject:"Copy",materialPickerTitle:"Select Material Asset",texturePickerTitle:"Select Texture Asset",emptyTexture:"Select Texture",emptyTextureMeta:"Choose a texture asset",inheritTexture:"Inherit Source Texture",inheritTextureMeta:"Use the GLB / source material texture when available",clearTexture:"Clear Texture",clearTextureMeta:"Do not use a texture",missingTexture:"Missing texture asset",missingTextureMeta:"The current reference cannot be resolved in the project asset library",loadingTexture:"Loading texture",failedTexture:"Texture failed to load",assetProfile:"Asset Profile",assetProfileEmpty:"Select a material asset to edit asset parameters",assetName:"Asset Name",assetKind:"Shader",assetKindPbr:"PBR standard material",assetKindStandard:"Standard material",assetLightingModel:"Lighting Model",assetLightingModelLit:"Lit",assetLightingModelUnlit:"Unlit",assetBaseColor:"Base Color",assetBaseTexture:"Base Texture",assetBrightness:"Texture Brightness",assetSaturation:"Texture Saturation",assetContrast:"Texture Contrast",assetHue:"Texture Hue",assetNormalTexture:"Normal Texture",assetNormalStrength:"Normal Strength",assetMetallic:"Metallic",assetRoughness:"Roughness",assetMetallicRoughnessTexture:"Metallic-Roughness Texture",assetOcclusionTexture:"AO Texture",assetOcclusionStrength:"AO Strength",resetValue:"Reset to shader default",modifiedValue:"Modified from shader default",inactiveReasons:{baseTexture:"Available after assigning a base texture.",litMaterial:"Available only when the lighting model is Lit.",normalTexture:"Available after assigning a normal texture.",occlusionTexture:"Available after assigning an AO texture.",alphaBlend:"Available only in Blend alpha mode.",alphaMask:"Available only in Mask alpha mode.",alphaTransparency:"Available only in Mask or Blend alpha mode."},assetEmissionColor:"Emission Color",assetEmissionIntensity:"Emission Intensity",assetEmissionTexture:"Emission Texture",assetEmissionMaskUrl:"Mask Texture",assetAlphaMode:"Alpha Mode",assetAlphaModeOpaque:"Opaque",assetAlphaModeMask:"Mask",assetAlphaModeBlend:"Blend",assetAlphaOpacity:"Opacity",assetAlphaCutoff:"Alpha Cutoff",assetAlphaTexture:"Alpha Texture",createSlotMaterial:"Add Material Slot",slotList:"Slot List",slotId:"Slot ID",slotOwnerPath:"Slot Owner Path",slotMaterialAsset:"Slot Material Asset",slotSourceMaterial:"Source Material",slotBindingPath:"Binding Path",reimportConflicts:"Reimport Material Conflicts",summaryAsset:e=>`Asset: ${e}`,summaryMissingAsset:"Missing asset",summaryCustomOverride:"Custom override",summaryInherit:"Inherit",summaryAddSlot:"Add slot",summarySlotCount:e=>`${e} slot${e===1?"":"s"}`,formatUsageCount:e=>e>0?`Used in ${e} place${e===1?"":"s"}`:"Unused",formatMaterialEditImpact:e=>e<=0?"This material is not used in the scene; edits only change the asset.":e===1?"Edits affect the current binding.":`Shared material: edits affect ${e} bindings.`,formatDuplicateMaterialImpact:e=>e<=0?"Copying creates an independently editable material asset.":e===1?"After copying, the current object or slot uses an independent material.":`After copying, the current object or slot uses an independent material; the original ${e} shared bindings are left unchanged.`,formatReimportConflictSummary:e=>`${e} material slot reimport difference${e===1?"":"s"} detected. Existing bindings are preserved until unmatched items are resolved.`,tooltips:{language:"Switch the artist material Inspector language.",materialAsset:"Choose a project-level shared material asset, or use the read-only Default PBR material.",slotMaterialAsset:"Leave this unset to preserve the original GLB material, or choose a material asset to override only this slot.",baseTexture:"Choose a project texture as the base texture. Texture adjustment parameters are applied to this texture first.",assetProfile:"Shared asset parameters affect every node bound to this material asset.",assetName:"Material asset names are display-only for bindings; stable material IDs survive renames.",assetKind:"Select the Shader Definition referenced by this material; compatible values survive a change.",lightingModel:"Lit materials respond to environment and directional lights; unlit materials are useful for UI, VFX, icons, and markers.",baseColor:"Base color is the final color factor multiplied after base texture adjustment. Editing the shared material asset affects every bound node.",duplicateForObject:"Copy the current material as an independent material for this object or slot, then bind it automatically.",brightness:"Base texture brightness multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",saturation:"Base texture saturation multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",contrast:"Base texture contrast multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",hue:"Base texture hue offset in degrees. It only affects materials with a base texture.",normalTexture:"Choose a normal map applied to the runtime bump/normal channel for PBR and Standard materials.",normalStrength:"Normal strength. 1 keeps the texture at original strength.",metallic:"Metallic value from 0 to 1.",roughness:"Roughness value from 0 to 1.",metallicRoughnessTexture:"Choose a metallic-roughness texture. PBR runtime reads blue as metallic and green as roughness by the common GLB convention.",occlusionTexture:"Choose an ambient occlusion texture. Applies to PBR materials.",occlusionStrength:"Ambient occlusion strength. 1 keeps the texture at original strength.",emissionColor:"Emission color multiplied by emission intensity.",emissionIntensity:"Emission intensity. 0 means no emission.",emissionTexture:"Choose an emissive texture. If empty, the mask texture remains the fallback.",emissionMaskUrl:"Choose a grayscale texture to modulate emission intensity.",alphaMode:"Alpha mode: opaque, alpha-test mask, or alpha-blend transparency.",alphaOpacity:"Overall material opacity. 1 is fully opaque.",alphaCutoff:"Alpha-test cutoff threshold for mask mode.",alphaTexture:"Choose an alpha/opacity texture.",createSlotMaterial:"Enter a GLB child node or mesh ownerNodePath to add a slot binding with the Default PBR material.",slotList:"Material slots on the root object are a readonly overview.",slotOwnerPath:"Child node or mesh path targeted by this material slot.",reimportConflicts:"Slots whose source material changed or could not be matched after model reimport. Existing bindings are preserved instead of being silently deleted or overwritten."}}};function Sr(e){return xS[e]??xS.zh}function Js(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var mw={},AS=new WeakMap;function DS(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function MS(e,t){return IS(e,OS(t))}function fw(e){return{materialPickerTitle:e.materialPickerTitle,replace:e.replace,duplicateForObject:e.duplicateForObject,duplicateForObjectTooltip:e.tooltips.duplicateForObject,summaryMissingAsset:e.summaryMissingAsset,summaryInherit:e.summaryInherit,inheritNone:e.inheritNone}}function pw(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function OS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function RS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=Iw(e,t,r,n,o,a??void 0);if(vS(t,o))return[...i,j({path:`scene.materialAssets.${t.id}.properties`,label:r.assetProfile,value:r.defaultMaterialReadOnly,order:n+2,source:"Document",effect:"default",disabledReason:r.defaultMaterialReadOnly,tags:["ArtistMaterial","MaterialAsset"],tooltip:r.tooltips.assetProfile})];if(!a)return i;let s=[...a.inspector.fields].sort((c,d)=>c.order-d.order||c.path.localeCompare(d.path)).map(c=>gw({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function gw(e){let{fieldDefinition:t}=e,r=wS(e.text,t.labelKey,t.label??t.path),n=yw(e.text,t.tooltipKey,t.tooltip),o=CS(e.materialAsset.properties,t),a=t.control==="texture"&&ao(e.materialAsset.shaderId,t.path)?bw(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=Pw({path:`${lr}${e.materialAsset.id}.${t.path}`,label:r,value:typeof o=="string"?o:"",order:e.orderOffset+t.order,text:e.text,context:e.context,textureState:a??void 0,tooltip:n});else if(t.control==="number")i=xw(e.document,e.materialAsset,t.path,r,typeof o=="number"?o:Number(t.defaultValue),e.orderOffset+t.order,t,n,e.context.materialShaderDefinitions);else if(t.control==="enum")i=Aw(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:wS(e.text,d.labelKey,d.label??d.value)})),n,e.context.materialShaderDefinitions);else{let d=t.control;i=Qs(e.document,e.materialAsset,t.path,r,o,e.orderOffset+t.order,d,d,"immediate",n,e.context.materialShaderDefinitions)}let s=t.control==="color"?ro(e.definition.shaderId,t.path,e.context.materialShaderDefinitions):null;i={...i,displayPrecision:t.displayPrecision,precision:t.precision,controlOptions:{...i.controlOptions,...t.control==="color"?{colorChannels:s?.kind==="color"&&s.channels===4?4:3}:{},materialShaderSectionId:t.sectionId,materialShaderUpdateClass:t.updateClass,materialShaderBinding:t.binding}};let c=t.conditions?.find(d=>!Sw(e.definition,e.materialAsset.properties,d));return c&&(i=kw(i,!1,hw(e.text,c))),a?Mw(i,e.text,a):Dw(i,e.text,t.defaultValue)}function bw(e,t){let r=Xs(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function CS(e,t){if(t.control==="texture"){let n=Xs(e,t.schemaPath??t.path);return GS(n)}let r=Xs(e,t.path);return r===void 0?structuredClone(t.defaultValue):r}function Xs(e,t){let r=t.replace(/^properties\./,"").split(".").filter(Boolean),n=e;for(let o of r){if(!n||typeof n!="object"||Array.isArray(n))return;n=n[o]}return n}function Sw(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?CS(t,n):Xs(t,r.path);if(r.operator==="truthy")return!!o;let a=JSON.stringify(o??null)===JSON.stringify(r.value??null);return r.operator==="equals"?a:!a}function wS(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function yw(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function hw(e,t){let r=t.inactiveReasonKey?e.inactiveReasons[t.inactiveReasonKey]:void 0;return typeof r=="string"?r:t.inactiveReason??"This field is inactive for the current material state."}function Ew(e){return e.defaultMaterialAssetIds??[An,Po]}function vS(e,t){return Ga(e,Ew(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function Iw(e,t,r,n,o,a){if(!vS(t,o)){let i=o.materialShaderDefinitions??Or;return[Qs(e,t,"name",r.assetName,MS(t,r),n,"string","string","change",r.tooltips.assetName,i),{path:`${lr}${t.id}.shaderId`,label:r.assetKind,valueType:"string",control:"enum",value:t.shaderId,readOnly:!1,persistence:"document",commitMode:"immediate",order:n+1,tooltip:r.tooltips.assetKind,tags:["ArtistMaterial","MaterialAsset","ShaderDefinition"],options:i.list().map(s=>({value:s.shaderId,label:s.displayName})),controlOptions:{materialShaderSelector:!0,shaderId:t.shaderId,shaderVersion:a?.version,shaderRuntimeKind:a?.runtimeKind,...a?.sourceFile?{shaderSourceFile:a.sourceFile}:{}},validate:s=>typeof s=="string"&&i.get(s)?{ok:!0,value:s}:{ok:!1,message:"Unknown Shader Definition."},coerce:s=>typeof s=="string"?s.trim():""}]}return[DS(`${lr}${t.id}.name`,r.assetName,MS(t,r),n,r.tooltips.assetName),DS(`${lr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function Pw(e){let t=du(e.context,e.value),r=Zs(e.context,e.text,e.value,t);return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:e.value,readOnly:!1,persistence:"document",commitMode:"change",order:e.order,tooltip:e.tooltip,tags:["ArtistMaterial","TextureAsset"],controlOptions:{...r,...e.textureState?{materialTextureState:e.textureState}:{},...!e.value&&e.textureState==="inherited"?{currentLabel:e.text.inheritTexture,currentMeta:e.text.inheritTextureMeta}:!e.value&&e.textureState==="cleared"?{currentLabel:e.text.clearTexture,currentMeta:e.text.clearTextureMeta}:{}},validate:n=>{let o=kS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=kS(e.context,e.path,n);return o.ok?o.value:null}}}function Zs(e,t,r,n){return{...PS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:Tw(t),candidateValue:"assetId"})}}function du(e,t){return qs(e.textureAssets,t)}function GS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function kS(e,t,r){if(r==null||r==="")return{ok:!0,value:null};if(typeof r!="string")return{ok:!1};let n=r.trim();if(!n)return{ok:!0,value:null};if(!t.endsWith(".textureAssetId"))return{ok:!0,value:n};let o=qs(e.textureAssets,n);return o?{ok:!0,value:o.id}:/^[A-Za-z0-9_-]+$/.test(n)?{ok:!0,value:n}:{ok:!0,value:null}}function Tw(e){return{texturePickerTitle:e.texturePickerTitle,replace:e.replace,emptyTexture:e.emptyTexture,emptyTextureMeta:e.emptyTextureMeta,clearTexture:e.clearTexture,clearTextureMeta:e.clearTextureMeta,missingTexture:e.missingTexture,missingTextureMeta:e.missingTextureMeta,loadingTexture:e.loadingTexture,failedTexture:e.failedTexture}}function xw(e,t,r,n,o,a,i={},s,c){return{...Qs(e,t,r,n,o,a,"number","number","live",s,c),...i.min!=null?{min:i.min}:{},...i.max!=null?{max:i.max}:{},...i.softMin!=null?{softMin:i.softMin}:{},...i.softMax!=null?{softMax:i.softMax}:{},step:i.step??.05}}function Aw(e,t,r,n,o,a,i,s,c){return{...Qs(e,t,r,n,o,a,"enum","enum","immediate",s,c),options:i,controlOptions:{variant:"segmented"}}}function Qs(e,t,r,n,o,a,i,s,c,d,u){return{...TS({document:e,materialAsset:t,fieldPath:r,label:n,value:o,order:a,valueType:i,control:s,commitMode:c,tooltip:d,pathPrefix:lr}),validate:l=>{let m=nt(r,l);return Bt(r,m,t.shaderId,u)?{ok:!0,value:m}:{ok:!1,message:`Invalid material asset field: ${r}.`}},coerce:l=>nt(r,l)}}function Dw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!ww(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function Mw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:"",resetMode:"inherit",modified:r!=="inherited",resetLabel:t.inheritTexture,modifiedLabel:r==="cleared"?t.clearTexture:t.modifiedValue}}}function ww(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function kw(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function jS(e,t,r,n){let o=r.currentAsset??ee(e,r.value);return{path:r.path,label:r.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.value,readOnly:!1,persistence:"document",commitMode:"change",order:r.order,controlOptions:Cw(Ys(e,o,r.text,r.value,n,r.previewContext),r.currentAction),tooltip:r.text.tooltips.materialAsset,tags:["ArtistMaterial","MaterialAsset"],document:e,validate:a=>{let i=cs(a);return i&&Ut(e,i)?{ok:!0,value:a}:a==null||a===""?{ok:!0,value:a}:typeof a=="string"&&Ut(e,a)?{ok:!0,value:a}:{ok:!1,message:`Material asset not found: ${String(a)}`}},coerce:a=>typeof a=="string"?a.trim():a,effect:Ow(t,r.value),validation:Rw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function Ow(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function Rw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function Cw(e,t){return t?{...e,currentActionId:t.actionId,currentActionParams:Object.fromEntries(Object.entries(t.params).filter(r=>typeof r[1]=="string"&&r[1].length>0))}:e}function vw(e,t,r){return jS(e,t,r,_e.getCachedUsageIndex(e))}function Ys(e,t,r,n,o,a={}){return{..._e.createPickerControlOptions({materialAssets:e.scene.materialAssets??[],currentAsset:t,currentValue:n,pickerText:fw(r),displayText:OS(r),document:e,ownershipText:pw(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function Gw(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Ys(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=AS.get(e);a||(a=new WeakMap,AS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??mw,c=i.get(s);c||(c=new Map,i.set(s,c));let d=c.get(n);if(d)return d;let u=Ys(e,t,r,n,_e.getCachedUsageIndex(e),o);return c.set(n,u),u}var jw={createSelectorInspectorPropertyWithUsage:jS,createSelectorInspectorPropertyWithCachedUsage:vw,createPickerControlOptionsWithUsage:Ys,createPickerControlOptionsWithCachedUsage:Gw},On=jw;function NS(e,t,r){let n=tg(e,t);if(n.state==="asset"&&n.materialAsset){let o=Qb(n.materialAsset),a=o==="default-pbr"?r.defaultMaterial:o==="default-standard"?r.defaultStandardMaterial:n.materialAsset.name??n.materialAsset.id;return r.summaryAsset(a)}return n.state==="missing-asset"?r.summaryMissingAsset:n.state==="override"?r.summaryCustomOverride:r.summaryInherit}function FS(e,t,r){let n=vr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function Nw(e,t,r,n,o,a={}){let i=Sr(Js(t)),s=[];return vr(e,t).forEach((d,u)=>{let l=Kt(d)??d.slotId,m=dl(t,d),f=o?.materialSlotBindings?.[d.slotId]??m,g=f?.materialAssetId?ee(e,f.materialAssetId):null,b=(u+1)*100,S=ms(d),y=ot(d)[0],I=y==null?null:To(d,y)?.profile,E=On.createSelectorInspectorPropertyWithUsage(e,r,{path:S,label:d.label||lu(l,u,i),value:m?.materialAssetId??"",order:b,text:i,currentAsset:g,currentAction:g?{actionId:"material.open-asset",params:{materialAssetId:g.id,browserAssetId:`material:${g.id}`,sourceObjectId:t.id,sourceBindingPath:S}}:I?{actionId:"material.create-from-source",params:{sourceObjectId:t.id,sourceBindingPath:S}}:void 0,previewContext:a},n);s.push(Fw(E,d,f,i,a))}),s}function Fw(e,t,r,n,o){let a=ot(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:wn(t,a),s=a==null?null:To(t,a)?.profile,c=s?Vt(ja(s),o):void 0,d=i?`GLB \u6E90\u6750\u8D28\uFF1A${i}`:"GLB \u6E90\u6750\u8D28",u=e.controlOptions??{},l=Array.isArray(u.candidates)?u.candidates.map(f=>f&&typeof f=="object"&&!Array.isArray(f)&&f.value===""?{...f,label:"\u6062\u590D\u7EE7\u627F",meta:d,...c?{preview:c}:{}}:f):void 0,m=r?.materialAssetId&&typeof u.currentMeta=="string"&&u.currentMeta?`${u.currentMeta} \xB7 ${d}`:d;return{...e,tooltip:n.tooltips.slotMaterialAsset,controlOptions:{...u,...r?.materialAssetId?{}:{currentLabel:i?`\u7EE7\u627F GLB\uFF1A${i}`:"\u7EE7\u627F GLB \u539F\u6750\u8D28",...c?{currentPreview:c}:{}},currentMeta:m,...l?{candidates:l}:{},...i?{sourceMaterialName:i}:{}}}}function _w(e,t,r,n){let o=vr(e,t);if(o.length===0)return[];let a=[],i=Hs(e,t),s=bs(e,t.id)??t.overrides;i.issues.length>0&&a.push(Bw("asset.materialSlots.reimportConflicts",r.reimportConflicts,$w(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>Lw(e,t,d,u,r,n,s));return a.push({path:"asset.materialSlots",label:r.slotList,valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:o.length,slots:c},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:r.slotMaterialAsset,slotId:r.slotId,ownerNodePath:r.slotOwnerPath,sourceMaterial:r.slotSourceMaterial,primitive:"Primitive",triangles:"Triangles",bounds:"Bounds",bindingPath:r.slotBindingPath},slots:c},tags:["ArtistMaterial","MaterialSlot","Readonly"],tooltip:r.tooltips.slotList,document:e}),a}function $w(e,t){let r=e.map(n=>{let o=n.label||n.ownerNodePath||n.slotId||n.previousSlotId||n.bindingPath||"slot";if(n.reason==="source-material-changed"){let a=n.previousSourceMaterialIndex==null?"?":`#${n.previousSourceMaterialIndex}`,i=n.sourceMaterialIndex==null?"?":`#${n.sourceMaterialIndex}`;return`${o}: source material ${a} -> ${i}; ${n.materialAssetId??t.inheritNone}`}return n.reason==="slot-removed"?`${o}: removed slot; ${n.materialAssetId??t.inheritNone}`:`${o}: ${n.status}`});return[t.formatReimportConflictSummary(e.length),...r].join(`
3
+ `)}function Lw(e,t,r,n,o,a,i){let s=dl(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??Dn),u=On.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=ot(r),m=l[0],f=m==null?null:wn(r,m),g=r.sourceSurfaces[0],b=g.ownerNodePath;return{key:ng(r),label:r.label||lu(b,n,o),slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:b,materialAssetId:s?.materialAssetId??"",materialLabel:u.currentLabel??o.inheritNone,materialMeta:u.currentMeta??o.summaryInherit,...u.currentPreview?{materialPreview:u.currentPreview}:{},...m==null?{}:{sourceMaterialIndex:m},...l.length?{sourceMaterialIndices:l}:{},...f?{sourceMaterialName:f}:{},...r.materialNames?.length?{materialNames:r.materialNames}:{},...r.sourceSurfaces.length===1&&typeof g.triangleCount=="number"?{triangleCount:g.triangleCount}:{},...r.sourceSurfaces.length===1&&g.boundingBox?{boundingBox:g.boundingBox}:{},bindingPath:ms(r)}}var zw={createChildMaterialBindingInspectorPropertiesWithUsage:Nw,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:_w},_S=zw;function lu(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function Bw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var $S="materialAsset::",Vw=5;function Uw(e){return e.startsWith($S)&&e.slice($S.length).trim()||null}function Kw(e,t,r,n,o,a){let i=[],s=Js(t),c=Sr(s),d=t.overrides?.materialBinding,u=bs(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??Dn,f=ee(e,m),g=l?.materialAssetId?l:{...l,materialAssetId:Dn};if(!rg(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:NS(g,f,c),persistence:"document",collapsedByDefault:!1,properties:[On.createSelectorInspectorPropertyWithUsage(e,r,{path:y,label:c.materialCard,value:d?.materialAssetId??"",order:0,text:c,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,sourceBindingPath:y}},previewContext:n},a)]})}let S=r==="primitive"?[]:_S.createChildMaterialBindingInspectorPropertiesWithUsage(e,t,r,a,u,n);return S.length>0&&i.push({id:"artistMaterialSlots",title:c.slotTitle,order:48,placement:"body",summary:FS(e,t,c),persistence:"document",collapsedByDefault:!1,properties:S}),i}function Hw(e,t,r,n){let o=Uw(t),a=o?ee(e,o):null;if(!a)return null;let i=Sr("zh"),s=n.forMaterial(a.id),c=RS(e,a,i,0,r),d=`scene.materialAssets.${a.id}.properties`,u=`${d}.`,l=E=>E.path===d||E.path.startsWith(u),m=c.filter(E=>!l(E)),f=c.filter(l),g=[{path:`scene.materialAssets.${a.id}.preview`,label:a.name||a.id,valueType:"object",control:"custom",customControl:"asset-picker-card",value:a.id,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:-10,controlOptions:{currentMaterialAssetId:a.id,currentMaterialShaderId:a.shaderId,...a.definitionVersion!=null?{currentMaterialDefinitionVersion:a.definitionVersion}:{},currentLabel:a.name||a.id,currentMeta:a.shaderId,currentPreview:Vt(a.properties,r)},document:e},...m,Xw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],b=[co({path:`scene.materialAssets.${a.id}.actions.locate`,label:"\u5728 Assets \u4E2D\u5B9A\u4F4D",actionId:"material.locate-asset",icon:"asset",params:{materialAssetId:a.id,browserAssetId:`material:${a.id}`},order:20,tooltip:"\u5728 Assets \u9762\u677F\u4E2D\u5B9A\u4F4D\u5F53\u524D\u6750\u8D28\u3002",disabled:!1}),co({path:`scene.materialAssets.${a.id}.actions.back`,label:"\u8FD4\u56DE\u6765\u6E90",actionId:"material.back-to-owner",icon:"chevron-left",params:{materialAssetId:a.id},order:21,tooltip:"\u8FD4\u56DE\u6253\u5F00\u5F53\u524D\u6750\u8D28\u524D\u7684\u5BF9\u8C61\u6216 Prefab Inspector\u3002",disabled:!1})],S=[{id:"materialAssetSummary",title:"Material",order:10,regionId:qi,persistence:"readonly",collapsedByDefault:!1,properties:g}];S.push({id:"materialAssetNavigation",title:"\u5BFC\u822A",order:15,placement:"body",persistence:"readonly",collapsedByDefault:!1,properties:b}),S.push({id:"materialReferences",title:`\u4F7F\u7528\u4F4D\u7F6E (${s.length})`,order:20,placement:"body",persistence:"readonly",collapsedByDefault:s.length===0,properties:[{path:`scene.materialAssets.${a.id}.references.browser`,label:"\u4F7F\u7528\u4F4D\u7F6E",valueType:"object",control:"custom",customControl:"material-reference-list",controlOptions:{previewLimit:Vw,items:s.map((E,D)=>({key:`${E.scope}:${E.gameObjectId}:${E.bindingPath}:${D}`,label:E.label,scope:E.scope,actionId:"material.open-owner",params:Object.fromEntries(Object.entries({materialAssetId:a.id,ownerScope:E.scope,sourceObjectId:E.gameObjectId,sourceBindingPath:E.bindingPath,slotId:E.slotId,ownerNodePath:E.ownerNodePath,prefabAssetId:E.prefabAssetId,prefabNodeId:E.prefabNodeId}).filter(x=>typeof x[1]=="string"&&x[1].length>0))}))},value:s.length,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:0,tooltip:s.length>0?"\u67E5\u770B\u4F7F\u7528\u5F53\u524D\u6750\u8D28\u7684 Scene \u5BF9\u8C61\u548C Prefab \u8282\u70B9\u3002":"\u5F53\u524D\u672A\u88AB\u4EFB\u4F55\u5BF9\u8C61\u6216 Prefab \u4F7F\u7528\u3002",document:e}]});let y=r.materialShaderDefinitions?.get(a.shaderId)??De(a.shaderId);for(let[E,D]of[...y?.inspector.sections??[]].sort((x,N)=>x.order-N.order||x.id.localeCompare(N.id)).entries())LS(S,{id:`material${D.id.charAt(0).toUpperCase()}${D.id.slice(1)}`,title:D.title,order:D.order,properties:[...E===0?f.filter(x=>x.path===d):[],...f.filter(x=>x.controlOptions?.materialShaderSectionId===D.id)]});let I=new Set(S.flatMap(E=>E.properties.map(D=>D.path)));return LS(S,{id:"materialAdvanced",title:"Advanced",order:80,properties:f.filter(E=>!I.has(E.path))}),{targetIds:[t],activeId:t,label:a.name||a.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"materialAsset",capabilities:["material"],document:e},sections:S}}function Ww(e,t,r,n={},o){return Kw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function qw(e,t,r={}){return Hw(e,t,r,_e.getCachedUsageIndex(e))}var Jw={createArtistMaterialInspectorSectionsWithCachedUsage:Ww,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:qw},uu=Jw;function LS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function Xw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var zS="modelAsset::";function Yw(e){return e.startsWith(zS)&&e.slice(zS.length).trim()||null}function BS(e,t,r={}){let n=Yw(t),o=n?Zw(e,n,r.modelAssets):null;if(!o)return null;let a=rk(o),i=[Qw(o)];return i.push(ek(e,o,a,r)),{targetIds:[t],activeId:t,label:o.displayName??o.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"modelAsset",capabilities:["asset","materialSlots"],document:e},sections:i}}function Zw(e,t,r){let n=e.assets.find(a=>a.id===t);if(n&&n.type!=="glb")return null;let o=r?.find(a=>a.assetId===t&&a.type==="glb");return o?Vr(n??{id:t,type:"glb"},o):n??null}function Qw(e){let t=nk(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:qi,persistence:"readonly",collapsedByDefault:!1,properties:[Fa(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),Fa(`assets.${e.id}.id`,"Asset ID",e.id,1),Fa(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[Fa(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function ek(e,t,r,n){let o=`\u6750\u8D28\u63D2\u69FD (${r.length})`;if(r.length===0)return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:"\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",persistence:"readonly",collapsedByDefault:!1,properties:[Fa(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>tk(s,c,n)),i={path:`assets.${t.id}.materialSlots`,label:"GLB \u6E90\u6750\u8D28",valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:r.length,slots:a},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:"\u5F53\u524D\u6765\u6E90",slotId:"Slot ID",ownerNodePath:"\u8282\u70B9\u8DEF\u5F84",sourceMaterial:"\u6E90\u6750\u8D28",primitive:"Primitive",triangles:"\u4E09\u89D2\u9762",bounds:"Bounds",bindingPath:"\u7ED1\u5B9A\u8DEF\u5F84"},slots:a},tags:["Asset","MaterialSlot","Readonly"],tooltip:"GLB / glTF \u6587\u4EF6\u4E2D\u89E3\u6790\u51FA\u7684\u53EA\u8BFB\u6750\u8D28\u63D2\u69FD\u3002",document:e};return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:`${r.length} \u4E2A\u5DF2\u89E3\u6790\u6E90\u63D2\u69FD`,persistence:"readonly",collapsedByDefault:!1,properties:[i]}}function tk(e,t,r){let n=e.sourceSurfaces[0],o=ot(e),a=n.sourceMaterialIndex??o[0],i=a==null?e.materialNames?.[0]??e.materialName??null:wn(e,a),s=a==null?null:To(e,a)?.profile??null,c=e.label||i||`Material Slot ${t+1}`;return{key:e.slotId,label:c,slotId:e.slotId,sourceSurfaces:structuredClone(e.sourceSurfaces),ownerNodePath:n.ownerNodePath,materialLabel:i??c,materialMeta:"\u7EE7\u627F GLB \u6E90\u6750\u8D28",...s?{materialPreview:Vt(s,r)}:{},...a==null?{}:{sourceMaterialIndex:a},...o.length>0?{sourceMaterialIndices:o}:{},...i?{sourceMaterialName:i}:{},...e.materialNames?.length?{materialNames:e.materialNames}:{},...e.sourceSurfaces.length===1&&typeof n.triangleCount=="number"?{triangleCount:n.triangleCount}:{},...e.sourceSurfaces.length===1&&n.boundingBox?{boundingBox:n.boundingBox}:{}}}function rk(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(Gr).filter(r=>!!r)}function Fa(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function nk(e){return typeof e=="string"&&e.trim()?e.trim():""}function _a(e,t,r,n={}){let o=pS(e,t),a=o.document;if(t.type==="prefab"){let u=VS(a,t),l=u?Vr(u,t):mu(t),m=KS(a,t,l,r,n),f=ak(u?a.assets.map(g=>g.id===l.id?l:g):[...a.assets,l],l);return{document:{...a,assets:f,scene:{...a.scene,gameObjects:[...a.scene.gameObjects,m]}},gameObject:m}}let i=VS(a,t),s=i?Vr(i,t):mu(t),c=t.type==="texture"?ok(a,t,s.id,r,n):US(a,t,s.id,r,n),d=gS(c,t,o.materialAssetIdsBySourceMaterialIndex);return{document:{...a,assets:i?a.assets.map(u=>u.id===s.id?s:u):[...a.assets,s],scene:{...a.scene,gameObjects:[...a.scene.gameObjects,d]}},gameObject:d}}function ok(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=dt(fu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=gu(a,o.objectId,i),c=bu(e,o.parentId),d=pu(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,kind:"transform",...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},metadata:{...t.metadata??{},assetId:t.assetId,assetType:"texture"},components:[wt(d),{type:"ImageRenderer",assetId:r,size:{width:1,height:1}}]}}function mu(e){return{id:e.assetId,guid:e.guid,type:e.type,displayName:e.displayName,category:e.category,warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:ec(e.defaults),prefab:ec(e.prefab),external:ec(e.external),metadata:ec(e.metadata)}}function US(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=dt(fu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=gu(a,o.objectId,i),c=bu(e,o.parentId),d=pu(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},components:[wt(d),{type:"ModelRenderer",assetId:r}]}}function KS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=dt(fu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=gu(a,o.objectId,i),c=bu(e,o.parentId),d=pu(e,c,n,o);return dg({id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},prefabAsset:r,transform:wt(d),metadata:{...t.metadata??{},assetId:t.assetId,assetType:"prefab"}})}function fu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function VS(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function ak(e,t){let r=pa(t);if(!r||e.some(a=>a.id===r))return[...e];let n=t.prefab?.sourceAssetGuid,o=!!n&&!e.some(a=>a.guid===n);return[...e,{id:r,...o?{guid:n}:{},type:"glb",displayName:r,category:"Model",metadata:{sourcePrefabId:t.id}}]}function pu(e,t,r,n){if(n.localTransform)return structuredClone(n.localTransform);let o=Ql(e,r);if(!t)return o;let a=n.resolveLocalTransform?.({document:e,parentId:t,worldTransform:o})??fr(e,t,o);if(!a)throw new Error(`Cannot resolve parent-local asset placement transform for ${t}.`);return a}function gu(e,t,r){if(t===void 0)return Oa(e,$s(r));if(Oa([],t)!==t||e.includes(t))throw new Error(`Requested asset instance id is invalid or already used: ${t}`);return t}function bu(e,t){let r=t??ye(e);if(r){if(!e.scene.gameObjects.some(n=>n.id===r))throw new Error(`Requested asset instance parent does not exist: ${r}`);return r}}function ec(e){return e==null?void 0:structuredClone(e)}function ik(e){return!!e&&rt(e)}function hu(e,t,r={}){let n=t.type==="document.replace"?t.document:WS({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function WS(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return La({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return Rn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return $a(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return _a(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return me(r.targetId)?t:Pn(t,r.targetId,{transform:r.transform});if(r.kind==="game-object.transform-batch")return r.targets.reduce((o,a)=>{if(me(a.targetId))return o;let i=$(o,a.targetId),s=i?G(i):null;if(!s)return o;if(ik(a.transform))return Pn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return Pn(o,a.targetId,{position:c.position?{...s.position,...c.position}:void 0,rotation:c.rotation?{...s.rotation,...c.rotation}:void 0,scale:c.scale?{...it(s,"scale"),...c.scale}:void 0})},t);if(r.kind==="game-object.duplicate-selection"){let o=new Set(t.scene.gameObjects.map(l=>l.id)),a=n.isProtectedDuplicateSource??sk,i=new Set(t.scene.gameObjects.filter(l=>a(l,t)).map(l=>l.id)),s=new Set,c=[];for(let l of r.gameObjects)o.has(l.id)||s.has(l.id)||Z(l)||a(l,t)||(s.add(l.id),c.push(l));let d=dk(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?Su(u,r.order):u}}}if(r.kind==="game-object.rename"){let o=r.name.trim();if(!o)return t;let a=t.scene.gameObjects.find(i=>i.id===r.targetId);return!a||a.name===o?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(i=>i.id===r.targetId?{...i,name:o}:i)}}}if(r.kind==="game-object.create-group"||r.kind==="game-object.create-primitive")return t.scene.gameObjects.some(o=>o.id===r.gameObject.id)?t:{...t,scene:{...t.scene,gameObjects:[...t.scene.gameObjects,r.gameObject]}};if(r.kind==="game-object.delete-subtree"){if(r.targetIds.some(me))return t;let o=kt(t,r.targetIds);if(o.size===0)return t;let a=n.isProtectedDeleteTarget??ck;return t.scene.gameObjects.some(i=>o.has(i.id)&&a(i,t))?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.filter(i=>!o.has(i.id))}}}if(r.kind==="game-object.reparent"){if(me(r.targetId))return t;let o=t.scene.gameObjects.find(c=>c.id===r.targetId);if(!o)return t;let a=r.transform?pr(r.transform):null;if(r.transform&&!a)return t;let i=!!a&&!HS(G(o),a);if(o.parentId===r.parentId&&!i)return t;let s={...o,parentId:r.parentId,components:i?o.components.map(c=>c.type==="Transform"?a:c):o.components};return{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(c=>c.id===r.targetId?s:c)}}}if(r.kind==="game-object.hierarchy-move"){let o=r.moves.filter(l=>!me(l.targetId)),a=new Map;for(let l of o){let m=pr(l.transform);if(!m)return t;a.set(l.targetId,m)}let i=new Map(o.map(l=>[l.targetId,l]));if(i.size===0)return t;let s=!1,c=t.scene.gameObjects.map(l=>{let m=i.get(l.id);if(!m)return l;let f=a.get(m.targetId),g=!HS(G(l),f);if(l.parentId===m.parentId&&!g)return l;let b={...l,parentId:m.parentId,components:g?l.components.map(S=>S.type==="Transform"?f:S):l.components};return s=!0,b}),d=Su(c,r.order),u=d.some((l,m)=>l!==t.scene.gameObjects[m]);return!s&&!u?t:{...t,scene:{...t.scene,gameObjects:d}}}if(r.kind==="game-object.group-selection"){if(Z(r.gameObject)||t.scene.gameObjects.some(s=>s.id===r.gameObject.id))return t;let o=new Set(r.childIds.filter(s=>!me(s)));if(o.size===0)return t;let a=new Map;for(let[s,c]of Object.entries(r.childTransforms)){if(!o.has(s))continue;let d=pr(c);if(!d)return t;a.set(s,d)}let i=t.scene.gameObjects.map(s=>{if(!o.has(s.id))return s;let c=a.get(s.id);return{...s,parentId:r.gameObject.id,components:c?s.components.map(d=>d.type!=="Transform"?d:c):s.components}});return{...t,scene:{...t.scene,gameObjects:Su([...i,r.gameObject],r.order)}}}return t}function sk(e){return Mt(e)}function ck(e){return Dt(e)}function dk(e,t,r){let n=new Map(e.map(a=>[a.id,a])),o=!0;for(;o;){o=!1;for(let a of[...n.values()])!a.parentId||n.has(a.parentId)||t.has(a.parentId)&&!r.has(a.parentId)||(n.delete(a.id),o=!0)}return e.filter(a=>n.has(a.id))}function Su(e,t){let r=new Map(e.map(a=>[a.id,a])),n=[],o=new Set;for(let a of t){if(o.has(a))continue;let i=r.get(a);i&&(n.push(i),o.add(a))}return[...n,...e.filter(a=>!o.has(a.id))]}function HS(e,t){if(!e)return!1;let r=Ee(e),n=Ee(t);return r||n?r&&n&&e.matrix.every((o,a)=>o===t.matrix[a]):yu(e.position,t.position)&&yu(e.rotation,t.rotation)&&yu(it(e,"scale"),it(t,"scale"))}function yu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var lk="main_camera",uk="environment_light",mk="sun_light",tc={projection:"orthographic",alpha:3.9269908169872414,beta:.8,radius:14,orthoSize:6,fov:.85,targetOffset:{x:0,y:0,z:0},minZ:1,maxZ:1e4,lowerBetaLimit:.8,upperBetaLimit:.8,lowerRadiusLimit:14,upperRadiusLimit:14,inertia:.9,targetScreenOffset:{x:0,y:0},inspectorLanguage:"zh"},Va={type:"directional",intensity:2,direction:{...Ts},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},Cn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function JS(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function XS(e){let t=Tu({...e,kind:"transform",transformType:"camera",camera:Ua(e.camera)});return delete t.light,delete t.primitive,xu(t,e)?e:t}function Pu(e,t){let r=Tu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:vn(e.light,t)});return delete r.camera,delete r.primitive,xu(r,e)?e:r}function YS(e){let t=Tu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,xu(t,e)?e:t}function Tu(e){return G(e)?e:{...e,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},...e.components]}}function Ua(e){let t=tc;return{...t,...e??{},projection:fk(e?.projection),fov:za(e?.fov,t.fov??.85),targetOffset:Sk(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:za(e?.minZ,t.minZ??1),maxZ:za(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:Ba(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:Ba(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:za(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:za(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:gk(e?.inertia,t.inertia??.9),targetScreenOffset:bk(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:pk(e?.inspectorLanguage)}}function ZS(e,t){return qS(e,t,{valueField:"beta",lowerField:"lowerBetaLimit",upperField:"upperBetaLimit",minValue:Number.NEGATIVE_INFINITY}),qS(e,t,{valueField:"radius",lowerField:"lowerRadiusLimit",upperField:"upperRadiusLimit",minValue:.001}),e}function qS(e,t,r){let n=`camera.${r.valueField}`,o=`camera.${r.lowerField}`,a=`camera.${r.upperField}`,i=Ba(e[r.valueField],tc[r.valueField]),s=Ba(e[r.lowerField],i),c=Ba(e[r.upperField],i);Number.isFinite(r.minValue)&&(i=Math.max(r.minValue,i),s=Math.max(r.minValue,s),c=Math.max(r.minValue,c)),c<s&&(t===a?s=c:c=s),t===o||t===a?i=Math.min(c,Math.max(s,i)):t===n&&(i<s&&(s=i),i>c&&(c=i)),e[r.valueField]=i,e[r.lowerField]=s,e[r.upperField]=c}function fk(e){return e==="perspective"?"perspective":"orthographic"}function pk(e){return e==="en"?"en":"zh"}function QS(e){return e==="en"?"en":"zh"}function Ba(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function za(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function gk(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function bk(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)}function Sk(e){if(!e||typeof e!="object")return!1;let 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)}function ey(e){return e.maxZ!=null&&e.minZ!=null&&e.maxZ<=e.minZ||e.upperBetaLimit!=null&&e.lowerBetaLimit!=null&&e.upperBetaLimit<e.lowerBetaLimit||e.upperRadiusLimit!=null&&e.lowerRadiusLimit!=null&&e.upperRadiusLimit<e.lowerRadiusLimit}function yk(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function vn(e,t="directional"){return yk(e,t)==="hemispheric"?Ek(e):hk(e)}function hk(e){let t=Va,r=e?.type==="directional"?e:void 0;return{...t,...r??{},type:"directional",direction:{...t.direction,...r?.direction??{}},diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,inspectorLanguage:QS(ty(r))}}function Ek(e){let t=Cn,r=e?.type==="hemispheric"?e:void 0;return{...t,...r??{},type:"hemispheric",diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,groundColor:r?.groundColor?{...t.groundColor,...r.groundColor}:t.groundColor,inspectorLanguage:QS(ty(r))}}function ty(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function xu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ry(e,t,r){return{id:Au(t,lk,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:Ua(void 0),components:[{type:"Transform",position:{x:0,y:5,z:-8},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function ny(e,t,r){return{id:Au(t,mk,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:vn(void 0,"directional"),components:[{type:"Transform",position:{x:0,y:4,z:-3},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function oy(e,t,r){return{id:Au(t,uk,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:vn(void 0,"hemispheric"),components:[{type:"Transform",position:{x:0,y:3,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function Au(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function iy(e,t){let r=t.name.trim();if(!r)return null;let n=$(e,t.id);return!n||n.name===r?null:{label:`Rename ${n.name??n.id} to ${r}`,patch:{kind:"game-object.rename",targetId:t.id,name:r},changedId:t.id}}function sy(e,t){let r=gy(e,t);if(r===null)return null;let n=dt(oc(e),t.name,{fallbackName:"Empty"}),o=dy(e.scene.gameObjects.map(i=>i.id),t.objectId,n);if(!o)return null;let a={id:o,guid:he(),name:n,kind:"transform",transformType:"plain",...r?{parentId:r}:{},active:!0,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Create empty ${n}`,patch:{kind:"game-object.create-group",gameObject:a},createdId:o,changedIds:[o]}}function cy(e,t){let r=Ck(t.shape);if(!r)return null;let n=Dk(e,t);if(n===null)return null;let o=dt(oc(e),t.name,{fallbackName:vk(r)}),a=dy(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=Gk(r),s={id:a,guid:he(),name:o,kind:"primitive",...n?{parentId:n}:{},active:!0,primitive:{shape:r},shadow:{cast:"none",receive:"none"},components:[wt(i)]};return{label:`Create ${o}`,patch:{kind:"game-object.create-primitive",gameObject:s},createdId:a,changedIds:[a]}}function dy(e,t,r){return t===void 0?ct(e,r):ct([],t)===t&&!e.includes(t)?t:null}function ly(e,t){if(t.ids.some(me))return null;let r=kt(e,t.ids);if(r.size===0||e.scene.gameObjects.some(a=>r.has(a.id)&&Dt(a)))return null;let n=Ok(e,r,t.activeId??null),o=[...r];return{label:`Delete ${o.length} GameObject${o.length===1?"":"s"}`,patch:{kind:"game-object.delete-subtree",targetIds:t.ids},deletedIds:o,fallbackSelectionId:n}}function Mu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=$(e,t.draggedId),o=$(e,t.targetId);return n?Z(n)?{ok:!1,reason:"Root GameObject cannot be reparented."}:o?G(n)?At(o)?n.id===o.id?{ok:!1,reason:"GameObject cannot be parented to itself."}:Rk(e,n.id,o.id)?{ok:!1,reason:"GameObject cannot be parented to its descendant."}:t.preserveWorldTransform!==!1&&!nc(e,n.id,o.id,void 0,{preserveWorldPolicy:r})?{ok:!1,reason:"Cannot preserve world transform under the target parent."}:{ok:!0}:{ok:!1,reason:`${t.targetId} cannot have children.`}:{ok:!1,reason:`${t.draggedId} has no Transform to preserve.`}:{ok:!1,reason:`Parent GameObject not found: ${t.targetId}`}:{ok:!1,reason:`GameObject not found: ${t.draggedId}`}}function uy(e,t,r={}){if(!Mu(e,t,r).ok)return null;let o=$(e,t.draggedId);if(!o||!G(o))return null;let a=t.targetId,i=t.preserveWorldTransform===!1?Jt(o):nc(e,o.id,a,void 0,{preserveWorldPolicy:r});return!i||o.parentId===a&&Iy(Jt(o),i)?null:{label:`Reparent ${o.name??o.id}`,patch:{kind:"game-object.reparent",targetId:o.id,parentId:a,transform:i},changedIds:[o.id]}}function wu(e,t,r={}){let n=gr(e),o=sp(n,t);if(!o.ok)return o;let a=ht(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be moved."};let i=Ru(e,t);if(i&&!Cu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=$(e,s);if(!c)return{ok:!1,reason:`GameObject not found: ${s}`};if(!G(c))return{ok:!1,reason:`${s} has no Transform to preserve.`};if(!nc(e,s,i,t,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}return{ok:!0}}function my(e,t,r={}){if(!wu(e,t,r).ok)return null;let o=gr(e),a=ht(o,t.ids),i=Ru(e,t),s=a.map(l=>{let m=$(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?Jt(m):nc(e,l,i,t,r),g=f?En(f):null;return g?i?{targetId:l,parentId:i,transform:g}:{targetId:l,transform:g}:null}).filter(l=>!!l);if(s.length!==a.length)return null;let c=Mk(e,a,t),d=e.scene.gameObjects.map(l=>l.id);return!s.some(l=>{let m=$(e,l.targetId);return!m||m.parentId!==l.parentId||!Iy(Jt(m),l.transform)})&&jk(d,c)?null:{label:`Move ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.hierarchy-move",moves:s,order:c},changedIds:a}}function ku(e,t,r={}){let n=gr(e),o=cp(n,t);if(!o.ok)return o;let a=ht(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be grouped."};let i=by(e,t.parentId??null);if(i&&!Cu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=Ey(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!Aa(e,i,c,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."};for(let d of a){let u=$(e,d);if(!u)return{ok:!1,reason:`GameObject not found: ${d}`};if(!G(u))return{ok:!1,reason:`${d} has no Transform to preserve.`};let l=ke(e,d);if(!l||!Sy(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function fy(e,t,r={}){if(!ku(e,t,r).ok)return null;let o=gr(e),a=ht(o,t.ids);if(a.length===0)return null;let i=by(e,t.parentId??null),s=Ey(e,a);if(!s)return null;let c={position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},d=Aa(e,i,c,r);if(!d)return null;let u=dt(oc(e),t.name,{fallbackName:"Parent"}),l=ct(e.scene.gameObjects.map(b=>b.id),u),m={id:l,guid:he(),name:u,kind:"transform",transformType:"plain",...i?{parentId:i}:{},active:!0,components:[wt(d)]},f={};for(let b of a){let S=$(e,b);if(!S)return null;if(t.preserveWorldTransform===!1){f[b]=Jt(S);continue}let y=ke(e,b);if(!y)return null;let I=Sy(c,y,r);if(!I)return null;f[b]=I}let g=wk(e,l,a,t.insertBeforeId??null);return{label:`Create Parent for ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.group-selection",gameObject:m,childIds:a,childTransforms:f,order:g},createdId:l,changedIds:[l,...a]}}function py(e){let t=e.isProtectedDuplicateSource??Ik,r=gr(e.document),n=new Set(ht(r,e.targetIds).filter(S=>{let y=$(e.document,S);return!!y&&!Z(y)&&!t(y,e.document)&&!Tk(e.document,y.id,t)})),o=Ou(e.document).filter(S=>n.has(S));if(o.length===0)return null;let a=kt(e.document,o),i=new Map,s=new Set(e.document.scene.gameObjects.map(S=>S.id)),c=new Map,d=oc(e.document),u=xk(e.document,o,a,t);for(let S of u){let y=$(e.document,S),I=dt(d,y.name,{alwaysAppendSuffix:!0,fallbackName:y.id});d.push(I);let E=ct([...s],I);s.add(E),i.set(y.id,E),c.set(y.id,I)}let l=u.map(S=>$(e.document,S)).filter(S=>!!S&&i.has(S.id)).map(S=>{let y=structuredClone(S);return y.id=i.get(S.id),y.guid=he(),y.name=c.get(S.id),y.parentId&&i.has(y.parentId)&&(y.parentId=i.get(y.parentId)),y});if(l.length===0)return null;let m=l.map(S=>S.id),f=o.map(S=>i.get(S)).filter(S=>!!S),g=Pk(e.document,o,e.activeId),b=g&&i.has(g)?i.get(g):f[f.length-1]??m[m.length-1]??null;return{label:`Duplicate ${m.length} object${m.length===1?"":"s"}`,patch:{kind:"game-object.duplicate-selection",gameObjects:l,order:Ak(e.document,o,i)},createdIds:m,selectedIds:f,activeId:b,changedIds:m}}function Ik(e){return Mt(e)}function Pk(e,t,r){if(r&&t.includes(r))return r;if(r){for(let n of t)if(kt(e,[n]).has(r))return n}return t[t.length-1]??null}function Tk(e,t,r){let n=new Map(e.scene.gameObjects.map(i=>[i.id,i])),o=new Set,a=n.get(t);for(;a?.parentId;){if(o.has(a.parentId))return!0;o.add(a.parentId);let i=n.get(a.parentId);if(!i)return!1;if(r(i,e))return!0;a=i}return!1}function xk(e,t,r,n){let o=Ou(e),a=new Map(o.map((l,m)=>[l,m])),i=new Map(e.scene.gameObjects.map(l=>[l.id,l])),s=new Map;for(let l of e.scene.gameObjects){let m=l.parentId&&i.has(l.parentId)?l.parentId:null,f=s.get(m)??[];f.push(l.id),s.set(m,f)}for(let l of s.values())l.sort((m,f)=>(a.get(m)??Number.MAX_SAFE_INTEGER)-(a.get(f)??Number.MAX_SAFE_INTEGER));let c=[],d=new Set,u=l=>{if(d.has(l)||!r.has(l))return;d.add(l);let m=$(e,l);if(!(!m||Z(m)||n(m,e))){c.push(m.id);for(let f of s.get(m.id)??[])u(f)}};for(let l of t)u(l);return c}function Ak(e,t,r){let n=Ou(e),o=new Map;for(let i of t){let s=kt(e,[i]),c=n.filter(l=>s.has(l)),d=c.map(l=>r.get(l)).filter(l=>!!l),u=c[c.length-1];u&&d.length>0&&o.set(u,d)}let a=[];for(let i of n){a.push(i);let s=o.get(i);s&&a.push(...s)}return a}function Ou(e){let t=e.scene.gameObjects,r=new Map(t.map(c=>[c.id,c])),n=new Map;for(let c of t){let d=c.parentId&&r.has(c.parentId)?c.parentId:null,u=n.get(d)??[];u.push(c.id),n.set(d,u)}let o=[],a=new Set,i=c=>{if(!(a.has(c)||!r.has(c))){a.add(c),o.push(c);for(let d of n.get(c)??[])i(d)}},s=ye(e);s&&i(s);for(let c of n.get(null)??[])i(c);for(let c of t)i(c.id);return o}function gy(e,t){if(t.parentId){let n=$(e,t.parentId);return n&&At(n)?n.id:null}let r=t.activeId?$(e,t.activeId):null;if(r&&At(r))return r.id;if(r?.parentId){let n=$(e,r.parentId);if(n&&At(n))return n.id}return ye(e)}function Dk(e,t){return t.parentId===null?ye(e):gy(e,t)}function Ru(e,t){if(t.placement==="root")return ye(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?$(e,t.targetId):null;return t.parentId??r?.parentId??ye(e)}function by(e,t){return t&&Cu(e,t)?t:ye(e)}function Cu(e,t){let r=$(e,t);return!!r&&At(r)}function nc(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=$(e,t);if(!i)return null;let s=n?o.resolveLocalTransform?.({document:e,intent:n,gameObject:i,parentId:r,worldTransform:a}):null;if(s)return En(s);let c=Aa(e,r,a,o.preserveWorldPolicy);return c?En(c):null}function Sy(e,t,r={}){let n=Zi(r),o=oo(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?En(o):null}function Mk(e,t,r){let n=yy(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=kk(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:Ru(e,r)});return hy(a,n,i)}function wk(e,t,r,n){let o=yy(e,r),a=new Set(o),i=e.scene.gameObjects.map(l=>l.id),s=i.filter(l=>!a.has(l)),c=Math.min(...r.map(l=>i.indexOf(l)).filter(l=>l>=0)),d=Number.isFinite(c)?s.filter(l=>i.indexOf(l)<c).length:s.length,u=n?Math.max(0,s.indexOf(n)):d;return hy(s,[t,...o],u)}function yy(e,t){let r=kt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function kk(e,t,r){return r.beforeId?ay(t.indexOf(r.beforeId),t.length):r.afterId?rc(e,t,r.afterId):r.placement==="before"&&r.targetId?ay(t.indexOf(r.targetId),t.length):r.placement==="after"&&r.targetId||r.placement==="inside"&&r.targetId?rc(e,t,r.targetId):r.placement==="root"?t.length:r.parentId?rc(e,t,r.parentId):t.length}function rc(e,t,r){let n=kt(e,[r]),o=t.indexOf(r);if(o<0)return t.length;for(let a=o+1;a<t.length&&n.has(t[a]);a+=1)o=a;return o+1}function hy(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function ay(e,t){return e>=0?e:t}function Ey(e,t){let r=t.map(o=>ke(e,o)).filter(o=>!!o);if(r.length===0)return null;let n=r.map(Yi);return{x:n.reduce((o,a)=>o+a.x,0)/n.length,y:n.reduce((o,a)=>o+a.y,0)/n.length,z:n.reduce((o,a)=>o+a.z,0)/n.length}}function Ok(e,t,r){let n=r?$(e,r):null;if(n?.parentId&&!t.has(n.parentId)&&$(e,n.parentId))return n.parentId;for(let o=e.scene.gameObjects.length-1;o>=0;o-=1){let a=e.scene.gameObjects[o];if(!t.has(a.id))return a.id}return null}function Rk(e,t,r){let n=Nl(e),o=new Set,a=n.get(r);for(;a?.parentId&&!o.has(a.parentId);){if(a.parentId===t)return!0;o.add(a.parentId),a=n.get(a.parentId)}return!1}function Ck(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function vk(e){return e[0].toUpperCase()+e.slice(1)}function Gk(e){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function oc(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function Iy(e,t){return!Tt(e)||!Tt(t)?ca(Fe(e),Fe(t)):Du(e.position,t.position)&&Du(e.rotation,t.rotation)&&Du(e.scale,t.scale)}function Du(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function jk(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function Gu(e){return{getHierarchyItems(t){return vu(t,e)},normalizeHierarchyDocument(t){return $l(t)},createRenamePatch(t,r){return yr(iy(t,r))},createCreateGroupPatch(t,r){return yr(sy(t,r))},createCreatePrimitivePatch(t,r){return yr(cy(t,r))},createDeleteSubtreePatch(t,r){let n=ly(t,r);if(!n)return null;let o=new Set(n.deletedIds);return t.scene.gameObjects.some(a=>o.has(a.id)&&e.isProtectedSystemGameObject(a))?null:yr(n)},collectSubtreeIdList(t,r){return br(t,r)},validateReparent(t,r){let n=e.findGameObject(t,r.draggedId),o=e.findGameObject(t,r.targetId);return n&&e.isProtectedSystemGameObject(n)?{ok:!1,reason:"Protected system GameObject cannot be reparented."}:o&&e.isProtectedSystemGameObject(o)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Mu(t,r)},createReparentPatch(t,r){return yr(uy(t,r))},validateHierarchyMove(t,r){let n=vu(t,e);if(ht(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be moved."};let a=Nk(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:wu(t,r)},createHierarchyMovePatch(t,r){return yr(my(t,r))},validateGroupSelection(t,r){let n=vu(t,e);if(ht(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be grouped."};let a=Fk(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:ku(t,r)},createGroupSelectionPatch(t,r){return yr(fy(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return yr(py({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return yr(Zl(t))}}}function vu(e,t){let r=gr(e),n=new Map(e.scene.gameObjects.map(a=>[a.id,a])),o=[];for(let a of r){let i=n.get(a.id)??null;o.push(t.decorateHierarchyItem?.({item:a,gameObject:i,document:e})??a),i&&o.push(...t.collectHierarchyItemChildren?.({item:a,gameObject:i,document:e})??[])}return o}function Nk(e,t,r){if(t.placement==="root")return r.resolveRootContainerId(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let n=t.targetId?r.findGameObject(e,t.targetId):null;return t.parentId??n?.parentId??r.resolveRootContainerId(e)}function Fk(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&At(n)?n.id:r.resolveRootContainerId(e)}function yr(e){return e?{...e,patch:e.patch}:null}function ju(e,t){let r=t.ensureGameObjectGuids(e),n=t.resolveRootContainerId(r),o=!1,a=!1,i=!1,s=r!==e,c=t.ensureDefaultMaterialAssets(r.scene.materialAssets??[]);s=s||c!==r.scene.materialAssets;let d=r.scene.gameObjects.map(g=>{if(g.id===t.systemDefaults.environmentLightId){a=!0;let b=t.systemDefaults.normalizeEnvironmentLightGameObject(g);return s=s||b!==g,b}if(g.id===t.systemDefaults.sunLightId){i=!0;let b=t.systemDefaults.normalizeSunLightGameObject(g);return s=s||b!==g,b}if(t.isCameraGameObject(g)){if(!o){o=!0;let b=t.systemDefaults.normalizeCameraGameObject(g);return s=s||b!==g,b}return s=!0,t.systemDefaults.normalizePlainTransformGameObject(g)}if(t.isLightGameObject(g)){let b=t.systemDefaults.normalizePlainTransformGameObject(g);return s=!0,b}if(!t.isCustomTransformType?.(g.transformType)&&_k(g)){let b=t.systemDefaults.normalizePlainTransformGameObject(g);return s=s||b!==g,b}return g}),u={createGameObjectGuid:t.createGameObjectGuid,createUniqueId:t.createUniqueId},l=new Set(d.map(g=>g.id));o||(s=!0,d.push(t.systemDefaults.createDefaultCameraGameObject(n,l,u))),a||(s=!0,d.push(t.systemDefaults.createDefaultEnvironmentLightGameObject(n,l,u))),i||(s=!0,d.push(t.systemDefaults.createDefaultSunLightGameObject(n,l,u)));let m=t.normalizeMaterialBindings({...r,scene:{...r.scene,gameObjects:d,materialAssets:c}},c,d);c=m.materialAssets,d=m.gameObjects,s=s||m.changed;let f=s?{...r,scene:{...r.scene,gameObjects:d,materialAssets:c}}:r;return t.syncMarkerGraphDocument(f)}function _k(e){return(e.kind==="transform"||e.transformType==="plain")&&!e.camera&&!e.light&&!e.primitive&&!e.prefab&&!e.marker&&!e.components.some(t=>t.type==="ModelRenderer"||t.type==="ImageRenderer")}function Nu(e,t,r){let n=r.normalizeRootTransformDocument($k(e,t,r));return r.syncMarkerGraphDocument(r.ensureGameObjectGuids(r.normalizeDocumentAfterCommand(n,t)))}function ac(e){return{normalizeFieldValue:e.normalizeFieldValue,validateField:({document:t,gameObject:r,path:n,value:o})=>e.validateField(t,r,n,o),blockFieldPatch:({document:t,targetId:r,path:n,value:o})=>ic(t,r,n,o,e),normalizePrimitiveShape:e.normalizePrimitiveShape,mergeCameraDefaults:e.systemDefaults.mergeCameraDefaults,normalizeCameraAfterFieldPatch:(t,r)=>t&&e.systemDefaults.normalizeCameraAfterFieldPatch(t,r),mergeLightDefaults:e.systemDefaults.mergeLightDefaults,isCustomTransformType:e.isCustomTransformType,applyCustomTransformType:e.applyCustomTransformType,clearCustomTransformState:e.clearCustomTransformState,patchCustomTransformField:e.patchCustomTransformField}}function Fu(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=Mg(a,{...r===o.systemDefaults.horizontalLightAnglePath?{horizontalAngleDeg:n}:{},...r===o.systemDefaults.elevationLightAnglePath?{elevationAngleDeg:n}:{}});return i===a?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(s=>s.id===t?i:s)}}}function ic(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return!1;let i=o.isCameraGameObject(a),s=o.isLightGameObject(a),c=o.isProtectedSystemGameObject(a),d=a.id===o.systemDefaults.sunLightId&&a.light?.type==="directional"&&(r==="transform.rotation"||r.startsWith("transform.rotation."));if(r.startsWith("transform.")&&c&&!d||r.startsWith("camera.")&&!i)return!0;if(r.startsWith("camera.")&&i){let u={camera:o.systemDefaults.mergeCameraDefaults(a.camera)};if(Oe(u,r,n),u.camera&&(u.camera=o.systemDefaults.normalizeCameraAfterFieldPatch(u.camera,r),o.systemDefaults.hasInvalidCameraRelationships(u.camera)))return!0}return!!(r.startsWith("light.")&&!s||r==="light.type"&&(a.id===o.systemDefaults.environmentLightId&&n!=="hemispheric"||a.id===o.systemDefaults.sunLightId&&n!=="directional")||r==="transformType"&&(i&&n!=="camera"||s&&n!=="light"||!s&&n==="light"||n==="camera"&&!i&&o.hasCamera(e,t)))}function $k(e,t,r){let n=t.type==="document.replace"?null:t.patch;if(n){if(n.kind==="scene.material-asset.field")return r.patchMaterialAssetField(e,n.materialAssetId,n.path,n.value);if(n.kind==="scene.material-asset.replace")return r.replaceMaterialAsset(e,n.materialAssetId,n.materialAsset);if(n.kind==="scene.material-asset.create")return r.addMaterialAsset(e,n.materialAsset);if(n.kind==="scene.material-asset.delete")return r.deleteMaterialAsset(e,n.materialAssetId);if(n.kind==="scene.material-asset.create-and-bind")return r.addMaterialAssetAndBind(e,n.targetId,n.bindingPath,n.materialAsset);if(n.kind==="scene.prefab-asset.create")return r.addPrefabAsset(e,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-asset.create-from-game-object"||n.kind==="scene.prefab-asset.duplicate")return r.addPrefabAsset(e,n.prefabAsset);if(n.kind==="scene.prefab-asset.field")return r.patchPrefabAssetField(e,n.assetId,n.path,n.value);if(n.kind==="scene.prefab-asset.replace")return r.replacePrefabAsset(e,n.assetId,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-material-asset.duplicate-and-bind")return r.addMaterialAssetAndBindPrefabOverride(e,n.assetId,n.bindingPath,n.materialAsset);let o=r.reduceExtensionPatch?.({document:e,patch:n,command:t});if(o)return o;if(n.kind==="game-object.field"&&r.isDirectionalLightAnglePath(n.path)||n.kind==="game-object.field"&&r.isCustomFieldPatchPath?.(n.path))return r.patchGameObjectField(e,n.targetId,n.path,n.value);if(n.kind==="game-object.rendering-alpha-index-migration")return zk(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return hu(e,t,Lk(r))}function Lk(e){return{field:ac(e),serializedProperty:{validateField:e.validateSerializedPropertyField},assetPlacement:{createGameObjectGuid:e.createGameObjectGuid,resolveLocalTransform:({document:t,parentId:r,worldTransform:n})=>e.resolveLocalTransform({document:t,parentId:r,worldTransform:n})},isProtectedDuplicateSource:t=>e.isProtectedSystemGameObject(t),isProtectedDeleteTarget:t=>e.isProtectedSystemGameObject(t)}}function zk(e,t){return Yl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function Ao(e,t){let r=e.path,n=t.normalizeValue(r,e.value),o=t.parseMaterialAssetFieldPath(r);if(o){let l=t.normalizeMaterialAssetValue(o.fieldPath,n);if(!t.hasMaterialAsset(e.document,o.materialAssetId)||!t.validateMaterialAssetFieldValue(e.document,o.materialAssetId,o.fieldPath,l))return null;let m=t.collectMaterialAssetBindingIds(e.document,o.materialAssetId);return{label:`Patch material asset ${o.materialAssetId} ${o.fieldPath}`,patch:t.createMaterialAssetFieldPatch(o.materialAssetId,o.fieldPath,l),changedId:m[0]??e.targetId,changedIds:m,...o.fieldPath.startsWith("properties.")?{reprojectIds:m}:{}}}let a=t.findGameObject(e.document,e.targetId);if(!a)return null;let i=a.id,s=t.parseDuplicateMaterialAssetValue(n);if(s&&t.isMaterialBindingPath(r))return Bk(e.document,a,r,s,t);if(t.isRootTransformPath(i,r))return null;if(r==="marker.target.objectId"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTargetUpdateCommand(e.document,i,n);return l?_u(i,"marker.target",l,t):null}if(r==="marker.geometry.kind"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerGeometryUpdateCommand(e.document,i,n);return l?_u(i,"marker.geometry",l,t):null}if(!t.validateValue(e.document,a,r,n).ok||t.blockFieldPatch(e.document,i,r,n))return null;if(r==="marker.type"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTypeUpdateCommand(e.document,i,n);return l?_u(i,"marker.type",l,t):null}if(t.isDirectionalLightAnglePath(r)&&typeof n=="number"&&Number.isFinite(n))return{label:`Patch ${i} ${r}`,patch:t.createDirectionalLightPatch(i,r,n),changedId:i,changedIds:[i],reprojectIds:[i]};let c=t.createCustomInspectorPropertyPatch?.({...e,gameObject:a,path:r,value:n});if(c)return c;let d=t.collectChangedIdsForFieldPath(e.document,i,r),u=t.isProjectionShapePath(r)||t.isArtistMaterialPatchPath(r)||t.isCustomProjectionPath?.(r)?[i]:void 0;return{label:`Patch ${i} ${r}`,patch:t.createGameObjectFieldPatch(i,r,n),changedId:i,changedIds:d,...u?{reprojectIds:u}:{}}}function sc(e,t,r,n,o){let a=o.patchCustomGameObjectField?.({document:e,targetId:t,path:r,value:n});if(a)return a;if(r.startsWith("metadata.")||o.isDirectionalLightAnglePath(r)){let s=o.findGameObject(e,t);if(!s)return e;let c=o.normalizeValue(r,n);return!o.validateValue(e,s,r,c).ok||o.blockFieldPatch(e,t,r,c)?e:o.isDirectionalLightAnglePath(r)&&typeof c=="number"&&Number.isFinite(c)?o.patchDirectionalLightAngleField(e,t,r,c):Vk(e,t,r,c,o)}let i=Rn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function Py(e,t,r,n,o){let a=Array.from(new Set(t.filter(Boolean)));if(a.length===0)return e;let i=o.patchCustomGameObjectsField?.({document:e,targetIds:a,path:r,value:n,patchSingle:(c,d,u,l)=>sc(c,d,u,l,o)});if(i)return i;if(r.startsWith("metadata."))return Uk(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>sc(c,d,r,n,o),e);let s=$a(e,a,r,n,o.fieldMutationOptions);return a.reduce((c,d)=>o.normalizeAfterFieldPatch(c,d,r,n),s)}function _u(e,t,r,n){return{label:`Patch ${e} ${t}`,patch:n.createMarkerGraphPatch(r),changedId:e,changedIds:[e],reprojectIds:[e]}}function Bk(e,t,r,n,o){let a=oS({document:e,gameObject:t,bindingPath:r,sourceMaterialAssetId:n,isBindingPathAllowed:s=>o.isMaterialBindingPathAllowed(t,s)});return a?{label:`Duplicate material ${o.findMaterialAssetName(e,n)??n} for ${t.name??t.id}`,patch:a.patch,changedId:a.changedId,changedIds:a.changedIds,createdId:a.createdId,reprojectIds:a.reprojectIds}:null}function Vk(e,t,r,n,o){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>{if(a.id!==t)return a;let i=structuredClone(a);return Oe(i,r,n),i.metadata&&Object.keys(i.metadata).length===0&&delete i.metadata,i})}}}function Uk(e,t,r,n,o){let a=new Set(t),i=o.normalizeValue(r,n),s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id))return d;let u=d;if(!o.validateValue(e,u,r,i).ok||o.blockFieldPatch(e,d.id,r,i))return d;let l=structuredClone(d);return Oe(l,r,i),l.metadata&&Object.keys(l.metadata).length===0&&delete l.metadata,s=!0,l});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function xy(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:hn(r.path,r.value)};return La({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return Ty({document:t.document,targetIds:t.targetIds,activeId:t.activeId,path:t.path,value:e.getSerializedMultiPropertyProbeValue(t.path),services:e}).length>0},createSerializedMultiPropertyPatch(t){if(!e.isSerializedMultiFieldPath(t.path))return null;let r=hn(t.path,t.value),n=Ty({...t,value:r,services:e});return n.length===0?null:{label:`Patch ${n.length} GameObjects ${t.path}`,patch:e.createFieldBatchPatch(n.map(o=>({targetId:o,path:t.path,value:r}))),changedIds:n,...e.isSerializedMultiProjectionPath(t.path)?{reprojectIds:n}:{}}}}}function Ty(e){return e.services.isSerializedMultiFieldPath(e.path)?e.targetIds.filter(t=>{let r=e.services.findGameObject(e.document,t);return e.services.canPatchCustomSerializedMultiField?.({document:e.document,targetId:t,path:e.path,value:e.value})===!1||e.services.isSerializedMultiProjectionPath(e.path)&&(!r||e.services.isCameraGameObject(r)||e.services.isLightGameObject(r))?!1:!!e.services.createInspectorPropertyPatch({document:e.document,targetId:t,path:e.path,value:e.value})}):[]}var Kk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Hk=/^transform\.(position|rotation|scale)$/,Wk=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Rn(e,t,r,n,o={}){return qk({document:e,targetId:t,path:r,value:n,options:o})}function $a(e,t,r,n,o={}){let a=new Set(t.filter(Boolean));if(a.size===0)return e;let i=o.normalizeFieldValue?.(r,n)??n,s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id)||$u(d.id,r))return d;let u=d;if(o.validateField?.({document:e,gameObject:u,path:r,value:i})?.ok===!1||o.blockFieldPatch?.({document:e,gameObject:u,targetId:d.id,path:r,value:i}))return d;let l=Iu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function Eu(e,t,r={}){let n=new Map;for(let i of t){if(!i.objectId||i.changes.length===0)continue;let s=n.get(i.objectId)??[];s.push(...i.changes),n.set(i.objectId,s)}if(n.size===0)return e;let o=!1,a=e.scene.gameObjects.map(i=>{let s=n.get(i.id);if(!s?.length)return i;let c;for(let d of s){if($u(i.id,d.path))continue;let u=r.normalizeFieldValue?.(d.path,d.value)??d.value;r.validateField?.({document:e,gameObject:c??i,path:d.path,value:u})?.ok!==!1&&(r.blockFieldPatch?.({document:e,gameObject:c??i,targetId:i.id,path:d.path,value:u})||(c??=structuredClone(i),c=wy(c,d.path,u,r,!0)))}return!c||JSON.stringify(c)===JSON.stringify(i)?i:(o=!0,c)});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function qk(e){if($u(e.targetId,e.path))return e.document;let t=$(e.document,e.targetId);if(!t)return e.document;let r=e.options?.normalizeFieldValue?.(e.path,e.value)??e.value;if(e.options?.validateField?.({document:e.document,gameObject:t,path:e.path,value:r})?.ok===!1||e.options?.blockFieldPatch?.({document:e.document,gameObject:t,targetId:e.targetId,path:e.path,value:r}))return e.document;let n=Iu(t,e.path,r,e.options);return n===t?e.document:{...e.document,scene:{...e.document.scene,gameObjects:e.document.scene.gameObjects.map(o=>o.id===e.targetId?n:o)}}}function Iu(e,t,r,n={}){let o=wy(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function wy(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?Ay(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?Dy(a):null;if(t==="name")return typeof r=="string"&&r.trim()?a.name=r.trim():delete a.name,a;if(t==="enabled")return a.active=r!==!1,a;if(t.startsWith("shadow."))return mn(a)&&Jk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=Yk(t,r);return Oe(a,t,c),Zk(a),a}if(t.startsWith("metadata."))return Oe(a,t,r),a.metadata&&Object.keys(a.metadata).length===0&&delete a.metadata,a;if(t==="instance.assetId"){let c=Se(a);return c&&typeof r=="string"&&(c.assetId=r),a.kind="instance",delete a.primitive,a}if(t==="primitive.shape"){let c=(n.normalizePrimitiveShape??rO)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return Qk(a,r,n),a;if(eO(a,t,r)){let c=i?Ay(a):null;return i&&c&&!My(i,c)?mo(a):a}if(n.patchCustomTransformField?.(a,t,r))return a;if(t.startsWith("marker."))return!a.marker||typeof a.marker!="object"||(a.kind="transform",delete a.primitive,Oe(a,t,r)),a;if(t.startsWith("camera."))return a.kind="transform",a.transformType="camera",a.camera=ky(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=tO(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=Oy(a.light,n),delete a.camera,n.clearCustomTransformState?.(a,"light"),delete a.primitive,Oe(a,t,r),(t==="light.direction"||t.startsWith("light.direction."))&&a.light?.type==="directional"&&(a.light.direction=Ta(a.light.direction,s??void 0));let c=s?Dy(a):null;return s&&c&&!My(s,c)?xs(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Jl(a)),a}function Ay(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function Dy(e){return e.light?.type==="directional"?{...e.light.direction}:null}function My(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Jk(e,t,r){if(!Xk(t,r))return;let n=e.shadow;e.shadow={cast:t==="shadow.cast"?r===!0?"enabled":"none":n?.cast==="enabled"?"enabled":"none",receive:t==="shadow.receive"?r===!0?"enabled":"none":n?.receive==="enabled"?"enabled":"none"}}function Xk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function Yk(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function Zk(e){let t=e.rendering;if(!t||typeof t!="object"||Array.isArray(t)){delete e.rendering;return}Object.keys(t).length===0&&delete e.rendering}function $u(e,t){return me(e)&&Kk.test(t)}function Qk(e,t,r){let n=t==="plain"||t==="light"||t==="camera",o=!n&&r.isCustomTransformType?.(t)===!0;if(!n&&!o)return;let a=t;e.kind="transform",e.transformType=a,delete e.primitive,a==="camera"?e.camera=ky(e.camera,r):delete e.camera,a==="light"?e.light=Oy(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function eO(e,t,r){let n=t.match(Hk);if(n){let a=G(e);if(!a||Ee(a))return!0;let i=n[1];return i==="scale"?(w(r)?a.scale={x:r,y:r,z:r}:Je(r)&&(a.scale={...r}),!0):(Je(r)&&(a[i]=i==="rotation"?{x:Wt(r.x),y:Wt(r.y),z:Wt(r.z)}:{...r}),!0)}let o=t.match(Wk);if(o&&w(r)){let a=G(e);if(!a||Ee(a))return!0;let i=o[1],s=o[2],c=i==="rotation"?Wt(r):r;return i==="scale"?a.scale={...it(a,"scale"),[s]:c}:a[i]={...a[i],[s]:c},!0}return!1}function ky(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):Ry(e)}function tO(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function Oy(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):Ry(e)}function rO(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function Ry(e){return nO(e)??{}}function nO(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var jy=["position","rotation","scale"],Ny=["x","y","z"],oO=1e-6;function Lu(e){let t=[{path:"gameObject.id",label:"ID",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.id},{path:"gameObject.name",label:"Name",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.name??e.gameObject.id}],r=G(e.gameObject);if(r){let o=Z(e.gameObject),a=o?Pt():Gs(r)?r:null;if(!a)return t;for(let i of jy)for(let s of Ny)t.push(sO({gameObject:e.gameObject,vectorName:i,axis:s,rootTransform:o,displayTransform:a,validateField:e.validateField}))}let n=Se(e.gameObject);return n&&t.push({path:"modelRenderer.assetId",label:"Asset ID",valueType:"asset",readOnly:!0,getValue:()=>n.assetId}),Ly(e.gameObject)&&t.push(...aO({gameObject:e.gameObject,validateField:e.validateField})),t}function Fy(e){let t=[];for(let r of jy)for(let n of Ny){let o=e.map(d=>{let u=G(d);return u&&!Ee(u)?it(u,r)[n]:null}).filter(d=>typeof d=="number");if(o.length!==e.length)continue;let a=r==="rotation"?o.map(xt):o,i=a[0]??0,s=a.some(d=>Math.abs(d-i)>oO),c=`transform.${r}.${n}`;t.push({path:c,label:`${r}.${n}`,valueType:"number",value:st(i),mixed:s,readOnly:!1,descriptor:{path:c,valueType:"number",getValue:()=>i}})}return t}function cc(e){if(e.length===0)return[];let t=e.map(n=>n.active!==!1),r=t[0]??!0;return[{path:"enabled",label:"Enabled",valueType:"boolean",value:r,mixed:t.some(n=>n!==r),readOnly:!1,descriptor:{path:"enabled",label:"Enabled",valueType:"boolean",getValue:()=>r}}]}function Ka(e){return e.length===0||e.some(r=>!Ly(r))?[]:[vy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),vy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function aO(e){return[Cy({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Cy({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Cy(e){return{path:e.path,label:e.label,valueType:e.valueType,...e.options?{options:e.options}:{},getValue:()=>_y(e.gameObject,e.path,e.defaultValue),setValue:(t,r,n)=>{if(!n.targetId)return t;let o=hn(e.path,r),a=e.validateField?.({document:t,gameObject:e.gameObject,nodeKind:Y(e.gameObject),path:e.path,value:o});return a&&!a.ok?t:Rn(t,n.targetId,e.path,o)}}}function vy(e,t){let n=e.map(a=>_y(a,t.path,t.defaultValue))[0]??t.defaultValue,o=iO(e,t.path);return{path:t.path,label:t.label,valueType:t.valueType,value:n,mixed:o,readOnly:!1,...t.options?{options:t.options}:{},descriptor:{path:t.path,label:t.label,valueType:t.valueType,...t.options?{options:t.options}:{},getValue:()=>n}}}function iO(e,t){let r=e.map(n=>$y(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function _y(e,t,r){let n=$y(e);return t==="shadow.cast"?Gy(n.cast):t==="shadow.receive"?Gy(n.receive):r}function Gy(e){return e==="enabled"}function $y(e){return We(e.shadow).shadow??{}}function Ly(e){if(Z(e)||e.transformType==="camera"||e.transformType==="light"||e.camera||e.light)return!1;let t=Y(e);return t==="instance"||t==="primitive"||t==="transform"}function sO(e){return{path:`transform.${e.vectorName}.${e.axis}`,label:`${e.vectorName}.${e.axis}`,valueType:"number",readOnly:e.rootTransform,getValue:()=>{let r=it(e.displayTransform,e.vectorName)[e.axis];return e.vectorName==="rotation"?st(xt(r)):r},...e.rootTransform?{}:{setValue:(r,n,o)=>cO({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function cO(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=$(e.document,e.targetId),n=r?G(r):null;if(!r||!n||Ee(n))return e.document;let o=`transform.${e.vectorName}.${e.axis}`,a=e.validateField?.({document:e.document,gameObject:r,nodeKind:Y(r),path:o,value:t});if(a&&!a.ok)return e.document;let i=e.vectorName==="rotation"?Wt(t):t,s=e.vectorName==="position"?{...n.position,[e.axis]:i}:n.position,c=e.vectorName==="rotation"?{...n.rotation,[e.axis]:i}:n.rotation,d=e.vectorName==="scale"?{...it(n,"scale"),[e.axis]:i}:it(n,"scale");return dO(e.document,e.targetId,{position:s,rotation:c,scale:d})}function dO(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Fl(n,r):n)}}}function zy(e){let t=new Map(e.document.scene.gameObjects.map(o=>[o.id,o])),r=e.targetIds.map(o=>t.get(o)??null).filter(o=>!!o&&!Z(o));if(r.length===0)return null;let n=r.map(o=>o.id);return{targetIds:n,activeId:e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null,label:e.label??`${r.length} GameObjects`,properties:[...cc(r),...Fy(r),...Ka(r)]}}var Bu="enabled",By="shadow.",Vy=200;function Uu(e){let t=lO(e.document,e.selectedIds);if(t.length===0)return null;let r=t.map(l=>l.id),n=e.activeId&&r.includes(e.activeId)?e.activeId:r[0]??null,o=e.largeSelectionThreshold??Vy,a=uO(t),i=Ka(a),s=t.length>o,c=s?mO({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):zy({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>Ky(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Uy({document:e.document,serialized:d,shadowOnly:s,renderingProfile:e.renderingProfile});return u.length===0?null:{targetIds:d.targetIds,activeId:d.activeId,label:d.label,document:e.document,selection:{targetIds:d.targetIds,activeId:d.activeId,document:e.document},sections:u}}function Uy(e){let t=fO(e.document,e.serialized,e.serialized.properties.filter(n=>Ky(n.path)),e.renderingProfile),r=zu("common","Common",10,e.serialized.properties.filter(n=>n.path===Bu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,zu("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,zu("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Bu&&!n.path.startsWith(By)),e.document)].filter(n=>!!n)}function lO(e,t){let r=new Map(e.scene.gameObjects.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.get(a);i&&(Z(i)||o.push(i))}return o}function uO(e){return e.filter(t=>yo({gameObject:t,nodeKind:Y(t)}))}function mO(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:Ka(e.shadowGameObjects);return{targetIds:e.gameObjects.map(r=>r.id),activeId:e.activeId,label:e.label??`${e.gameObjects.length} GameObjects`,properties:[...cc(e.gameObjects),...t]}}function fO(e,t,r,n){if(r.length===0)return null;let o=new Map(e.scene.gameObjects.map(S=>[S.id,S])),a=t.targetIds.map(S=>o.get(S)).filter(S=>!!S).filter(S=>yo({gameObject:S,nodeKind:Y(S)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&yo({gameObject:i,nodeKind:Y(i)})?i:a[0]??null;if(!s)return null;let c=Y(s),d=r.find(S=>S.path==="shadow.cast"),u=r.find(S=>S.path==="shadow.receive");if(!d||!u)return null;let l=Vu(d,0),m=Vu(u,1),f=yn({path:d.path,nodeKind:c,document:e}),g=yn({path:u.path,nodeKind:c,document:e}),b=n!==void 0&&ks(Fs(n))==="none";return{id:"shadow",title:"\u9634\u5F71",order:25,placement:"body",...b?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[{...l,label:"\u6295\u5C04\u9634\u5F71",control:"boolean",value:l.value===!0,mixed:l.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6240\u9009\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002",validate:f},{...m,label:"\u63A5\u6536\u9634\u5F71",control:"boolean",value:m.value===!0,mixed:m.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002",validate:g},...b?[Vl()]:[]]}}function Ky(e){return e.startsWith(By)}function zu(e,t,r,n,o){return n.length===0?null:{id:e,title:t,order:r,placement:"body",persistence:"document",properties:n.map((a,i)=>{let s=Vu(a,i),c=pO(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?yn({path:a.path,nodeKind:c,document:o}):s.validate}})}}function Vu(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":gO(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:bO(e.valueType),order:t,source:e}}function pO(e,t){if(t.startsWith("transform."))return"transform";if(t===Bu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function gO(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function bO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var SO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function La(e){if(me(e.patch.targetId)&&SO.test(e.patch.path))return e.document;let t=$(e.document,e.patch.targetId);if(!t)return e.document;let r=e.patch.path.startsWith("transform.rotation")?Hy(t):null,n=e.patch.path.startsWith("light.direction")?Wy(t):null,o=Cp(e.document,Lu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=$(o,e.patch.targetId);if(!a)return o;let i=r?Hy(a):null,s=n?Wy(a):null,c=r&&i&&!qy(r,i),d=n&&s&&!qy(n,s);return!c&&!d?o:{...o,scene:{...o.scene,gameObjects:o.scene.gameObjects.map(u=>{if(u.id!==e.patch.targetId)return u;let l=c?mo(u):u;return d?xs(l):l})}}}function Hy(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function Wy(e){return e.light?.type==="directional"?e.light.direction:null}function qy(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Hu(e){let t=e.findGameObject(e.document,e.targetId);if(!t)return null;let r=e.isMarkerGameObject(t);return{targetIds:[t.id],activeId:t.id,label:t.name??t.id,document:e.document,selection:{targetIds:[t.id],activeId:t.id,scopeType:"scene",targetKind:r?"marker":e.readNodeKind(t),...r?{capabilities:["markerGraph"]}:{},document:e.document},sections:e.createInspectorSections(e.document,t,e.context)}}function Wu(e){let t=Uu({document:e.document,selectedIds:e.selectedIds,activeId:e.activeId,renderingProfile:e.renderingProfile}),r=t?{...t,selection:{...t.selection,scopeType:"scene"}}:null;if(!e.extraSection)return r;if(!r){let n=e.resolveFallbackTargetIds(),o=e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null;return{targetIds:n,activeId:o,label:e.formatFallbackLabel(n),document:e.document,selection:{targetIds:n,activeId:o,scopeType:"scene",targetKind:e.fallbackSelectionKind??"object",document:e.document},sections:[e.extraSection]}}return{...r,sections:[...r.sections.filter(n=>n.id!==e.extraSection.id),e.extraSection].sort((n,o)=>(n.order??0)-(o.order??0))}}function qu(e){let t=[...e.createBaseSections()],r=e.isCameraGameObject(e.gameObject),n=e.isLightGameObject(e.gameObject),o=e.isMarkerGameObject(e.gameObject),a=e.nodeKind==="transform";return Ku(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),Ha(t,a&&r?e.createCameraSection?.():null),Ku(t,a&&n?e.createLightSections?.():null),Ha(t,a&&o?e.createMarkerSection?.():null),Ha(t,e.createPrefabInstanceSection?.()),(e.isMaterialInspectorCandidate?.({nodeKind:e.nodeKind,gameObject:e.gameObject,isCamera:r,isLight:n,isMarker:o})??(e.nodeKind==="instance"||e.nodeKind==="primitive"||a&&!r&&!n&&!o))&&(Ku(t,e.createMaterialSections?.()),Ha(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function Ha(e,t){t&&e.push(t)}function Ku(e,t){if(t)for(let r of t)Ha(e,r)}function Ju(e){let t=e.outline,r=t?"active":"default",n=r==="default"?Jy:void 0;return{id:"outline",title:"Outline",order:60,placement:"body",summary:t?"Configured":"Defaults",persistence:r==="default"?"readonly":"document",effect:r,disabledReason:n,collapsedByDefault:!0,properties:hO(yO(e),r,n)}}var Jy="Outline fields are showing defaults; configure an outline override before edits affect this object.";function yO(e){let t=e.outline,r=[e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.renderOutline",label:"Render Outline",valueType:"boolean",control:"boolean",value:t?.renderOutline??!1,commitMode:"immediate",order:0}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineWidth",label:"Width",valueType:"number",control:"number",value:t?.outlineWidth??.04,commitMode:"live",order:1,min:0,step:.005,displayPrecision:3,precision:3,stepPrecision:.001}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineColor",label:"Color",valueType:"color",control:"color",value:t?.outlineColor??{r:.03,g:.03,b:.03},commitMode:"immediate",order:2})],n=j({path:"overrides.outline.raw",label:"Raw Override",value:t??"not configured",order:r.length,source:"Document",tags:["Raw"]});return n&&r.push(n),r}function hO(e,t,r){return!t||t==="active"?e:e.map(n=>({...n,readOnly:!0,persistence:n.persistence==="runtime"?"runtime":"readonly",control:n.control==="custom"?n.control:"readonly",effect:n.effect??t,disabledReason:n.disabledReason??r}))}var EO={title:"\u6807\u8BB0",typeLabel:"\u6807\u8BB0\u7C7B\u578B",kindLabel:"\u7A7A\u95F4\u7C7B\u522B",tagsLabel:"\u6807\u7B7E",colorLabel:"\u989C\u8272",noteLabel:"\u5907\u6CE8",geometryLabel:"\u51E0\u4F55",targetLabel:"\u7ED1\u5B9A\u5BF9\u8C61",targetStatusLabel:"\u7ED1\u5B9A\u72B6\u6001",emptyTypeOption:"\u672A\u9009\u62E9",emptyTargetOption:"\u672A\u7ED1\u5B9A",tagsPlaceholder:"\u6807\u7B7E, \u53E6\u4E00\u4E2A\u6807\u7B7E",notePlaceholder:"\u53EF\u9009\u6807\u8BB0\u5907\u6CE8",unselectedSummary:"\u672A\u9009\u62E9",missingTargetPrefix:"\u7F3A\u5931",missingTargetStatus:"\u76EE\u6807\u7F3A\u5931",targetStatusUnbound:"\u672A\u7ED1\u5B9A",targetStatusOk:"\u6B63\u5E38",unsupportedTargetPrefix:"\u4E0D\u652F\u6301\u76EE\u6807"},IO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},PO={box:"\u77E9\u5F62",cylinder:"\u5706\u5F62",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function Qu(e){let t={...EO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=xO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=e.markerTypeCatalog.find(l=>l.type===r.type)??null,i=n==="region"?TO(a,e.formatMarkerGeometryKindLabel):[],s=wO(r),c=s?.kind==="scene-object"?s.id:"",d=AO(e.document,e.gameObject.id,c,e.isMarkerGameObject,t),u=[e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.type",label:t.typeLabel,valueType:"enum",control:o.length>0?"enum":"string",value:r.type,coerce:l=>mr("marker.type",l),options:o.length>0?o:void 0,commitMode:"change",order:0}),Yu("marker.kind",t.kindLabel,MO(n,e.formatMarkerKindLabel),1),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.tags",label:t.tagsLabel,valueType:"string",control:"string",value:r.tags?.join(", ")??"",coerce:l=>mr("marker.tags",l),commitMode:"blur",placeholder:t.tagsPlaceholder,order:2}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.color",label:t.colorLabel,valueType:"color",control:"color",value:r.color??{r:.1,g:.85,b:1},commitMode:"immediate",order:3}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.note",label:t.noteLabel,valueType:"string",control:"string",value:r.note??"",coerce:l=>mr("marker.note",l),commitMode:"blur",placeholder:t.notePlaceholder,order:4}),i.length>0?e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.geometry.kind",label:t.geometryLabel,valueType:"enum",control:"enum",value:r.geometry.kind,options:i,commitMode:"change",order:5}):Yu("marker.geometry.kind",t.geometryLabel,Xy(r.geometry.kind,e.formatMarkerGeometryKindLabel),5),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.target.objectId",label:t.targetLabel,valueType:"enum",control:"enum",value:c,coerce:l=>mr("marker.target.objectId",l),options:d,commitMode:"change",order:6}),Yu("marker.target.status",t.targetStatusLabel,kO(e.document,s,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:DO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:u}}function TO(e,t){let r=e?.allowedGeometryKinds?.filter(o=>o==="box"||o==="cylinder")??[];return(r.length>0?[...new Set(r)]:e?.defaultGeometryKind?[e.defaultGeometryKind]:["box"]).map(o=>({label:Xy(o,t),value:o}))}function xO(e,t,r,n){let o=e.map(a=>({label:Zu(a.type,a.label||a.type,n),value:a.type}));return t&&!o.some(a=>a.value===t)&&o.push({label:Zu(t,t,n),value:t}),o}function AO(e,t,r,n,o){let a=[{label:o.emptyTargetOption,value:""},...e.scene.gameObjects.filter(i=>i.id!==t&&!n(i)).map(i=>({label:i.name||i.id,value:i.id}))];return r&&!a.some(i=>i.value===r)&&a.push({label:`${o.missingTargetPrefix}: ${r}`,value:r}),a}function DO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Zu(t,o?.label||t,n)}function Zu(e,t,r){return r?.(e,t)??t}function MO(e,t){return t?.(e)??IO[e]??e}function Xy(e,t){return t?.(e)??PO[e]??e}function wO(e){return e.target?Xu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Xu(e.geometry.target):null}function kO(e,t,r){return t?t.kind!=="scene-object"?`${r.unsupportedTargetPrefix}: ${t.kind}`:e.scene.gameObjects.some(n=>n.id===t.id)?r.targetStatusOk:r.missingTargetStatus:r.targetStatusUnbound}function Xu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Yu(e,t,r,n){return j({path:e,label:t,value:r,order:n,source:"Document"})}var Wa={r:1,g:1,b:1,a:1};function OO(e){return{...e}}function eh(e){let t=OO(e);return{services:t,normalizeLayoutPatchValue:r=>pc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>ih(r,n,t),canPatchMultiField:(r,n,o,a)=>jO(r,n,o,a,t),patchLayout:(r,n,o)=>NO(r,n,o,t),patchKind:(r,n,o)=>FO(r,n,o,t),patchInspectorField:(r,n,o,a)=>_O(r,n,o,a,t),normalizeGameObject:r=>Gn(r,t),replaceUi:(r,n,o)=>LO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>dc(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>zO(r,n,t),normalizeScales:(r,n,o)=>fc(r,t,n,o),mergeDefaults:r=>ut(r,t.createDefaultGroundDecal,t)}}function th(e){return{...e.policy,createDocumentInspectorProperty:e.createDocumentInspectorProperty,normalizeValue:e.normalizeValue,findTarget:e.findTarget,getTargetId:e.getTargetId,getTargetNodeKind:e.getTargetNodeKind,getTargetGroundDecal:e.getTargetGroundDecal,canShowTarget:e.canShowTarget,isUiTarget:e.isUiTarget,canPatchMultiField:e.canPatchMultiField,findTextureAsset:e.findTextureAsset,resolveTextureAssetUrl:e.resolveTextureAssetUrl,getMaterialText:e.getMaterialText,createTexturePickerControlOptions:e.createTexturePickerControlOptions}}var RO=75;function em(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:ch({x:typeof r.x=="number"?r.x:1,y:typeof r.y=="number"?r.y:1,z:typeof r.z=="number"?r.z:1})}return!/^transform\.scale\.(x|y|z)$/.test(e)||typeof t!="number"||!Number.isFinite(t)?null:Math.max(.001,Math.abs(t))}function pc(e,t={}){let r=Qa(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>CO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function CO(e,t,r={}){let n=Qa(e);if(!n)return null;let o=mR(n.id)??`layer_${t}`,a=Mo(n.rect),i=n.fontSize==null?null:lc(n.fontSize),s=n.rotationDeg==null?null:ko(n.rotationDeg);return!a||n.fontSize!=null&&i==null||n.rotationDeg!=null&&s==null?null:{id:o,rect:a,...s==null?{}:{rotationDeg:s},...i==null?{}:{fontSize:Ur(i)}}}function Mo(e){let t=Qa(e);if(!t)return null;let r=Yt(t.x),n=Yt(t.z),o=lc(t.width),a=lc(t.depth);return r==null||n==null||o==null||a==null?null:{x:r,z:n,width:o,depth:a}}function Yt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function lc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function rh(e,t){if(e==="groundDecal.editorPreviewActive")return typeof t=="boolean"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(gc(e))return Mo(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(nh(e)){let r=ko(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(bc(e))return typeof t=="string"?{ok:!0,value:t.trim()}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(hc(e))return typeof t=="string"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(oh(e)){let r=rm(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(Sc(e)||Pc(e)||Ec(e)){let r=qa(t);return r?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(yc(e)||Tc(e)||Ic(e)){let r=Ja(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(xc(e)){let r=tm(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(Kr(e)){let r=Za(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Xa(e){let t=e.match(/^groundDecal\.layers\.(\d+)\.(rect|rotationDeg|textureId|text\.value|text\.fontSize|color|color\.a|tint|tint\.a|text\.color|text\.color\.a|editorPreviewPercent)$/);if(!t)return null;let r=Number(t[1]);return!Number.isInteger(r)||r<0?null:{index:r,field:t[2]}}function gc(e){return/^groundDecal\.layers\.\d+\.rect$/.test(e)}function nh(e){return/^groundDecal\.layers\.\d+\.rotationDeg$/.test(e)}function bc(e){return/^groundDecal\.layers\.\d+\.textureId$/.test(e)}function Sc(e){return/^groundDecal\.layers\.\d+\.color$/.test(e)}function yc(e){return/^groundDecal\.layers\.\d+\.color\.a$/.test(e)}function hc(e){return/^groundDecal\.layers\.\d+\.text\.value$/.test(e)}function oh(e){return/^groundDecal\.layers\.\d+\.text\.fontSize$/.test(e)}function Ec(e){return/^groundDecal\.layers\.\d+\.text\.color$/.test(e)}function Ic(e){return/^groundDecal\.layers\.\d+\.text\.color\.a$/.test(e)}function Pc(e){return/^groundDecal\.layers\.\d+\.tint$/.test(e)}function Tc(e){return/^groundDecal\.layers\.\d+\.tint\.a$/.test(e)}function xc(e){return/^groundDecal\.layers\.\d+\.editorPreviewPercent$/.test(e)}function Kr(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ac(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Xa(e)||Kr(e)}function Ya(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ac(e)}function vO(e,t,r={}){return t==="rect"?wo(e,r):t==="rotationDeg"?Mc(e,r):t==="textureId"||t==="tint"||t==="tint.a"?uc(e,r):t==="text.value"||t==="text.fontSize"||t==="text.color"||t==="text.color.a"?ah(e,r):t==="color"||t==="color.a"?mc(e,r):t==="editorPreviewPercent"?e.kind==="textureProgress"?uc(e,r):e.kind==="progress"&&mc(e,r):!1}function Dc(e,t={}){return t.isProjectEditableLayer?.(e)??e.enabled!==!1}function wo(e,t={}){return t.isLayoutEditableLayer?.(e)??e.enabled!==!1}function Mc(e,t={}){return t.isRotationEditableLayer?.(e)??!1}function uc(e,t={}){return t.isEditableTextureLayer?.(e)??(e.kind==="texture"||e.kind==="textureProgress")}function mc(e,t={}){return t.isEditableColorLayer?.(e)??(e.kind==="color"||e.kind==="progress")}function ah(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function ih(e,t,r={}){let n=e.layers.filter(o=>wo(o,r));return t.length!==n.length?!1:n.every((o,a)=>{let i=t[a];return i?.id===o.id&&(i.fontSize==null||o.kind==="text")&&(i.rotationDeg==null||Mc(o,r))})}function qa(e){let t=Qa(e);if(!t)return null;let r=Yt(t.r),n=Yt(t.g),o=Yt(t.b);if(r==null||n==null||o==null)return null;let a=Yt(t.a);return{r:Ur(Math.max(0,Math.min(1,r))),g:Ur(Math.max(0,Math.min(1,n))),b:Ur(Math.max(0,Math.min(1,o))),...a==null?{}:{a:Ur(Math.max(0,Math.min(1,a)))}}}function Ja(e){let t=Yt(e);return t==null?null:Ur(Math.max(0,Math.min(1,t)))}function tm(e){let t=Yt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function ko(e){let t=Yt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=Ur(r);return Object.is(n,-0)?0:n}function rm(e){let t=lc(e);return t==null?null:Ur(t)}function Za(e){let t=Yt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function Ur(e){return Math.round(e*1e3)/1e3}function wc(e,t){return e==="groundDecal.editorPreviewActive"?t===!0:e==="groundDecal.layers"?pc(t)??t:gc(e)?Mo(t)??t:nh(e)?ko(t)??t:bc(e)&&typeof t=="string"?t.trim():hc(e)&&typeof t=="string"?t:oh(e)?rm(t)??t:Sc(e)||Pc(e)||Ec(e)?qa(t)??t:yc(e)||Tc(e)||Ic(e)?Ja(t)??t:xc(e)?tm(t)??t:Kr(e)?Za(t)??t:t}function sh(e,t,r){if(t==="rect"){let n=Mo(r);return n?GO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=ko(r);if(n==null)return null;if(n===0){if(e.rotationDeg==null)return e;let{rotationDeg:o,...a}=e;return a}return e.rotationDeg===n?e:{...e,rotationDeg:n}}if(t==="textureId"){if(e.kind!=="texture"&&e.kind!=="textureProgress"||typeof r!="string")return null;let n=r.trim();if(!n){if(!e.textureId)return e;let{textureId:o,...a}=e;return a}return e.textureId===n?e:{...e,textureId:n}}if(t==="text.value")return e.kind!=="text"||typeof r!="string"?null:e.text.value===r?e:{...e,text:{...e.text,value:r}};if(t==="text.fontSize"){if(e.kind!=="text")return null;let n=rm(r);return n==null?null:e.text.fontSize===n?e:{...e,text:{...e.text,fontSize:n}}}if(t==="color"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=qa(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return Do(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ja(r);if(n===null)return null;let o={...e.color,a:n};return Do(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=tm(r);return n===null?null:e.editorPreviewPercent===n?e:{...e,editorPreviewPercent:n}}if(t==="tint"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=qa(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return Do(e.tint??Wa,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ja(r);if(n===null)return null;let o={...Wa,...e.tint??{},a:n};return Do(e.tint??Wa,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=qa(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return Do(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Ja(r);if(n===null)return null;let o={...e.text.color,a:n};return Do(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}return null}function ut(e,t,r={}){let n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=typeof n?.uiKind=="string"?n.uiKind.trim():"",a=o&&(r.isKnownUiKind?.(o)??!0)?o:r.defaultUiKind??"default",i=t(a);return n?{...i,...structuredClone(n),uiKind:a,size:{...i.size,...n.size&&typeof n.size=="object"?n.size:{}},layers:Array.isArray(n.layers)&&n.layers.length>0?structuredClone(n.layers):i.layers,mask:n.mask&&typeof n.mask=="object"?{...i.mask??{},...n.mask}:i.mask,rendering:n.rendering&&typeof n.rendering=="object"?{...i.rendering??{},...n.rendering}:i.rendering}:i}function Do(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function GO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function ch(e){let t=[e.x,e.y,e.z].filter(n=>Number.isFinite(n));if(t.length===0)return 1;let r=t.reduce((n,o)=>Math.abs(o-1)>Math.abs(n-1)?o:n,t[0]);return Math.max(.001,Math.abs(r))}function jO(e,t,r,n,o){if(!Ya(r))return!1;let a=WO(e,t);if(!a||!o.canShowGroundDecalInspector(a))return!1;let i=ut(a.groundDecal,o.createDefaultGroundDecal,o);if(r==="groundDecal.size.width"||r==="groundDecal.size.depth"||Kr(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=pc(n,o);return d?ih(i,d,o):!1}let s=Xa(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Dc(c,o)&&vO(c,s.field,o)}function NO(e,t,r,n){let o=pc(r,n);return o?lh(e,a=>a.id===t?BO(a,o,n):a):e}function FO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:lh(e,a=>a.id===t?VO(a,o,n):a)}function _O(e,t,r,n,o){if(r==="groundDecal.editorPreviewActive"){if(typeof n!="boolean")return e;let d=!1,u=e.scene.gameObjects.map(l=>{if(l.id!==t||!o.canShowGroundDecalInspector(l))return l;let m=ut(l.groundDecal,o.createDefaultGroundDecal,o);return m.editorPreviewActive===n?l:(d=!0,Gn({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if(Kr(r))return $O(e,t,r,n,o);let a=Xa(r);if(!a)return null;let i=!1,s=wc(r,n),c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=ut(d.groundDecal,o.createDefaultGroundDecal,o),l=u.layers[a.index];if(!l||!Dc(l,o)||a.field==="rect"&&!wo(l,o))return d;let m=sh(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,Gn({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function $O(e,t,r,n,o){let a=Za(n);if(a===null)return e;let i=r==="groundDecal.rendering.textureWidth"?"textureWidth":"textureHeight",s=!1,c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=ut(d.groundDecal,o.createDefaultGroundDecal,o);return u.rendering?.[i]===a?d:(s=!0,Gn({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function LO(e,t,r,n){if(!n.isGroundDecalConfig(r))return e;let o=!1,a=e.scene.gameObjects.map(i=>i.id!==t||!n.isGroundDecalUiGameObject(i)||i.groundDecal.uiKind!==r.uiKind?i:(o=!0,Gn({...i,kind:"transform",transformType:"groundDecal",groundDecal:ut(r,n.createDefaultGroundDecal,n)},n)));return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function dc(e,t,r,n,o){return r.startsWith("transform.scale")?fc(e,o,t,em(r,n)):e}function zO(e,t,r){if(t.type==="document.replace")return fc(e,r);let n=t.patch;return n.kind==="game-object.field"?dc(e,String(n.targetId??""),String(n.path??""),n.value,r):n.kind==="game-object.property-field-batch"&&Array.isArray(n.fields)?n.fields.reduce((o,a)=>{let i=Qa(a);return dc(o,String(i?.targetId??""),String(i?.path??""),i?.value,r)},e):n.kind==="game-object.field-batch"?Array.isArray(n.targetIds)?n.targetIds.reduce((o,a)=>dc(o,String(a),String(n.path??""),n.value,r),e):e:fc(e,r)}function fc(e,t,r,n){let o=!1,a=e.scene.gameObjects.map(i=>{if(r&&i.id!==r||!t.isGroundDecalUiGameObject(i))return i;let s=G(i);if(!s||!HO(s)||!s.scale)return i;let c=n??ch(s.scale);return Math.abs(s.scale.x-c)<1e-6&&Math.abs(s.scale.y-c)<1e-6&&Math.abs(s.scale.z-c)<1e-6?i:(o=!0,{...i,components:i.components.map(d=>d===s?{...d,scale:{x:c,y:c,z:c}}:d)})});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function Gn(e,t){let r=UO({...e,kind:"transform",transformType:"groundDecal",groundDecal:ut(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function dh(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function BO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=ut(e.groundDecal,r.createDefaultGroundDecal,r);return Gn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!wo(a,r))return a;let s=n.get(a.id)??t[i];if(!s)return a;let c=a.kind==="text"?{...a.rect,x:s.rect.x,z:s.rect.z}:s.rect,d=a.kind==="text"&&s.fontSize!=null?{...a,rect:c,text:{...a.text,fontSize:s.fontSize}}:{...a,rect:c};return s.rotationDeg!=null&&Mc(a,r)&&(d=sh(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function VO(e,t,r){let n=ut(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return Gn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function UO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[KO(),...e.components]}}function KO(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function HO(e){return e.type==="Transform"&&e.mode!=="matrix"}function WO(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function lh(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function uh(e,t,r={},n){let o=ut(t,n.createDefaultGroundDecal,n),a=[uR("groundDecal.uiKind","Type",n.createUiKindLabel?.(o.uiKind)??o.uiKind,0),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.width",label:"Width",valueType:"number",control:"number",value:o.size.width,commitMode:"live",order:1,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.depth",label:"Depth",valueType:"number",control:"number",value:o.size.depth,commitMode:"live",order:2,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureWidth",label:"Texture Width",valueType:"number",control:"number",value:o.rendering?.textureWidth??512,commitMode:"change",order:3,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureHeight",label:"Texture Height",valueType:"number",control:"number",value:o.rendering?.textureHeight??512,commitMode:"change",order:4,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.layers",label:"Layout",valueType:"object",control:"custom",customControl:"ground-decal-layout",value:bh(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:dR(o),aspectRatioUsesDecalSize:cR(o),sizeWidth:o.size.width,sizeDepth:o.size.depth}})],i=10;if((n.canShowActivePreview?.(o)??!1)&&a.push(n.createDocumentInspectorProperty(null,e,{path:"groundDecal.editorPreviewActive",label:"Preview Active Background",valueType:"boolean",control:"boolean",value:o.editorPreviewActive===!0,commitMode:"immediate",order:6,tags:["GroundDecalUI","Preview"],controlOptions:{refreshInspector:!1}})),r.enableGroundDecalUiActions&&(n.canShowLayerPairActions?.(o)??!1)&&n.layerPairActions){let s=n.getLayerPairs?.(o).length??0,c=n.canAddLayerPair?.(o)??!1,d=n.canRemoveLayerPair?.(o)??!1;a.push(Qy({path:n.layerPairActions.addPath??"groundDecal.layerPairs.add",label:n.layerPairActions.addLabel??"Add item",actionId:n.layerPairActions.addActionId,order:i,icon:"asset",tooltip:n.layerPairActions.addTooltip??"Add an item.",params:{},disabled:!c,disabledReason:c?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"add",pairCount:s}),effect:c?"active":"unsupported"})),i+=1,a.push(Qy({path:n.layerPairActions.removePath??"groundDecal.layerPairs.remove",label:n.layerPairActions.removeLabel??"Remove item",actionId:n.layerPairActions.removeActionId,order:i,icon:"asset",tooltip:n.layerPairActions.removeTooltip??"Remove an item.",params:{},disabled:!d,disabledReason:d?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"remove",pairCount:s}),effect:d?"active":"unsupported"})),i+=1}for(let s=0;s<o.layers.length;s+=1){let c=o.layers[s];if(!c||!Dc(c,n))continue;let d=Sh(c,n);if(uc(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=nR(e,r,c,s,d,i,n);u!=="stretch"&&o.lockAspectToBorder===!0&&o.aspectSourceLayerId===c.id&&(l.controlOptions={...l.controlOptions,groundDecalAspectSizeWidth:o.size.width,groundDecalAspectSizeDepthPath:"groundDecal.size.depth",groundDecalAspectTextureWidth:o.rendering?.textureWidth??512,groundDecalAspectTextureHeight:o.rendering?.textureHeight??512,groundDecalAspectTextureWidthPath:"groundDecal.rendering.textureWidth",groundDecalAspectTextureHeightPath:"groundDecal.rendering.textureHeight"}),a.push(l),i+=1,a.push(iR(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&mc(c,n)||c.kind==="textureProgress"&&uc(c,n))&&(a.push(aR(e,c,s,d,i,n)),i+=1),mc(c,n)&&(a.push(oR(e,c,s,d,i,n)),i+=1),ah(c,n)&&(a.push(n.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${s}.text.value`,label:`${d} Text`,valueType:"string",control:"string",value:c.text.value,commitMode:"blur",order:i,tags:["GroundDecalUI","Text"]})),i+=1,a.push(sR(e,c,s,d,i,n)),i+=1)}return lR(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function mh(e,t,r,n){let o=n.getTargetGroundDecal(e),a=ut(o,n.createDefaultGroundDecal,n),i=uh(t,a,{...r,enableGroundDecalUiActions:n.isUiTarget?.(e)??!1},n),s=i.find(d=>d.path==="groundDecal.layers");if(!s)throw new Error("Ground Decal Inspector requires the canonical layout property.");let c=i.filter(d=>d!==s).map(d=>({...d,controlOptions:{...d.controlOptions,groundDecalWorkbenchChild:!0}}));return{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:JO(a,n),persistence:"document",collapsedByDefault:!1,properties:[qO(a,[s,...c],n),...c]}}function qO(e,t,r){let n=t.find(a=>a.path==="groundDecal.layers");if(!n||!n.value||typeof n.value!="object"||Array.isArray(n.value))throw new Error("Ground Decal Inspector requires the canonical layout property.");let o={uiKind:e.uiKind,uiKindLabel:r.createUiKindLabel?.(e.uiKind)??e.uiKind,layout:n.value,properties:t.filter(a=>a!==n)};return{...n,label:"Ground Decal Editor",customControl:"ground-decal-workbench",value:o,controlOptions:{...n.controlOptions,refreshInspector:!1}}}function JO(e,t){let r=t.createUiKindLabel?.(e.uiKind)??e.uiKind,n=Math.max(1,Math.round(e.rendering?.textureWidth??512)),o=Math.max(1,Math.round(e.rendering?.textureHeight??512)),a=n===o?`${n}\xB2`:`${n}\xD7${o}`,i=t.canShowLayerPairActions?.(e)??!1?t.getLayerPairs?.(e).length??0:0;return i>0?`${r} \xB7 ${i} item${i===1?"":"s"} \xB7 ${a}`:`${r} \xB7 ${a}`}function fh(e,t,r,n,o){let a=gh(e,t,o);if(a.length<=1)return null;let i=a.find(l=>o.getTargetId(l.target)===r)??a[0];if(!i)return null;let s=XO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=uh(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>ZO(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:QO(a,l.path,n,o)}));return d.length===0?null:{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:a.some(l=>l.decal.uiKind!==i.decal.uiKind)?"Mixed":`${a.length} ${o.createUiKindLabel?.(i.decal.uiKind)??i.decal.uiKind} UIs`,persistence:"document",collapsedByDefault:!1,properties:d}}function ph(e,t,r){return gh(e,t,r).map(n=>r.getTargetId(n.target))}function gh(e,t,r){let n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.findTarget(e,a);!i||!r.canShowTarget(i)||o.push({target:i,decal:ut(r.getTargetGroundDecal(i),r.createDefaultGroundDecal,r)})}return o}function XO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>YO(o,t));return n.every(o=>o===r)}function YO(e,t={}){return e.layers.map((r,n)=>({layer:r,index:n})).filter(r=>Dc(r.layer,t)).map(({layer:r,index:n})=>`${n}:${r.id}:${r.role}:${r.kind}`).join("|")}function ZO(e,t){return e.path==="groundDecal.raw"?!1:e.path==="groundDecal.uiKind"||e.path==="groundDecal.size.width"||e.path==="groundDecal.size.depth"||e.path==="groundDecal.editorPreviewActive"||Kr(e.path)?!0:e.path==="groundDecal.layers"||Xa(e.path)?t:!1}function QO(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(eR(i.decal,t,r,n)));return a.some(i=>i!==o)}function eR(e,t,r,n){if(t==="groundDecal.uiKind")return e.uiKind;if(t==="groundDecal.size.width")return e.size.width;if(t==="groundDecal.size.depth")return e.size.depth;if(t==="groundDecal.editorPreviewActive")return e.editorPreviewActive===!0;if(t==="groundDecal.rendering.textureWidth")return e.rendering?.textureWidth??512;if(t==="groundDecal.rendering.textureHeight")return e.rendering?.textureHeight??512;if(t==="groundDecal.layers")return bh(e,r,n).layers;let o=Xa(t);if(!o)return;let a=e.layers[o.index];if(a)return tR(a,o.field)}function tR(e,t){if(t==="rect")return e.rect;if(t==="rotationDeg")return e.rotationDeg??0;if(t==="textureId")return e.kind==="texture"||e.kind==="textureProgress"?e.textureId:void 0;if(t==="text.value")return e.kind==="text"?e.text.value:void 0;if(t==="text.fontSize")return e.kind==="text"?e.text.fontSize:void 0;if(t==="color")return e.kind==="color"||e.kind==="progress"?e.color:void 0;if(t==="color.a")return e.kind==="color"||e.kind==="progress"?e.color.a??1:void 0;if(t==="tint")return e.kind==="texture"||e.kind==="textureProgress"?e.tint??Wa:void 0;if(t==="tint.a")return e.kind==="texture"||e.kind==="textureProgress"?e.tint?.a??1:void 0;if(t==="text.color")return e.kind==="text"?e.text.color:void 0;if(t==="text.color.a")return e.kind==="text"?e.text.color.a??1:void 0;if(t==="editorPreviewPercent")return e.kind==="progress"||e.kind==="textureProgress"?nm(e):void 0}function bh(e,t,r){let n=Ki(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>wo(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>Yy(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=Yy(t,a,i,r),c=r.getLayerPreviewVisibility?.(a,e);return c?{...s,enabled:s.enabled!==!1&&c.value,previewVisibilityPath:c.path,previewVisibilityBaseEnabled:s.enabled!==!1}:s})}}function Yy(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:Sh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Mc(t,n),enabled:t.enabled!==!1,editable:wo(t,n),zOrder:t.zOrder,...typeof t.opacity=="number"?{opacity:t.opacity}:{},...n.useUniformLayoutScaleMode?.(t)?{scaleMode:"uniform"}:{},...t.kind==="progress"||t.kind==="textureProgress"?{previewValuePath:`groundDecal.layers.${r}.editorPreviewPercent`}:{},...t.kind==="text"&&typeof t.text.fontSize=="number"?{fontSize:t.text.fontSize}:{},preview:rR(e,t,n)}}function Sh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function rR(e,t,r){if(t.kind==="texture"||t.kind==="textureProgress"){if(!t.textureId)return;let n=r.findTextureAsset?.(e,t.textureId)??null,o=n?.url??e.resolveTextureAssetUrl?.(t.textureId)??r.resolveTextureAssetUrl?.(t.textureId);return o?{kind:t.kind==="textureProgress"?"imageProgress":"image",url:o,alt:n?.label??t.textureId,imageFit:r.resolveImageFit?.(t)??t.imageFit??"contain",...t.tint?{tint:t.tint}:{},...t.kind==="textureProgress"?{value:Zy(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:Zy(t),direction:t.direction,color:t.color};if(t.kind==="text")return{kind:"text",text:t.text.value,fontFamily:t.text.fontFamily,fontSize:t.text.fontSize,fontWeight:t.text.fontWeight,color:t.text.color,strokeColor:t.text.strokeColor,strokeWidth:t.text.strokeWidth,align:t.text.align,baseline:t.text.baseline}}function nm(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:RO;return Math.round(Math.max(0,Math.min(100,t)))}function Zy(e){return nm(e)/100}function nR(e,t,r,n,o,a,i){let s=i.getMaterialText?.("zh"),c=i.findTextureAsset?.(t,r.textureId)??null,d=`groundDecal.layers.${n}.textureId`;return i.createDocumentInspectorProperty(null,e,{path:d,label:`${o} PNG`,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.textureId??"",commitMode:"change",order:a,tags:["GroundDecalUI","TextureAsset"],controlOptions:i.createTexturePickerControlOptions?.(t,s,r.textureId,c)??{currentTextureId:r.textureId,currentTexture:c},coerce:u=>i.normalizeValue(d,u)})}function oR(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function aR(e,t,r,n,o,a){let i=`groundDecal.layers.${r}.editorPreviewPercent`;return a.createDocumentInspectorProperty(null,e,{path:i,label:`${n} Preview %`,valueType:"number",control:"number",value:nm(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function iR(e,t,r,n,o,a){let i=t.tint??Wa;return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.tint`,label:`${n} Color`,valueType:"color",control:"color",value:i,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function sR(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.text.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.text.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function cR(e){return e.size.width>0&&e.size.depth>0}function dR(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function lR(e,t){let r=j(t);r&&e.push(r)}function uR(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Qy(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Qa(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function mR(e){return typeof e=="string"&&e.trim()?e.trim():null}var jn="groundDecal";function fR(e){if(e.id!==jn||e.scene?.kind!==jn||!e.config||typeof e.config!="object"||Array.isArray(e.config))return null;let t=e.config;return!Array.isArray(t.uiKinds)||t.uiKinds.length===0||t.uiKinds.some(r=>typeof r!="string"||r.trim().length===0)||!t.documentPolicy||typeof t.documentPolicy!="object"||Array.isArray(t.documentPolicy)||typeof t.documentPolicy.createDefaultGroundDecal!="function"||typeof t.documentPolicy.isGroundDecalConfig!="function"?null:t}function yh(e,t){let r=fR(e);if(!r)return null;let n=r.documentPolicy,o=pR(n),a=s=>s?.transformType===jn&&o.isGroundDecalConfig(s.groundDecal);return gR({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>th({policy:{...o,...r.inspectorPolicy??{}},createDocumentInspectorProperty:s,normalizeValue:wc,findTarget:(d,u)=>d.scene.gameObjects.find(l=>l.id===u)??null,getTargetId:d=>d.id,getTargetNodeKind:d=>d.kind??"transform",getTargetGroundDecal:d=>d.groundDecal??null,canShowTarget:a,isUiTarget:a,canPatchMultiField:c.canPatchMultiField,findTextureAsset:(d,u)=>du(d,u??""),getMaterialText:Sr,createTexturePickerControlOptions:(d,u,l,m)=>Zs(d,u,l??"",m)}),getDocumentInspectorPropertyFactory:t,createDefaultGroundDecal:o.createDefaultGroundDecal,createObjectPatch:s=>({kind:"game-object.create-primitive",gameObject:s}),isGroundDecalObject:a,createHierarchyLabel:r.createHierarchyLabel}).contribution}function pR(e){let t=e;return{...e,createDefaultGroundDecal:r=>structuredClone(e.createDefaultGroundDecal(r)),isGroundDecalConfig(r){return e.isGroundDecalConfig(structuredClone(r))},...typeof t.isProjectEditableLayer=="function"?{isProjectEditableLayer:r=>t.isProjectEditableLayer(structuredClone(r))}:{},...typeof t.isLayoutEditableLayer=="function"?{isLayoutEditableLayer:r=>t.isLayoutEditableLayer(structuredClone(r))}:{},...typeof t.isRotationEditableLayer=="function"?{isRotationEditableLayer:r=>t.isRotationEditableLayer(structuredClone(r))}:{}}}function gR(e){let r=(e.features.find(i=>i.id===jn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=eh({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=bR({uiKinds:n,documentBridge:o,createInspectorServices:i=>e.createInspectorServices(i,o),getDocumentInspectorPropertyFactory:e.getDocumentInspectorPropertyFactory,createDefaultGroundDecal:e.createDefaultGroundDecal,createObjectPatch:e.createObjectPatch,canShowInspector:e.isGroundDecalObject,isGroundDecalObject:e.isGroundDecalObject,createHierarchyLabel:e.createHierarchyLabel});return{bridge:o,contribution:a,uiKinds:n,resolve(i){return i.id===jn&&i.scene?.kind===jn?a:null}}}function bR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:jn}],normalizeInspectorValue:(n,o)=>n.startsWith("groundDecal.")?wc(n,o):void 0,validateInspectorField({path:n,value:o}){if(n==="groundDecal.uiKind")return e.uiKinds.includes(String(o))?{ok:!0,value:o}:{ok:!1,message:"Invalid value for scene node field: groundDecal.uiKind."};if(n==="groundDecal.size.width"||n==="groundDecal.size.depth")return typeof o=="number"&&Number.isFinite(o)&&o>0?{ok:!0,value:o}:{ok:!1,message:`Invalid value for scene node field: ${n}.`};if(n==="groundDecal.layers"){let a=t.normalizeLayoutPatchValue(o);return a?{ok:!0,value:a}:{ok:!1,message:"Invalid value for scene node field: groundDecal.layers."}}return rh(n,o)},isInspectorPatchPath:Ac,isProjectionPath:dh,normalizeDocumentAfterCommand:t.normalizeScalesForCommand,normalizeAfterFieldPatch:t.normalizeScaleAfterFieldPatch,fieldMutation:{isCustomTransformType:n=>n==="groundDecal",applyCustomTransformType(n,o){o==="groundDecal"&&(n.groundDecal=t.mergeDefaults(n.groundDecal))},clearCustomTransformState(n,o){o!=="groundDecal"&&delete n.groundDecal},patchCustomTransformField(n,o,a){return o.startsWith("groundDecal.")?(n.kind="transform",n.transformType=n.transformType??"groundDecal",delete n.primitive,n.groundDecal=t.mergeDefaults(n.groundDecal),yR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=em(o,a);return s===null?null:{label:`Patch ${n.id} transform.scale`,patch:{kind:"game-object.field",targetId:n.id,path:"transform.scale",value:{x:s,y:s,z:s}},changedId:n.id,changedIds:i()}},patchGameObjectField:({document:n,targetId:o,path:a,value:i})=>a==="groundDecal.uiKind"?t.patchKind(n,o,i):a==="groundDecal.layers"?t.patchLayout(n,o,i):t.patchInspectorField(n,o,a,i),patchGameObjectsField:({document:n,targetIds:o,path:a,value:i,patchSingle:s})=>a==="groundDecal.uiKind"||a==="groundDecal.layers"||Ac(a)?o.reduce((c,d)=>s(c,d,a,i),n):null,reducePatch:({document:n,patch:o})=>o.kind==="game-object.ground-decal-ui.replace"?t.replaceUi(n,String(o.targetId),o.groundDecal):null,createHierarchyPatch:(n,o)=>SR(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[mh(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>fh(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>ph(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Ya,isSerializedMultiProjectionPath:Ya,getSerializedMultiProbeValue:hR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Ya(a)||t.canPatchMultiField(n,o,a,i)}}function SR(e,t,r){let n=t.startsWith("ground-decal:")?t.slice(13):"";if(!r.uiKinds.includes(n))return null;let o=ct(e.scene.gameObjects.map(d=>d.id),`${n}_ground_decal_ui`),a=r.createHierarchyLabel?.(n)??`${n} Ground Decal UI`,i=new Set(e.scene.gameObjects.map(d=>d.name).filter(Boolean)),s=a;for(let d=2;i.has(s);d+=1)s=`${a} ${d}`;let c={id:o,guid:he(),name:s,kind:"transform",parentId:ye(e)??void 0,active:!0,transformType:"groundDecal",groundDecal:r.createDefaultGroundDecal(n),components:[{type:"Transform",position:{x:0,y:.02,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Add ${a}`,patch:r.createObjectPatch(c),createdId:o,changedIds:[o],reprojectIds:[o]}}function yR(e,t,r){let n=t.split("."),o=e;for(let a of n.slice(0,-1))o=o[a]??={};o[n[n.length-1]]=r}function hR(e){if(e.endsWith(".width")||e.endsWith(".depth"))return 1;if(e.endsWith(".rotationDeg"))return 45;if(e.endsWith("textureWidth")||e.endsWith("textureHeight"))return 512;if(e==="groundDecal.layers")return{layers:[{id:"mainLogo",rect:{x:0,z:0,width:1,depth:1}}]};if(bc(e))return"texture_probe";if(hc(e))return"30";if(Sc(e)||Pc(e)||Ec(e))return{r:1,g:1,b:1,a:1};if(yc(e)||Tc(e)||Ic(e))return 1;if(xc(e))return 75;if(gc(e))return Mo({x:0,z:0,width:1,depth:1});if(Kr(e))return Za(512)}function ei(e){let t=typeof e=="string"&&e.trim()?e.trim():void 0;if(!t)return;if(t.includes("\0"))throw new Error("external_asset_path_must_be_portable");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))throw new Error("external_asset_path_must_be_portable");let n=[];for(let o of r.split("/"))if(!(!o||o===".")){if(o==="..")throw new Error("external_asset_path_must_be_portable");n.push(o)}if(n.length===0)throw new Error("external_asset_path_must_be_portable");return n.join("/")}function ce(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function kc(e,t=4,r="$"){if(!Number.isInteger(t)||t<0||t>100)throw new Error(`json.number.invalidDecimalPlaces: ${t}`);let n=[],o=a=>{if(typeof a=="number"){if(!Number.isFinite(a))throw new Error(`json.number.nonFinite: ${ER(r,n)}`);if(Object.is(a,-0))return 0;if(Number.isInteger(a))return a;let i=Number(a.toFixed(t));return Object.is(i,-0)?0:i}if(Array.isArray(a)){let i;for(let s=0;s<a.length;s+=1){let c=a[s];n.push(s);let d=o(c);n.pop(),!Object.is(d,c)&&(i??=a.slice(),i[s]=d)}return i??a}if(a&&typeof a=="object"){let i=a,s;for(let[c,d]of Object.entries(i)){n.push(c);let u=o(d);n.pop(),!Object.is(u,d)&&(s??={...i},s[c]=u)}return s??a}return a};return o(e)}function ER(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var om=64*1024,IR=8,hh=256,PR=8*1024,TR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function Eh(e){if(!ti(e))throw new Error("asset_import_payload_must_be_object");for(let a of Object.keys(e))if(!TR.has(a))throw new Error(`asset_import_field_not_allowed:${a}`);MR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:AR(t.assetPath),n=Oo(t.projectAssetId,"projectAssetId");if(!r&&!n)throw new Error("asset_import_asset_path_or_project_asset_id_required");if(t.assetType!==void 0&&t.assetType!=="model"&&t.assetType!=="texture")throw new Error("asset_import_asset_type_invalid");let o=["platformAssetId","guid","assetName","displayName","mimeType","assetUrl","category","materialMode"];for(let a of o){let i=Oo(t[a],a);i&&(t[a]=i)}for(let a of["placeable","singleton"])if(t[a]!==void 0&&typeof t[a]!="boolean")throw new Error(`asset_import_${a}_must_be_boolean`);if(t.warmupCount!==void 0&&(!Number.isInteger(t.warmupCount)||t.warmupCount<0))throw new Error("asset_import_warmupCount_must_be_non_negative_integer");for(let a of["defaultScale","scale"])t[a]!==void 0&&(t[a]=DR(t[a],a));if(t.metadata!==void 0&&!ti(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!ti(t.external))throw new Error("asset_import_external_must_be_object");let a=new Set(["platformAssetId","assetPath","assetUrl"]);for(let s of Object.keys(t.external))if(!a.has(s))throw new Error(`asset_import_external_field_not_allowed:${s}`);let i=t.external.assetPath===void 0?void 0:xR(t.external.assetPath,"external.assetPath");t.external={...Oo(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:Oo(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...Oo(t.external.assetUrl,"external.assetUrl")?{assetUrl:Oo(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function xR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=ei(e);if(!r)throw new Error("empty");if(r.length>1024)throw new Error("too_long");return r}catch{throw new Error(`asset_import_${t}_must_be_project_relative`)}}function AR(e){if(typeof e!="string")throw new Error("asset_import_assetPath_must_be_string");let t=e.trim();if(!t||t.includes("\0")||t.length>4096)throw new Error("asset_import_assetPath_invalid");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||r.startsWith("//"))return r;try{return ei(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function Oo(e,t){if(e===void 0)return;if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);let r=e.trim();if(!r)throw new Error(`asset_import_${t}_must_not_be_empty`);if(r.length>1024)throw new Error(`asset_import_${t}_too_long`);return r}function DR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(ti(e)&&Object.keys(e).every(r=>r==="x"||r==="y"||r==="z")&&typeof e.x=="number"&&Number.isFinite(e.x)&&e.x>0&&typeof e.y=="number"&&Number.isFinite(e.y)&&e.y>0&&typeof e.z=="number"&&Number.isFinite(e.z)&&e.z>0)return{x:e.x,y:e.y,z:e.z};throw new Error(`asset_import_${t}_invalid`)}function MR(e){let t=0,r=(n,o)=>{if(o>IR)throw new Error("asset_import_payload_too_deep");if(n===null||typeof n=="boolean")return;if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("asset_import_payload_number_invalid");return}if(typeof n=="string"){if(n.length>PR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>hh)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!ti(n)||Object.getPrototypeOf(n)!==Object.prototype)throw new Error("asset_import_payload_not_json_safe");let a=Object.entries(n);if(t+=a.length,t>hh)throw new Error("asset_import_payload_too_many_values");for(let[,i]of a){if(i===void 0||typeof i=="function"||typeof i=="symbol"||typeof i=="bigint")throw new Error("asset_import_payload_not_json_safe");r(i,o+1)}};if(r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>om)throw new Error("asset_import_payload_too_large")}function ti(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Dh="@fps-games/editor.playable-sdk.scene-compiler",Mh="3",wR=new Set(["shadowMode","childMaterialBindings","childMaterials"]),kR=new Set(["coordinateSpace","center","size","rotation"]),Ih=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function Oc(e){kh(e,!0)}function wh(e){let t=ga(e);return Oc(t.document),t}function cm(e){kh(e,!1)}function kh(e,t){let r=k(e);if(!r)throw new Error("editor_scene_must_be_object");if(r.schemaVersion!==1)throw P("schema.unsupportedVersion","$.schemaVersion");if(!Array.isArray(r.assets))throw new Error("editor_scene_assets_must_be_array");let n=k(r.scene);if(!Array.isArray(n?.gameObjects))throw new Error("editor_scene_game_objects_must_be_array");if(n.materialAssets!=null&&!Array.isArray(n.materialAssets))throw new Error("editor_scene_material_assets_must_be_array");if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw P("schema.forbiddenField","$.scene.shadowMapExperiment");vR(r.assets,n.gameObjects),sm(r,"$"),GR(r.assets),CR(r.assets,n.gameObjects),jR(n.gameObjects,r.assets),NR(n.gameObjects),RR(n.materialAssets??[]),t&&FR(r.assets,n.gameObjects),Ws(r),OR(r.assets,n.gameObjects)}function OR(e,t){for(let r=0;r<t.length;r+=1){let n=k(t[r]),o=`$.scene.gameObjects[${r}]`,a=Object.prototype.hasOwnProperty.call(n,"shadow");if(k(n.prefab)){if(a)throw P("schema.forbiddenField",`${o}.shadow`)}else if(mn(n))Ph(n.shadow,`${o}.shadow`);else if(a)throw P("schema.forbiddenField",`${o}.shadow`);if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw P("schema.forbiddenField",`${o}.shadowMapExperiment`)}for(let r=0;r<e.length;r+=1){let n=k(e[r]),o=`$.assets[${r}]`,a=k(n.defaults);if(a?.shadow!==void 0)throw P("schema.forbiddenField",`${o}.defaults.shadow`);if(a?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${o}.defaults.shadowMapExperiment`);let i=k(n.prefab);if(!i)continue;let s=k(i.defaults);if(Ph(s?.shadow,`${o}.prefab.defaults.shadow`),s?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${o}.prefab.defaults.shadowMapExperiment`);Array.isArray(i.nodes)&&i.nodes.forEach((c,d)=>{let u=k(c),l=`${o}.prefab.nodes[${d}]`,m=k(u?.defaults);if(u?.shadow!==void 0)throw P("schema.forbiddenField",`${l}.shadow`);if(m?.shadow!==void 0)throw P("schema.forbiddenField",`${l}.defaults.shadow`);if(u?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${l}.shadowMapExperiment`);if(m?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${l}.defaults.shadowMapExperiment`)})}}function Ph(e,t){let r=k(e);if(!r||r.cast===void 0||r.receive===void 0)throw P("schema.invalidType",t);if(r.cast!=="enabled"&&r.cast!=="none"||r.receive!=="enabled"&&r.receive!=="none")throw P("schema.invalidValue",t);for(let n of Object.keys(r))if(n!=="cast"&&n!=="receive")throw P("schema.forbiddenField",`${t}.${n}`)}function RR(e){let t=new Set,r=new Set;for(let n=0;n<e.length;n+=1){let o=k(e[n]),a=`$.scene.materialAssets[${n}]`;if(!o)throw P("schema.invalidType",a);if(Object.prototype.hasOwnProperty.call(o,"materialKind"))throw P("schema.deprecatedField",`${a}.materialKind`);if(Object.prototype.hasOwnProperty.call(o,"profile"))throw P("schema.deprecatedField",`${a}.profile`);let i=C(o.id);if(!i)throw P("schema.invalidType",`${a}.id`);if(t.has(i))throw P("schema.invalidValue",`${a}.id`);t.add(i);let s=C(o.guid);if(s){if(r.has(s))throw P("schema.invalidValue",`${a}.guid`);r.add(s)}if(!C(o.name))throw P("schema.invalidType",`${a}.name`);let c=C(o.shaderId);if(!c)throw P("schema.invalidValue",`${a}.shaderId`);let d=De(c),u=o.definitionVersion;if(u!=null&&(typeof u!="number"||!Number.isSafeInteger(u)||u<1))throw P("schema.invalidValue",`${a}.definitionVersion`);if(!d&&u==null)throw P("schema.invalidValue",`${a}.definitionVersion`);if(d){let l=no(c,o.properties,`${a}.properties`);if(l[0])throw P("schema.invalidValue",l[0].path)}else if(!k(o.properties))throw P("schema.invalidType",`${a}.properties`);for(let l of Object.keys(o))if(!["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(l))throw P("schema.unknownField",`${a}.${l}`)}}function CR(e,t){let r=new Set(e.map(k).filter(a=>a?.type==="glb").map(a=>C(a?.id)).filter(a=>!!a)),n=new Set(e.map(k).filter(a=>a?.type==="texture").map(a=>C(a?.id)).filter(a=>!!a)),o=new Map;for(let a of e.map(k)){if(a?.type!=="prefab")continue;let i=C(a.id),s=C(k(a.prefab)?.sourceAssetId);i&&s&&o.set(i,s)}for(let a=0;a<e.length;a+=1){let i=k(e[a]);if(i?.type!=="prefab")continue;let s=k(i.prefab),c=C(s?.sourceAssetId),d=C(s?.rootNodeId);if(!c||!r.has(c))throw P("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);let u=Array.isArray(s?.nodes)?s.nodes:[];for(let l=0;l<u.length;l+=1){let m=k(u[l]),f=C(m?.sourceAssetId);if(m?.kind==="model"&&(!f||!r.has(f)))throw P("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`);if(m?.kind==="prefabInstance"){let g=C(m.childPrefabId),b=g?o.get(g):null;if(C(m.id)===d&&c!==b)throw P("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);if(f&&f!==b)throw P("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`)}}}for(let a=0;a<t.length;a+=1){let i=k(t[a]),s=C(k(i?.instance)?.assetId);if(s&&!r.has(s))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].instance.assetId`);let c=Array.isArray(i?.components)?i.components:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ModelRenderer")continue;let l=C(u.assetId);if(!l||!r.has(l))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`)}for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ImageRenderer")continue;let l=C(u.assetId);if(!l||!n.has(l))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`);let m=k(u.size);if(!m||!Ah(m.width)||!Ah(m.height))throw P("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function vR(e,t){let r=new Set;e.forEach((a,i)=>{let s=k(a);if(!s)throw P("schema.invalidType",`$.assets[${i}]`);let c=C(s.id);if(!c||!C(s.type))throw P("schema.invalidValue",`$.assets[${i}]`);if(r.has(c))throw P("schema.invalidValue",`$.assets[${i}].id`);r.add(c)});let n=new Set,o=new Map;t.forEach((a,i)=>{let s=k(a);if(!s)throw P("schema.invalidType",`$.scene.gameObjects[${i}]`);let c=C(s.id);if(!c)throw P("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.has(c))throw P("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.add(c),o.set(c,{value:s,index:i}),!Array.isArray(s.components))throw P("schema.invalidType",`$.scene.gameObjects[${i}].components`);s.components.forEach((d,u)=>{let l=k(d);if(!l)throw P("schema.invalidType",`$.scene.gameObjects[${i}].components[${u}]`);if(!C(l.type))throw P("schema.invalidValue",`$.scene.gameObjects[${i}].components[${u}].type`)})});for(let[a,i]of o){if(!("parentId"in i.value))continue;let s=C(i.value.parentId);if(!s||!o.has(s))throw P("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);let c=new Set([a]),d=s;for(;d;){if(c.has(d))throw P("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);c.add(d);let u=o.get(d)?.value;d=u&&u.parentId!=null?C(u.parentId):null}}}function sm(e,t){if(Array.isArray(e)){e.forEach((n,o)=>sm(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(wR.has(n))throw P("schema.deprecatedField",a);n==="shadow"&&Xo(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&sm(o,a)}}function GR(e){let t=new Set(e.map(k).filter(i=>i?.type==="prefab").map(i=>C(i?.id)).filter(i=>!!i)),r=new Map;for(let i=0;i<e.length;i+=1){let s=k(e[i]);if(s?.type!=="prefab")continue;let c=k(s.prefab);if(!Array.isArray(c?.nodes))throw P("schema.unsupportedVersion",`$.assets[${i}].prefab.nodes`);Th(c.defaults,`$.assets[${i}].prefab.defaults`);let d=[],u=new Set;for(let g=0;g<c.nodes.length;g+=1){let b=`$.assets[${i}].prefab.nodes[${g}]`,S=k(c.nodes[g]);if(!S)throw P("schema.invalidType",b);Th(S.defaults,`${b}.defaults`);let y=C(S.id);if(!y||!Ih.has(String(S.kind)))throw P("schema.invalidValue",b);if(u.has(y))throw P("schema.invalidValue",`${b}.id`);u.add(y),d.push(S)}let l=C(c?.rootNodeId),m=l?d.find(g=>C(g?.id)===l):null,f=!!m&&Ih.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==ln||d.length===0||!f)throw P("schema.unsupportedVersion",`$.assets[${i}].prefab`);r.set(C(s.id),d.flatMap((g,b)=>{let S=C(g.childPrefabId);return S?[{prefabId:S,path:`$.assets[${i}].prefab.nodes[${b}].childPrefabId`}]:[]}));for(let g=0;g<d.length;g+=1){let b=d[g];hg(b,new Map(d.map(D=>[C(D.id),D])),`$.assets[${i}].prefab.nodes[${g}]`);let S=C(b.id),y=C(b.parentId);if(S!==l&&(!y||!u.has(y)))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${g}].parentId`);if(b.kind==="prefabInstance"){let D=C(b.childPrefabId);if(!D||!t.has(D))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${g}].childPrefabId`)}let I=new Set([S]),E=y;for(;E;){if(I.has(E))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${g}].parentId`);I.add(E);let D=d.find(x=>C(x.id)===E);E=D?C(D.parentId):null}}}let n=new Set,o=new Set,a=i=>{if(!o.has(i)){n.add(i);for(let s of r.get(i)??[]){if(n.has(s.prefabId))throw P("schema.invalidReference",s.path);a(s.prefabId)}n.delete(i),o.add(i)}};for(let i of r.keys())a(i)}function Th(e,t){if(e==null)return;let r=k(e);if(!r)throw P("schema.invalidType",t);if(Object.prototype.hasOwnProperty.call(r,"active")&&typeof r.active!="boolean")throw P("schema.invalidType",`${t}.active`)}function jR(e,t){let r=new Map;for(let n of t.map(k)){if(n?.type!=="prefab")continue;let o=C(n.id),a=C(k(n.prefab)?.sourceAssetId);o&&a&&r.set(o,a)}for(let n=0;n<e.length;n+=1){let o=k(e[n]);if(!o||o.prefab==null)continue;let a=k(o.prefab),i=C(a?.prefabId),s=i?r.get(i):null;if(!i||!s)throw P("schema.unsupportedVersion",`$.scene.gameObjects[${n}].prefab`);if(C(a?.sourceAssetId)!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].prefab.sourceAssetId`);let c=C(k(o.instance)?.assetId);if(c&&c!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].instance.assetId`);let d=Array.isArray(o.components)?o.components:[];for(let u=0;u<d.length;u+=1){let l=k(d[u]);if(l?.type==="ModelRenderer"&&C(l.assetId)!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].components[${u}].assetId`)}}}function NR(e){for(let t=0;t<e.length;t+=1){let r=k(k(k(e[t])?.marker)?.geometry);if(r?.kind!=="box"&&r?.kind!=="cylinder")continue;for(let o of kR)if(Object.prototype.hasOwnProperty.call(r,o))throw P("schema.deprecatedField",`$.scene.gameObjects[${t}].marker.geometry.${o}`);if(!(Array.isArray(k(e[t])?.components)?k(e[t]).components:[]).some(o=>k(o)?.type==="Transform"))throw P("schema.invalidValue",`$.scene.gameObjects[${t}].components`)}}function FR(e,t){let r=new Map,n=new Map;for(let o=0;o<e.length;o+=1){let a=k(e[o]),i=C(a?.id);if(!a||!i)continue;if(a.type==="prefab"){let l=C(k(a.prefab)?.sourceAssetId);l&&n.set(i,l)}let s=k(a.metadata),c=s?.materialSlots;if(c==null){r.set(i,new Set);continue}if(!Array.isArray(c))throw P("schema.invalidType",`$.assets[${o}].metadata.materialSlots`);let d=_R(s?.assetAnalysis),u=new Set;for(let l=0;l<c.length;l+=1){let m=k(c[l]),f=C(m?.slotId);if(!m||!f)throw P("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}]`);let g=`$.assets[${o}].metadata.materialSlots[${l}]`;for(let b of["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMaterialIndices","sourceMeshName","triangleCount","boundingBox"])if(Object.prototype.hasOwnProperty.call(m,b))throw P("schema.deprecatedField",`${g}.${b}`);if(!Array.isArray(m.sourceSurfaces))throw P("schema.invalidType",`${g}.sourceSurfaces`);if(m.sourceSurfaces.length===0)throw P("schema.invalidValue",`${g}.sourceSurfaces`);for(let b=0;b<m.sourceSurfaces.length;b+=1){let S=`${g}.sourceSurfaces[${b}]`,y=k(m.sourceSurfaces[b]);if(!y||!C(y.ownerNodePath))throw P("schema.invalidValue",S);xh(y,"nodeIndex",S),xh(y,"sourceMaterialIndex",S);for(let E of["meshIndex","primitiveIndex"])if(!Number.isInteger(y[E])||y[E]<0)throw P("schema.invalidValue",`${S}.${E}`);if(y.nodeIndexPath!=null&&(!Array.isArray(y.nodeIndexPath)||y.nodeIndexPath.some(E=>!Number.isInteger(E)||E<0)))throw P("schema.invalidValue",`${S}.nodeIndexPath`);let I=y.meshIndex;if(!C(y.sourceMeshName)&&!d.has(I))throw P("schema.invalidValue",`${S}.sourceMeshName`)}if(u.has(f))throw P("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}].slotId`);u.add(f)}r.set(i,u)}for(let o=0;o<e.length;o+=1){let a=k(e[o]);if(a?.type!=="prefab")continue;let i=k(a.prefab),s=C(i?.sourceAssetId);am(i?.overrides,s?r.get(s):void 0,`$.assets[${o}].prefab.overrides`);let c=Array.isArray(i?.nodes)?i.nodes:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]),l=C(u?.childPrefabId),m=C(u?.sourceAssetId)??(l?n.get(l)??null:null);am(u?.overrides,m?r.get(m):void 0,`$.assets[${o}].prefab.nodes[${d}].overrides`)}}for(let o=0;o<t.length;o+=1){let a=k(t[o]),s=(Array.isArray(a?.components)?a.components:[]).map(k).find(d=>d?.type==="ModelRenderer"),c=C(s?.assetId);am(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function am(e,t,r){let n=k(e);if(!n||n.materialSlotBindings==null)return;let o=k(n.materialSlotBindings);if(!o)throw P("schema.invalidType",`${r}.materialSlotBindings`);for(let[a,i]of Object.entries(o)){if(!t?.has(a))throw P("schema.invalidReference",`${r}.materialSlotBindings.${a}`);let s=`${r}.materialSlotBindings.${a}`,c=k(i);if(!c)throw P("schema.invalidType",s);for(let d of Object.keys(c))if(d!=="materialAssetId"&&d!=="override")throw P("schema.deprecatedField",`${s}.${d}`);if("materialAssetId"in c&&c.materialAssetId!=null&&!C(c.materialAssetId))throw P("schema.invalidValue",`${s}.materialAssetId`);if("override"in c&&!k(c.override))throw P("schema.invalidType",`${s}.override`);"override"in c&&$R(c.override,`${s}.override`)}}function xh(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw P("schema.invalidValue",`${r}.${t}`)}function _R(e){let t=k(e),r=Array.isArray(t?.meshes)?t.meshes:[];return new Set(r.flatMap(n=>{let o=k(n),a=o?.meshIndex,i=Number.isInteger(a)?a:null;return i!=null&&C(o?.name)?[i]:[]}))}function $R(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);if(Ro(r,["lightingModel","baseColor","normal","metallic","roughness","metallicRoughness","occlusion","emission","alpha"],t),"lightingModel"in r&&!["lit","unlit"].includes(String(r.lightingModel)))throw P("schema.invalidValue",`${t}.lightingModel`);for(let n of["metallic","roughness"])ni(r,n,t);LR(r.baseColor,`${t}.baseColor`),im(r.normal,`${t}.normal`,["texture","strength"]),im(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),im(r.occlusion,`${t}.occlusion`,["texture","strength"]),zR(r.emission,`${t}.emission`),BR(r.alpha,`${t}.alpha`)}function LR(e,t){if(e==null)return;let r=Co(e,t);Ro(r,["color","texture","brightness","saturation","contrast","hue"],t),Oh(r.color,`${t}.color`),ri(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ni(r,n,t)}function im(e,t,r){if(e==null)return;let n=Co(e,t);Ro(n,r,t),ri(n.texture,`${t}.texture`),r.includes("strength")&&ni(n,"strength",t)}function zR(e,t){if(e==null)return;let r=Co(e,t);Ro(r,["color","intensity","texture","maskTexture"],t),Oh(r.color,`${t}.color`),ni(r,"intensity",t),ri(r.texture,`${t}.texture`),ri(r.maskTexture,`${t}.maskTexture`)}function BR(e,t){if(e==null)return;let r=Co(e,t);if(Ro(r,["mode","opacity","cutoff","texture"],t),"mode"in r&&!["opaque","mask","blend"].includes(String(r.mode)))throw P("schema.invalidValue",`${t}.mode`);for(let n of["opacity","cutoff"])ni(r,n,t);ri(r.texture,`${t}.texture`)}function ri(e,t){if(e==null)return;let r=Co(e,t);Ro(r,["url","textureAssetId"],t);for(let n of["url","textureAssetId"])if(n in r&&r[n]!=null&&!C(r[n]))throw P("schema.invalidValue",`${t}.${n}`)}function Oh(e,t){if(e==null)return;let r=Co(e,t);for(let n of["r","g","b"])VR(r,n,t)}function Ro(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw P("schema.deprecatedField",`${r}.${o}`)}function ni(e,t,r){if(t in e&&e[t]!=null&&(typeof e[t]!="number"||!Number.isFinite(e[t])))throw P("schema.invalidType",`${r}.${t}`)}function VR(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw P("schema.invalidValue",`${r}.${t}`)}function Co(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);return r}function P(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function C(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function Ah(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function oi(){return{isCoreMaterialOverridePath:gl,isMaterialAssetIdOverridePath:ug,addMaterialAsset:Us}}function Rh(e,t=[]){return e.assets.filter(Ye).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=UR(r,t);return[{id:`prefab:${r.id}`,assetId:r.id,guid:r.guid,type:"prefab",kind:"prefab",label:r.displayName??r.id,displayName:r.displayName??r.id,category:r.category??"Prefab",origin:"project",placeable:o.placeable,...o.availability?{availability:structuredClone(o.availability)}:{},dedupeKey:`prefab:${r.guid??r.id}`,prefab:{id:r.id,guid:r.guid,displayName:r.displayName??r.id,category:r.category??"Prefab",...structuredClone(r.prefab),sourceAssetId:n},metadata:structuredClone(r.metadata??{})}]})}function UR(e,t){let r=e.prefab?.sourceAssetId,n=typeof r=="string"?t.find(a=>a.assetId===r||a.id===r):void 0,o=n?.availability;return{placeable:n?.placeable!==!1&&o?.status!=="unavailable",...o?{availability:o}:{}}}function dm(e,t,r=oi()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(um(e))return t==null?null:e==="prefab.defaults.shadow"?t:e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"?t===!0?"enabled":t===!1?"none":t:t;if(r.isMaterialAssetIdOverridePath(e)&&typeof t=="string"){let n=t.trim();return n||null}return t}function lm(e,t,r=oi()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(um(e)){if(e==="prefab.defaults.shadow")return!!t&&typeof t=="object"&&typeof t.cast=="boolean"&&typeof t.receive=="boolean";let n=e.slice(16);return po({path:n,nodeKind:"instance",value:t}).ok}return r.isCoreMaterialOverridePath(e)?r.isMaterialAssetIdOverridePath(e)&&(t==null||typeof t=="string"&&t.trim().length>0):!1}function um(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function Ch(e,t,r){let n=[...e.assets];r&&!n.some(a=>a.id===r.id)&&n.push(structuredClone(r));let o=Rc(t);return n.some(a=>a.id===t.id)||n.push(structuredClone(o)),n.length===e.assets.length?e:{...e,assets:n}}function mm(e,t,r,n,o=oi()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Ye(s));if(!a)return e;let i=KR(Gh(a),r,n,o);return JSON.stringify(i)===JSON.stringify(a)?e:{...e,assets:e.assets.map(s=>s.id===t?i:s)}}function vh(e,t,r,n){let o=e.assets.find(s=>s.id===t&&Ye(s));if(!o)return e;let a=n&&!e.assets.some(s=>s.id===n.id)?[...e.assets,structuredClone(n)]:e.assets,i=Rc({...structuredClone(r),id:t});return JSON.stringify(i)===JSON.stringify(o)&&a===e.assets?e:{...e,assets:a.map(s=>s.id===t?i:s)}}function KR(e,t,r,n=oi()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||um(t)){let o=structuredClone(e),a=structuredClone(o.prefab??e.prefab);if(a.defaults={...a.defaults??{}},t==="prefab.defaults.active")r==null?delete a.defaults.active:a.defaults.active=r;else{if(t==="prefab.defaults.shadow"){if(!r||typeof r!="object")return e;let s=r.cast,c=r.receive;return typeof s!="boolean"||typeof c!="boolean"?e:(a.defaults.shadow={cast:s?"enabled":"none",receive:c?"enabled":"none"},o.prefab=a,Rc(o))}if(r!=="enabled"&&r!=="none")return e;let i=a.defaults.shadow;a.defaults.shadow={cast:t==="prefab.defaults.shadow.cast"?r:i?.cast==="enabled"?"enabled":"none",receive:t==="prefab.defaults.shadow.receive"?r:i?.receive==="enabled"?"enabled":"none"}}return Object.keys(a.defaults).length===0&&delete a.defaults,o.prefab=a,Rc(o)}return ba(e,t,r)}function Gh(e){if(!Ye(e))return e;let t=cg(e);return t.ok?t.prefabAsset:e}function Rc(e){if(!Ye(e))return e;let t=Gh(e),r=Ze(t);if(!r||!Array.isArray(t.prefab?.nodes))return t;let n=t.prefab.nodes.findIndex(a=>a.id===r);if(n<0)return t;let o=structuredClone(t.prefab.nodes[n]);if(o.name=t.displayName??o.name,t.prefab.defaults){let{shadow:a,...i}=t.prefab.defaults;Object.keys(i).length>0?o.defaults=structuredClone(i):delete o.defaults}else delete o.defaults;return t.prefab.nodes=[...t.prefab.nodes],t.prefab.nodes[n]=o,t}function jh(e,t,r,n,o=oi()){let a=o.addMaterialAsset(e,n);return mm(a,t,r,n.id,o)}function Fh(e,t,r,n){let o=Le(e,t.assetId),a=t.sourceAssetId??o?.prefab?.sourceAssetId,i=a?e.assets.find(l=>l.id===a):null,s=HR(i,a),c=Cc(i),d=WR(c,!!n.importStructureReady),u=$h(n.importStructure)?Lh(n.importStructure):[];return vc([s,...d?[d]:[],...u],r)}function HR(e,t){return{id:"prefab-source",label:e?.displayName??t??"Missing source asset",kind:"source",sourceAssetId:t,...e?.metadata?.relativePath?{meta:e.metadata.relativePath}:{}}}function WR(e,t){return e.length===0?null:{id:"prefab-material-slots",label:`${t?"Editable Material Slots":"Meshes / Materials"} (${e.length})`,kind:"group",children:[...e]}}function Cc(e){return(Array.isArray(e?.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(JR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=Bh(o.ownerNodePath),i=ot(r),s=i.map(m=>wn(r,m)).filter(m=>!!m);if(s.length===0&&r.materialNames?.length&&s.push(...r.materialNames.filter(m=>typeof m=="string"&&!!m.trim())),s.length===0&&r.materialName&&s.push(r.materialName),!r.slotId)return null;let c=`prefab.overrides.materialSlotBindings.${r.slotId}`,d=o.sourceMaterialIndex,u=r.label??s[0]??a.split("/").filter(Boolean).pop()??`Material Slot ${n+1}`;return{id:`prefab-material-slot:${pm(r.slotId??a,`material_slot_${n+1}`)}:${n+1}`,itemType:"prefab-material-slot",label:u,kind:"material",bindingKind:"slot",bindingPath:c,materialAssetIdPath:`${c}.materialAssetId`,profilePathPrefix:`${c}.override`,slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:a,...typeof o.nodeIndex=="number"?{nodeIndex:o.nodeIndex}:{},...o.nodeIndexPath?.length?{nodeIndexPath:o.nodeIndexPath}:{},...typeof o.meshIndex=="number"?{meshIndex:o.meshIndex}:{},...typeof o.primitiveIndex=="number"?{primitiveIndex:o.primitiveIndex}:{},...d==null?{}:{sourceMaterialIndex:d},...i.length>0?{sourceMaterialIndices:i}:{},...s[0]?{sourceMaterialName:s[0]}:{},...s.length>0?{sourceMaterialNames:s}:{},...r.sourceSurfaces.length===1&&typeof o.triangleCount=="number"?{triangleCount:o.triangleCount}:{},...r.sourceSurfaces.length===1&&o.boundingBox?{boundingBox:o.boundingBox}:{},meta:[a,r.sourceSurfaces.length===1?`primitive #${o.primitiveIndex}`:`${r.sourceSurfaces.length} source surfaces`,s.length>0?s.join(", "):null].filter(Boolean).join(" - ")}}).filter(r=>r!=null)}function _h(e){return e.map(t=>[t.label,typeof t.primitiveIndex=="number"?`primitive #${t.primitiveIndex}`:null,typeof t.sourceMaterialIndex=="number"?`material #${t.sourceMaterialIndex}`:null,typeof t.triangleCount=="number"?`${t.triangleCount} triangles`:null,qR(t.boundingBox)].filter(Boolean).join(" \xB7 ")).join(`
4
+ `)}function qR(e){if(!e)return null;let t=e.min?e.min.join(", "):"",r=e.max?e.max.join(", "):"";return t&&r?`bounds min ${t}; max ${r}`:t?`bounds min ${t}`:r?`bounds max ${r}`:null}function JR(e){return Gr(e)}function $h(e){return["nodes","materials","textures","animations"].some(t=>ai(e,t).length>0)}function Lh(e){let t=[],r=ai(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:XR(r)});let n=ai(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>fm(i,s,"material"))});let o=ai(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>fm(i,s,"texture"))});let a=ai(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>fm(i,s,"animation"))}),t}function XR(e){let t=e.map((o,a)=>{let i=Re(o.id)??`runtime-node-${a+1}`,s=Re(o.kind),c={id:`prefab-import-node:${pm(i,`node_${a+1}`)}`,runtimeId:i,label:Re(o.name)??Re(o.sourceName)??i,kind:s==="mesh"?"mesh":s==="root"?"root":"group",...Re(o.ownerNodePath)?{ownerNodePath:Re(o.ownerNodePath)}:{},...Re(o.sourceName)?{sourceName:Re(o.sourceName)}:{},...Array.isArray(o.materialIds)?{materialIds:o.materialIds.filter(d=>typeof d=="string")}:{},children:[]};return{runtimeId:i,parentId:Re(o.parentId),item:c}}),r=new Map(t.map(o=>[o.runtimeId,o.item])),n=[];for(let o of t)o.parentId&&r.has(o.parentId)?r.get(o.parentId).children.push(o.item):n.push(o.item);return n}function fm(e,t,r){let n=Re(e.id)??`${r}-${t+1}`,o=Re(e.url),a=Array.isArray(e.nodeIds)?e.nodeIds.filter(s=>typeof s=="string"):[],i=Array.isArray(e.textureIds)?e.textureIds.filter(s=>typeof s=="string"):[];return{id:`prefab-import-${r}:${pm(n,`${r}_${t+1}`)}`,itemType:r==="material"?"runtime-material":r==="texture"?"runtime-texture":"runtime-animation",runtimeId:n,label:Re(e.name)??n,kind:r,...Re(e.kind)?{runtimeKind:Re(e.kind)}:{},...o?{url:o}:{},...a.length>0?{nodeIds:a}:{},...i.length>0?{textureIds:i}:{},meta:[Re(e.kind),o,a.length>0?`${a.length} node${a.length===1?"":"s"}`:null,i.length>0?`${i.length} texture${i.length===1?"":"s"}`:null].filter(Boolean).join(" - ")}}function zh(e,t,r,n){if(r.itemType==="prefab-material-slot"||r.itemType==="runtime-material"||r.itemType==="runtime-texture")return r;if(r.itemType!=="prefab-node"||r.kind!=="model")return null;let o=typeof r.sourceAssetId=="string"?r.sourceAssetId:t.sourceAssetId;if(!o)return null;let a=e.assets.find(c=>c.id===o),i=Cc(a);if(i.length>0){let c=i[0]??null;return c?{...c,...typeof r.nodeId=="string"?{prefabNodeId:r.nodeId}:{}}:null}return($h(n.importStructure)?Lh(n.importStructure).find(c=>c.id==="prefab-import-materials"):null)?.children?.[0]??null}function vc(e,t){for(let r of e){if(r.id===t)return r;let n=r.children?vc(r.children,t):null;if(n)return n}return null}function Bh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function pm(e,t){return Bh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function ai(e,t){let n=Nh(e)?.[t];return Array.isArray(n)?n.map(Nh).filter(o=>!!o):[]}function Nh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"&&e.trim()?e.trim():null}function Vh(e,t,r={}){let n=Le(e,t.assetId);if(!n?.prefab)return[{id:"prefab-scene",label:"Prefab Scene Tree",kind:"root",children:[]}];let o=Ze(n),a=fl(n,null);return[{id:"prefab-root",label:"Prefab Scene Tree",kind:"root",children:(o?a.filter(s=>s.id===o):a).map(s=>Uh(n,s))}]}function Uh(e,t){let r=fl(e,t.id).map(n=>Uh(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??YR(t),kind:t.kind,itemType:"prefab-node",...t.guid?{guid:t.guid}:{},...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.childPrefabId?{childPrefabId:t.childPrefabId}:{},...t.sourceNodePath?{sourceNodePath:t.sourceNodePath}:{},...t.transform?{transform:structuredClone(t.transform)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults&&Object.keys(t.defaults).length>0?{defaults:structuredClone(t.defaults)}:{},...t.overrides&&Object.keys(t.overrides).length>0?{overrides:structuredClone(t.overrides)}:{},...r.length>0?{children:r}:{}}}function YR(e){return e.kind==="model"?e.sourceAssetId??e.id:e.kind==="prefabInstance"?e.childPrefabId??e.id:e.kind==="primitive"?e.primitive?.shape??e.id:e.id}function Kh(e,t,r){if(t.itemType!=="prefab-node"||t.kind!=="model")return null;let n=typeof t.sourceAssetId=="string"?t.sourceAssetId:null;if(!n)return null;let o=e.assets.find(g=>g.id===n),a=Cc(o),i=jc(o?.metadata?.assetAnalysis),s=gm(i?.nodes),c=gm(i?.meshes),d=Gc(r.importStructure,"nodes").length,u=Gc(r.importStructure,"materials").length,l=Gc(r.importStructure,"textures").length,m=Gc(r.importStructure,"animations").length,f=[Ot("prefab.sourceStructure.sourceAsset","Source Asset",o?.displayName??n,0),Ot("prefab.sourceStructure.assetId","Asset ID",n,1)];return o?.metadata?.relativePath&&f.push(Ot("prefab.sourceStructure.relativePath","Relative Path",String(o.metadata.relativePath),2)),f.push(Ot("prefab.sourceStructure.materialSlots","Material Slots",String(a.length),10),Ot("prefab.sourceStructure.modelNodes","Model Nodes",s.length>0?ZR(s):"No SDK node analysis",11),Ot("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?QR(c):"No SDK mesh primitive analysis",12),Ot("prefab.sourceStructure.runtimeNodes","Runtime Nodes",String(d),20),Ot("prefab.sourceStructure.runtimeMaterials","Runtime Materials",String(u),21),Ot("prefab.sourceStructure.runtimeTextures","Runtime Textures",String(l),22),Ot("prefab.sourceStructure.runtimeAnimations","Runtime Animations",String(m),23)),a.length>0&&f.push(Ot("prefab.sourceStructure.materialSlotSummary","Material Slot Summary",_h(a),30)),{id:"prefab-source-structure",title:"Source Structure",summary:o?"Readonly GLB / glTF anatomy":"Missing source asset",persistence:"readonly",effect:o?"active":"unsupported",properties:f}}function ZR(e){return e.slice(0,8).map((t,r)=>{let n=Nc(t.ownerNodePath)??Nc(t.name)??`node #${typeof t.nodeIndex=="number"?t.nodeIndex:r}`,o=typeof t.meshIndex=="number"?`mesh #${t.meshIndex}`:null,a=typeof t.primitiveCount=="number"?`${t.primitiveCount} primitives`:null;return[n,o,a].filter(Boolean).join(" \xB7 ")}).join(`
5
+ `)}function QR(e){return e.slice(0,8).map((t,r)=>{let n=Nc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=gm(t.primitives);if(o.length===0)return n;let a=o.slice(0,6).map((i,s)=>[`p${typeof i.primitiveIndex=="number"?i.primitiveIndex:s}`,typeof i.sourceMaterialIndex=="number"?`mat #${i.sourceMaterialIndex}`:null,Nc(i.materialName),typeof i.triangleCount=="number"?`${i.triangleCount} tri`:null].filter(Boolean).join(" ")).join(", ");return`${n}: ${a}`}).join(`
6
+ `)}function Gc(e,t){let n=jc(e)?.[t];return Array.isArray(n)?n.map(jc).filter(o=>!!o):[]}function jc(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function gm(e){return Array.isArray(e)?e.map(jc).filter(t=>!!t):[]}function Nc(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ot(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Hh(e,t,r){let n=e.prefab?.defaults?.shadow;return[ii({path:"prefab.defaults.shadow.cast",label:"Cast Shadow",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",order:t+0,tooltip:"Controls shadow casting for the entire Prefab definition."},r),ii({path:"prefab.defaults.shadow.receive",label:"Receive Shadow",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",order:t+1,tooltip:"Controls shadow receiving for the entire Prefab definition."},r)]}function ii(e,t){let r=n=>t.normalizePrefabAssetFieldValue(e.path,e.coerce?e.coerce(n):n);return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,...e.mixed===!0?{mixed:!0}:{},readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},...e.tooltip?{tooltip:e.tooltip}:{},validate:n=>t.validatePrefabAssetFieldValue(e.path,r(n))?{ok:!0,value:r(n)}:{ok:!1,message:`Invalid prefab field: ${e.path}.`},coerce:r}}function eC(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?tC(e,t,r,n,o,a()):r.itemType==="runtime-material"?Wh("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?Wh("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function tC(e,t,r,n,o,a){let i=Sr("en"),s=mg(t,r),c=r.prefabNodeId?io(t,r.prefabNodeId):null,d=r.prefabNodeId&&r.slotId?c?.overrides?.materialSlotBindings?.[r.slotId]:s,u=typeof d?.materialAssetId=="string"?d.materialAssetId:"",l=u||(typeof s?.materialAssetId=="string"?s.materialAssetId:""),m=e,f=ee(m,l||Dn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[vo("prefab.materialOverride.status","Status","Editable",0),vo("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),vo("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),On.createSelectorInspectorPropertyWithUsage(m,"instance",{path:r.materialAssetIdPath,label:"Material",value:u,order:10,text:i,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,ownerScope:"prefab",prefabAssetId:t.id,prefabNodeId:r.prefabNodeId,sourceBindingPath:r.materialAssetIdPath}},previewContext:n},a)]}}function rC(e,t,r,n,o){return eC(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var nC={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:rC},qh=nC;function Wh(e,t){return{id:"prefab-material-override-target",title:"Prefab Material Override",order:20,placement:"body",summary:e,persistence:"readonly",effect:"unsupported",collapsedByDefault:!1,properties:[vo("prefab.materialOverride.status","Status","Read Only",0),vo("prefab.materialOverride.reason","Reason",e,1),vo("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function vo(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function oC(e,t,r,n,o,a){let i=Le(e,t.assetId);if(!i)return null;let s=t.sourceAssetId?e.assets.find(S=>S.id===t.sourceAssetId)??null:null,c=r?vc(Vh(e,t,n),r)??Fh(e,t,r,n):null,d=c?zh(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Kh(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?io(i,m):null,g=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?sC(i,f):null,b=f?.kind==="marker"&&f.marker?uC(i,f,o):null;return{targetIds:[i.id],activeId:i.id,label:n.importStructureReady?"Prefab Runtime Ready":t.label,document:e,selection:{targetIds:[i.id],activeId:i.id,scopeType:"prefab-stage",targetKind:"prefab",document:e},sections:[{id:"prefab-stage",title:"Prefab Stage",summary:n.importStructureReady?"Runtime Ready":"Preview",persistence:"document",properties:[ii({path:"displayName",label:"Display Name",valueType:"string",control:"string",value:i.displayName??i.id,order:0},o),j({path:"prefab.sourceAssetId",label:"Source Asset",value:s?.displayName??t.sourceAssetId??"Missing",order:1}),ii({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...Hh(i,3,o),j({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(S=>!!S)},...g?[g]:[],...b?[b]:[],...l?[l]:[],...u?[u]:[]]}}function aC(e,t,r,n={},o){return oC(e,t,r,n,o,qh.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var iC={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:aC},Xh=iC;function sC(e,t){let r=cC(t),n=t.parentId?io(e,t.parentId):null,o=[],a=0;for(let i of["position","rotation","scale"])for(let s of["x","y","z"]){let c=r[i][s];o.push({path:`transform.${i}.${s}`,label:`${dC(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?lC(c):c,readOnly:!1,persistence:"document",commitMode:"live",order:a,step:i==="rotation"?1:.1,validate:d=>typeof d=="number"&&Number.isFinite(d)?{ok:!0,value:d}:{ok:!1,message:"Transform value must be a finite number."},coerce:d=>typeof d=="number"?d:Number(d)}),a+=1}return{id:"transform",title:"Transform",summary:`Relative to: ${n?.name??n?.id??"Prefab"}`,order:20,placement:"body",persistence:"document",collapsedByDefault:!1,properties:o}}function cC(e){return e.transform?.type==="Transform"&&e.transform.mode!=="matrix"?{...e.transform,mode:e.transform.mode??"trs",scale:e.transform.scale??{x:1,y:1,z:1}}:{type:"Transform",mode:"trs",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function dC(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function lC(e){return Math.round(e*180/Math.PI*1e6)/1e6}function uC(e,t,r){let n=t.marker,o=n.target??null,a=o?Jh(o):"",i=[{label:"Unbound",value:""},...Qe(e).filter(u=>u.id!==t.id).map(u=>{let l=u.kind==="marker"?"marker":"scene-object";return{label:u.name??u.id,value:Jh({kind:l,id:u.id})}})];o&&a&&!i.some(u=>u.value===a)&&i.push({label:`Missing: ${o.id}`,value:a});let s=r.markerTypeCatalog.map(u=>({label:u.label||u.type,value:u.type}));s.some(u=>u.value===n.type)||s.push({label:`Missing: ${n.type}`,value:n.type});let c=r.markerTypeCatalog.find(u=>u.type===n.type)??null,d=c?.kind==="region"?c.allowedGeometryKinds?.length?c.allowedGeometryKinds:["box"]:[];return{id:"prefab-marker",title:"Marker",summary:r.markerTypeCatalog.find(u=>u.type===n.type)?.label??n.type,order:35,placement:"body",persistence:"document",collapsedByDefault:!1,properties:[Go({path:"prefab.marker.type",label:"Marker Type",valueType:"enum",control:"enum",value:n.type,options:s,order:0,validate:u=>typeof u=="string"&&r.markerTypeCatalog.some(l=>l.type===u)}),j({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),d.length>0?Go({path:"prefab.marker.geometry",label:"Geometry",valueType:"enum",control:"enum",value:n.geometry.kind,options:d.map(u=>({label:u==="cylinder"?"Circle":"Rectangle",value:u})),order:2,validate:u=>typeof u=="string"&&d.includes(u)}):j({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),Go({path:"prefab.marker.target",label:"Target",valueType:"enum",control:"enum",value:a,options:i,order:3,validate:u=>typeof u=="string"&&i.some(l=>l.value===u)}),j({path:"prefab.marker.targetStatus",label:"Target Status",value:o?i.some(u=>u.value===a&&!u.label.startsWith("Missing:"))?"Resolved":"Unresolved local reference":"Unbound",order:4,source:"Derived"}),Go({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:u=>typeof u=="string"}),Go({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:u=>typeof u=="string"}),Go({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:mC})].filter(u=>!!u)}}function Go(e){return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},validate:t=>e.validate(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid Prefab Marker field: ${e.path}.`}}}function Jh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function mC(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return["r","g","b"].every(r=>typeof t[r]=="number"&&Number.isFinite(t[r])&&t[r]>=0&&t[r]<=1)}function Yh(e,t){let r=fn(e,t.id);if(!r.prefab)return null;let n=r.diagnostics.filter(m=>m.severity==="error").length,o=r.diagnostics.filter(m=>m.severity==="warning").length,a=r.diagnostics.filter(m=>m.severity==="info").length,i=r.diagnostics.length>0,s=n>0?"unsupported":i?"derived":"active",c=n>0?"Prefab relation is incomplete; fix the missing definition or source asset before using prefab actions.":void 0,d=r.definition?.displayName??r.definition?.id??r.prefab.prefabId,u=r.sourceAsset?.displayName??r.sourceAsset?.id??r.prefab.sourceAssetId??"Missing",l=[j({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),j({path:"prefab.relation.source",label:"Source Model",value:u,order:1,source:r.sourceAsset?"Asset":"Document",effect:s,disabledReason:c})].filter(m=>!!m);return i&&l.push(j({path:"prefab.relation.diagnostics",label:"Diagnostics",value:r.diagnostics.map(m=>`${m.severity}:${m.code} - ${m.message}`).join(`
7
+ `),order:2,source:"Derived",effect:s,disabledReason:c})),l.push(bm({path:"prefab.actions.editDefinition",label:"Edit Prefab",actionId:"prefab.edit-definition",order:10,icon:"prefab",tooltip:"Open the prefab definition stage.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(bm({path:"prefab.actions.selectDefinition",label:"Select Prefab",actionId:"prefab.select-definition",order:11,icon:"prefab",tooltip:"Select the prefab asset in the asset browser.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(bm({path:"prefab.actions.pingSource",label:"Ping Source",actionId:"prefab.ping-source",order:12,icon:"asset",tooltip:"Select the prefab source asset in the asset browser.",params:{assetId:r.sourceAsset?.id??r.prefab.sourceAssetId},disabled:!r.sourceAsset,disabledReason:c,effect:s})),{id:"prefab-instance",title:"Prefab",order:48,placement:"body",summary:n>0?`${n} ${n===1?"error":"errors"}`:o>0?"Warning":a>0?"Info":"Ready",persistence:"readonly",effect:s,disabledReason:c,collapsedByDefault:!1,properties:l}}function bm(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Zh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function ym(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function Nn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return bC(r)?ae(r):Ie(1,1,1)}return Ie(1,1,1)}function Hr(e,t){let r=ke(e,t);return r&&Tt(r)?r:null}function hm(e,t,r){let n=fr(e,t??void 0,r);return n&&Tt(n)?n:null}function tE(e,t){let r=ke(e,t.id);return r?nE(r,t.name??t.id):null}function rE(e,t){let r=xm(t);if(r?.kind!=="scene-object")return null;let n=e.scene.gameObjects.find(a=>a.id===r.id)??null,o=ke(e,r.id);return!n||!o?null:nE(o,r.label||n.name||r.id)}function nE(e,t){let r=Fe(e),n=Fc(Ie(r[0],r[1],r[2]));if(!n)return null;let o=Ie(r[4],r[5],r[6]),a=Fc(fC(o,Sm(n,Qh(o,n))));if(!a)return null;let i=Fc(eE(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);Qh(i,s)<0&&(i=Sm(i,-1));let c=Fc(eE(i,n));return c?{origin:Yi(e),right:n,up:c,forward:i,label:t}:null}function Qh(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function eE(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function fC(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function Sm(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Fc(e){let t=Math.hypot(e.x,e.y,e.z);return Number.isFinite(t)&&t>1e-6?Sm(e,1/t):null}function hr(e,t,r,n={}){let o=t.trim(),a=o?Rr(yC(e),n).find(i=>i.type===o)?.kind:void 0;return _c(a??r??(o?void 0:"point"))}function _c(e){let t=e?.trim();return t?t==="object-bound"||t==="object-bounds"?"object":t:"point"}function Em(e,t,r){if(Pm(t)){let n=Im(r);return(e.geometry.kind==="box"||e.geometry.kind==="cylinder")&&n.includes(e.geometry.kind)?e.geometry.kind:pC(r,n)}return Tm(t)&&xm(e)?"object-bounds":"point"}function Im(e){let t=e?.allowedGeometryKinds?.filter(r=>r==="box"||r==="cylinder")??[];return t.length>0?[...new Set(t)]:e?.defaultGeometryKind?[e.defaultGeometryKind]:["box"]}function pC(e,t=Im(e)){let r=e?.defaultGeometryKind;return r&&t.includes(r)?r:t[0]??"box"}function si(e,t,r,n,o={},a,i){let s=Hr(e,t.id),c=ae(s?.position??Ie(0,0,0)),d=ae(s?.rotation??Ie(0,0,0)),u=gC(e,t,r,o)?jo(r):ae(s?.scale??Nn(t));if(Pm(r)){let m=Im(a);return(i&&m.includes(i)?i:Em(t.marker,r,a))==="cylinder"?{kind:"cylinder",coordinateSpace:"world",center:c,radius:Bc(Math.max(Math.abs(u.x),Math.abs(u.z))/2),height:Vc(u.y),rotation:d}:{kind:"box",coordinateSpace:"world",center:c,size:zc(u),rotation:d}}let l=xm(t.marker);return Tm(r)&&l?{kind:"object-bounds",target:l}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:c,...l?{target:l}:{}}}function oE(e,t,r,n,o){if(o)return Tm(n)||r.kind==="object-bounds"?{kind:"object-bounds",target:structuredClone(o)}:r.kind==="point"?{...structuredClone(r),target:structuredClone(o)}:structuredClone(r);if(r.kind==="object-bounds"){let a=Hr(e,t.id);return{kind:"point",coordinateSpace:"world",position:ae(a?.position??Ie(0,0,0))}}if(r.kind==="point"){let a=structuredClone(r);return delete a.target,a}return structuredClone(r)}function aE(e,t){let r=e.scene.gameObjects.find(n=>n.id===t)??null;return!r||de(r)?null:{kind:"scene-object",id:r.id,label:r.name||r.id}}function gC(e,t,r,n={}){let o=hr(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=Hr(e,t.id)?.scale??Nn(t);return sE(a,jo(o))}function iE(e,t,r,n={}){if(!de(t))return!1;let o=hr(e,t.marker.type,t.marker.kind,n),a=_c(r.kind);if(o===a&&t.marker.geometry.kind===r.geometry.kind)return!1;let i=Hr(e,t.id)?.scale??Nn(t);return sE(i,jo(o))}function jo(e){return Pm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function Pm(e){return _c(e)==="region"}function Tm(e){return _c(e)==="object"}function xm(e){return e.target?structuredClone(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?structuredClone(e.geometry.target):null}function sE(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function cE(e){switch(e.kind){case"box":return{kind:"box"};case"cylinder":return{kind:"cylinder"};case"point":return{kind:"point",coordinateSpace:e.coordinateSpace,...e.coordinateSpace==="local"?{position:ae(e.position)}:{},...e.target?{target:structuredClone(e.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(e.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:e.coordinateSpace,vertices:e.vertices.map(ae),...e.faces?{faces:e.faces.map(t=>[...t])}:{}}}}function $c(e){switch(e.kind){case"box":return ae(e.center);case"cylinder":return ae(e.center);case"point":return e.coordinateSpace==="world"?ae(e.position):Ie(0,0,0);case"polyhedron":return SC(e.vertices);case"object-bounds":return Ie(0,0,0)}}function Lc(e){return(e.kind==="box"||e.kind==="cylinder")&&e.rotation?ae(e.rotation):Ie(0,0,0)}function Am(e,t){if(e.kind==="box")return zc(e.size);if(e.kind==="cylinder"){let r=Bc(e.radius)*2;return{x:r,y:Vc(e.height),z:r}}return ae(t)}function zc(e){return{x:Math.max(1e-6,Math.abs(e.x)),y:Math.max(1e-6,Math.abs(e.y)),z:Math.max(1e-6,Math.abs(e.z))}}function Bc(e){return Math.max(1e-6,Math.abs(Number.isFinite(e)?e:0))}function Vc(e){return Math.max(1e-6,Math.abs(Number.isFinite(e)?e:0))}function Uc(e){return e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function ae(e){return{x:e.x,y:e.y,z:e.z}}function bC(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Ie(e,t,r){return{x:e,y:t,z:r}}function dE(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function SC(e){if(e.length===0)return Ie(0,0,0);let t={x:Math.min(...e.map(n=>n.x)),y:Math.min(...e.map(n=>n.y)),z:Math.min(...e.map(n=>n.z))},r={x:Math.max(...e.map(n=>n.x)),y:Math.max(...e.map(n=>n.y)),z:Math.max(...e.map(n=>n.z))};return{x:(t.x+r.x)/2,y:(t.y+r.y)/2,z:(t.z+r.z)/2}}function yC(e){return e.scene.markerGraph??null}function Kc(e,t={}){let r=AC(e,t);if(r!==e)return Kc(r,t);let n=hC(e);if(n!==e)return Kc(n,t);let o=ci(e);if(!o)return e;let a=dr(o),i=EC(e,a);return sa(o,i)?e:Wd(e,i)}function hC(e){let t=ci(e),r=t?dr(t):null;if(!r||r.markers.length===0)return e;let n=new Set(e.scene.gameObjects.map(c=>c.id)),o=new Map,a=[];for(let c of r.markers){if(e.scene.gameObjects.some(u=>u.id===c.id&&de(u))){o.set(c.id,c.id);continue}let d=n.has(c.id)?OC(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>uE(e,Ap(c.marker,o),c.gameObjectId,null)),s=dr({...r,markers:[],relations:r.relations.map(c=>xp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function EC(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>IC(i,r)),o=new Set([...n.map(i=>i.id),...e.scene.gameObjects.filter(de).map(i=>i.id)]),a=t.relations.filter(i=>Hd(i.from,r,o)&&Hd(i.to,r,o));return{...t,markers:n,relations:a}}function IC(e,t){if(!ia(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return ia(e.geometry.target,t);case"point":return ia(e.geometry.target,t);case"box":case"cylinder":case"polyhedron":return!0}}function lE(e,t,r={}){switch(t.type){case"marker.create-box":return PC(e,t.marker,t.parentId??null);case"marker.update":return TC(e,t.markerId,t.patch,r);case"marker.delete":return xC(e,t.markerId);default:return null}}function PC(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=dr(ci(e)),o=uE(e,t,t.id,r),a={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,o]}};return Wd(a,{...n,markers:n.markers.filter(i=>i.id!==t.id)})}function TC(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=Er(e,o,n),i=cr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=dr(void 0);if(sa({...s,markers:[a]},{...s,markers:[i]}))return e;let c=mE(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function xC(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=Dp(e,t),o=dr(ci(e));return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.filter(a=>!n.has(a.id)),markerGraph:{...o,markers:[],relations:o.relations.filter(a=>!Kd(a.from,n)&&!Kd(a.to,n))}}}}function AC(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=DC(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function DC(e,t,r={}){return wC(e,t,r)}function uE(e,t,r,n){let o=jo(t.kind),a={position:$c(t.geometry),rotation:Lc(t.geometry),scale:Am(t.geometry,o)},i=n?hm(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:pE(t),components:[{type:"Transform",...i}]}}function mE(e,t,r,n={}){let o=Hr(e,t.id)?.scale??Nn(t),a=iE(e,t,r,n)?jo(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:pE(r),components:MC(e,t,t.components,r.geometry,a)}}function MC(e,t,r,n,o){let a=o??Nn(t),i=Hr(e,t.id),s={position:ym(n)?ae(i?.position??$c(n)):$c(n),rotation:ym(n)?ae(i?.rotation??Lc(n)):Lc(n),scale:Am(n,a)},c=hm(e,t.parentId,s)??s,d=!1,u=r.map(l=>l.type!=="Transform"?l:(d=!0,{...l,position:c.position,rotation:c.rotation,scale:c.scale}));return d?u:[...u,{type:"Transform",position:c.position,rotation:c.rotation,scale:c.scale}]}function wC(e,t,r={}){if(t.marker.geometry.kind==="polyhedron")return t;let n=hr(e,t.marker.type,t.marker.kind,r),o=Rr(ci(e),r).find(c=>c.type===t.marker.type)??null,a=Em(t.marker,n,o);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===a)return t;let i=Er(e,t,r),s=cr({...i,kind:n,markerType:t.marker.type.trim(),geometry:si(e,t,n,i.geometry,r,o)});return mE(e,t,s,r)}function fE(e,t={}){return e.scene.gameObjects.filter(de).map(r=>Er(e,r,t))}function Er(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?rE(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):tE(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:hr(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:kC(e,t),...n.target?{target:structuredClone(n.target)}:{},...i?{semanticFrame:i}:{},...n.tags?.length?{tags:[...n.tags]}:{},...Object.keys(o).length>0?{metadata:o}:{}}}function kC(e,t){let r=t.marker,n=Hr(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??Nn(t);switch(r.geometry.kind){case"box":return{kind:"box",coordinateSpace:"world",center:ae(o),size:zc(i),rotation:ae(a)};case"cylinder":return{kind:"cylinder",coordinateSpace:"world",center:ae(o),radius:Bc(Math.max(Math.abs(i.x),Math.abs(i.z))/2),height:Vc(i.y),rotation:ae(a)};case"point":return(r.geometry.coordinateSpace??"world")==="world"?{kind:"point",coordinateSpace:"world",position:r.geometry.offset?dE(o,r.geometry.offset):ae(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}}:{kind:"point",coordinateSpace:"local",position:r.geometry.position?ae(r.geometry.position):ae(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(r.geometry.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:r.geometry.coordinateSpace??"world",vertices:r.geometry.vertices.map(ae),...r.geometry.faces?{faces:r.geometry.faces.map(s=>[...s])}:{}}}}function pE(e){let t=e.metadata?structuredClone(e.metadata):{},r=RC(t.color),n=typeof t.note=="string",o=n?t.note:void 0;return r&&delete t.color,n&&delete t.note,{schemaVersion:1,type:e.markerType,...e.kind?{kind:e.kind}:{},...e.tags?.length?{tags:[...e.tags]}:{},...o!==void 0?{note:o}:{},...r?{color:r}:{},...e.target?{target:structuredClone(e.target)}:{},...e.semanticFrame?{semanticFrame:structuredClone(e.semanticFrame)}:{},geometry:cE(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function OC(e,t){let r=Uc(e)||"marker",n=1,o=`${r}-marker`;for(;t.has(o);)n+=1,o=`${r}-marker-${n}`;return o}function RC(e){if(!e||typeof e!="object")return null;let t=e,r=Dm(t.r),n=Dm(t.g),o=Dm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function Dm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function ci(e){return e.scene.markerGraph??null}function bE(e){let t=n=>e.getMarkerTypeCatalogFromGraph(gE(n)),r=n=>{let o=dr(gE(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of fE(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=wp(n,o,{sanitizeMarkerGameObjectId:Uc});return kp(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(qd(a)),label:Op(a),...Rp(a),...a.type==="marker.create-box"?{createdId:a.marker.id}:{},normalizedCommand:qd(a)}:null},createMarkerTypeUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim();if(!s)return null;let c=t(n).find(m=>m.type===s)??null;if(!c)return null;let d=hr(n,s,i.marker.kind,e.options),u=Er(n,i,e.options),l=si(n,i,d,u.geometry,e.options,c);return{type:"marker.update",markerId:o,patch:{markerType:s,kind:d,geometry:l}}},createMarkerGeometryUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=t(n).find(m=>m.type===i.marker.type)??null,c=a.trim();if(!s||s.kind!=="region")return null;let d=s.allowedGeometryKinds?.length?s.allowedGeometryKinds:["box"];if(c!=="box"&&c!=="cylinder"||!d.includes(c))return null;let u=Er(n,i,e.options);if(i.marker.geometry.kind===c)return{type:"marker.update",markerId:o,patch:{geometry:u.geometry}};let l=si(n,i,"region",u.geometry,e.options,s,c);return{type:"marker.update",markerId:o,patch:{geometry:l}}},createMarkerTargetUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?aE(n,s):null;if(s&&!c)return null;let d=Er(n,i,e.options),u=hr(n,i.marker.type,i.marker.kind,e.options),l=oE(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return hr(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=lE(n,o,e.options);if(a)return a;let i=r(n),s=Mp(i,o,e.options);return sa(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return Kc(n,e.options)}}}function gE(e){return e?.scene.markerGraph}function SE(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?hE(e,n,r,r.id,t):[]})}function yE(e,t,r,n=[]){let o=Le(e,t);if(!o)return[];let a={id:r,name:o.displayName??o.id,kind:"group",components:[Hc()]};return hE(e,o,a,r,n)}function hE(e,t,r,n,o){let a=[],i=[];EE(e,t,{instanceId:r.id,parentId:r.parentId,rootTransform:G(r)??Hc(),isHostRoot:!0,visitedPrefabIds:new Set,derivedObjects:a,markerDescriptors:i});let s=new Set([r.id,...a.map(d=>d.id)]);for(let d of a)d.marker&&(d.marker.target&&s.add(d.marker.target.id),d.marker.geometry.kind==="point"&&d.marker.geometry.target&&s.add(d.marker.geometry.target.id),d.marker.geometry.kind==="object-bounds"&&s.add(d.marker.geometry.target.id));let c={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects.filter(d=>!s.has(d.id)),r,...a]}};return i.flatMap(d=>{let u=c.scene.gameObjects.find(l=>l.id===d.runtimeId);return u?.marker?[{ownerInstanceId:n,prefabAssetId:d.prefabAssetId,localNodeId:d.localNodeId,marker:Er(c,u,{builtInMarkerTypes:o})}]:[]})}function EE(e,t,r){if(r.visitedPrefabIds.has(t.id))return;let n=Qe(t),o=Ze(t),a=o?n.find(d=>d.id===o):null;if(!a)return;let i=new Set(r.visitedPrefabIds).add(t.id),s={instanceId:r.instanceId,rootNodeId:a.id},c=d=>so(s,d.id);for(let d of n){let u=c(d),l=d.id===a.id,m=d.parentId?n.find(b=>b.id===d.parentId):null,f=l?r.parentId:c(m??a);if(d.kind==="prefabInstance"&&d.childPrefabId){let b=Le(e,d.childPrefabId);b&&EE(e,b,{instanceId:u,...f?{parentId:f}:{},rootTransform:l?r.rootTransform:d.transform??Hc(),isHostRoot:r.isHostRoot&&l,visitedPrefabIds:i,derivedObjects:r.derivedObjects,markerDescriptors:r.markerDescriptors});continue}if(r.isHostRoot&&l)continue;let g=d.kind==="marker"&&d.marker?ya({...structuredClone(d.marker),semanticFrame:void 0},s):void 0;r.derivedObjects.push({id:u,name:d.name??d.id,kind:d.kind==="marker"?"transform":"group",...f?{parentId:f}:{},...g?{marker:g}:{},components:[l?r.rootTransform:d.transform??Hc()]}),g&&r.markerDescriptors.push({prefabAssetId:t.id,localNodeId:d.id,runtimeId:u})}}function Hc(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function CC(e){return e?e.list().filter(t=>De(t.shaderId)==null).map(t=>{let r=t.inspector.sections.length,n=t.inspector.fields.length;return{id:`shader:${t.shaderId}`,assetId:t.shaderId,label:t.displayName,kind:"shader",placeable:!1,meta:`${t.shaderId} \xB7 v${t.version} \xB7 ${n} fields`,shader:{shaderId:t.shaderId,displayName:t.displayName,version:t.version,runtimeKind:t.runtimeKind,sectionCount:r,fieldCount:n,...t.sourceFile?{sourceFile:t.sourceFile}:{}}}}):[]}function IE(e){let t=xy(e.objectCommandServices);return{getHierarchyItems:e.hierarchyFacade.getHierarchyItems,normalizeHierarchyDocument:e.hierarchyFacade.normalizeHierarchyDocument,createRenamePatch:e.hierarchyFacade.createRenamePatch,createCreateGroupPatch:e.hierarchyFacade.createCreateGroupPatch,createCreatePrimitivePatch:e.hierarchyFacade.createCreatePrimitivePatch,createDeleteSubtreePatch:e.hierarchyFacade.createDeleteSubtreePatch,collectSubtreeIdList:e.hierarchyFacade.collectSubtreeIdList,validateReparent:e.hierarchyFacade.validateReparent,createReparentPatch:e.hierarchyFacade.createReparentPatch,validateHierarchyMove:e.hierarchyFacade.validateHierarchyMove,createHierarchyMovePatch:e.hierarchyFacade.createHierarchyMovePatch,validateGroupSelection:e.hierarchyFacade.validateGroupSelection,createGroupSelectionPatch:e.hierarchyFacade.createGroupSelectionPatch,createDuplicateSelectionPatch:e.hierarchyFacade.createDuplicateSelectionPatch,createPlacedAssetPatch:e.hierarchyFacade.createPlacedAssetPatch,applySerializedPropertyPatch:t.applySerializedPropertyPatch,canCreateSerializedMultiPropertyPatch:t.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:t.createSerializedMultiPropertyPatch,createBrowserAssetItems(r,n={}){let o=_e.getCachedUsageIndex(r);return[..._e.createBrowserAssetItems(r,o,n),...CC(n.materialShaderDefinitions),...Rh(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o,a){let i=_a(r,n,o,{...e.assetPlacementServices,...a});return{document:i.document,gameObject:i.gameObject}}}}function vC(e,t){if(!e.scene||typeof e.scene!="object"||Array.isArray(e.scene))return null;let r=e.scene;if(r.kind!==e.id)return null;let n=AE(r.contribution);return n?Mm(n):t?yh(e,t):null}function TE(e){let t=(e.features??[]).flatMap(p=>{let A=e.resolveFeatureSceneContribution?.(p);if(A)return[Mm(A)];let h=vC(p,()=>d);if(h)return[h];let R=AE(p.scene);return R?[Mm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=iv(t),o=bE({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>tv(e.markerTypes,p)}),a=(p,A)=>A?$(p,A):null,i=()=>[p=>n?.validateInspectorField?.({document:p.document??null,gameObject:p.document?a(p.document,p.targetId):null,path:p.path,value:p.value})??null,p=>ev(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Ml({hasMaterialAsset:Ut,isMarkerGameObject:de,isDirectionalLightAnglePath:fo})],s=(p,A)=>n?.normalizeInspectorValue?.(p,A)??mr(p,A,{isDirectionalLightAnglePath:fo}),c=(p,A,h,R)=>{if(fo(h)&&A.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:A,path:h,value:R});return K||po({document:p,path:h,nodeKind:di(A),value:R,extraValidators:i()})},d=(p,A,h)=>xa({document:p,nodeKind:A,property:h,extraValidators:i()}),l={systemDefaults:qC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:Zh,findGameObject:a,isCameraGameObject:Dt,isLightGameObject:go,isProtectedSystemGameObject:Mt,hasCamera:(p,A)=>p.scene.gameObjects.some(h=>h.id!==A&&Dt(h)),...n?.fieldMutation},m=XC(e,o,l,a,s,c,n),f=(p,A,h,R)=>sc(p,A,h,R,m),g=(p,A,h,R)=>Py(p,A,h,R,m),b=(p,A)=>Eu(p,A,m.fieldMutationOptions),S=(p,A,h)=>Pn(p,A,{transform:h}),y=(p,A)=>Xl(p,A),I=JC(e,o,l,f,g,n),E=YC(o),D={isRootTransformPath:js,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:Dt,isLightGameObject:go,isSerializedMultiFieldPath:p=>nv(p,n),isSerializedMultiProjectionPath:p=>ov(p,n),getSerializedMultiPropertyProbeValue:p=>av(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>Ao(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},x=IE({hierarchyFacade:E,objectCommandServices:D,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:A,worldTransform:h})=>fr(p,A??void 0,h)}}),N={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(A=>A.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(A=>A.type==="ImageRenderer"),readNodeKind:di},B={};return Object.assign(B,{historyDocumentStorage:r,defaults:{camera:tc,sunLight:Va,environmentLight:Cn},reduceDocument:(p,A)=>Nu(p,A,I),ensureEnvironmentDefaults:p=>ju(p,I),isSelectableHierarchyId:(p,A)=>_l(p,A),resolveDiagnosticLocator:(p,A)=>{let h=A.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=vr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:vp,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:x.getHierarchyItems,normalizeHierarchyDocument:x.normalizeHierarchyDocument,createRenamePatch:x.createRenamePatch,createCreateGroupPatch:x.createCreateGroupPatch,createCreatePrimitivePatch:x.createCreatePrimitivePatch,createDeleteSubtreePatch:x.createDeleteSubtreePatch,createReparentPatch:x.createReparentPatch,createHierarchyMovePatch:x.createHierarchyMovePatch,createGroupSelectionPatch:x.createGroupSelectionPatch,createDuplicateSelectionPatch:x.createDuplicateSelectionPatch,createPlacedAssetPatch:x.createPlacedAssetPatch,validateReparent:x.validateReparent,validateHierarchyMove:x.validateHierarchyMove,validateGroupSelection:x.validateGroupSelection,collectSubtreeIds:br,createFeatureHierarchyPatch:(p,A)=>n?.createHierarchyPatch?.(p,A)??null,createInspectorPropertyPatch:p=>NC(m,p),createSceneMaterialBindingPatch:p=>jC(e,m,p),createPrefabMaterialBindingPatch:p=>FC(e,p),createMaterialPropertiesPatch:p=>WC(e,m,p),createMaterialAssetCreatePatch:p=>LC(e,p),createMaterialAssetRestorePatch:p=>zC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>BC(e,p),createMaterialAssetDuplicatePatch:p=>VC(e,p),createMaterialAssetDeletePatch:p=>UC(e,p),createMaterialAssetRenamePatch:p=>KC(e,p),createMaterialAssetSetShaderPatch:p=>HC(e,p),patchGameObjectField:f,patchGameObjectsField:g,patchGameObjectPropertiesMany:b,patchGameObjectTransform:S,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>GC(e,m,p),canCreateSerializedMultiPropertyPatch:x.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:x.createSerializedMultiPropertyPatch,createBrowserAssetItems:x.createBrowserAssetItems,addAssetLibraryItemToDocument:x.addAssetLibraryItemToDocument,getInspectorObject:(p,A,h={})=>ZC(B,e,o,p,A,PE(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,A,h,R={})=>QC(p,A,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,A,h,R={})=>Xh.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,A,h,PE(e.materialShaderDefinitions,R),{createIdentityTransformComponent:JS,mergeLightDefaults:vn,sunLightId:"sun_light",normalizePrefabAssetFieldValue:dm,validatePrefabAssetFieldValue:lm,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>Kl({...p,sourceRef:qt(p.document)},N),createRuntimeInspectorSnapshot:p=>ha({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>SE(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,A,h)=>yE(p,A,h,o.getMarkerTypeCatalog(p)),getRelationTypeCatalog:()=>e.relationTypes.map(p=>structuredClone(p)),createMarkerGraphPatch:o.createMarkerGraphPatch,reduceMarkerGraphPatch:o.reduceMarkerGraphPatch,syncMarkerGraphDocument:o.syncMarkerGraphDocument,resolveMarkerKind:o.resolveMarkerKind,assertMaterialAssetIntegrity:Ws}),B}function GC(e,t,r){if(r.changes.length<2)return null;let n=new Set,o=[],a=new Set;for(let s of r.changes){let c=`${s.targetId}\0${s.path}`;if(!s.targetId||!s.path||n.has(c))return null;n.add(c);let d=Ao({document:r.document,targetId:s.targetId,path:s.path,value:s.value},t),u=d?.patch;if(!d||!u||u.kind!=="game-object.field"||u.targetId!==s.targetId||u.path!==s.path)return null;o.push({targetId:s.targetId,path:s.path,value:u.value});for(let l of d.reprojectIds??[])a.add(l)}let i=[...new Set(o.map(s=>s.targetId))];return{patch:e.createPatch.gameObjectFieldBatch(o),label:`Patch ${o.length} Inspector properties`,changedIds:i,...a.size>0?{reprojectIds:[...a]}:{}}}function jC(e,t,r){if(r.targets.length===0)return null;let n=new Set,o=[];for(let s of r.targets){let c=`${s.objectId}\0${s.path}`;if(n.has(c))return null;n.add(c);let u=Ao({document:r.document,targetId:s.objectId,path:s.path,value:r.materialAssetId},t)?.patch;if(!u||u.kind!=="game-object.field"||u.targetId!==s.objectId||u.path!==s.path)return null;o.push({targetId:s.objectId,path:s.path,value:u.value})}let a=[...new Set(o.map(s=>s.targetId))],i=xE(r.document,r.targets,r.materialAssetId);return{patch:e.createPatch.gameObjectFieldBatch(o),label:`${r.materialAssetId?"Set":"Clear"} ${o.length} scene material binding${o.length===1?"":"s"}`,changedIds:a,reprojectIds:a,presentationImpact:i}}function NC(e,t){let r=Ao(t,e);if(!r||!Cr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:xE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function FC(e,t){if(t.targets.length===0||t.materialAssetId&&!Ut(t.document,t.materialAssetId)||new Set(t.targets.map(s=>s.prefabAssetId)).size!==1)return null;let n=t.targets[0].prefabAssetId,o=Le(t.document,n);if(!o?.prefab)return null;let a=structuredClone(o),i=new Set;for(let s of t.targets){let c=`${s.nodeId??""}\0${s.path}`;if(i.has(c))return null;i.add(c);let d=`prefab.${s.path}`,u=dm(d,t.materialAssetId);if(!lm(d,u))return null;if(!s.nodeId){a=ba(a,d,u);continue}let l=a.prefab?.nodes?.findIndex(S=>S.id===s.nodeId)??-1;if(l<0||!a.prefab?.nodes)return null;let m=a.prefab.nodes[l],f={...a,prefab:{...a.prefab,overrides:structuredClone(m.overrides)}},g=ba(f,d,u),b={...m,...g.prefab?.overrides?{overrides:structuredClone(g.prefab.overrides)}:{}};g.prefab?.overrides||delete b.overrides,a.prefab.nodes=[...a.prefab.nodes],a.prefab.nodes[l]=b}return{patch:e.createPatch.prefabAssetReplace?.(n,a)??{kind:"scene.prefab-asset.replace",assetId:n,prefabAsset:a},label:`${t.materialAssetId?"Set":"Clear"} ${t.targets.length} prefab material binding${t.targets.length===1?"":"s"}`,changedId:n,changedIds:[n],reprojectIds:[n],presentationImpact:_C(t.document,t.targets,t.materialAssetId)}}function xE(e,t,r){let n=new Set(t.map(a=>`${a.objectId}\0${a.path}`)),o=new Set;r&&o.add(r);for(let a of fa(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function _C(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=$C(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function $C(e,t){let r=Le(e,t.prefabAssetId)?.prefab,n=t.nodeId?r?.nodes?.find(a=>a.id===t.nodeId)?.overrides:r?.overrides;if(!n)return null;let o=t.path==="overrides.materialBinding.materialAssetId"?n.materialBinding?.materialAssetId:n.materialSlotBindings?.[zt(t.path,"materialAssetId")??""]?.materialAssetId;return typeof o=="string"&&o.trim()?o.trim():null}function LC(e,t){let r=eS(t.document,t.definition,t.name);return{patch:e.createPatch.materialAssetCreate?.(r)??{kind:"scene.material-asset.create",materialAsset:r},label:`Create material ${r.name}`,changedIds:[],createdId:r.id}}function zC(e,t){return ee(t.document,t.materialAsset.id)?null:{patch:e.createPatch.materialAssetCreate?.(t.materialAsset)??{kind:"scene.material-asset.create",materialAsset:t.materialAsset},label:`Restore material ${t.materialAsset.name}`,changedIds:[],createdId:t.materialAsset.id}}function BC(e,t){let r=aS({document:t.document,gameObject:t.gameObject,bindingPath:t.bindingPath,profile:t.profile,sourceAsset:t.sourceAsset,sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,sourceMaterialName:t.sourceMaterialName});return r?{...r,patch:e.createPatch.materialAssetCreateAndBind?.({targetId:r.patch.targetId,bindingPath:r.patch.bindingPath,materialAsset:r.patch.materialAsset})??r.patch,label:`Create material ${r.patch.materialAsset.name} from GLB source`,presentationImpact:{inspector:["material"],materials:{assetIds:[r.createdId]}}}:null}function VC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=tS(t.document,r);return{patch:e.createPatch.materialAssetCreate?.(n)??{kind:"scene.material-asset.create",materialAsset:n},label:`Duplicate material ${r.name??r.id}`,changedIds:[],createdId:n.id,presentationImpact:{inspector:["material"],materials:{assetIds:[n.id]}}}}function UC(e,t){let r=sS(t.document,t.materialAssetId);return r.ok?{patch:e.createPatch.materialAssetDelete?.(t.materialAssetId)??{kind:"scene.material-asset.delete",materialAssetId:t.materialAssetId},label:`Delete material ${r.materialAsset.name??r.materialAsset.id}`,changedIds:[],presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}:null}function KC(e,t){let r=ee(t.document,t.materialAssetId),n=nt("name",t.name);return!r||iu(r)||typeof n!="string"||!Bt("name",n)?null:{patch:e.createPatch.materialAssetField(t.materialAssetId,"name",n),label:`Rename material ${r.name} to ${n}`,changedIds:ma(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function HC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||iu(r))return null;let n=SS(r,t.definition),o=ma(t.document,t.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(t.materialAssetId,n.materialAsset)??{kind:"scene.material-asset.replace",materialAssetId:t.materialAssetId,materialAsset:n.materialAsset},label:`Set material ${r.name} shader to ${t.definition.displayName}`,changedIds:o,reprojectIds:o,presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}},preservedPaths:n.preservedPaths,resetPaths:n.resetPaths}}function WC(e,t,r){if(r.changes.length===0)return null;let n=ee(r.document,r.materialAssetId);if(!n)return null;let o=new Set,a=r.document;for(let c of r.changes){if(!c.path.startsWith("properties.")||o.has(c.path))return null;if(o.add(c.path),c.inheritTexture){if(!ao(n.shaderId,c.path))return null;a=Vs(a,r.materialAssetId,c.path,null,e.materialShaderDefinitions,{textureMode:"inherit"});continue}let d=`scene.materialAssets.${r.materialAssetId}.${c.path}`,l=Ao({document:a,targetId:r.materialAssetId,path:d,value:c.value},t)?.patch;if(!l||l.kind!=="scene.material-asset.field"||l.materialAssetId!==r.materialAssetId||l.path!==c.path)return null;a=Vs(a,r.materialAssetId,c.path,l.value,e.materialShaderDefinitions)}let i=ee(a,r.materialAssetId);if(!i)return null;let s=ma(r.document,r.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(r.materialAssetId,i)??{kind:"scene.material-asset.replace",materialAssetId:r.materialAssetId,materialAsset:i},label:`Patch material ${r.materialAssetId} properties`,changedIds:s,reprojectIds:s}}function qC(e){let t=r=>n=>{let o=r(n);if(!e)return o;let a=structuredClone(o),i=structuredClone(n),s=e(a,i)??a;return JSON.stringify(s)===JSON.stringify(n)?n:s};return{environmentLightId:"environment_light",sunLightId:"sun_light",horizontalLightAnglePath:"light.directionHorizontalAngleDeg",elevationLightAnglePath:"light.directionElevationAngleDeg",normalizeEnvironmentLightGameObject:r=>t(n=>Pu(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>Pu(n,"directional"))(r),normalizeCameraGameObject:t(XS),normalizePlainTransformGameObject:t(YS),createDefaultCameraGameObject:ry,createDefaultEnvironmentLightGameObject:oy,createDefaultSunLightGameObject:ny,mergeCameraDefaults:Ua,normalizeCameraAfterFieldPatch:ZS,hasInvalidCameraRelationships:ey,mergeLightDefaults:vn}}function JC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:Da,syncMarkerGraphDocument:t.syncMarkerGraphDocument,ensureGameObjectGuids:jl,normalizeDocumentAfterCommand:(i,s)=>a?.normalizeDocumentAfterCommand?.(i,s)??i,patchMaterialAssetField:(i,s,c,d)=>Vs(i,s,c,d,e.materialShaderDefinitions),replaceMaterialAsset:(i,s,c)=>nS(i,s,c),addMaterialAsset:(i,s)=>Us(i,s),deleteMaterialAsset:(i,s)=>cS(i,s),addMaterialAssetAndBind:(i,s,c,d)=>dS(i,s,c,d),addPrefabAsset:(i,s,c)=>Ch(i,s,c),patchPrefabAssetField:(i,s,c,d)=>mm(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>vh(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>jh(i,s,c,d),patchGameObjectField:n,patchGameObjectsField:o,reduceExtensionPatch:({document:i,patch:s,command:c})=>s.kind==="game-object.property-field-batch"&&Array.isArray(s.fields)?s.fields.reduce((d,u)=>o(d,[u.targetId],u.path,u.value),i):a?.reducePatch?.({document:i,patch:s,command:c})??null,isCustomFieldPatchPath:a?.isInspectorPatchPath,reduceMarkerGraphPatch:(i,s)=>t.reduceMarkerGraphPatch(i,s),isDirectionalLightAnglePath:fo,validateSerializedPropertyField:i=>r.validateField(i.document,i.gameObject,i.path,i.value),createGameObjectGuid:he,createUniqueId:ct,resolveLocalTransform:({document:i,parentId:s,worldTransform:c})=>fr(i,s??void 0,c),resolveRootContainerId:ye,ensureDefaultMaterialAssets:Zb,normalizeMaterialBindings:fS}}function XC(e,t,r,n,o,a,i){return{fieldMutationOptions:ac(r),findGameObject:n,normalizeValue:o,validateValue:a,blockFieldPatch:(s,c,d,u)=>ic(s,c,d,u,r),isRootTransformPath:js,parseDuplicateMaterialAssetValue:cs,isMaterialBindingPath:Cr,isMaterialBindingPathAllowed:(s,c)=>Cr(c)&&(!!e.resolveFieldSchema?.(c,di(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Vp,normalizeMaterialAssetValue:nt,hasMaterialAsset:Ut,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return Bt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:ma,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGeometryUpdateCommand:t.createMarkerGeometryUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:fo,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>Fu(s,c,d,u,r),createCustomInspectorPropertyPatch:({document:s,gameObject:c,path:d,value:u})=>i?.createInspectorPropertyPatch?.({document:s,gameObject:c,path:d,value:u,collectChangedIds:()=>br(s,[c.id])})??null,patchCustomGameObjectField:i?.patchGameObjectField,patchCustomGameObjectsField:i?.patchGameObjectsField,normalizeAfterFieldPatch:(s,c,d,u)=>i?.normalizeAfterFieldPatch?.(s,c,d,u)??s,isProjectionShapePath:rv,isArtistMaterialPatchPath:ss,isCustomProjectionPath:i?.isProjectionPath,collectChangedIdsForFieldPath:(s,c,d)=>d.startsWith("transform.")?br(s,[c]):[c],createGameObjectFieldPatch:e.createPatch.gameObjectField,createMaterialAssetFieldPatch:e.createPatch.materialAssetField}}function YC(e){return Gu({findGameObject:(t,r)=>r?$(t,r):null,resolveRootContainerId:ye,isProtectedSystemGameObject:Mt,isProtectedSystemGameObjectId:Cl,decorateHierarchyItem:({item:t,gameObject:r})=>r&&de(r)?{...t,role:"marker",icon:"view-overlay",canHaveChildren:!1}:t})}function PE(e,t){return{materialShaderDefinitions:e,...t}}function ZC(e,t,r,n,o,a,i,s,c,d){let u=BS(n,o,a);if(u)return u;let l=uu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||Hu({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:di,isMarkerGameObject:de,createInspectorSections:(m,f,g)=>{let b=di(f);return qu({document:m,gameObject:f,context:g,nodeKind:b,isCameraGameObject:Dt,isLightGameObject:go,isMarkerGameObject:de,createBaseSections:()=>Bl({document:m,gameObject:f,nodeKind:b,extraValidators:c(),rootTransform:zr,renderingProfile:t.getRenderingProfile(),transformTypeOptions:DE(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:b,context:g,createDocumentInspectorProperty:i})??[],createCameraSection:()=>kl({nodeKind:b,camera:f.camera,rig:Ua(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>ql({nodeKind:b,gameObject:f,light:vn(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(S,y)=>d?.normalizeInspectorValue?.(S,y)??mr(S,y),defaultEnvironmentGroundColor:Cn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?Qu({document:m,gameObject:f,nodeKind:b,markerTypeCatalog:r.getMarkerTypeCatalog(m),resolveMarkerKind:(S,y)=>r.resolveMarkerKind(m,y.type,y.kind),isMarkerGameObject:de,formatMarkerTypeLabel:t.formatMarkerTypeLabel??((S,y)=>y),createDocumentInspectorProperty:i}):null,createPrefabInstanceSection:()=>Yh(m,f),createMaterialSections:()=>uu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,b,g,{createDocumentInspectorProperty:i}),createOutlineSection:()=>Ju({nodeKind:b,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function QC(e,t,r,n,o,a){let i=null,s=[];for(let c of o){let d=c.createMultiInspectorSection?.({document:e,targetIds:t,activeId:r,context:n})??null;if(d){i=d,s=c.resolveMultiInspectorTargetIds?.(e,t)??[];break}}return Wu({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function ev(e,t,r){return e?r==null&&e.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${t}.`}:e.validate(r)?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${t}.`}:null}function tv(e,t){return Rr(t,{builtInMarkerTypes:e})}var di=Y;function rv(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function nv(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function ov(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function av(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function AE(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return["documentReducerImmutability","transformTypeOptions","normalizeInspectorValue","validateInspectorField","isInspectorPatchPath","isProjectionPath","normalizeDocumentAfterCommand","normalizeAfterFieldPatch","fieldMutation","createInspectorPropertyPatch","patchGameObjectField","patchGameObjectsField","reducePatch","createHierarchyPatch","createInspectorSections","createMultiInspectorSection","resolveMultiInspectorTargetIds","isSerializedMultiFieldPath","isSerializedMultiProjectionPath","getSerializedMultiProbeValue","canPatchSerializedMultiField"].some(n=>t[n]!=null)?t:null}function Mm(e){let{documentReducerImmutability:t,...r}=e;return r}function iv(e){if(e.length===0)return;let t=r=>{for(let n of e){let o=r(n);if(o!=null)return o}return null};return{documentReducerImmutability:e.every(r=>r.documentReducerImmutability==="preserves-input")?"preserves-input":void 0,transformTypeOptions:DE(e.flatMap(r=>r.transformTypeOptions??[])).slice(wa.length),normalizeInspectorValue(r,n){for(let o of e){let a=o.normalizeInspectorValue?.(r,n);if(a!==void 0)return a}},validateInspectorField:r=>t(n=>n.validateInspectorField?.(r)),isInspectorPatchPath:r=>e.some(n=>n.isInspectorPatchPath?.(r)),isProjectionPath:r=>e.some(n=>n.isProjectionPath?.(r)),normalizeDocumentAfterCommand:(r,n)=>e.reduce((o,a)=>a.normalizeDocumentAfterCommand?.(o,n)??o,r),normalizeAfterFieldPatch:(r,n,o,a)=>e.reduce((i,s)=>s.normalizeAfterFieldPatch?.(i,n,o,a)??i,r),fieldMutation:sv(e),createInspectorPropertyPatch:r=>t(n=>n.createInspectorPropertyPatch?.(r)),patchGameObjectField:r=>t(n=>n.patchGameObjectField?.(r)),patchGameObjectsField:r=>t(n=>n.patchGameObjectsField?.(r)),reducePatch:r=>t(n=>n.reducePatch?.(r)),createHierarchyPatch:(r,n)=>t(o=>o.createHierarchyPatch?.(r,n)),createInspectorSections:r=>e.flatMap(n=>n.createInspectorSections?.(r)??[]),isSerializedMultiFieldPath:r=>e.some(n=>n.isSerializedMultiFieldPath?.(r)),isSerializedMultiProjectionPath:r=>e.some(n=>n.isSerializedMultiProjectionPath?.(r)),getSerializedMultiProbeValue(r){for(let n of e){let o=n.getSerializedMultiProbeValue?.(r);if(o!==void 0)return o}},canPatchSerializedMultiField:r=>e.every(n=>n.canPatchSerializedMultiField?.(r)!==!1)}}function DE(e=[]){let t=[],r=new Set;for(let n of[...wa,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function sv(e){let t=e.flatMap(r=>r.fieldMutation?[r.fieldMutation]:[]);if(t.length!==0)return{isCustomTransformType:r=>t.some(n=>n.isCustomTransformType?.(r)),applyCustomTransformType(r,n){for(let o of t)o.clearCustomTransformState?.(r,n);for(let o of t)o.applyCustomTransformType?.(r,n)},clearCustomTransformState(r,n){for(let o of t)o.clearCustomTransformState?.(r,n)},patchCustomTransformField(r,n,o){for(let a of t)if(a.patchCustomTransformField?.(r,n,o))return!0;return!1}}}var wm=["model","texture","image","sound"],Wc=[".glb",".gltf"],km=[".png",".jpg",".jpeg",".webp"],ME=[".env",".hdr",".dds",".ktx",".ktx2"],qc=[...km,...ME],Jc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],No=[...Wc,...qc,...Jc];function wE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Xc(e,t){let r=wE(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function Yc(e){let o=String(e??"").trim().split(/[^a-zA-Z0-9_$]+/).filter(Boolean).map((a,i)=>i===0?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join("").replace(/[^a-zA-Z0-9_$]/g,"")||"assetUrl";return/^[a-zA-Z_$]/.test(o)?o:`asset${o}`}function Zc(e,t=""){let 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";let n=kE(t);return Wc.includes(n)?"model":Jc.includes(n)?"sound":qc.includes(n)?"texture":null}function kE(e){let t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.slice(r+1),o=n.lastIndexOf(".");return o>=0?n.slice(o).toLowerCase():""}function Om(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...No].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function Rm(e,t){return String(e??"").trim()||Om(t)||"Asset"}function Cm(e,t){return Om(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function vm(e){return e==="model"?Wc:e==="sound"?Jc:e==="texture"?qc:e==="image"?km:[]}function jm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=Gm(t.x),n=Gm(t.y),o=Gm(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function Gm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Nm(e){return e==="shared"||e==="instance"?e:void 0}function Fm(e){return Number.isInteger(e)&&e>=0?e:void 0}var OE="rendering",Fn=Jf;function Wr(e){let t=ce(e);return cv(t?.companionConfigs)}function $m(e){return Wr(e)[OE]??null}function RE(e){return wr(Wr(e)[Fn])}function cv(e){if(e==null)return{};let t=dv(e,"$.companionConfigs"),r={};for(let[n,o]of Object.entries(t)){if(!n||n!==n.trim())throw _m("schema.invalidValue","$.companionConfigs");let a=n;if(o===null){r[a]=null;continue}let i=ce(o);if(!i)throw _m("schema.invalidType",`$.companionConfigs.${a}`);a===OE&&St(i),a===Fn&&Yn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function dv(e,t){let r=ce(e);if(!r)throw _m("schema.invalidType",t);return r}function _m(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}var lv=Object.freeze({bash:"shell",cjs:"javascript",conf:"config",config:"config",css:"css",env:"dotenv",frag:"glsl",fs:"glsl",glsl:"glsl",htm:"html",html:"html",ini:"config",js:"javascript",json:"json",jsonc:"jsonc",jsx:"javascript",less:"less",md:"markdown",mjs:"javascript",scss:"scss",shader:"glsl",sh:"shell",toml:"toml",ts:"typescript",tsx:"typescript",txt:"text",vert:"glsl",vs:"glsl",wgsl:"wgsl",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"shell"}),uv=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),mv=Object.freeze({png:{kind:"image",mimeType:"image/png"},jpg:{kind:"image",mimeType:"image/jpeg"},jpeg:{kind:"image",mimeType:"image/jpeg"},webp:{kind:"image",mimeType:"image/webp"},gif:{kind:"image",mimeType:"image/gif"},bmp:{kind:"image",mimeType:"image/bmp"},glb:{kind:"model",mimeType:"model/gltf-binary"},mp3:{kind:"audio",mimeType:"audio/mpeg"},wav:{kind:"audio",mimeType:"audio/wav"},ogg:{kind:"audio",mimeType:"audio/ogg"},m4a:{kind:"audio",mimeType:"audio/mp4"},aac:{kind:"audio",mimeType:"audio/aac"},flac:{kind:"audio",mimeType:"audio/flac"}});function Qc(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"",n=r.lastIndexOf(".");return n>0?r.slice(n+1):""}function Lm(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return uv[r]??lv[Qc(r)]??null}function CE(e){return Lm(e)!==null}function zm(e){return mv[Qc(e)]??null}var fv="fps.plugin.ground-decal",vE="@fps-games/plugin-ground-decal";function GE(e){bv(e);let t=e.plugins.find(i=>i.pluginId===fv),r=t?gv(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:pv(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:Sv(e.metadata),project:Object.freeze({projectId:e.projectId,projectName:e.projectName,source:Object.freeze({editorScene:o.document,runtimeScene:o.runtimeArtifact,...o.rendering?{rendering:o.rendering}:{},...o.shadows?{shadows:o.shadows}:{}}),assets:Object.freeze({...a}),features:Object.freeze(n),...e.metadata&&Ce(e.metadata)?{metadata:Object.freeze({...e.metadata})}:{}})})}function pv(e){let t=new Map(e.kinds.map(l=>[l.id,l])),r=new Set(e.editableLayerRoles??[]),n=new Set(e.layoutEditableLayerRoles??[]),o=new Set(e.rotationEditableLayerRoles??[]),a=new Set(e.stretchedImageRoles??[]),i=new Set(e.activePreviewKinds??[]),s=l=>t.has(l),c=l=>{let m=t.get(l)??t.get(e.defaultUiKind);if(!m)throw new Error(`Ground Decal kind is not configured: ${l}`);return structuredClone(m.defaultConfig)},d=l=>yv(l,t),u={defaultUiKind:e.defaultUiKind,isKnownUiKind:s,isProjectEditableLayer:l=>r.size===0||r.has(l.role),isLayoutEditableLayer:l=>n.has(l.role),isRotationEditableLayer:l=>o.has(l.role),createDefaultGroundDecal:c,isGroundDecalConfig:d};return{uiKinds:Object.freeze([...t.keys()]),documentPolicy:u,inspectorPolicy:{...u,isEditableTextureLayer:l=>(l.kind==="texture"||l.kind==="textureProgress")&&(r.size===0||r.has(l.role)),isEditableColorLayer:l=>(l.kind==="color"||l.kind==="progress")&&(r.size===0||r.has(l.role)),isEditableTextLayer:l=>l.kind==="text"&&(r.size===0||r.has(l.role)),useUniformLayoutScaleMode:l=>n.has(l.role),resolveImageFit:l=>"imageFit"in l&&(l.imageFit==="stretch"||l.imageFit==="contain")?l.imageFit:a.has(l.role)?"stretch":"contain",createLayerLabel:l=>hv(l.role),createUiKindLabel:l=>t.get(l)?.label??l,canShowActivePreview:l=>i.has(l.uiKind),getLayerPreviewVisibility:(l,m)=>i.has(m.uiKind)&&l.role==="activeBackground"?{path:"groundDecal.editorPreviewActive",value:m.editorPreviewActive===!0}:null},createHierarchyLabel:l=>t.get(l)?.hierarchyLabel??`${t.get(l)?.label??l} Ground Decal UI`}}function gv(e){if(e.packageName!==vE)throw new Error(`Ground Decal Plugin package must be ${vE}.`);if(!e.targets.includes("editor"))throw new Error("Ground Decal Plugin must target editor.");let t=e.config;if(!Ce(t)||t.schemaVersion!==1)throw new Error("Ground Decal Plugin config schemaVersion must be 1.");if(typeof t.defaultUiKind!="string"||!Array.isArray(t.kinds)||t.kinds.length===0)throw new Error("Ground Decal Plugin config must define defaultUiKind and kinds.");let r=new Set;for(let n of t.kinds){if(!Ce(n)||typeof n.id!="string"||typeof n.label!="string"||!Ce(n.defaultConfig))throw new Error("Ground Decal Plugin kinds must contain id, label, and defaultConfig.");if(r.has(n.id))throw new Error(`Duplicate Ground Decal kind: ${n.id}`);if(r.add(n.id),n.defaultConfig.uiKind!==n.id)throw new Error(`Ground Decal defaultConfig.uiKind must match kind id: ${n.id}`)}if(!r.has(t.defaultUiKind))throw new Error(`Ground Decal defaultUiKind is not declared: ${t.defaultUiKind}`);for(let n of["editableLayerRoles","layoutEditableLayerRoles","rotationEditableLayerRoles","stretchedImageRoles","activePreviewKinds"]){let o=t[n];if(o!==void 0&&(!Array.isArray(o)||o.some(a=>typeof a!="string")))throw new Error(`Ground Decal Plugin config.${n} must be an array of strings.`)}return t}function bv(e){if(!Ce(e)||e.schemaVersion!==1)throw new Error("Editor Project definition schemaVersion must be 1.");if(typeof e.projectId!="string"||typeof e.projectName!="string")throw new Error("Editor Project identity is invalid.");if(!Ce(e.authoring)||!Ce(e.authoring.source)||!Ce(e.authoring.assets)||!Array.isArray(e.plugins))throw new Error("Editor Project authoring or Plugin configuration is invalid.")}function Sv(e){return Ce(e)?Object.freeze({...Array.isArray(e.markerTypes)?{markerTypes:Object.freeze(e.markerTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{},...Array.isArray(e.relationTypes)?{relationTypes:Object.freeze(e.relationTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{}}):Object.freeze({})}function yv(e,t){if(!Ce(e)||typeof e.uiKind!="string"||!t.has(e.uiKind)||!Ce(e.size)||!ed(e.size.width)||!ed(e.size.depth)||!Array.isArray(e.layers))return!1;let r=new Set;for(let n of e.layers){if(!Ce(n)||typeof n.id!="string"||!n.id||typeof n.role!="string"||!n.role||typeof n.kind!="string"||!Ce(n.rect)||!Number.isFinite(n.rect.x)||!Number.isFinite(n.rect.z)||!ed(n.rect.width)||!ed(n.rect.depth)||r.has(n.id))return!1;r.add(n.id)}return!0}function ed(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function hv(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var Ev=["/__fps_editor_authoring"],Iv=[["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"],["asset-import","/asset-import"],["save-editor-scene","/save-editor-scene"]];function jE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??Ev,o=Pv(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=Tv(a);return i?{route:a,routeName:i,prefix:o}:null}function Pv(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function Tv(e){return Iv.find(([,t])=>e===t)?.[0]??null}function Pe(e,t){return{statusCode:e,body:t}}function td(e){return{statusCode:e,body:null}}async function NE(e,t){let r=jE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return td(204);try{if(xv(r.routeName)){if(n!=="GET")return Pe(405,{ok:!1,error:"method_not_allowed"});if(r.routeName==="project-file"){let a=new URL(e.url??"","http://localhost").searchParams.get("path")?.trim()??"";if(!a)return Pe(400,{ok:!1,error:"missing_file_path"});let i=await t.loadProjectFile?.({path:a,route:r});return Pe(200,i??{ok:!1,error:"not_found"})}return Pe(200,await Av(r,t))}if(n!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let o=e.body??await t.readBody?.(e,r)??{};return await Dv(r,o,t)}catch(o){let a=typeof o?.code=="string"?o.code:"authoring_request_failed",i=a==="asset_import_payload_too_large"?413:r.routeName==="save-editor-scene"&&a==="authoring_source_revision_mismatch"?200:r.routeName==="asset-import"?400:500;return Pe(i,{ok:!1,error:o instanceof Error?o.message:String(o),code:a,details:ce(o?.details)})}}function xv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function Av(e,t){return e.routeName==="manifest"&&t.loadManifest?t.loadManifest(e):e.routeName==="editor-scene"&&t.loadEditorScene?t.loadEditorScene(e):e.routeName==="editor-asset-library"&&t.loadEditorAssetLibrary?t.loadEditorAssetLibrary(e):e.routeName==="project-files"&&t.loadProjectFiles?t.loadProjectFiles(e):{ok:!1,error:"not_found"}}async function Dv(e,t,r){if(e.routeName==="asset-import"){let n=Eh(t),o=await r.importAsset?.({payload:n,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}return e.routeName==="save-editor-scene"?Mv(e,t,r):e.routeName==="commit"?Pe(410,await wv(e,t,r)):Pe(404,{ok:!1,error:"not_found"})}async function Mv(e,t,r){let n=t.mode==="prepare-platform-save"?"prepare-platform-save":"local-commit-save",o=await r.saveEditorScene?.({body:t,mode:n,rawEditorScene:t.editorScene,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}async function wv(e,t,r){return r.commit?.({body:t,route:e})??{ok:!1,error:"platform_commit_route_disabled",message:"Save through /__fps_editor_authoring/save-editor-scene so scene.main remains the authoring source of truth."}}function _E(e,t,r={}){let n=wh(e).document,o=t;Object.prototype.hasOwnProperty.call(o,"staticShadows")&&o.staticShadows!=null&&Yn(o.staticShadows,"$.staticShadows");let{scene:a,...i}=t,s=structuredClone(i),c=Ke(a)?a:void 0,d=qt(n),u={...d,compilerId:Dh,compilerVersion:Mh,compiledAt:new Date().toISOString()};s.schemaVersion=3,s.meta={...s.meta??{},generatedFrom:u};let l=c?.rootId||"root",m=n.scene.gameObjects.filter(I=>I.id!==l),f=vv(n,r.materialShaderDefinitions,!0),g={...n,scene:{...n.scene,materialAssets:f}},b=m.flatMap(I=>Uv(I,d,g,r)),S=b.map($E);Ov(l,S),Rv(l,S);let y={rootId:l,assets:g.assets.filter(Nv).map(Fv),nodes:S,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=Hv(s.plugins,r.shadowMapExperimentConfig,b,l,d.revision),Ui(s),{sceneConfig:s,summary:{assetCount:y.assets.length,gameObjectCount:n.scene.gameObjects.length,nodeCount:y.nodes.length}}}function $E(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function Ov(e,t){let r=new Set([e]);for(let n=0;n<t.length;n+=1){let o=t[n].id;if(r.has(o)){let a=new Error(`schema.invalidReference: $.scene.nodes[${n}].id`);throw Object.assign(a,{code:"schema.invalidReference",path:`$.scene.nodes[${n}].id`,nodeId:o}),a}r.add(o)}}function Rv(e,t){let r=new Map(t.map(n=>[n.id,n]));for(let n=0;n<t.length;n+=1){let o=t[n];if(!(o.source?.component!=="PrefabMarker"||!("marker"in o)||!o.marker))for(let a of Cv(o.marker)){let i=r.get(a.target.id);if(a.target.id!==e&&(!i||i.source?.objectId===o.source.objectId))continue;let s=`$.scene.nodes[${n}].marker.${a.path}.id`,c=new Error(`schema.invalidReference: ${s}`);throw Object.assign(c,{code:"schema.invalidReference",path:s,nodeId:o.id,targetId:a.target.id}),c}}}function Cv(e){let t=[];return e.target&&t.push({path:"target",target:e.target}),e.geometry.kind==="point"&&e.geometry.target&&t.push({path:"geometry.target",target:e.geometry.target}),e.geometry.kind==="object-bounds"&&t.push({path:"geometry.target",target:e.geometry.target}),t}function vv(e,t,r=!1){let n=structuredClone(e.scene.materialAssets??[]);for(let a=0;a<n.length;a+=1){let i=n[a];if(De(i.shaderId))continue;let s=t?.get(i.shaderId);if(!s){if(!r)continue;throw Bm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Bm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=no(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Bm("material.propertiesInvalid",c[0].path,c[0].message)}let o=us(Gv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Bm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function Gv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=WE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),...jv(r)]}}}function jv(e){let t=[];for(let r of e.scene.gameObjects){let n=fn(e,r);!n.definition||!rd(n.definition)||t.push(...LE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function LE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=KE(Qe(e.prefabAsset),Ze(e.prefabAsset)??""),r=t.find(a=>a.id===Ze(e.prefabAsset));if(!r)return e.visitedPrefabIds.delete(e.prefabAsset.id),[];let n=HE(t,e.prefabAsset),o=[];for(let a of t){if(a.kind==="prefabInstance"&&a.childPrefabId){let d=e.editorDocument.assets.find(u=>u.id===a.childPrefabId);if(d&&rd(d)){o.push(...LE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=rG(e.hostGameObject,a);if(!i)continue;let s=a.kind==="model"&&a.sourceAssetId?e.editorDocument.assets.find(d=>d.id===a.sourceAssetId):void 0,c=Wm({hostGameObject:i,prefabAsset:e.prefabAsset,rootNode:r,node:a,asset:s,editorDocument:e.editorDocument,instanceOverrides:a.id===n?e.instanceOverrides:void 0});c&&o.push({...i,overrides:c})}return e.visitedPrefabIds.delete(e.prefabAsset.id),o}function Nv(e){return e.type==="glb"||e.type==="texture"}function Fv(e){let t=Lv(e),r=e.type==="glb"?zv(e):[],n=$v(e.external),o=_v(e.defaults);return{id:e.id,type:e.type,...e.guid?{guid:e.guid}:{},...t?{url:t}:{},...typeof e.warmupCount=="number"&&Number.isInteger(e.warmupCount)&&e.warmupCount>=0?{warmupCount:e.warmupCount}:{},...typeof e.singleton=="boolean"?{singleton:e.singleton}:{},...typeof e.materialMode=="string"?{materialMode:e.materialMode}:{},...o!==void 0?{defaults:o}:{},...n?{external:n}:{},...r.length>0?{materialSlots:r}:{}}}function _v(e){if(!e)return;let t=structuredClone(e);return Ke(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function $v(e){let t=Ke(e)?e:void 0,r=Ir(t?.platformAssetId),n=Ir(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Lv(e){let t=Ke(e.metadata)?e.metadata:void 0,r=Ke(e.external)?e.external:void 0;return Ir(t?.url)??Ir(r?.assetUrl)??void 0}function zv(e){let t=Ke(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Bv(t?.assetAnalysis);return r.flatMap(o=>{if(!Ke(o))return[];let a=Ir(o.slotId);if(!a)return[];let i=Ir(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ke(c))return[];let d=Ir(c.ownerNodePath),u=li(c.meshIndex),l=li(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=li(c.nodeIndex),f=Vv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),g=li(c.sourceMaterialIndex),b=Ir(c.sourceMeshName)??n.get(u);return[{ownerNodePath:d,...m==null?{}:{nodeIndex:m},...f.length>0?{nodeIndexPath:f}:{},meshIndex:u,primitiveIndex:l,...g==null?{}:{sourceMaterialIndex:g},...b?{sourceMeshName:b}:{}}]});return s.length===0?[]:[{slotId:a,...i?{label:i}:{},sourceSurfaces:s}]})}function Bv(e){let t=Ke(e)?e:void 0,r=Array.isArray(t?.meshes)?t.meshes:[];return new Map(r.flatMap(n=>{if(!Ke(n))return[];let o=li(n.meshIndex),a=Ir(n.name);return o==null||!a?[]:[[o,a]]}))}function Vv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function li(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function Uv(e,t,r,n){let o=fn(r,e);return(o.definition&&rd(o.definition)?qv(e,o.definition,t,r,new Set,n):[Kv(e,t,r,n)]).map(i=>{let s=i.kind==="instance"?r.assets.find(d=>d.id===i.instance.assetId):void 0,c=n.inferShadowMapExperimentUpdateClass?.({gameObject:e,runtimeNode:$E(i),...s?{asset:s}:{}})??Wv(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function Kv(e,t,r,n={}){let o=G(e),a=Se(e),i=jr(e),s=oG(e),c=Y(e),d=WE(e,r),u=pg(e),l={sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision,...e.guid?{objectGuid:e.guid}:{},objectId:e.id,component:a?"ModelRenderer":i?"ImageRenderer":s||c==="primitive"?"PrimitiveRenderer":c==="transform"?"Transform":"GameObject"},m={id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Yv(r,e,n),...u?{rendering:u}:{},source:l,...o&&"position"in o?{transform:{position:o.position,rotation:o.rotation,...o.scale?{scale:o.scale}:{}}}:{}};if(c==="primitive")return{...m,kind:"primitive",primitive:{shape:s?.shape??"cube"},...d?{overrides:d}:{}};if(i)return{...m,kind:"image",image:{assetId:i.assetId,size:{width:i.size.width,height:i.size.height}},...d?{overrides:d}:{}};if(!a){if(c==="transform"){let f=Xv(e,n),g=f.transformType;delete f.transformType;let b=FE(g)??FE(e.transformType);return{...m,kind:"transform",...b?{transformType:b}:{},...e.camera?{camera:sG(e.camera)}:{},...e.light?{light:qE(e.light)}:{},...e.marker?{marker:{label:e.name||e.id,...structuredClone(e.marker)}}:{},...f,...d?{overrides:d}:{}}}return{...m,kind:"group"}}return{...m,kind:"instance",instance:{assetId:a.assetId},...d?{overrides:d}:{}}}function Hv(e,t,r,n,o){let a=(e??[]).filter(u=>u.pluginId!==Ed);if(!t)return a;let i=r.find(u=>u.id===t.lightRef),s=i?.kind==="transform"&&i.light?.type==="directional"?i:void 0;if(!i&&t.enabled)throw new Error(`shadowMapExperiment.lightMissing:${t.lightRef}`);if(i&&!s&&t.enabled)throw new Error(`shadowMapExperiment.lightUnsupported:${t.lightRef}`);let c=s?.kind==="transform"&&s.light?.type==="directional"?[s.light.direction.x,s.light.direction.y,s.light.direction.z]:[0,-1,0],d=Of({revision:typeof o=="number"&&Number.isInteger(o)&&o>=0?o:0,scopeId:n,config:t,lightDirection:c,objects:r.filter(u=>u.kind==="instance"||u.kind==="primitive").map(u=>({entityId:u.id,renderableIds:[u.id],cast:u.shadow?.cast==="enabled",receive:u.shadow?.receive==="enabled",inferredUpdateClass:u.shadowMapExperimentInferredUpdateClass??"static"}))});return[...a,{pluginId:Ed,schemaVersion:3,data:d}]}function Wv(e){let t=Ke(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=Vm(t.skinCount),n=Vm(t.morphTargetCount);return r>0||n>0?"skinned":Vm(t.animationCount)>0?"dynamic":"static"}function Vm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function qv(e,t,r,n,o,a){return zE({prefabAsset:t,sourceRef:r,editorDocument:n,hostGameObject:e,rootRuntimeId:e.id,rootParentId:e.parentId,rootName:e.name??t.displayName??t.id,rootTransform:G(e)??void 0,rootActive:e.active,instanceOverrides:e.overrides,propertyPathPrefix:`assets.${t.id}.prefab.nodes`,visitedPrefabIds:o,compilerOptions:a})}function zE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Um({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"PrefabCycle",propertyPath:e.propertyPathPrefix})];e.visitedPrefabIds.add(e.prefabAsset.id);let t=Qe(e.prefabAsset),r=Ze(e.prefabAsset),n=r?t.find(d=>d.id===r):null;if(!n||t.length===0)return e.visitedPrefabIds.delete(e.prefabAsset.id),[Um({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"Prefab",propertyPath:e.propertyPathPrefix})];let o={instanceId:e.rootRuntimeId,rootNodeId:n.id},a=d=>so(o,d.id),i=KE(t,n.id),s=HE(i,e.prefabAsset),c=[];for(let d of i){let u=a(d),l=d.id===n.id?e.rootParentId:a(t.find(m=>m.id===d.parentId)??n);if(d.kind==="prefabInstance"&&d.childPrefabId){let m=e.editorDocument.assets.find(f=>f.id===d.childPrefabId);if(m&&rd(m)){let f=d.id===n.id;c.push(...zE({prefabAsset:m,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeId:u,rootParentId:l,rootName:f?e.rootName??d.name??m.displayName??m.id:d.name??m.displayName??m.id,rootTransform:f?e.rootTransform??d.transform:d.transform,rootActive:f?e.rootActive??d.defaults?.active??e.prefabAsset.prefab?.defaults?.active:d.defaults?.active,instanceOverrides:f?ui(ui(Zt(e.prefabAsset.prefab?.overrides),Zt(d.overrides)),Zt(e.instanceOverrides)):d.overrides,propertyPathPrefix:`${e.propertyPathPrefix}.${d.id}.childPrefab.nodes`,visitedPrefabIds:new Set(e.visitedPrefabIds),compilerOptions:e.compilerOptions}));continue}c.push(Um({id:u,name:d.name??d.childPrefabId??"Prefab Instance",parentId:l,transform:d.transform,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,component:"UnsupportedPrefabInstance",propertyPath:`${e.propertyPathPrefix}.${d.id}`}));continue}c.push(Jv({node:d,rootNode:n,identityScope:o,prefabAsset:e.prefabAsset,runtimeId:u,parentId:l,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeName:e.rootName,rootRuntimeTransform:e.rootTransform,rootRuntimeActive:e.rootActive,instanceOverrides:d.id===s?e.instanceOverrides:void 0,propertyPath:`${e.propertyPathPrefix}.${d.id}`,shadowFallbackMode:Hm(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),Qv({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:Hm(e.compilerOptions)})}function Jv(e){let t=e.node.id===e.rootNode.id,r=t?e.rootRuntimeTransform??e.node.transform:e.node.transform,n=e.node.kind==="model"&&e.node.sourceAssetId?e.editorDocument.assets.find(i=>i.id===e.node.sourceAssetId):void 0,o=e.node.kind==="model"||e.node.kind==="primitive",a=BE({id:e.runtimeId,name:t?e.rootRuntimeName??e.node.name??e.prefabAsset.displayName??e.prefabAsset.id:e.node.name,parentId:e.parentId,transform:r,active:t?e.rootRuntimeActive??e.node.defaults?.active??e.prefabAsset.prefab?.defaults?.active:e.node.defaults?.active,...o?{shadow:e.prefabAsset.prefab?.defaults?.shadow}:{},editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.node.kind==="model"?"PrefabModel":e.node.kind==="primitive"?"PrefabPrimitive":e.node.kind==="light"?"PrefabLight":e.node.kind==="marker"?"PrefabMarker":"PrefabNode",propertyPath:e.propertyPath});if(e.node.kind==="model"&&e.node.sourceAssetId){let i=Wm({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:n,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"instance",instance:{assetId:e.node.sourceAssetId},...i?{overrides:i}:{}}}if(e.node.kind==="primitive"){let i=Wm({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:void 0,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"primitive",primitive:{shape:e.node.primitive?.shape??"cube"},...i?{overrides:i}:{}}}return e.node.kind==="light"?{...a,kind:"transform",transformType:"light",...e.node.light?{light:qE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...ya(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Um(e){return{...BE({id:e.id,name:e.name,parentId:e.parentId,transform:e.transform,editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.component,propertyPath:e.propertyPath}),kind:"group"}}function Xv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function BE(e){return{id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Zv(e),source:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,revision:e.sourceRef.revision,...e.hostGameObject.guid?{objectGuid:e.hostGameObject.guid}:{},objectId:e.hostGameObject.id,component:e.component,propertyPath:e.propertyPath},...e.transform&&"position"in e.transform?{transform:{position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}}:{}}}function Yv(e,t,r){let n=Os({document:e,casterId:t.id,caster:t,fallbackMode:Hm(r)});return qm(n,!!t.shadow)?{shadowPlan:n}:{}}function Zv(e){if(!e.editorDocument)return{};let t=We(e.shadow),r=!!e.shadow||!!t.shadow;if(!r&&t.diagnostics.length===0)return{};let n=Os({document:e.editorDocument,casterId:e.hostGameObject.id,caster:e.hostGameObject,resolvedSettings:t.shadow,fallbackMode:e.shadowFallbackMode}),o={...n,casterId:e.id,diagnostics:[...t.diagnostics,...n.diagnostics].map(a=>({...a,casterId:a.casterId===e.hostGameObject.id||!a.casterId?e.id:a.casterId}))};return qm(o,r)?{shadowPlan:o}:{}}function qm(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function Qv(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>eG(i)),n={...e.editorDocument,scene:{...e.editorDocument.scene,gameObjects:[...e.editorDocument.scene.gameObjects.filter(i=>!t.has(i.id)),...r]}},o=e.compiledNodes.filter(i=>i.shadow?.receive==="enabled").map(i=>i.id),a=r.find(i=>i.light?.type==="directional"&&i.active!==!1)?.id;return e.compiledNodes.map((i,s)=>{let c=r[s],d=Os({document:n,casterId:i.id,caster:c,explicitReceiverIds:o,...a?{defaultLightId:a}:{},fallbackMode:e.shadowFallbackMode}),u=!!i.shadow;if(!qm(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function Hm(e){let t=Ne(e.renderingProfile).shadows,r=t.planar.enabled?"planar":t.blob.enabled?"blob":t.staticProjected.enabled?"static":t.enabled?"dynamic":"none";return r==="planar"?"projected":r}function eG(e){let t=[];return e.transform&&t.push({type:"Transform",position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}),e.kind==="instance"&&t.push({type:"ModelRenderer",assetId:e.instance.assetId}),e.kind==="image"&&t.push({type:"ImageRenderer",assetId:e.image.assetId,size:structuredClone(e.image.size)}),{id:e.id,...e.name?{name:e.name}:{},kind:e.kind==="image"?"transform":e.kind,...e.parentId?{parentId:e.parentId}:{},...e.enabled===!1?{active:!1}:{},...e.shadow?{shadow:{cast:e.shadow.cast==="enabled"?"enabled":"none",receive:e.shadow.receive==="enabled"?"enabled":"none"}}:{},...e.kind==="primitive"?{primitive:{shape:e.primitive.shape}}:{},...e.kind==="transform"&&e.transformType?{transformType:e.transformType}:{},...e.kind==="transform"&&e.light?{light:e.light}:{},...e.kind==="transform"&&e.camera?{camera:e.camera}:{},...e.kind==="transform"&&e.marker?{marker:structuredClone(e.marker)}:{},components:t}}function Wm(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?UE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=nG([Km(Zt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),Km(Zt(e.rootNode.overrides),e.rootNode.kind==="model"?e.rootNode.sourceAssetId:e.prefabAsset.prefab?.sourceAssetId,e.asset),e.node.id===e.rootNode.id?void 0:Km(Zt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Zt(e.instanceOverrides);return VE(ui(n,o),e.asset)}function Km(e,t,r){return VE(e,t&&t===r?.id?r:void 0)}function VE(e,t){if(!e?.materialSlotBindings)return e;let r=Ke(t?.metadata)&&Array.isArray(t.metadata.materialSlots)?t.metadata.materialSlots:[],n=new Set(r.flatMap(i=>{let s=Ke(i)&&typeof i.slotId=="string"?i.slotId.trim():"";return s?[s]:[]})),o=Object.fromEntries(Object.entries(e.materialSlotBindings).filter(([i])=>n.has(i))),a=structuredClone(e);return Object.keys(o).length>0?a.materialSlotBindings=o:delete a.materialSlotBindings,Object.keys(a).length>0?a:void 0}function UE(e,t,r){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"instance",components:[...t.transform?[t.transform]:[],{type:"ModelRenderer",assetId:r}]}}function tG(e,t){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"primitive",primitive:{shape:t.primitive?.shape??"cube"},components:[...t.transform?[t.transform]:[]]}}function rG(e,t){return t.kind==="model"&&t.sourceAssetId?UE(e,t,t.sourceAssetId):t.kind==="primitive"?tG(e,t):null}function nG(e){let t;for(let r of e){let n=Zt(r);n&&(t=ui(t,n))}return t}function KE(e,t){let r=new Map;for(let s of e){if(!s.parentId)continue;let c=r.get(s.parentId)??[];c.push(s),r.set(s.parentId,c)}let n=[],o=new Set,a=s=>{if(!o.has(s.id)){o.add(s.id),n.push(s);for(let c of r.get(s.id)??[])a(c)}},i=e.find(s=>s.id===t);i&&a(i);for(let s of e)a(s);return n}function HE(e,t){let r=t.prefab?.sourceAssetId;return e.find(n=>n.kind==="model"&&n.sourceAssetId===r)?.id??e.find(n=>n.kind==="model")?.id}function rd(e){return Ye(e)&&e.prefab.compositionVersion===ln&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ze(e)}function oG(e){return e.primitive??null}function WE(e,t){let r=Y(e);if(r!=="instance"&&r!=="transform"&&r!=="primitive")return;let n=Se(e),o=n?t.assets.find(a=>a.id===n.assetId):void 0;return aG(e,t,o)}function aG(e,t,r){let n=Zt(e.overrides),o=fn(t,e),a=Zt(o.definition?.prefab?.overrides);return ui(a,n)}function ui(e,t){let r=gs(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))iG(o)||a===void 0||(r??={},r[o]=structuredClone(a));return r&&Object.keys(r).length>0?r:void 0}function Zt(e){if(!Ke(e))return;let t=structuredClone(e);return Object.keys(t).length>0?t:void 0}function iG(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ke(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ir(e){return(typeof e=="string"?e.trim():"")||void 0}function FE(e){return typeof e=="string"?e:void 0}function sG(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function qE(e){return e.type==="directional"?Wn({schemaVersion:1,type:"directional",intensity:e.intensity,direction:ta(e.direction),diffuseColor:e.diffuseColor??Va.diffuseColor}):Wn({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??Cn.diffuseColor,groundColor:e.groundColor??Cn.groundColor})}var cG=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function YE(e){let t=Ki(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>dG(n,o)),rendering:{textureWidth:t.width,textureHeight:t.height}};return e.aspectSourceLayerId&&(r.aspectSourceLayerId=e.aspectSourceLayerId),typeof e.lockAspectToBorder=="boolean"&&(r.lockAspectToBorder=e.lockAspectToBorder),e.mask&&(r.mask={...typeof e.mask.enabled=="boolean"?{enabled:e.mask.enabled}:{},...e.mask.source==="roundedRect"||e.mask.source==="borderAlpha"||e.mask.source==="texture"?{source:e.mask.source}:{},...e.mask.textureId?{textureId:e.mask.textureId}:{},...typeof e.mask.cornerRadius=="number"&&Number.isFinite(e.mask.cornerRadius)?{cornerRadius:e.mask.cornerRadius}:{},...typeof e.mask.padding=="number"&&Number.isFinite(e.mask.padding)?{padding:e.mask.padding}:{}}),e.rendering&&(r.rendering={...r.rendering,...typeof e.rendering.alphaIndex=="number"&&Number.isFinite(e.rendering.alphaIndex)?{alphaIndex:e.rendering.alphaIndex}:{},...typeof e.rendering.diffuseTextureLevel=="number"&&Number.isFinite(e.rendering.diffuseTextureLevel)?{diffuseTextureLevel:e.rendering.diffuseTextureLevel}:{},...typeof e.rendering.emissiveTextureLevel=="number"&&Number.isFinite(e.rendering.emissiveTextureLevel)?{emissiveTextureLevel:e.rendering.emissiveTextureLevel}:{}}),r}function dG(e,t){let r=ko(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:lG(e.rect),...r!==0?{rotationDeg:r}:{},...typeof e.enabled=="boolean"?{enabled:e.enabled}:{},...typeof e.opacity=="number"&&Number.isFinite(e.opacity)?{opacity:e.opacity}:{}};return e.kind==="texture"?{...n,kind:"texture",...e.textureId?{textureId:e.textureId}:{},...e.tint?{tint:Fo(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:XE(e.value),...e.tint?{tint:Fo(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...JE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:Fo(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:XE(e.value??0),color:Fo(e.color),...JE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:Fo(e.text.color),...e.text.fontFamily?{fontFamily:e.text.fontFamily}:{},...typeof e.text.fontSize=="number"&&Number.isFinite(e.text.fontSize)?{fontSize:e.text.fontSize}:{},...e.text.fontWeight!=null?{fontWeight:String(e.text.fontWeight)}:{},...e.text.strokeColor?{strokeColor:Fo(e.text.strokeColor)}:{},...typeof e.text.strokeWidth=="number"&&Number.isFinite(e.text.strokeWidth)?{strokeWidth:e.text.strokeWidth}:{},...e.text.align==="left"||e.text.align==="center"||e.text.align==="right"?{align:e.text.align}:{},...e.text.baseline==="top"||e.text.baseline==="middle"||e.text.baseline==="bottom"?{baseline:e.text.baseline}:{}}}}function lG(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function Fo(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function JE(e){return typeof e=="string"&&cG.has(e)}function XE(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function ZE(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return td(204);try{if(r==="GET"){let c=pG(await t.loadConfig?.()),d=c.renderingConfig;St(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:fG(d),normalized:u,summary:Hn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=mi(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});St(o);let a=Ne(o),i=Hn(a),s=await t.saveConfig?.({body:n,renderingConfig:o,normalized:a,summary:i});return Pe(200,{ok:!0,...s??{},renderingConfig:o,normalized:a,summary:i})}catch(n){let o=uG(n),a=mG(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:mi(n?.details)})}}function uG(e){let t=e?.code;return typeof t=="string"&&t?t:null}function mG(e){let t=e?.path;return typeof t=="string"&&t?t:null}function mi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function fG(e){return mi(e)??{}}function pG(e){let t=mi(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:mi(t.response)??{}}:{renderingConfig:e??{},response:{}}}function QE(e,t={}){let r=t.generatedBy??"scripts/register-asset.mjs",n=t.codeKeyPolicy??"legacy",o=e.filter(d=>d.codeKey);if(n==="disabled"&&o.length>0){let d=o[0];throw Object.assign(new Error("manifest_code_key_disabled"),{name:"PlayableEditorAssetCatalogGenerationError",details:{codeKeyPolicy:n,assetId:d.assetId,codeKey:d.codeKey}})}let a=e.map(d=>`import ${Yc(d.assetId)} from ${JSON.stringify(`${d.relativePath}?url`)};`).join(`
8
+ `),i=e.map(d=>{let u=_i(d.relativePath);if(!u)throw new Error(`Generated asset catalog entry has no file extension: ${d.assetId}`);if(!Hf(u))throw new Error(`Generated asset catalog entry has unsupported format: ${d.assetId} (${u})`);let l=[`guid: ${JSON.stringify(d.guid)}`,`assetId: ${JSON.stringify(d.assetId)}`,`kind: ${JSON.stringify(d.kind)}`,`displayName: ${JSON.stringify(d.displayName)}`,`url: ${Yc(d.assetId)}`,`format: ${JSON.stringify(u)}`,`relativePath: ${JSON.stringify(d.relativePath)}`,d.originalFileName?`originalFileName: ${JSON.stringify(d.originalFileName)}`:"",d.codeKey?`codeKey: ${JSON.stringify(d.codeKey)}`:"",d.category?`category: ${JSON.stringify(d.category)}`:"",typeof d.placeable=="boolean"?`placeable: ${JSON.stringify(d.placeable)}`:"",typeof d.warmupCount=="number"?`warmupCount: ${JSON.stringify(d.warmupCount)}`:"",typeof d.singleton=="boolean"?`singleton: ${JSON.stringify(d.singleton)}`:"",d.materialMode?`materialMode: ${JSON.stringify(d.materialMode)}`:"",d.defaults?`defaults: ${JSON.stringify(d.defaults)}`:"",d.contentHash?`contentHash: ${JSON.stringify(d.contentHash)}`:"",typeof d.byteSize=="number"?`byteSize: ${JSON.stringify(d.byteSize)}`:"",d.external?`external: ${JSON.stringify(d.external)}`:"",d.metadata?`metadata: ${JSON.stringify(d.metadata)}`:"",d.createdAt?`createdAt: ${JSON.stringify(d.createdAt)}`:"",d.updatedAt?`updatedAt: ${JSON.stringify(d.updatedAt)}`:""].filter(Boolean).join(", ");return` ${JSON.stringify(d.assetId)}: { ${l} },`}).join(`
9
9
  `),s=new Map;for(let d of o)s.set(d.codeKey,d.assetId);let c=[...s].map(([d,u])=>` ${JSON.stringify(d)}: ${JSON.stringify(u)},`).join(`
10
10
  `);return[`// This file is generated by ${r}.`,"// Do not edit by hand.","",a,"",'export type GeneratedAssetCatalogKind = "model" | "texture" | "image" | "sound";',"","export interface GeneratedAssetCatalogEntry {"," guid: string;"," assetId: string;"," kind: GeneratedAssetCatalogKind;"," displayName: string;"," url: string;"," format: `.${string}`;"," relativePath: string;"," originalFileName?: string;",...n==="legacy"?[" /** @deprecated Use the canonical assetId for persisted and runtime identity. */"," codeKey?: string;"]:[]," category?: string;"," placeable?: boolean;"," warmupCount?: number;"," singleton?: boolean;"," materialMode?: string;"," defaults?: Record<string, unknown>;"," contentHash?: string;"," byteSize?: number;"," external?: { platformAssetId?: string; assetPath?: string; assetUrl?: string };"," metadata?: Record<string, unknown>;"," createdAt?: string;"," updatedAt?: string;","}","","export const GENERATED_ASSET_CATALOG: Record<string, GeneratedAssetCatalogEntry> = {",i,"};","","export const GENERATED_ASSET_URL_MAP = Object.fromEntries("," Object.entries(GENERATED_ASSET_CATALOG).map(([assetId, entry]) => [assetId, entry.url]),",") as Record<string, string>;","","export const GENERATED_MODEL_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "model").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_TEXTURE_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "texture").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_IMAGE_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "image").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_SOUND_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "sound").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","/** @deprecated Resolve assets by canonical assetId through GENERATED_ASSET_CATALOG. */","export const ASSET_IDS = {",c,"} as const satisfies Record<string, string>;"].join(`
11
11
  `)+`
12
- `}import zm from"node:fs/promises";import lt from"node:path";var Bm=5;async function di(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await XE(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=MG(e.sourcePath,t);return o&&(t.textureUsage=o.usage,t.capabilities={...pe(t.capabilities)?t.capabilities:{},materialTexture:o.materialTexture,environmentTexture:o.environmentTexture}),Object.keys(t).length>0?t:null}if(e.kind!=="model")return Object.keys(t).length>0?t:null;t.assetMetadataVersion=Bm;let n=await YE(e.sourcePath,{assetGuid:e.guid,assetId:e.assetId,cwd:e.cwd,assetsDir:e.assetsDir,existingMaterialSlots:t.materialSlots});return n.length===0?delete t.materialSlots:t.materialSlots=n,Object.keys(t).length>0?t:null}async function XE(e){return e.kind==="model"?aG(e.sourcePath):e.kind==="texture"||e.kind==="image"?iG(e.sourcePath):null}async function YE(e,t={}){try{let r=await ZE(e);return SG(r,{...t,sourcePath:e})}catch{return[]}}async function ZE(e){let t=lt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await zm.readFile(e,"utf8"));if(t!==".glb")return null;let r=await zm.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let a=12;for(;a+8<=r.length;){let i=r.readUInt32LE(a),s=r.readUInt32LE(a+4);if(a+=8,a+i>r.length)return null;if(s===1313821514){let c=r.toString("utf8",a,a+i).replace(/\0+$/g,"");return JSON.parse(c)}a+=i}return null}async function aG(e){try{let t=await ZE(e);if(!t||typeof t!="object")return null;let r=Array.isArray(t.scenes)?t.scenes:[],n=Array.isArray(t.nodes)?t.nodes:[],o=Array.isArray(t.meshes)?t.meshes:[],a=Array.isArray(t.materials)?t.materials:[],i=Array.isArray(t.textures)?t.textures:[],s=Array.isArray(t.images)?t.images:[],c=Array.isArray(t.animations)?t.animations:[],d=Array.isArray(t.skins)?t.skins:[],u=Array.isArray(t.accessors)?t.accessors:[],l=nI(t),m=oI(n),f=new Set(l),S=o.reduce((E,T)=>E+(Array.isArray(T?.primitives)?T.primitives.length:0),0),g=o.reduce((E,T)=>E+(Array.isArray(T?.primitives)?T.primitives.reduce((A,$)=>A+(Array.isArray($?.targets)?$.targets.length:0),0):0),0),b=uG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=mG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,complexity:b});return{kind:"gltf",format:lt.extname(e).toLowerCase()===".gltf"?"gltf":"glb",summary:`${n.length} nodes, ${o.length} meshes, ${S} primitives, ${a.length} materials`,complexity:b,sceneCount:r.length,nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,nodes:sG(n,o,a,u,m,f),meshes:cG(o,a,u),materials:dG(t),diagnostics:y}}catch{return null}}async function iG(e){try{let t=await zm.readFile(e),r=lt.extname(e).toLowerCase(),n=r===".png"?fG(t):r===".jpg"||r===".jpeg"?pG(t):r===".webp"?gG(t):null;if(!n)return null;let o=bG(n);return{kind:"image",format:n.format,summary:`${n.width}x${n.height} ${n.mime}`,complexity:n.estimatedPixels>=4096*4096?"high":n.estimatedPixels>=2048*2048?"medium":"low",width:n.width,height:n.height,mime:n.mime,bitDepth:n.bitDepth,hasAlpha:n.hasAlpha,estimatedPixels:n.estimatedPixels,diagnostics:o}}catch{return null}}function sG(e,t,r,n,o,a){return e.slice(0,100).map((i,s)=>{let c=Number.isInteger(i?.mesh)?i.mesh:-1,d=c>=0&&c<t.length?t[c]:null,u=Array.isArray(i?.children)?i.children.filter(f=>Number.isInteger(f)):[],l=aI(e,o,a,s),m={nodeIndex:s,nodeIndexPath:sI(o,s),...typeof i?.name=="string"&&i.name.trim()?{name:i.name.trim()}:{},...l?{ownerNodePath:l}:{},...u.length>0?{children:u}:{}};if(d){let f=QE(d,r,n);Object.assign(m,{meshIndex:c,...typeof d?.name=="string"&&d.name.trim()?{meshName:d.name.trim()}:{},primitiveCount:f.length,...f.length>0?{primitives:f}:{}})}return m})}function cG(e,t,r){return e.slice(0,50).map((n,o)=>{let a=Array.isArray(n?.primitives)?n.primitives:[],i=[...new Set(a.map(c=>Number.isInteger(c?.material)?c.material:-1).filter(c=>c>=0))],s=QE(n,t,r);return{meshIndex:o,...typeof n?.name=="string"&&n.name.trim()?{name:n.name.trim()}:{},primitiveCount:a.length,...s.length>0?{primitives:s}:{},...i.length>0?{materialIndices:i}:{},...i.length>0?{materialNames:i.map(c=>{let d=t[c];return typeof d?.name=="string"?d.name.trim():""}).filter(Boolean)}:{}}})}function QE(e,t,r){let n=pe(e)?e:{};return(Array.isArray(n.primitives)?n.primitives:[]).map((a,i)=>{let s=Number.isInteger(a?.material)?a.material:-1,c=s>=0?t[s]:null,d=typeof c?.name=="string"&&c.name.trim()?c.name.trim():"",u=cI(a,r),l=dI(a,r);return{primitiveIndex:i,...Number.isInteger(a?.mode)?{mode:a.mode}:{},...s>=0?{sourceMaterialIndex:s}:{},...d?{materialName:d}:{},...Number.isFinite(u)?{triangleCount:u}:{},...l?{boundingBox:l}:{}}})}function dG(e){return(Array.isArray(e?.materials)?e.materials:[]).slice(0,50).map((r,n)=>{let o=r?.pbrMetallicRoughness&&typeof r.pbrMetallicRoughness=="object"?r.pbrMetallicRoughness:{},a=lG(r,o);return{sourceMaterialIndex:n,...typeof r?.name=="string"&&r.name.trim()?{materialName:r.name.trim()}:{},...Array.isArray(o.baseColorFactor)?{baseColorFactor:o.baseColorFactor.slice(0,4)}:{},metallicFactor:Number.isFinite(o.metallicFactor)?o.metallicFactor:1,roughnessFactor:Number.isFinite(o.roughnessFactor)?o.roughnessFactor:1,alphaMode:tI(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function lG(e,t){let r=[];return si(r,"baseColor",t?.baseColorTexture),si(r,"metallicRoughness",t?.metallicRoughnessTexture),si(r,"normal",e?.normalTexture),si(r,"occlusion",e?.occlusionTexture),si(r,"emissive",e?.emissiveTexture),r}function si(e,t,r){!pe(r)||!Number.isInteger(r.index)||e.push({slot:t,textureIndex:r.index,...Number.isFinite(r.texCoord)?{texCoord:r.texCoord}:{}})}function uG(e){return e.nodeCount>=300||e.meshCount>=250||e.primitiveCount>=300||e.materialCount>=200||e.textureCount>=80||e.imageCount>=80?"high":e.nodeCount>=100||e.meshCount>=80||e.primitiveCount>=100||e.materialCount>=50||e.textureCount>=24||e.imageCount>=24?"medium":"low"}function mG(e){let t=[];return e.complexity==="high"&&t.push({severity:"warning",source:"asset",code:"asset.analysis.highComplexity",message:"GLTF asset is structurally complex; agent should place and inspect it before duplicating or using dense shadows.",details:{nodeCount:e.nodeCount,meshCount:e.meshCount,primitiveCount:e.primitiveCount,materialCount:e.materialCount,textureCount:e.textureCount,imageCount:e.imageCount}}),(e.animationCount>0||e.skinCount>0||e.morphTargetCount>0)&&t.push({severity:"info",source:"asset",code:"asset.analysis.riggedOrAnimated",message:"GLTF asset contains animation, skin, or morph target data.",details:{animationCount:e.animationCount,skinCount:e.skinCount,morphTargetCount:e.morphTargetCount}}),t}function fG(e){if(e.length<33||e[0]!==137||e.toString("ascii",1,4)!=="PNG"||e[4]!==13||e[5]!==10||e[6]!==26||e[7]!==10||e.toString("ascii",12,16)!=="IHDR")return null;let r=e.readUInt32BE(16),n=e.readUInt32BE(20),o=e[24],a=e[25],i=!1,s=33;for(;s+12<=e.length;){let c=e.readUInt32BE(s),d=s+12+c;if(d>e.length)break;let u=e.toString("ascii",s+4,s+8);if(u==="tRNS"){i=!0;break}if(u==="IDAT"||u==="IEND")break;s=d}return{format:"png",mime:"image/png",width:r,height:n,bitDepth:o,hasAlpha:a===4||a===6||i,estimatedPixels:r*n}}function pG(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let r=e[t+1],n=e.readUInt16BE(t+2);if(n<2)return null;if(r>=192&&r<=207&&![196,200,204].includes(r)&&t+8<e.length){let a=e[t+4],i=e.readUInt16BE(t+5),s=e.readUInt16BE(t+7);return{format:"jpeg",mime:"image/jpeg",width:s,height:i,bitDepth:a,hasAlpha:!1,estimatedPixels:s*i}}t+=2+n}return null}function gG(e){if(e.length<30||e.toString("ascii",0,4)!=="RIFF"||e.toString("ascii",8,12)!=="WEBP")return null;let t=e.toString("ascii",12,16);if(t==="VP8X"&&e.length>=30){let r=e[20],n=WE(e,24)+1,o=WE(e,27)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:(r&16)!==0,estimatedPixels:n*o}}if(t==="VP8 "&&e.length>=30){let r=e.readUInt16LE(26)&16383,n=e.readUInt16LE(28)&16383;return{format:"webp",mime:"image/webp",width:r,height:n,hasAlpha:!1,estimatedPixels:r*n}}if(t==="VP8L"&&e.length>=25&&e[20]===47){let r=e.readUInt32LE(21),n=(r&16383)+1,o=(r>>14&16383)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:!0,estimatedPixels:n*o}}return null}function WE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function bG(e){let t=[];return e.estimatedPixels>=4096*4096&&t.push({severity:"warning",source:"asset",code:"asset.analysis.largeImage",message:"Image asset is large; agent should inspect texture usage before assigning it broadly.",details:{width:e.width,height:e.height,estimatedPixels:e.estimatedPixels}}),t}function SG(e,t={}){if(!e||typeof e!="object")return[];let r=Array.isArray(e.nodes)?e.nodes:[],n=Array.isArray(e.meshes)?e.meshes:[],o=Array.isArray(e.materials)?e.materials:[],a=hG(e,t),i=nI(e),s=oI(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=xG(t.existingMaterialSlots),l=[],m=new Map;for(let f=0;f<r.length;f+=1){let S=r[f],g=Number.isInteger(S?.mesh)?S.mesh:-1;if(g<0||g>=n.length)continue;let b=aI(r,s,c,f);if(!b)continue;let y=n[g],I=Array.isArray(y?.primitives)?y.primitives:[],E=kG(S,y,b),T=iI(y),A=sI(s,f);for(let $=0;$<I.length;$+=1){let z=I[$],p=OG(z,o),D=rI({ownerNodePath:b,nodeIndex:f,meshIndex:g,primitiveIndex:$}),h=cI(z,d),R=dI(z,d),K=I.length>1?`${E} / Primitive ${$}`:E,ne={ownerNodePath:b,nodeIndex:f,nodeIndexPath:A,meshIndex:g,primitiveIndex:$,...T?{sourceMeshName:T}:{},...p.index>=0?{sourceMaterialIndex:p.index}:{},...Number.isFinite(h)?{triangleCount:h}:{},...R?{boundingBox:R}:{}};if(p.index>=0){let F=m.get(p.index)??{label:K,materialName:p.name,sourceSurfaces:[]};F.sourceSurfaces.push(ne),m.set(p.index,F);continue}l.push({slotId:u.byExactSource.get(D)??AG({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:g,primitiveIndex:I.length>1?$:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,S]of m){let g=S.sourceSurfaces.sort(eI);l.push({slotId:u.bySourceMaterialIndex.get(f)??DG({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:S.label,sourceSurfaces:g,...S.materialName?{materialName:S.materialName,materialNames:[S.materialName]}:{},...EG(a,[f])})}return l.sort(yG)}function yG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return eI(r,n)}function eI(e,t){let r=String(e?.ownerNodePath??"").localeCompare(String(t?.ownerNodePath??""));if(r!==0)return r;let n=Number.isInteger(e?.nodeIndex)?e.nodeIndex:-1,o=Number.isInteger(t?.nodeIndex)?t.nodeIndex:-1;if(n!==o)return n-o;let a=Number.isInteger(e?.meshIndex)?e.meshIndex:-1,i=Number.isInteger(t?.meshIndex)?t.meshIndex:-1;if(a!==i)return a-i;let s=Number.isInteger(e?.primitiveIndex)?e.primitiveIndex:-1,c=Number.isInteger(t?.primitiveIndex)?t.primitiveIndex:-1;return s-c}function hG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=IG(e,o,t);a&&n.push(a)}return n}function EG(e,t){if(!t.length||!e.length)return{};let r=new Map(e.map(o=>[o.sourceMaterialIndex,o])),n=t.map(o=>r.get(o)).filter(Boolean);return n.length>0?{sourceMaterialProfiles:n}:{}}function IG(e,t,r={}){let n=Array.isArray(e?.materials)?e.materials[t]:null;if(!n||typeof n!="object")return null;let o={},a=[],i=n.pbrMetallicRoughness&&typeof n.pbrMetallicRoughness=="object"?n.pbrMetallicRoughness:{},s={},c=Array.isArray(i.baseColorFactor)?i.baseColorFactor:null,d=qE(c);d&&(s.color=d);let u=ci(e,i.baseColorTexture,r,"baseColor.texture",s,"texture",a);Object.keys(s).length>0&&(o.baseColor={...s,brightness:1,saturation:1,contrast:1,hue:0});let l={};ci(e,n.normalTexture,r,"normal.texture",l,"texture",a),Number.isFinite(n.normalTexture?.scale)?l.strength=n.normalTexture.scale:l.texture&&(l.strength=1),Object.keys(l).length>0&&(o.normal=l),o.metallic=Number.isFinite(i.metallicFactor)?i.metallicFactor:1,o.roughness=Number.isFinite(i.roughnessFactor)?i.roughnessFactor:1;let m={};ci(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};ci(e,n.occlusionTexture,r,"occlusion.texture",f,"texture",a),Number.isFinite(n.occlusionTexture?.strength)?f.strength=n.occlusionTexture.strength:f.texture&&(f.strength=1),Object.keys(f).length>0&&(o.occlusion=f);let S={},g=qE(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),b=g&&(g.r!==0||g.g!==0||g.b!==0);b&&(S.color=g),ci(e,n.emissiveTexture,r,"emission.texture",S,"texture",a),b&&(S.intensity=1),Object.keys(S).length>0&&(o.emission=S);let y={},I=tI(n.alphaMode);if(I&&(y.mode=I),(I==="mask"||I==="blend")&&(c&&Number.isFinite(c[3])&&c[3]!==1&&(y.opacity=c[3]),Number.isFinite(n.alphaCutoff)?y.cutoff=n.alphaCutoff:I==="mask"&&(y.cutoff=.5),u.texture&&(y.texture=structuredClone(u.texture)),u.hint&&a.push({...u.hint,profilePath:"alpha.texture"})),Object.keys(y).length>0&&(o.alpha=y),Object.keys(o).length===0&&a.length===0)return null;let E=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";return{sourceMaterialIndex:t,...E?{materialName:E}:{},...Object.keys(o).length>0?{profile:o}:{},...a.length>0?{textureHints:a}:{}}}function qE(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?{r:t,g:r,b:n}:null}function tI(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function ci(e,t,r,n,o,a,i){let s=PG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function PG(e,t,r,n){let o=pe(t)?t:{},a=Number.isInteger(o.index)?o.index:-1;if(a<0)return{};let i=Array.isArray(e?.textures)?e.textures:[],s=Array.isArray(e?.images)?e.images:[],c=i[a],d=TG(c),u=d.imageIndex,l=u>=0?s[u]:null,m=typeof l?.uri=="string"?l.uri.trim():"",f=/^data:/i.test(m),S={profilePath:n,textureIndex:a,...u>=0?{imageIndex:u}:{},...d.previewImageIndex>=0?{previewImageIndex:d.previewImageIndex}:{},...m&&!f?{uri:m}:{},...Number.isInteger(l?.bufferView)?{bufferView:l.bufferView}:{},...typeof l?.mimeType=="string"&&l.mimeType.trim()?{mimeType:l.mimeType.trim()}:{}};if(l?.bufferView!=null)return{hint:{...S,reason:"embedded-texture"}};if(!m)return{hint:{...S,reason:"missing-image-uri"}};if(f)return{hint:{...S,reason:"embedded-texture"}};if(/^https?:\/\//i.test(m)||m.startsWith("/"))return{texture:{url:m}};let g=m;try{g=decodeURIComponent(m)}catch{return{hint:{...S,reason:"unresolved-external-texture"}}}let b=lt.dirname(String(r.sourcePath??"")),y=lt.resolve(b,g),I=r.assetsDir?lt.resolve(r.assetsDir):"",E=r.cwd?lt.resolve(r.cwd):"",T=I?lt.relative(I,y):"../";return I&&E&&T&&!T.startsWith("..")&&!lt.isAbsolute(T)?{texture:{url:`/${lt.relative(E,y).split(lt.sep).join("/")}`},hint:{...S,reason:"external-texture"}}:{hint:{...S,reason:"external-texture"}}}function TG(e){let t=pe(e)?e:{},r=pe(t.extensions)?t.extensions:{},n=Number.isInteger(t.source)?t.source:-1,o=pe(r.KHR_texture_basisu)?r.KHR_texture_basisu:{};if(Number.isInteger(o.source))return{imageIndex:o.source,previewImageIndex:n>=0&&n!==o.source?n:-1};let a=pe(r.EXT_texture_webp)?r.EXT_texture_webp:{};return Number.isInteger(a.source)?{imageIndex:a.source,previewImageIndex:-1}:{imageIndex:n,previewImageIndex:-1}}function xG(e){let t=new Map,r=new Map;if(!Array.isArray(e))return{byExactSource:t,bySourceMaterialIndex:new Map};for(let o of e){if(!pe(o))continue;let a=Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[],i=typeof o.slotId=="string"?o.slotId.trim():"";if(!i)continue;let s=new Set;for(let c of a){if(!pe(c))continue;let d=typeof c.ownerNodePath=="string"?c.ownerNodePath.trim().replace(/^\/+|\/+$/g,""):"",u=Number.isInteger(c.nodeIndex)?c.nodeIndex:-1,l=Number.isInteger(c.meshIndex)?c.meshIndex:-1,m=Number.isInteger(c.primitiveIndex)?c.primitiveIndex:-1;a.length===1&&d&&u>=0&&l>=0&&m>=0&&t.set(rI({ownerNodePath:d,nodeIndex:u,meshIndex:l,primitiveIndex:m}),i),Number.isInteger(c.sourceMaterialIndex)&&c.sourceMaterialIndex>=0&&s.add(c.sourceMaterialIndex)}if(s.size===1){let[c]=s,d=r.get(c)??[];d.push(i),r.set(c,d)}}let n=new Map;for(let[o,a]of r)a.length===1&&n.set(o,a[0]);return{byExactSource:t,bySourceMaterialIndex:n}}function rI(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function AG(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${uI(r)}`}function DG(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${uI(t)}`}function MG(e,t){if(t.textureUsage==="material"||t.usage==="material")return{usage:"material",materialTexture:!0,environmentTexture:!1};if(pe(t.capabilities)&&t.capabilities.materialTexture===!0)return{usage:"material",materialTexture:!0,environmentTexture:!1};if(t.textureUsage==="environment"||t.usage==="environment")return{usage:"environment",materialTexture:!1,environmentTexture:!0};if(pe(t.capabilities)&&t.capabilities.environmentTexture===!0)return{usage:"environment",materialTexture:!1,environmentTexture:!0};let r=lt.extname(e).toLowerCase();return[".env",".hdr",".dds",".ktx",".ktx2"].includes(r)?{usage:"environment",materialTexture:!1,environmentTexture:!0}:[".png",".jpg",".jpeg",".webp"].includes(r)?{usage:"material",materialTexture:!0,environmentTexture:!1}:null}function nI(e){let t=Array.isArray(e.scenes)?e.scenes:[],r=Number.isInteger(e.scene)?e.scene:0,n=t[r]??t[0];return Array.isArray(n?.nodes)?n.nodes.filter(Number.isInteger):[]}function oI(e){let t=new Map;for(let r=0;r<e.length;r+=1){let n=Array.isArray(e[r]?.children)?e[r].children:[];for(let o of n)Number.isInteger(o)&&!t.has(o)&&t.set(o,r)}return t}function aI(e,t,r,n){let o=[],a=n,i=new Set;for(;Number.isInteger(a)&&a>=0&&a<e.length;){if(i.has(a))return"";i.add(a),o.push(wG(e[a],a));let s=t.get(a);if(typeof s!="number"||!Number.isInteger(s))break;a=s}return o.reverse(),o.length>1&&r.has(a)&&o.shift(),o.filter(Boolean).join("/")}function wG(e,t){return(pe(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function kG(e,t,r){let n=pe(e)&&typeof e.name=="string"?e.name.trim():"",o=iI(t);return n||o||r.split("/").filter(Boolean).pop()||r}function iI(e){return pe(e)&&typeof e.name=="string"?e.name.trim():""}function sI(e,t){let r=[],n=t,o=new Set;for(;Number.isInteger(n)&&n>=0;){if(o.has(n))return[];o.add(n),r.push(n);let a=e.get(n);if(!Number.isInteger(a))break;n=a}return r.reverse(),r}function OG(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.material)?r.material:-1,o=n>=0?t[n]:null,a=typeof o?.name=="string"&&o.name.trim()?o.name.trim():"";return{index:n,name:a}}function cI(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=lI(r),a=n>=0?t[n]:null,i=o>=0?t[o]:null,s=Number.isFinite(a?.count)?Number(a.count):Number.isFinite(i?.count)?Number(i.count):null;if(s==null)return null;let c=Number.isInteger(r.mode)?r.mode:4;return c===4?Math.floor(s/3):c===5||c===6?Math.max(0,s-2):0}function dI(e,t){let r=pe(e)?e:{},n=lI(r),o=n>=0?t[n]:null,a=JE(o?.min),i=JE(o?.max);return a&&i?{min:a,max:i}:null}function lI(e){let t=pe(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function JE(e){if(!Array.isArray(e)||e.length<3)return null;let t=Number(e[0]),r=Number(e[1]),n=Number(e[2]);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?[t,r,n]:null}function pe(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function uI(e){let t=String(e??""),r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}import ed from"node:crypto";import{constants as NG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import li from"node:fs/promises";import Ot from"node:path";async function fI(e,t={}){try{let r=await RG(e);if(!r)return[];let n=Array.isArray(r.gltf.images)?r.gltf.images:[],o=t.imageIndexes?new Set(t.imageIndexes.filter(i=>Number.isInteger(i)&&i>=0)):null,a=[];for(let i=0;i<n.length;i+=1){if(o&&!o.has(i))continue;let s=ut(n[i]);if(!s)continue;let c=await CG(e,r,s);if(!c)continue;let d=ui(s.name)??(c.originalFileName?Ot.parse(c.originalFileName).name:null)??void 0;a.push({imageIndex:i,bytes:c.bytes,extension:c.extension,mimeType:c.mimeType,...d?{displayName:d}:{},...c.originalFileName?{originalFileName:c.originalFileName}:{}})}return a}catch{return[]}}function pI(e){let t=new Set;for(let r of bI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function gI(e){let t=new Map;for(let r of bI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n==null||o==null||n===o||t.set(`${n}:${o}`,{imageIndex:n,previewImageIndex:o})}return[...t.values()].sort((r,n)=>r.imageIndex-n.imageIndex||r.previewImageIndex-n.previewImageIndex)}function bI(e){if(!e)return[];let t=[],r=Array.isArray(e.materialSlots)?e.materialSlots:[];for(let n of r){let o=ut(n),a=Array.isArray(o?.sourceMaterialProfiles)?o.sourceMaterialProfiles:[];for(let i of a){let s=ut(i),c=Array.isArray(s?.textureHints)?s.textureHints:[];for(let d of c){let u=ut(d);u&&t.push(u)}}}return t}function SI(e,t){if(!e||t.length===0)return e;let r=new Map(t.map(i=>[i.imageIndex,i.textureAssetId])),n=structuredClone(e),o=Array.isArray(n.materialSlots)?n.materialSlots:[],a=!1;for(let i of o){let s=ut(i),c=Array.isArray(s?.sourceMaterialProfiles)?s.sourceMaterialProfiles:[];for(let d of c){let u=ut(d);if(!u)continue;let l=Array.isArray(u.textureHints)?u.textureHints:[];if(l.length===0)continue;let m=[];for(let f of l){let S=ut(f),g=hr(S?.imageIndex),b=ui(S?.profilePath),y=g==null?null:r.get(g)??null;if(!y||!b||!GG(b)){m.push(f);continue}let I=ut(u.profile)??{};jG(I,b,{textureAssetId:y}),u.profile=I,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function RG(e){let t=Ot.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await li.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>mI(e,ut(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await li.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let n=null,o=[],a=12;for(;a+8<=r.length;){let c=r.readUInt32LE(a),d=r.readUInt32LE(a+4);if(a+=8,a+c>r.length)return null;let u=r.subarray(a,a+c);d===1313821514?n=JSON.parse(u.toString("utf8").replace(/\0+$/g,"")):d===5130562&&o.push(Buffer.from(u)),a+=c}if(!n)return null;let i=Array.isArray(n.buffers)?n.buffers:[],s=await Promise.all(i.map(async(c,d)=>{let u=ut(c);return ui(u?.uri)?mI(e,u):o[d]??(d===0?o[0]??null:null)}));return s.length===0&&o.length>0&&s.push(o[0]),{gltf:n,buffers:s}}async function mI(e,t){let r=ui(t?.uri);if(!r)return null;let n=EI(r);if(n)return n.bytes;if(Um(r))return null;let o=hI(r);return o?yI(e,o):null}async function CG(e,t,r){let n=ui(r.uri);if(n){let f=EI(n);if(f){let I=Vm(f.bytes);return I?{bytes:f.bytes,...I}:null}if(Um(n))return null;let S=hI(n);if(!S)return null;let g=await yI(e,S);if(!g)return null;let b=Ot.basename(S),y=Vm(g);return y?{bytes:g,...y,originalFileName:b}:null}let o=hr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ut(a[o]),s=hr(i?.buffer)??0,c=t.buffers[s],d=hr(i?.byteOffset)??0,u=hr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=Vm(l);return m?{bytes:l,...m}:null}async function yI(e,t){if(Ot.isAbsolute(t)||Ot.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await li.realpath(Ot.dirname(e)),n=Ot.resolve(r,t),o=await li.realpath(n);return vG(r,o)?await li.readFile(o):null}catch{return null}}function hI(e){if(Um(e))return null;try{return decodeURIComponent(e)}catch{return null}}function vG(e,t){let r=Ot.relative(e,t);return r===""||!r.startsWith(`..${Ot.sep}`)&&r!==".."&&!Ot.isAbsolute(r)}function EI(e){let t=/^data:([^;,]+)?(?:;[^,]*)?,(.*)$/is.exec(e);if(!t)return null;let r=e.slice(0,e.indexOf(","));try{return{bytes:r.toLowerCase().includes(";base64")?Buffer.from(t[2]??"","base64"):Buffer.from(decodeURIComponent(t[2]??""),"utf8")}}catch{return null}}function Vm(e){return e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?{extension:".png",mimeType:"image/png"}:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{extension:".jpg",mimeType:"image/jpeg"}:e.length>=12&&e.toString("ascii",0,4)==="RIFF"&&e.toString("ascii",8,12)==="WEBP"?{extension:".webp",mimeType:"image/webp"}:e.length>=12&&e.subarray(0,12).equals(Buffer.from([171,75,84,88,32,50,48,187,13,10,26,10]))?{extension:".ktx2",mimeType:"image/ktx2"}:null}function GG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function jG(e,t,r){let n=t.split("."),o=e;for(let a=0;a<n.length-1;a+=1){let i=n[a],s=ut(o[i])??{};o[i]=s,o=s}o[n[n.length-1]]=r}function Um(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/")||Ot.win32.isAbsolute(e)}function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ui(e){return typeof e=="string"&&e.trim()?e.trim():null}function hr(e){return Number.isInteger(e)&&e>=0?e:null}var U=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function Go(e,t,r={}){if(!t.payload&&!t.payloadData)throw new U("missing_payload_arg");let n=await WG(e,t),o=e.codeKeyPolicy??"legacy";if(o==="disabled"&&Object.prototype.hasOwnProperty.call(n,"codeKey"))throw new U("payload_code_key_disabled",{codeKeyPolicy:o,codeKey:n.codeKey});let a=v.resolve(e.cwd,String(n.sourcePath??n.assetPath??"")),i=LG(e,a);if(!i)throw new U(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:MI(e)});try{await W.access(a,NG.R_OK)}catch(h){let R=vo(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new U(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=XG(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Zt(e),d=await Qm(a),u=Wc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new U("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});Jm(u,a,"source_path");let l=JG(c,n,s,a,d,u,e),m=ae(n.assetName)??l?.originalFileName??v.basename(a),f=ae(n.guid);if(l&&f&&l.guid!==f)throw new U("payload_guid_must_match_existing_asset",{guid:f,existingGuid:l.guid,existingAssetId:l.assetId});let S=l?.guid??f??ed.randomUUID(),g=ae(n.projectAssetId),b=Kc(u,S);if(l?.assetId&&l.assetId!==b)throw new U("manifest_asset_id_must_match_guid",{guid:S,assetId:l.assetId,expectedAssetId:b});if(g&&g!==b)throw new U("project_asset_id_must_match_guid",{guid:S,projectAssetId:g,expectedAssetId:b});let y=i===".gltf"?v.posix.join(b,v.basename(a)):`${b}${i}`,I=zG(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),E=fi(e,I,u,"target_path"),T=new Date().toISOString(),A=hm(ae(n.displayName)??l?.displayName,m),$=Qc({...Qc(l?.external)??{},...s??{}}),z=!1,p=[],D=null;try{await W.mkdir(v.dirname(E),{recursive:!0});let h=VG(a,E),R=h||await OI(E),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,E),z=!l,i===".gltf"&&await FG(a,E));let F=await kI(e,{existing:l,payload:n,sourcePath:a,targetPath:E,kind:u,guid:S,assetId:b}),Ir=Ke(l?.metadata),er=Ke(F);if(u==="model"&&(Ir.assetAnalysisStatus==="complete"||Object.keys(Ke(Ir.assetAnalysis)).length>0)&&er.assetAnalysisStatus==="unavailable")throw new U("source_asset_analysis_failed",{sourcePath:a,assetId:b,guid:S});if(u==="model"){let tr=await _G({config:e,manifest:c,metadata:F,sourcePath:a,sourceAssetId:b,sourceAssetGuid:S,sourceDisplayName:A,now:T});p=tr.createdPaths,F=SI(F,tr.references)}let qr=Ym({...l??{},guid:S,assetId:b,kind:u,displayName:A,relativePath:I,originalFileName:m,...o==="legacy"?{codeKey:Em(ae(n.codeKey)??ae(n.assetName)??l?.codeKey,m)}:{},...ae(n.category)?{category:ae(n.category)}:{},placeable:u==="texture"?!0:typeof n.placeable=="boolean"?n.placeable:l?.placeable??u==="model",...Am(n.warmupCount)!=null?{warmupCount:Am(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...xm(n.materialMode)?{materialMode:xm(n.materialMode)}:{},...Tm(n.scale)?{defaults:{transform:{scale:Tm(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:$,metadata:F,createdAt:l?.createdAt??T,updatedAt:K?T:l?.updatedAt??T});if(!qr)throw new U("invalid_manifest_entry",{assetId:b,guid:S});D=qr;let hi=c.findIndex(tr=>tr.guid===S||tr.assetId===b);hi>=0?c[hi]=qr:c.push(qr),c.sort(QG),await nj(e,c)}catch(h){z&&await W.rm(i===".gltf"?v.dirname(E):E,{recursive:i===".gltf",force:!0}).catch(()=>{});for(let R of p)await W.rm(R,{force:!0}).catch(()=>{});throw h}return{ok:!0,guid:S,assetId:b,kind:u,...D?.contentHash?{contentHash:D.contentHash}:{},...D?.external?{external:D.external}:{},displayName:D?.displayName,originalFileName:D?.originalFileName,assetUrl:HG(e,I,u),targetPath:E,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function FG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new U("gltf_source_invalid_json")}let n=v.dirname(await W.realpath(e)),o=v.dirname(t),a=[...Array.isArray(r.buffers)?r.buffers:[],...Array.isArray(r.images)?r.images:[]],i=new Set;for(let s of a){let c=ae(Ke(s)?.uri);if(!c||c.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(c)||c.startsWith("//"))continue;let d;try{d=decodeURIComponent(c.split(/[?#]/,1)[0])}catch{continue}let u=d.replace(/\\/g,"/"),l=v.posix.normalize(u);if(!l||l==="."||l===".."||l.startsWith("../")||v.posix.isAbsolute(l)||i.has(l))continue;i.add(l);let m;try{m=await W.realpath(v.resolve(n,...l.split("/")))}catch{continue}try{Km(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));Km(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function Km(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new U(r)}async function _G(e){let t=pI(e.metadata),r=gI(e.metadata),n=await fI(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=[];try{for(let d of n){let u=mi(d.bytes),l=e.manifest.find(A=>A.kind==="texture"&&A.contentHash===u.contentHash&&Ke(Ke(A.metadata).capabilities).materialTexture!==!1&&Ke(A.metadata).textureUsage!=="environment");if(l){a.set(d.imageIndex,l),o.push({imageIndex:d.imageIndex,textureAssetId:l.assetId});continue}let m=tj(u.contentHash),f=Kc("texture",m),S=e.manifest.find(A=>A.guid===m||A.assetId===f);if(S)throw new U("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,contentHash:u.contentHash,conflictingAssetId:S.assetId,conflictingContentHash:S.contentHash});let g=`${f}${d.extension}`,b=wI(e.config,"texture",g),y=fi(e.config,b,"texture","derived_texture_target_path");if(await W.mkdir(v.dirname(y),{recursive:!0}),await OI(y)){let A=await Qm(y);if(A.contentHash!==u.contentHash)throw new U("derived_texture_target_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,targetPath:y,contentHash:u.contentHash,existingContentHash:A.contentHash})}else await ej(y,d.bytes),i.push(y);let I=d.displayName?`${e.sourceDisplayName} / ${d.displayName}`:`${e.sourceDisplayName} Texture ${d.imageIndex+1}`,E=await kI(e.config,{existing:null,payload:{metadata:{textureUsage:"material",capabilities:{materialTexture:!0,environmentTexture:!1},derivedFrom:{kind:"gltf-image",sourceAssetId:e.sourceAssetId,sourceAssetGuid:e.sourceAssetGuid,imageIndex:d.imageIndex,mimeType:d.mimeType}}},sourcePath:y,targetPath:y,kind:"texture",guid:m,assetId:f}),T=Ym({guid:m,assetId:f,kind:"texture",displayName:I,relativePath:b,originalFileName:d.originalFileName??`${rj(I)}${d.extension}`,category:"Texture",placeable:!0,contentHash:u.contentHash,byteSize:u.byteSize,metadata:E,createdAt:e.now,updatedAt:e.now});if(!T)throw new U("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f});e.manifest.push(T),a.set(d.imageIndex,T),o.push({imageIndex:d.imageIndex,textureAssetId:f})}let s=new Map,c=new Map;for(let d of a.values())v.extname(d.relativePath).toLowerCase()===".ktx2"&&s.set(d.assetId,d);for(let d of r){let u=a.get(d.imageIndex),l=a.get(d.previewImageIndex);!u||!l||v.extname(u.relativePath).toLowerCase()!==".ktx2"||c.set(u.assetId,l.assetId)}for(let d of s.values()){let u=Ke(d.metadata),l=$G(u);delete l[e.sourceAssetId];let m=c.get(d.assetId);m&&(l[e.sourceAssetId]=m);let f=Object.fromEntries(Object.entries(l).sort(([b],[y])=>b.localeCompare(y))),S=Object.values(f)[0],g={...u};S?(g.previewTextureAssetId=S,g.previewTextureAssetIdsBySourceAssetId=f):(delete g.previewTextureAssetId,delete g.previewTextureAssetIdsBySourceAssetId),d.metadata=g}return{references:o,createdPaths:i}}catch(s){for(let c of i)await W.rm(c,{force:!0}).catch(()=>{});throw s}}function $G(e){let t={},r=Ke(e.previewTextureAssetIdsBySourceAssetId);for(let[a,i]of Object.entries(r)){let s=ae(a),c=ae(i);s&&c&&(t[s]=c)}if(Object.keys(t).length>0)return t;let n=ae(e.previewTextureAssetId),o=ae(Ke(e.derivedFrom).sourceAssetId);return n&&o&&(t[o]=n),t}async function Wm(e,t={}){let r=await DI(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function qm(e,t={}){return DI(e,t,!0)}async function DI(e,t,r){let n=await Zt(e),o=[],a=[];for(let i of n){let s=fi(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await Qm(s)}catch(m){let f=II(i,m,t,"source-audit",s);if(!r||!f)throw PI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&Ke(i.metadata).assetMetadataVersion!==Bm,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await Go(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=II(i,m,t,"source-analysis",s);if(!r||!f)throw PI(f,m,s);a.push(f);continue}if(!l.contentHash)throw new U("asset_refresh_missing_content_hash",{assetId:i.assetId,guid:i.guid,sourcePath:s});o.push({guid:i.guid,assetId:i.assetId,kind:i.kind,...i.contentHash?{previousContentHash:i.contentHash}:{},contentHash:l.contentHash})}return{ok:!0,scannedAssetCount:n.length,refreshedAssets:o,availabilityIssues:a}}function II(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof U?t.message:void 0,s=vo(t)?t.code:t instanceof U?ae(t.details.nodeCode):void 0,c=i===a||i==="source_file_not_found"||i==="source_file_unreadable"||i==="source_asset_analysis_failed"||i==="gltf_source_invalid_json",d=vo(t)&&typeof t.path=="string"?v.resolve(t.path):null;if(!c&&(!s||n!=="source-audit"&&d!==v.resolve(o)))return null;let u=i==="source_asset_analysis_failed"?"analysis-failed":i==="gltf_source_invalid_json"?"invalid":s==="ENOENT"||i===a||i==="source_file_not_found"?"missing":s==="EACCES"||s==="EPERM"||i==="source_file_unreadable"?"unreadable":s==="EISDIR"||s==="EINVAL"?"invalid":"audit-failed",l=i??(u==="missing"?a:u==="unreadable"?"source_file_unreadable":u==="invalid"?"source_file_invalid":"source_file_audit_failed");return{assetId:e.assetId,guid:e.guid,kind:e.kind,relativePath:e.relativePath,stage:n,reason:u,code:l,...s?{nodeCode:s}:{},retryable:!0}}function PI(e,t,r){return!e||t instanceof U?t:new U(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Zt(e){let t=await Xm(e.manifestPath,[]);if(!Array.isArray(t))throw new U("manifest_invalid_root",{manifestPath:e.manifestPath});let r=t.map((i,s)=>{let c=Ym(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:e.manifestPath});return c}),n=new Set,o=new Set,a=e.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:e.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new U("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new U("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function jo(e){return e.loadRules?e.loadRules():e.rulesPath?Xm(e.rulesPath,{}):{}}function TI(e){return(Array.isArray(e)?e:[e]).filter(r=>typeof r=="string"&&!!r.trim()).map(r=>{let n=r.trim().toLowerCase();return n.startsWith(".")?n:`.${n}`})}function MI(e){let t=TI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:TI(ko)}function LG(e,t){let r=t.toLowerCase();return MI(e).find(n=>r.endsWith(n))??null}function zG(e,t){return t.existing?.relativePath?t.existing.relativePath:BG(e,t.sourcePath,t.kind)??wI(e,t.kind,t.targetFileName)}function wI(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function BG(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!xI(v.resolve(n),o)||xI(v.resolve(e.generatedDir),o)?null:(Jm(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function xI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function VG(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function UG(e,t,r){let n=v.relative(e,t);if(n.startsWith("..")||v.isAbsolute(n))throw new U(`${r}_outside_allowed_directory`,{parent:e,child:t})}function KG(e,t,r){let n=v.relative(e,t);if(!n.startsWith("..")&&!v.isAbsolute(n))throw new U(`${r}_inside_forbidden_directory`,{parent:e,child:t})}function fi(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return UG(a,o,n),KG(v.resolve(e.generatedDir),o,n),Jm(r,o,n),o}function HG(e,t,r){let n=fi(e,t,r,"asset_url_path");return typeof e.publicUrlForCatalogRelativePath=="function"?e.publicUrlForCatalogRelativePath(t):typeof e.publicUrlForRelativePath=="function"?e.publicUrlForRelativePath(t):`/${v.relative(e.cwd,n).split(v.sep).join("/")}`}function Jm(e,t,r){let n=v.extname(t).toLowerCase(),o=Im(e);if(!o.includes(n))throw new U(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function Xm(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(vo(r)&&r.code==="ENOENT")return t;throw r}}async function WG(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await Xm(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new U("invalid_payload_json",{payloadPath:r});return n}function Ym(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?Zm:ae,o=n(r.guid),a=n(r.assetId),i=n(r.kind);if(t&&(!i||"assetKind"in r||"assetType"in r))return null;let s=t?bm.includes(i)?i:null:Wc(r.kind??r.assetKind??r.assetType,r.relativePath),c=n(r.displayName),d=n(r.relativePath);if(!o||!a||!s||!c||!d||t&&(!jn(r,"originalFileName")||!jn(r,"codeKey")||!jn(r,"category")||!jn(r,"materialMode")||!jn(r,"contentHash")||!jn(r,"createdAt")||!jn(r,"updatedAt")||"placeable"in r&&typeof r.placeable!="boolean"||"warmupCount"in r&&(!Number.isInteger(r.warmupCount)||r.warmupCount<0)||"singleton"in r&&typeof r.singleton!="boolean"||"defaults"in r&&Kr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&Kr(r.metadata)==null||"external"in r&&!qG(r.external)))return null;let u=Kr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),S=n(r.materialMode),g=Kr(r.defaults),b=n(r.contentHash),y=Qc(r.external),I=n(r.createdAt),E=n(r.updatedAt);return{guid:o,assetId:a,kind:s,displayName:c,relativePath:d,...l?{originalFileName:l}:{},...m?{codeKey:m}:{},...f?{category:f}:{},...typeof r.placeable=="boolean"?{placeable:r.placeable}:{},...typeof r.warmupCount=="number"?{warmupCount:r.warmupCount}:{},...typeof r.singleton=="boolean"?{singleton:r.singleton}:{},...S?{materialMode:S}:{},...g?{defaults:g}:{},...b?{contentHash:b}:{},...typeof r.byteSize=="number"?{byteSize:r.byteSize}:{},...y?{external:y}:{},...u?{metadata:u}:{},...I?{createdAt:I}:{},...E?{updatedAt:E}:{}}}function Zm(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function jn(e,t){return!(t in e)||Zm(e[t])!=null}function qG(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=["platformAssetId","assetPath","assetUrl"],n=Object.keys(t);return n.length>0&&n.every(o=>r.includes(o)&&Zm(t[o])!=null)}function Qc(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=ae(r.platformAssetId),o;try{if(o=Ja(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new U("external_asset_path_must_be_portable",{assetPath:ae(r.assetPath)})}let a=ae(r.assetUrl);return!n&&!o&&!a?null:{...n?{platformAssetId:n}:{},...o?{assetPath:o}:{},...a?{assetUrl:a}:{}}}function Kr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function kI(e,t){let r=Kr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:Kr(t.existing?.metadata),payloadMetadata:r}),o=Kr(n);return o||null}return di({kind:t.kind,sourcePath:t.sourcePath,existingMetadata:Kr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function JG(e,t,r,n,o,a,i){let s=ae(t.guid),c=ae(t.projectAssetId);if(s){let l=e.find(m=>m.guid===s);if(l)return l}if(c){let l=e.find(m=>m.assetId===c);if(l)return l}if(r?.platformAssetId){let l=e.find(m=>m.kind===a&&YG(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&ZG(m.external)===r.assetPath);if(l)return l}let d=v.resolve(n),u=e.find(l=>{if(l.kind!==a)return!1;try{return v.resolve(fi(i,l.relativePath,l.kind,"manifest_asset_path"))===d}catch{return!1}});if(u)return u;if(o.contentHash){let l=e.find(m=>m.kind===a&&m.contentHash===o.contentHash);if(l)return l}return null}function XG(e){return Qc({...e.external&&typeof e.external=="object"&&!Array.isArray(e.external)?e.external:{},platformAssetId:e.external?.platformAssetId??e.platformAssetId??e.assetId,assetUrl:e.external?.assetUrl??e.assetUrl},!0)}function YG(e){return ae(Ke(e).platformAssetId)}function ZG(e){return ae(Ke(e).assetPath)}function QG(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function Hm(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!vo(n)||n.code!=="ENOENT")throw n}let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{return await W.writeFile(r,t),await W.rename(r,e),!0}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function ej(e,t){let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{await W.writeFile(r,t),await W.rename(r,e)}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function Qm(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...mi(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...mi(t),byteSize:r.size}}let o=v.dirname(await W.realpath(e)),a=new Map;for(let d of[...Array.isArray(n.buffers)?n.buffers:[],...Array.isArray(n.images)?n.images:[]]){let u=ae(Ke(d)?.uri);if(!u||u.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(u)||u.startsWith("//"))continue;let l;try{l=decodeURIComponent(u.split(/[?#]/,1)[0])}catch{continue}let m=v.posix.normalize(l.replace(/\\/g,"/"));if(!m||m==="."||m===".."||m.startsWith("../")||v.posix.isAbsolute(m))continue;let f;try{f=await W.realpath(v.resolve(o,...m.split("/")))}catch{continue}try{Km(o,f,"gltf_dependency_path_escape")}catch{continue}a.set(m,f)}let i=ed.createHash("sha256").update("playable-editor-gltf-bundle-v1\0"),s=[{path:"",...mi(t)}],c=r.size;for(let[d,u]of[...a].sort(([l],[m])=>l.localeCompare(m))){let l=await W.readFile(u);s.push({path:d,...mi(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function mi(e){return{contentHash:`sha256:${ed.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function tj(e){let t=ed.createHash("sha256").update(`material-texture\0${e}`).digest("hex");return`${t.slice(0,8)}-${t.slice(8,12)}-5${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function rj(e){return e.trim().replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^_+|_+$/g,"")||"Imported_Texture"}async function OI(e){try{return await W.access(e),!0}catch{return!1}}async function nj(e,t){let r=HE(t,{codeKeyPolicy:e.codeKeyPolicy??"legacy"});await W.mkdir(v.dirname(e.manifestPath),{recursive:!0}),await W.mkdir(v.dirname(e.registryPath),{recursive:!0});let n=await AI(e.manifestPath),o=await AI(e.registryPath);try{await Hm(e.manifestPath,`${JSON.stringify(t,null,2)}
13
- `),await Hm(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await oj(s,c)}catch(d){i.push(d)}if(i.length>0){let s=new Error("generated_registry_transaction_rollback_failed");throw s.cause=a,s.rollbackErrors=i,s}throw a}}async function AI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(vo(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function oj(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await Hm(e,t.content)}}function ae(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function vo(e){return e instanceof Error&&"code"in e}function RI(e){return{async loadManifest(){let t=await Zt(e.assetRegistryConfig),r=e.textureRegistryConfig?await Zt(e.textureRegistryConfig):[];return{ok:!0,manifest:t,textureManifest:r}},async loadEditorAssetLibrary(){let t=await e.loadAssetCatalogEntries(),r=[...e.createAssetLibrary?e.createAssetLibrary(t):Ns(t)];return{ok:!0,assets:r,summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):aj(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await jo(r),o=cj(n.errorCodes),a=await Zt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await Go(r,{payloadData:{...t,sourcePath:t.assetPath}},o):null,c=s?.assetId??i;if(!c)throw new Error("asset_import_result_missing_asset_id");s&&await sj(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Ns(d)],l=u.find(m=>m.assetId===c||m.id===c);if(!l)throw new Error("asset_import_catalog_projection_missing");return{ok:!0,assetId:c,asset:l,assets:u,disposition:s&&a.some(m=>m.assetId===c)?"deduplicated":s?"created":"existing"}}}}function aj(e,t,r){return r&&ij(e)?r:t}function ij(e){let t=typeof e.assetType=="string"?e.assetType.toLowerCase():"";if(/^(texture|image|png|jpg|jpeg|webp)$/.test(t))return!0;let r=typeof e.kind=="string"?e.kind.toLowerCase():"";if(/^(texture|image)$/.test(r)||(typeof e.mimeType=="string"?e.mimeType.toLowerCase():"").startsWith("image/"))return!0;let o=[e.sourcePath,e.assetPath,e.assetName].filter(a=>typeof a=="string").join(`
14
- `);return/\.(png|jpe?g|webp)(?:$|[?#])/i.test(o)}async function sj(e,t,r){if(!e.invalidateFiles)return;let n=typeof e.additionalInvalidationFiles=="function"?await e.additionalInvalidationFiles():e.additionalInvalidationFiles??[],o=new Set([...n,r.manifestPath||t.manifestPath,r.registryPath||t.registryPath]);await e.invalidateFiles([...o])}function cj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function ef(e,t={}){let r=[],n=0;for await(let o of e){let a=Buffer.from(o);if(n+=a.byteLength,t.maxBytes!==void 0&&n>t.maxBytes)throw Object.assign(new Error("asset_import_payload_too_large"),{code:"asset_import_payload_too_large",details:{maxBytes:t.maxBytes}});r.push(a)}return JSON.parse(Buffer.concat(r).toString("utf8")||"{}")}function Hr(e,t,r){if(e.statusCode=t.statusCode,pi(e,r),t.body==null){e.end();return}e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(t.body))}function pi(e,t={}){e.setHeader("Access-Control-Allow-Origin",t.origin??"*"),e.setHeader("Access-Control-Allow-Methods",t.methods??"GET,POST,OPTIONS"),e.setHeader("Access-Control-Allow-Headers",t.headers??"Content-Type, Authorization"),e.setHeader("Cross-Origin-Resource-Policy",t.resourcePolicy??"cross-origin"),e.setHeader("Cross-Origin-Embedder-Policy",t.embedderPolicy??"credentialless"),e.setHeader("Cache-Control",t.cacheControl??"no-store")}import{existsSync as _I,readFileSync as $I}from"node:fs";import{mkdir as vI,rename as fj,rm as GI,writeFile as pj}from"node:fs/promises";import{randomUUID as gj}from"node:crypto";import Nn from"node:path";import dj from"node:path";var td=new Map;async function rd(e,t){let r=[...new Set(e.map(i=>dj.resolve(i)))].sort(),n=[...new Set(r.map(i=>td.get(i)).filter(Boolean))],o=()=>{},a=new Promise(i=>{o=i});for(let i of r)td.set(i,a);await Promise.all(n);try{return await t()}finally{o();for(let i of r)td.get(i)===a&&td.delete(i)}}import{performance as tf}from"node:perf_hooks";var lj=1,uj=["prepare","compile","validate","stringify","write","checkpoint"];function CI(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:rf(tf.now()-n),rssBeforeBytes:o.rss,rssAfterBytes:a.rss,maxObservedRssBytes:Math.max(o.rss,a.rss),heapUsedBeforeBytes:o.heapUsed,heapUsedAfterBytes:a.heapUsed,maxObservedHeapUsedBytes:Math.max(o.heapUsed,a.heapUsed)})};return{measure(r,n){let o=process.memoryUsage(),a=tf.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=tf.now();try{return await n()}finally{t(r,a,o)}},snapshot(){return mj(e)}}}function mj(e){let t=new Map;for(let n of e){let o=t.get(n.phase);if(!o){t.set(n.phase,{...n});continue}o.durationMs=rf(o.durationMs+n.durationMs),o.rssAfterBytes=n.rssAfterBytes,o.maxObservedRssBytes=Math.max(o.maxObservedRssBytes,n.maxObservedRssBytes),o.heapUsedAfterBytes=n.heapUsedAfterBytes,o.maxObservedHeapUsedBytes=Math.max(o.maxObservedHeapUsedBytes,n.maxObservedHeapUsedBytes)}let r=uj.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:lj,measuredDurationMs:rf(r.reduce((n,o)=>n+o.durationMs,0)),maxObservedRssBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedRssBytes),0),maxObservedHeapUsedBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedHeapUsedBytes),0),phases:r}}function rf(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function LI(e){let t=e.paths,r=gi(t.editorScenePath),n=r?la(r).document:null,o=gi(t.scenePath),a=await e.loadServices(e.server,e.projectRoot),i=await e.listEditorAssetLibrary(e.server,"report");n&&Rm(n),n&&wa(n,i);let s=n?a.ensureEditorSceneEnvironmentDefaults(a.enrichEditorSceneDocumentAssets(a.ensureAuthoringSource(n),i)):null;s&&qc(s);let c=t.renderingConfigPath?gi(t.renderingConfigPath):void 0;c&&gt(c);let d={...Ur(s),...t.renderingConfigPath?{rendering:c}:{}},u=UI(t.shadowsConfigPath),l=se(o),m=typeof l?.version=="number"?l.version:void 0,f=typeof l?.updatedAt=="string"?l.updatedAt:void 0;return{ok:!0,editorScenePath:t.editorScenePath,scenePath:t.scenePath,editorScene:s,assets:i,...m===void 0?{}:{version:m},...f===void 0?{}:{updatedAt:f},...Object.keys(d).length>0?{companionConfigs:d}:{},...u?{shadowMapExperimentConfig:u}:{},drift:s?a.detectRuntimeInputDrift(s,o):null,summary:VI(s)}}async function zI(e){Fn(e),NI(e.body,"$",!0),NI(e.rawEditorScene,"$.editorScene");let t=Mm(e.body),r=Ur(e.body),n=Object.prototype.hasOwnProperty.call(r,"rendering");t&&gt(t);let o=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig");if(o&&KI(e.body),o&&!e.paths.shadowsConfigPath)throw new Error("shadows_config_path_missing");let a=[e.paths.editorScenePath,...e.saveMode==="local-commit-save"?[e.paths.scenePath]:[],...n&&e.paths.renderingConfigPath?[e.paths.renderingConfigPath]:[],...o&&e.paths.shadowsConfigPath?[e.paths.shadowsConfigPath]:[]];return rd(a,()=>(Fn(e),bj(e)))}async function bj(e){let t=CI(),r=t.measure("prepare",()=>Sj(e)),n=la(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Fn(e);let a=e.paths,i=Ur(e.body),s=Mm(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,Gn),u=i[Gn],l=Ar(u),m=t.measure("prepare",()=>gi(a.scenePath)??{}),f=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig"),g=KI(e.body)??UI(a.shadowsConfigPath);t.measure("validate",()=>{nf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let b=Ur(n),y=b[Gn];t.measure("validate",()=>{nf(y,Ar(y),{present:Object.prototype.hasOwnProperty.call(b,Gn),path:"$.editorScene.companionConfigs.staticShadows"})});let I=se(m)?.staticShadows;t.measure("validate",()=>{nf(I,Ar(I),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),Rm(n)});let E=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,T=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Fn(e),t.measure("validate",()=>{wa(n,T)});let A=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),T));return Ac(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(A),o.assertEditorSceneMaterialAssetIntegrity(A)});let $=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(A)),z=d?l:l??pE(n)??Ar(se(m)?.staticShadows),p=t.measure("prepare",()=>Ac(yj($,{staticShadows:z}),4)),D=t.measure("prepare",()=>Ql(p,T)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig($,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:g??null})),R=z?{...h.sceneConfig,staticShadows:z}:{...h.sceneConfig};z||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,F=new Date().toISOString(),Ir=t.measure("compile",()=>Ac(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:F}:R,4));t.measure("validate",()=>{Fi(Ir)});let er=se(Ir)?.version,qr=e.saveMode==="local-commit-save"&&typeof er=="number"?er:ne,hi=`/${Nn.relative(e.projectRoot,a.scenePath).split(Nn.sep).join("/")}?v=${encodeURIComponent(String(qr))}`,tr="",Bn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(D,null,2)}
15
- `);await t.measureAsync("write",()=>nd(e,Bn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Fn(e),await vI(Nn.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
- `);await t.measureAsync("write",()=>nd(e,Bn,a.renderingConfigPath,xe))}else if(c&&!a.renderingConfigPath)throw new Error("rendering_config_path_missing");if(f){if(!a.shadowsConfigPath||!g)throw new Error("shadows_config_path_missing");await vI(Nn.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(g,null,2)}
17
- `);await t.measureAsync("write",()=>nd(e,Bn,a.shadowsConfigPath,xe))}tr=t.measure("stringify",()=>`${JSON.stringify(Ir,null,2)}
18
- `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>nd(e,Bn,a.scenePath,tr)),Fn(e),await t.measureAsync("write",async()=>{for(let xe of Bn)await fj(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await GI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(Bn.filter(xe=>!xe.committed).map(xe=>GI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let yf=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return yf.length>0&&e.invalidateFiles?.(e.server,yf),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:qr,updatedAt:F,sceneUrl:hi}:{},editorScene:p,...g?{shadowMapExperimentConfig:g}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:z}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(E??null)??null}:{}}:{},sceneJsonText:tr,performanceProfile:t.snapshot(),summary:{editorScene:VI($),compiled:h.summary}}}async function nd(e,t,r,n){Fn(e);let o=Nn.join(Nn.dirname(r),`.${Nn.basename(r)}.${process.pid}.${gj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await pj(o,n,{encoding:"utf8",signal:e.signal})}function Fn(e){if(!e.signal?.aborted&&(e.deadlineAt===void 0||Date.now()<e.deadlineAt))return;let t=new Error("Document export lifecycle deadline elapsed before filesystem persistence completed.");throw Object.assign(t,{code:"document_export_timeout"}),t}function Sj(e){let t=gi(e.paths.editorScenePath);if(!t)return e.rawEditorScene;let r=jI(t);if(!r)return e.rawEditorScene;let n=jI(e.rawEditorScene),o=typeof e.body.expectedAuthoringSourceRevision=="number"&&Number.isFinite(e.body.expectedAuthoringSourceRevision)?e.body.expectedAuthoringSourceRevision:n?.revision??null;if(!(n?.sourceId===r.sourceId&&n.sourceType===r.sourceType)){let m={stage:e.saveMode==="prepare-platform-save"?"document.export":"document.save",expectedSourceId:r.sourceId,expectedSourceType:r.sourceType,actualSourceId:n?.sourceId??null,actualSourceType:n?.sourceType??null},f=new Error("authoring_source_identity_mismatch");throw Object.assign(f,{code:"authoring_source_identity_mismatch",details:m,...m}),f}if(n.revision===r.revision&&o===r.revision)return e.rawEditorScene;let i=se(e.body.authoringSourceConflictResolution);if(i?.strategy==="overwrite"&&typeof i.expectedPersistedRevision=="number"&&Number.isFinite(i.expectedPersistedRevision)&&i.expectedPersistedRevision===r.revision){let l=structuredClone(e.rawEditorScene),m=se(se(l.meta)?.authoringSource);return m&&(m.revision=r.revision),l}let c=e.saveMode==="prepare-platform-save"?"document.export":"document.save",d={stage:c,sourceId:r.sourceId,sourceType:r.sourceType,expectedRevision:o,submittedRevision:n.revision,persistedRevision:r.revision},u=new Error("authoring_source_revision_mismatch");throw Object.assign(u,{code:"authoring_source_revision_mismatch",stage:c,sourceId:r.sourceId,expectedRevision:o,actualRevision:r.revision,details:d}),u}function jI(e){let t=se(se(e.meta)?.authoringSource);return typeof t?.sourceId!="string"||!t.sourceId.trim()||typeof t.sourceType!="string"||!t.sourceType.trim()||typeof t.revision!="number"||!Number.isFinite(t.revision)?null:{sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision}}function nf(e,t,r){if(!r.present||e==null||t)return;let n=new Error(`schema.unsupportedVersion: ${r.path}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:r.path}),n}function BI(e){qc(e)}function VI(e){let t=se(e),r=se(t?.meta),n=se(r?.authoringSource),o=se(t?.scene);return{schemaVersion:t?.schemaVersion??null,sourceId:n?.sourceId??null,sourceType:n?.sourceType??null,revision:n?.revision??null,assets:Array.isArray(t?.assets)?t.assets.length:0,gameObjects:Array.isArray(o?.gameObjects)?o.gameObjects.length:0,materialAssets:Array.isArray(o?.materialAssets)?o.materialAssets.length:0}}function yj(e,t){let r={...Ur(e)};delete r.rendering;for(let[o,a]of Object.entries(t))a==null?delete r[o]:r[o]=a;let n={...e};return Object.keys(r).length>0?n.companionConfigs=r:delete n.companionConfigs,n}function gi(e){return _I(e)?JSON.parse($I(e,"utf8")||"{}"):null}function UI(e){if(!e)return null;if(!_I(e))throw new Error(`shadows_config_missing:${e}`);let t=JSON.parse($I(e,"utf8")||"{}");return wi(t,"$"),structuredClone(t)}function KI(e){return Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentConfig")?(wi(e.shadowMapExperimentConfig,"$.shadowMapExperimentConfig"),structuredClone(e.shadowMapExperimentConfig)):null}function NI(e,t,r=!1){let n=se(e);if(!n)return;for(let a of["shadowMapExperimentConfig","shadowsConfig"])if(!(r&&a==="shadowMapExperimentConfig")&&Object.prototype.hasOwnProperty.call(n,a))throw FI(`${t}.${a}`);let o=se(n.companionConfigs);if(o&&Object.prototype.hasOwnProperty.call(o,"shadows"))throw FI(`${t}.companionConfigs.shadows`)}function FI(e){let t=new Error(`shadow_map_experiment_config_readonly:${e}`);return Object.assign(t,{code:"shadowMapExperiment.configReadonly",path:e}),t}import yi from"node:path";import{pipeline as wj}from"node:stream/promises";import{realpathSync as hj}from"node:fs";import af from"node:path";function No(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of Ej(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function Ej(e){let t=af.resolve(e),r=bi(t);return[...new Set([e,t,r,of(e),of(t),of(r)])]}function bi(e){let t=af.resolve(e);try{return hj(t)}catch{return t}}function of(e){return e.split(af.sep).join("/")}import{constants as HI}from"node:fs";import Si from"node:fs/promises";import _n from"node:path";var Ij=128*1024*1024,Pj=512*1024*1024;async function Fo(e){let t=[];for(let n=0;n<2;n+=1)try{await e.close();return}catch(o){t.push(o)}let r=new Error("project_file_close_failed");throw r.errors=t,r}function Tj(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||_n.posix.isAbsolute(t)||/^[A-Za-z]:\//.test(t))throw new Error("project_file_path_invalid");let r=t.split("/");if(r.some(n=>!n||n==="."||n===".."))throw new Error("project_file_path_invalid");return r.join("/")}function sf(e){if(e===void 0)return Ij;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,Pj)}async function od(e,t){let r=Tj(t),n=await Si.realpath(_n.resolve(e)),o=_n.resolve(n,...r.split("/"));WI(n,o),await xj(n,r);let a;try{a=await Si.open(o,HI.O_RDONLY|(HI.O_NOFOLLOW??0))}catch(i){throw i?.code==="ELOOP"?new Error("project_file_symlink_unsupported"):i}try{let i=await a.stat();if(!i.isFile())throw new Error("project_file_not_found");let s=await Si.realpath(o);if(WI(n,s),s!==o)throw new Error("project_file_symlink_unsupported");let c=await Si.stat(s);if(c.dev!==i.dev||c.ino!==i.ino)throw new Error("project_file_changed_during_read");return{absolutePath:o,handle:a,relativePath:r,stat:i}}catch(i){try{await Fo(a)}catch(s){let c=new Error("project_file_close_failed");throw c.errors=[i,s],c}throw i}}function WI(e,t){let r=_n.relative(e,t);if(!r||r===".."||r.startsWith(`..${_n.sep}`)||_n.isAbsolute(r))throw new Error("project_file_path_invalid")}async function xj(e,t){let r=e;for(let n of t.split("/"))if(r=_n.join(r,n),(await Si.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import Er from"node:fs/promises";import mt from"node:path";var qI=512*1024,Aj=new Set([".DS_Store",".cache",".git",".next",".nuxt",".parcel-cache",".turbo",".vite","build","coverage","dist","dist-tests","node_modules","output","playwright-report","test-results"]);async function JI(e,t={}){let r=await Er.realpath(mt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...Aj,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=mt.resolve(r,c),u=await Dj(r,d);if(u){u.sort((l,m)=>Number(m.isDirectory())-Number(l.isDirectory())||l.name.localeCompare(m.name,void 0,{numeric:!0,sensitivity:"base"}));for(let l of u){if(l.name.startsWith(".")||o.has(l.name)||l.isSymbolicLink())continue;if(a.length>=n){i=!0;return}let m=mt.posix.join(c.split(mt.sep).join("/"),l.name),f=mt.resolve(r,...m.split("/")),S=await Mj(r,f);if(!S)continue;let g=S==="file"?mt.extname(l.name).slice(1).toLowerCase():"";a.push({path:m,name:l.name,parentPath:c?c.split(mt.sep).join("/"):null,kind:S,...g?{extension:g}:{}}),S==="directory"&&await s(m)}}};return await s(""),{rootName:mt.basename(r)||"Project",entries:a,truncated:i}}async function Dj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await Er.realpath(t);if(n!==t||!cf(e,n))return null;let o=await Er.readdir(t,{withFileTypes:!0}),a=await Er.lstat(t),i=await Er.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!cf(e,i)?null:o}catch{return null}}async function XI(e,t,r={}){let n=await od(e,t),{handle:o,relativePath:a,stat:i}=n;if(!AE(a))throw await Fo(o),new Error("project_file_preview_unsupported");let s=qI,c,d=0;try{s=Math.max(1,Math.min(r.maxBytes??qI,4*1024*1024));let l=Math.min(i.size,s);c=Buffer.alloc(l),l>0&&({bytesRead:d}=await o.read(c,0,l,0))}finally{await Fo(o)}let u=mt.basename(a);return{path:a,name:u,extension:Jc(u),language:Cm(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Mj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink())return null;let n=await Er.realpath(t);if(n===e||!cf(e,n)||n!==t)return null;let o=await Er.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function cf(e,t){let r=mt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${mt.sep}`)&&!mt.isAbsolute(r)}var df="/__fps_editor_authoring";function YI(e){let t=Promise.resolve([]);return{name:e.name??"fps-editor-project-authoring-api",enforce:"post",apply:"serve",async configureServer(r){let n=e.createAssetAuthoringHandlers(r);e.getAuthoringWrittenFiles&&(t=e.getAuthoringWrittenFiles(r).then(o=>o.map(a=>yi.resolve(e.projectRoot,a))).then(async o=>(kj(r,o),Oj(r.watcher,o),await r.watcher?.unwatch?.(o),e.logger?.log?.("[ProjectAuthoring][Vite] watcher and HMR suppressed for authoring-written files",o),o)).catch(o=>(e.logger?.warn?.("[ProjectAuthoring][Vite] failed to resolve authoring files for HMR suppression",o),[])),await t),r.middlewares.use(async(o,a,i)=>{let s=new URL(o.url??"","http://localhost"),c=s.pathname,d=c===df||c.startsWith(`${df}/`),u=d&&c.slice(df.length)||"/";if(d&&u==="/project-media"){if(pi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Hr(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Hr(a,{statusCode:400,body:{ok:!1,error:"missing_file_path"}});return}try{let f=await od(e.projectRoot,m),S=null,g=null;try{let b=vm(f.relativePath);if(!b)throw new Error("project_file_media_unsupported");if(f.stat.size>sf(e.projectMediaMaxBytes))throw new Error("project_file_media_too_large");let y=yi.basename(f.relativePath);if(a.statusCode=200,a.setHeader("Content-Type",b.mimeType),a.setHeader("Content-Length",String(f.stat.size)),a.setHeader("Content-Disposition",`inline; filename*=UTF-8''${encodeURIComponent(y)}`),a.setHeader("X-Content-Type-Options","nosniff"),f.stat.size>0&&(g=Buffer.allocUnsafe(1),(await f.handle.read(g,0,1,f.stat.size-1)).bytesRead!==1))throw new Error("project_file_changed_during_read");f.stat.size>1&&await wj(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(b){S=b}try{await Fo(f.handle)}catch(b){if(S){let y=new Error("project_file_close_failed");y.errors=[S,b],S=y}else S=b}if(S)throw S;g?a.end(g):a.end()}catch(f){if(a.headersSent)a.destroy(f instanceof Error?f:void 0);else{let S=f instanceof Error?f.message:String(f);Hr(a,{statusCode:S==="project_file_media_too_large"?413:404,body:{ok:!1,error:S}})}}return}if(d&&(u==="/rendering-profile"||u.startsWith("/rendering-profile/"))){if(!e.handleRenderingProfileRoute){i();return}if(pi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}try{let m=await e.handleRenderingProfileRoute({server:r,req:o,readJsonBody:ef});Hr(a,m)}catch(m){Hr(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await kE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>ef(o,{...f.routeName==="asset-import"?{maxBytes:Zu}:{}}),async loadManifest(m){let f=await n;if(!f.loadManifest)throw new Error("asset_manifest_handler_unavailable");return f.loadManifest(m)},async loadEditorAssetLibrary(m){let f=await n;if(!f.loadEditorAssetLibrary)throw new Error("asset_library_handler_unavailable");return f.loadEditorAssetLibrary(m)},async loadProjectFiles(){return JI(e.projectRoot,e.projectFileScan)},async loadProjectFile({path:m}){return XI(e.projectRoot,m)},async loadEditorScene(){return e.loadEditorScene(r)},async importAsset(m){let f=await n;if(!f.importAsset)throw new Error("asset_import_handler_unavailable");return f.importAsset(m)},async saveEditorScene({mode:m,rawEditorScene:f,body:S}){return e.saveEditorScene({server:r,saveMode:m,rawEditorScene:f,body:S})}});if(!l){if(d){pi(a),Hr(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Hr(a,l)})},async handleHotUpdate(r){if(typeof r.file!="string")return;let n=await t;if(ad(r.file,n))return[]}}}function ad(e,t){let r=bi(e);return t.some(n=>{let o=bi(n);if(r===o)return!0;let a=yi.relative(o,r);return a.length>0&&a!==".."&&!a.startsWith(`..${yi.sep}`)&&!yi.isAbsolute(a)})}function kj(e,t){if(!e.watcher?.prependListener||!e.ws?.send)return;let r=null,n=null,o=()=>{r=null,n&&clearTimeout(n),n=null},a=s=>{o(),r=typeof s=="string"&&ad(s,t)?bi(s):null,r&&(n=setTimeout(o,1e3))};for(let s of["add","change","unlink"])e.watcher.prependListener(s,a);let i=e.ws.send.bind(e.ws);e.ws.send=(s,...c)=>{let d=typeof s?.triggeredBy=="string"?s.triggeredBy:void 0,u=d?ad(d,t):!1;if(!(s?.type==="full-reload"&&(u||r&&!d)))return i(s,...c)}}function Oj(e,t){if(!e?.add)return;let r=e.add.bind(e);e.add=n=>{let a=(typeof n=="string"?[n]:[...n]).filter(i=>!ad(i,t));return a.length===0?e:r(typeof n=="string"?a[0]:a)}}import $n,{resolve as _o}from"node:path";import{pathToFileURL as Rj}from"node:url";function ZI(e){let t=Promise.resolve();function r(m){let f=t.then(m);return t=f.then(()=>{},()=>{}),f}async function n(m,f="strict"){let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=[S,g].filter(T=>!!T),y=[],I=[],E=0;for(let T of b){let A=await jo(T),$=typeof A.errorCodes=="object"&&A.errorCodes?A.errorCodes:{},z=f==="report"?await qm(T,$):await Wm(T,$);E+=z.scannedAssetCount,y.push(...z.refreshedAssets);let p="availabilityIssues"in z&&Array.isArray(z.availabilityIssues)?z.availabilityIssues:[];I.push(...p)}return y.length>0&&No(m,[...b.flatMap(T=>[T.manifestPath,T.registryPath]),...lf(e)]),{scannedAssetCount:E,refreshedAssets:y,availabilityIssues:Cj(I)}}function o(m){return r(async()=>{let f=await n(m,"strict");return{scannedAssetCount:f.scannedAssetCount,refreshedAssets:f.refreshedAssets}})}function a(m){return r(async()=>{let f=await n(m,"report"),S=u(Ma(await c(!1)),f.availabilityIssues??[]);return{scannedAssetCount:f.scannedAssetCount,refreshedAssetIds:f.refreshedAssets.map(g=>g.assetId),availabilityIssues:f.availabilityIssues??[],assets:S}})}function i(m,f){return r(async()=>{let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=f.kind??([".png",".jpg",".jpeg",".env"].includes($n.extname(f.sourcePath).toLowerCase())?"texture":"model"),y=b==="texture"?g??S:S,I=await jo(y),E=typeof I.errorCodes=="object"&&I.errorCodes?I.errorCodes:{},T=await Zt(y),A=await Go(y,{payloadData:{sourcePath:f.sourcePath,...f.displayName?{displayName:f.displayName}:{},kind:b,...f.category?{category:f.category}:{},...f.placeable===void 0?{}:{placeable:f.placeable}}},E);No(m,[y.manifestPath,y.registryPath,...lf(e)]);let z=Ma(await c(!1)).find(p=>p.assetId===A.assetId);if(!z)throw new Error("asset_import_catalog_projection_missing");return{asset:z,disposition:T.some(p=>p.assetId===A.assetId)?"deduplicated":"created"}})}async function s(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=RI({assetRegistryConfig:f,textureRegistryConfig:S,loadAssetCatalogEntries:()=>c(!0),additionalInvalidationFiles:lf(e),invalidateFiles(b){No(m,b)}});return{loadManifest:b=>r(async()=>(await n(m,"report"),g.loadManifest(b))),loadEditorAssetLibrary:b=>r(async()=>{let y=await n(m,"report"),I=await g.loadEditorAssetLibrary(b);return!I||typeof I!="object"||!Array.isArray(I.assets)?I:{...I,assets:u(I.assets,y.availabilityIssues??[])}}),importAsset:b=>r(async()=>g.importAsset(b))}}async function c(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=[f,S].filter(E=>!!E),b=[...new Map(g.map(E=>[E.manifestPath,E])).values()],y=(await Promise.all(b.map(E=>Zt(E)))).flat(),I=new Set;return y.filter(E=>{if(E.kind!=="model"&&E.kind!=="texture"||m&&E.kind==="model"&&E.placeable!==!0)return!1;if(I.has(E.assetId))throw new Error(`asset_catalog_duplicate_asset_id:${E.assetId}`);return I.add(E.assetId),!0})}async function d(m,f="strict"){return r(async()=>{let S=await n(m,f);return u(Ma(await c(!1)),S.availabilityIssues??[])})}function u(m,f){if(f.length===0)return m;let S=new Map;for(let g of f){let b=S.get(g.assetId)??[];b.push(g),S.set(g.assetId,b)}return m.map(g=>{let b=typeof g.assetId=="string"?g.assetId:typeof g.id=="string"?g.id:"",y=b?S.get(b):void 0;return!y||y.length===0?g:{...g,availability:{status:"unavailable",issues:y.map(I=>({code:I.code,reason:I.reason,stage:I.stage,severity:"error",relativePath:I.relativePath,...I.nodeCode?{nodeCode:I.nodeCode}:{},retryable:I.retryable}))}}})}async function l(){if(e.assetRegistryConfig)return{projectAssetRegistryConfig:e.assetRegistryConfig,projectTextureRegistryConfig:e.textureRegistryConfig??e.assetRegistryConfig};if(!e.assetCatalogConfigModulePath)throw new Error("Project asset authoring requires assetRegistryConfig or assetCatalogConfigModulePath.");return import(`${Rj(_o(e.projectRoot,e.assetCatalogConfigModulePath)).href}?project-asset-catalog-config=${Date.now()}`)}return{createProjectAssetAuthoringHandlers:s,listEditorAssetLibrary:d,loadProjectAssetCatalogConfigModule:l,importProjectAsset:i,refreshProjectAssetCatalog:o,refreshAndListProjectAssetCatalog:a}}function Cj(e){let t=new Set;return e.filter(r=>{let n=JSON.stringify([r.assetId,r.guid,r.kind,r.relativePath,r.stage,r.reason,r.code,r.nodeCode??null,r.retryable]);return t.has(n)?!1:(t.add(n),!0)})}function QI(e,t){let r=_o(e,t.importedDir),n=_o(e,t.generatedDir),o=$n.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:$n.join(n,"asset-catalog.manifest.json"),registryPath:$n.join(n,"asset-catalog.generated.ts"),scenePath:_o(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:_o(e,t.editorScene)}:{},supportedExtensions:ko,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=$n.join(r,s,i);return $n.relative(n,c).split($n.sep).join("/")},resolveAssetMetadata(a){return di({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function lf(e){return(e.additionalInvalidationFiles??[]).map(t=>_o(e.projectRoot,t))}import id from"node:path";function eP(e,t){return{editorScenePath:id.resolve(t,e.source.editorScene),scenePath:id.resolve(t,e.source.runtimeScene),...e.source.rendering?{renderingConfigPath:id.resolve(t,e.source.rendering)}:{},...e.source.shadows?{shadowsConfigPath:id.resolve(t,e.source.shadows)}:{}}}import{existsSync as vj,readFileSync as Gj}from"node:fs";import{mkdir as jj,writeFile as Nj}from"node:fs/promises";import uf from"node:path";function tP(e,t){let r=e.source.rendering,n=r?uf.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>uf.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:_j,async handleRoute(a){return n?KE({method:Fj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:vj(n)?JSON.parse(Gj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return rd([n],async()=>(await jj(uf.dirname(n),{recursive:!0}),await Nj(n,`${JSON.stringify(i,null,2)}
19
- `,"utf8"),No(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Fj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function _j(e){return{postProcessEnabled:e?.postProcess?.enabled??e?.globalVolume?.enabled??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??e?.globalVolume?.postProcessing?.bloom?.enabled??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}import{randomUUID as $j}from"node:crypto";import{realpath as Lj}from"node:fs/promises";import{createServer as zj}from"node:http";async function nP(e){let t=await Lj(e.projectRoot),r=$j(),n=[...e.middlewares??[]],o=zj((c,d)=>{Bj(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){mf(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){mf(d,404,{ok:!1,error:"not_found"});return}Promise.resolve(f(c,d,m)).catch(S=>{if(d.headersSent){d.destroy(S instanceof Error?S:void 0);return}mf(d,500,{ok:!1,error:S instanceof Error?S.message:String(S)})})};m()});await new Promise((c,d)=>{o.once("error",d),o.listen(0,"127.0.0.1",()=>{o.off("error",d),c()})});let a=o.address();if(!a||typeof a=="string")throw await rP(o).catch(()=>{}),new Error("Editor Project I/O worker address is unavailable.");let i=`http://127.0.0.1:${a.port}`;e.logger?.info?.(`[fps-editor] Project I/O worker ready at ${i}`);let s=null;return Object.freeze({serviceInstanceId:r,internalUrl:i,dispose(){return s||(s=rP(o).catch(c=>{throw s=null,c}),s)}})}function Bj(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function mf(e,t,r){Vj(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
- `))}function Vj(e){return e.destroyed||e.writableEnded}async function rP(e){e.listening&&await new Promise((t,r)=>{e.close(n=>n?r(n):t())})}var Rt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),Ln={kind:"texture"},oP={kind:"color"},Uj={kind:"enum",values:["lit","unlit"]},Kj={kind:"enum",values:["opaque","mask","blend"]},sP={lightingModel:Uj,baseColor:{kind:"object",properties:{color:oP,texture:Ln,brightness:Rt(0),saturation:Rt(0),contrast:Rt(0),hue:Rt(-180,180)}},normal:{kind:"object",properties:{texture:Ln,strength:Rt(0)}},emission:{kind:"object",properties:{color:oP,intensity:Rt(0),texture:Ln,maskTexture:Ln}},alpha:{kind:"object",properties:{mode:Kj,opacity:Rt(0,1),cutoff:Rt(0,1),texture:Ln}}},Hj={kind:"object",properties:{...sP,metallic:Rt(0,1),roughness:Rt(0,1),metallicRoughness:{kind:"object",properties:{texture:Ln}},occlusion:{kind:"object",properties:{texture:Ln,strength:Rt(0)}}}},Wj={kind:"object",properties:sP},qj={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},Jj={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},aP=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],zn={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},cP=[Lo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Lo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),zo("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),Ct("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),zo("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[zn]),Ct("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[zn,$o("properties.normal.texture.textureAssetId","normalTexture")]}),Lo("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),Ct("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),zo("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Lo("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),Ct("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),Ct("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),zo("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Xj=[...cP,Ct("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[zn]}),Ct("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[zn]}),zo("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[zn]),zo("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[zn]),Ct("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[zn,$o("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],pf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:Hj,defaultProperties:qj,inspector:{sections:aP,fields:Xj}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Wj,defaultProperties:Jj,inspector:{sections:aP,fields:cP}}],EK=gf(pf);function gf(e){let t=new Map;for(let n of e){Yj(n,t);let o=Zj(n);t.set(n.shaderId,mP(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Lo(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function Ct(e,t,r,n,o,a,i={}){return Lo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function zo(e,t,r,n,o,a,i,s){return Lo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function $o(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Yj(e,t){if(!Wn(e.shaderId)&&!Qo(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!eN(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);dP(e.shaderId,e.propertiesSchema,"properties");let r=[];if(uP(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);Qj(e,a),o.add(a.path)}}function Zj(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=lP(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Qj(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=lP(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function dP(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))dP(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function eN(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function tN(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function lP(e,t){let r=tN(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function uP(e,t,r,n){if(e.kind==="object"){if(!ff(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&uP(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];iP(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){iP(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!ff(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function iP(e,t,r,n,o){if(!ff(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function mP(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))mP(t)}return e}function ff(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var rN=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),nN=Object.freeze([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function sd(e){return oN(new TextEncoder().encode(e))}function fP(e){return`sha256:${sd(JSON.stringify(e))}`}function oN(e){let t=Math.ceil((e.length+9)/64)*64,r=new Uint8Array(t);r.set(e),r[e.length]=128;let n=new DataView(r.buffer);n.setUint32(t-8,Math.floor(e.length/536870912),!1),n.setUint32(t-4,e.length*8>>>0,!1);let o=[...rN],a=new Uint32Array(64);for(let i=0;i<r.length;i+=64){for(let g=0;g<16;g+=1)a[g]=n.getUint32(i+g*4,!1);for(let g=16;g<64;g+=1){let b=a[g-15],y=a[g-2],I=Qt(b,7)^Qt(b,18)^b>>>3,E=Qt(y,17)^Qt(y,19)^y>>>10;a[g]=a[g-16]+I+a[g-7]+E>>>0}let[s,c,d,u,l,m,f,S]=o;for(let g=0;g<64;g+=1){let b=Qt(l,6)^Qt(l,11)^Qt(l,25),y=l&m^~l&f,I=S+b+y+nN[g]+a[g]>>>0,E=Qt(s,2)^Qt(s,13)^Qt(s,22),T=s&c^s&d^c&d,A=E+T>>>0;S=f,f=m,m=l,l=u+I>>>0,u=d,d=c,c=s,s=I+A>>>0}o[0]=o[0]+s>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+u>>>0,o[4]=o[4]+l>>>0,o[5]=o[5]+m>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+S>>>0}return o.map(i=>i.toString(16).padStart(8,"0")).join("")}function Qt(e,t){return e>>>t|e<<32-t}var aN="fps.plugin.materials";function gP(e){let t=e?.[aN];if(t==null)return null;if(!Bo(t)||t.schemaVersion!==1||typeof t.snapshotId!="string"||!Array.isArray(t.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");let r=structuredClone(t);return iN(r),bP(r)}function bf(e){return gf([...pf,...e?.shaders.map(t=>t.definition)??[]])}function iN(e){if(!/^sha256:[a-f0-9]{64}$/.test(e.snapshotId)||e.shaders.length===0)throw new Error("Materials Plugin snapshot identity is invalid. Run fps-editor-prepare again.");for(let r of e.shaders)if(!Bo(r)||!Bo(r.definition)||!Bo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");bf(e);for(let r of e.shaders){let{definition:n,program:o}=r;if(o.shaderId!==n.shaderId||o.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(o.language!=="glsl"||!pP(o.vertexSourcePath)||!pP(o.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(o.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(o.fragmentSourceHash)||typeof o.vertexSource!="string"||!o.vertexSource.trim()||typeof o.fragmentSource!="string"||!o.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(sd(o.vertexSource)!==o.vertexSourceHash||sd(o.fragmentSource)!==o.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(o.attributes)||o.attributes.length===0||o.attributes.some(a=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))||new Set(o.attributes).size!==o.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(o.alphaMode)||!Bo(o.enumUniformValues)||!Bo(o.frame)||!["on-demand","continuous"].includes(o.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}let t={schemaVersion:e.schemaVersion,shaders:e.shaders};if(fP(t)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function pP(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function bP(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))bP(t);return Object.freeze(e)}function Bo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function yP(e){let t=ME(e.definition),r=gP(e.pluginSnapshots),n=bf(r),o=t.project,a=sN(e.projectRoot),i=QI(e.projectRoot,{importedDir:o.assets.importedDir,generatedDir:o.assets.generatedDir,runtimeArtifact:o.source.runtimeScene,editorScene:o.source.editorScene}),s=ZI({projectRoot:e.projectRoot,assetRegistryConfig:i}),c=tP(o,{projectRoot:e.projectRoot}),d=eP(o,e.projectRoot),u=iE({materialShaderDefinitions:n,markerTypes:t.metadata.markerTypes??[],relationTypes:t.metadata.relationTypes??[],features:o.features,getRenderingProfile:()=>({shadows:{defaultMode:"none"}}),createPatch:{gameObjectField:(g,b,y)=>({kind:"game-object.field",targetId:g,path:b,value:y}),gameObjectFieldBatch:g=>({kind:"game-object.property-field-batch",fields:g}),materialAssetField:(g,b,y)=>({kind:"scene.material-asset.field",materialAssetId:g,path:b,value:y}),materialAssetReplace:(g,b)=>({kind:"scene.material-asset.replace",materialAssetId:g,materialAsset:b}),prefabAssetReplace:(g,b)=>({kind:"scene.prefab-asset.replace",assetId:g,prefabAsset:b}),markerGraph:g=>({kind:"scene.marker-graph",command:g})}}),l={ensureAuthoringSource:vg,detectRuntimeInputDrift:jg,enrichEditorSceneDocumentAssets:Zl,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:BI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:Gg,compileEditorSceneDocumentToSceneConfig:(g,b,y)=>RE(g,b,{...y,materialShaderDefinitions:n,readCustomTransformRuntimeData:I=>I?.transformType==="groundDecal"&&dN(I.groundDecal)?{groundDecal:UE(I.groundDecal)}:null})},f=(g,b="report")=>s.listEditorAssetLibrary(a,b),S=YI({projectRoot:e.projectRoot,createAssetAuthoringHandlers:()=>s.createProjectAssetAuthoringHandlers(a),handleRenderingProfileRoute:c.handleRoute,loadEditorScene:()=>LI({projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,loadServices:async()=>l}),saveEditorScene:g=>zI({...g,projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,saveServices:async()=>m,normalizeRenderingProfile:b=>Ne(b),summarizeRenderingProfile:b=>Vn(b),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await cN(S.configureServer,a),nP({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function sN(e){let t={stack:[],use(o){this.stack.push(o)}},r=new SP,n=new SP;return n.unwatch=async()=>{},n.add=()=>n,{middlewares:t,httpServer:r,watcher:n,ws:{send(){}},moduleGraph:{getModulesByFile(){},invalidateModule(){}},config:{root:e,logger:console}}}async function cN(e,t){if(typeof e=="function"){await e(t);return}e&&typeof e=="object"&&"handler"in e&&typeof e.handler=="function"&&await e.handler(t)}function dN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Wr=await yP({projectRoot:process.cwd(),definition:EP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:EP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Wr||typeof Wr.serviceInstanceId!="string"||typeof Wr.internalUrl!="string"||typeof Wr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Wr.serviceInstanceId,internalUrl:Wr.internalUrl});var Sf=!0,IP=setInterval(()=>{Sf&&process.send?.({type:"heartbeat",serviceInstanceId:Wr.serviceInstanceId})},1e3);IP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(Sf=!1),e?.type==="test.start-heartbeat"&&(Sf=!0)});var hP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{hP||(hP=!0,clearInterval(IP),Wr.dispose().finally(()=>{process.exitCode=e==="SIGINT"?130:143}))});function lN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function EP(e){let t=JSON.parse(lN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}
12
+ `}import Jm from"node:fs/promises";import mt from"node:path";var Xm=5;async function gi(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await nI(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=FG(e.sourcePath,t);return o&&(t.textureUsage=o.usage,t.capabilities={...pe(t.capabilities)?t.capabilities:{},materialTexture:o.materialTexture,environmentTexture:o.environmentTexture}),Object.keys(t).length>0?t:null}if(e.kind!=="model")return Object.keys(t).length>0?t:null;t.assetMetadataVersion=Xm;let n=await oI(e.sourcePath,{assetGuid:e.guid,assetId:e.assetId,cwd:e.cwd,assetsDir:e.assetsDir,existingMaterialSlots:t.materialSlots});return n.length===0?delete t.materialSlots:t.materialSlots=n,Object.keys(t).length>0?t:null}async function nI(e){return e.kind==="model"?gG(e.sourcePath):e.kind==="texture"||e.kind==="image"?bG(e.sourcePath):null}async function oI(e,t={}){try{let r=await aI(e);return MG(r,{...t,sourcePath:e})}catch{return[]}}async function aI(e){let t=mt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await Jm.readFile(e,"utf8"));if(t!==".glb")return null;let r=await Jm.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let a=12;for(;a+8<=r.length;){let i=r.readUInt32LE(a),s=r.readUInt32LE(a+4);if(a+=8,a+i>r.length)return null;if(s===1313821514){let c=r.toString("utf8",a,a+i).replace(/\0+$/g,"");return JSON.parse(c)}a+=i}return null}async function gG(e){try{let t=await aI(e);if(!t||typeof t!="object")return null;let r=Array.isArray(t.scenes)?t.scenes:[],n=Array.isArray(t.nodes)?t.nodes:[],o=Array.isArray(t.meshes)?t.meshes:[],a=Array.isArray(t.materials)?t.materials:[],i=Array.isArray(t.textures)?t.textures:[],s=Array.isArray(t.images)?t.images:[],c=Array.isArray(t.animations)?t.animations:[],d=Array.isArray(t.skins)?t.skins:[],u=Array.isArray(t.accessors)?t.accessors:[],l=lI(t),m=uI(n),f=new Set(l),g=o.reduce((E,D)=>E+(Array.isArray(D?.primitives)?D.primitives.length:0),0),b=o.reduce((E,D)=>E+(Array.isArray(D?.primitives)?D.primitives.reduce((x,N)=>x+(Array.isArray(N?.targets)?N.targets.length:0),0):0),0),S=IG({nodeCount:n.length,meshCount:o.length,primitiveCount:g,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=PG({nodeCount:n.length,meshCount:o.length,primitiveCount:g,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:b,complexity:S});return{kind:"gltf",format:mt.extname(e).toLowerCase()===".gltf"?"gltf":"glb",summary:`${n.length} nodes, ${o.length} meshes, ${g} primitives, ${a.length} materials`,complexity:S,sceneCount:r.length,nodeCount:n.length,meshCount:o.length,primitiveCount:g,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:b,nodes:SG(n,o,a,u,m,f),meshes:yG(o,a,u),materials:hG(t),diagnostics:y}}catch{return null}}async function bG(e){try{let t=await Jm.readFile(e),r=mt.extname(e).toLowerCase(),n=r===".png"?TG(t):r===".jpg"||r===".jpeg"?xG(t):r===".webp"?AG(t):null;if(!n)return null;let o=DG(n);return{kind:"image",format:n.format,summary:`${n.width}x${n.height} ${n.mime}`,complexity:n.estimatedPixels>=4096*4096?"high":n.estimatedPixels>=2048*2048?"medium":"low",width:n.width,height:n.height,mime:n.mime,bitDepth:n.bitDepth,hasAlpha:n.hasAlpha,estimatedPixels:n.estimatedPixels,diagnostics:o}}catch{return null}}function SG(e,t,r,n,o,a){return e.slice(0,100).map((i,s)=>{let c=Number.isInteger(i?.mesh)?i.mesh:-1,d=c>=0&&c<t.length?t[c]:null,u=Array.isArray(i?.children)?i.children.filter(f=>Number.isInteger(f)):[],l=mI(e,o,a,s),m={nodeIndex:s,nodeIndexPath:pI(o,s),...typeof i?.name=="string"&&i.name.trim()?{name:i.name.trim()}:{},...l?{ownerNodePath:l}:{},...u.length>0?{children:u}:{}};if(d){let f=iI(d,r,n);Object.assign(m,{meshIndex:c,...typeof d?.name=="string"&&d.name.trim()?{meshName:d.name.trim()}:{},primitiveCount:f.length,...f.length>0?{primitives:f}:{}})}return m})}function yG(e,t,r){return e.slice(0,50).map((n,o)=>{let a=Array.isArray(n?.primitives)?n.primitives:[],i=[...new Set(a.map(c=>Number.isInteger(c?.material)?c.material:-1).filter(c=>c>=0))],s=iI(n,t,r);return{meshIndex:o,...typeof n?.name=="string"&&n.name.trim()?{name:n.name.trim()}:{},primitiveCount:a.length,...s.length>0?{primitives:s}:{},...i.length>0?{materialIndices:i}:{},...i.length>0?{materialNames:i.map(c=>{let d=t[c];return typeof d?.name=="string"?d.name.trim():""}).filter(Boolean)}:{}}})}function iI(e,t,r){let n=pe(e)?e:{};return(Array.isArray(n.primitives)?n.primitives:[]).map((a,i)=>{let s=Number.isInteger(a?.material)?a.material:-1,c=s>=0?t[s]:null,d=typeof c?.name=="string"&&c.name.trim()?c.name.trim():"",u=gI(a,r),l=bI(a,r);return{primitiveIndex:i,...Number.isInteger(a?.mode)?{mode:a.mode}:{},...s>=0?{sourceMaterialIndex:s}:{},...d?{materialName:d}:{},...Number.isFinite(u)?{triangleCount:u}:{},...l?{boundingBox:l}:{}}})}function hG(e){return(Array.isArray(e?.materials)?e.materials:[]).slice(0,50).map((r,n)=>{let o=r?.pbrMetallicRoughness&&typeof r.pbrMetallicRoughness=="object"?r.pbrMetallicRoughness:{},a=EG(r,o);return{sourceMaterialIndex:n,...typeof r?.name=="string"&&r.name.trim()?{materialName:r.name.trim()}:{},...Array.isArray(o.baseColorFactor)?{baseColorFactor:o.baseColorFactor.slice(0,4)}:{},metallicFactor:Number.isFinite(o.metallicFactor)?o.metallicFactor:1,roughnessFactor:Number.isFinite(o.roughnessFactor)?o.roughnessFactor:1,alphaMode:cI(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function EG(e,t){let r=[];return fi(r,"baseColor",t?.baseColorTexture),fi(r,"metallicRoughness",t?.metallicRoughnessTexture),fi(r,"normal",e?.normalTexture),fi(r,"occlusion",e?.occlusionTexture),fi(r,"emissive",e?.emissiveTexture),r}function fi(e,t,r){!pe(r)||!Number.isInteger(r.index)||e.push({slot:t,textureIndex:r.index,...Number.isFinite(r.texCoord)?{texCoord:r.texCoord}:{}})}function IG(e){return e.nodeCount>=300||e.meshCount>=250||e.primitiveCount>=300||e.materialCount>=200||e.textureCount>=80||e.imageCount>=80?"high":e.nodeCount>=100||e.meshCount>=80||e.primitiveCount>=100||e.materialCount>=50||e.textureCount>=24||e.imageCount>=24?"medium":"low"}function PG(e){let t=[];return e.complexity==="high"&&t.push({severity:"warning",source:"asset",code:"asset.analysis.highComplexity",message:"GLTF asset is structurally complex; agent should place and inspect it before duplicating or using dense shadows.",details:{nodeCount:e.nodeCount,meshCount:e.meshCount,primitiveCount:e.primitiveCount,materialCount:e.materialCount,textureCount:e.textureCount,imageCount:e.imageCount}}),(e.animationCount>0||e.skinCount>0||e.morphTargetCount>0)&&t.push({severity:"info",source:"asset",code:"asset.analysis.riggedOrAnimated",message:"GLTF asset contains animation, skin, or morph target data.",details:{animationCount:e.animationCount,skinCount:e.skinCount,morphTargetCount:e.morphTargetCount}}),t}function TG(e){if(e.length<33||e[0]!==137||e.toString("ascii",1,4)!=="PNG"||e[4]!==13||e[5]!==10||e[6]!==26||e[7]!==10||e.toString("ascii",12,16)!=="IHDR")return null;let r=e.readUInt32BE(16),n=e.readUInt32BE(20),o=e[24],a=e[25],i=!1,s=33;for(;s+12<=e.length;){let c=e.readUInt32BE(s),d=s+12+c;if(d>e.length)break;let u=e.toString("ascii",s+4,s+8);if(u==="tRNS"){i=!0;break}if(u==="IDAT"||u==="IEND")break;s=d}return{format:"png",mime:"image/png",width:r,height:n,bitDepth:o,hasAlpha:a===4||a===6||i,estimatedPixels:r*n}}function xG(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let r=e[t+1],n=e.readUInt16BE(t+2);if(n<2)return null;if(r>=192&&r<=207&&![196,200,204].includes(r)&&t+8<e.length){let a=e[t+4],i=e.readUInt16BE(t+5),s=e.readUInt16BE(t+7);return{format:"jpeg",mime:"image/jpeg",width:s,height:i,bitDepth:a,hasAlpha:!1,estimatedPixels:s*i}}t+=2+n}return null}function AG(e){if(e.length<30||e.toString("ascii",0,4)!=="RIFF"||e.toString("ascii",8,12)!=="WEBP")return null;let t=e.toString("ascii",12,16);if(t==="VP8X"&&e.length>=30){let r=e[20],n=eI(e,24)+1,o=eI(e,27)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:(r&16)!==0,estimatedPixels:n*o}}if(t==="VP8 "&&e.length>=30){let r=e.readUInt16LE(26)&16383,n=e.readUInt16LE(28)&16383;return{format:"webp",mime:"image/webp",width:r,height:n,hasAlpha:!1,estimatedPixels:r*n}}if(t==="VP8L"&&e.length>=25&&e[20]===47){let r=e.readUInt32LE(21),n=(r&16383)+1,o=(r>>14&16383)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:!0,estimatedPixels:n*o}}return null}function eI(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function DG(e){let t=[];return e.estimatedPixels>=4096*4096&&t.push({severity:"warning",source:"asset",code:"asset.analysis.largeImage",message:"Image asset is large; agent should inspect texture usage before assigning it broadly.",details:{width:e.width,height:e.height,estimatedPixels:e.estimatedPixels}}),t}function MG(e,t={}){if(!e||typeof e!="object")return[];let r=Array.isArray(e.nodes)?e.nodes:[],n=Array.isArray(e.meshes)?e.meshes:[],o=Array.isArray(e.materials)?e.materials:[],a=kG(e,t),i=lI(e),s=uI(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=GG(t.existingMaterialSlots),l=[],m=new Map;for(let f=0;f<r.length;f+=1){let g=r[f],b=Number.isInteger(g?.mesh)?g.mesh:-1;if(b<0||b>=n.length)continue;let S=mI(r,s,c,f);if(!S)continue;let y=n[b],I=Array.isArray(y?.primitives)?y.primitives:[],E=$G(g,y,S),D=fI(y),x=pI(s,f);for(let N=0;N<I.length;N+=1){let B=I[N],p=LG(B,o),A=dI({ownerNodePath:S,nodeIndex:f,meshIndex:b,primitiveIndex:N}),h=gI(B,d),R=bI(B,d),K=I.length>1?`${E} / Primitive ${N}`:E,ne={ownerNodePath:S,nodeIndex:f,nodeIndexPath:x,meshIndex:b,primitiveIndex:N,...D?{sourceMeshName:D}:{},...p.index>=0?{sourceMaterialIndex:p.index}:{},...Number.isFinite(h)?{triangleCount:h}:{},...R?{boundingBox:R}:{}};if(p.index>=0){let _=m.get(p.index)??{label:K,materialName:p.name,sourceSurfaces:[]};_.sourceSurfaces.push(ne),m.set(p.index,_);continue}l.push({slotId:u.byExactSource.get(A)??jG({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:b,primitiveIndex:I.length>1?N:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,g]of m){let b=g.sourceSurfaces.sort(sI);l.push({slotId:u.bySourceMaterialIndex.get(f)??NG({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:g.label,sourceSurfaces:b,...g.materialName?{materialName:g.materialName,materialNames:[g.materialName]}:{},...OG(a,[f])})}return l.sort(wG)}function wG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return sI(r,n)}function sI(e,t){let r=String(e?.ownerNodePath??"").localeCompare(String(t?.ownerNodePath??""));if(r!==0)return r;let n=Number.isInteger(e?.nodeIndex)?e.nodeIndex:-1,o=Number.isInteger(t?.nodeIndex)?t.nodeIndex:-1;if(n!==o)return n-o;let a=Number.isInteger(e?.meshIndex)?e.meshIndex:-1,i=Number.isInteger(t?.meshIndex)?t.meshIndex:-1;if(a!==i)return a-i;let s=Number.isInteger(e?.primitiveIndex)?e.primitiveIndex:-1,c=Number.isInteger(t?.primitiveIndex)?t.primitiveIndex:-1;return s-c}function kG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=RG(e,o,t);a&&n.push(a)}return n}function OG(e,t){if(!t.length||!e.length)return{};let r=new Map(e.map(o=>[o.sourceMaterialIndex,o])),n=t.map(o=>r.get(o)).filter(Boolean);return n.length>0?{sourceMaterialProfiles:n}:{}}function RG(e,t,r={}){let n=Array.isArray(e?.materials)?e.materials[t]:null;if(!n||typeof n!="object")return null;let o={},a=[],i=n.pbrMetallicRoughness&&typeof n.pbrMetallicRoughness=="object"?n.pbrMetallicRoughness:{},s={},c=Array.isArray(i.baseColorFactor)?i.baseColorFactor:null,d=tI(c);d&&(s.color=d);let u=pi(e,i.baseColorTexture,r,"baseColor.texture",s,"texture",a);Object.keys(s).length>0&&(o.baseColor={...s,brightness:1,saturation:1,contrast:1,hue:0});let l={};pi(e,n.normalTexture,r,"normal.texture",l,"texture",a),Number.isFinite(n.normalTexture?.scale)?l.strength=n.normalTexture.scale:l.texture&&(l.strength=1),Object.keys(l).length>0&&(o.normal=l),o.metallic=Number.isFinite(i.metallicFactor)?i.metallicFactor:1,o.roughness=Number.isFinite(i.roughnessFactor)?i.roughnessFactor:1;let m={};pi(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};pi(e,n.occlusionTexture,r,"occlusion.texture",f,"texture",a),Number.isFinite(n.occlusionTexture?.strength)?f.strength=n.occlusionTexture.strength:f.texture&&(f.strength=1),Object.keys(f).length>0&&(o.occlusion=f);let g={},b=tI(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),S=b&&(b.r!==0||b.g!==0||b.b!==0);S&&(g.color=b),pi(e,n.emissiveTexture,r,"emission.texture",g,"texture",a),S&&(g.intensity=1),Object.keys(g).length>0&&(o.emission=g);let y={},I=cI(n.alphaMode);if(I&&(y.mode=I),(I==="mask"||I==="blend")&&(c&&Number.isFinite(c[3])&&c[3]!==1&&(y.opacity=c[3]),Number.isFinite(n.alphaCutoff)?y.cutoff=n.alphaCutoff:I==="mask"&&(y.cutoff=.5),u.texture&&(y.texture=structuredClone(u.texture)),u.hint&&a.push({...u.hint,profilePath:"alpha.texture"})),Object.keys(y).length>0&&(o.alpha=y),Object.keys(o).length===0&&a.length===0)return null;let E=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";return{sourceMaterialIndex:t,...E?{materialName:E}:{},...Object.keys(o).length>0?{profile:o}:{},...a.length>0?{textureHints:a}:{}}}function tI(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?{r:t,g:r,b:n}:null}function cI(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function pi(e,t,r,n,o,a,i){let s=CG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function CG(e,t,r,n){let o=pe(t)?t:{},a=Number.isInteger(o.index)?o.index:-1;if(a<0)return{};let i=Array.isArray(e?.textures)?e.textures:[],s=Array.isArray(e?.images)?e.images:[],c=i[a],d=vG(c),u=d.imageIndex,l=u>=0?s[u]:null,m=typeof l?.uri=="string"?l.uri.trim():"",f=/^data:/i.test(m),g={profilePath:n,textureIndex:a,...u>=0?{imageIndex:u}:{},...d.previewImageIndex>=0?{previewImageIndex:d.previewImageIndex}:{},...m&&!f?{uri:m}:{},...Number.isInteger(l?.bufferView)?{bufferView:l.bufferView}:{},...typeof l?.mimeType=="string"&&l.mimeType.trim()?{mimeType:l.mimeType.trim()}:{}};if(l?.bufferView!=null)return{hint:{...g,reason:"embedded-texture"}};if(!m)return{hint:{...g,reason:"missing-image-uri"}};if(f)return{hint:{...g,reason:"embedded-texture"}};if(/^https?:\/\//i.test(m)||m.startsWith("/"))return{texture:{url:m}};let b=m;try{b=decodeURIComponent(m)}catch{return{hint:{...g,reason:"unresolved-external-texture"}}}let S=mt.dirname(String(r.sourcePath??"")),y=mt.resolve(S,b),I=r.assetsDir?mt.resolve(r.assetsDir):"",E=r.cwd?mt.resolve(r.cwd):"",D=I?mt.relative(I,y):"../";return I&&E&&D&&!D.startsWith("..")&&!mt.isAbsolute(D)?{texture:{url:`/${mt.relative(E,y).split(mt.sep).join("/")}`},hint:{...g,reason:"external-texture"}}:{hint:{...g,reason:"external-texture"}}}function vG(e){let t=pe(e)?e:{},r=pe(t.extensions)?t.extensions:{},n=Number.isInteger(t.source)?t.source:-1,o=pe(r.KHR_texture_basisu)?r.KHR_texture_basisu:{};if(Number.isInteger(o.source))return{imageIndex:o.source,previewImageIndex:n>=0&&n!==o.source?n:-1};let a=pe(r.EXT_texture_webp)?r.EXT_texture_webp:{};return Number.isInteger(a.source)?{imageIndex:a.source,previewImageIndex:-1}:{imageIndex:n,previewImageIndex:-1}}function GG(e){let t=new Map,r=new Map;if(!Array.isArray(e))return{byExactSource:t,bySourceMaterialIndex:new Map};for(let o of e){if(!pe(o))continue;let a=Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[],i=typeof o.slotId=="string"?o.slotId.trim():"";if(!i)continue;let s=new Set;for(let c of a){if(!pe(c))continue;let d=typeof c.ownerNodePath=="string"?c.ownerNodePath.trim().replace(/^\/+|\/+$/g,""):"",u=Number.isInteger(c.nodeIndex)?c.nodeIndex:-1,l=Number.isInteger(c.meshIndex)?c.meshIndex:-1,m=Number.isInteger(c.primitiveIndex)?c.primitiveIndex:-1;a.length===1&&d&&u>=0&&l>=0&&m>=0&&t.set(dI({ownerNodePath:d,nodeIndex:u,meshIndex:l,primitiveIndex:m}),i),Number.isInteger(c.sourceMaterialIndex)&&c.sourceMaterialIndex>=0&&s.add(c.sourceMaterialIndex)}if(s.size===1){let[c]=s,d=r.get(c)??[];d.push(i),r.set(c,d)}}let n=new Map;for(let[o,a]of r)a.length===1&&n.set(o,a[0]);return{byExactSource:t,bySourceMaterialIndex:n}}function dI(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function jG(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${yI(r)}`}function NG(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${yI(t)}`}function FG(e,t){if(t.textureUsage==="material"||t.usage==="material")return{usage:"material",materialTexture:!0,environmentTexture:!1};if(pe(t.capabilities)&&t.capabilities.materialTexture===!0)return{usage:"material",materialTexture:!0,environmentTexture:!1};if(t.textureUsage==="environment"||t.usage==="environment")return{usage:"environment",materialTexture:!1,environmentTexture:!0};if(pe(t.capabilities)&&t.capabilities.environmentTexture===!0)return{usage:"environment",materialTexture:!1,environmentTexture:!0};let r=mt.extname(e).toLowerCase();return[".env",".hdr",".dds",".ktx",".ktx2"].includes(r)?{usage:"environment",materialTexture:!1,environmentTexture:!0}:[".png",".jpg",".jpeg",".webp"].includes(r)?{usage:"material",materialTexture:!0,environmentTexture:!1}:null}function lI(e){let t=Array.isArray(e.scenes)?e.scenes:[],r=Number.isInteger(e.scene)?e.scene:0,n=t[r]??t[0];return Array.isArray(n?.nodes)?n.nodes.filter(Number.isInteger):[]}function uI(e){let t=new Map;for(let r=0;r<e.length;r+=1){let n=Array.isArray(e[r]?.children)?e[r].children:[];for(let o of n)Number.isInteger(o)&&!t.has(o)&&t.set(o,r)}return t}function mI(e,t,r,n){let o=[],a=n,i=new Set;for(;Number.isInteger(a)&&a>=0&&a<e.length;){if(i.has(a))return"";i.add(a),o.push(_G(e[a],a));let s=t.get(a);if(typeof s!="number"||!Number.isInteger(s))break;a=s}return o.reverse(),o.length>1&&r.has(a)&&o.shift(),o.filter(Boolean).join("/")}function _G(e,t){return(pe(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function $G(e,t,r){let n=pe(e)&&typeof e.name=="string"?e.name.trim():"",o=fI(t);return n||o||r.split("/").filter(Boolean).pop()||r}function fI(e){return pe(e)&&typeof e.name=="string"?e.name.trim():""}function pI(e,t){let r=[],n=t,o=new Set;for(;Number.isInteger(n)&&n>=0;){if(o.has(n))return[];o.add(n),r.push(n);let a=e.get(n);if(!Number.isInteger(a))break;n=a}return r.reverse(),r}function LG(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.material)?r.material:-1,o=n>=0?t[n]:null,a=typeof o?.name=="string"&&o.name.trim()?o.name.trim():"";return{index:n,name:a}}function gI(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=SI(r),a=n>=0?t[n]:null,i=o>=0?t[o]:null,s=Number.isFinite(a?.count)?Number(a.count):Number.isFinite(i?.count)?Number(i.count):null;if(s==null)return null;let c=Number.isInteger(r.mode)?r.mode:4;return c===4?Math.floor(s/3):c===5||c===6?Math.max(0,s-2):0}function bI(e,t){let r=pe(e)?e:{},n=SI(r),o=n>=0?t[n]:null,a=rI(o?.min),i=rI(o?.max);return a&&i?{min:a,max:i}:null}function SI(e){let t=pe(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function rI(e){if(!Array.isArray(e)||e.length<3)return null;let t=Number(e[0]),r=Number(e[1]),n=Number(e[2]);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?[t,r,n]:null}function pe(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function yI(e){let t=String(e??""),r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}import od from"node:crypto";import{constants as HG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import bi from"node:fs/promises";import Rt from"node:path";async function EI(e,t={}){try{let r=await zG(e);if(!r)return[];let n=Array.isArray(r.gltf.images)?r.gltf.images:[],o=t.imageIndexes?new Set(t.imageIndexes.filter(i=>Number.isInteger(i)&&i>=0)):null,a=[];for(let i=0;i<n.length;i+=1){if(o&&!o.has(i))continue;let s=ft(n[i]);if(!s)continue;let c=await BG(e,r,s);if(!c)continue;let d=Si(s.name)??(c.originalFileName?Rt.parse(c.originalFileName).name:null)??void 0;a.push({imageIndex:i,bytes:c.bytes,extension:c.extension,mimeType:c.mimeType,...d?{displayName:d}:{},...c.originalFileName?{originalFileName:c.originalFileName}:{}})}return a}catch{return[]}}function II(e){let t=new Set;for(let r of TI(e)){let n=Pr(r.imageIndex),o=Pr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function PI(e){let t=new Map;for(let r of TI(e)){let n=Pr(r.imageIndex),o=Pr(r.previewImageIndex);n==null||o==null||n===o||t.set(`${n}:${o}`,{imageIndex:n,previewImageIndex:o})}return[...t.values()].sort((r,n)=>r.imageIndex-n.imageIndex||r.previewImageIndex-n.previewImageIndex)}function TI(e){if(!e)return[];let t=[],r=Array.isArray(e.materialSlots)?e.materialSlots:[];for(let n of r){let o=ft(n),a=Array.isArray(o?.sourceMaterialProfiles)?o.sourceMaterialProfiles:[];for(let i of a){let s=ft(i),c=Array.isArray(s?.textureHints)?s.textureHints:[];for(let d of c){let u=ft(d);u&&t.push(u)}}}return t}function xI(e,t){if(!e||t.length===0)return e;let r=new Map(t.map(i=>[i.imageIndex,i.textureAssetId])),n=structuredClone(e),o=Array.isArray(n.materialSlots)?n.materialSlots:[],a=!1;for(let i of o){let s=ft(i),c=Array.isArray(s?.sourceMaterialProfiles)?s.sourceMaterialProfiles:[];for(let d of c){let u=ft(d);if(!u)continue;let l=Array.isArray(u.textureHints)?u.textureHints:[];if(l.length===0)continue;let m=[];for(let f of l){let g=ft(f),b=Pr(g?.imageIndex),S=Si(g?.profilePath),y=b==null?null:r.get(b)??null;if(!y||!S||!UG(S)){m.push(f);continue}let I=ft(u.profile)??{};KG(I,S,{textureAssetId:y}),u.profile=I,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function zG(e){let t=Rt.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await bi.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>hI(e,ft(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await bi.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let n=null,o=[],a=12;for(;a+8<=r.length;){let c=r.readUInt32LE(a),d=r.readUInt32LE(a+4);if(a+=8,a+c>r.length)return null;let u=r.subarray(a,a+c);d===1313821514?n=JSON.parse(u.toString("utf8").replace(/\0+$/g,"")):d===5130562&&o.push(Buffer.from(u)),a+=c}if(!n)return null;let i=Array.isArray(n.buffers)?n.buffers:[],s=await Promise.all(i.map(async(c,d)=>{let u=ft(c);return Si(u?.uri)?hI(e,u):o[d]??(d===0?o[0]??null:null)}));return s.length===0&&o.length>0&&s.push(o[0]),{gltf:n,buffers:s}}async function hI(e,t){let r=Si(t?.uri);if(!r)return null;let n=MI(r);if(n)return n.bytes;if(Zm(r))return null;let o=DI(r);return o?AI(e,o):null}async function BG(e,t,r){let n=Si(r.uri);if(n){let f=MI(n);if(f){let I=Ym(f.bytes);return I?{bytes:f.bytes,...I}:null}if(Zm(n))return null;let g=DI(n);if(!g)return null;let b=await AI(e,g);if(!b)return null;let S=Rt.basename(g),y=Ym(b);return y?{bytes:b,...y,originalFileName:S}:null}let o=Pr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ft(a[o]),s=Pr(i?.buffer)??0,c=t.buffers[s],d=Pr(i?.byteOffset)??0,u=Pr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=Ym(l);return m?{bytes:l,...m}:null}async function AI(e,t){if(Rt.isAbsolute(t)||Rt.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await bi.realpath(Rt.dirname(e)),n=Rt.resolve(r,t),o=await bi.realpath(n);return VG(r,o)?await bi.readFile(o):null}catch{return null}}function DI(e){if(Zm(e))return null;try{return decodeURIComponent(e)}catch{return null}}function VG(e,t){let r=Rt.relative(e,t);return r===""||!r.startsWith(`..${Rt.sep}`)&&r!==".."&&!Rt.isAbsolute(r)}function MI(e){let t=/^data:([^;,]+)?(?:;[^,]*)?,(.*)$/is.exec(e);if(!t)return null;let r=e.slice(0,e.indexOf(","));try{return{bytes:r.toLowerCase().includes(";base64")?Buffer.from(t[2]??"","base64"):Buffer.from(decodeURIComponent(t[2]??""),"utf8")}}catch{return null}}function Ym(e){return e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?{extension:".png",mimeType:"image/png"}:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{extension:".jpg",mimeType:"image/jpeg"}:e.length>=12&&e.toString("ascii",0,4)==="RIFF"&&e.toString("ascii",8,12)==="WEBP"?{extension:".webp",mimeType:"image/webp"}:e.length>=12&&e.subarray(0,12).equals(Buffer.from([171,75,84,88,32,50,48,187,13,10,26,10]))?{extension:".ktx2",mimeType:"image/ktx2"}:null}function UG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function KG(e,t,r){let n=t.split("."),o=e;for(let a=0;a<n.length-1;a+=1){let i=n[a],s=ft(o[i])??{};o[i]=s,o=s}o[n[n.length-1]]=r}function Zm(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/")||Rt.win32.isAbsolute(e)}function ft(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Si(e){return typeof e=="string"&&e.trim()?e.trim():null}function Pr(e){return Number.isInteger(e)&&e>=0?e:null}var U=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function $o(e,t,r={}){if(!t.payload&&!t.payloadData)throw new U("missing_payload_arg");let n=await nj(e,t),o=e.codeKeyPolicy??"legacy";if(o==="disabled"&&Object.prototype.hasOwnProperty.call(n,"codeKey"))throw new U("payload_code_key_disabled",{codeKeyPolicy:o,codeKey:n.codeKey});let a=v.resolve(e.cwd,String(n.sourcePath??n.assetPath??"")),i=XG(e,a);if(!i)throw new U(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:GI(e)});try{await W.access(a,HG.R_OK)}catch(h){let R=_o(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new U(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=ij(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Qt(e),d=await cf(a),u=Zc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new U("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});nf(u,a,"source_path");let l=aj(c,n,s,a,d,u,e),m=ie(n.assetName)??l?.originalFileName??v.basename(a),f=ie(n.guid);if(l&&f&&l.guid!==f)throw new U("payload_guid_must_match_existing_asset",{guid:f,existingGuid:l.guid,existingAssetId:l.assetId});let g=l?.guid??f??od.randomUUID(),b=ie(n.projectAssetId),S=Xc(u,g);if(l?.assetId&&l.assetId!==S)throw new U("manifest_asset_id_must_match_guid",{guid:g,assetId:l.assetId,expectedAssetId:S});if(b&&b!==S)throw new U("project_asset_id_must_match_guid",{guid:g,projectAssetId:b,expectedAssetId:S});let y=i===".gltf"?v.posix.join(S,v.basename(a)):`${S}${i}`,I=YG(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),E=hi(e,I,u,"target_path"),D=new Date().toISOString(),x=Rm(ie(n.displayName)??l?.displayName,m),N=nd({...nd(l?.external)??{},...s??{}}),B=!1,p=[],A=null;try{await W.mkdir(v.dirname(E),{recursive:!0});let h=QG(a,E),R=h||await FI(E),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,E),B=!l,i===".gltf"&&await WG(a,E));let _=await NI(e,{existing:l,payload:n,sourcePath:a,targetPath:E,kind:u,guid:g,assetId:S}),xr=He(l?.metadata),tr=He(_);if(u==="model"&&(xr.assetAnalysisStatus==="complete"||Object.keys(He(xr.assetAnalysis)).length>0)&&tr.assetAnalysisStatus==="unavailable")throw new U("source_asset_analysis_failed",{sourcePath:a,assetId:S,guid:g});if(u==="model"){let rr=await qG({config:e,manifest:c,metadata:_,sourcePath:a,sourceAssetId:S,sourceAssetGuid:g,sourceDisplayName:x,now:D});p=rr.createdPaths,_=xI(_,rr.references)}let Yr=af({...l??{},guid:g,assetId:S,kind:u,displayName:x,relativePath:I,originalFileName:m,...o==="legacy"?{codeKey:Cm(ie(n.codeKey)??ie(n.assetName)??l?.codeKey,m)}:{},...ie(n.category)?{category:ie(n.category)}:{},placeable:u==="texture"?!0:typeof n.placeable=="boolean"?n.placeable:l?.placeable??u==="model",...Fm(n.warmupCount)!=null?{warmupCount:Fm(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...Nm(n.materialMode)?{materialMode:Nm(n.materialMode)}:{},...jm(n.scale)?{defaults:{transform:{scale:jm(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:N,metadata:_,createdAt:l?.createdAt??D,updatedAt:K?D:l?.updatedAt??D});if(!Yr)throw new U("invalid_manifest_entry",{assetId:S,guid:g});A=Yr;let Ai=c.findIndex(rr=>rr.guid===g||rr.assetId===S);Ai>=0?c[Ai]=Yr:c.push(Yr),c.sort(dj),await fj(e,c)}catch(h){B&&await W.rm(i===".gltf"?v.dirname(E):E,{recursive:i===".gltf",force:!0}).catch(()=>{});for(let R of p)await W.rm(R,{force:!0}).catch(()=>{});throw h}return{ok:!0,guid:g,assetId:S,kind:u,...A?.contentHash?{contentHash:A.contentHash}:{},...A?.external?{external:A.external}:{},displayName:A?.displayName,originalFileName:A?.originalFileName,assetUrl:rj(e,I,u),targetPath:E,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function WG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new U("gltf_source_invalid_json")}let n=v.dirname(await W.realpath(e)),o=v.dirname(t),a=[...Array.isArray(r.buffers)?r.buffers:[],...Array.isArray(r.images)?r.images:[]],i=new Set;for(let s of a){let c=ie(He(s)?.uri);if(!c||c.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(c)||c.startsWith("//"))continue;let d;try{d=decodeURIComponent(c.split(/[?#]/,1)[0])}catch{continue}let u=d.replace(/\\/g,"/"),l=v.posix.normalize(u);if(!l||l==="."||l===".."||l.startsWith("../")||v.posix.isAbsolute(l)||i.has(l))continue;i.add(l);let m;try{m=await W.realpath(v.resolve(n,...l.split("/")))}catch{continue}try{Qm(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));Qm(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function Qm(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new U(r)}async function qG(e){let t=II(e.metadata),r=PI(e.metadata),n=await EI(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=[];try{for(let d of n){let u=yi(d.bytes),l=e.manifest.find(x=>x.kind==="texture"&&x.contentHash===u.contentHash&&He(He(x.metadata).capabilities).materialTexture!==!1&&He(x.metadata).textureUsage!=="environment");if(l){a.set(d.imageIndex,l),o.push({imageIndex:d.imageIndex,textureAssetId:l.assetId});continue}let m=uj(u.contentHash),f=Xc("texture",m),g=e.manifest.find(x=>x.guid===m||x.assetId===f);if(g)throw new U("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,contentHash:u.contentHash,conflictingAssetId:g.assetId,conflictingContentHash:g.contentHash});let b=`${f}${d.extension}`,S=jI(e.config,"texture",b),y=hi(e.config,S,"texture","derived_texture_target_path");if(await W.mkdir(v.dirname(y),{recursive:!0}),await FI(y)){let x=await cf(y);if(x.contentHash!==u.contentHash)throw new U("derived_texture_target_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,targetPath:y,contentHash:u.contentHash,existingContentHash:x.contentHash})}else await lj(y,d.bytes),i.push(y);let I=d.displayName?`${e.sourceDisplayName} / ${d.displayName}`:`${e.sourceDisplayName} Texture ${d.imageIndex+1}`,E=await NI(e.config,{existing:null,payload:{metadata:{textureUsage:"material",capabilities:{materialTexture:!0,environmentTexture:!1},derivedFrom:{kind:"gltf-image",sourceAssetId:e.sourceAssetId,sourceAssetGuid:e.sourceAssetGuid,imageIndex:d.imageIndex,mimeType:d.mimeType}}},sourcePath:y,targetPath:y,kind:"texture",guid:m,assetId:f}),D=af({guid:m,assetId:f,kind:"texture",displayName:I,relativePath:S,originalFileName:d.originalFileName??`${mj(I)}${d.extension}`,category:"Texture",placeable:!0,contentHash:u.contentHash,byteSize:u.byteSize,metadata:E,createdAt:e.now,updatedAt:e.now});if(!D)throw new U("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f});e.manifest.push(D),a.set(d.imageIndex,D),o.push({imageIndex:d.imageIndex,textureAssetId:f})}let s=new Map,c=new Map;for(let d of a.values())v.extname(d.relativePath).toLowerCase()===".ktx2"&&s.set(d.assetId,d);for(let d of r){let u=a.get(d.imageIndex),l=a.get(d.previewImageIndex);!u||!l||v.extname(u.relativePath).toLowerCase()!==".ktx2"||c.set(u.assetId,l.assetId)}for(let d of s.values()){let u=He(d.metadata),l=JG(u);delete l[e.sourceAssetId];let m=c.get(d.assetId);m&&(l[e.sourceAssetId]=m);let f=Object.fromEntries(Object.entries(l).sort(([S],[y])=>S.localeCompare(y))),g=Object.values(f)[0],b={...u};g?(b.previewTextureAssetId=g,b.previewTextureAssetIdsBySourceAssetId=f):(delete b.previewTextureAssetId,delete b.previewTextureAssetIdsBySourceAssetId),d.metadata=b}return{references:o,createdPaths:i}}catch(s){for(let c of i)await W.rm(c,{force:!0}).catch(()=>{});throw s}}function JG(e){let t={},r=He(e.previewTextureAssetIdsBySourceAssetId);for(let[a,i]of Object.entries(r)){let s=ie(a),c=ie(i);s&&c&&(t[s]=c)}if(Object.keys(t).length>0)return t;let n=ie(e.previewTextureAssetId),o=ie(He(e.derivedFrom).sourceAssetId);return n&&o&&(t[o]=n),t}async function tf(e,t={}){let r=await vI(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function rf(e,t={}){return vI(e,t,!0)}async function vI(e,t,r){let n=await Qt(e),o=[],a=[];for(let i of n){let s=hi(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await cf(s)}catch(m){let f=wI(i,m,t,"source-audit",s);if(!r||!f)throw kI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&He(i.metadata).assetMetadataVersion!==Xm,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await $o(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=wI(i,m,t,"source-analysis",s);if(!r||!f)throw kI(f,m,s);a.push(f);continue}if(!l.contentHash)throw new U("asset_refresh_missing_content_hash",{assetId:i.assetId,guid:i.guid,sourcePath:s});o.push({guid:i.guid,assetId:i.assetId,kind:i.kind,...i.contentHash?{previousContentHash:i.contentHash}:{},contentHash:l.contentHash})}return{ok:!0,scannedAssetCount:n.length,refreshedAssets:o,availabilityIssues:a}}function wI(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof U?t.message:void 0,s=_o(t)?t.code:t instanceof U?ie(t.details.nodeCode):void 0,c=i===a||i==="source_file_not_found"||i==="source_file_unreadable"||i==="source_asset_analysis_failed"||i==="gltf_source_invalid_json",d=_o(t)&&typeof t.path=="string"?v.resolve(t.path):null;if(!c&&(!s||n!=="source-audit"&&d!==v.resolve(o)))return null;let u=i==="source_asset_analysis_failed"?"analysis-failed":i==="gltf_source_invalid_json"?"invalid":s==="ENOENT"||i===a||i==="source_file_not_found"?"missing":s==="EACCES"||s==="EPERM"||i==="source_file_unreadable"?"unreadable":s==="EISDIR"||s==="EINVAL"?"invalid":"audit-failed",l=i??(u==="missing"?a:u==="unreadable"?"source_file_unreadable":u==="invalid"?"source_file_invalid":"source_file_audit_failed");return{assetId:e.assetId,guid:e.guid,kind:e.kind,relativePath:e.relativePath,stage:n,reason:u,code:l,...s?{nodeCode:s}:{},retryable:!0}}function kI(e,t,r){return!e||t instanceof U?t:new U(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Qt(e){let t=await of(e.manifestPath,[]);if(!Array.isArray(t))throw new U("manifest_invalid_root",{manifestPath:e.manifestPath});let r=t.map((i,s)=>{let c=af(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:e.manifestPath});return c}),n=new Set,o=new Set,a=e.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:e.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new U("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new U("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function Lo(e){return e.loadRules?e.loadRules():e.rulesPath?of(e.rulesPath,{}):{}}function OI(e){return(Array.isArray(e)?e:[e]).filter(r=>typeof r=="string"&&!!r.trim()).map(r=>{let n=r.trim().toLowerCase();return n.startsWith(".")?n:`.${n}`})}function GI(e){let t=OI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:OI(No)}function XG(e,t){let r=t.toLowerCase();return GI(e).find(n=>r.endsWith(n))??null}function YG(e,t){return t.existing?.relativePath?t.existing.relativePath:ZG(e,t.sourcePath,t.kind)??jI(e,t.kind,t.targetFileName)}function jI(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function ZG(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!RI(v.resolve(n),o)||RI(v.resolve(e.generatedDir),o)?null:(nf(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function RI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function QG(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function ej(e,t,r){let n=v.relative(e,t);if(n.startsWith("..")||v.isAbsolute(n))throw new U(`${r}_outside_allowed_directory`,{parent:e,child:t})}function tj(e,t,r){let n=v.relative(e,t);if(!n.startsWith("..")&&!v.isAbsolute(n))throw new U(`${r}_inside_forbidden_directory`,{parent:e,child:t})}function hi(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return ej(a,o,n),tj(v.resolve(e.generatedDir),o,n),nf(r,o,n),o}function rj(e,t,r){let n=hi(e,t,r,"asset_url_path");return typeof e.publicUrlForCatalogRelativePath=="function"?e.publicUrlForCatalogRelativePath(t):typeof e.publicUrlForRelativePath=="function"?e.publicUrlForRelativePath(t):`/${v.relative(e.cwd,n).split(v.sep).join("/")}`}function nf(e,t,r){let n=v.extname(t).toLowerCase(),o=vm(e);if(!o.includes(n))throw new U(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function of(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(_o(r)&&r.code==="ENOENT")return t;throw r}}async function nj(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await of(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new U("invalid_payload_json",{payloadPath:r});return n}function af(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?sf:ie,o=n(r.guid),a=n(r.assetId),i=n(r.kind);if(t&&(!i||"assetKind"in r||"assetType"in r))return null;let s=t?wm.includes(i)?i:null:Zc(r.kind??r.assetKind??r.assetType,r.relativePath),c=n(r.displayName),d=n(r.relativePath);if(!o||!a||!s||!c||!d||t&&(!_n(r,"originalFileName")||!_n(r,"codeKey")||!_n(r,"category")||!_n(r,"materialMode")||!_n(r,"contentHash")||!_n(r,"createdAt")||!_n(r,"updatedAt")||"placeable"in r&&typeof r.placeable!="boolean"||"warmupCount"in r&&(!Number.isInteger(r.warmupCount)||r.warmupCount<0)||"singleton"in r&&typeof r.singleton!="boolean"||"defaults"in r&&qr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&qr(r.metadata)==null||"external"in r&&!oj(r.external)))return null;let u=qr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),g=n(r.materialMode),b=qr(r.defaults),S=n(r.contentHash),y=nd(r.external),I=n(r.createdAt),E=n(r.updatedAt);return{guid:o,assetId:a,kind:s,displayName:c,relativePath:d,...l?{originalFileName:l}:{},...m?{codeKey:m}:{},...f?{category:f}:{},...typeof r.placeable=="boolean"?{placeable:r.placeable}:{},...typeof r.warmupCount=="number"?{warmupCount:r.warmupCount}:{},...typeof r.singleton=="boolean"?{singleton:r.singleton}:{},...g?{materialMode:g}:{},...b?{defaults:b}:{},...S?{contentHash:S}:{},...typeof r.byteSize=="number"?{byteSize:r.byteSize}:{},...y?{external:y}:{},...u?{metadata:u}:{},...I?{createdAt:I}:{},...E?{updatedAt:E}:{}}}function sf(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function _n(e,t){return!(t in e)||sf(e[t])!=null}function oj(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=["platformAssetId","assetPath","assetUrl"],n=Object.keys(t);return n.length>0&&n.every(o=>r.includes(o)&&sf(t[o])!=null)}function nd(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=ie(r.platformAssetId),o;try{if(o=ei(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new U("external_asset_path_must_be_portable",{assetPath:ie(r.assetPath)})}let a=ie(r.assetUrl);return!n&&!o&&!a?null:{...n?{platformAssetId:n}:{},...o?{assetPath:o}:{},...a?{assetUrl:a}:{}}}function qr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function NI(e,t){let r=qr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:qr(t.existing?.metadata),payloadMetadata:r}),o=qr(n);return o||null}return gi({kind:t.kind,sourcePath:t.sourcePath,existingMetadata:qr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function aj(e,t,r,n,o,a,i){let s=ie(t.guid),c=ie(t.projectAssetId);if(s){let l=e.find(m=>m.guid===s);if(l)return l}if(c){let l=e.find(m=>m.assetId===c);if(l)return l}if(r?.platformAssetId){let l=e.find(m=>m.kind===a&&sj(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&cj(m.external)===r.assetPath);if(l)return l}let d=v.resolve(n),u=e.find(l=>{if(l.kind!==a)return!1;try{return v.resolve(hi(i,l.relativePath,l.kind,"manifest_asset_path"))===d}catch{return!1}});if(u)return u;if(o.contentHash){let l=e.find(m=>m.kind===a&&m.contentHash===o.contentHash);if(l)return l}return null}function ij(e){return nd({...e.external&&typeof e.external=="object"&&!Array.isArray(e.external)?e.external:{},platformAssetId:e.external?.platformAssetId??e.platformAssetId??e.assetId,assetUrl:e.external?.assetUrl??e.assetUrl},!0)}function sj(e){return ie(He(e).platformAssetId)}function cj(e){return ie(He(e).assetPath)}function dj(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function ef(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!_o(n)||n.code!=="ENOENT")throw n}let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{return await W.writeFile(r,t),await W.rename(r,e),!0}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function lj(e,t){let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{await W.writeFile(r,t),await W.rename(r,e)}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function cf(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...yi(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...yi(t),byteSize:r.size}}let o=v.dirname(await W.realpath(e)),a=new Map;for(let d of[...Array.isArray(n.buffers)?n.buffers:[],...Array.isArray(n.images)?n.images:[]]){let u=ie(He(d)?.uri);if(!u||u.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(u)||u.startsWith("//"))continue;let l;try{l=decodeURIComponent(u.split(/[?#]/,1)[0])}catch{continue}let m=v.posix.normalize(l.replace(/\\/g,"/"));if(!m||m==="."||m===".."||m.startsWith("../")||v.posix.isAbsolute(m))continue;let f;try{f=await W.realpath(v.resolve(o,...m.split("/")))}catch{continue}try{Qm(o,f,"gltf_dependency_path_escape")}catch{continue}a.set(m,f)}let i=od.createHash("sha256").update("playable-editor-gltf-bundle-v1\0"),s=[{path:"",...yi(t)}],c=r.size;for(let[d,u]of[...a].sort(([l],[m])=>l.localeCompare(m))){let l=await W.readFile(u);s.push({path:d,...yi(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function yi(e){return{contentHash:`sha256:${od.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function uj(e){let t=od.createHash("sha256").update(`material-texture\0${e}`).digest("hex");return`${t.slice(0,8)}-${t.slice(8,12)}-5${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function mj(e){return e.trim().replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^_+|_+$/g,"")||"Imported_Texture"}async function FI(e){try{return await W.access(e),!0}catch{return!1}}async function fj(e,t){let r=QE(t,{codeKeyPolicy:e.codeKeyPolicy??"legacy"});await W.mkdir(v.dirname(e.manifestPath),{recursive:!0}),await W.mkdir(v.dirname(e.registryPath),{recursive:!0});let n=await CI(e.manifestPath),o=await CI(e.registryPath);try{await ef(e.manifestPath,`${JSON.stringify(t,null,2)}
13
+ `),await ef(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await pj(s,c)}catch(d){i.push(d)}if(i.length>0){let s=new Error("generated_registry_transaction_rollback_failed");throw s.cause=a,s.rollbackErrors=i,s}throw a}}async function CI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(_o(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function pj(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await ef(e,t.content)}}function ie(e){return typeof e=="string"&&e.trim()?e.trim():null}function He(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function _o(e){return e instanceof Error&&"code"in e}function _I(e){return{async loadManifest(){let t=await Qt(e.assetRegistryConfig),r=e.textureRegistryConfig?await Qt(e.textureRegistryConfig):[];return{ok:!0,manifest:t,textureManifest:r}},async loadEditorAssetLibrary(){let t=await e.loadAssetCatalogEntries(),r=[...e.createAssetLibrary?e.createAssetLibrary(t):Eo(t)];return{ok:!0,...Tn(t,r),summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):gj(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await Lo(r),o=yj(n.errorCodes),a=await Qt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await $o(r,{payloadData:{...t,sourcePath:t.assetPath}},o):null,c=s?.assetId??i;if(!c)throw new Error("asset_import_result_missing_asset_id");s&&await Sj(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Eo(d)],l=Tn(d,u),m=u.find(f=>f.assetId===c||f.id===c);if(!m)throw new Error("asset_import_catalog_projection_missing");return{ok:!0,assetId:c,asset:m,assets:l.assets,resourceProjection:l.resourceProjection,disposition:s&&a.some(f=>f.assetId===c)?"deduplicated":s?"created":"existing"}}}}function gj(e,t,r){return r&&bj(e)?r:t}function bj(e){let t=typeof e.assetType=="string"?e.assetType.toLowerCase():"";if(/^(texture|image|png|jpg|jpeg|webp)$/.test(t))return!0;let r=typeof e.kind=="string"?e.kind.toLowerCase():"";if(/^(texture|image)$/.test(r)||(typeof e.mimeType=="string"?e.mimeType.toLowerCase():"").startsWith("image/"))return!0;let o=[e.sourcePath,e.assetPath,e.assetName].filter(a=>typeof a=="string").join(`
14
+ `);return/\.(png|jpe?g|webp)(?:$|[?#])/i.test(o)}async function Sj(e,t,r){if(!e.invalidateFiles)return;let n=typeof e.additionalInvalidationFiles=="function"?await e.additionalInvalidationFiles():e.additionalInvalidationFiles??[],o=new Set([...n,r.manifestPath||t.manifestPath,r.registryPath||t.registryPath]);await e.invalidateFiles([...o])}function yj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function df(e,t={}){let r=[],n=0;for await(let o of e){let a=Buffer.from(o);if(n+=a.byteLength,t.maxBytes!==void 0&&n>t.maxBytes)throw Object.assign(new Error("asset_import_payload_too_large"),{code:"asset_import_payload_too_large",details:{maxBytes:t.maxBytes}});r.push(a)}return JSON.parse(Buffer.concat(r).toString("utf8")||"{}")}function Jr(e,t,r){if(e.statusCode=t.statusCode,Ei(e,r),t.body==null){e.end();return}e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(t.body))}function Ei(e,t={}){e.setHeader("Access-Control-Allow-Origin",t.origin??"*"),e.setHeader("Access-Control-Allow-Methods",t.methods??"GET,POST,OPTIONS"),e.setHeader("Access-Control-Allow-Headers",t.headers??"Content-Type, Authorization"),e.setHeader("Cross-Origin-Resource-Policy",t.resourcePolicy??"cross-origin"),e.setHeader("Cross-Origin-Embedder-Policy",t.embedderPolicy??"credentialless"),e.setHeader("Cache-Control",t.cacheControl??"no-store")}import{existsSync as KI,readFileSync as HI}from"node:fs";import{mkdir as LI,rename as Tj,rm as zI,writeFile as xj}from"node:fs/promises";import{randomUUID as Aj}from"node:crypto";import $n from"node:path";import hj from"node:path";var ad=new Map;async function id(e,t){let r=[...new Set(e.map(i=>hj.resolve(i)))].sort(),n=[...new Set(r.map(i=>ad.get(i)).filter(Boolean))],o=()=>{},a=new Promise(i=>{o=i});for(let i of r)ad.set(i,a);await Promise.all(n);try{return await t()}finally{o();for(let i of r)ad.get(i)===a&&ad.delete(i)}}import{performance as lf}from"node:perf_hooks";var Ej=1,Ij=["prepare","compile","validate","stringify","write","checkpoint"];function $I(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:uf(lf.now()-n),rssBeforeBytes:o.rss,rssAfterBytes:a.rss,maxObservedRssBytes:Math.max(o.rss,a.rss),heapUsedBeforeBytes:o.heapUsed,heapUsedAfterBytes:a.heapUsed,maxObservedHeapUsedBytes:Math.max(o.heapUsed,a.heapUsed)})};return{measure(r,n){let o=process.memoryUsage(),a=lf.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=lf.now();try{return await n()}finally{t(r,a,o)}},snapshot(){return Pj(e)}}}function Pj(e){let t=new Map;for(let n of e){let o=t.get(n.phase);if(!o){t.set(n.phase,{...n});continue}o.durationMs=uf(o.durationMs+n.durationMs),o.rssAfterBytes=n.rssAfterBytes,o.maxObservedRssBytes=Math.max(o.maxObservedRssBytes,n.maxObservedRssBytes),o.heapUsedAfterBytes=n.heapUsedAfterBytes,o.maxObservedHeapUsedBytes=Math.max(o.maxObservedHeapUsedBytes,n.maxObservedHeapUsedBytes)}let r=Ij.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:Ej,measuredDurationMs:uf(r.reduce((n,o)=>n+o.durationMs,0)),maxObservedRssBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedRssBytes),0),maxObservedHeapUsedBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedHeapUsedBytes),0),phases:r}}function uf(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function WI(e){let t=e.paths,r=Ii(t.editorScenePath),n=r?ga(r).document:null,o=Ii(t.scenePath),a=await e.loadServices(e.server,e.projectRoot),i=e.loadEditorAssetLibrarySnapshot?await e.loadEditorAssetLibrarySnapshot(e.server,"report"):{assets:await e.listEditorAssetLibrary(e.server,"report"),resourceProjection:{schemaVersion:1,entries:[]}},s=i.assets;n&&cm(n),n&&va(n,s);let c=n?a.ensureEditorSceneEnvironmentDefaults(a.enrichEditorSceneDocumentAssets(a.ensureAuthoringSource(n),s)):null;c&&Oc(c);let d=t.renderingConfigPath?Ii(t.renderingConfigPath):void 0;d&&St(d);let u={...Wr(c),...t.renderingConfigPath?{rendering:d}:{}},l=YI(t.shadowsConfigPath),m=ce(o),f=typeof m?.version=="number"?m.version:void 0,g=typeof m?.updatedAt=="string"?m.updatedAt:void 0;return{ok:!0,editorScenePath:t.editorScenePath,scenePath:t.scenePath,editorScene:c,assets:s,resourceProjection:i.resourceProjection,...f===void 0?{}:{version:f},...g===void 0?{}:{updatedAt:g},...Object.keys(u).length>0?{companionConfigs:u}:{},...l?{shadowMapExperimentConfig:l}:{},drift:c?a.detectRuntimeInputDrift(c,o):null,summary:XI(c)}}async function qI(e){Ln(e),VI(e.body,"$",!0),VI(e.rawEditorScene,"$.editorScene");let t=$m(e.body),r=Wr(e.body),n=Object.prototype.hasOwnProperty.call(r,"rendering");t&&St(t);let o=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig");if(o&&ZI(e.body),o&&!e.paths.shadowsConfigPath)throw new Error("shadows_config_path_missing");let a=[e.paths.editorScenePath,...e.saveMode==="local-commit-save"?[e.paths.scenePath]:[],...n&&e.paths.renderingConfigPath?[e.paths.renderingConfigPath]:[],...o&&e.paths.shadowsConfigPath?[e.paths.shadowsConfigPath]:[]];return id(a,()=>(Ln(e),Dj(e)))}async function Dj(e){let t=$I(),r=t.measure("prepare",()=>Mj(e)),n=ga(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Ln(e);let a=e.paths,i=Wr(e.body),s=$m(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,Fn),u=i[Fn],l=wr(u),m=t.measure("prepare",()=>Ii(a.scenePath)??{}),f=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig"),b=ZI(e.body)??YI(a.shadowsConfigPath);t.measure("validate",()=>{mf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let S=Wr(n),y=S[Fn];t.measure("validate",()=>{mf(y,wr(y),{present:Object.prototype.hasOwnProperty.call(S,Fn),path:"$.editorScene.companionConfigs.staticShadows"})});let I=ce(m)?.staticShadows;t.measure("validate",()=>{mf(I,wr(I),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),cm(n)});let E=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,D=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Ln(e),t.measure("validate",()=>{va(n,D)});let x=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),D));return kc(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(x),o.assertEditorSceneMaterialAssetIntegrity(x)});let N=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(x)),B=d?l:l??RE(n)??wr(ce(m)?.staticShadows),p=t.measure("prepare",()=>kc(wj(N,{staticShadows:B}),4)),A=t.measure("prepare",()=>ou(p,D)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig(N,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:b??null})),R=B?{...h.sceneConfig,staticShadows:B}:{...h.sceneConfig};B||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,_=new Date().toISOString(),xr=t.measure("compile",()=>kc(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:_}:R,4));t.measure("validate",()=>{Ui(xr)});let tr=ce(xr)?.version,Yr=e.saveMode==="local-commit-save"&&typeof tr=="number"?tr:ne,Ai=`/${$n.relative(e.projectRoot,a.scenePath).split($n.sep).join("/")}?v=${encodeURIComponent(String(Yr))}`,rr="",Kn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(A,null,2)}
15
+ `);await t.measureAsync("write",()=>sd(e,Kn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Ln(e),await LI($n.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
+ `);await t.measureAsync("write",()=>sd(e,Kn,a.renderingConfigPath,xe))}else if(c&&!a.renderingConfigPath)throw new Error("rendering_config_path_missing");if(f){if(!a.shadowsConfigPath||!b)throw new Error("shadows_config_path_missing");await LI($n.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(b,null,2)}
17
+ `);await t.measureAsync("write",()=>sd(e,Kn,a.shadowsConfigPath,xe))}rr=t.measure("stringify",()=>`${JSON.stringify(xr,null,2)}
18
+ `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>sd(e,Kn,a.scenePath,rr)),Ln(e),await t.measureAsync("write",async()=>{for(let xe of Kn)await Tj(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await zI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(Kn.filter(xe=>!xe.committed).map(xe=>zI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let Df=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return Df.length>0&&e.invalidateFiles?.(e.server,Df),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:Yr,updatedAt:_,sceneUrl:Ai}:{},editorScene:p,...b?{shadowMapExperimentConfig:b}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:B}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(E??null)??null}:{}}:{},sceneJsonText:rr,performanceProfile:t.snapshot(),summary:{editorScene:XI(N),compiled:h.summary}}}async function sd(e,t,r,n){Ln(e);let o=$n.join($n.dirname(r),`.${$n.basename(r)}.${process.pid}.${Aj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await xj(o,n,{encoding:"utf8",signal:e.signal})}function Ln(e){if(!e.signal?.aborted&&(e.deadlineAt===void 0||Date.now()<e.deadlineAt))return;let t=new Error("Document export lifecycle deadline elapsed before filesystem persistence completed.");throw Object.assign(t,{code:"document_export_timeout"}),t}function Mj(e){let t=Ii(e.paths.editorScenePath);if(!t)return e.rawEditorScene;let r=BI(t);if(!r)return e.rawEditorScene;let n=BI(e.rawEditorScene),o=typeof e.body.expectedAuthoringSourceRevision=="number"&&Number.isFinite(e.body.expectedAuthoringSourceRevision)?e.body.expectedAuthoringSourceRevision:n?.revision??null;if(!(n?.sourceId===r.sourceId&&n.sourceType===r.sourceType)){let m={stage:e.saveMode==="prepare-platform-save"?"document.export":"document.save",expectedSourceId:r.sourceId,expectedSourceType:r.sourceType,actualSourceId:n?.sourceId??null,actualSourceType:n?.sourceType??null},f=new Error("authoring_source_identity_mismatch");throw Object.assign(f,{code:"authoring_source_identity_mismatch",details:m,...m}),f}if(n.revision===r.revision&&o===r.revision)return e.rawEditorScene;let i=ce(e.body.authoringSourceConflictResolution);if(i?.strategy==="overwrite"&&typeof i.expectedPersistedRevision=="number"&&Number.isFinite(i.expectedPersistedRevision)&&i.expectedPersistedRevision===r.revision){let l=structuredClone(e.rawEditorScene),m=ce(ce(l.meta)?.authoringSource);return m&&(m.revision=r.revision),l}let c=e.saveMode==="prepare-platform-save"?"document.export":"document.save",d={stage:c,sourceId:r.sourceId,sourceType:r.sourceType,expectedRevision:o,submittedRevision:n.revision,persistedRevision:r.revision},u=new Error("authoring_source_revision_mismatch");throw Object.assign(u,{code:"authoring_source_revision_mismatch",stage:c,sourceId:r.sourceId,expectedRevision:o,actualRevision:r.revision,details:d}),u}function BI(e){let t=ce(ce(e.meta)?.authoringSource);return typeof t?.sourceId!="string"||!t.sourceId.trim()||typeof t.sourceType!="string"||!t.sourceType.trim()||typeof t.revision!="number"||!Number.isFinite(t.revision)?null:{sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision}}function mf(e,t,r){if(!r.present||e==null||t)return;let n=new Error(`schema.unsupportedVersion: ${r.path}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:r.path}),n}function JI(e){Oc(e)}function XI(e){let t=ce(e),r=ce(t?.meta),n=ce(r?.authoringSource),o=ce(t?.scene);return{schemaVersion:t?.schemaVersion??null,sourceId:n?.sourceId??null,sourceType:n?.sourceType??null,revision:n?.revision??null,assets:Array.isArray(t?.assets)?t.assets.length:0,gameObjects:Array.isArray(o?.gameObjects)?o.gameObjects.length:0,materialAssets:Array.isArray(o?.materialAssets)?o.materialAssets.length:0}}function wj(e,t){let r={...Wr(e)};delete r.rendering;for(let[o,a]of Object.entries(t))a==null?delete r[o]:r[o]=a;let n={...e};return Object.keys(r).length>0?n.companionConfigs=r:delete n.companionConfigs,n}function Ii(e){return KI(e)?JSON.parse(HI(e,"utf8")||"{}"):null}function YI(e){if(!e)return null;if(!KI(e))throw new Error(`shadows_config_missing:${e}`);let t=JSON.parse(HI(e,"utf8")||"{}");return Gi(t,"$"),structuredClone(t)}function ZI(e){return Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentConfig")?(Gi(e.shadowMapExperimentConfig,"$.shadowMapExperimentConfig"),structuredClone(e.shadowMapExperimentConfig)):null}function VI(e,t,r=!1){let n=ce(e);if(!n)return;for(let a of["shadowMapExperimentConfig","shadowsConfig"])if(!(r&&a==="shadowMapExperimentConfig")&&Object.prototype.hasOwnProperty.call(n,a))throw UI(`${t}.${a}`);let o=ce(n.companionConfigs);if(o&&Object.prototype.hasOwnProperty.call(o,"shadows"))throw UI(`${t}.companionConfigs.shadows`)}function UI(e){let t=new Error(`shadow_map_experiment_config_readonly:${e}`);return Object.assign(t,{code:"shadowMapExperiment.configReadonly",path:e}),t}import xi from"node:path";import{pipeline as _j}from"node:stream/promises";import{realpathSync as kj}from"node:fs";import pf from"node:path";function zo(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of Oj(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function Oj(e){let t=pf.resolve(e),r=Pi(t);return[...new Set([e,t,r,ff(e),ff(t),ff(r)])]}function Pi(e){let t=pf.resolve(e);try{return kj(t)}catch{return t}}function ff(e){return e.split(pf.sep).join("/")}import{constants as QI}from"node:fs";import Ti from"node:fs/promises";import zn from"node:path";var Rj=128*1024*1024,Cj=512*1024*1024;async function Bo(e){let t=[];for(let n=0;n<2;n+=1)try{await e.close();return}catch(o){t.push(o)}let r=new Error("project_file_close_failed");throw r.errors=t,r}function vj(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||zn.posix.isAbsolute(t)||/^[A-Za-z]:\//.test(t))throw new Error("project_file_path_invalid");let r=t.split("/");if(r.some(n=>!n||n==="."||n===".."))throw new Error("project_file_path_invalid");return r.join("/")}function gf(e){if(e===void 0)return Rj;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,Cj)}async function cd(e,t){let r=vj(t),n=await Ti.realpath(zn.resolve(e)),o=zn.resolve(n,...r.split("/"));eP(n,o),await Gj(n,r);let a;try{a=await Ti.open(o,QI.O_RDONLY|(QI.O_NOFOLLOW??0))}catch(i){throw i?.code==="ELOOP"?new Error("project_file_symlink_unsupported"):i}try{let i=await a.stat();if(!i.isFile())throw new Error("project_file_not_found");let s=await Ti.realpath(o);if(eP(n,s),s!==o)throw new Error("project_file_symlink_unsupported");let c=await Ti.stat(s);if(c.dev!==i.dev||c.ino!==i.ino)throw new Error("project_file_changed_during_read");return{absolutePath:o,handle:a,relativePath:r,stat:i}}catch(i){try{await Bo(a)}catch(s){let c=new Error("project_file_close_failed");throw c.errors=[i,s],c}throw i}}function eP(e,t){let r=zn.relative(e,t);if(!r||r===".."||r.startsWith(`..${zn.sep}`)||zn.isAbsolute(r))throw new Error("project_file_path_invalid")}async function Gj(e,t){let r=e;for(let n of t.split("/"))if(r=zn.join(r,n),(await Ti.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import Tr from"node:fs/promises";import pt from"node:path";var tP=512*1024,jj=new Set([".DS_Store",".cache",".git",".next",".nuxt",".parcel-cache",".turbo",".vite","build","coverage","dist","dist-tests","node_modules","output","playwright-report","test-results"]);async function rP(e,t={}){let r=await Tr.realpath(pt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...jj,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=pt.resolve(r,c),u=await Nj(r,d);if(u){u.sort((l,m)=>Number(m.isDirectory())-Number(l.isDirectory())||l.name.localeCompare(m.name,void 0,{numeric:!0,sensitivity:"base"}));for(let l of u){if(l.name.startsWith(".")||o.has(l.name)||l.isSymbolicLink())continue;if(a.length>=n){i=!0;return}let m=pt.posix.join(c.split(pt.sep).join("/"),l.name),f=pt.resolve(r,...m.split("/")),g=await Fj(r,f);if(!g)continue;let b=g==="file"?pt.extname(l.name).slice(1).toLowerCase():"";a.push({path:m,name:l.name,parentPath:c?c.split(pt.sep).join("/"):null,kind:g,...b?{extension:b}:{}}),g==="directory"&&await s(m)}}};return await s(""),{rootName:pt.basename(r)||"Project",entries:a,truncated:i}}async function Nj(e,t){try{let r=await Tr.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await Tr.realpath(t);if(n!==t||!bf(e,n))return null;let o=await Tr.readdir(t,{withFileTypes:!0}),a=await Tr.lstat(t),i=await Tr.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!bf(e,i)?null:o}catch{return null}}async function nP(e,t,r={}){let n=await cd(e,t),{handle:o,relativePath:a,stat:i}=n;if(!CE(a))throw await Bo(o),new Error("project_file_preview_unsupported");let s=tP,c,d=0;try{s=Math.max(1,Math.min(r.maxBytes??tP,4*1024*1024));let l=Math.min(i.size,s);c=Buffer.alloc(l),l>0&&({bytesRead:d}=await o.read(c,0,l,0))}finally{await Bo(o)}let u=pt.basename(a);return{path:a,name:u,extension:Qc(u),language:Lm(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Fj(e,t){try{let r=await Tr.lstat(t);if(r.isSymbolicLink())return null;let n=await Tr.realpath(t);if(n===e||!bf(e,n)||n!==t)return null;let o=await Tr.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function bf(e,t){let r=pt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${pt.sep}`)&&!pt.isAbsolute(r)}var Sf="/__fps_editor_authoring";function oP(e){let t=Promise.resolve([]);return{name:e.name??"fps-editor-project-authoring-api",enforce:"post",apply:"serve",async configureServer(r){let n=e.createAssetAuthoringHandlers(r);e.getAuthoringWrittenFiles&&(t=e.getAuthoringWrittenFiles(r).then(o=>o.map(a=>xi.resolve(e.projectRoot,a))).then(async o=>($j(r,o),Lj(r.watcher,o),await r.watcher?.unwatch?.(o),e.logger?.log?.("[ProjectAuthoring][Vite] watcher and HMR suppressed for authoring-written files",o),o)).catch(o=>(e.logger?.warn?.("[ProjectAuthoring][Vite] failed to resolve authoring files for HMR suppression",o),[])),await t),r.middlewares.use(async(o,a,i)=>{let s=new URL(o.url??"","http://localhost"),c=s.pathname,d=c===Sf||c.startsWith(`${Sf}/`),u=d&&c.slice(Sf.length)||"/";if(d&&u==="/project-media"){if(Ei(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Jr(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Jr(a,{statusCode:400,body:{ok:!1,error:"missing_file_path"}});return}try{let f=await cd(e.projectRoot,m),g=null,b=null;try{let S=zm(f.relativePath);if(!S)throw new Error("project_file_media_unsupported");if(f.stat.size>gf(e.projectMediaMaxBytes))throw new Error("project_file_media_too_large");let y=xi.basename(f.relativePath);if(a.statusCode=200,a.setHeader("Content-Type",S.mimeType),a.setHeader("Content-Length",String(f.stat.size)),a.setHeader("Content-Disposition",`inline; filename*=UTF-8''${encodeURIComponent(y)}`),a.setHeader("X-Content-Type-Options","nosniff"),f.stat.size>0&&(b=Buffer.allocUnsafe(1),(await f.handle.read(b,0,1,f.stat.size-1)).bytesRead!==1))throw new Error("project_file_changed_during_read");f.stat.size>1&&await _j(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(S){g=S}try{await Bo(f.handle)}catch(S){if(g){let y=new Error("project_file_close_failed");y.errors=[g,S],g=y}else g=S}if(g)throw g;b?a.end(b):a.end()}catch(f){if(a.headersSent)a.destroy(f instanceof Error?f:void 0);else{let g=f instanceof Error?f.message:String(f);Jr(a,{statusCode:g==="project_file_media_too_large"?413:404,body:{ok:!1,error:g}})}}return}if(d&&(u==="/rendering-profile"||u.startsWith("/rendering-profile/"))){if(!e.handleRenderingProfileRoute){i();return}if(Ei(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}try{let m=await e.handleRenderingProfileRoute({server:r,req:o,readJsonBody:df});Jr(a,m)}catch(m){Jr(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await NE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>df(o,{...f.routeName==="asset-import"?{maxBytes:om}:{}}),async loadManifest(m){let f=await n;if(!f.loadManifest)throw new Error("asset_manifest_handler_unavailable");return f.loadManifest(m)},async loadEditorAssetLibrary(m){let f=await n;if(!f.loadEditorAssetLibrary)throw new Error("asset_library_handler_unavailable");return f.loadEditorAssetLibrary(m)},async loadProjectFiles(){return rP(e.projectRoot,e.projectFileScan)},async loadProjectFile({path:m}){return nP(e.projectRoot,m)},async loadEditorScene(){return e.loadEditorScene(r)},async importAsset(m){let f=await n;if(!f.importAsset)throw new Error("asset_import_handler_unavailable");return f.importAsset(m)},async saveEditorScene({mode:m,rawEditorScene:f,body:g}){return e.saveEditorScene({server:r,saveMode:m,rawEditorScene:f,body:g})}});if(!l){if(d){Ei(a),Jr(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Jr(a,l)})},async handleHotUpdate(r){if(typeof r.file!="string")return;let n=await t;if(dd(r.file,n))return[]}}}function dd(e,t){let r=Pi(e);return t.some(n=>{let o=Pi(n);if(r===o)return!0;let a=xi.relative(o,r);return a.length>0&&a!==".."&&!a.startsWith(`..${xi.sep}`)&&!xi.isAbsolute(a)})}function $j(e,t){if(!e.watcher?.prependListener||!e.ws?.send)return;let r=null,n=null,o=()=>{r=null,n&&clearTimeout(n),n=null},a=s=>{o(),r=typeof s=="string"&&dd(s,t)?Pi(s):null,r&&(n=setTimeout(o,1e3))};for(let s of["add","change","unlink"])e.watcher.prependListener(s,a);let i=e.ws.send.bind(e.ws);e.ws.send=(s,...c)=>{let d=typeof s?.triggeredBy=="string"?s.triggeredBy:void 0,u=d?dd(d,t):!1;if(!(s?.type==="full-reload"&&(u||r&&!d)))return i(s,...c)}}function Lj(e,t){if(!e?.add)return;let r=e.add.bind(e);e.add=n=>{let a=(typeof n=="string"?[n]:[...n]).filter(i=>!dd(i,t));return a.length===0?e:r(typeof n=="string"?a[0]:a)}}import Bn,{resolve as Vo}from"node:path";import{pathToFileURL as zj}from"node:url";function aP(e){let t=Promise.resolve();function r(f){let g=t.then(f);return t=g.then(()=>{},()=>{}),g}async function n(f,g="strict"){let{projectAssetRegistryConfig:b,projectTextureRegistryConfig:S}=await m(),y=[b,S].filter(x=>!!x),I=[],E=[],D=0;for(let x of y){let N=await Lo(x),B=typeof N.errorCodes=="object"&&N.errorCodes?N.errorCodes:{},p=g==="report"?await rf(x,B):await tf(x,B);D+=p.scannedAssetCount,I.push(...p.refreshedAssets);let A="availabilityIssues"in p&&Array.isArray(p.availabilityIssues)?p.availabilityIssues:[];E.push(...A)}return I.length>0&&zo(f,[...y.flatMap(x=>[x.manifestPath,x.registryPath]),...yf(e)]),{scannedAssetCount:D,refreshedAssets:I,availabilityIssues:Bj(E)}}function o(f){return r(async()=>{let g=await n(f,"strict");return{scannedAssetCount:g.scannedAssetCount,refreshedAssets:g.refreshedAssets}})}function a(f){return r(async()=>{let g=await n(f,"report"),b=await c(),S=l(Ca(b),g.availabilityIssues??[]),y=Tn(b,S);return{scannedAssetCount:g.scannedAssetCount,refreshedAssetIds:g.refreshedAssets.map(I=>I.assetId),availabilityIssues:g.availabilityIssues??[],assets:[...y.assets],resourceProjection:y.resourceProjection}})}function i(f,g){return r(async()=>{let{projectAssetRegistryConfig:b,projectTextureRegistryConfig:S}=await m(),y=g.kind??([".png",".jpg",".jpeg",".env"].includes(Bn.extname(g.sourcePath).toLowerCase())?"texture":"model"),I=y==="texture"?S??b:b,E=await Lo(I),D=typeof E.errorCodes=="object"&&E.errorCodes?E.errorCodes:{},x=await Qt(I),N=await $o(I,{payloadData:{sourcePath:g.sourcePath,...g.displayName?{displayName:g.displayName}:{},kind:y,...g.category?{category:g.category}:{},...g.placeable===void 0?{}:{placeable:g.placeable}}},D);zo(f,[I.manifestPath,I.registryPath,...yf(e)]);let p=Ca(await c()).find(A=>A.assetId===N.assetId);if(!p)throw new Error("asset_import_catalog_projection_missing");return{asset:p,disposition:x.some(A=>A.assetId===N.assetId)?"deduplicated":"created"}})}async function s(f){let{projectAssetRegistryConfig:g,projectTextureRegistryConfig:b}=await m(),S=_I({assetRegistryConfig:g,textureRegistryConfig:b,loadAssetCatalogEntries:c,createAssetLibrary:y=>Eo(y.filter(I=>I.kind==="texture"||I.kind==="model"&&I.placeable===!0)),additionalInvalidationFiles:yf(e),invalidateFiles(y){zo(f,y)}});return{loadManifest:y=>r(async()=>(await n(f,"report"),S.loadManifest(y))),loadEditorAssetLibrary:y=>r(async()=>{let I=await n(f,"report"),E=await S.loadEditorAssetLibrary(y);return!E||typeof E!="object"||!Array.isArray(E.assets)?E:{...E,assets:l(E.assets,I.availabilityIssues??[])}}),importAsset:y=>r(async()=>S.importAsset(y))}}async function c(){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:g}=await m(),b=[f,g].filter(E=>!!E),S=[...new Map(b.map(E=>[E.manifestPath,E])).values()],y=(await Promise.all(S.map(E=>Qt(E)))).flat(),I=new Set;return y.filter(E=>{if(I.has(E.assetId))throw new Error(`asset_catalog_duplicate_asset_id:${E.assetId}`);return I.add(E.assetId),!0})}async function d(f,g="strict"){return[...(await u(f,g)).assets]}async function u(f,g="strict"){return r(async()=>{let b=await n(f,g),S=await c(),y=l(Ca(S),b.availabilityIssues??[]);return Tn(S,y)})}function l(f,g){if(g.length===0)return f;let b=new Map;for(let S of g){let y=b.get(S.assetId)??[];y.push(S),b.set(S.assetId,y)}return f.map(S=>{let y=typeof S.assetId=="string"?S.assetId:typeof S.id=="string"?S.id:"",I=y?b.get(y):void 0;return!I||I.length===0?S:{...S,availability:{status:"unavailable",issues:I.map(E=>({code:E.code,reason:E.reason,stage:E.stage,severity:"error",relativePath:E.relativePath,...E.nodeCode?{nodeCode:E.nodeCode}:{},retryable:E.retryable}))}}})}async function m(){if(e.assetRegistryConfig)return{projectAssetRegistryConfig:e.assetRegistryConfig,projectTextureRegistryConfig:e.textureRegistryConfig??e.assetRegistryConfig};if(!e.assetCatalogConfigModulePath)throw new Error("Project asset authoring requires assetRegistryConfig or assetCatalogConfigModulePath.");return import(`${zj(Vo(e.projectRoot,e.assetCatalogConfigModulePath)).href}?project-asset-catalog-config=${Date.now()}`)}return{createProjectAssetAuthoringHandlers:s,listEditorAssetLibrary:d,loadEditorAssetLibrarySnapshot:u,loadProjectAssetCatalogConfigModule:m,importProjectAsset:i,refreshProjectAssetCatalog:o,refreshAndListProjectAssetCatalog:a}}function Bj(e){let t=new Set;return e.filter(r=>{let n=JSON.stringify([r.assetId,r.guid,r.kind,r.relativePath,r.stage,r.reason,r.code,r.nodeCode??null,r.retryable]);return t.has(n)?!1:(t.add(n),!0)})}function iP(e,t){let r=Vo(e,t.importedDir),n=Vo(e,t.generatedDir),o=Bn.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:Bn.join(n,"asset-catalog.manifest.json"),registryPath:Bn.join(n,"asset-catalog.generated.ts"),scenePath:Vo(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:Vo(e,t.editorScene)}:{},supportedExtensions:No,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=Bn.join(r,s,i);return Bn.relative(n,c).split(Bn.sep).join("/")},resolveAssetMetadata(a){return gi({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function yf(e){return(e.additionalInvalidationFiles??[]).map(t=>Vo(e.projectRoot,t))}import ld from"node:path";function sP(e,t){return{editorScenePath:ld.resolve(t,e.source.editorScene),scenePath:ld.resolve(t,e.source.runtimeScene),...e.source.rendering?{renderingConfigPath:ld.resolve(t,e.source.rendering)}:{},...e.source.shadows?{shadowsConfigPath:ld.resolve(t,e.source.shadows)}:{}}}import{existsSync as Vj,readFileSync as Uj}from"node:fs";import{mkdir as Kj,writeFile as Hj}from"node:fs/promises";import hf from"node:path";function cP(e,t){let r=e.source.rendering,n=r?hf.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>hf.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:qj,async handleRoute(a){return n?ZE({method:Wj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:Vj(n)?JSON.parse(Uj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return id([n],async()=>(await Kj(hf.dirname(n),{recursive:!0}),await Hj(n,`${JSON.stringify(i,null,2)}
19
+ `,"utf8"),zo(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Wj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function qj(e){return{postProcessEnabled:e?.postProcess?.enabled??e?.globalVolume?.enabled??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??e?.globalVolume?.postProcessing?.bloom?.enabled??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}import{randomUUID as Jj}from"node:crypto";import{realpath as Xj}from"node:fs/promises";import{createServer as Yj}from"node:http";async function lP(e){let t=await Xj(e.projectRoot),r=Jj(),n=[...e.middlewares??[]],o=Yj((c,d)=>{Zj(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){Ef(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){Ef(d,404,{ok:!1,error:"not_found"});return}Promise.resolve(f(c,d,m)).catch(g=>{if(d.headersSent){d.destroy(g instanceof Error?g:void 0);return}Ef(d,500,{ok:!1,error:g instanceof Error?g.message:String(g)})})};m()});await new Promise((c,d)=>{o.once("error",d),o.listen(0,"127.0.0.1",()=>{o.off("error",d),c()})});let a=o.address();if(!a||typeof a=="string")throw await dP(o).catch(()=>{}),new Error("Editor Project I/O worker address is unavailable.");let i=`http://127.0.0.1:${a.port}`;e.logger?.info?.(`[fps-editor] Project I/O worker ready at ${i}`);let s=null;return Object.freeze({serviceInstanceId:r,internalUrl:i,dispose(){return s||(s=dP(o).catch(c=>{throw s=null,c}),s)}})}function Zj(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function Ef(e,t,r){Qj(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
+ `))}function Qj(e){return e.destroyed||e.writableEnded}async function dP(e){e.listening&&await new Promise((t,r)=>{e.close(n=>n?r(n):t())})}var Ct=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),Vn={kind:"texture"},uP={kind:"color"},eN={kind:"enum",values:["lit","unlit"]},tN={kind:"enum",values:["opaque","mask","blend"]},pP={lightingModel:eN,baseColor:{kind:"object",properties:{color:uP,texture:Vn,brightness:Ct(0),saturation:Ct(0),contrast:Ct(0),hue:Ct(-180,180)}},normal:{kind:"object",properties:{texture:Vn,strength:Ct(0)}},emission:{kind:"object",properties:{color:uP,intensity:Ct(0),texture:Vn,maskTexture:Vn}},alpha:{kind:"object",properties:{mode:tN,opacity:Ct(0,1),cutoff:Ct(0,1),texture:Vn}}},rN={kind:"object",properties:{...pP,metallic:Ct(0,1),roughness:Ct(0,1),metallicRoughness:{kind:"object",properties:{texture:Vn}},occlusion:{kind:"object",properties:{texture:Vn,strength:Ct(0)}}}},nN={kind:"object",properties:pP},oN={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},aN={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},mP=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],Un={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},gP=[Ko("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Ko("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Ho("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),vt("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Uo("properties.baseColor.texture.textureAssetId","baseTexture")]}),vt("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Uo("properties.baseColor.texture.textureAssetId","baseTexture")]}),vt("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Uo("properties.baseColor.texture.textureAssetId","baseTexture")]}),vt("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Uo("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ho("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[Un]),vt("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Un,Uo("properties.normal.texture.textureAssetId","normalTexture")]}),Ko("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),vt("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Ho("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Ko("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),vt("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),vt("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Ho("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],iN=[...gP,vt("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[Un]}),vt("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[Un]}),Ho("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[Un]),Ho("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[Un]),vt("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Un,Uo("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],Pf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:rN,defaultProperties:oN,inspector:{sections:mP,fields:iN}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:nN,defaultProperties:aN,inspector:{sections:mP,fields:gP}}],CK=Tf(Pf);function Tf(e){let t=new Map;for(let n of e){sN(n,t);let o=cN(n);t.set(n.shaderId,hP(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Ko(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function vt(e,t,r,n,o,a,i={}){return Ko(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Ho(e,t,r,n,o,a,i,s){return Ko(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Uo(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function sN(e,t){if(!Xn(e.shaderId)&&!oa(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!lN(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);bP(e.shaderId,e.propertiesSchema,"properties");let r=[];if(yP(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);dN(e,a),o.add(a.path)}}function cN(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=SP(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function dN(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=SP(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function bP(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))bP(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function lN(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function uN(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function SP(e,t){let r=uN(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function yP(e,t,r,n){if(e.kind==="object"){if(!If(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&yP(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];fP(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){fP(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!If(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function fP(e,t,r,n,o){if(!If(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function hP(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))hP(t)}return e}function If(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var mN=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fN=Object.freeze([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ud(e){return pN(new TextEncoder().encode(e))}function EP(e){return`sha256:${ud(JSON.stringify(e))}`}function pN(e){let t=Math.ceil((e.length+9)/64)*64,r=new Uint8Array(t);r.set(e),r[e.length]=128;let n=new DataView(r.buffer);n.setUint32(t-8,Math.floor(e.length/536870912),!1),n.setUint32(t-4,e.length*8>>>0,!1);let o=[...mN],a=new Uint32Array(64);for(let i=0;i<r.length;i+=64){for(let b=0;b<16;b+=1)a[b]=n.getUint32(i+b*4,!1);for(let b=16;b<64;b+=1){let S=a[b-15],y=a[b-2],I=er(S,7)^er(S,18)^S>>>3,E=er(y,17)^er(y,19)^y>>>10;a[b]=a[b-16]+I+a[b-7]+E>>>0}let[s,c,d,u,l,m,f,g]=o;for(let b=0;b<64;b+=1){let S=er(l,6)^er(l,11)^er(l,25),y=l&m^~l&f,I=g+S+y+fN[b]+a[b]>>>0,E=er(s,2)^er(s,13)^er(s,22),D=s&c^s&d^c&d,x=E+D>>>0;g=f,f=m,m=l,l=u+I>>>0,u=d,d=c,c=s,s=I+x>>>0}o[0]=o[0]+s>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+u>>>0,o[4]=o[4]+l>>>0,o[5]=o[5]+m>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+g>>>0}return o.map(i=>i.toString(16).padStart(8,"0")).join("")}function er(e,t){return e>>>t|e<<32-t}var gN="fps.plugin.materials";function PP(e){let t=e?.[gN];if(t==null)return null;if(!Wo(t)||t.schemaVersion!==1||typeof t.snapshotId!="string"||!Array.isArray(t.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");let r=structuredClone(t);return bN(r),TP(r)}function xf(e){return Tf([...Pf,...e?.shaders.map(t=>t.definition)??[]])}function bN(e){if(!/^sha256:[a-f0-9]{64}$/.test(e.snapshotId)||e.shaders.length===0)throw new Error("Materials Plugin snapshot identity is invalid. Run fps-editor-prepare again.");for(let r of e.shaders)if(!Wo(r)||!Wo(r.definition)||!Wo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");xf(e);for(let r of e.shaders){let{definition:n,program:o}=r;if(o.shaderId!==n.shaderId||o.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(o.language!=="glsl"||!IP(o.vertexSourcePath)||!IP(o.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(o.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(o.fragmentSourceHash)||typeof o.vertexSource!="string"||!o.vertexSource.trim()||typeof o.fragmentSource!="string"||!o.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(ud(o.vertexSource)!==o.vertexSourceHash||ud(o.fragmentSource)!==o.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(o.attributes)||o.attributes.length===0||o.attributes.some(a=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))||new Set(o.attributes).size!==o.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(o.alphaMode)||!Wo(o.enumUniformValues)||!Wo(o.frame)||!["on-demand","continuous"].includes(o.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}let t={schemaVersion:e.schemaVersion,shaders:e.shaders};if(EP(t)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function IP(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function TP(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))TP(t);return Object.freeze(e)}function Wo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function AP(e){let t=GE(e.definition),r=PP(e.pluginSnapshots),n=xf(r),o=t.project,a=SN(e.projectRoot),i=iP(e.projectRoot,{importedDir:o.assets.importedDir,generatedDir:o.assets.generatedDir,runtimeArtifact:o.source.runtimeScene,editorScene:o.source.editorScene}),s=aP({projectRoot:e.projectRoot,assetRegistryConfig:i}),c=cP(o,{projectRoot:e.projectRoot}),d=sP(o,e.projectRoot),u=TE({materialShaderDefinitions:n,markerTypes:t.metadata.markerTypes??[],relationTypes:t.metadata.relationTypes??[],features:o.features,getRenderingProfile:()=>({shadows:{defaultMode:"none"}}),createPatch:{gameObjectField:(S,y,I)=>({kind:"game-object.field",targetId:S,path:y,value:I}),gameObjectFieldBatch:S=>({kind:"game-object.property-field-batch",fields:S}),materialAssetField:(S,y,I)=>({kind:"scene.material-asset.field",materialAssetId:S,path:y,value:I}),materialAssetReplace:(S,y)=>({kind:"scene.material-asset.replace",materialAssetId:S,materialAsset:y}),prefabAssetReplace:(S,y)=>({kind:"scene.prefab-asset.replace",assetId:S,prefabAsset:y}),markerGraph:S=>({kind:"scene.marker-graph",command:S})}}),l={ensureAuthoringSource:$g,detectRuntimeInputDrift:zg,enrichEditorSceneDocumentAssets:nu,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:JI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:Lg,compileEditorSceneDocumentToSceneConfig:(S,y,I)=>_E(S,y,{...I,materialShaderDefinitions:n,readCustomTransformRuntimeData:E=>E?.transformType==="groundDecal"&&hN(E.groundDecal)?{groundDecal:YE(E.groundDecal)}:null})},f=(S,y="report")=>s.listEditorAssetLibrary(a,y),g=(S,y="report")=>s.loadEditorAssetLibrarySnapshot(a,y),b=oP({projectRoot:e.projectRoot,createAssetAuthoringHandlers:()=>s.createProjectAssetAuthoringHandlers(a),handleRenderingProfileRoute:c.handleRoute,loadEditorScene:()=>WI({projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,loadEditorAssetLibrarySnapshot:g,loadServices:async()=>l}),saveEditorScene:S=>qI({...S,projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,saveServices:async()=>m,normalizeRenderingProfile:y=>Ne(y),summarizeRenderingProfile:y=>Hn(y),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await yN(b.configureServer,a),lP({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function SN(e){let t={stack:[],use(o){this.stack.push(o)}},r=new xP,n=new xP;return n.unwatch=async()=>{},n.add=()=>n,{middlewares:t,httpServer:r,watcher:n,ws:{send(){}},moduleGraph:{getModulesByFile(){},invalidateModule(){}},config:{root:e,logger:console}}}async function yN(e,t){if(typeof e=="function"){await e(t);return}e&&typeof e=="object"&&"handler"in e&&typeof e.handler=="function"&&await e.handler(t)}function hN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Xr=await AP({projectRoot:process.cwd(),definition:MP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:MP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Xr||typeof Xr.serviceInstanceId!="string"||typeof Xr.internalUrl!="string"||typeof Xr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Xr.serviceInstanceId,internalUrl:Xr.internalUrl});var Af=!0,wP=setInterval(()=>{Af&&process.send?.({type:"heartbeat",serviceInstanceId:Xr.serviceInstanceId})},1e3);wP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(Af=!1),e?.type==="test.start-heartbeat"&&(Af=!0)});var DP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{DP||(DP=!0,clearInterval(wP),Xr.dispose().finally(()=>{process.exitCode=e==="SIGINT"?130:143}))});function EN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function MP(e){let t=JSON.parse(EN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}