@fps-games/editor-deployment 0.2.3-beta.19 → 0.2.3-beta.21

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 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 n0=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(`
1
+ import{EventEmitter as xP}from"node:events";var Yo="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=Yo,t={}){let r=md[e]??md[Yo];return{opacity:Xo(t.opacity,r.opacity),softness:Xo(t.softness,r.softness),bias:Xo(t.bias,r.bias),normalBias:Xo(t.normalBias,r.normalBias),maxDistance:Xo(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 Xo(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 kf(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=kf(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=Yo){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 Zo(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),en(r,"opacity",t,n=>n>=0&&n<=1),en(r,"softness",t,n=>n>=0),en(r,"bias",t,()=>!0),en(r,"normalBias",t,()=>!0),en(r,"maxDistance",t,n=>n>0),en(r,"bakeSamples",t,n=>n>0),en(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 en(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=Rf(r.qualityProfiles,`${t}.qualityProfiles`),i=Rf(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 Cf(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:Of(s.cast,`${d}.cast`)??l.cast==="enabled",receive:Of(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 vf({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:Gt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:ea(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 Of(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"),ea(r.center,`${t}.center`),ea(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"),Qo(r.bias,`${t}.bias`,0,.1),Qo(r.normalBias,`${t}.normalBias`,0,1),Qo(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&Qo(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"),Qo(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 Rf(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:ea(e.center,"$.bounds.center"),extent:ea(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function ea(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 Qo(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 vf(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))vf(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var Gf=["useBlobShadow","blobSettings"],QP=["resolution","maxSize"],eT=new Set(["none","blob","static","planar","dynamic"]);function St(e){let t=tn(e);if(!t)throw X("schema.invalidType","$");for(let o of Gf)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=tn(t.shadows);if(!r)throw X("schema.invalidType","$.shadows");for(let o of Gf)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=tn(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"),rn(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),rn(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),dT(r.csm,"$.shadows.csm")}function tT(e,t){if(e===void 0)return;let r=tn(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=tn(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=tn(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(rn(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),rn(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`)),rn(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),rn(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)),rn(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 rn(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=tn(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 tn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function z(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function jf(e,t){let r=z(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=z(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 ta(e,t){let r=z(e);return{...Td(r,t),a:nr(r.a,t.a,0,1)}}function Dr(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 Nf(e){return e===0||e===1||e===2||e===3?e:null}function Ff(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function _f(e,t){return e===1||e===2||e===4||e===8?e:t}function $f(e,t){return e==="fixed"||e==="receiver"?e:t}function Lf(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 Mr(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 zf=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Bf=[...zf,"_blobShadow"],mT=[...Bf,"_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&&St(e);let t=z(e),r=z(t.shadows),n=z(r.settings),o=z(r.blob),a=fT(o),i=gT(r.staticProjected),s=z(r.shadowRange),c=z(r.shadowOrtho),d=z(r.csm),u=z(t.shadowMeshes);return{renderingGroups:Uf(t.renderingGroups),environment:bT(t.globalVolume),postProcess:ST(t.globalVolume),shadows:{defaultMode:Lf(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:Dr(u.shadowReceivers),shadowCasters:Dr(u.shadowCasters),excludeFromShadow:Dr(u.excludeFromShadow)}}}function qn(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=z(e),r=z(t.plane),n=z(t.appearance),o=z(t.size),a=ta(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:ta(n.color,a),edgeSoftness:nr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Mr(o.maxSize,20)}}}function Uf(e){let t=z(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:Vf.map(n=>{let o=r.find(i=>Nf(z(i).renderingGroupId)===n.renderingGroupId),a=z(o);return{renderingGroupId:n.renderingGroupId,name:Ad(a.name,n.name),alphaIndexPresets:Kf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function Kf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=z(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=z(e),r=z(t.plane),n=z(t.appearance),o=z(t.projection),a=z(t.stencil),i=z(t.casters),s=z(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:jf(r.normal,{x:0,y:1,z:0}),height:be(r.height,0),heightMode:$f(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:ta(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:Dr(i.includePatterns),excludePatterns:Dr(i.excludePatterns),rootBoundaryPatterns:Dr(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Dr(s.patterns)}}}function gT(e){let t=z(e),r=z(t.plane),n=z(t.appearance),o=z(t.bake),a=Mr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:ta(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Mr(o.texelsPerMeter,256),atlasSize:Mr(o.atlasSize,4096),maxAtlasPages:Mr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Mr(o.targetChunkCount,64)}}}function bT(e){let t=z(e),r=z(t.environment),n=z(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=z(e),r=z(t.imageProcessing),n=z(t.toneMapping),o=z(t.antialiasing),a=z(t.postProcessing),i=z(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:Ff(n.type,"aces")},antialiasing:{samples:_f(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:Mr(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"}},Hf=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 na(e,t="$.direction"){let r=Wf(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Hf&&yt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Jn(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=Wf(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Hf&&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 Wf(e,t){let r=wd(e,t);return Fi(r,IT,t),Object.freeze({x:ra(r.x,`${t}.x`),y:ra(r.y,`${t}.y`),z:ra(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 ra(e,t){return(typeof e!="number"||!Number.isFinite(e))&&yt(t,"expected a finite number"),e}function TT(e,t){let r=ra(e,t);return r<0&&yt(t,"expected a non-negative number"),r}function Md(e,t){let r=ra(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 qf(e){return xT.has(e)}function Zn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function Jf(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=Xf(e.baseColor?.color);n&&(r.color=n);let o=nn(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=nn(e.normal?.texture);i!==void 0&&(a.texture=i),or(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Yn(e.metallic)&&(t.metallic=e.metallic),Yn(e.roughness)&&(t.roughness=e.roughness);let s={},c=nn(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=nn(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=Xf(e.emission?.color);m&&(l.color=m),or(e.emission,l,"intensity");let f=nn(e.emission?.texture);f!==void 0&&(l.texture=f);let g=nn(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=nn(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=Jf(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),Xn(t,n,"baseColor"),Xn(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),Xn(t,n,"metallicRoughness"),Xn(t,n,"occlusion"),Xn(t,n,"emission"),Xn(t,n,"alpha"))}return Jf(t)??{}}function Xn(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function Xf(e){return e&&Yn(e.r)&&Yn(e.g)&&Yn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function nn(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){Yn(e?.[r])&&(t[r]=e[r])}function Yn(e){return typeof e=="number"&&Number.isFinite(e)}var Yf="staticShadows";function kr(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 Qn(e,t="$.staticShadows"){let r=kr(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=wr(t.x),n=wr(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=wr(t.sourceRootCount),n=wr(t.sourceMeshCount),o=wr(t.attemptedChunkCount),a=wr(t.chunkCount),i=wr(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 wr(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=wr(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),oa=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,x)=>{c.length<s&&c.push({path:p,message:x})};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&&Zf(()=>Qn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let b=new Set,S=new Map,y=new Map,I=new Set,E=new Set([g.rootId]),A=new Map,D=new Map,j=new Set;return g.assets.forEach((p,x)=>{let h=`$.scene.assets[${x}]`;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(($,Ar)=>{let tr=`${K}[${Ar}]`;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)&&tp(p,h,l)}),g.nodes.forEach((p,x)=>{let h=`$.scene.nodes[${x}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&A.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"&&D.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&j.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,x)=>{let h=`$.scene.materialAssets[${x}]`;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=Zn(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?np(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,x)=>{if(!M(p))return;let h=`$.scene.nodes[${x}]`,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,A,`${h}.parentId`,l),mx(p.source,`${h}.source`,l),ap(p.transform,`${h}.transform`,l),Rx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&Zf(()=>Zo(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)?(ep(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),ep(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,j,`${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)&&tp(p,h,l)}),g.materials.forEach((p,x)=>{let h=`$.scene.materials[${x}]`;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=D.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)?sp(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 Zf(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}rp(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"):rp(c,d,n,i)}}}function rp(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&&np(e.override,`${t}.override`,n)}}function np(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),on(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)?(on(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)?on(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(on(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"),on(e.emission.texture,`${t}.emission.texture`,r),on(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"),on(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var ex=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function ia(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&ex.test(e)}function tx(e){return ia(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 on(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){oa.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(oa.has("sceneNode")&&r.has(e))return;let a=oa.has("root")&&oa.has("sceneNode")?"root or scene node":oa.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(ap(e.transform,`${t}.transform`,r),Qf(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))Qf(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}op(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}op(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 op(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 ap(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}Or(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}Or(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}Or(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"){Or(e,["kind"],t,r);return}if(e.kind==="point"){Or(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"){Or(e,["kind","target"],t,r),Rd(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){Or(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}Or(e,["r","g","b"],t,r);for(let n of["r","g","b"])ip(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function Or(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 an(e){return qe(e)&&e>0}function ip(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&&!an(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!an(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&&!an(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&&!ip(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),an(e.minZ)&&an(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"),an(e.lowerRadiusLimit)&&an(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{Jn(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:na(e.direction,`${t}.direction`)}}function Qf(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"),eo(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"),eo(e.tint,`${t}.tint`,r)):e.kind==="color"?eo(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"),eo(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"),eo(e.color,`${t}.color`,r),eo(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 eo(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 ep(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function sp(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)?sp(o,a,r):r(a,`${n} must be an object`))}}function tp(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=cp(e)??512,o=cp(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 cp(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function dp(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(!fp(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=>up(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!mp(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 lp(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(!fp(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&&!mp(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||up(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 up(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 mp(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function fp(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}:{}}),sn={kind:"texture"},pp={kind:"color"},Gx={kind:"enum",values:["lit","unlit"]},jx={kind:"enum",values:["opaque","mask","blend"]},Sp={lightingModel:Gx,baseColor:{kind:"object",properties:{color:pp,texture:sn,brightness:Et(0),saturation:Et(0),contrast:Et(0),hue:Et(-180,180)}},normal:{kind:"object",properties:{texture:sn,strength:Et(0)}},emission:{kind:"object",properties:{color:pp,intensity:Et(0),texture:sn,maskTexture:sn}},alpha:{kind:"object",properties:{mode:jx,opacity:Et(0,1),cutoff:Et(0,1),texture:sn}}},Nx={kind:"object",properties:{...Sp,metallic:Et(0,1),roughness:Et(0,1),metallicRoughness:{kind:"object",properties:{texture:sn}},occlusion:{kind:"object",properties:{texture:sn,strength:Et(0)}}}},Fx={kind:"object",properties:Sp},_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}},gp=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],cn={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},yp=[ro("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),ro("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),no("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:[to("properties.baseColor.texture.textureAssetId","baseTexture")]}),It("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[to("properties.baseColor.texture.textureAssetId","baseTexture")]}),It("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[to("properties.baseColor.texture.textureAssetId","baseTexture")]}),It("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[to("properties.baseColor.texture.textureAssetId","baseTexture")]}),no("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[cn]),It("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[cn,to("properties.normal.texture.textureAssetId","normalTexture")]}),ro("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}),no("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),ro("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"}]}),no("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=[...yp,It("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[cn]}),It("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[cn]}),no("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[cn]),no("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[cn]),It("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[cn,to("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],zx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:Nx,defaultProperties:_x,inspector:{sections:gp,fields:Lx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Fx,defaultProperties:$x,inspector:{sections:gp,fields:yp}}],Rr=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,Ip(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=Rr){return t.get(e)}function De(e){return jd(e)}function Vx(e,t,r=Rr){let n=Fd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function oo(e,t,r=Rr){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 ao(e,t,r="properties",n=Rr){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 ro(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 ro(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function no(e,t,r,n,o,a,i,s){return ro(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function to(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Ux(e,t){if(!Zn(e.shaderId)&&!ia(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.`);hp(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=Ep(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=Ep(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 hp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))hp(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 Ep(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"];bp(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){bp(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 bp(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 Ip(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))Ip(t)}return e}function Gd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Cr(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,Jx(n));for(let n of sa(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=sa(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=sa(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||Ap(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=sa(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 sa(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 Ap(e,t={}){return!!Ud(e,t)}function cr(e){let{spatial:t,...r}=structuredClone(e);return r}function Wi(e){return structuredClone(e)}function Dp(e,t){return{...Wi(e),from:Pp(e.from,t),to:Pp(e.to,t)}}function Mp(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 Pp(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function wp(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 ca(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 Tp(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=>!Tp(r.from,t)&&!Tp(r.to,t))}}function xp(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 kp(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 xp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>xp(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 Op(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 Rp(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)&&!Cr(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&Cr(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||Ap(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&sa(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 ca(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 Cp(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 vp(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 da(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Gp(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",jp="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=Lp(e);return t&&mA(t)?{mode:"matrix",matrix:t}:null}function Np(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!!Lp(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&&!!Fp(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,A=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)*A,(f-b)*A,(1-(d+m))*A,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 Fp(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,A=r*s-n*i,D=r*c-o*i,j=n*c-o*s,_=d*g-u*f,p=d*b-l*f,x=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+A*x-D*p+j*_;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*j-b*D+S*A)*$,(l*D-u*j-m*A)*$,(s*x-a*K-c*p)*$,(t*K-n*x+o*p)*$,(b*E-f*j-S*I)*$,(d*j-l*E+m*I)*$,(a*R-i*x+c*_)*$,(r*x-t*R-o*_)*$,(f*D-g*E+S*y)*$,(u*E-d*D-m*y)*$,(i*p-a*h-s*_)*$,(t*h-r*p+n*_)*$,(g*I-f*A-b*y)*$,(d*A-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 la(Fe(d),e,1e-5)?d:null}function el(e,t={}){let r=Qd(e);return r||(t.allowMatrixFallback?Xi(e):null)}function _p(e){let t=uA();for(let r of e)t=Zd(Fe(r),t);return el(t,{allowMatrixFallback:!0})}function $p(e,t){return el(Zd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function io(e,t,r={}){let n=Fp(Fe(e));return n?el(Zd(Fe(t),n),r):null}function la(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 Lp(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,A=d*S-f*m,D=d*b-l*f,j=d*g-f*u,_=+(i*y-s*I+c*E),p=-(a*y-s*A+c*D),x=+(a*I-i*A+c*j),h=-(a*E-i*D+s*j);return t*_+r*p+n*x+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 dn(e){return e==null||typeof e=="string"}function ln(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 ua(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 ma(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&&!ua(t.scale))}function os(e){return e==="orthographic"||e==="perspective"}function as(e){return e==="hemispheric"||e==="directional"}var Lt=["group","instance","transform","primitive"],zp=["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"?ua(t):Je(t))}}function TA(e,t){return{path:`transform.${e}.${t}`,appliesTo:Lt,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?ma(r):w(r))}}function xA(e){return[PA(e),...IA.map(t=>TA(e,t))]}var rl=[{path:"name",appliesTo:Lt,validate:dn},{path:"parentId",appliesTo:Lt,validate:dn},{path:"enabled",appliesTo:Lt,validate:es},{path:"shadow.cast",appliesTo:zp,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:zp,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:ma,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:dn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:ln},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Qi(e)},{path:"marker.note",appliesTo:["transform"],validate:dn},{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 U(e){return{path:e,appliesTo:se,validate:t=>t==null||w(t)}}function Bp(e){return{path:e,appliesTo:se,validate:t=>t==null||typeof t=="boolean"}}function ue(e){return{path:e,appliesTo:se,validate:ln}}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"),U("overrides.material.metallic"),U("overrides.material.roughness"),U("overrides.material.contrast"),U("overrides.material.brightness"),U("overrides.material.saturation"),U("overrides.material.hue"),U("overrides.material.colorDensity"),U("overrides.material.alpha"),U("overrides.material.alphaCutOff"),U("overrides.material.transparencyMode"),Bp("overrides.material.backFaceCulling"),ue("overrides.material.albedoTexture.url"),ue("overrides.material.normalTexture.url"),U("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"),U("overrides.material.pbr.baseWeight"),Xe("overrides.material.pbr.reflectivityColor"),U("overrides.material.pbr.microSurface"),Xe("overrides.material.pbr.emissiveColor"),Xe("overrides.material.pbr.ambientColor"),U("overrides.material.pbr.lightFalloff"),U("overrides.material.pbr.directIntensity"),U("overrides.material.pbr.emissiveIntensity"),U("overrides.material.pbr.environmentIntensity"),U("overrides.material.pbr.specularIntensity"),U("overrides.material.pbr.metallicF0Factor"),U("overrides.material.pbr.indexOfRefraction"),Xe("overrides.material.standard.diffuseColor"),Xe("overrides.material.standard.specularColor"),U("overrides.material.standard.specularPower"),Xe("overrides.material.standard.emissiveColor"),Xe("overrides.material.standard.ambientColor"),Bp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:se,validate:ln},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"),U("overrides.materialBinding.override.baseColor.brightness"),U("overrides.materialBinding.override.baseColor.saturation"),U("overrides.materialBinding.override.baseColor.contrast"),U("overrides.materialBinding.override.baseColor.hue"),ue("overrides.materialBinding.override.normal.texture.url"),ue("overrides.materialBinding.override.normal.texture.textureAssetId"),U("overrides.materialBinding.override.normal.strength"),U("overrides.materialBinding.override.metallic"),U("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"),U("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},U("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"),U("overrides.materialBinding.override.alpha.opacity"),U("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"},U("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}],Vp=[...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=Vp.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 Up(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 Kp(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 vr(e){return e==="overrides.materialBinding.materialAssetId"||zt(e,"materialAssetId")!=null}function il(e){if(vr(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 so(e,t){if(!De(e)||!is(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return oo(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=Rr){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 oo(t,e,r);for(let n of r.list()){let o=oo(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 Hp(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:fa(r.metallic??0),roughness:fa(r.roughness??1),...r.emission?.color?{emissionColor:Jp(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=un(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=un(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=un(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=un(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=un(r.emission?.texture,t),c=un(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=un(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function un(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 qp(e,t){let r=e??{},n=Wp(r.metallic??0),o=Wp(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function BA(e){let r=(e.baseColor??{}).color??_A;return Jp(r)}function Jp(e){return{r:fa(e.r),g:fa(e.g),b:fa(e.b)}}function fa(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Wp(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 ng(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 pa(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?ga(e).filter(n=>n.materialAssetId===r):[]}function ga(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=Gr(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)){Xp(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??[])Xp(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 Xp(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=ga(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 Gr(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 og(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 ag(e){return e.slotId}function ms(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function dl(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function ig(e){let t=sg(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=jr(s);c&&i.push(c)}return i}function jr(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=sg(t);if(!r)return[];let n=Hp(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=Yp(t.min),n=Yp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Yp(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 sg(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 ga(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)??[]}},Zp=new WeakMap;function QA(e){let t=Zp.get(e);return t||(t=new ls(e),Zp.set(e,t)),t}function ll(e){return e?.system?.preset}function Qp(e,t){let r=ll(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function eg(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?tg(e.document,r.id,e.ownershipText,t):null,a=r?eg(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?rg(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?Qp(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=tg(e.document,s.id,e.ownershipText,t);return{label:Qp(s,e.displayText),value:s.id,meta:rg(eg(s,e.displayText),c),kind:"material",preview:Vt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function tg(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 rg(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:qp(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 mn=1;var ml="prefab.";function Sa(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 pn(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),pn(r)?(r.shadow=dg(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:dg(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 dg(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 s0=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 Nr(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 ba(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 co(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 lg(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!==mn||t.length===0||!r)return ul(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${mn} 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=mn,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 ug(e){let t=ba(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 mg(e){if(!e.startsWith(ml))return null;let t=e.slice(ml.length);return ss(t)?t:null}function gl(e){return mg(e)?.endsWith(".materialAssetId")===!0}function fg(e){return e.startsWith(ml)&&e.endsWith(".materialAssetId")&&gl(e)}function pg(e,t){if(t.slotId)return ig(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function ya(e,t,r){let n=mg(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=hg(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function gg(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=kd(e?.override,t?.override);return Sl({...n??r?{materialAssetId:n??r}:{},...fn(o)?{override:o}:{}})}function gs(e,t){let r={},n=gg(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=bD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),fn(r)?r:void 0}function bs(e,t){let r=gn(e,t);if(!(!r.gameObject||!r.prefab))return gs(r.definition?.prefab?.overrides,SD(r.gameObject.overrides))}function gn(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=ba(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)&&ba(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":Nr(e)||e.transformType?"transform":"group"}function bg(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=bl(t?.renderingGroupId),n=yg(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 Sg(e){return yg(e)}function cD(e){return e.type==="Transform"}function dD(e){return e.type==="ModelRenderer"}function lD(e){return e.type==="ImageRenderer"}function yg(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 cg(["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?cg(["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 cg(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(Eg)?null:[...e,...r]}function pD(e,t,r){if(t.some(Eg))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 hg(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),fn(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}:{},...fn(n)?{override:n}:{}};return fn(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 fn(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=gg(e?.[o],t?.[o]);a&&(n[o]=a)}return fn(n)?n:void 0}function SD(e){return hg(e)}function fn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function Eg(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var yD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function Ig(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}`);ha(e.parentId)||F("schema.invalidReference",`${r}.parentId`),PD(e.transform,`${r}.transform`),hD(e.marker,`${r}.marker`);let n=ha(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=_r(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`),ha(r.type)||F("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!ha(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=_r(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&&Fr(r.position,`${t}.position`),r.offset!==void 0&&Fr(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)=>Fr(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=_r(e);r||F("schema.invalidType",t),at(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&F("schema.invalidValue",`${t}.kind`),ha(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=_r(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`),Fr(r.position,`${t}.position`),Fr(r.rotation,`${t}.rotation`),r.scale!==void 0&&Fr(r.scale,`${t}.scale`)}function TD(e,t){let r=_r(e);r||F("schema.invalidType",t),at(r,["origin","forward","right","up","label","description"],t),Fr(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Fr(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=_r(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 Fr(e,t){let r=_r(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=_r(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 _r(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ha(e){return typeof e=="string"&&e.trim()?e.trim():null}function F(e,t){throw new Error(`${e}: ${t}`)}function lo(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:lo(t,e.id)}}function Ea(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 B(e,t){if(Pg(e))try{return e[t]}catch{return}}function le(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 Ht(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 bn(e){let t=Ht(e),r=le(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function Pg(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(B(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 N(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=N(t);r&&e.push(r)}function uo(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=Sn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>N({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 Sn(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 Ia(e){let t=e.projectedRoot??e.root??null,r=xg(t),n=r.find(o=>!!B(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:Ag(t),meshes:r,primaryMesh:n,material:vD(t)}}function hs(e){let t=we(e,"getHierarchyBoundingVectors"),r=Sn(B(t,"min")),n=Sn(B(t,"max"));if(r&&n)return Tg(r,n);let o=we(e,"getBoundingInfo"),a=B(o,"boundingBox"),i=Sn(B(a,"minimumWorld")),s=Sn(B(a,"maximumWorld"));return i&&s?Tg(i,s):null}function xg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return Dg(e)&&r.unshift(e),[...new Set(r)]}function Ag(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function Dg(e){return!!e&&(!!B(e,"material")||typeof B(e,"getTotalVertices")=="function"||typeof B(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 mo(e,t){let r=B(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 Pa(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 Tg(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=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 Ts={x:-.3,y:-1,z:-.2},Mg=-180,wg=180,Ta=-90,xa=90;function Aa(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=Lr(As(e)),n=Lr(Gg(t,Ta,xa)),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=Cg({direction:e.light.direction,rotation:r}),o=Al(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:Lr(n.elevationAngleDeg),y:Lr(n.horizontalAngleDeg),z:fo(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function kg(e,t){if(!Ds(e.light))return e;let r=Dl(e);if(!r)return e;let n=fo(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=fo(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=Al(n,o),i={...r.rotation,x:Lr(o),y:Lr(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}=Cg({direction:t,rotation:e});return Al(r,n)}function jD(e,t){let r=Rg(e);return{x:Lr(r.elevationAngleDeg),y:Lr(r.horizontalAngleDeg),z:fo(t?.z)?t.z:0}}function po(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 vg(r,Aa(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 vg(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function Og(e){let t=Aa(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 Rg(e){let t=Aa(e);return{horizontalAngleDeg:As(Ps(Math.atan2(t.z,t.x))),elevationAngleDeg:Ps(Math.asin(Gg(-t.y,-1,1)))}}function Cg(e){let t=Rg(e.direction);return{horizontalAngleDeg:fo(e.rotation?.y)?Ps(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:fo(e.rotation?.x)?Ps(e.rotation.x):t.elevationAngleDeg}}function fo(e){return typeof e=="number"&&Number.isFinite(e)}function vg(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 Lr(e){return e*Math.PI/180}function xl(e){return Math.round(e*1e6)/1e6}function Gg(e,t,r){return Math.min(r,Math.max(t,e))}var yn="light.directionHorizontalAngleDeg",hn="light.directionElevationAngleDeg";function go(e){return e===yn||e===hn}function jg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=FD(t);return r==null?t:e===yn?Math.round(As(r)):e===hn?Math.round(_D(r,Ta,xa)):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 En(e){return t=>bo({...e,value:t})}function bo(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 In(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?Ng(t):t}function mr(e,t,r={}){if((r.isDirectionalLightAnglePath??Fg)(e))return jg(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"?Ng(t):In(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??Fg)(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(vr(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(vr(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 Ng(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 Fg(e){return e===yn||e===hn}function Da(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:En({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 _g={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"}},$g=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function wl(e){return _g[e]??_g.zh}function VD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function Lg(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:$g,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:Lg(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 zg(e){let t=qt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Ms,sourceType:ws,revision:t.revision??1}}}}function Bg(e){let t=qt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Ms,sourceType:ws,revision:(t.revision??0)+1}}}}function Vg(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&&Ug(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(Ug(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Kg(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function Ug(e,t){let r=Rs(e,t);return!!r&&r.active!==!1&&Kg(r)}function Kg(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 So(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)||So(e)}function Cl(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Mt(r)}var zr="root",nM="go_",vl="GameObject";function me(e){return e===zr}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 Hg(e,t=vl){return Gl(e)??Gl(t)??vl}function dt(e,t,r={}){let n=Hg(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 Br=Pt();function ke(e,t){if(me(t))return Pt();let r=L(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 _p(n.map(Jt))}function L(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?io(o,r,n):null}function Ma(e,t,r,n={}){let o=Zi(n);return fr(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function Jt(e){return Z(e)?Pt():ho(e)}function wa(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=ho(r),o=!!G(r)&&!sM(n,Br),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=Wg(s,t);return a=a||l!==s,l}if(!o||s.parentId!==zr||!G(s))return s;let d=$p(n,ho(s));if(!d)return s;let u=Fl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function Wg(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)&&yo(s.position,Br.position)&&yo(s.rotation,Br.rotation)&&yo(qg(s,"scale"),Br.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(Br)}function ho(e){let t=G(e);return t?Ee(t)?Xi(t.matrix)??Pt():{position:{...t.position},rotation:{...t.rotation},scale:{...qg(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=Pn(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 Pn(e){return rt(e)?Xi(e.matrix):Np(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 qg(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)?la(Fe(e),Fe(t)):yo(e.position,t.position)&&yo(e.rotation,t.rotation)&&yo(e.scale,t.scale)}function yo(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===zr&&!!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===zr?!1:!!L(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!==zr).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=wa(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?io(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=[Jg(e)],r=Yg(e);r&&t.push(r);let n=eb(e);n&&t.push(n);let o=nb(e);o&&t.push(o);let a=ib(e);a&&t.push(a);let i=mM(e);i&&t.push(i);let s=cb(e);s&&t.push(s);let c=db(e);c&&t.push(c);let d=ub(e);return d&&t.push(d),t}function Jg(e){return{id:"common",title:"Common",order:10,placement:"body",summary:_s(e),persistence:"document",collapsedByDefault:!1,properties:Xg(e)}}function Xg(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??Oa})):o.push(et("common.transformType","Transform Type",r.transformType??"none",6)),o}function Yg(e){return $r({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:Zg(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Qg(e)})}function Zg(e){let t=e.gameObject.parentId?L(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Qg(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?L(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 eb(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:rb(e),persistence:"document",collapsedByDefault:!1,properties:tb(e)}:null}function tb(e){if(!G(e.gameObject))return[];let r=_s(e),n=Z(e.gameObject),o=n?e.rootTransform??Pt():ho(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 rb(e){let t=e.gameObject.parentId?L(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 nb(e){let t=Se(e.gameObject),r=Nr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:ab(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?uM(e,r):ob(e)}:null}function uM(e,t){let r=ka(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 ob(e){let t=Se(e.gameObject);if(!t)return[];let{document:r}=e,n=ka(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 ab(e,t){let r=ka(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function ib(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:sb(e)}:null}function sb(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(!Eo(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?[uo({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 cb(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 db(e){return $r({id:"components",title:"Scripts / Components",order:65,summary:Ul(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:lb(e.gameObject)})}function Ul(e){return e.components.map(t=>t.type).join(", ")||"none"}function lb(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 ub(e){let t=e.assetId??Se(e.gameObject)?.assetId??Nr(e.gameObject)?.assetId??null,r=mb({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:fb({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function mb(e){let t=[],r=e.assetId?ka(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 fb(e){let t=e.assetId?ka(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 Da({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=N(t);r&&e.push(r)}function et(e,t,r,n){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function _s(e){return e.nodeKind??Y(e.gameObject)}function Eo(e){let t=e.gameObject;return Z(t)?!1:pn(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 ka(e,t){return e.assets.find(r=>r.id===t)??null}var Oa=[{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 pb(e){return[Sb(e),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.runtime),wb(e.runtime),kb(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=Ia({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return pb({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:gb(e.projectionNode)},projectionAssetMetadata:bb(e.projectionNode)})}function gb(e){let t=B(e,"asset");return le(t,"assetId")??le(t,"id")}function bb(e){return B(B(e,"asset"),"metadata")}function Sb(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:bn(r.primaryMesh)??"none",order:11,source:"Derived"}),T(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:bn(r.material)??"none",order:12,source:"Derived"}),T(n,{path:"runtime.material.kind",label:"Material Kind",value:Gb(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?bn(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function yb(e){let t=[],r=hs(e.root)??hs(e.primaryMesh);return r?(Tn(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),Tn(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),Tn(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),Tn(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+mo(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 hb(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 Eb(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 B(t,"moveWithCollisions")=="function"?"available":"not available"}),Tn(r,"runtime.collisions.ellipsoid","Ellipsoid",B(t,"ellipsoid"),r.length,"Runtime","not configured"),Tn(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 Ib(e){let t=e.primaryMesh??e.root,r=B(t,"physicsBody"),n=B(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:Pa(o,"mass")??"not available"}),T(a,{path:"runtime.physics.friction",label:"Friction",value:Pa(o,"friction")??"not available"}),T(a,{path:"runtime.physics.restitution",label:"Restitution",value:Pa(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?bn(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function Pb(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:bn(B(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 Tb(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:bn(t)??"none",collapsedByDefault:!0,properties:r})}function xb(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 jb){let a=B(t,o);a&&(n+=1,Rb(r,`runtime.material.textures.${o}`,Ra(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 Ab(e){let t=[],r=0;for(let n of Nb){let o=B(e.material,n);Ob(t,`runtime.material.colors.${n}`,Ra(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 Db(e){let t=[];for(let r of Fb)T(t,{path:`runtime.material.metallicRoughness.${r}`,label:Ra(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 Mb(e){let t=[];for(let r of _b)T(t,{path:`runtime.material.intensity.${r}`,label:Ra(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 wb(e){let t=e.primaryMesh??e.root,r=B(t,"skeleton"),n=[];return T(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:mo(e.root,"animations"),source:"Derived"}),T(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:mo(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:mo(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?le(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function kb(e){let{runtime:t}=e,r=[];return T(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:B(t.root,"metadata")??"none",tags:["Raw"]}),T(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:B(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),T(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:B(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=N({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function Tn(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 Ob(e,t,r,n,o){let a=vb(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 Rb(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:Cb(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 Cb(e){return le(e,"url")??le(e,"name")??le(we(e,"getInternalTexture"),"url")}function vb(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 Gb(e){let t=Ht(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function Ra(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var jb=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],Nb=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],Fb=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],_b=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var Lb=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],$b={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 $b[e]??$b.zh}function Wl(e){return e.inspectorLanguage==="en"?"en":"zh"}function zb(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:Lb,controlOptions:{variant:"segmented"},tooltip:s.tooltips.language}),N({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:yn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:Mg,max:wg,step:1,coerce:m=>a(yn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:hn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:Ta,max:xa,step:1,coerce:m=>a(hn,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 Bb(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:[N({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"}),N({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"}),N({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"}),N({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:AM(Og(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:zb(e)}];return e.light.type==="directional"&&r.push(Bb({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=N(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=Vr(e.overrides);if(!t)return;let r=Vb(t.material);r?t.material=r:delete t.material;let n=Vr(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=Vr(s);if(!c){delete n[i];continue}let d=Vb(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=Vr(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=Vr(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function Vb(e){let t=Vr(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=Vr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=Vr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function Vr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function xn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Kb(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=Kb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Kb(e,t){let r=Ub(e),n=MM(e,t),o=Ub(n);return r&&o&&!wM(r,o)?po(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 Ub(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 Hb(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=Hb({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&&Sg(e.rendering?.alphaIndex)===t.fromAlphaIndex}var Ca=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=Ca(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 Wb(e){let t=e.scene.gameObjects.filter(r=>!!Se(r)||!!Nr(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}:Wb(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Po(e){return e.filter(t=>NM(t.kind)&&tu(t)).map(eu).sort(ru)}function Ga(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(eu).sort(ru)}function An(e,t){return{assets:[...t],resourceProjection:Xb(e,t)}}function Xb(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 Yb(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 Yb(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=Io(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=Io(c),u=va(d?.meshIndex),l=Ve(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=Io(c),u=va(d?.nodeIndex),l=Ve(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=qb(t,"meshCount",r.length)||qb(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=Io(c);if(!d||Ve(d.sourceMeshName))return c;let u=va(d.meshIndex);if(u==null)return c;let l=va(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 qb(e,t,r){let n=va(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=Io(r.metadata),o=Ve(n?.previewTextureAssetId);o&&t.add(o);let a=Io(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 va(e){return Number.isInteger(e)&&e>=0?e:null}function Io(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?Ur(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(Ur({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){ja(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 ja(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 Zb(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 Zb(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),To(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),To(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),To(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),To(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 Ur(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 To(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>To(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):To(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 Na(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 Dn(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,Dn(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,Dn(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,Dn(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(Dn(t.emission,"texture"),Dn(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),Dn(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function Dn(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 Qb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=nt(t,r);if(a?!so(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)),ao(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 Mn="mat_default_pbr",xo="mat_default_standard",VM="00000000-0000-4000-8000-000000000001",UM="00000000-0000-4000-8000-000000000002",wn=Mn,Sr={id:Mn,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:xo,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(Sr)}function WM(){return structuredClone(KM)}function eS(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 tS(e){return e?.system?.preset==="default-pbr"||e?.id===Mn?"default-pbr":e?.system?.preset==="default-standard"||e?.id===xo?"default-standard":null}function Fa(e){let t=structuredClone(Sr.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 Kr(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=kn(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function kn(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var au=[Mn,xo],qM="New Material";function rS(e,t,r=`${t.displayName} Material`){let n=_a(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=_a(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 nS(e,t,r){let n=t.name?.trim()||t.id,o=_a(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=_a(e);return{id:ur(r),guid:r,name:Bs(e,t.name),shaderId:Sr.shaderId,definitionVersion:Sr.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:Fa(t.profile)}}function oS(e,t){let r=`${t.sourceAssetGuid||t.sourceAssetId}:material:${t.sourceMaterialIndex}`,n=Up(r),o=ur(n),i=(e.scene.materialAssets??[]).some(s=>s.id===o||s.guid===n)?_a(e):n;return{id:ur(i),guid:i,name:Bs(e,t.name),shaderId:Sr.shaderId,definitionVersion:Sr.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:Fa(t.profile)}}function aS(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 _a(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 iS(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 sS(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=Qb(d,r,nt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function cS(e,t,r=[]){let n=ee(e,t),o=cl(e,t);return n?Na(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 dS(e,t){return cS(e,t,au)}function YM(e,t,r=[]){return cS(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function iu(e){return Na(e,au)}function lS(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 uS(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=Ao(y),E=I?ee(e,I):null,A=fS(S),D=A[0],j=S.slotId?u.get(S.slotId):void 0;if(j){f.push({status:"changed",reason:"slot-remapped",...S.slotId?{slotId:S.slotId}:{},previousSlotId:j.fromSlotId,ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...D==null?{}:{sourceMaterialIndex:D},...A.length>0?{sourceMaterialIndices:A}:{},materialAssetId:I,bindingPath:`overrides.materialSlotBindings.${S.slotId}.materialAssetId`,conflict:!1});continue}let _=pS(E,o,n?.id)?.sourceMaterialIndex;if(_!=null&&A.length>0&&!A.includes(_)){f.push(mS({status:"changed",reason:"source-material-changed",...S.slotId?{slotId:S.slotId}:{},ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...D==null?{}:{sourceMaterialIndex:D},...A.length>0?{sourceMaterialIndices:A}:{},previousSourceMaterialIndex:_,...I?{materialAssetId:I}:{},bindingPath:S.slotId?`overrides.materialSlotBindings.${S.slotId}.materialAssetId`:""}));continue}if(!I&&A.length>0){f.push({status:"unchanged",reason:"slot-current",...S.slotId?{slotId:S.slotId}:{},ownerNodePath:Kt(S)??void 0,label:Ks(S,b),...D==null?{}:{sourceMaterialIndex:D},...A.length>0?{sourceMaterialIndices:A}:{},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),...D==null?{}:{sourceMaterialIndex:D},...A.length>0?{sourceMaterialIndices:A}:{},...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(mS({status:"removed",reason:"slot-removed",slotId:b,...Ao(S)?{materialAssetId:Ao(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=Ao(u),m=l?ee(e.document,l):null,f=pS(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&&fS(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 Ao(e)===Ao(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 fS(e){return ot(e)}function pS(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 Ao(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function mS(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 gS(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 bS(e,t){let r=du(t);if(r.length===0)return lw(e);let n={};for(let s of e.scene.materialAssets??[]){let c=s.origin;if(!c||!Number.isInteger(c.sourceMaterialIndex))continue;(c.sourceAssetGuid&&t.guid?c.sourceAssetGuid===t.guid:c.sourceAssetId===t.assetId)&&(n[String(c.sourceMaterialIndex)]=s.id)}let o=[];for(let s of r)for(let c of s.sourceMaterialProfiles??[]){let d=String(c.sourceMaterialIndex);if(n[d]||!c.profile)continue;let u=o.length===0?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},l=oS(u,{profile:c.profile,name:c.materialName?.trim()||`${t.displayName} Material ${c.sourceMaterialIndex+1}`,sourceAssetId:t.assetId,...t.guid?{sourceAssetGuid:t.guid}:{},sourceSlotId:s.slotId,sourceMaterialIndex:c.sourceMaterialIndex,...c.materialName?.trim()?{sourceMaterialName:c.materialName.trim()}:{}});o.push(l),n[d]=l.id}let a=o.length===0?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},i=cw(a,t);return o.length===0&&!i.changed?{document:e,createdMaterialAssetIds:[],updatedMaterialAssetIds:[],changed:!1,materialAssetIdsBySourceMaterialIndex:n}:{document:i.document,createdMaterialAssetIds:o.map(s=>s.id),updatedMaterialAssetIds:i.updatedMaterialAssetIds,changed:!0,materialAssetIdsBySourceMaterialIndex:n}}var sw=[["baseColor","texture"],["normal","texture"],["metallicRoughness","texture"],["occlusion","texture"],["emission","texture"],["emission","maskTexture"],["alpha","texture"]];function cw(e,t){let r=new Map;for(let a of du(t))for(let i of a.sourceMaterialProfiles??[])i.profile&&r.set(i.sourceMaterialIndex,i.profile);if(r.size===0)return{document:e,updatedMaterialAssetIds:[],changed:!1};let n=[],o=(e.scene.materialAssets??[]).map(a=>{let i=a.origin;if(i?.type!=="imported")return a;let s=i.sourceMaterialIndex;if(typeof s!="number"||!Number.isInteger(s)||!(i.sourceAssetGuid&&t.guid?i.sourceAssetGuid===t.guid:i.sourceAssetId===t.assetId)||a.shaderId!==Sr.shaderId)return a;let d=r.get(s);if(!d)return a;let u=dw(a.properties,d);return u===a.properties?a:(n.push(a.id),{...a,properties:u})});return n.length===0?{document:e,updatedMaterialAssetIds:n,changed:!1}:{document:{...e,scene:{...e.scene,materialAssets:o}},updatedMaterialAssetIds:n,changed:!0}}function dw(e,t){let r=t,n=e;for(let[o,a]of sw){let s=r[o]?.[a],c=s&&typeof s=="object"?s.textureAssetId:void 0;if(typeof c!="string"||!c.trim())continue;let u=n[o]?.[a];if(u===null||u&&typeof u=="object"&&(u.textureAssetId!==void 0||u.url!==void 0))continue;n===e&&(n=structuredClone(e));let l=n,m=l[o]??{};l[o]={...m,[a]:{...u&&typeof u=="object"?u:{},textureAssetId:c.trim()}}}return n}function SS(e,t,r){let n={};for(let o of du(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 du(e){if(e.type!=="glb"&&e.type!=="gltf")return[];let t=e.metadata?.materialSlots;return Array.isArray(t)?t.map(jr).filter(r=>!!r):[]}function lw(e){return{document:e,createdMaterialAssetIds:[],updatedMaterialAssetIds:[],changed:!1,materialAssetIdsBySourceMaterialIndex:{}}}function yS(e,t){let r=new Set,n=e.properties,o=On(n)?n:{},a=On(t.defaultProperties)?t.defaultProperties:{},i=hS(t.propertiesSchema,o,a,"properties",r),s=new Set;ES(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 hS(e,t,r,n,o){if(e.kind!=="object")return uw(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=On(t)?t:{},i=On(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=hS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function uw(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(!On(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 ES(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;On(o)&&!mw(o)?ES(o,a,r):r.add(a)}}function mw(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 On(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function On(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function fw(e){return e?.system?.preset}function PS(e,t){let r=fw(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 IS(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function TS(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(pw);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?IS(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:IS(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function pw(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function xS(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 AS={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 yr(e){return AS[e]??AS.zh}function Js(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var gw={},DS=new WeakMap;function MS(e,t,r,n,o){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function wS(e,t){return PS(e,RS(t))}function bw(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 Sw(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function RS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function CS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=xw(e,t,r,n,o,a??void 0);if(GS(t,o))return[...i,N({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=>yw({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function yw(e){let{fieldDefinition:t}=e,r=kS(e.text,t.labelKey,t.label??t.path),n=Iw(e.text,t.tooltipKey,t.tooltip),o=vS(e.materialAsset.properties,t),a=t.control==="texture"&&so(e.materialAsset.shaderId,t.path)?hw(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=Aw({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=Mw(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=ww(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:kS(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"?oo(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=>!Ew(e.definition,e.materialAsset.properties,d));return c&&(i=Cw(i,!1,Pw(e.text,c))),a?Ow(i,e.text,a):kw(i,e.text,t.defaultValue)}function hw(e,t){let r=Xs(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function vS(e,t){if(t.control==="texture"){let n=Xs(e,t.schemaPath??t.path);return jS(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 Ew(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?vS(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 kS(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function Iw(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function Pw(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 Tw(e){return e.defaultMaterialAssetIds??[Mn,xo]}function GS(e,t){return Na(e,Tw(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function xw(e,t,r,n,o,a){if(!GS(t,o)){let i=o.materialShaderDefinitions??Rr;return[Qs(e,t,"name",r.assetName,wS(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[MS(`${lr}${t.id}.name`,r.assetName,wS(t,r),n,r.tooltips.assetName),MS(`${lr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function Aw(e){let t=lu(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=OS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=OS(e.context,e.path,n);return o.ok?o.value:null}}}function Zs(e,t,r,n){return{...TS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:Dw(t),candidateValue:"assetId"})}}function lu(e,t){return qs(e.textureAssets,t)}function jS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function OS(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 Dw(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 Mw(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 ww(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{...xS({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 kw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!Rw(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function Ow(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 Rw(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function Cw(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function NS(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:jw(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:vw(t,r.value),validation:Gw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function vw(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function Gw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function jw(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 Nw(e,t,r){return NS(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:bw(r),displayText:RS(r),document:e,ownershipText:Sw(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function Fw(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Ys(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=DS.get(e);a||(a=new WeakMap,DS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??gw,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 _w={createSelectorInspectorPropertyWithUsage:NS,createSelectorInspectorPropertyWithCachedUsage:Nw,createPickerControlOptionsWithUsage:Ys,createPickerControlOptionsWithCachedUsage:Fw},Rn=_w;function FS(e,t,r){let n=ng(e,t);if(n.state==="asset"&&n.materialAsset){let o=tS(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 _S(e,t,r){let n=Gr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function $w(e,t,r,n,o,a={}){let i=yr(Js(t)),s=[];return Gr(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:kn(d,y)?.profile,E=Rn.createSelectorInspectorPropertyWithUsage(e,r,{path:S,label:d.label||uu(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(Lw(E,d,f,i,a))}),s}function Lw(e,t,r,n,o){let a=ot(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:Kr(t,a),s=a==null?null:kn(t,a)?.profile,c=s?Vt(Fa(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 zw(e,t,r,n){let o=Gr(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(Kw("asset.materialSlots.reimportConflicts",r.reimportConflicts,Bw(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>Vw(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 Bw(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 Vw(e,t,r,n,o,a,i){let s=dl(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??wn),u=Rn.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=ot(r),m=l[0],f=m==null?null:Kr(r,m),g=r.sourceSurfaces[0],b=g.ownerNodePath;return{key:ag(r),label:r.label||uu(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 Uw={createChildMaterialBindingInspectorPropertiesWithUsage:$w,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:zw},$S=Uw;function uu(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function Kw(e,t,r,n,o){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var LS="materialAsset::",Hw=5;function Ww(e){return e.startsWith(LS)&&e.slice(LS.length).trim()||null}function qw(e,t,r,n,o,a){let i=[],s=Js(t),c=yr(s),d=t.overrides?.materialBinding,u=bs(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??wn,f=ee(e,m),g=l?.materialAssetId?l:{...l,materialAssetId:wn};if(!og(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:FS(g,f,c),persistence:"document",collapsedByDefault:!1,properties:[Rn.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:_S(e,t,c),persistence:"document",collapsedByDefault:!1,properties:S}),i}function Jw(e,t,r,n){let o=Ww(t),a=o?ee(e,o):null;if(!a)return null;let i=yr("zh"),s=n.forMaterial(a.id),c=CS(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,Qw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],b=[uo({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}),uo({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:Hw,items:s.map((E,A)=>({key:`${E.scope}:${E.gameObjectId}:${E.bindingPath}:${A}`,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(D=>typeof D[1]=="string"&&D[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,A]of[...y?.inspector.sections??[]].sort((D,j)=>D.order-j.order||D.id.localeCompare(j.id)).entries())zS(S,{id:`material${A.id.charAt(0).toUpperCase()}${A.id.slice(1)}`,title:A.title,order:A.order,properties:[...E===0?f.filter(D=>D.path===d):[],...f.filter(D=>D.controlOptions?.materialShaderSectionId===A.id)]});let I=new Set(S.flatMap(E=>E.properties.map(A=>A.path)));return zS(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 Xw(e,t,r,n={},o){return qw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function Yw(e,t,r={}){return Jw(e,t,r,_e.getCachedUsageIndex(e))}var Zw={createArtistMaterialInspectorSectionsWithCachedUsage:Xw,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:Yw},mu=Zw;function zS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function Qw(e,t,r,n,o){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var BS="modelAsset::";function ek(e){return e.startsWith(BS)&&e.slice(BS.length).trim()||null}function VS(e,t,r={}){let n=ek(t),o=n?tk(e,n,r.modelAssets):null;if(!o)return null;let a=ak(o),i=[rk(o)];return i.push(nk(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 tk(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?Ur(n??{id:t,type:"glb"},o):n??null}function rk(e){let t=ik(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:qi,persistence:"readonly",collapsedByDefault:!1,properties:[$a(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),$a(`assets.${e.id}.id`,"Asset ID",e.id,1),$a(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[$a(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function nk(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:[$a(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>ok(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 ok(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:Kr(e,a),s=a==null?null:kn(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 ak(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(jr).filter(r=>!!r)}function $a(e,t,r,n){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function ik(e){return typeof e=="string"&&e.trim()?e.trim():""}function La(e,t,r,n={}){let o=bS(e,t),a=o.document;if(t.type==="prefab"){let u=US(a,t),l=u?Ur(u,t):fu(t),m=HS(a,t,l,r,n),f=ck(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=US(a,t),s=i?Ur(i,t):fu(t),c=t.type==="texture"?sk(a,t,s.id,r,n):KS(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 sk(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=dt(pu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=bu(a,o.objectId,i),c=Su(e,o.parentId),d=gu(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 fu(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 KS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=dt(pu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=bu(a,o.objectId,i),c=Su(e,o.parentId),d=gu(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 HS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=dt(pu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=bu(a,o.objectId,i),c=Su(e,o.parentId),d=gu(e,c,n,o);return ug({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 pu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function US(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function ck(e,t){let r=ba(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 gu(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 bu(e,t,r){if(t===void 0)return Ca(e,$s(r));if(Ca([],t)!==t||e.includes(t))throw new Error(`Requested asset instance id is invalid or already used: ${t}`);return t}function Su(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 dk(e){return!!e&&rt(e)}function Eu(e,t,r={}){let n=t.type==="document.replace"?t.document:qS({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function qS(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return Ba({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return Cn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return za(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return La(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return me(r.targetId)?t:xn(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=L(o,a.targetId),s=i?G(i):null;if(!s)return o;if(dk(a.transform))return xn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return xn(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??lk,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=mk(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?yu(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??uk;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&&!WS(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=!WS(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=yu(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:yu([...i,r.gameObject],r.order)}}}return t}function lk(e){return Mt(e)}function uk(e){return Dt(e)}function mk(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 yu(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 WS(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]):hu(e.position,t.position)&&hu(e.rotation,t.rotation)&&hu(it(e,"scale"),it(t,"scale"))}function hu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var fk="main_camera",pk="environment_light",gk="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"},Ka={type:"directional",intensity:2,direction:{...Ts},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},vn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function XS(){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 YS(e){let t=xu({...e,kind:"transform",transformType:"camera",camera:Ha(e.camera)});return delete t.light,delete t.primitive,Au(t,e)?e:t}function Tu(e,t){let r=xu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:Gn(e.light,t)});return delete r.camera,delete r.primitive,Au(r,e)?e:r}function ZS(e){let t=xu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,Au(t,e)?e:t}function xu(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 Ha(e){let t=tc;return{...t,...e??{},projection:bk(e?.projection),fov:Va(e?.fov,t.fov??.85),targetOffset:Ek(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:Va(e?.minZ,t.minZ??1),maxZ:Va(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:Ua(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:Ua(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:Va(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:Va(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:yk(e?.inertia,t.inertia??.9),targetScreenOffset:hk(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:Sk(e?.inspectorLanguage)}}function QS(e,t){return JS(e,t,{valueField:"beta",lowerField:"lowerBetaLimit",upperField:"upperBetaLimit",minValue:Number.NEGATIVE_INFINITY}),JS(e,t,{valueField:"radius",lowerField:"lowerRadiusLimit",upperField:"upperRadiusLimit",minValue:.001}),e}function JS(e,t,r){let n=`camera.${r.valueField}`,o=`camera.${r.lowerField}`,a=`camera.${r.upperField}`,i=Ua(e[r.valueField],tc[r.valueField]),s=Ua(e[r.lowerField],i),c=Ua(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 bk(e){return e==="perspective"?"perspective":"orthographic"}function Sk(e){return e==="en"?"en":"zh"}function ey(e){return e==="en"?"en":"zh"}function Ua(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Va(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function yk(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function hk(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 Ek(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 ty(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 Ik(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function Gn(e,t="directional"){return Ik(e,t)==="hemispheric"?Tk(e):Pk(e)}function Pk(e){let t=Ka,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:ey(ry(r))}}function Tk(e){let t=vn,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:ey(ry(r))}}function ry(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function Au(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ny(e,t,r){return{id:Du(t,fk,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:Ha(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 oy(e,t,r){return{id:Du(t,gk,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:Gn(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 ay(e,t,r){return{id:Du(t,pk,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:Gn(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 Du(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function sy(e,t){let r=t.name.trim();if(!r)return null;let n=L(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 cy(e,t){let r=by(e,t);if(r===null)return null;let n=dt(oc(e),t.name,{fallbackName:"Empty"}),o=ly(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 dy(e,t){let r=jk(t.shape);if(!r)return null;let n=kk(e,t);if(n===null)return null;let o=dt(oc(e),t.name,{fallbackName:Nk(r)}),a=ly(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=Fk(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 ly(e,t,r){return t===void 0?ct(e,r):ct([],t)===t&&!e.includes(t)?t:null}function uy(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=vk(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 wu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=L(e,t.draggedId),o=L(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."}:Gk(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 my(e,t,r={}){if(!wu(e,t,r).ok)return null;let o=L(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&&Py(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 ku(e,t,r={}){let n=gr(e),o=dp(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=Cu(e,t);if(i&&!vu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=L(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 fy(e,t,r={}){if(!ku(e,t,r).ok)return null;let o=gr(e),a=ht(o,t.ids),i=Cu(e,t),s=a.map(l=>{let m=L(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?Jt(m):nc(e,l,i,t,r),g=f?Pn(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=Ok(e,a,t),d=e.scene.gameObjects.map(l=>l.id);return!s.some(l=>{let m=L(e,l.targetId);return!m||m.parentId!==l.parentId||!Py(Jt(m),l.transform)})&&_k(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 Ou(e,t,r={}){let n=gr(e),o=lp(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=Sy(e,t.parentId??null);if(i&&!vu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=Iy(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!Ma(e,i,c,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."};for(let d of a){let u=L(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||!yy(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function py(e,t,r={}){if(!Ou(e,t,r).ok)return null;let o=gr(e),a=ht(o,t.ids);if(a.length===0)return null;let i=Sy(e,t.parentId??null),s=Iy(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=Ma(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=L(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=yy(c,y,r);if(!I)return null;f[b]=I}let g=Rk(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 gy(e){let t=e.isProtectedDuplicateSource??xk,r=gr(e.document),n=new Set(ht(r,e.targetIds).filter(S=>{let y=L(e.document,S);return!!y&&!Z(y)&&!t(y,e.document)&&!Dk(e.document,y.id,t)})),o=Ru(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=Mk(e.document,o,a,t);for(let S of u){let y=L(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=>L(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=Ak(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:wk(e.document,o,i)},createdIds:m,selectedIds:f,activeId:b,changedIds:m}}function xk(e){return Mt(e)}function Ak(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 Dk(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 Mk(e,t,r,n){let o=Ru(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=L(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 wk(e,t,r){let n=Ru(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 Ru(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 by(e,t){if(t.parentId){let n=L(e,t.parentId);return n&&At(n)?n.id:null}let r=t.activeId?L(e,t.activeId):null;if(r&&At(r))return r.id;if(r?.parentId){let n=L(e,r.parentId);if(n&&At(n))return n.id}return ye(e)}function kk(e,t){return t.parentId===null?ye(e):by(e,t)}function Cu(e,t){if(t.placement==="root")return ye(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?L(e,t.targetId):null;return t.parentId??r?.parentId??ye(e)}function Sy(e,t){return t&&vu(e,t)?t:ye(e)}function vu(e,t){let r=L(e,t);return!!r&&At(r)}function nc(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=L(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 Pn(s);let c=Ma(e,r,a,o.preserveWorldPolicy);return c?Pn(c):null}function yy(e,t,r={}){let n=Zi(r),o=io(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?Pn(o):null}function Ok(e,t,r){let n=hy(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=Ck(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:Cu(e,r)});return Ey(a,n,i)}function Rk(e,t,r,n){let o=hy(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 Ey(s,[t,...o],u)}function hy(e,t){let r=kt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function Ck(e,t,r){return r.beforeId?iy(t.indexOf(r.beforeId),t.length):r.afterId?rc(e,t,r.afterId):r.placement==="before"&&r.targetId?iy(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 Ey(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function iy(e,t){return e>=0?e:t}function Iy(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 vk(e,t,r){let n=r?L(e,r):null;if(n?.parentId&&!t.has(n.parentId)&&L(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 Gk(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 jk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function Nk(e){return e[0].toUpperCase()+e.slice(1)}function Fk(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 Py(e,t){return!Tt(e)||!Tt(t)?la(Fe(e),Fe(t)):Mu(e.position,t.position)&&Mu(e.rotation,t.rotation)&&Mu(e.scale,t.scale)}function Mu(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 _k(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ju(e){return{getHierarchyItems(t){return Gu(t,e)},normalizeHierarchyDocument(t){return $l(t)},createRenamePatch(t,r){return hr(sy(t,r))},createCreateGroupPatch(t,r){return hr(cy(t,r))},createCreatePrimitivePatch(t,r){return hr(dy(t,r))},createDeleteSubtreePatch(t,r){let n=uy(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:hr(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."}:wu(t,r)},createReparentPatch(t,r){return hr(my(t,r))},validateHierarchyMove(t,r){let n=Gu(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=$k(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:ku(t,r)},createHierarchyMovePatch(t,r){return hr(fy(t,r))},validateGroupSelection(t,r){let n=Gu(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=Lk(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Ou(t,r)},createGroupSelectionPatch(t,r){return hr(py(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return hr(gy({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return hr(Zl(t))}}}function Gu(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 $k(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 Lk(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&At(n)?n.id:r.resolveRootContainerId(e)}function hr(e){return e?{...e,patch:e.patch}:null}function Nu(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)&&zk(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 zk(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 Fu(e,t,r){let n=r.normalizeRootTransformDocument(Bk(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 _u(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=kg(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 Bk(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 Uk(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return Eu(e,t,Vk(r))}function Vk(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 Uk(e,t){return Yl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function Do(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 Kk(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):Hk(e,t,r,c,o)}let i=Cn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function Ty(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 Wk(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>sc(c,d,r,n,o),e);let s=za(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 Kk(e,t,r,n,o){let a=iS({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 Hk(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 Wk(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 Ay(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:In(r.path,r.value)};return Ba({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return xy({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=In(t.path,t.value),n=xy({...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 xy(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 qk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Jk=/^transform\.(position|rotation|scale)$/,Xk=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Cn(e,t,r,n,o={}){return Yk({document:e,targetId:t,path:r,value:n,options:o})}function za(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)||Lu(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=Pu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function Iu(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(Lu(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=ky(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 Yk(e){if(Lu(e.targetId,e.path))return e.document;let t=L(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=Pu(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 Pu(e,t,r,n={}){let o=ky(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function ky(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?Dy(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?My(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 pn(a)&&Zk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=eO(t,r);return Oe(a,t,c),tO(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??aO)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return rO(a,r,n),a;if(nO(a,t,r)){let c=i?Dy(a):null;return i&&c&&!wy(i,c)?po(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=Oy(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=oO(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=Ry(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=Aa(a.light.direction,s??void 0));let c=s?My(a):null;return s&&c&&!wy(s,c)?xs(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Jl(a)),a}function Dy(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function My(e){return e.light?.type==="directional"?{...e.light.direction}:null}function wy(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 Zk(e,t,r){if(!Qk(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 Qk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function eO(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function tO(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 Lu(e,t){return me(e)&&qk.test(t)}function rO(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=Oy(e.camera,r):delete e.camera,a==="light"?e.light=Ry(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function nO(e,t,r){let n=t.match(Jk);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(Xk);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 Oy(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):Cy(e)}function oO(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function Ry(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):Cy(e)}function aO(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function Cy(e){return iO(e)??{}}function iO(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var Ny=["position","rotation","scale"],Fy=["x","y","z"],sO=1e-6;function zu(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 Ny)for(let s of Fy)t.push(lO({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}),zy(e.gameObject)&&t.push(...cO({gameObject:e.gameObject,validateField:e.validateField})),t}function _y(e){let t=[];for(let r of Ny)for(let n of Fy){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)>sO),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 Wa(e){return e.length===0||e.some(r=>!zy(r))?[]:[Gy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Gy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function cO(e){return[vy({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),vy({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function vy(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=In(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:Cn(t,n.targetId,e.path,o)}}}function Gy(e,t){let n=e.map(a=>$y(a,t.path,t.defaultValue))[0]??t.defaultValue,o=dO(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 dO(e,t){let r=e.map(n=>Ly(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function $y(e,t,r){let n=Ly(e);return t==="shadow.cast"?jy(n.cast):t==="shadow.receive"?jy(n.receive):r}function jy(e){return e==="enabled"}function Ly(e){return We(e.shadow).shadow??{}}function zy(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 lO(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)=>uO({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function uO(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=L(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 mO(e.document,e.targetId,{position:s,rotation:c,scale:d})}function mO(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Fl(n,r):n)}}}function By(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),..._y(r),...Wa(r)]}}var Vu="enabled",Vy="shadow.",Uy=200;function Ku(e){let t=fO(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??Uy,a=pO(t),i=Wa(a),s=t.length>o,c=s?gO({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):By({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>Hy(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Ky({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 Ky(e){let t=bO(e.document,e.serialized,e.serialized.properties.filter(n=>Hy(n.path)),e.renderingProfile),r=Bu("common","Common",10,e.serialized.properties.filter(n=>n.path===Vu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,Bu("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,Bu("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Vu&&!n.path.startsWith(Vy)),e.document)].filter(n=>!!n)}function fO(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 pO(e){return e.filter(t=>Eo({gameObject:t,nodeKind:Y(t)}))}function gO(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:Wa(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 bO(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=>Eo({gameObject:S,nodeKind:Y(S)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&Eo({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=Uu(d,0),m=Uu(u,1),f=En({path:d.path,nodeKind:c,document:e}),g=En({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 Hy(e){return e.startsWith(Vy)}function Bu(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=Uu(a,i),c=SO(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?En({path:a.path,nodeKind:c,document:o}):s.validate}})}}function Uu(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":yO(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:hO(e.valueType),order:t,source:e}}function SO(e,t){if(t.startsWith("transform."))return"transform";if(t===Vu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function yO(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function hO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var EO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Ba(e){if(me(e.patch.targetId)&&EO.test(e.patch.path))return e.document;let t=L(e.document,e.patch.targetId);if(!t)return e.document;let r=e.patch.path.startsWith("transform.rotation")?Wy(t):null,n=e.patch.path.startsWith("light.direction")?qy(t):null,o=Gp(e.document,zu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=L(o,e.patch.targetId);if(!a)return o;let i=r?Wy(a):null,s=n?qy(a):null,c=r&&i&&!Jy(r,i),d=n&&s&&!Jy(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?po(u):u;return d?xs(l):l})}}}function Wy(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function qy(e){return e.light?.type==="directional"?e.light.direction:null}function Jy(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 Wu(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 qu(e){let t=Ku({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 Ju(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 Hu(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),qa(t,a&&r?e.createCameraSection?.():null),Hu(t,a&&n?e.createLightSections?.():null),qa(t,a&&o?e.createMarkerSection?.():null),qa(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))&&(Hu(t,e.createMaterialSections?.()),qa(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function qa(e,t){t&&e.push(t)}function Hu(e,t){if(t)for(let r of t)qa(e,r)}function Xu(e){let t=e.outline,r=t?"active":"default",n=r==="default"?Xy: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:PO(IO(e),r,n)}}var Xy="Outline fields are showing defaults; configure an outline override before edits affect this object.";function IO(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=N({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 PO(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 TO={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"},xO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},AO={box:"\u77E9\u5F62",cylinder:"\u5706\u5F62",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function em(e){let t={...TO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=MO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=e.markerTypeCatalog.find(l=>l.type===r.type)??null,i=n==="region"?DO(a,e.formatMarkerGeometryKindLabel):[],s=RO(r),c=s?.kind==="scene-object"?s.id:"",d=wO(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}),Zu("marker.kind",t.kindLabel,OO(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}):Zu("marker.geometry.kind",t.geometryLabel,Yy(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}),Zu("marker.target.status",t.targetStatusLabel,CO(e.document,s,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:kO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:u}}function DO(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:Yy(o,t),value:o}))}function MO(e,t,r,n){let o=e.map(a=>({label:Qu(a.type,a.label||a.type,n),value:a.type}));return t&&!o.some(a=>a.value===t)&&o.push({label:Qu(t,t,n),value:t}),o}function wO(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 kO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Qu(t,o?.label||t,n)}function Qu(e,t,r){return r?.(e,t)??t}function OO(e,t){return t?.(e)??xO[e]??e}function Yy(e,t){return t?.(e)??AO[e]??e}function RO(e){return e.target?Yu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Yu(e.geometry.target):null}function CO(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 Yu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Zu(e,t,r,n){return N({path:e,label:t,value:r,order:n,source:"Document"})}var Ja={r:1,g:1,b:1,a:1};function vO(e){return{...e}}function th(e){let t=vO(e);return{services:t,normalizeLayoutPatchValue:r=>pc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>sh(r,n,t),canPatchMultiField:(r,n,o,a)=>_O(r,n,o,a,t),patchLayout:(r,n,o)=>$O(r,n,o,t),patchKind:(r,n,o)=>LO(r,n,o,t),patchInspectorField:(r,n,o,a)=>zO(r,n,o,a,t),normalizeGameObject:r=>jn(r,t),replaceUi:(r,n,o)=>VO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>dc(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>UO(r,n,t),normalizeScales:(r,n,o)=>fc(r,t,n,o),mergeDefaults:r=>ut(r,t.createDefaultGroundDecal,t)}}function rh(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 GO=75;function tm(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:dh({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=ti(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>jO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function jO(e,t,r={}){let n=ti(e);if(!n)return null;let o=gR(n.id)??`layer_${t}`,a=wo(n.rect),i=n.fontSize==null?null:lc(n.fontSize),s=n.rotationDeg==null?null:Oo(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:Hr(i)}}}function wo(e){let t=ti(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 nh(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 wo(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(oh(e)){let r=Oo(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(ah(e)){let r=nm(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=Xa(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=Ya(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(xc(e)){let r=rm(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(Wr(e)){let r=ei(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Za(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 oh(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 ah(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 Wr(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ac(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Za(e)||Wr(e)}function Qa(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ac(e)}function NO(e,t,r={}){return t==="rect"?ko(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"?ih(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 ko(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 ih(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function sh(e,t,r={}){let n=e.layers.filter(o=>ko(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 Xa(e){let t=ti(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:Hr(Math.max(0,Math.min(1,r))),g:Hr(Math.max(0,Math.min(1,n))),b:Hr(Math.max(0,Math.min(1,o))),...a==null?{}:{a:Hr(Math.max(0,Math.min(1,a)))}}}function Ya(e){let t=Yt(e);return t==null?null:Hr(Math.max(0,Math.min(1,t)))}function rm(e){let t=Yt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function Oo(e){let t=Yt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=Hr(r);return Object.is(n,-0)?0:n}function nm(e){let t=lc(e);return t==null?null:Hr(t)}function ei(e){let t=Yt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function Hr(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)?wo(t)??t:oh(e)?Oo(t)??t:bc(e)&&typeof t=="string"?t.trim():hc(e)&&typeof t=="string"?t:ah(e)?nm(t)??t:Sc(e)||Pc(e)||Ec(e)?Xa(t)??t:yc(e)||Tc(e)||Ic(e)?Ya(t)??t:xc(e)?rm(t)??t:Wr(e)?ei(t)??t:t}function ch(e,t,r){if(t==="rect"){let n=wo(r);return n?FO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=Oo(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=nm(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=Xa(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return Mo(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ya(r);if(n===null)return null;let o={...e.color,a:n};return Mo(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=rm(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=Xa(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return Mo(e.tint??Ja,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ya(r);if(n===null)return null;let o={...Ja,...e.tint??{},a:n};return Mo(e.tint??Ja,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=Xa(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return Mo(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Ya(r);if(n===null)return null;let o={...e.text.color,a:n};return Mo(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 Mo(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function FO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function dh(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 _O(e,t,r,n,o){if(!Qa(r))return!1;let a=XO(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"||Wr(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=pc(n,o);return d?sh(i,d,o):!1}let s=Za(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Dc(c,o)&&NO(c,s.field,o)}function $O(e,t,r,n){let o=pc(r,n);return o?uh(e,a=>a.id===t?KO(a,o,n):a):e}function LO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:uh(e,a=>a.id===t?HO(a,o,n):a)}function zO(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,jn({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if(Wr(r))return BO(e,t,r,n,o);let a=Za(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"&&!ko(l,o))return d;let m=ch(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,jn({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function BO(e,t,r,n,o){let a=ei(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,jn({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function VO(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,jn({...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,tm(r,n)):e}function UO(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=ti(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||!JO(s)||!s.scale)return i;let c=n??dh(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 jn(e,t){let r=WO({...e,kind:"transform",transformType:"groundDecal",groundDecal:ut(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function lh(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function KO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=ut(e.groundDecal,r.createDefaultGroundDecal,r);return jn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!ko(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=ch(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function HO(e,t,r){let n=ut(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return jn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function WO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[qO(),...e.components]}}function qO(){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 JO(e){return e.type==="Transform"&&e.mode!=="matrix"}function XO(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function uh(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function mh(e,t,r={},n){let o=ut(t,n.createDefaultGroundDecal,n),a=[pR("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:Sh(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:mR(o),aspectRatioUsesDecalSize:uR(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(eh({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(eh({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=yh(c,n);if(uc(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=iR(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(dR(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&mc(c,n)||c.kind==="textureProgress"&&uc(c,n))&&(a.push(cR(e,c,s,d,i,n)),i+=1),mc(c,n)&&(a.push(sR(e,c,s,d,i,n)),i+=1),ih(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(lR(e,c,s,d,i,n)),i+=1)}return fR(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function fh(e,t,r,n){let o=n.getTargetGroundDecal(e),a=ut(o,n.createDefaultGroundDecal,n),i=mh(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:ZO(a,n),persistence:"document",collapsedByDefault:!1,properties:[YO(a,[s,...c],n),...c]}}function YO(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 ZO(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 ph(e,t,r,n,o){let a=bh(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=QO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=mh(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>tR(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:rR(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 gh(e,t,r){return bh(e,t,r).map(n=>r.getTargetId(n.target))}function bh(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 QO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>eR(o,t));return n.every(o=>o===r)}function eR(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 tR(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"||Wr(e.path)?!0:e.path==="groundDecal.layers"||Za(e.path)?t:!1}function rR(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(nR(i.decal,t,r,n)));return a.some(i=>i!==o)}function nR(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 Sh(e,r,n).layers;let o=Za(t);if(!o)return;let a=e.layers[o.index];if(a)return oR(a,o.field)}function oR(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??Ja: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"?om(e):void 0}function Sh(e,t,r){let n=Ki(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>ko(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>Zy(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=Zy(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 Zy(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:yh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Mc(t,n),enabled:t.enabled!==!1,editable:ko(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:aR(e,t,n)}}function yh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function aR(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:Qy(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:Qy(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 om(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:GO;return Math.round(Math.max(0,Math.min(100,t)))}function Qy(e){return om(e)/100}function iR(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 sR(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 cR(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:om(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function dR(e,t,r,n,o,a){let i=t.tint??Ja;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 lR(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 uR(e){return e.size.width>0&&e.size.depth>0}function mR(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function fR(e,t){let r=N(t);r&&e.push(r)}function pR(e,t,r,n,o){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function eh(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 ti(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function gR(e){return typeof e=="string"&&e.trim()?e.trim():null}var Nn="groundDecal";function bR(e){if(e.id!==Nn||e.scene?.kind!==Nn||!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 hh(e,t){let r=bR(e);if(!r)return null;let n=r.documentPolicy,o=SR(n),a=s=>s?.transformType===Nn&&o.isGroundDecalConfig(s.groundDecal);return yR({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>rh({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)=>lu(d,u??""),getMaterialText:yr,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 SR(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 yR(e){let r=(e.features.find(i=>i.id===Nn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=th({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=hR({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===Nn&&i.scene?.kind===Nn?a:null}}}function hR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:Nn}],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 nh(n,o)},isInspectorPatchPath:Ac,isProjectionPath:lh,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),IR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=tm(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)=>ER(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[fh(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>ph(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>gh(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Qa,isSerializedMultiProjectionPath:Qa,getSerializedMultiProbeValue:PR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Qa(a)||t.canPatchMultiField(n,o,a,i)}}function ER(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 IR(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 PR(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 wo({x:0,z:0,width:1,depth:1});if(Wr(e))return ei(512)}function ri(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: ${TR(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 TR(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var am=64*1024,xR=8,Eh=256,AR=8*1024,DR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function Ih(e){if(!ni(e))throw new Error("asset_import_payload_must_be_object");for(let a of Object.keys(e))if(!DR.has(a))throw new Error(`asset_import_field_not_allowed:${a}`);OR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:wR(t.assetPath),n=Ro(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=Ro(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]=kR(t[a],a));if(t.metadata!==void 0&&!ni(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!ni(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:MR(t.external.assetPath,"external.assetPath");t.external={...Ro(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:Ro(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...Ro(t.external.assetUrl,"external.assetUrl")?{assetUrl:Ro(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function MR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=ri(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 wR(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 ri(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function Ro(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 kR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(ni(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 OR(e){let t=0,r=(n,o)=>{if(o>xR)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>AR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>Eh)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!ni(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>Eh)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>am)throw new Error("asset_import_payload_too_large")}function ni(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Mh="@fps-games/editor.playable-sdk.scene-compiler",wh="3",RR=new Set(["shadowMode","childMaterialBindings","childMaterials"]),CR=new Set(["coordinateSpace","center","size","rotation"]),Ph=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function Oc(e){Oh(e,!0)}function kh(e){let t=Sa(e);return Oc(t.document),t}function dm(e){Oh(e,!1)}function Oh(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");NR(r.assets,n.gameObjects),cm(r,"$"),FR(r.assets),jR(r.assets,n.gameObjects),_R(n.gameObjects,r.assets),$R(n.gameObjects),GR(n.materialAssets??[]),t&&LR(r.assets,n.gameObjects),Ws(r),vR(r.assets,n.gameObjects)}function vR(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(pn(n))Th(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(Th(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 Th(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 GR(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=ao(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 jR(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||!Dh(m.width)||!Dh(m.height))throw P("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function NR(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 cm(e,t){if(Array.isArray(e)){e.forEach((n,o)=>cm(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(RR.has(n))throw P("schema.deprecatedField",a);n==="shadow"&&Zo(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&cm(o,a)}}function FR(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`);xh(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);xh(S.defaults,`${b}.defaults`);let y=C(S.id);if(!y||!Ph.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&&Ph.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==mn||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];Ig(b,new Map(d.map(A=>[C(A.id),A])),`$.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 A=C(b.childPrefabId);if(!A||!t.has(A))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 A=d.find(D=>C(D.id)===E);E=A?C(A.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 xh(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 _R(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 $R(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 CR)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 LR(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=zR(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);Ah(y,"nodeIndex",S),Ah(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);im(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);im(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);im(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function im(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&&BR(c.override,`${s}.override`)}}function Ah(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw P("schema.invalidValue",`${r}.${t}`)}function zR(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 BR(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);if(Co(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"])ai(r,n,t);VR(r.baseColor,`${t}.baseColor`),sm(r.normal,`${t}.normal`,["texture","strength"]),sm(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),sm(r.occlusion,`${t}.occlusion`,["texture","strength"]),UR(r.emission,`${t}.emission`),KR(r.alpha,`${t}.alpha`)}function VR(e,t){if(e==null)return;let r=vo(e,t);Co(r,["color","texture","brightness","saturation","contrast","hue"],t),Rh(r.color,`${t}.color`),oi(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ai(r,n,t)}function sm(e,t,r){if(e==null)return;let n=vo(e,t);Co(n,r,t),oi(n.texture,`${t}.texture`),r.includes("strength")&&ai(n,"strength",t)}function UR(e,t){if(e==null)return;let r=vo(e,t);Co(r,["color","intensity","texture","maskTexture"],t),Rh(r.color,`${t}.color`),ai(r,"intensity",t),oi(r.texture,`${t}.texture`),oi(r.maskTexture,`${t}.maskTexture`)}function KR(e,t){if(e==null)return;let r=vo(e,t);if(Co(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"])ai(r,n,t);oi(r.texture,`${t}.texture`)}function oi(e,t){if(e==null)return;let r=vo(e,t);Co(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 Rh(e,t){if(e==null)return;let r=vo(e,t);for(let n of["r","g","b"])HR(r,n,t)}function Co(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 ai(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 HR(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw P("schema.invalidValue",`${r}.${t}`)}function vo(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 Dh(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ii(){return{isCoreMaterialOverridePath:gl,isMaterialAssetIdOverridePath:fg,addMaterialAsset:Us}}function Ch(e,t=[]){return e.assets.filter(Ye).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=WR(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 WR(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 lm(e,t,r=ii()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(mm(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 um(e,t,r=ii()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(mm(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 bo({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 mm(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function vh(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 fm(e,t,r,n,o=ii()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Ye(s));if(!a)return e;let i=qR(jh(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&&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 qR(e,t,r,n=ii()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||mm(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 ya(e,t,r)}function jh(e){if(!Ye(e))return e;let t=lg(e);return t.ok?t.prefabAsset:e}function Rc(e){if(!Ye(e))return e;let t=jh(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 Nh(e,t,r,n,o=ii()){let a=o.addMaterialAsset(e,n);return fm(a,t,r,n.id,o)}function _h(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=JR(i,a),c=Cc(i),d=XR(c,!!n.importStructureReady),u=Lh(n.importStructure)?zh(n.importStructure):[];return vc([s,...d?[d]:[],...u],r)}function JR(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 XR(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(ZR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=Vh(o.ownerNodePath),i=ot(r),s=i.map(m=>Kr(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:${gm(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,YR(t.boundingBox)].filter(Boolean).join(" \xB7 ")).join(`
4
+ `)}function YR(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 ZR(e){return jr(e)}function Lh(e){return["nodes","materials","textures","animations"].some(t=>si(e,t).length>0)}function zh(e){let t=[],r=si(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:QR(r)});let n=si(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>pm(i,s,"material"))});let o=si(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>pm(i,s,"texture"))});let a=si(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>pm(i,s,"animation"))}),t}function QR(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:${gm(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 pm(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}:${gm(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 Bh(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(Lh(n.importStructure)?zh(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 Vh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function gm(e,t){return Vh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function si(e,t){let n=Fh(e)?.[t];return Array.isArray(n)?n.map(Fh).filter(o=>!!o):[]}function Fh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"&&e.trim()?e.trim():null}function Uh(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=>Kh(n,s))}]}function Kh(e,t){let r=fl(e,t.id).map(n=>Kh(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??eC(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 eC(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 Hh(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=bm(i?.nodes),c=bm(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?tC(s):"No SDK node analysis",11),Ot("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?rC(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 tC(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 rC(e){return e.slice(0,8).map((t,r)=>{let n=Nc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=bm(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 bm(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 N({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[ci({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),ci({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 ci(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 nC(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?oC(e,t,r,n,o,a()):r.itemType==="runtime-material"?qh("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?qh("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function oC(e,t,r,n,o,a){let i=yr("en"),s=pg(t,r),c=r.prefabNodeId?co(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||wn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[Go("prefab.materialOverride.status","Status","Editable",0),Go("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),Go("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),Rn.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 aC(e,t,r,n,o){return nC(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var iC={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:aC},Jh=iC;function qh(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:[Go("prefab.materialOverride.status","Status","Read Only",0),Go("prefab.materialOverride.reason","Reason",e,1),Go("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function Go(e,t,r,n,o){return N({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function sC(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(Uh(e,t,n),r)??_h(e,t,r,n):null,d=c?Bh(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Hh(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?co(i,m):null,g=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?lC(i,f):null,b=f?.kind==="marker"&&f.marker?pC(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:[ci({path:"displayName",label:"Display Name",valueType:"string",control:"string",value:i.displayName??i.id,order:0},o),N({path:"prefab.sourceAssetId",label:"Source Asset",value:s?.displayName??t.sourceAssetId??"Missing",order:1}),ci({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...Wh(i,3,o),N({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(S=>!!S)},...g?[g]:[],...b?[b]:[],...l?[l]:[],...u?[u]:[]]}}function cC(e,t,r,n={},o){return sC(e,t,r,n,o,Jh.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var dC={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:cC},Yh=dC;function lC(e,t){let r=uC(t),n=t.parentId?co(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:`${mC(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?fC(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 uC(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 mC(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function fC(e){return Math.round(e*180/Math.PI*1e6)/1e6}function pC(e,t,r){let n=t.marker,o=n.target??null,a=o?Xh(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:Xh({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:[jo({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)}),N({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),d.length>0?jo({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)}):N({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),jo({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)}),N({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"}),jo({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:u=>typeof u=="string"}),jo({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:u=>typeof u=="string"}),jo({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:gC})].filter(u=>!!u)}}function jo(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 Xh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function gC(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 Zh(e,t){let r=gn(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=[N({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),N({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(N({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(Sm({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(Sm({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(Sm({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 Sm(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 Qh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function hm(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function Fn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return hC(r)?ae(r):Ie(1,1,1)}return Ie(1,1,1)}function qr(e,t){let r=ke(e,t);return r&&Tt(r)?r:null}function Em(e,t,r){let n=fr(e,t??void 0,r);return n&&Tt(n)?n:null}function rE(e,t){let r=ke(e,t.id);return r?oE(r,t.name??t.id):null}function nE(e,t){let r=Am(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:oE(o,r.label||n.name||r.id)}function oE(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(bC(o,ym(n,eE(o,n))));if(!a)return null;let i=Fc(tE(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);eE(i,s)<0&&(i=ym(i,-1));let c=Fc(tE(i,n));return c?{origin:Yi(e),right:n,up:c,forward:i,label:t}:null}function eE(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function tE(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 bC(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function ym(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?ym(e,1/t):null}function Er(e,t,r,n={}){let o=t.trim(),a=o?Cr(IC(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 Im(e,t,r){if(Tm(t)){let n=Pm(r);return(e.geometry.kind==="box"||e.geometry.kind==="cylinder")&&n.includes(e.geometry.kind)?e.geometry.kind:SC(r,n)}return xm(t)&&Am(e)?"object-bounds":"point"}function Pm(e){let t=e?.allowedGeometryKinds?.filter(r=>r==="box"||r==="cylinder")??[];return t.length>0?[...new Set(t)]:e?.defaultGeometryKind?[e.defaultGeometryKind]:["box"]}function SC(e,t=Pm(e)){let r=e?.defaultGeometryKind;return r&&t.includes(r)?r:t[0]??"box"}function di(e,t,r,n,o={},a,i){let s=qr(e,t.id),c=ae(s?.position??Ie(0,0,0)),d=ae(s?.rotation??Ie(0,0,0)),u=yC(e,t,r,o)?No(r):ae(s?.scale??Fn(t));if(Tm(r)){let m=Pm(a);return(i&&m.includes(i)?i:Im(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=Am(t.marker);return xm(r)&&l?{kind:"object-bounds",target:l}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:c,...l?{target:l}:{}}}function aE(e,t,r,n,o){if(o)return xm(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=qr(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 iE(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 yC(e,t,r,n={}){let o=Er(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=qr(e,t.id)?.scale??Fn(t);return cE(a,No(o))}function sE(e,t,r,n={}){if(!de(t))return!1;let o=Er(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=qr(e,t.id)?.scale??Fn(t);return cE(i,No(o))}function No(e){return Tm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function Tm(e){return _c(e)==="region"}function xm(e){return _c(e)==="object"}function Am(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 cE(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 dE(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 EC(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 Dm(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 hC(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 lE(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function EC(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 IC(e){return e.scene.markerGraph??null}function Kc(e,t={}){let r=wC(e,t);if(r!==e)return Kc(r,t);let n=PC(e);if(n!==e)return Kc(n,t);let o=li(e);if(!o)return e;let a=dr(o),i=TC(e,a);return da(o,i)?e:Wd(e,i)}function PC(e){let t=li(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)?vC(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>mE(e,Mp(c.marker,o),c.gameObjectId,null)),s=dr({...r,markers:[],relations:r.relations.map(c=>Dp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function TC(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>xC(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 xC(e,t){if(!ca(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return ca(e.geometry.target,t);case"point":return ca(e.geometry.target,t);case"box":case"cylinder":case"polyhedron":return!0}}function uE(e,t,r={}){switch(t.type){case"marker.create-box":return AC(e,t.marker,t.parentId??null);case"marker.update":return DC(e,t.markerId,t.patch,r);case"marker.delete":return MC(e,t.markerId);default:return null}}function AC(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=dr(li(e)),o=mE(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 DC(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=Ir(e,o,n),i=cr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=dr(void 0);if(da({...s,markers:[a]},{...s,markers:[i]}))return e;let c=fE(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function MC(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=wp(e,t),o=dr(li(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 wC(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=kC(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function kC(e,t,r={}){return RC(e,t,r)}function mE(e,t,r,n){let o=No(t.kind),a={position:$c(t.geometry),rotation:Lc(t.geometry),scale:Dm(t.geometry,o)},i=n?Em(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:gE(t),components:[{type:"Transform",...i}]}}function fE(e,t,r,n={}){let o=qr(e,t.id)?.scale??Fn(t),a=sE(e,t,r,n)?No(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:gE(r),components:OC(e,t,t.components,r.geometry,a)}}function OC(e,t,r,n,o){let a=o??Fn(t),i=qr(e,t.id),s={position:hm(n)?ae(i?.position??$c(n)):$c(n),rotation:hm(n)?ae(i?.rotation??Lc(n)):Lc(n),scale:Dm(n,a)},c=Em(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=Er(e,t.marker.type,t.marker.kind,r),o=Cr(li(e),r).find(c=>c.type===t.marker.type)??null,a=Im(t.marker,n,o);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===a)return t;let i=Ir(e,t,r),s=cr({...i,kind:n,markerType:t.marker.type.trim(),geometry:di(e,t,n,i.geometry,r,o)});return fE(e,t,s,r)}function pE(e,t={}){return e.scene.gameObjects.filter(de).map(r=>Ir(e,r,t))}function Ir(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?nE(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):rE(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:Er(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:CC(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 CC(e,t){let r=t.marker,n=qr(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??Fn(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?lE(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 gE(e){let t=e.metadata?structuredClone(e.metadata):{},r=GC(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:dE(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function vC(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 GC(e){if(!e||typeof e!="object")return null;let t=e,r=Mm(t.r),n=Mm(t.g),o=Mm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function Mm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function li(e){return e.scene.markerGraph??null}function SE(e){let t=n=>e.getMarkerTypeCatalogFromGraph(bE(n)),r=n=>{let o=dr(bE(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of pE(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=Op(n,o,{sanitizeMarkerGameObjectId:Uc});return Rp(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(qd(a)),label:Cp(a),...vp(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=Er(n,s,i.marker.kind,e.options),u=Ir(n,i,e.options),l=di(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=Ir(n,i,e.options);if(i.marker.geometry.kind===c)return{type:"marker.update",markerId:o,patch:{geometry:u.geometry}};let l=di(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?iE(n,s):null;if(s&&!c)return null;let d=Ir(n,i,e.options),u=Er(n,i.marker.type,i.marker.kind,e.options),l=aE(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return Er(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=uE(n,o,e.options);if(a)return a;let i=r(n),s=kp(i,o,e.options);return da(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return Kc(n,e.options)}}}function bE(e){return e?.scene.markerGraph}function yE(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?EE(e,n,r,r.id,t):[]})}function hE(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 EE(e,o,a,r,n)}function EE(e,t,r,n,o){let a=[],i=[];IE(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:Ir(c,u,{builtInMarkerTypes:o})}]:[]})}function IE(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=>lo(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&&IE(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?Ea({...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 jC(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 PE(e){let t=Ay(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),...jC(n.materialShaderDefinitions),...Ch(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o,a){let i=La(r,n,o,{...e.assetPlacementServices,...a});return{document:i.document,gameObject:i.gameObject}}}}function NC(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=DE(r.contribution);return n?wm(n):t?hh(e,t):null}function xE(e){let t=(e.features??[]).flatMap(p=>{let x=e.resolveFeatureSceneContribution?.(p);if(x)return[wm(x)];let h=NC(p,()=>d);if(h)return[h];let R=DE(p.scene);return R?[wm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=dv(t),o=SE({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>ov(e.markerTypes,p)}),a=(p,x)=>x?L(p,x):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=>nv(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Ml({hasMaterialAsset:Ut,isMarkerGameObject:de,isDirectionalLightAnglePath:go})],s=(p,x)=>n?.normalizeInspectorValue?.(p,x)??mr(p,x,{isDirectionalLightAnglePath:go}),c=(p,x,h,R)=>{if(go(h)&&x.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:x,path:h,value:R});return K||bo({document:p,path:h,nodeKind:ui(x),value:R,extraValidators:i()})},d=(p,x,h)=>Da({document:p,nodeKind:x,property:h,extraValidators:i()}),l={systemDefaults:YC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:Qh,findGameObject:a,isCameraGameObject:Dt,isLightGameObject:So,isProtectedSystemGameObject:Mt,hasCamera:(p,x)=>p.scene.gameObjects.some(h=>h.id!==x&&Dt(h)),...n?.fieldMutation},m=QC(e,o,l,a,s,c,n),f=(p,x,h,R)=>sc(p,x,h,R,m),g=(p,x,h,R)=>Ty(p,x,h,R,m),b=(p,x)=>Iu(p,x,m.fieldMutationOptions),S=(p,x,h)=>xn(p,x,{transform:h}),y=(p,x)=>Xl(p,x),I=ZC(e,o,l,f,g,n),E=ev(o),A={isRootTransformPath:js,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:Dt,isLightGameObject:So,isSerializedMultiFieldPath:p=>iv(p,n),isSerializedMultiProjectionPath:p=>sv(p,n),getSerializedMultiPropertyProbeValue:p=>cv(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>Do(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},D=PE({hierarchyFacade:E,objectCommandServices:A,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:x,worldTransform:h})=>fr(p,x??void 0,h)}}),j={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(x=>x.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(x=>x.type==="ImageRenderer"),readNodeKind:ui},_={};return Object.assign(_,{historyDocumentStorage:r,defaults:{camera:tc,sunLight:Ka,environmentLight:vn},reduceDocument:(p,x)=>Fu(p,x,I),ensureEnvironmentDefaults:p=>Nu(p,I),isSelectableHierarchyId:(p,x)=>_l(p,x),resolveDiagnosticLocator:(p,x)=>{let h=x.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=Gr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:jp,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:D.getHierarchyItems,normalizeHierarchyDocument:D.normalizeHierarchyDocument,createRenamePatch:D.createRenamePatch,createCreateGroupPatch:D.createCreateGroupPatch,createCreatePrimitivePatch:D.createCreatePrimitivePatch,createDeleteSubtreePatch:D.createDeleteSubtreePatch,createReparentPatch:D.createReparentPatch,createHierarchyMovePatch:D.createHierarchyMovePatch,createGroupSelectionPatch:D.createGroupSelectionPatch,createDuplicateSelectionPatch:D.createDuplicateSelectionPatch,createPlacedAssetPatch:D.createPlacedAssetPatch,validateReparent:D.validateReparent,validateHierarchyMove:D.validateHierarchyMove,validateGroupSelection:D.validateGroupSelection,collectSubtreeIds:br,createFeatureHierarchyPatch:(p,x)=>n?.createHierarchyPatch?.(p,x)??null,createInspectorPropertyPatch:p=>$C(m,p),createSceneMaterialBindingPatch:p=>_C(e,m,p),createPrefabMaterialBindingPatch:p=>LC(e,p),createMaterialPropertiesPatch:p=>XC(e,m,p),createMaterialAssetCreatePatch:p=>VC(e,p),createMaterialAssetRestorePatch:p=>UC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>KC(e,p),createMaterialAssetDuplicatePatch:p=>HC(e,p),createMaterialAssetDeletePatch:p=>WC(e,p),createMaterialAssetRenamePatch:p=>qC(e,p),createMaterialAssetSetShaderPatch:p=>JC(e,p),patchGameObjectField:f,patchGameObjectsField:g,patchGameObjectPropertiesMany:b,patchGameObjectTransform:S,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>FC(e,m,p),canCreateSerializedMultiPropertyPatch:D.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:D.createSerializedMultiPropertyPatch,createBrowserAssetItems:D.createBrowserAssetItems,addAssetLibraryItemToDocument:D.addAssetLibraryItemToDocument,getInspectorObject:(p,x,h={})=>tv(_,e,o,p,x,TE(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,x,h,R={})=>rv(p,x,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,x,h,R={})=>Yh.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,x,h,TE(e.materialShaderDefinitions,R),{createIdentityTransformComponent:XS,mergeLightDefaults:Gn,sunLightId:"sun_light",normalizePrefabAssetFieldValue:lm,validatePrefabAssetFieldValue:um,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>Kl({...p,sourceRef:qt(p.document)},j),createRuntimeInspectorSnapshot:p=>Ia({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>yE(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,x,h)=>hE(p,x,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}),_}function FC(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=Do({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 _C(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=Do({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=AE(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 $C(e,t){let r=Do(t,e);if(!r||!vr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:AE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function LC(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=lm(d,t.materialAssetId);if(!um(d,u))return null;if(!s.nodeId){a=ya(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=ya(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:zC(t.document,t.targets,t.materialAssetId)}}function AE(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 ga(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function zC(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=BC(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function BC(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 VC(e,t){let r=rS(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 UC(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 KC(e,t){let r=sS({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 HC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=nS(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 WC(e,t){let r=dS(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 qC(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:pa(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function JC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||iu(r))return null;let n=yS(r,t.definition),o=pa(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 XC(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(!so(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=Do({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=pa(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 YC(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=>Tu(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>Tu(n,"directional"))(r),normalizeCameraGameObject:t(YS),normalizePlainTransformGameObject:t(ZS),createDefaultCameraGameObject:ny,createDefaultEnvironmentLightGameObject:ay,createDefaultSunLightGameObject:oy,mergeCameraDefaults:Ha,normalizeCameraAfterFieldPatch:QS,hasInvalidCameraRelationships:ty,mergeLightDefaults:Gn}}function ZC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:wa,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)=>aS(i,s,c),addMaterialAsset:(i,s)=>Us(i,s),deleteMaterialAsset:(i,s)=>lS(i,s),addMaterialAssetAndBind:(i,s,c,d)=>uS(i,s,c,d),addPrefabAsset:(i,s,c)=>vh(i,s,c),patchPrefabAssetField:(i,s,c,d)=>fm(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>Gh(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>Nh(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:go,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:eS,normalizeMaterialBindings:gS}}function QC(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:vr,isMaterialBindingPathAllowed:(s,c)=>vr(c)&&(!!e.resolveFieldSchema?.(c,ui(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Kp,normalizeMaterialAssetValue:nt,hasMaterialAsset:Ut,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return Bt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:pa,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGeometryUpdateCommand:t.createMarkerGeometryUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:go,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>_u(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:av,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 ev(e){return ju({findGameObject:(t,r)=>r?L(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 TE(e,t){return{materialShaderDefinitions:e,...t}}function tv(e,t,r,n,o,a,i,s,c,d){let u=VS(n,o,a);if(u)return u;let l=mu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||Wu({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:ui,isMarkerGameObject:de,createInspectorSections:(m,f,g)=>{let b=ui(f);return Ju({document:m,gameObject:f,context:g,nodeKind:b,isCameraGameObject:Dt,isLightGameObject:So,isMarkerGameObject:de,createBaseSections:()=>Bl({document:m,gameObject:f,nodeKind:b,extraValidators:c(),rootTransform:Br,renderingProfile:t.getRenderingProfile(),transformTypeOptions:ME(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:b,context:g,createDocumentInspectorProperty:i})??[],createCameraSection:()=>kl({nodeKind:b,camera:f.camera,rig:Ha(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>ql({nodeKind:b,gameObject:f,light:Gn(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(S,y)=>d?.normalizeInspectorValue?.(S,y)??mr(S,y),defaultEnvironmentGroundColor:vn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?em({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:()=>Zh(m,f),createMaterialSections:()=>mu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,b,g,{createDocumentInspectorProperty:i}),createOutlineSection:()=>Xu({nodeKind:b,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function rv(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 qu({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function nv(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 ov(e,t){return Cr(t,{builtInMarkerTypes:e})}var ui=Y;function av(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function iv(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function sv(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function cv(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function DE(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 wm(e){let{documentReducerImmutability:t,...r}=e;return r}function dv(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:ME(e.flatMap(r=>r.transformTypeOptions??[])).slice(Oa.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:lv(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 ME(e=[]){let t=[],r=new Set;for(let n of[...Oa,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function lv(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 km=["model","texture","image","sound"],Wc=[".glb",".gltf"],Om=[".png",".jpg",".jpeg",".webp"],wE=[".env",".hdr",".dds",".ktx",".ktx2"],qc=[...Om,...wE],Jc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],Fo=[...Wc,...qc,...Jc];function kE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Xc(e,t){let r=kE(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=OE(t);return Wc.includes(n)?"model":Jc.includes(n)?"sound":qc.includes(n)?"texture":null}function OE(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 Rm(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...Fo].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function Cm(e,t){return String(e??"").trim()||Rm(t)||"Asset"}function vm(e,t){return Rm(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function Gm(e){return e==="model"?Wc:e==="sound"?Jc:e==="texture"?qc:e==="image"?Om:[]}function Nm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=jm(t.x),n=jm(t.y),o=jm(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function jm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Fm(e){return e==="shared"||e==="instance"?e:void 0}function _m(e){return Number.isInteger(e)&&e>=0?e:void 0}var RE="rendering",_n=Yf;function Jr(e){let t=ce(e);return uv(t?.companionConfigs)}function Lm(e){return Jr(e)[RE]??null}function CE(e){return kr(Jr(e)[_n])}function uv(e){if(e==null)return{};let t=mv(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===RE&&St(i),a===_n&&Qn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function mv(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 fv=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"}),pv=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),gv=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 zm(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return pv[r]??fv[Qc(r)]??null}function vE(e){return zm(e)!==null}function Bm(e){return gv[Qc(e)]??null}var bv="fps.plugin.ground-decal",GE="@fps-games/plugin-ground-decal";function jE(e){hv(e);let t=e.plugins.find(i=>i.pluginId===bv),r=t?yv(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:Sv(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:Ev(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 Sv(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=>Iv(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=>Pv(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 yv(e){if(e.packageName!==GE)throw new Error(`Ground Decal Plugin package must be ${GE}.`);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 hv(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 Ev(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 Iv(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 Pv(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var Tv=["/__fps_editor_authoring"],xv=[["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 NE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??Tv,o=Av(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=Dv(a);return i?{route:a,routeName:i,prefix:o}:null}function Av(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function Dv(e){return xv.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 FE(e,t){let r=NE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return td(204);try{if(Mv(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 wv(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 kv(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 Mv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function wv(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 kv(e,t,r){if(e.routeName==="asset-import"){let n=Ih(t),o=await r.importAsset?.({payload:n,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}return e.routeName==="save-editor-scene"?Ov(e,t,r):e.routeName==="commit"?Pe(410,await Rv(e,t,r)):Pe(404,{ok:!1,error:"not_found"})}async function Ov(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 Rv(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=kh(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=Ke(a)?a:void 0,d=qt(n),u={...d,compilerId:Mh,compilerVersion:wh,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=Nv(n,r.materialShaderDefinitions,!0),g={...n,scene:{...n.scene,materialAssets:f}},b=m.flatMap(I=>Wv(I,d,g,r)),S=b.map(LE);vv(l,S),Gv(l,S);let y={rootId:l,assets:g.assets.filter($v).map(Lv),nodes:S,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=Jv(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 LE(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function vv(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 Gv(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 jv(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 jv(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 Nv(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 Vm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Vm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=ao(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Vm("material.propertiesInvalid",c[0].path,c[0].message)}let o=us(Fv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Vm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function Fv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=qE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),..._v(r)]}}}function _v(e){let t=[];for(let r of e.scene.gameObjects){let n=gn(e,r);!n.definition||!rd(n.definition)||t.push(...zE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function zE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=HE(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=WE(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(...zE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=aG(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=qm({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 $v(e){return e.type==="glb"||e.type==="texture"}function Lv(e){let t=Vv(e),r=e.type==="glb"?Uv(e):[],n=Bv(e.external),o=zv(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 zv(e){if(!e)return;let t=structuredClone(e);return Ke(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function Bv(e){let t=Ke(e)?e:void 0,r=Pr(t?.platformAssetId),n=Pr(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Vv(e){let t=Ke(e.metadata)?e.metadata:void 0,r=Ke(e.external)?e.external:void 0;return Pr(t?.url)??Pr(r?.assetUrl)??void 0}function Uv(e){let t=Ke(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Kv(t?.assetAnalysis);return r.flatMap(o=>{if(!Ke(o))return[];let a=Pr(o.slotId);if(!a)return[];let i=Pr(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ke(c))return[];let d=Pr(c.ownerNodePath),u=mi(c.meshIndex),l=mi(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=mi(c.nodeIndex),f=Hv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),g=mi(c.sourceMaterialIndex),b=Pr(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 Kv(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=mi(n.meshIndex),a=Pr(n.name);return o==null||!a?[]:[[o,a]]}))}function Hv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function mi(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function Wv(e,t,r,n){let o=gn(r,e);return(o.definition&&rd(o.definition)?Yv(e,o.definition,t,r,new Set,n):[qv(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:LE(i),...s?{asset:s}:{}})??Xv(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function qv(e,t,r,n={}){let o=G(e),a=Se(e),i=Nr(e),s=sG(e),c=Y(e),d=qE(e,r),u=bg(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)}:{},...eG(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=Qv(e,n),g=f.transformType;delete f.transformType;let b=_E(g)??_E(e.transformType);return{...m,kind:"transform",...b?{transformType:b}:{},...e.camera?{camera:lG(e.camera)}:{},...e.light?{light:JE(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 Jv(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=Cf({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 Xv(e){let t=Ke(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=Um(t.skinCount),n=Um(t.morphTargetCount);return r>0||n>0?"skinned":Um(t.animationCount)>0?"dynamic":"static"}function Um(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function Yv(e,t,r,n,o,a){return BE({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 BE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Km({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),[Km({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=>lo(o,d.id),i=HE(t,n.id),s=WE(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(...BE({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?fi(fi(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(Km({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(Zv({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:Wm(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),rG({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:Wm(e.compilerOptions)})}function Zv(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=VE({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=qm({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=qm({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:JE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...Ea(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Km(e){return{...VE({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 Qv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function VE(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)}:{},...tG(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 eG(e,t,r){let n=Os({document:e,casterId:t.id,caster:t,fallbackMode:Wm(r)});return Jm(n,!!t.shadow)?{shadowPlan:n}:{}}function tG(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 Jm(o,r)?{shadowPlan:o}:{}}function Jm(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function rG(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>nG(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(!Jm(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function Wm(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 nG(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 qm(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?KE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=iG([Hm(Zt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),Hm(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:Hm(Zt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Zt(e.instanceOverrides);return UE(fi(n,o),e.asset)}function Hm(e,t,r){return UE(e,t&&t===r?.id?r:void 0)}function UE(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 KE(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 oG(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 aG(e,t){return t.kind==="model"&&t.sourceAssetId?KE(e,t,t.sourceAssetId):t.kind==="primitive"?oG(e,t):null}function iG(e){let t;for(let r of e){let n=Zt(r);n&&(t=fi(t,n))}return t}function HE(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 WE(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===mn&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ze(e)}function sG(e){return e.primitive??null}function qE(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 cG(e,t,o)}function cG(e,t,r){let n=Zt(e.overrides),o=gn(t,e),a=Zt(o.definition?.prefab?.overrides);return fi(a,n)}function fi(e,t){let r=gs(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))dG(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 dG(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ke(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Pr(e){return(typeof e=="string"?e.trim():"")||void 0}function _E(e){return typeof e=="string"?e:void 0}function lG(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function JE(e){return e.type==="directional"?Jn({schemaVersion:1,type:"directional",intensity:e.intensity,direction:na(e.direction),diffuseColor:e.diffuseColor??Ka.diffuseColor}):Jn({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??vn.diffuseColor,groundColor:e.groundColor??vn.groundColor})}var uG=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function ZE(e){let t=Ki(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>mG(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 mG(e,t){let r=Oo(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:fG(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:_o(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:YE(e.value),...e.tint?{tint:_o(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...XE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:_o(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:YE(e.value??0),color:_o(e.color),...XE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:_o(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:_o(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 fG(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function _o(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function XE(e){return typeof e=="string"&&uG.has(e)}function YE(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function QE(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return td(204);try{if(r==="GET"){let c=SG(await t.loadConfig?.()),d=c.renderingConfig;St(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:bG(d),normalized:u,summary:qn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=pi(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});St(o);let a=Ne(o),i=qn(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=pG(n),a=gG(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:pi(n?.details)})}}function pG(e){let t=e?.code;return typeof t=="string"&&t?t:null}function gG(e){let t=e?.path;return typeof t=="string"&&t?t:null}function pi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function bG(e){return pi(e)??{}}function SG(e){let t=pi(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:pi(t.response)??{}}:{renderingConfig:e??{},response:{}}}function eI(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(!qf(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 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 oj(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=YG(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=sj(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=ij(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=ZG(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=ej(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(lj),await pj(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:nj(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=mj(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 uj(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??`${fj(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,[]);return XG(t,e)}function XG(e,t={}){if(!Array.isArray(e))throw new U("manifest_invalid_root",{manifestPath:t.manifestPath});let r=e.map((i,s)=>{let c=af(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:t.manifestPath});return c}),n=new Set,o=new Set,a=t.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:t.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 YG(e,t){let r=t.toLowerCase();return GI(e).find(n=>r.endsWith(n))??null}function ZG(e,t){return t.existing?.relativePath?t.existing.relativePath:QG(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 QG(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 ej(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function tj(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 rj(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 tj(a,o,n),rj(v.resolve(e.generatedDir),o,n),nf(r,o,n),o}function nj(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 oj(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&&!aj(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 aj(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 ij(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&&cj(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&dj(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 sj(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 cj(e){return ie(He(e).platformAssetId)}function dj(e){return ie(He(e).assetPath)}function lj(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 uj(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 mj(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 fj(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 pj(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 gj(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 gj(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}):bj(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await Lo(r),o=hj(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 yj(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 bj(e,t,r){return r&&Sj(e)?r:t}function Sj(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 yj(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 hj(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 xj,rm as zI,writeFile as Aj}from"node:fs/promises";import{randomUUID as Dj}from"node:crypto";import $n from"node:path";import Ej from"node:path";var ad=new Map;async function id(e,t){let r=[...new Set(e.map(i=>Ej.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 Ij=1,Pj=["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 Tj(e)}}}function Tj(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=Pj.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:Ij,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),Mj(e)))}async function Mj(e){let t=$I(),r=t.measure("prepare",()=>wj(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(kj(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 xj(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}.${Dj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await Aj(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 wj(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 kj(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 Oj}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 Rj(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function Rj(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 Oj(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 Cj=128*1024*1024,vj=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 Gj(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 Cj;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,vj)}async function cd(e,t){let r=Gj(t),n=await Ti.realpath(zn.resolve(e)),o=zn.resolve(n,...r.split("/"));eP(n,o),await jj(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 jj(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,Nj=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([...Nj,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=pt.resolve(r,c),u=await Fj(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 _j(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 Fj(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 _j(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=>(Lj(r,o),zj(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 Lj(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 zj(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 Bj}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:Vj(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(`${Bj(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 Vj(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 Uj,readFileSync as Kj}from"node:fs";import{mkdir as Hj,writeFile as Wj}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:Jj,async handleRoute(a){return n?ZE({method:qj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:Uj(n)?JSON.parse(Kj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return id([n],async()=>(await Hj(hf.dirname(n),{recursive:!0}),await Wj(n,`${JSON.stringify(i,null,2)}
19
- `,"utf8"),zo(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function qj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function Jj(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 Xj}from"node:crypto";import{realpath as Yj}from"node:fs/promises";import{createServer as Zj}from"node:http";async function lP(e){let t=await Yj(e.projectRoot),r=Xj(),n=[...e.middlewares??[]],o=Zj((c,d)=>{Qj(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 Qj(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){eN(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
- `))}function eN(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"},tN={kind:"enum",values:["lit","unlit"]},rN={kind:"enum",values:["opaque","mask","blend"]},pP={lightingModel:tN,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:rN,opacity:Ct(0,1),cutoff:Ct(0,1),texture:Vn}}},nN={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)}}}},oN={kind:"object",properties:pP},aN={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}},iN={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"}])],sN=[...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:nN,defaultProperties:aN,inspector:{sections:mP,fields:sN}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:oN,defaultProperties:iN,inspector:{sections:mP,fields:gP}}],vK=Tf(Pf);function Tf(e){let t=new Map;for(let n of e){cN(n,t);let o=dN(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 cN(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&&!uN(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.`);lN(e,a),o.add(a.path)}}function dN(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 lN(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 uN(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function mN(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function SP(e,t){let r=mN(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 fN=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),pN=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 gN(new TextEncoder().encode(e))}function EP(e){return`sha256:${ud(JSON.stringify(e))}`}function gN(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=[...fN],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+pN[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 bN="fps.plugin.materials";function PP(e){let t=e?.[bN];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 SN(r),TP(r)}function xf(e){return Tf([...Pf,...e?.shaders.map(t=>t.definition)??[]])}function SN(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=yN(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"&&EN(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 hN(b.configureServer,a),lP({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function yN(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 hN(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 EN(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 IN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function MP(e){let t=JSON.parse(IN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}
12
+ `}import Xm from"node:fs/promises";import mt from"node:path";var Ym=5;async function Si(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await oI(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=LG(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=Ym;let n=await aI(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 oI(e){return e.kind==="model"?yG(e.sourcePath):e.kind==="texture"||e.kind==="image"?hG(e.sourcePath,e.sourceBytes):null}async function aI(e,t={}){try{let r=await iI(e);return OG(r,{...t,sourcePath:e})}catch{return[]}}async function iI(e){let t=mt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await Xm.readFile(e,"utf8"));if(t!==".glb")return null;let r=await Xm.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 yG(e){try{let t=await iI(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=uI(t),m=mI(n),f=new Set(l),g=o.reduce((E,A)=>E+(Array.isArray(A?.primitives)?A.primitives.length:0),0),b=o.reduce((E,A)=>E+(Array.isArray(A?.primitives)?A.primitives.reduce((D,j)=>D+(Array.isArray(j?.targets)?j.targets.length:0),0):0),0),S=xG({nodeCount:n.length,meshCount:o.length,primitiveCount:g,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=AG({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:EG(n,o,a,u,m,f),meshes:IG(o,a,u),materials:PG(t),diagnostics:y}}catch{return null}}async function hG(e,t){try{let r=t??await Xm.readFile(e),n=mt.extname(e).toLowerCase(),o=n===".png"?DG(r):n===".jpg"||n===".jpeg"?MG(r):n===".webp"?wG(r):null;if(!o)return null;let a=kG(o);return{kind:"image",format:o.format,summary:`${o.width}x${o.height} ${o.mime}`,complexity:o.estimatedPixels>=4096*4096?"high":o.estimatedPixels>=2048*2048?"medium":"low",width:o.width,height:o.height,mime:o.mime,bitDepth:o.bitDepth,hasAlpha:o.hasAlpha,estimatedPixels:o.estimatedPixels,diagnostics:a}}catch{return null}}function EG(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=fI(e,o,a,s),m={nodeIndex:s,nodeIndexPath:gI(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=sI(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 IG(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=sI(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 sI(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=bI(a,r),l=SI(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 PG(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=TG(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:dI(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function TG(e,t){let r=[];return gi(r,"baseColor",t?.baseColorTexture),gi(r,"metallicRoughness",t?.metallicRoughnessTexture),gi(r,"normal",e?.normalTexture),gi(r,"occlusion",e?.occlusionTexture),gi(r,"emissive",e?.emissiveTexture),r}function gi(e,t,r){!pe(r)||!Number.isInteger(r.index)||e.push({slot:t,textureIndex:r.index,...Number.isFinite(r.texCoord)?{texCoord:r.texCoord}:{}})}function xG(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 AG(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 DG(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 MG(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 wG(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=tI(e,24)+1,o=tI(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 tI(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function kG(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 OG(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=CG(e,t),i=uI(e),s=mI(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=FG(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=fI(r,s,c,f);if(!S)continue;let y=n[b],I=Array.isArray(y?.primitives)?y.primitives:[],E=BG(g,y,S),A=pI(y),D=gI(s,f);for(let j=0;j<I.length;j+=1){let _=I[j],p=VG(_,o),x=lI({ownerNodePath:S,nodeIndex:f,meshIndex:b,primitiveIndex:j}),h=bI(_,d),R=SI(_,d),K=I.length>1?`${E} / Primitive ${j}`:E,ne={ownerNodePath:S,nodeIndex:f,nodeIndexPath:D,meshIndex:b,primitiveIndex:j,...A?{sourceMeshName:A}:{},...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(x)??_G({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:b,primitiveIndex:I.length>1?j:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,g]of m){let b=g.sourceSurfaces.sort(cI);l.push({slotId:u.bySourceMaterialIndex.get(f)??$G({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:g.label,sourceSurfaces:b,...g.materialName?{materialName:g.materialName,materialNames:[g.materialName]}:{},...vG(a,[f])})}return l.sort(RG)}function RG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return cI(r,n)}function cI(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 CG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=GG(e,o,t);a&&n.push(a)}return n}function vG(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 GG(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=rI(c);d&&(s.color=d);let u=bi(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={};bi(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={};bi(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};bi(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=rI(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),S=b&&(b.r!==0||b.g!==0||b.b!==0);S&&(g.color=b),bi(e,n.emissiveTexture,r,"emission.texture",g,"texture",a),S&&(g.intensity=1),Object.keys(g).length>0&&(o.emission=g);let y={},I=dI(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 rI(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 dI(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function bi(e,t,r,n,o,a,i){let s=jG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function jG(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=NG(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):"",A=I?mt.relative(I,y):"../";return I&&E&&A&&!A.startsWith("..")&&!mt.isAbsolute(A)?{texture:{url:`/${mt.relative(E,y).split(mt.sep).join("/")}`},hint:{...g,reason:"external-texture"}}:{hint:{...g,reason:"external-texture"}}}function NG(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 FG(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(lI({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 lI(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function _G(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${hI(r)}`}function $G(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${hI(t)}`}function LG(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 uI(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 mI(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 fI(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(zG(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 zG(e,t){return(pe(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function BG(e,t,r){let n=pe(e)&&typeof e.name=="string"?e.name.trim():"",o=pI(t);return n||o||r.split("/").filter(Boolean).pop()||r}function pI(e){return pe(e)&&typeof e.name=="string"?e.name.trim():""}function gI(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 VG(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 bI(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=yI(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 SI(e,t){let r=pe(e)?e:{},n=yI(r),o=n>=0?t[n]:null,a=nI(o?.min),i=nI(o?.max);return a&&i?{min:a,max:i}:null}function yI(e){let t=pe(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function nI(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 hI(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 JG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import yi from"node:fs/promises";import Rt from"node:path";async function II(e,t={}){try{let r=await UG(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 KG(e,r,s);if(!c)continue;let d=hi(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 PI(e){let t=new Set;for(let r of xI(e)){let n=Tr(r.imageIndex),o=Tr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function TI(e){let t=new Map;for(let r of xI(e)){let n=Tr(r.imageIndex),o=Tr(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 xI(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 AI(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=Tr(g?.imageIndex),S=hi(g?.profilePath),y=b==null?null:r.get(b)??null;if(!y||!S||!WG(S)){m.push(f);continue}let I=ft(u.profile)??{};qG(I,S,{textureAssetId:y}),u.profile=I,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function UG(e){let t=Rt.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await yi.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>EI(e,ft(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await yi.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 hi(u?.uri)?EI(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 EI(e,t){let r=hi(t?.uri);if(!r)return null;let n=wI(r);if(n)return n.bytes;if(Qm(r))return null;let o=MI(r);return o?DI(e,o):null}async function KG(e,t,r){let n=hi(r.uri);if(n){let f=wI(n);if(f){let I=Zm(f.bytes);return I?{bytes:f.bytes,...I}:null}if(Qm(n))return null;let g=MI(n);if(!g)return null;let b=await DI(e,g);if(!b)return null;let S=Rt.basename(g),y=Zm(b);return y?{bytes:b,...y,originalFileName:S}:null}let o=Tr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ft(a[o]),s=Tr(i?.buffer)??0,c=t.buffers[s],d=Tr(i?.byteOffset)??0,u=Tr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=Zm(l);return m?{bytes:l,...m}:null}async function DI(e,t){if(Rt.isAbsolute(t)||Rt.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await yi.realpath(Rt.dirname(e)),n=Rt.resolve(r,t),o=await yi.realpath(n);return HG(r,o)?await yi.readFile(o):null}catch{return null}}function MI(e){if(Qm(e))return null;try{return decodeURIComponent(e)}catch{return null}}function HG(e,t){let r=Rt.relative(e,t);return r===""||!r.startsWith(`..${Rt.sep}`)&&r!==".."&&!Rt.isAbsolute(r)}function wI(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 Zm(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 WG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function qG(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 Qm(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 hi(e){return typeof e=="string"&&e.trim()?e.trim():null}function Tr(e){return Number.isInteger(e)&&e>=0?e:null}var V=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function zo(e,t,r={}){if(!t.payload&&!t.payloadData)throw new V("missing_payload_arg");let n=await cj(e,t),o=e.codeKeyPolicy??"legacy";if(o==="disabled"&&Object.prototype.hasOwnProperty.call(n,"codeKey"))throw new V("payload_code_key_disabled",{codeKeyPolicy:o,codeKey:n.codeKey});let a=v.resolve(e.cwd,String(n.sourcePath??n.assetPath??"")),i=tj(e,a);if(!i)throw new V(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:jI(e)});try{await W.access(a,JG.R_OK)}catch(h){let R=Lo(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new V(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=uj(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Qt(e),d=await lf(a),u=Zc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new V("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});of(u,a,"source_path");let l=lj(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 V("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 V("manifest_asset_id_must_match_guid",{guid:g,assetId:l.assetId,expectedAssetId:S});if(b&&b!==S)throw new V("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=rj(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),E=Ln(e,I,u,"target_path"),A=new Date().toISOString(),D=Cm(ie(n.displayName)??l?.displayName,m),j=nd({...nd(l?.external)??{},...s??{}}),_=!1,p=[],x=null;try{await W.mkdir(v.dirname(E),{recursive:!0});let h=oj(a,E),R=h||await FI(E),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,E),_=!l,i===".gltf"&&await XG(a,E));let $=await df(e,{existing:l,payload:n,sourcePath:a,targetPath:E,kind:u,guid:g,assetId:S}),Ar=He(l?.metadata),tr=He($);if(u==="model"&&(Ar.assetAnalysisStatus==="complete"||Object.keys(He(Ar.assetAnalysis)).length>0)&&tr.assetAnalysisStatus==="unavailable")throw new V("source_asset_analysis_failed",{sourcePath:a,assetId:S,guid:g});if(u==="model"){let rr=await YG({config:e,manifest:c,metadata:$,sourcePath:a,sourceAssetId:S,sourceAssetGuid:g,sourceDisplayName:D,now:A});p=rr.createdPaths,$=AI($,rr.references)}let Qr=sf({...l??{},guid:g,assetId:S,kind:u,displayName:D,relativePath:I,originalFileName:m,...o==="legacy"?{codeKey:vm(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",..._m(n.warmupCount)!=null?{warmupCount:_m(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...Fm(n.materialMode)?{materialMode:Fm(n.materialMode)}:{},...Nm(n.scale)?{defaults:{transform:{scale:Nm(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:j,metadata:$,createdAt:l?.createdAt??A,updatedAt:K?A:l?.updatedAt??A});if(!Qr)throw new V("invalid_manifest_entry",{assetId:S,guid:g});x=Qr;let Ai=c.findIndex(rr=>rr.guid===g||rr.assetId===S);Ai>=0?c[Ai]=Qr:c.push(Qr),c.sort(pj),await yj(e,c)}catch(h){_&&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,...x?.contentHash?{contentHash:x.contentHash}:{},...x?.external?{external:x.external}:{},displayName:x?.displayName,originalFileName:x?.originalFileName,assetUrl:sj(e,I,u),targetPath:E,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function XG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new V("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{ef(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));ef(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function ef(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new V(r)}async function YG(e){let t=new Set(e.manifest.map(o=>o.assetId)),r=await ZG(e),n=[];try{for(let o of r.fileWrites)if(await W.mkdir(v.dirname(o.targetPath),{recursive:!0}),await FI(o.targetPath)){if((await lf(o.targetPath)).contentHash!==$o(o.bytes).contentHash)throw new V("derived_texture_target_conflict",{targetPath:o.targetPath})}else await gj(o.targetPath,o.bytes),n.push(o.targetPath);if(e.config.resolveAssetMetadata)for(let o of e.manifest){if(t.has(o.assetId))continue;let a=Ln(e.config,o.relativePath,o.kind,"derived_texture_target_path");o.metadata=await df(e.config,{existing:null,payload:{metadata:o.metadata},sourcePath:a,targetPath:a,kind:o.kind,guid:o.guid,assetId:o.assetId})??void 0}return{references:r.references,createdPaths:n}}catch(o){for(let a of n)await W.rm(a,{force:!0}).catch(()=>{});throw o}}async function ZG(e){let t=PI(e.metadata),r=TI(e.metadata),n=await II(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=new Map,s=new Set(n.map(d=>d.imageIndex)),c=t.filter(d=>!s.has(d));if(c.length>0&&v.extname(e.sourcePath).toLowerCase()===".glb")throw new V("gltf_material_texture_extract_failed",{imageIndexes:c});{for(let l of n){let m=$o(l.bytes),f=e.manifest.find(_=>_.kind==="texture"&&_.contentHash===m.contentHash&&He(He(_.metadata).capabilities).materialTexture!==!1&&He(_.metadata).textureUsage!=="environment");if(f){i.set(f.assetId,{relativePath:f.relativePath,targetPath:Ln(e.config,f.relativePath,"texture","derived_texture_target_path"),bytes:l.bytes}),a.set(l.imageIndex,f),o.push({imageIndex:l.imageIndex,textureAssetId:f.assetId});continue}let g=bj(m.contentHash),b=Xc("texture",g),S=e.manifest.find(_=>_.guid===g||_.assetId===b);if(S)throw new V("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:l.imageIndex,assetId:b,contentHash:m.contentHash,conflictingAssetId:S.assetId,conflictingContentHash:S.contentHash});let y=`${b}${l.extension}`,I=NI(e.config,"texture",y),E=Ln(e.config,I,"texture","derived_texture_target_path");i.set(b,{relativePath:I,targetPath:E,bytes:l.bytes});let A=l.displayName?`${e.sourceDisplayName} / ${l.displayName}`:`${e.sourceDisplayName} Texture ${l.imageIndex+1}`,D=await df({...e.config,resolveAssetMetadata:void 0},{existing:null,payload:{metadata:{textureUsage:"material",capabilities:{materialTexture:!0,environmentTexture:!1},derivedFrom:{kind:"gltf-image",sourceAssetId:e.sourceAssetId,sourceAssetGuid:e.sourceAssetGuid,imageIndex:l.imageIndex,mimeType:l.mimeType}}},sourcePath:E,sourceBytes:l.bytes,targetPath:E,kind:"texture",guid:g,assetId:b}),j=sf({guid:g,assetId:b,kind:"texture",displayName:A,relativePath:I,originalFileName:l.originalFileName??`${Sj(A)}${l.extension}`,category:"Texture",placeable:!0,contentHash:m.contentHash,byteSize:m.byteSize,metadata:D,createdAt:e.now,updatedAt:e.now});if(!j)throw new V("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:l.imageIndex,assetId:b});e.manifest.push(j),a.set(l.imageIndex,j),o.push({imageIndex:l.imageIndex,textureAssetId:b})}let d=new Map,u=new Map;for(let l of a.values())v.extname(l.relativePath).toLowerCase()===".ktx2"&&d.set(l.assetId,l);for(let l of r){let m=a.get(l.imageIndex),f=a.get(l.previewImageIndex);!m||!f||v.extname(m.relativePath).toLowerCase()!==".ktx2"||u.set(m.assetId,f.assetId)}for(let l of d.values()){let m=He(l.metadata),f=QG(m);delete f[e.sourceAssetId];let g=u.get(l.assetId);g&&(f[e.sourceAssetId]=g);let b=Object.fromEntries(Object.entries(f).sort(([I],[E])=>I.localeCompare(E))),S=Object.values(b)[0],y={...m};S?(y.previewTextureAssetId=S,y.previewTextureAssetIdsBySourceAssetId=b):(delete y.previewTextureAssetId,delete y.previewTextureAssetIdsBySourceAssetId),l.metadata=y}return{references:o,fileWrites:[...i.values()]}}}function QG(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 rf(e,t={}){let r=await GI(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function nf(e,t={}){return GI(e,t,!0)}async function GI(e,t,r){let n=await Qt(e),o=[],a=[];for(let i of n){let s=Ln(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await lf(s)}catch(m){let f=kI(i,m,t,"source-audit",s);if(!r||!f)throw OI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&He(i.metadata).assetMetadataVersion!==Ym,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await zo(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=kI(i,m,t,"source-analysis",s);if(!r||!f)throw OI(f,m,s);a.push(f);continue}if(!l.contentHash)throw new V("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 kI(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof V?t.message:void 0,s=Lo(t)?t.code:t instanceof V?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=Lo(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 OI(e,t,r){return!e||t instanceof V?t:new V(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Qt(e){let t=await af(e.manifestPath,[]);return ej(t,e)}function ej(e,t={}){if(!Array.isArray(e))throw new V("manifest_invalid_root",{manifestPath:t.manifestPath});let r=e.map((i,s)=>{let c=sf(i,!0);if(!c)throw new V("manifest_invalid_entry",{index:s,manifestPath:t.manifestPath});return c}),n=new Set,o=new Set,a=t.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new V("manifest_code_key_disabled",{manifestPath:t.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new V("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new V("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function Bo(e){return e.loadRules?e.loadRules():e.rulesPath?af(e.rulesPath,{}):{}}function RI(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 jI(e){let t=RI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:RI(Fo)}function tj(e,t){let r=t.toLowerCase();return jI(e).find(n=>r.endsWith(n))??null}function rj(e,t){return t.existing?.relativePath?t.existing.relativePath:nj(e,t.sourcePath,t.kind)??NI(e,t.kind,t.targetFileName)}function NI(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function nj(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!CI(v.resolve(n),o)||CI(v.resolve(e.generatedDir),o)?null:(of(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function CI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function oj(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function aj(e,t,r){let n=v.relative(e,t);if(n.startsWith("..")||v.isAbsolute(n))throw new V(`${r}_outside_allowed_directory`,{parent:e,child:t})}function ij(e,t,r){let n=v.relative(e,t);if(!n.startsWith("..")&&!v.isAbsolute(n))throw new V(`${r}_inside_forbidden_directory`,{parent:e,child:t})}function Ln(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return aj(a,o,n),ij(v.resolve(e.generatedDir),o,n),of(r,o,n),o}function sj(e,t,r){let n=Ln(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 of(e,t,r){let n=v.extname(t).toLowerCase(),o=Gm(e);if(!o.includes(n))throw new V(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function af(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(Lo(r)&&r.code==="ENOENT")return t;throw r}}async function cj(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await af(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new V("invalid_payload_json",{payloadPath:r});return n}function sf(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?cf: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?km.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&&Xr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&Xr(r.metadata)==null||"external"in r&&!dj(r.external)))return null;let u=Xr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),g=n(r.materialMode),b=Xr(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 cf(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function $n(e,t){return!(t in e)||cf(e[t])!=null}function dj(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)&&cf(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=ri(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new V("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 Xr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function df(e,t){let r=Xr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:Xr(t.existing?.metadata),payloadMetadata:r}),o=Xr(n);return o||null}return Si({kind:t.kind,sourcePath:t.sourcePath,sourceBytes:t.sourceBytes,existingMetadata:Xr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function lj(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&&mj(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&fj(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(Ln(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 uj(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 mj(e){return ie(He(e).platformAssetId)}function fj(e){return ie(He(e).assetPath)}function pj(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function tf(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!Lo(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 gj(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 lf(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...$o(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...$o(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{ef(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:"",...$o(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,...$o(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function $o(e){return{contentHash:`sha256:${od.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function bj(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 Sj(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 yj(e,t){let r=eI(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 vI(e.manifestPath),o=await vI(e.registryPath);try{await tf(e.manifestPath,`${JSON.stringify(t,null,2)}
13
+ `),await tf(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await hj(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 vI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(Lo(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function hj(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await tf(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 Lo(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):Po(t)];return{ok:!0,...An(t,r),summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):Ej(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await Bo(r),o=Tj(n.errorCodes),a=await Qt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await zo(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 Pj(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Po(d)],l=An(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 Ej(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 Pj(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 Tj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function uf(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 Yr(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 wj,rm as zI,writeFile as kj}from"node:fs/promises";import{randomUUID as Oj}from"node:crypto";import zn from"node:path";import xj from"node:path";var ad=new Map;async function id(e,t){let r=[...new Set(e.map(i=>xj.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 mf}from"node:perf_hooks";var Aj=1,Dj=["prepare","compile","validate","stringify","write","checkpoint"];function $I(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:ff(mf.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=mf.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=mf.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=ff(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=Dj.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:Aj,measuredDurationMs:ff(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 ff(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function WI(e){let t=e.paths,r=Ii(t.editorScenePath),n=r?Sa(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&&dm(n),n&&ja(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={...Jr(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){Bn(e),VI(e.body,"$",!0),VI(e.rawEditorScene,"$.editorScene");let t=Lm(e.body),r=Jr(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,()=>(Bn(e),Rj(e)))}async function Rj(e){let t=$I(),r=t.measure("prepare",()=>Cj(e)),n=Sa(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Bn(e);let a=e.paths,i=Jr(e.body),s=Lm(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,_n),u=i[_n],l=kr(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",()=>{pf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let S=Jr(n),y=S[_n];t.measure("validate",()=>{pf(y,kr(y),{present:Object.prototype.hasOwnProperty.call(S,_n),path:"$.editorScene.companionConfigs.staticShadows"})});let I=ce(m)?.staticShadows;t.measure("validate",()=>{pf(I,kr(I),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),dm(n)});let E=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,A=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Bn(e),t.measure("validate",()=>{ja(n,A)});let D=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),A));return kc(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(D),o.assertEditorSceneMaterialAssetIntegrity(D)});let j=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(D)),_=d?l:l??CE(n)??kr(ce(m)?.staticShadows),p=t.measure("prepare",()=>kc(vj(j,{staticShadows:_}),4)),x=t.measure("prepare",()=>ou(p,A)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig(j,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:b??null})),R=_?{...h.sceneConfig,staticShadows:_}:{...h.sceneConfig};_||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,$=new Date().toISOString(),Ar=t.measure("compile",()=>kc(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:$}:R,4));t.measure("validate",()=>{Ui(Ar)});let tr=ce(Ar)?.version,Qr=e.saveMode==="local-commit-save"&&typeof tr=="number"?tr:ne,Ai=`/${zn.relative(e.projectRoot,a.scenePath).split(zn.sep).join("/")}?v=${encodeURIComponent(String(Qr))}`,rr="",Wn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(x,null,2)}
15
+ `);await t.measureAsync("write",()=>sd(e,Wn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Bn(e),await LI(zn.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
+ `);await t.measureAsync("write",()=>sd(e,Wn,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(zn.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(b,null,2)}
17
+ `);await t.measureAsync("write",()=>sd(e,Wn,a.shadowsConfigPath,xe))}rr=t.measure("stringify",()=>`${JSON.stringify(Ar,null,2)}
18
+ `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>sd(e,Wn,a.scenePath,rr)),Bn(e),await t.measureAsync("write",async()=>{for(let xe of Wn)await wj(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await zI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(Wn.filter(xe=>!xe.committed).map(xe=>zI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let wf=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return wf.length>0&&e.invalidateFiles?.(e.server,wf),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:Qr,updatedAt:$,sceneUrl:Ai}:{},editorScene:p,...b?{shadowMapExperimentConfig:b}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:_}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(E??null)??null}:{}}:{},sceneJsonText:rr,performanceProfile:t.snapshot(),summary:{editorScene:XI(j),compiled:h.summary}}}async function sd(e,t,r,n){Bn(e);let o=zn.join(zn.dirname(r),`.${zn.basename(r)}.${process.pid}.${Oj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await kj(o,n,{encoding:"utf8",signal:e.signal})}function Bn(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 Cj(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 pf(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 vj(e,t){let r={...Jr(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 Vj}from"node:stream/promises";import{realpathSync as Gj}from"node:fs";import bf from"node:path";function Vo(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of jj(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function jj(e){let t=bf.resolve(e),r=Pi(t);return[...new Set([e,t,r,gf(e),gf(t),gf(r)])]}function Pi(e){let t=bf.resolve(e);try{return Gj(t)}catch{return t}}function gf(e){return e.split(bf.sep).join("/")}import{constants as QI}from"node:fs";import Ti from"node:fs/promises";import Vn from"node:path";var Nj=128*1024*1024,Fj=512*1024*1024;async function Uo(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 _j(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||Vn.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 Nj;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,Fj)}async function cd(e,t){let r=_j(t),n=await Ti.realpath(Vn.resolve(e)),o=Vn.resolve(n,...r.split("/"));eP(n,o),await $j(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 Uo(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=Vn.relative(e,t);if(!r||r===".."||r.startsWith(`..${Vn.sep}`)||Vn.isAbsolute(r))throw new Error("project_file_path_invalid")}async function $j(e,t){let r=e;for(let n of t.split("/"))if(r=Vn.join(r,n),(await Ti.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import xr from"node:fs/promises";import pt from"node:path";var tP=512*1024,Lj=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 xr.realpath(pt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...Lj,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=pt.resolve(r,c),u=await zj(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 Bj(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 zj(e,t){try{let r=await xr.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await xr.realpath(t);if(n!==t||!yf(e,n))return null;let o=await xr.readdir(t,{withFileTypes:!0}),a=await xr.lstat(t),i=await xr.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!yf(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(!vE(a))throw await Uo(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 Uo(o)}let u=pt.basename(a);return{path:a,name:u,extension:Qc(u),language:zm(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Bj(e,t){try{let r=await xr.lstat(t);if(r.isSymbolicLink())return null;let n=await xr.realpath(t);if(n===e||!yf(e,n)||n!==t)return null;let o=await xr.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function yf(e,t){let r=pt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${pt.sep}`)&&!pt.isAbsolute(r)}var hf="/__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=>(Uj(r,o),Kj(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===hf||c.startsWith(`${hf}/`),u=d&&c.slice(hf.length)||"/";if(d&&u==="/project-media"){if(Ei(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Yr(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Yr(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=Bm(f.relativePath);if(!S)throw new Error("project_file_media_unsupported");if(f.stat.size>Sf(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 Vj(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(S){g=S}try{await Uo(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);Yr(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:uf});Yr(a,m)}catch(m){Yr(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await FE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>uf(o,{...f.routeName==="asset-import"?{maxBytes:am}:{}}),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),Yr(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Yr(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 Uj(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 Kj(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 Un,{resolve as Ko}from"node:path";import{pathToFileURL as Hj}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(D=>!!D),I=[],E=[],A=0;for(let D of y){let j=await Bo(D),_=typeof j.errorCodes=="object"&&j.errorCodes?j.errorCodes:{},p=g==="report"?await nf(D,_):await rf(D,_);A+=p.scannedAssetCount,I.push(...p.refreshedAssets);let x="availabilityIssues"in p&&Array.isArray(p.availabilityIssues)?p.availabilityIssues:[];E.push(...x)}return I.length>0&&Vo(f,[...y.flatMap(D=>[D.manifestPath,D.registryPath]),...Ef(e)]),{scannedAssetCount:A,refreshedAssets:I,availabilityIssues:Wj(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(Ga(b),g.availabilityIssues??[]),y=An(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(Un.extname(g.sourcePath).toLowerCase())?"texture":"model"),I=y==="texture"?S??b:b,E=await Bo(I),A=typeof E.errorCodes=="object"&&E.errorCodes?E.errorCodes:{},D=await Qt(I),j=await zo(I,{payloadData:{sourcePath:g.sourcePath,...g.displayName?{displayName:g.displayName}:{},kind:y,...g.category?{category:g.category}:{},...g.placeable===void 0?{}:{placeable:g.placeable}}},A);Vo(f,[I.manifestPath,I.registryPath,...Ef(e)]);let p=Ga(await c()).find(x=>x.assetId===j.assetId);if(!p)throw new Error("asset_import_catalog_projection_missing");return{asset:p,disposition:D.some(x=>x.assetId===j.assetId)?"deduplicated":"created"}})}async function s(f){let{projectAssetRegistryConfig:g,projectTextureRegistryConfig:b}=await m(),S=_I({assetRegistryConfig:g,textureRegistryConfig:b,loadAssetCatalogEntries:c,createAssetLibrary:y=>Po(y.filter(I=>I.kind==="texture"||I.kind==="model"&&I.placeable===!0)),additionalInvalidationFiles:Ef(e),invalidateFiles(y){Vo(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(Ga(S),b.availabilityIssues??[]);return An(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(`${Hj(Ko(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 Wj(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=Ko(e,t.importedDir),n=Ko(e,t.generatedDir),o=Un.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:Un.join(n,"asset-catalog.manifest.json"),registryPath:Un.join(n,"asset-catalog.generated.ts"),scenePath:Ko(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:Ko(e,t.editorScene)}:{},supportedExtensions:Fo,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=Un.join(r,s,i);return Un.relative(n,c).split(Un.sep).join("/")},resolveAssetMetadata(a){return Si({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function Ef(e){return(e.additionalInvalidationFiles??[]).map(t=>Ko(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 qj,readFileSync as Jj}from"node:fs";import{mkdir as Xj,writeFile as Yj}from"node:fs/promises";import If from"node:path";function cP(e,t){let r=e.source.rendering,n=r?If.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>If.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:Qj,async handleRoute(a){return n?QE({method:Zj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:qj(n)?JSON.parse(Jj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return id([n],async()=>(await Xj(If.dirname(n),{recursive:!0}),await Yj(n,`${JSON.stringify(i,null,2)}
19
+ `,"utf8"),Vo(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Zj(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 eN}from"node:crypto";import{realpath as tN}from"node:fs/promises";import{createServer as rN}from"node:http";async function lP(e){let t=await tN(e.projectRoot),r=eN(),n=[...e.middlewares??[]],o=rN((c,d)=>{nN(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){Pf(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){Pf(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}Pf(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 nN(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function Pf(e,t,r){oN(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
+ `))}function oN(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}:{}}),Kn={kind:"texture"},uP={kind:"color"},aN={kind:"enum",values:["lit","unlit"]},iN={kind:"enum",values:["opaque","mask","blend"]},pP={lightingModel:aN,baseColor:{kind:"object",properties:{color:uP,texture:Kn,brightness:Ct(0),saturation:Ct(0),contrast:Ct(0),hue:Ct(-180,180)}},normal:{kind:"object",properties:{texture:Kn,strength:Ct(0)}},emission:{kind:"object",properties:{color:uP,intensity:Ct(0),texture:Kn,maskTexture:Kn}},alpha:{kind:"object",properties:{mode:iN,opacity:Ct(0,1),cutoff:Ct(0,1),texture:Kn}}},sN={kind:"object",properties:{...pP,metallic:Ct(0,1),roughness:Ct(0,1),metallicRoughness:{kind:"object",properties:{texture:Kn}},occlusion:{kind:"object",properties:{texture:Kn,strength:Ct(0)}}}},cN={kind:"object",properties:pP},dN={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}},lN={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}],Hn={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},gP=[Wo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Wo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),qo("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:[Ho("properties.baseColor.texture.textureAssetId","baseTexture")]}),vt("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Ho("properties.baseColor.texture.textureAssetId","baseTexture")]}),vt("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Ho("properties.baseColor.texture.textureAssetId","baseTexture")]}),vt("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Ho("properties.baseColor.texture.textureAssetId","baseTexture")]}),qo("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[Hn]),vt("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Hn,Ho("properties.normal.texture.textureAssetId","normalTexture")]}),Wo("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}),qo("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Wo("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"}]}),qo("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],uN=[...gP,vt("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[Hn]}),vt("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[Hn]}),qo("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[Hn]),qo("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[Hn]),vt("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Hn,Ho("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],xf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:sN,defaultProperties:dN,inspector:{sections:mP,fields:uN}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:cN,defaultProperties:lN,inspector:{sections:mP,fields:gP}}],_K=Af(xf);function Af(e){let t=new Map;for(let n of e){mN(n,t);let o=fN(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 Wo(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 Wo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function qo(e,t,r,n,o,a,i,s){return Wo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Ho(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function mN(e,t){if(!Zn(e.shaderId)&&!ia(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&&!gN(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.`);pN(e,a),o.add(a.path)}}function fN(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 pN(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 gN(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function bN(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function SP(e,t){let r=bN(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(!Tf(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(!Tf(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(!Tf(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 Tf(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var SN=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),yN=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 hN(new TextEncoder().encode(e))}function EP(e){return`sha256:${ud(JSON.stringify(e))}`}function hN(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=[...SN],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+yN[b]+a[b]>>>0,E=er(s,2)^er(s,13)^er(s,22),A=s&c^s&d^c&d,D=E+A>>>0;g=f,f=m,m=l,l=u+I>>>0,u=d,d=c,c=s,s=I+D>>>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 EN="fps.plugin.materials";function PP(e){let t=e?.[EN];if(t==null)return null;if(!Jo(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),TP(r)}function Df(e){return Af([...xf,...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(!Jo(r)||!Jo(r.definition)||!Jo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");Df(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)||!Jo(o.enumUniformValues)||!Jo(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 Jo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function AP(e){let t=jE(e.definition),r=PP(e.pluginSnapshots),n=Df(r),o=t.project,a=PN(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=xE({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:zg,detectRuntimeInputDrift:Vg,enrichEditorSceneDocumentAssets:nu,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:JI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:Bg,compileEditorSceneDocumentToSceneConfig:(S,y,I)=>$E(S,y,{...I,materialShaderDefinitions:n,readCustomTransformRuntimeData:E=>E?.transformType==="groundDecal"&&xN(E.groundDecal)?{groundDecal:ZE(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=>qn(y),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await TN(b.configureServer,a),lP({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function PN(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 TN(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 xN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Zr=await AP({projectRoot:process.cwd(),definition:MP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:MP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Zr||typeof Zr.serviceInstanceId!="string"||typeof Zr.internalUrl!="string"||typeof Zr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Zr.serviceInstanceId,internalUrl:Zr.internalUrl});var Mf=!0,wP=setInterval(()=>{Mf&&process.send?.({type:"heartbeat",serviceInstanceId:Zr.serviceInstanceId})},1e3);wP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(Mf=!1),e?.type==="test.start-heartbeat"&&(Mf=!0)});var DP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{DP||(DP=!0,clearInterval(wP),Zr.dispose().finally(()=>{process.exitCode=e==="SIGINT"?130:143}))});function AN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function MP(e){let t=JSON.parse(AN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}